modules package¶
Submodules¶
modules.database module¶
Connectivity modules for various NoSQL databases.
-
class
modules.database.
CouchDriver
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
CouchDriver provides connectivity for Apache CouchDB. Observations send to a CouchDriver instance will be cached and then stored in the database defined the configuration. TinyDB is used for caching (either file-based or in-memory).
The JSON-based configuration for this module:
- Parameters
server (str) – FQDN or IP address of CouchDB server.
path (str) – Additional CouchDB instance path or blank.
port (int) – Port number of CouchDB server.
user (str) – User name.
password (str) – Password.
db (str) – Database name.
tls (bool) – Use TLS encryption (default: False).
cacheFile (str) – Optional file name of local cache database (e.g., cache.json). If not set, an in-memory database will be used instead.
-
has_cached_observation_data
() → bool¶ Returns whether or not a cached observation exists in the local cache database.
- Returns
True if cached observation exists, False if not.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
-
run
() → None¶ Inserts cached observation data into CouchDB database.
-
start
() → None¶ Starts the module.
-
class
modules.database.
TinyDriver
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
TinyDriver stores observations in a TinyDB document store.
The JSON-based configuration for this module:
- Parameters
path (str) – Path to the database file.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
modules.export module¶
Module for the export of observations.
-
class
modules.export.
CloudExporter
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
CloudExporter sends observation data to an OpenADMS Server instance. Observations are cached locally in case the service is temporary not reachable and then send again. Caching can be done either in-memory or file-based. In-memory is faster and requires less I/O operations, but cached observations do not persist over restarts (data loss may be occur).
The JSON-based configuration for this module:
- Parameters
server – FQDN of the OpenADMS Server instance.
user – User name for OpenADMS Server (HTTP Basic Auth).
password – Password for OpenADMS Server (HTTP Basic Auth).
db – Path to the cache database file (e.g.: cache.json).
cache – Caching type (either file or memory).
Example
The configuration may be:
{ "server": "https://api.examples.com/", "user": "test", "password": "secret", "db": "cache.json", "cache": "file" }
-
has_cached_observation
() → bool¶ Returns whether or not a cached observation exists in the database.
- Returns
True if cached observation exists, False if not.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Caches observation object locally.
- Parameters
obs – Observation object.
- Returns
The observation object.
-
run
() → None¶ Sends cached observation to RESTful service.
-
start
() → None¶ Starts the module.
-
class
modules.export.
FileExporter
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
FileExporter writes sensor data to a flat file in CSV format.
The JSON-based configuration for this module:
- Parameters
dateTimeFormat (str) – Format of date and time (see arrow library).
fileExtension (str) – Extension of the file (
.txt
or.csv
).fileName (str) – File name with optional placeholders
{{date}}
,{{target}}
,{{name}}
,{{port}}
.fileRotation (str) – Either
none
,daily
,monthly
, oryearly
.paths (List[str]) – Paths to save files to (multiple paths possible).
separator (str) – Separator between values within the CSV file.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Appends data to a flat file in CSV format.
- Parameters
obs – Observation object.
- Returns
The Observation object.
-
class
modules.export.
FileRotation
¶ Bases:
enum.Enum
Enumeration of file rotation times of flat files.
-
DAILY
= 1¶
-
MONTHLY
= 2¶
-
NONE
= 0¶
-
YEARLY
= 3¶
-
-
class
modules.export.
RealTimePublisher
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
RealTimePublisher forwards incoming Observation objects by MQTT to a list of receivers.
The JSON-based configuration for this module:
- {
- “realTimePublisher”: {
“enabled”: true, “topics”: [
“onlineViewer”
]
}
}
- Parameters
enabled (bool) – Turns processing of observations on or off.
topics (List) – List of topics to send the observations to.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
modules.notification module¶
Module for notifications and alerting.
-
class
modules.notification.
AlertMessageFormatter
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
AlertMessageFormatter caches and formats alerts. They are then forwarded to other modules for further processing and transmission.
- Parameters
messageCollectionEnabled (bool) – If true, cache alert messages.
messageCollectionTime (float) – Time to cache messages before sending.
properties (Dict) – Additional properties to add to the message.
receiver (str) – Name of the receiving module.
templates (Dict) – Templates for header, body, and footer.
type (str) – Type of the message to be send (email, sms, etc.).
-
handle_alert_message
(header: Dict[str, Any], payload: Dict[str, Any]) → None¶ Handles messages of type alert and either caches them or forwards them to the process_alert_messages() method.
- Parameters
header – The alert header.
payload – The alert payload.
-
process_alert_messages
(receiver: str, alerts: List[Dict[str, str]]) → None¶ Parses a template and fills values of an alert message into header, body, and footer. The parsed template is forwarded to an agent (e-mail, SMS, …).
- Parameters
receiver – The receiver of the alert.
alerts – The list of alert messages.
-
run
() → None¶ Processes the cached alert messages.
-
start
() → None¶ Starts the worker.
-
class
modules.notification.
Alerter
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
Alerter is used to send warning and error messages to other modules.
The JSON-based configuration for this module:
- Parameters
enabled (bool) – If true, alerter is enabled.
modules (Dict) – Modules to send alert messages to.
-
fire
(record: logging.LogRecord) → None¶
-
run
() → None¶
-
start
() → None¶ Starts the worker.
-
class
modules.notification.
Camera
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
Camera captures pictures using an attached digital camera or webcam and forwards them to a given MQTT topic.
-
run
() → None¶
-
start
() → None¶ Starts the worker.
-
-
class
modules.notification.
CloudAgent
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
Sends logs messages to OpenADMS Server instances.
- Parameters
host (str) – URL or IP address of OpenADMS Sever instance.
user (str) – OpenADMS Server user name.
password (str) – OpenADMS Server password.
-
handle_alert_message
(header: Dict[str, Any], payload: Dict[str, Any]) → None¶ Caches messages of type alert.
- Parameters
header – The alert header.
payload – The alert payload.
-
run
() → None¶ Processes the cached alert messages.
-
start
() → None¶ Starts the worker.
-
class
modules.notification.
Heartbeat
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
Heartbeat sends heartbeat messages (“pings”) to OpenADMS Server instances. A HTTP PUT request is made to <host>/api/v1/heartbeats/.
The JSON-based configuration for this module:
- Parameters
host (str) – IP address or FQDN of OpenADMS Server instance.
user (str) – User name (HTTP BasicAuth).
password (str) – Password (HTTP BasicAuth).
frequency (int) – Heartbeat frequency in seconds.
-
run
() → None¶
-
start
() → None¶ Starts the worker.
-
class
modules.notification.
IrcAgent
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
IrcAgent sends alert messages to the Internet Relay Chat. This module acts as a simple IRC bot which connects to an IRC server and sends text messages to a channel or user. Only a few commands of RFC 1459 are implemented.
The JSON-based configuration for this module:
- Parameters
channel (str) – IRC channel to join (e.g.:
#test
).host (str) – FQDN or IP address of IRC server.
port (int) – Port number of IRC server.
tls (bool) – If true, use TLS encryption.
nickname (str) – Nickname to use (default:
openadms
).password (str) – Password of registered nickname (optional).
target (str) – IRC channel or user to send messages to.
-
handle_irc
(header: Dict[str, Any], payload: Dict[str, Any]) → None¶ Handles messages of type irc and puts alert message on a queue.
- Parameters
header – The message header.
payload – The message payload.
-
run
() → None¶ Connects to IRC server, enters channel, and sends messages. Reacts to PING messages by the server.
-
start
() → None¶ Starts the worker.
-
class
modules.notification.
MailAgent
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
MailAgents sends e-mails via SMTP.
The JSON-based configuration for this module:
- Parameters
retryDelay (float) – Time to wait before resending after failure.
charset (str) – Character set of the email.
defaultSubject (str) – Default subject if no subject is given.
host (str) – FQDN or IP address of the SMTP server.
startTls (bool) – If true, use StartTLS encryption.
tls (bool) – If true, use TLS encryption.
port (int) – Port number of the SMTP server.
userMail (str) – Email address of the sender.
userName (str) – SMTP user name.
userPassword (str) – SMTP user password.
-
handle_mail
(header: Dict[str, Any], payload: Dict[str, Any]) → None¶ Handles messages of type email and forwards them to the process_mail() method.
- Parameters
header – The message header.
payload – The message payload.
-
process_mail
(mail_from: str, mail_to: str, mail_subject: str, mail_message: str) → None¶ Sends e-mails by SMTP.
- Parameters
mail_from – The sender of the email.
mail_to – The recipient of the email.
mail_subject – The subject of the email.
mail_message – The body text of the email.
-
class
modules.notification.
MastodonAgent
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
Mastodon sends toots to the Mastodon social network. Requires the Python module Mastodon.py.
The JSON-based configuration for this module:
- Parameters
email (str) – Login email address of Mastodon account.
password (str) – Login password of Mastodon account.
url (str) – URL of the Mastodon instance (e.g.: https://mastodon.at).
-
handle_mastodon
(header: Dict[str, Any], payload: Dict[str, Any]) → None¶ Uses the Mastodon API to send toots to the network.
- Parameters
header – The message header.
payload – The message payload.
-
class
modules.notification.
RssAgent
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
RSSAgent creates an RSS 2.0 feed out of given data.
The JSON-based configuration for this module:
- Parameters
author (str) – Author of the RSS feed.
description (str) – Description text of the RSS feed.
language (str) – Language of the RSS feed (e.g.: en-gb).
link (str) – URL to the RSS feed.
size (int) – Number of entries in the RSS feed.
title (str) – Title of the RSS feed.
-
escape
(html: str) → str¶ Returns the given HTML with ampersands, quotes, and carets encoded.
- Parameters
html – String with HTML special characters.
- Returns
Escaped string.
-
get_rss_feed
(vars: Dict[str, str], items: List[Dict[str, str]]) → str¶ Returns a string with the RSS 2.0 feed. Feed template is hard-coded into this method. Rather quick and dirty, but does the job.
- Parameters
vars – The variables to replace in the RSS template.
items – The items of the RSS feeds.
- Returns
The RSS 2.0 feed as a string.
-
handle_rss
(header: Dict[str, Any], payload: Dict[str, Any]) → None¶ Handles messages of type rss and forwards them to the process_rss() method.
- Parameters
header – The message header.
payload – The message payload.
-
parse
(template: str, **kwargs) → str¶ Substitutes placeholders in the template with variables from the given arguments.
- Parameters
template – The template.
kwargs – The key-value pairs.
- Returns
String with parsed template.
-
rfc_822
(date: str = None) → str¶ Returns a date string formatted as RFC 822. If no date is given, the current date is used.
- Parameters
date – A string with date and time in UTC.
- Returns
A string with of date and time as RFC 822.
-
write
(file_path: pathlib.Path, contents: str) → None¶ Writes string to file.
-
class
modules.notification.
ShortMessageAgent
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
ShortMessageAgent uses a socket connection to a GSM modem to send SMS.
The JSON-based configuration for this module:
- Parameters
host (str) – FQDN or IP address of the SMS server.
port (int) – Port number of the SMS server.
-
handle_short_message
(header: Dict[str, Any], payload: Dict[str, Any]) → None¶ Handles messages of type sms.
- Parameters
header – The message header.
payload – The message payload.
-
process_short_message
(number: str, message: str) → None¶ Sends an SMS to a socket server.
- Parameters
number – The number of the recipient (e.g., “+49 176 123456”).
message – The message text.
-
class
modules.notification.
StatusPublisher
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
StatusPublisher sends retained messages to a given topic of the MQTT server. The messages include project, node, and system information, as well as current uptime, loaded modules and sensors, and current timestamp.
The JSON-based configuration for this module:
- Parameters
topic (str) – MQTT topic to publish to.
interval (int) – Interval of status messages.
-
run
() → None¶
-
start
() → None¶ Starts the worker.
modules.port module¶
Module for sensor communication.
-
class
modules.port.
BluetoothPort
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
BluetoothPort is used for RFCOMM serial communication. It initiates a socket connection to a sensor by using the native Bluetooth support of Python 3.3. At the moment, the class is not very useful and needs further testing.
The JSON-based configuration for this module:
- Parameters
port (str) – Port name.
serverMacAddress (str) – MAC address of the server.
-
close
() → None¶ Closes the socket connection.
-
get_mac_address
(s: str) → Optional[str]¶ Re-formats a given MAC address.
- Parameters
s – String with MAC address.
- Returns
String with valid MAC address or None if address is invalid.
-
process_observation
(obs: core.observation.Observation) → Optional[core.observation.Observation]¶ Sends a request to the attached sensor and forwards the response.
- Parameters
obs – Observation object.
- Returns
The extended observation object or None if connection failed.
-
sanitize
(s: str) → str¶ Escapes some non-printable characters in a given string.
- Parameters
s – String to sanitize.
- Returns
Sanitized string.
-
class
modules.port.
FileSystemPort
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
This module has nothing to configure.
-
process_observation
(obs: core.observation.Observation) → Optional[core.observation.Observation]¶ Processes an observation object. Open files in file system and adds values to the observation.
- Parameters
obs – The observation object.
- Returns
The processed observation.
-
sanitize
(s: str) → str¶ Escapes some non-printable characters in a given string.
-
-
class
modules.port.
SerialPort
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
SerialPort does I/O on a given serial port. The port can be used in either active or passive mode. In active mode, the communication with the sensor is based on request/response. In passive mode, the port just listens for incoming data without sending any requests.
The JSON-based configuration for this module:
- Parameters
port (str) – Name of the port (e.g.: COM1 or /dev/tty0).
baudRate (int) – Baud rate (e.g.: 4800, 9600, or 115200).
byteSize (int) – Start bits, either 5, 6, 7, or 8.
stopBits (float) – Stop bits, either 1, 1.5, or 2.
parity (str) – Parity, either odd, even, or none.
softwareFlowControl (bool) – XON/XOFF flow control.
hardwareFlowControl (bool) – RTS/CTS flow control.
maxAttempts (int) – Maximum number of attempts to access the port.
timeout (float) – Timeout in seconds.
-
close
() → None¶
-
listen
(obs_draft: core.observation.Observation) → None¶ Threaded method for passive mode. Reads incoming data from serial port. Used for sensors which start streaming data without prior request.
- Parameters
obs_draft – The observation draft with the response pattern.
-
process_observation
(obs: core.observation.Observation) → Optional[core.observation.Observation]¶ Processes an observation object. Sends request to sensor and stores response.
- Parameters
obs – The observation object.
- Returns
The processed observation.
-
sanitize
(s: str) → str¶ Escapes some non-printable characters in a given string.
-
class
modules.port.
SerialPortConfiguration
(port: str, baudrate: int, bytesize: int, stopbits: float, parity: str, timeout: float, xonxoff: bool, rtscts: bool)¶ Bases:
object
SerialPortConfiguration saves a serial port configuration.
- Parameters
port – Name of the port (e.g.: COM1 or /dev/tty0).
baudrate – Baud rate (e.g.: 4800, 9600, or 115200).
bytesize – Start bits, either 5, 6, 7, or 8.
stopbits – Stop bits, either 1, 1.5, or 2.
parity – Parity, either none, even, odd, mark, or space.
timeout (float) – Timeout in seconds.
xonxoff – Software flow control.
rtscts – Hardware flow control.
-
property
baudrate
¶
-
property
bytesize
¶
-
property
parity
¶
-
property
port
¶
-
property
rtscts
¶
-
property
stopbits
¶
-
property
timeout
¶
-
property
xonxoff
¶
modules.processing module¶
Module for data processing (pre-processing, atmospheric corrections, transformations, and so on).
-
class
modules.processing.
PreProcessor
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
PreProcessor extracts values from the raw responses of a given observation and converts them to the defined data types.
This module has nothing to configure.
-
is_float
(value: str) → bool¶ Returns whether a value is float or not.
- Parameters
value – The value string.
- Returns
True if value is float, false if not.
-
is_int
(value: str) → bool¶ Returns whether a value is int or not. Float values are seen as int.
- Parameters
value – The value string.
- Returns
True if value is integer, false if not.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Extracts the values from the raw responses of the observation using regular expressions.
- Parameters
obs – The observation object.
- Returns
The observation object with extracted and converted responses.
-
sanitize
(s: str) → str¶ Escapes some non-printable characters in a given string.
- Parameters
s – String to sanitize.
- Returns
Sanitized string.
-
to_float
(raw_value: str) → Optional[float]¶ Converts string to float.
- Parameters
raw_value – The raw string.
- Returns
Float number if string can be converted, otherwise None.
-
to_int
(raw_value: str) → Optional[int]¶ Converts string to int.
- Parameters
raw_value – The raw string.
- Returns
Integer number if string can be converted, otherwise None.
-
-
class
modules.processing.
ResponseValueInspector
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
ResponseValueInspector checks if response values in observations are within defined thresholds and creates critical log messages if not.
The JSON-based configuration for this module:
- Parameters
observations (Dict) – Observations to inspect.
Example
The configuration may be:
{ "observations": { "getDistance": { "slopeDist": { "min": 2.0, "max": 300.0 } } } }
-
is_number
(value: str) → bool¶ Returns whether a value is a number or not.
- Parameters
value – The value variable.
- Returns
True of value is a number, false if not.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Checks, if responses are inside defined bounds.
- Parameters
obs – The observation object.
- Returns
The untouched observation object.
-
class
modules.processing.
ReturnCodeInspector
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
ReturnCodeInspector inspects the return code in an observation sent by sensors of Leica Geosystems and creates an appropriate log message.
The JSON-based configuration for this module:
- Parameters
responseSets (List) – Names of response sets to inspect.
retries (int) – Number of retries in case of an error.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
-
class
modules.processing.
ReturnCodes
¶ Bases:
object
ReturnCodes stores a dictionary of return codes of sensors of Leica Geosystems. The dictionary is static and has the following structure:
{ <return_code>: [ <log_level> (int), <retry_measurement> (bool), <log_message> (str) ] }
The return code numbers and messages are take from the official GeoCOM reference manual of the Leica TPS1200, TS30, and TM30 total stations. The log level can be set to these values:
5: CRITICAL, 4: ERROR, 3: WARNING, 2: INFO, 1: DEBUG, 0: NONE.
Please choose a proper value for each return code. Please be aware that the code list is not complete yet.
-
codes
= {2: [4, False, 'Unknown error, result unspecified'], 3: [3, False, 'Invalid result'], 4: [4, False, 'Fatal error'], 5: [4, False, 'GeoCOM command unknown (not implemented yet)'], 6: [4, False, 'Function execution timed out (result unspecified)'], 13: [4, True, 'System busy'], 514: [4, False, 'Several targets detected'], 1283: [3, False, 'Measurement without full correction'], 1284: [3, False, 'Accuracy can not be guaranteed'], 1285: [4, True, 'Only angle measurement valid'], 1288: [3, False, 'Only angle measurement valid, but without full correction'], 1292: [4, True, 'Distance measurement not done (no aim, etc.)'], 8704: [4, True, 'Position not reached'], 8708: [4, True, 'Position not exactly reached'], 8710: [4, True, 'No target detected'], 8711: [4, False, 'Multiple targets detected'], 8714: [4, False, 'Target acquisition not enabled'], 8716: [4, True, 'Target position not exactly reached']}¶
-
-
class
modules.processing.
UnitConverter
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
UnitConverter can be used to convert response values of arbitrary observations. For instance, a response in centimeters can be converted to meters by setting a scale factor.
The JSON-based configuration for this module:
- Parameters
<responseSetName> (Dict) – Responses to convert.
Example
The configuration may be:
{ "slopeDist": { "conversionType": "scale", "sourceUnit": "mm", "scalingValue": 0.01, "targetUnit": "m" } }
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
-
scale
(value: float, factor: float) → float¶ Scales value by factor.
- Parameters
value – Value to scale.
factor – Scaling factor.
- Returns
Scaled value.
modules.rpi module¶
Module for Raspberry-Pi-specific features, which are not available on other systems.
-
class
modules.rpi.
InterruptCounter
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
InterruptCounter counts GPIO interrupts on a single pin of a Raspberry Pi single-board computer by using RPi.GPIO. Works on Linux only.
The JSON-based configuration for this module:
- Parameters
bounceTime (float) – Bounce time in ms.
countTime (float) – Observation time in s.
pin (int) – GPIO pin number of the Raspberry Pi.
receiver (str) – Name of the receiving module.
sensorName (str) – Name of the connected sensor.
-
init_gpio
() → None¶ Initializes the GPIO interface.
-
run
() → None¶ The counter loop. Creates a new observation at the defined interval.
-
start
() → None¶ Starts the module.
modules.schedule module¶
Module for the scheduling of observations.
-
class
modules.schedule.
Job
(name: str, port_name: str, obs: core.observation.Observation, is_enabled: bool, start_date: str, end_date: str, weekdays: Dict[str, List], uplink: Callable[[str, Dict[str, Any], Dict[str, Any]], None])¶ Bases:
object
Job stores an observation object and sends it to a callback function if the current date and time are within the set schedule.
- Parameters
name – Name of the job.
project_id – ID of the project.
node_id – ID of the sensor node.
port_name – Name of the (serial) port.
obs – Observation object.
is_enabled – If True, job is enabled.
start_date – Date to start the job.
stop_date – Date to stop the job.
weekdays – Dict of days and times to run this job at.
uplink – Callback function to send the observation to.
-
has_expired
() → bool¶ Checks whether or not the job has expired.
-
property
is_enabled
¶
-
is_pending
() → bool¶ Checks whether or not the job is within the current time frame and ready for processing.
-
property
name
¶
-
run
() → None¶ Iterates trough the observation set and sends observations to an external callback function.
-
class
modules.schedule.
Scheduler
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
Scheduler is used to manage the monitoring process by sending observations to a sensor. Each observation is represented by a single job. Jobs are stored in a jobs list and will be executed at the given date and time. A separate scheduler is necessary for each serial port.
The JSON-based configuration for this module:
- Parameters
port (str) – Name of the port module.
sensor (str) – Name of the sensor.
schedules (List[Dict]) – List of schedules.
-
add
(job: modules.schedule.Job) → None¶ Appends a job to the jobs list.
- Parameters
job – Job to add.
-
load_jobs
() → None¶ Loads all observation sets from the configurations and creates jobs to put into the jobs list.
-
run
() → None¶ Threaded method to process the jobs queue.
-
start
() → None¶ Starts the worker.
modules.server module¶
Module for network services.
-
class
modules.server.
LocalControlServer
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
LocalControlServer creates a web service for the remote control of OpenADMS. The server shows HTML page with system information and log messages. The user can start and stop modules defined in the OpenADMS Node configuration. It is recommended to run a reverse proxy in front of the LocalControlServer.
The JSON-based configuration for this module:
- Parameters
host (str) – FQDN or IP address of the server.
port (int) – Port number.
-
run
() → None¶ Runs HTTPServer within a thread to avoid blocking.
-
start
() → None¶ Starts the server.
-
stop
() → None¶ Stops the server.
-
class
modules.server.
RequestHandler
(manager: core.manager.Manager, log_handler: core.logging.RingBufferLogHandler, *args)¶ Bases:
http.server.BaseHTTPRequestHandler
Custom HTTP request handler.
-
absolute_path
(path: str) → pathlib.Path¶
-
do_GET
() → None¶ Creates the response to a GET request.
-
do_HEAD
() → None¶ Creates HTTP header.
-
do_action_query
(query: Dict) → None¶ Processes action query.
- Parameters
query – GET query to process.
-
get_404
() → str¶ Returns a “file not found” page (error 404).
- Returns
String with HTML page.
-
get_file_contents
(path: pathlib.Path) → str¶ Opens a file and returns the contents.
- Parameters
path – File path.
- Returns
String with file contents.
-
get_index
(template: str) → str¶ Returns the index page of this module in HTML format.
- Parameters
template – The template.
- Returns
String with the parsed index page.
-
get_modules_table
() → str¶ Returns table rows with all modules of the current configuration in HTML format. Rather quick and dirty with hard-coded template, but does the job.
- Returns
String with modules as HTML table rows.
-
get_sensors_table
() → str¶ Returns table rows with all sensors of the current configuration in HTML format. Rather quick and dirty with hard-coded template, but does the job.
- Returns
String with sensors as HTML table rows.
-
log_message
(format: str, *args) → None¶ Prevents HTTP request handler from adding log messages to the root logger.
-
parse
(template: str, **kwargs) → str¶ Substitutes placeholders in the template with variables from the given arguments.
- Parameters
template – The (HTML) template.
kwargs – The key-value pairs.
- Returns
String with parsed template.
-
respond
(opts: Dict[str, str]) → None¶ Responds to an HTTP request.
- Parameters
opts – Status code, mime type, return data.
-
modules.testing module¶
Module for testing the monitoring system.
-
class
modules.testing.
ErrorGenerator
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
ErrorGenerates creates warning, error, or critical log messages in a given interval for testing purposes.
The JSON-based configuration for this module:
- Parameters
warning (bool) – Enable warning messages.
error (bool) – Enable error messages.
critical (bool) – Enable critical messages.
interval (float) – Interval to create log messages (in seconds).
-
run
() → None¶ Generates log messages in the set interval.
-
start
() → None¶ Starts the module.
modules.totalstation module¶
Module for the processing of observations of total station positioning systems (pre-processing, atmospheric corrections, transformations).
-
class
modules.totalstation.
DistanceCorrector
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
Corrects the slope distance of EDM measurements using atmospheric data.
The JSON-based configuration for this module:
- Parameters
atmosphericCorrectionEnabled (bool) – Enables atmospheric correction.
seaLevelCorrectionEnabled (bool) – Enables correction to sea level.
distanceName (str) – Name of the response set.
temperature (float) – Default temperature (in °C).
pressure (float) – Default pressure (in hPa/mbar).
humidity (float) – Default humidity (0.0 … 1.0).
sensorHeight (float) – Height of sensor.
-
get_atmospheric_correction
(temperature: float, pressure: float, humidity: float) → float¶ Calculates the atmospheric correction value in parts per million (ppm) for the reduction of distances gained by electronic distance measurement (EDM).
The formulas are taken from the official manual of the Leica TM30 robotic total station. They should be valid for all modern total stations of Leica Geosystems. For further information, please see Leica TM30 manual on page 76.
-
get_sea_level_correction
(sensor_height: float) → float¶ Calculates sea level correction value.
- Parameters
sensor_height – Height of sensor in metres.
- Returns
Correction value.
-
property
humidity
¶
-
property
last_update
¶
-
property
pressure
¶
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
-
property
sensor_height
¶
-
property
temperature
¶
-
class
modules.totalstation.
HelmertTransformer
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
HelmertTransformer calculates the 3-dimensional coordinates of a view point using the Helmert transformation.
The JSON-based configuration for this module:
- Parameters
residualMismatchTransformationEnabled (bool) – If True, prorate residual mismatches.
fixedPoints (Dict[Dict]) – Coordinates of fixed points.
viewPoint (Dict) – Target name and receivers of view point.
-
calculate_point_coordinates
(hz: float, v: float, dist: float, view_point_x: float, view_point_y: float, view_point_z: float, a: float, o: float) → Tuple[float, float, float]¶ Calculates Cartesian coordinates out of polar coordinates.
- Parameters
hz – Horizontal direction.
v – Vertical angle.
dist – Horizontal distance.
view_point_x – X coordinate of the view point.
view_point_y – Y coordinate of the view point.
view_point_z – Z coordinate of the view point.
a – Transformation parameter a.
o – Transformation parameter o.
- Returns
Three-dimensional coordinates x, y, z.
-
get_cartesian_coordinates
(hz: float, v: float, slope_dist: float) → Tuple[float, float, float]¶ Returns Cartesian coordinates out of horizontal direction, vertical angle, and slope distance.
- Parameters
hz – Horizontal direction in rad.
v – Vertical angle in rad.
slope_dist – Slope distance in metres.
- Returns
Coordinates x, y, z.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Calculates the coordinates of the view point and further target points by using the Helmert transformation. The given observation can either be of a fixed point or of a target point. Measured polar coordinates of the fixed points are used to determine the Cartesian coordinates of the view point and the given target points.
An Observation object will be created for the view point and send to the receivers defined in the configuration.
- Parameters
obs – Observation object.
- Returns
The Observation object.
-
class
modules.totalstation.
PolarTransformer
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
PolarTransformer calculates 3-dimensional coordinates of a target using the sensor position and the azimuth position from the configuration together with the horizontal direction, the vertical angle, and the distance of a total station observation. The result (Y, X, Z) is added to the observation data set.
It is possible to use multiple fixed points in order to improve the accuracy of the horizontal directions (‘Abriss’ in German).
The JSON-based configuration for this module:
- Parameters
adjustmentEnabled (bool) – If True, improve horizontal directions.
azimuthAngle (float) – Between local and global azimuth (in gon).
azimuthPointName (str) – Name of azimuth.
fixedPoints (Dict[Dict]) – Coordinates of fixed points (X, Y, Z).
viewPoint (Dict) – Coordinates of view point (X, Y, Z).
-
get_azimuth_angle
(view_point_azimuth: float, view_point_x: float, view_point_y: float, target_point_x: float, target_point_y: float) → float¶ Calculates the azimuth angle to a target point by using the direction and the distance measured from a given view point.
- Parameters
view_point_azimuth – Global azimuth.
view_point_x – X coordinate of view point.
view_point_y – Y coordinate of view point.
target_point_x – X coordinate of target point.
target_point_y – Y coordinate of target point.
- Returns
The azimuth angle to target point.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
-
transform
(view_point_x: float, view_point_y: float, view_point_z: float, target_point_x: float, target_point_y: float, hz: float, v: float, dist: float) → Tuple[float, float, float]¶ Calculates coordinates (x, y, z) out of horizontal direction, vertical angle, and slope distance to a target point using a 3-dimensional polar transformation.
- Parameters
view_point_x – X coordinate of view point.
view_point_y – Y coordinate of view point.
view_point_z – Z coordinate of view point.
target_point_x – X coordinate of target point.
target_point_y – Y coordinate of target point.
hz – Horizontal direction between view point and target point.
v – Vertical angle between view point and target point.
dist – Horizontal distance between view point and target point.
- Returns
X, Y, and Z coordinates of transformed target.
-
class
modules.totalstation.
RefractionCorrector
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
RefractionCorrector removes the influence of the refraction from a measured distance and corrects the Z value of an observed target.
The module has nothing to configure.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
-
-
class
modules.totalstation.
SerialMeasurementProcessor
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
SerialMeasurementProcessor calculates serial measurements by using observations of one target in two faces. The two faces, consisting of horizontal directions, vertical angles, and slope distances, are averaged and stored in a new response set.
The module has nothing to configure.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
-
modules.unix module¶
Module for BSD-specific features, which are not available on other operating systems.
-
class
modules.unix.
GpioController
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
GpioController sets single pins of the General Purpose Input Output (GPIO) interface of a Raspberry Pi single-board computer running FreeBSD, NetBSD, or OpenBSD. This module does not work on Linux.
The JSON-based configuration for this module:
- Parameters
defaultState (int) – Default state of pin (either 0 or 1).
duration (float) – Time span to change the state of the pin (in seconds).
pin (str) – Name of the GPIO pin.
-
handle_gpio
(header: Dict[str, Any], payload: Dict[str, Any]) → None¶ Puts message payload in the queue.
- Parameters
header – The message header.
payload – The message payload.
-
run
() → None¶ Waits for new messages and sets GPIO pin to high or low.
-
start
() → None¶ Starts the worker.
modules.virtual module¶
Module for virtual sensors.
-
class
modules.virtual.
VirtualDTM
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
modules.virtual.VirtualSensor
VirtualDTM simulates the STS DTM meteorological sensor.
-
get_pressure
(request: str) → str¶ Returns pressure value between 980 and 1150 hPa.
- Parameters
request – Request string.
- Returns
String with pressure value.
-
get_temperature
(request: str) → str¶ Returns temperature value between -20 and 40 °C.
- Parameters
request – Request string.
- Returns
String with temperature value.
-
power_on
(request: str) → str¶ Simulates power-on.
- Parameters
request – Request string.
- Returns
Response string.
-
save
(request: str) → str¶ Simulates saving of changes.
- Parameters
request – Request string.
- Returns
Response string.
-
set_command_set
(request: str) → str¶ Simulates change of command set.
- Parameters
request – Request string.
- Returns
Response string.
-
-
class
modules.virtual.
VirtualIndicatorOne
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
modules.virtual.VirtualSensor
VirtualIndicatorOne simulates the Sylvac S_Dial One digital indicator/extensometer.
-
get_distance
(request: str) → str¶ Returns fake distance.
- Parameters
request – Request string.
- Returns
Response string with distance.
-
-
class
modules.virtual.
VirtualSensor
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
core.prototype.Prototype
VirtualSensor is a prototype class for virtual sensors.
-
process_observation
(obs: core.observation.Observation) → core.observation.Observation¶ Processes an observation object. Will be overridden by actual worker.
- Parameters
obs – Observation object.
- Returns
The processed observation object.
-
sanitize
(s: str) → str¶ Escapes some non-printable characters in a given string.
- Parameters
s – The string to sanitize.
- Returns
The sanitized string.
-
-
class
modules.virtual.
VirtualTotalStationTM30
(module_name: str, module_type: str, manager: core.manager.Manager)¶ Bases:
modules.virtual.VirtualSensor
VirtualTotalStationTM30 simulates the Leica TM30 totalstation by processing GeoCOM commands.
-
do_complete_measurement
(request: str) → str¶ Does a complete measurement of slope distance, horizontal direction, and vertical angle to a target. The values are randomly selected within boundaries. Just a quick and dirty approach to get fake sensor data.
- Parameters
request – GeoCOM request string.
- Returns
GeoCOM string with encapsulated sensor data.
-
get_sensor_id
(request: str) → str¶ Returns the sensor id.
- Parameters
request – GeoCOM request string.
- Returns
GeoCOM string with encapsulated sensor id.
-
get_sensor_name
(request: str) → str¶ Returns the sensor name.
- Parameters
request – GeoCOM request string.
- Returns
GeoCOM string with encapsulated sensor name.
-
measure_distance
(request: str) → str¶ Returns the return code for distance measurement.
- Parameters
request – GeoCOM request string.
- Returns
GeoCOM string with return code.
-
set_direction
(request: str) → str¶ Returns the return code for direction setting.
- Parameters
request – GeoCOM request string.
- Returns
GeoCOM string with return code.
-