-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmotorClass.py
27 lines (22 loc) · 989 Bytes
/
motorClass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from componentClass import Component
import json
class Motor(Component):
"""
An implementation of the component used to request data from the
motor periodically, which then sends it to the corresponding topic
to be read by the API
"""
# Setup method for this specific device
def setup(self,samplingInterval):
self.sampInterval = samplingInterval
self.requestTopic = "sbrick/01/rr/get_adc"
self.set_topic("motor")
print "{} setup finished".format(self.name)
# Data Handling for this specific device, from collection to publishing to
# the correct MQTT Topics.
def handleData(self, timestamp):
self.mqttHandler.publish(self.requestTopic, json.dumps(
self.gen_request_message(timestamp)), retain=True)
def gen_request_message(self, timestamp):
return {'status': 0, 'req_msg': '{"sbrick_id": "88:6B:0F:80:29:D1"}',
'resp_topic': self.my_topic, 'timestamp': timestamp}