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 10 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)

Update: 

Delete

Explain the lifecycle of models (ThingModel, AppModel, DataModel). From definition, to instantiation, to updates/modification, or delete, to triggering of actions.

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