Class Structure
This page explains the class structure of the objects that Thing Interaction Framework and its SDK are based on.
Note that the structure presented on this page is the conceptual model unless stated otherwise, so it may be different from the class relationship in the SDK.
Structure of thing-related classes
The following diagram illustrates the structure of thing-related classes. The structure is hidden under the ThingIFAPI
class implementation-wise.
- The
Thing
, the subject to be controlled, is represented as a subclass of theTarget
. Currently, the thing is the only destination for sending commands. The conceptTarget
is introduced to expand the destination in the future (i.e., sending commands to mobile applications and other types of devices). - The thing owner is represented as the
Owner
, and theUser
is defined as its subclass. The conceptOwner
is introduced for expanding this relationship in the future (e.g., adding admin accounts). - The
Target
can have multipleSchema
. In the SDK implementation, multiple instances of theThingIFAPI
will be generated and each of them will have one schema. - The
Target
can have triggers, commands, and state with the multiplicity shown in the diagram.
Structure of command-related classes
The following diagram illustrates the structure of command-related classes.
- As explained in Action and Command Execution, the
Command
has multipleAction
andActionResult
inside. - One
Target
is identified as the destination for sending commands. As already explained, theTarget
is an abstraction of theThing
. In the actual SDK, this is not implemented as a class reference. The SDK has theTarget
as an ID.
Structure of trigger-related classes
The following diagram illustrates the structure of thing-related classes.
The
Trigger
is a class used for the trigger execution explained in Auto Execution with Triggers.- It has a
Predicate
andCommand
when you are auto-executing a command. - It has a
Predicate
andServerCode
when you are auto-executing server code.
The multiplicity of the
Command
andServerCode
must not be 0 at the same time. They are exclusive, so only one of them can be 1.- It has a
The
Predicate
corresponds to a "predicate" of the predicate logic, and it represents a function that returns if the trigger execution condition is satisfied or not. It can have theStatePredicate
that covers the state comparison based condition, theScheduleOncePredicate
that covers the one-time schedule, and theSchedulePredicate
that covers the recurring schedule.The
Trigger
has aCommand
when auto-executing the command, but this is merely the template of the command. The actual command for the execution is created using this template.
The next diagram illustrates how the Trigger
and subsequent classes are implemented in the SDK. All class names are from the Android SDK. The iOS SDK also has the same structure, but some of the class names are different.
- The relationship between
Predicate
,Command
, andServerCode
is the same as that of the conceptual model. You will use a pair ofPredicate
andCommand
orPredicate
andServerCode
. - The
Predicate
has aStatePredicate
,ScheduleOncePredicate
andSchedulePredicate
as its subclass. - The
StatePredicte
for making the state comparison has aCondition
andTriggersWhen
inside. As explained in State Condition, they correspond to the comparison condition (what to compare) and the execution condition (how to associate the condition to the command execution). TheTriggersWhen
is the enum implementation-wise, so you will use it as an attribute of the class. - The
ScheduleOncePredicate
to designate a time has thescheduleAt
attribute inside. As explained in One-Time Schedule, it is a time condition to execute a trigger once. - The
SchedulePredicate
to designate a time has theschedule
attribute inside. As explained in Recurring Schedule, it is a time condition to execute a trigger on the scheduled interval. - The
Condition
has theClause
that is a root of the tree structure. You can define the condition using its subclasses (e.g.,Equals
,NotEquals
). You can use the recursion for theAnd
andOr
.
Read the development guides (Android, iOS, JavaScript) for more details about the implementation.