edit plugin readme Issue #40

remove interface.txt - all infos now in the plugins/readme.md
This commit is contained in:
Schrolli 2015-07-08 09:44:13 +02:00
parent 1ab3b61ef4
commit 07872ac817
2 changed files with 27 additions and 123 deletions

View file

@ -4,7 +4,9 @@ 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`
You can find a little template plugin file in `plugins/template/template.py` But you can also take a look in all other plugins.
A plugin must be in an seperate folder with the same name of the .py file
#### 1.2 Plugin Init `.onLoad()`
This `.onLoad()` routine is called one time for initialize the plugin
@ -12,6 +14,8 @@ 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
Here are the information from BOSWatch available. See section `5. Process the data from BOSWatch`
## 2. Use Global Logging
#### 2.1 Init and Use
@ -30,7 +34,7 @@ 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
all messages to find errors and for the internal program flow
`info`
messages that serve only to inform the user
@ -80,37 +84,51 @@ VALUE = globals.config.getboolean("SECTION", "OPTION") #Value must be an Boolean
## 4. Global helper functions
#### 4.1 timeHandler.py
#### 4.1 configHandler.py
First you must include the helper file
```python
from includes.helper import configHandler
```
##### 4.1.1 `.checkConfig(section)`
This function read all options from a config section and prints it to the debug log. The return value is `true`, also the section var is empty. In case of error a `false` is returned and error printed to log.
```python
if configHandler.checkConfig("template"): #check config file
########## User Plugin CODE ##########
pass
```
#### 4.2 timeHandler.py
First you must include the helper file
```python
from includes.helper import timeHandler
```
##### 4.1.1 `.curtime(format)`
##### 4.2.1 `.curtime(format)`
```python
timeHandler.curtime() # returns a formated datetime string
```
you can give the function an format string. See https://docs.python.org/2/library/time.html#time.strftime
default (without format parameter) the function returns a date time with this format `%d.%m.%Y %H:%M:%S`
##### 4.1.2 `.getDate()`
##### 4.2.2 `.getDate()`
```python
timeHandler.getDate() # returns the current date in format `%d.%m.%Y`
```
##### 4.1.3 `.getTime()`
##### 4.2.3 `.getTime()`
```python
timeHandler.getTime() # returns the current time in format `%H:%M:%S`
```
##### 4.1.4 `.getTimestamp()`
##### 4.2.4 `.getTimestamp()`
```python
timeHandler.getTimestamp() # returns the current linux timestamp
```
#### 4.2 wildcardHandler.py
#### 4.3 wildcardHandler.py
First you must include the helper file
```python
from includes.helper import wildcardHandler
```
##### 4.2.1 'replaceWildcards(text,data)'
##### 4.3.1 `.replaceWildcards(text,data)`
```python
wildcardHandler.replaceWildcards(text,data) # replace all standard wildcards
```

View file

@ -1,114 +0,0 @@
Handover to Plugin:
-------------------
typ = [FMS|ZVEI|POC]
freq = [Freq in Hz]
data = {"KEY1":"VALUE1","KEY2":"VALUE2"}
The following informations are included in the var "data".
They can be used by their Index Names: data['OPTION']
ZVEI:
- zvei
- description
FMS:
- fms
- status
- direction
- directionText
- tsi
- description
POCSAG:
- ric
- function
- functionChar
- msg
- bitrate
- description
Global Objects:
---------------
1.)
import logging # Global logger
Message into Log: logging.LOGLEVEL("MESSAGE")
Loglevel: debug|info|warning|error|exception|critical
2.)
import globals # Global variables
reads Data from the config.ini
VALUE = globals.config.get("SECTION", "OPTION")
General for plugins:
--------------------
All Plugins have to implement the following functions (see template.py):
def onLoad():
"""
While loading the plugins by pluginLoader.loadPlugins()
this onLoad() routine is called one time for initialize the plugin
@requires: nothing
@return: nothing
@exception: Exception if init has an fatal error so that the plugin couldn't work
"""
def run(typ,freq,data):
"""
This function is the implementation of the Plugin.
If necessary the configuration hast to be set in the config.ini.
@type typ: string (FMS|ZVEI|POC)
@param typ: Typ of the dataset
@type data: map of data (structure see interface.txt)
@param data: Contains the parameter for dispatch
@type freq: string
@keyword freq: frequency of the SDR Stick
@requires: If necessary the configuration hast to be set in the config.ini.
@return: nothing
@exception: nothing, make sure this function will never thrown an exception
"""
Global Functions for plugins:
-----------------------------
# for format see https://docs.python.org/2/library/time.html#time.strftime
#
from includes.helper import timeHandler
timeHandler.curtime("FORMAT") # without format string the function returns with "%d.%m.%Y %H:%M:%S"
timeHandler.getDate() # Gets the date in "%d.%m.%Y"
timeHandler.getTime() # Gets the time in %H:%M:%S
timeHandler.getTimestamp() # Gets a integer timestamp
# replace all the standard wildcards in the given text
# the function needs the data[] var
# %TIME% = Time (by script)
# %DATE% = Date (by script)
#
# %FMS% = FMS Code
# %STATUS% = FMS Status
# %DIR% = Direction of the telegram (0/1)
# %DIRT% = Direction of the telegram (Text-String)
# %TSI% = Tactical Short Information (I-IV)
#
# %ZVEI% = ZVEI 5-tone Code
#
# %RIC% = Pocsag RIC
# %FUNC% = Pocsac function/Subric (1-4)
# %FUNCCHAR% = Pocsac function/Subric als character (a-d)
# %MSG% = Message of the Pocsag telegram
# %BITRATE% = Bitrate of the Pocsag telegram
# %DESCR% = Description from csv-file
#
from includes.helper import wildcardHandler
wildcardHandler.replaceWildcards("TEXT",data[])