From 1d65f9fb97ca5586e5b2589365851391313e6f22 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Tue, 7 Jul 2015 14:08:46 +0200 Subject: [PATCH] edit plugin readme Issue #40 --- README.md | 6 ++-- plugins/README.md | 57 ++++++++++++++++++++++++++++++++++-- plugins/template/template.py | 35 ++++++++++------------ 3 files changed, 73 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 1e8bd6a..3c2ed6a 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,8 @@ Thanks to smith_fms and McBo from Funkmeldesystem.de - Forum for Inspiration and ### Code your own Plugin -To code your own Plugin look at the litte example `/plugins/template/template.py` +See `plugins/README.md` -In the text-file `plugins/interface.txt` are all relevant data, that your plugin can use. +~~To code your own Plugin look at the litte example `/plugins/template/template.py`~~ + +~~In the text-file `plugins/interface.txt` are all relevant data, that your plugin can use.~~ diff --git a/plugins/README.md b/plugins/README.md index 71818be..98b2edb 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -2,7 +2,58 @@ More information and a little Tutorial coming soon! -##### Code your own Plugin -To code your own Plugin look at the litte example `/plugins/template/template.py` +### Plugin template +##### General +You can find a little template plugin file in `plugins/template/template.py` +##### .onLoad() +This onLoad() routine is called one time for initialize the plugin +##### .run() +This onLoad() routine is called every time an alarm comes in -In the text-file `plugins/interface.txt` are all relevant data, that your plugin can use. +### Use Global Logging +##### Init and Use +##### Choose right Loglevel + +### Use config file +##### 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: +```python +[template] +test1 = testString +test2 = 123456 +``` + +##### Read data from config.ini +To read yout configuration data you must import the `globals.py` where the global config-object is located: +```python +from includes import globals # Global variables +``` + +Now you can get your configration data with: +```python +VALUE = globals.config.get("SECTION", "OPTION") #Gets any value +``` +or better, use this: +```python +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 +``` + + +### Global helper functions +##### timeHandler.py +##### wildcardHandler.py + +### Process the data from BOSWatch +Three parameters are passed during the alarm to the .run() method +##### typ +Thats the function of the alarm. Possible values are **FMS**, **ZVEI** or **POC** +##### freq +The reception frequency of the tuner in Hz +##### data[ ] diff --git a/plugins/template/template.py b/plugins/template/template.py index 68581bc..7218ced 100644 --- a/plugins/template/template.py +++ b/plugins/template/template.py @@ -1,29 +1,24 @@ #!/usr/bin/python # -*- coding: cp1252 -*- -######### -# USAGE -# -# Config -# ====== -# to read a option from config File -# VALUE = globals.config.get("SECTION", "OPTION") -# -# Data from boswatch.py -# ===================== -# use data["KEY"] for Alarm Data from boswatch.py -# for usable KEYs in different Functions (FMS|ZVEI|POC) see interface.txt -# -# LOG Messages -# ============ -# send Log Messages with logging.LOGLEVEL("MESSAGE") -# usable Loglevels debug|info|warning|error|exception|critical -# if you use .exception in Try:Exception: Construct, it logs the Python EX.message too +""" +template plugin to show the function and usage of plugins +@author: Jens Herrmann +@author: Bastian Schroll + +@requires: none +""" + +# +# Imports +# import logging # Global logger - from includes import globals # Global variables -#from includes import helper #Global helper functions + +# Helper function, uncomment to use +#from includes.helper import timeHandler +#from includes.helper import wildcardHandler ## #