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.

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 the Target. Currently, the thing is the only destination for sending commands. The concept Target 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 the User is defined as its subclass. The concept Owner is introduced for expanding this relationship in the future (e.g., adding admin accounts).
  • The Target can have multiple Schema. In the SDK implementation, multiple instances of the ThingIFAPI 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.

The following diagram illustrates the structure of command-related classes.

  • As explained in Action and Command Execution, the Command has multiple Action and ActionResult inside.
  • One Target is identified as the destination for sending commands. As already explained, the Target is an abstraction of the Thing. In the actual SDK, this is not implemented as a class reference. The SDK has the Target as an ID.

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 and Command when you are auto-executing a command.
    • It has a Predicate and ServerCode when you are auto-executing server code.

    The multiplicity of the Command and ServerCode must not be 0 at the same time. They are exclusive, so only one of them can be 1.

  • 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 the StatePredicate that covers the state comparison based condition, the ScheduleOncePredicate that covers the one-time schedule, and the SchedulePredicate that covers the recurring schedule.

  • The Trigger has a Command 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, and ServerCode is the same as that of the conceptual model. You will use a pair of Predicate and Command or Predicate and ServerCode.
  • The Predicate has a StatePredicate, ScheduleOncePredicate and SchedulePredicate as its subclass.
  • The StatePredicte for making the state comparison has a Condition and TriggersWhen 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). The TriggersWhen is the enum implementation-wise, so you will use it as an attribute of the class.
  • The ScheduleOncePredicate to designate a time has the scheduleAt 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 the schedule attribute inside. As explained in Recurring Schedule, it is a time condition to execute a trigger on the scheduled interval.
  • The Condition has the Clause 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 the And and Or.

Read the development guides (Android, iOS, JavaScript) for more details about the implementation.