SensorTag as Device#90
Conversation
| sensors=[Sensors.TEMPERATURE, Sensors.HUMIDITY, Sensors.BAROMETER, | ||
| Sensors.BATTERY_LEVEL, Sensors.LIGHTMETER, | ||
| Sensors.ACCELEROMETER, Sensors.GYROSCOPE]) | ||
| sensor_tag = sensor_tag_collector.get_sensor_tag() |
There was a problem hiding this comment.
There shouldn't be the requirement of get_sensor_tag(), just have one definition for sensor tag device and use it.
| Facilitates collecting sensor metrics even in-case of dis-connectivity due to external factors, without any need | ||
| of manual restart of the program. | ||
|
|
||
| Use this class to collect metrics from SensorTag. |
There was a problem hiding this comment.
There shouldn't be a separate class for collecting metrics, make it part of SensorTagDevice class. Creates confusion and complexity for user.
| ALL = 8 | ||
|
|
||
|
|
||
| class SensorTagDevice(Device, SensorTag): |
There was a problem hiding this comment.
Why is SensorTagDevice dependent on SensorTag ? Any specific requirement, I`m not clear with this implementation.
| """ | ||
|
|
||
| def __init__(self, name, device_mac, entity_type="Device"): | ||
| Device.__init__( |
| :return: None | ||
| """ | ||
| log.info("Connecting to SensorTag Device: {0} with MAC_ADDRESS: {1}".format(self.device_name, self.device_mac)) | ||
| self.tag = SensorTagDevice( |
There was a problem hiding this comment.
This line should be part of user code(Initializing Device class) shouldn't be in the core Liota.
| self.metrics.append(reg_mem_free_metric) | ||
|
|
||
| # Connects to the SensorTag device over BLE | ||
| self.sensor_tag_collector = SensorTagCollector(device_name=config['DeviceName'], device_mac=config['DeviceMac'], |
There was a problem hiding this comment.
Create a separate device package and metrics package. Initialization of device shouldn't be part of this device metrics package.
| ureg = pint.UnitRegistry() | ||
|
|
||
|
|
||
| def read_cpu_procs(): |
There was a problem hiding this comment.
Just keep the device metrics in this package, don`t combine the device metrics and edge system metrics in the same package.
| sampling_function=read_cpu_procs | ||
| ) | ||
| reg_cpu_procs_metric = iotcc.register(cpu_procs_metric) | ||
| iotcc.create_relationship(iotcc_edge_system, reg_cpu_procs_metric) |
There was a problem hiding this comment.
Just keep the package dependent on the device metrics only.
|
|
||
| # create a data center object, IoTCC in this case, using websocket as a transport layer | ||
| iotcc = IotControlCenter(config['IotCCUID'], config['IotCCPassword'], | ||
| WebSocketDccComms(url=config['WebSocketUrl'])) |
| Returns SensorTagDevice entity. | ||
| :return: SensorTagDevice entity object. | ||
| """ | ||
| return self.tag |
There was a problem hiding this comment.
We need to discuss about this tag implementation.
There was a problem hiding this comment.
Remove this tag comments.
|
We need to discuss some of the implementations. |
# Conflicts: # requirements.txt
|
Addressed review comments |
| Returns SensorTagDevice entity. | ||
| :return: SensorTagDevice entity object. | ||
| """ | ||
| return self.tag |
There was a problem hiding this comment.
Remove this tag comments.
| @@ -0,0 +1,155 @@ | |||
| # -*- coding: utf-8 -*- | |||
There was a problem hiding this comment.
Just rename the path as "packages/examples/metrics".As you are making the new folder I`ll prefer if you can move the entities in the specific folder.
There was a problem hiding this comment.
Okay will rename it. For packages, we need to move device and metric entities separately. This will result changes in many files. In the interest of keeping no.of files changed for a PR less, I'll raise a separate one just for refactoring once this is merged.
| temperature_metric = Metric( | ||
| name="AmbientTemperature", | ||
| unit=ureg.degC, | ||
| interval=0, |
There was a problem hiding this comment.
Can the interval be other than "0"?
There was a problem hiding this comment.
We provide sampling interval here
So, to collect from SensorTag, it must be zero.
| @@ -0,0 +1,232 @@ | |||
| # -*- coding: utf-8 -*- | |||
| # ----------------------------------------------------------------------------# | |||
There was a problem hiding this comment.
As you are making the new folder I`ll prefer if you can move the entities in the specific folder.
There was a problem hiding this comment.
We have separate folder for model_simulated examples. This is the first actual device. DHT examples can go in here.
| @@ -0,0 +1,155 @@ | |||
| # -*- coding: utf-8 -*- | |||
There was a problem hiding this comment.
Probably you can move all the metrics associated package in this folder.
Uh oh!
There was an error while loading. Please reload this page.