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 16 Next »

The lifecycle of models consists of the following stages:

Definition: a model is developed using Thing Definition Language.

Compilation: a model is deployed to TQLEngine and the definition is compiled

Instantiation: model instance(s) are created when model attribute values are provided (by Create/Save queries). Model instance data is always persisted in the storage (but workflow instances remain in the memory).

Updated: changes to the model instance attributes will result in updates of the model instance data in the storage. Updates can happen in two ways:

(1) modifying the attribute's value. Attribute values can be modified by queries (Update or Save queries). This type of update will in turn activate the associated action and workflow if the attribute is an actionable attribute.

(2) modifying the attribute's known (known value).This type of modifications happen when the output of an action/workflow is used to update the Attribute. These updates will NOT activate any action.

Deleted: the model instance is removed. This is done by a DeleteAll query.

In ThingModels and AppModels, model lifecycle is closely linked to the workflow lifecycle (DataModels do not have Actions or workflows).

 

Models can be "partially" instantiated. That is, if some, but not all attribute values are given, then model instance(s) will still be created with the attributes which have value. The other attribute values can be provided later as model instance updates.

Example of a Create query to instantiate a TempSensor model.

Model Instantiation
<Create format="version,current"> <!-- This will create -->
   <TempSensor>
            <peripheral>serial</peripheral>
            <baudrate>115200</baudrate>
            <interfacePort>/dev/cu.usbserial-AL01C0ME</interfacePort>
            <interface>serial</interface>
            <format>ascii</format>
            <operation>receive</operation>
            <uniqueId>76522</uniqueId>
            <payload>$Null()</payload>
            <tempValue>$Null()</tempValue>
    </TempSensor>
</Save>

For update and delete, see common CRUD operations on models.

Model instance data

TQLEngine maintains model instances data in the storage (TQLCache) based on the model definition (the model definition itself is not stored, but held in memory). The model instance data storage type is defined in the deployment script. For example, the the deployment script below, the <Process> points to the [:ModelFile:], which will be replaced by the model definition file name at the time of deployment. The Type="Sqlsff" defines that storage type is the SFF unstructured SQL database.

Model instance data may also be stored in external databases (SQL or NoSQL) by providing the connecting string to the <Storage>.

Model Deployment
<NewFacetInstance fid="[:FacetIDName:]"
        Name="[:FacetInstanceName:]" Type="SffTqlFacet">
        <OnActivate>
            <NewFacetInstance name="tqlwf" type="SffWdlFacet" />
            <TopicFacet>?TQLGenericTopic</TopicFacet>
            <Process>
                <Storage Name="[:TQLCacheName:]"
                    Type="SqlSff"
                    Comment="[:TQLCacheName:] Database SFF Unstructured SQL database" />
                <Namespace>
                    <Include>[:ModelFile:]</Include> <!-- ModelFile contains the definition for the model -->
                </Namespace>
            </Process>
        </OnActivate>
        ...

 

 

  • No labels