此软件订阅包含原始传感器数据的MQTT主题,并发布可配置时间跨度的平均值。
Alcathous的Python项目详细描述
此软件订阅包含原始传感器数据和 发布可配置时间跨度的平均值。
可用的算法是:*Average-香草平均值/平均值 实施。*WeightedAverage-所有值的加权平均值 时间窗口内的有效数据点。重量是反时间 时间戳的差异。*Count-计算有多少 有效的数据点在给定的时间窗口内。*Maximum-这个 时间窗口内所有有效数据点的最大值。* Minimum-时间内所有有效数据点的最小值 窗户。
炼金术[1]是科普拉斯的兄弟。他们都是佩洛普斯的儿子。 [wiki]
PELOPS概述
Alcathous是基于mqtt的微服务集合的一部分 pelops。微服务概述 架构和示例可以在 (http://gitlab.com/pelops/pelops)。
对于用户
安装核心功能
核心功能的先决条件是:
sudo apt install python3 python3-pip
通过PIP安装:
sudo pip3 install pelops alcathous
若要更新到最新版本,请将--upgrade作为前缀添加到 pip3行以上。
通过Gitlab安装(可能需要其他软件包):
git clone git@gitlab.com:pelops/alcathous.git cd alcathous sudo python3 setup.py install
这将安装以下shell脚本:*alcathous
脚本cli参数是:*'-c'/'-config'-config文件 (强制)*“-版本”-显示版本号并退出< > >
yaml配置
yaml[2]文件必须包含三个根块:*mqtt-mqtt地址, MQTT端口和凭据文件的路径凭据文件(文件 包含两个条目:mqtt user,mqtt password)*logger- 日志级别和要使用的文件*数据准备*概述- manager*方法的参数-算法映射, 参数和主题pub suffix*datapoints-哪些主题应该 使用的方法和应采用的方法
mqtt: mqtt-address: localhost mqtt-port: 1883 credentials-file: ~/credentials.yaml log-level: INFO logger: log-level: DEBUG log-file: alcathous.log data-preparation: # alcathous root node no_data_behavior: last_valid # mute, last_valid, empty_message update_cycle: 30 # new values published each ... seconds number_worker: 2 # how many worker threads should be spawned to process task queue methods: - name: avg_5min # unique name for method topic-pub-suffix: avg_5min algorithm: avg # avg - average, wavg - weighted average, count, min, max time_window: 5 # use the values from the last ... minutes - name: wavg_5min # unique name for method topic-pub-suffix: wavg_5min algorithm: wavg # avg - average, wavg - weighted average, count, min, max time_window: 5 # use the values from the last ... minutes - name: count_2min # unique name for method topic-pub-suffix: count_2min algorithm: count # avg - average, wavg - weighted average, count, min, max time_window: 2 # use the values from the last ... minutes - name: min_3min # unique name for method topic-pub-suffix: min_3min algorithm: min # avg - average, wavg - weighted average, count, min, max time_window: 3 # use the values from the last ... minutes - name: max_3min # unique name for method topic-pub-suffix: max_3min algorithm: max # avg - average, wavg - weighted average, count, min, max time_window: 3 # use the values from the last ... minutes datapoints: - topic-sub: /test/0/raw topic-pub-prefix: /test/0/aggregated/ zero_is_valid: False # 0 is valid or rejected methods: wavg_5min, avg_5min, count_2min, min_3min, max_3min - topic-sub: /test/1/raw topic-pub-prefix: /test/1/aggregated/ zero_is_valid: False # 0 is valid or rejected methods: wavg_5min, avg_5min
系统d
- 添加systemd示例。
对于开发人员
开始
该项目由三个主要模块组成:*datapointmanager- 加载配置并创建所有Datapoint实例。主办方 循环。*datapoint-Datapoint是 配置。它保存为给定主题接收的所有数据,有自己的集合 方法实例的。*algorithms-可配置的算法 然后在DataPoint中用作数据准备方法。目前, 实现了两种算法:平均值和加权平均值。第一次 一个将时间窗口中的所有值都视为等价的,后一个将加权 它们的时间跨度介于time_from和time_value之间。
DataPointManager有两个列表:对^{tt19}的引用$ 所有实例化方法的函数和对 purge来自所有实例化的DataPoints的函数。第一个 列表按执行成本估算排序(最高值优先)。 两个列表都应用于工作线程(general.number_worker)- 请根据你的需要调整工人的数量。
待办事项
- 为输入值添加更好的有效性检查
- …
其他
代码是为python3编写的(并在 覆盆子皮零与覆盆子伸展)。
Merge requests /bug reports是 欢迎光临。
[1] | The icon used for this project is in fact not Alcathous. Moreover, it is Odysseus and resembles perfectly my failed journey to find a fitting symbol. |
[2] | Currently, pyyaml is yaml 1.1 compliant. In pyyaml On/Off and Yes/No are automatically converted to True/False. This is an unwanted behavior and deprecated in yaml 1.2. In copreus this autoconversion is removed. Thus, On/Off and Yes/No are read from the yaml file as strings (see module baseclasses.myconfigtools). |