Skip to content

Developing custom plugins

sceeter89 edited this page Jun 8, 2015 · 2 revisions

Development

To develop custom sensor or motor you need to create a yapsy-plugin, which basically means:

  1. Copy template from plugin/templates directory, and give it appropriate name, .yapsy-plugin file must have name matching directory name.
  2. Update information in yapsy-plugin file
  3. Mandatory fields are in Core section: 1. Name - plugin's name, that will be logged if something noticeable happens to plugin 1. Module - name of plugin's directory, or file name if it's single file plugin 1. Key - short-hand, unique name, that will be used to clearly identify plugin. Only one plugin with given name will be loaded. This is also string that motors will use to access some concrete sensor from system state. It also means, that you cannot enter key that matches built-in sensor name. Keys are case-insensitive. 1. Last chance - this parameter is valid only for motor plugins. If you set this parameter to True then this motor will be executed during last loop when application is terminated. This might be useful for motors to shutdown corresponding devices or send notification that system is shutting down.

Generally command_center will "swallow" all exceptions thrown in sensor/motor, log them and eventually disable plugin if it does not work properly. There are two exceptions:

  1. If you press Ctrl+C, then command_center will shutdown gracefully, so you may kill it from console.
  2. If, for some reason, you really want application to stop (probably due to some hardware failure, or alert) you can throw TerminateApplication error which will force application to stop.

Shutdown procedure is as follows:

  1. Finish current loop
  2. Set termination built-in sensor
  3. Execute final loop only for motors declared as last chance. When you declare such a motor please notice, that in last loop state will only contain built-in sensors, so be prepared for missing custom sensors state.
  4. Terminate application

Application flow

Sensors, then motors, if too much fails then disabled and logged information about all exceptions. Conditions when disabled.

Sensors

About sensors.

Writing custom sensor

Motors

About motors.

Writing custom motor

Clone this wiki locally