Services

Introduction

There are two kinds of Services in Automate: UserServices and SystemServices.

SystemServices are mainly designed to implement a practical way of writing an interface between your custom SystemObjects and their corresponding resources (devices for example). For example, RpioService provide access to Raspberry Pi GPIO pins for RpioActuator and RpioSensor objects, and ArduinoService, correspondingly, provides access to Arduino devices for ArduinoActuator and ArduinoSensors. (Arduino and RPIO support are provided by extensions, see Extensions).

UserServices, on the other hand, provide user interfaces to the system. For example, WebService provides access to the system via web browser, TextUIService via IPython shell and RpcService via XmlRPC (remote procedure call) interface for other applications.

If not automatically loaded (services with autoload set to True), they need to be instantiated (contrary to SystemObject) outside the System, and given in the initialization of the system (services). For example of initialization and configuring of WebService, see “Hello World” in Automate.

Services Class Definitions

class automate.service.AbstractService[source]

Base class for System and UserServices

autoload = False

If set to True, service is loaded automatically (if not explicitly prevented in automate.system.System.exclude_services). Overwrite this in subclasses,

setup()[source]

Initialize service here. Define in subclasses.

cleanup()[source]

Cleanup actions must be performed here. This must be blocking until service is fully cleaned up.

Define in subclasses.

class automate.service.AbstractUserService[source]

Baseclass for UserServices. These are set up on startup. They provide usually user interaction services.

class automate.service.AbstractSystemService[source]

Baseclass for SystemServices. These are set up by when first requested by Sensor or other object.

Builtin Services

class automate.services.logstore.LogStoreService[source]

Provides interface to log output. Used by WebService.

log_level = None

Log level

log_length = None

Log length

most_recent_line = None

The most recent log line is always updated here. t Subscription to this attribute can be used to follow new log entries.

class automate.services.statussaver.StatusSaverService[source]

Service which is responsible for scheduling dumping system into file periodically.

dump_interval = None

Dump saving interval, in seconds. Default 30 minutes.

class automate.services.plantumlserv.PlantUMLService[source]

Provides UML diagrams of the system as SVG images. Used by WebService.

PLantUMLService requires either PlantUML software (which is opensource software written in Java) to be installed locally (see http://plantuml.sourceforge.net/) or it is possible to use online service of plantuml.com In addition you need python package plantuml (available via PYPI).

url = None

URL of PlantUML Java Service. To use PlantUML online service, set this to ‘http://www.plantuml.com/plantuml/svg/

arrow_colors = None

Arrow colors as HTML codes stored as a dictionary with keys: controlled_target, active_target, inactive_target, trigger

background_colors = None

Background colors as HTML codes, stored as a dictionary with keys: program, actuator, sensor

write_puml(filename='')[source]

Writes PUML from the system. If filename is given, stores result in the file. Otherwise returns result as a string.

write_svg()[source]

Returns PUML from the system as a SVG image. Requires plantuml library.

class automate.services.textui.TextUIService[source]

Provides interactive Python shell frontend to the System. Uses IPython if it is installed. Provides couple of functions to the System namespace.

ls(what)[source]

List actuators, programs or sensors (what is string)

lsa()[source]

List actuators

lsp()[source]

List programs

lss()[source]

List sensors

help(*args, **kwargs)[source]

Print Automate help if no parameter is given. Otherwise, act as pydoc.help()

text_ui()[source]

Start Text UI main loop