Commit 24c5cacf1f16cbd784abe91e2f5ac7ae71b48f1a
1 parent
f948c7ff
Exists in
dev
Version 1.2 de Report avec data_type.
Showing
2 changed files
with
27 additions
and
16 deletions
Show diff stats
src/utils/report/doc/user_guide_module_report.odt
No preview for this file type
src/utils/report/status_json.py
... | ... | @@ -25,7 +25,7 @@ class Status_json: |
25 | 25 | |
26 | 26 | Example a a very wimple Json file report contents: |
27 | 27 | { |
28 | - "frame_model": "1.1", | |
28 | + "frame_model": "1.2", | |
29 | 29 | "name_creator": "PLC", |
30 | 30 | "version_creator": "20180909", |
31 | 31 | "entities": [ |
... | ... | @@ -34,7 +34,7 @@ Example a a very wimple Json file report contents: |
34 | 34 | "origin": "Raspberry", |
35 | 35 | "version_firmware": "20180924A", |
36 | 36 | "site": "MyObservatory", |
37 | - "date": "2018-09-25T22:24:16.387", | |
37 | + "date": "2018-11-29T15:07:20.999", | |
38 | 38 | "devices": [ |
39 | 39 | { |
40 | 40 | "device_name": "DHT22", |
... | ... | @@ -44,10 +44,10 @@ Example a a very wimple Json file report contents: |
44 | 44 | "device_values": [ |
45 | 45 | { |
46 | 46 | "name": "OutsideTemperature", |
47 | - "type": "float", | |
47 | + "data_type": "float", | |
48 | 48 | "value": "22", |
49 | 49 | "unit": "degC", |
50 | - "monitoring_name": "temperature", | |
50 | + "monitoring_name": "Temperature_outside", | |
51 | 51 | "comment": "Temperature" |
52 | 52 | } |
53 | 53 | ] |
... | ... | @@ -56,7 +56,7 @@ Example a a very wimple Json file report contents: |
56 | 56 | } |
57 | 57 | ] |
58 | 58 | } |
59 | - | |
59 | + | |
60 | 60 | A value is stored in a UFKI (Unique Four Key Identifier): |
61 | 61 | UFKI = entity_name device_name serial_number name |
62 | 62 | |
... | ... | @@ -239,7 +239,7 @@ https://github.com/hjson/hjson-py |
239 | 239 | #################################################################### |
240 | 240 | |
241 | 241 | def _status_new(self, name_creator, version_creator): |
242 | - status_header = {'frame_model':'1.1', 'name_creator':name_creator, 'version_creator':version_creator, 'entities':[]} | |
242 | + status_header = {'frame_model':'1.2', 'name_creator':name_creator, 'version_creator':version_creator, 'entities':[]} | |
243 | 243 | #self._status = { 'statuses':[] } |
244 | 244 | #self._status['statuses'].append(status_header) |
245 | 245 | self._status = status_header |
... | ... | @@ -483,7 +483,7 @@ https://github.com/hjson/hjson-py |
483 | 483 | res.append(re) |
484 | 484 | return res |
485 | 485 | |
486 | - def get_values(self, only_device_name="", only_serial_number="", getvalue=False): | |
486 | + def get_ufkis(self, only_device_name="", only_serial_number="", getvalue=False): | |
487 | 487 | """ Get the current values |
488 | 488 | |
489 | 489 | Inputs: |
... | ... | @@ -494,6 +494,7 @@ https://github.com/hjson/hjson-py |
494 | 494 | ------ |
495 | 495 | >>> report = report.Status_json() |
496 | 496 | >>> print("{}",format(report.get_devices())) |
497 | + >>> print("{}",format(report.get_ufkis("","",True)) | |
497 | 498 | |
498 | 499 | Related topics: |
499 | 500 | --------------- |
... | ... | @@ -521,6 +522,16 @@ https://github.com/hjson/hjson-py |
521 | 522 | res.append(re) |
522 | 523 | return res |
523 | 524 | |
525 | + def get_sensors(self, only_device_name="", only_serial_number="", getvalue=False): | |
526 | + """ Get the current values. Alias of get_ufkis. | |
527 | + """ | |
528 | + return self.get_ufkis(only_device_name, only_serial_number, getvalue); | |
529 | + | |
530 | + def get_values(self, only_device_name="", only_serial_number="", getvalue=False): | |
531 | + """ Get the current values. Alias of get_ufkis. | |
532 | + """ | |
533 | + return self.get_ufkis(only_device_name, only_serial_number, getvalue); | |
534 | + | |
524 | 535 | |
525 | 536 | # ======================================================== |
526 | 537 | # === debug methods |
... | ... | @@ -604,10 +615,10 @@ if __name__ == "__main__": |
604 | 615 | rep.append_device("DHT22", "meteo", "1", "0") |
605 | 616 | rep.append_value( "OutsideTemperature", "float","22","degC","Temperature_outside","Temperature") |
606 | 617 | # --- List the UFKIs |
607 | - ufiks = rep.get_values("","",False) | |
618 | + ufkis = rep.get_ufkis("","",False) | |
608 | 619 | print(" List of all UFKIs:") |
609 | - for ufik in ufiks: | |
610 | - print(" UFKI = {}".format(ufik)) | |
620 | + for ufki in ufkis: | |
621 | + print(" UFKI = {}".format(ufki)) | |
611 | 622 | # --- save the Json file |
612 | 623 | rep.save_json("plc_verysimple.json") |
613 | 624 | |
... | ... | @@ -646,10 +657,10 @@ if __name__ == "__main__": |
646 | 657 | rep.append_value( "SkyTemperature", "float","-15.67","degC","Temperature_sky","Temperature of the sky") |
647 | 658 | rep.append_value( "CanTemperature", "float","22.47","degC","","Temperature of the TO can") |
648 | 659 | # --- List the UFKIs |
649 | - ufiks = rep.get_values("","",False) | |
660 | + ufkis = rep.get_ufkis("","",False) | |
650 | 661 | print(" List of all UFKIs:") |
651 | - for ufik in ufiks: | |
652 | - print(" UFKI = {}".format(ufik)) | |
662 | + for ufki in ufkis: | |
663 | + print(" UFKI = {}".format(ufki)) | |
653 | 664 | # --- read the value of one UFKI |
654 | 665 | |
655 | 666 | # --- save the Json file |
... | ... | @@ -667,6 +678,6 @@ if __name__ == "__main__": |
667 | 678 | res = rep.get_devices() |
668 | 679 | print(" devices = {}".format(res)) |
669 | 680 | print(" List of all UFKIs:") |
670 | - ufiks = rep.get_values("","",True) | |
671 | - for ufik in ufiks: | |
672 | - print(" UFKI = {}".format(ufik)) | |
681 | + ufkis = rep.get_ufkis("","",True) | |
682 | + for ufki in ufkis: | |
683 | + print(" UFKI = {}".format(ufki)) | ... | ... |