BOSWatch/plugins
2015-07-07 14:24:41 +02:00
..
BosMon remove trailing whitespace 2015-07-02 09:02:49 +02:00
eMail solve issue #41: support more than one recipient 2015-07-03 23:43:22 +02:00
firEmergency insert little docu into firEmergency Plugin 2015-07-05 09:02:21 +02:00
httpRequest insert wildcardHandler.replaceWildcards() in httpReq Plugin 2015-07-07 13:17:18 +02:00
jsonSocket remove trailing whitespace 2015-07-02 09:02:49 +02:00
MySQL move helper functions in seperate folder and split to logical files 2015-07-02 15:16:24 +02:00
template edit plugin readme Issue #40 2015-07-07 14:08:46 +02:00
interface.txt insert helper function timeHandler.getTimestamp() 2015-07-02 21:39:43 +02:00
README.md edit plugin readme Issue #40 2015-07-07 14:24:41 +02:00

How to Code your own plugin:

More information and a little Tutorial coming soon!

1. Plugin template

1.1 General

You can find a little template plugin file in plugins/template/template.py

1.2 Plugin Init .onLoad()

This .onLoad() routine is called one time for initialize the plugin

1.3 Plugin call .run()

This .run() routine is called every time an alarm comes in

2. Use Global Logging

2.1 Init and Use

First you must import the logging module

import logging # Global logger

Now you can send log messages with:

logging.LOGLEVEL("MESSAGE")

You must replace the word LOGLEVEL with one if the following debug, info, warning, error, exception or critical

To use the right loglevel see next section 2.2 Choose right Loglevel

2.2 Choose right Loglevel

debug all messages to find errors and for the internal program flow

info messages that serve only to inform the user

warning

error error does not lead to the end of boswatch

Exception

critical errors leading to the end of boswatch immediate - in plugins not allowed

3. Use config file

3.1 Own configuration in config.ini

First you must set a new Section in config.ini A section is between brackets. Its recommended to give the section the same name as the plugin. [SECTION_NAME]

Now you can an set a unlimited number of options with its own value in these format: OPTION = VALUE.

Here is the sample from the template plugin:

[template]
test1 = testString
test2 = 123456
3.2 Read data from config.ini

To read yout configuration data you must import the globals.py where the global config-object is located:

from includes import globals  # Global variables

Now you can get your configration data with:

VALUE = globals.config.get("SECTION", "OPTION") #Gets any value

or better, use this:

VALUE = globals.config.getint("SECTION", "OPTION") #Value must be an Integer
VALUE = globals.config.getfloat("SECTION", "OPTION") #Value must be an Float
VALUE = globals.config.getboolean("SECTION", "OPTION") #Value must be an Boolean

4. Global helper functions

4.1 timeHandler.py
4.2 wildcardHandler.py

5. Process the data from BOSWatch

Three parameters are passed during the alarm to the .run() method

5.1 typ

Thats the function of the alarm. Possible values are FMS, ZVEI or POC

5.2 freq

The reception frequency of the tuner in Hz

5.3 data[ ]