Automate ComponentsΒΆ

Inheritance diagram of automate.program.Program, automate.program.DefaultProgram, automate.statusobject.StatusObject, automate.statusobject.AbstractSensor, automate.statusobject.AbstractActuator, automate.callable.AbstractCallable, automate.service.AbstractService

Automate system is built of the following components:

  • System (derived by user from System) binds all parts together into a single state machine
  • Services (subclassed of AbstractService) provide programming interfaces with user and devices that can be used by SystemObjects.
  • SystemObjects (subclassed of SystemObject or ProgrammableSystemObject):
    • Sensors (subclassed on AbstractSensor) are used as an interface to the (usually read-only) state of device or software.
    • Actuators (subclassed on AbstractActuator) are used as an interface to set/write the state of device or software.
    • Programs (subclassed on ProgrammableSystemObject) define the logic between Sensors and Actuators. They are used to control statuses of Actuators, by rules that are programmed by using special Callables (subclasses of AbstractCallable) objects that depend on statuses of Sensors and other components. Also Sensors and Actuators are often subclassed from ProgrammableSystemObject so they also have similar features by themselves. Depending on the application, however, it might (or might not) improve readability if plain Program component is used.

All Automate components are derived from HasTraits, provided by Traits library, which provides automatic notification of attribute changes, which is used extensively in Automate. Due to traits, all Automate components are configured by passing attribute names as keyword arguments in object initialization (see for example attributes pin and dev traits of ArduinoDigitalActuator in the example below).

Automate system is written by subclassing System and adding there desired SystemObject as its attributes, such as in the following example:

from automate import *
class MySystem(System):
  mysensor = FloatSensor()
  myactuator = ArduinoDigitalActuator(pin=13, dev=0)
  myprogram = Program()
  ...

After defining the system, it can be instantiated. There, services with their necessary arguments can be explicitly defined as follows:

mysys = MySystem(services=[WebService(http_port=8080), ArduinoService(dev='/dev/ttyS0')])

Some services (those that have autoload atribute set to True) do not need to be explicitly defined. For example, ArduinoService would be used automatically loaded because of the usage of ArduinoDigitalActuator, with default settings (dev='/dev/ttyUSB0'). Instantiating System will launch IPython shell to access the system internals from the command line. This can be prevented, if necessary, by defining keyword argument exclude_services as ['TextUIService'], which disables autoloading of TextUIService. For further information about services, see Services.