Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

There are three types of Models that can be defined at the time of creating models for your IoT applications. The three models are:

  • DataModel
  • ThingModel
  • AppModel

Model lifecycle consists of three steps

  • Definition - Models are defined either using TQLStudio Model Editor or any IDE of your choice. Modeling Language (Thing Definition Language) is essential to define models.
  • Deploy - As part of a deployable unit within TQLEngine's package file. Models definitions are made part of SffTqlFacet Facet type.
  • Query - Querying of model consists of CRUD as well as Subscription (and notification).

Model Instances

Once models are defined and deployed their schematic layout is persisted in Storage (TQL Cache) defined at the time of the deployment. Note that even though models are persisted in SQL type of storage that data is highly unstructured and stored in proprietary format.

Before Models can be queried using Find - Models must be initialized or populated with data. The result of model creation is called Model Instances.

For example: Here is the definition of a ThingModel - PhidgetSensorModel that combines PhidgetSensorFacet. 

 

PhidgetSensor Thing Model
<ThingFacet Name="PhidgetSensorFacet">
  <Integer Name="SensorValue" Update="auto" KnownBy="PhidgetSensorAction"/>
  <String Name="SensorURL" Default="phid://"/>
  <String Name="SensorInterfaceIndex"/>
  <String Name="SensorType"/>
  <String Name="SensorInterfaceType"/>
  <String Name="SensorValueFormat"/>
  <String Name="Simulated"/>
</ThingFacet>
<ThingModel Name="PhidgetSensorModel" Combines="PhidgetSensorFacet">
  <Sid Name="phidId"/>
</ThingModel>

The instances of PhidgetSensorModel is created using Create TQL Query. 

Create PhidgetSensor ThingModel Instance
<Query>
  <Create>
    <PhidgetSensors>
      <SensorURL>phid://</SensorURL>
      <SensorType>Rotation</SensorType>
      <SensorInterfaceType>PhidgetInterfaceKit</SensorInterfaceType>
      <SensorValueFormat>Raw</SensorValueFormat>
      <SensorInterfaceIndex>0</SensorInterfaceIndex>
      <SensorValue value="$Null()" version="1"/>
      <Simulated>true</Simulated>
    </PhidgetSensors>
  </Create>
</Query>

The Result of Model Instance Creation is:

 

Automatically generated System Attributes

  
  
  
  

 

 

  • No labels