Commit de367e7f723356b86a9cd213d5e5fe6d9863e9bd
1 parent
b586f117
Exists in
dev
Add components file (RoofControler, PLC)
Showing
5 changed files
with
116 additions
and
6 deletions
Show diff stats
CHANGELOG
... | ... | @@ -0,0 +1,17 @@ |
1 | +- attribute: | |
2 | + key: manufacturer | |
3 | + is_container: False | |
4 | + value: unknown | |
5 | + is_editable: False | |
6 | + unit: "" | |
7 | + label: manufacturer | |
8 | + description: "" | |
9 | + | |
10 | +- attribute: | |
11 | + key: model | |
12 | + is_container: False | |
13 | + value: unknown | |
14 | + unit: "" | |
15 | + is_editable: False | |
16 | + label: "model" | |
17 | + description: "" | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +- attribute: | |
2 | + key: manufacturer | |
3 | + is_container: False | |
4 | + value: unknown | |
5 | + is_editable: False | |
6 | + unit: "" | |
7 | + label: manufacturer | |
8 | + description: "" | |
9 | + | |
10 | +- attribute: | |
11 | + key: model | |
12 | + is_container: False | |
13 | + value: unknown | |
14 | + unit: "" | |
15 | + is_editable: False | |
16 | + label: "model" | |
17 | + description: "" | ... | ... |
privatedev/config/tnc/device_Raspberry_TAROT_sn002.yml
... | ... | @@ -301,11 +301,23 @@ DEVICE: |
301 | 301 | unit: degC |
302 | 302 | description: From CV7 anemometer sensor |
303 | 303 | |
304 | -A CHANGER... | |
304 | + - CAPABILITY: | |
305 | 305 | # --------- |
306 | 306 | # PLC/DHT22 |
307 | 307 | # --------- |
308 | + component: WeatherStation | |
308 | 309 | |
310 | + attributes: | |
311 | + | |
312 | + - attribute: | |
313 | + key: manufacturer | |
314 | + value: unknown | |
315 | + | |
316 | + - attribute: | |
317 | + key: model | |
318 | + value: DHT22 | |
319 | + | |
320 | + output_data: | |
309 | 321 | - data: |
310 | 322 | key: /entities/devices/DHT22/Error_code |
311 | 323 | category: electricity |
... | ... | @@ -348,7 +360,20 @@ A CHANGER... |
348 | 360 | # --------- |
349 | 361 | # PLC/RG11 |
350 | 362 | # --------- |
363 | + - CAPABILITY: | |
364 | + component: WeatherStation | |
365 | + | |
366 | + attributes: | |
367 | + | |
368 | + - attribute: | |
369 | + key: manufacturer | |
370 | + value: unknown | |
371 | + | |
372 | + - attribute: | |
373 | + key: model | |
374 | + value: RG11 | |
351 | 375 | |
376 | + output_data: | |
352 | 377 | - data: |
353 | 378 | key: /entities/devices/RG11/Error_code |
354 | 379 | category: electricity |
... | ... | @@ -378,7 +403,20 @@ A CHANGER... |
378 | 403 | # ------------ |
379 | 404 | # PLC/MLX90614 |
380 | 405 | # ------------ |
406 | + - CAPABILITY: | |
407 | + component: WeatherStation | |
408 | + | |
409 | + attributes: | |
410 | + | |
411 | + - attribute: | |
412 | + key: manufacturer | |
413 | + value: unknown | |
414 | + | |
415 | + - attribute: | |
416 | + key: model | |
417 | + value: MLX90614 | |
381 | 418 | |
419 | + output_data: | |
382 | 420 | - data: |
383 | 421 | key: /entities/devices/MLX90614/Error_code |
384 | 422 | category: electricity | ... | ... |
src/core/pyros_django/obsconfig/obsconfig_class.py
... | ... | @@ -105,6 +105,7 @@ class OBSConfig: |
105 | 105 | open(self.CONFIG_PATH+self.pickle_file, "rb")) |
106 | 106 | can_pickle_file_be_read = True |
107 | 107 | else: |
108 | + print(f"{self.CONFIG_PATH+self.pickle_file} can't be accessed, waiting for availability") | |
108 | 109 | time.sleep(0.5) |
109 | 110 | except IOError: |
110 | 111 | print("Error when reading the pickle file") |
... | ... | @@ -165,7 +166,7 @@ class OBSConfig: |
165 | 166 | dict: dictionary of the config file (with values) |
166 | 167 | """ |
167 | 168 | # disable pykwalify error to clean the output |
168 | - # logging.disable(logging.ERROR) | |
169 | + logging.disable(logging.ERROR) | |
169 | 170 | try: |
170 | 171 | can_yaml_file_be_read = False |
171 | 172 | while can_yaml_file_be_read != True: |
... | ... | @@ -311,7 +312,13 @@ class OBSConfig: |
311 | 312 | attribute = attribute["attribute"] |
312 | 313 | |
313 | 314 | attributes[attribute.pop("key")] = attribute |
315 | + output_data = {} | |
316 | + if capability.get("output_data"): | |
314 | 317 | |
318 | + for data in capability['output_data']: | |
319 | + cap_data = data["data"] | |
320 | + name = cap_data.pop("key") | |
321 | + output_data[name] = cap_data | |
315 | 322 | # for each attributes of generic component attributes |
316 | 323 | for attribute_name in attributes.keys(): |
317 | 324 | # merge attributes of general component with specified component in device config file |
... | ... | @@ -329,6 +336,7 @@ class OBSConfig: |
329 | 336 | |
330 | 337 | # return inherited and overwritten attributes of capability |
331 | 338 | capability["attributes"] = component_attributes |
339 | + capability["output_data"] = output_data | |
332 | 340 | return capability |
333 | 341 | |
334 | 342 | def get_devices_names_and_file(self) -> dict: |
... | ... | @@ -1278,6 +1286,30 @@ class OBSConfig: |
1278 | 1286 | return dependencies_return |
1279 | 1287 | |
1280 | 1288 | |
1289 | + def get_output_data_device(self,device): | |
1290 | + device = self.get_device_capabilities(device) | |
1291 | + result = {} | |
1292 | + for component in device: | |
1293 | + if component.get("output_data"): | |
1294 | + output_data = component.get("output_data") | |
1295 | + for data in output_data: | |
1296 | + data = data["data"] | |
1297 | + key = data.pop("key") | |
1298 | + result[key] = data | |
1299 | + return result | |
1300 | + | |
1301 | + def get_output_data_device_sort_monitoring_name(self,device): | |
1302 | + output_data = self.get_output_data_device(device) | |
1303 | + monitoring_names = {} | |
1304 | + if len(output_data) > 0: | |
1305 | + for data in output_data: | |
1306 | + key = data | |
1307 | + data_dict = output_data[data] | |
1308 | + monitoring_name = data_dict.pop("monitoring_name") | |
1309 | + data_dict["key"] = key | |
1310 | + monitoring_names[monitoring_name] = data_dict | |
1311 | + return monitoring_names | |
1312 | + | |
1281 | 1313 | class MissingMandatoryAgentException(Exception): |
1282 | 1314 | """ |
1283 | 1315 | Exception raised when an mandatory Pyros Agent is missing in the observatory configuration. |
... | ... | @@ -1300,15 +1332,18 @@ def main(): |
1300 | 1332 | # print(config.getEditableAttributesOfChannel(unit_name,"OpticalChannel_up")) |
1301 | 1333 | config = OBSConfig("../../../../privatedev/config/tnc/observatory_tnc.yml") |
1302 | 1334 | unit_name = config.get_units_name()[0] |
1303 | - #dc = config.getDeviceControllerNameForAgent(unit_name,"mount")[0] | |
1335 | + # dc = config.getDeviceControllerNameForAgent(unit_name,"mount")[0] | |
1304 | 1336 | # print(config.getDeviceConfigForDeviceController(dc)) |
1305 | 1337 | # print(config.getCommParamsForAgentDevice(unit_name,"mount")) |
1306 | 1338 | # print(config.getChannelCapabilities(unit_name,"OpticalChannel_down2")) |
1307 | 1339 | # print(config.get_channel_groups(unit_name)) |
1308 | 1340 | # print(config.getEditableAttributesOfCapability(config.getChannelCapabilities(unit_name,"OpticalChannel_down2")[0])) |
1309 | 1341 | # print(config.getEditableAttributesOfChannel(unit_name,"OpticalChannel_down2")) |
1310 | - print(config.getEditableAttributesOfMount(unit_name)) | |
1311 | - | |
1342 | + #print(config.getEditableAttributesOfMount(unit_name)) | |
1343 | + config.get_devices() | |
1344 | + #print(config.get_output_data_device("TAROT_meteo")) | |
1345 | + print(config.get_output_data_device_sort_monitoring_name("TAROT_meteo").keys()) | |
1346 | + #print(config.get_device_capabilities("TAROT_meteo")) | |
1312 | 1347 | # print(config.get_devices()["FLI-Kepler4040"]["device_config"]) |
1313 | 1348 | # print(config.get_devices()["FLI-Kepler4040"]["device_config"]["CAPABILITIES"][1]["attributes"]["manufacturer"]) |
1314 | 1349 | # print(config.get_devices()["FLI-Kepler4040"]["device_config"]["CAPABILITIES"]) | ... | ... |