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

The lifecycle of models consists of several 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)

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 (need conformation).

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.

 

Models are defined by using ThingModel, AppModel or DataModel types.

ThingModel
<ThingModel Name="TempSensor" combines="TempFacetSerial">
       <Sid Name="sensorId" />
</ThingModel>

 

 

Once Model definitions are deployed in the engine, engine creates the meta data for the models in the storage defined in the deployment script.

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>
        ...

 

Models are only definitions like Schema in database. Once the models are defined, instances can be created by using 'Create' or 'Save'. Instances are data and workflow instances. data is always persisted in the storage, but workflow remains in the memory.

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>

 

In data centeric world, sometimes partioning between model and instances can be grey. In purety, model is something, where every essential attribute is not defined yet.  In other words, any instance can be defined with only partial attributes of the model, as long as model declares it legal. In TQLEngine, instances are created only through create or save query.

Clarify the relationship/dependencies between model lifecycle and workflow lifecycle (if a workflow is defined within a action in the model)

When model is deployed, its definition along with action workflows are staged in memory as per the modifier limit. As when instance gets created, workflows may get activated, if actionable attribute is updated. Modifier - live decides on number of active instances of the workflows. When workflow is done executing the tasks, it will get trashed. If any of the task is marked as 'while="true"', that will maintain the workflow in the active state for ever.

 

 

  • No labels