Commit 0eaf1aa96e430004c5c5018daf54e299241a8831
Exists in
dev
Merge branch 'dev' of https://gitlab.irap.omp.eu/epallier/pyros into dev
Dont know
Showing
12 changed files
with
48 additions
and
351 deletions
Show diff stats
devices_channel/src_device/client/client_channel_serial.py
@@ -21,7 +21,7 @@ class ClientChannelSerial(ClientChannel): | @@ -21,7 +21,7 @@ class ClientChannelSerial(ClientChannel): | ||
21 | buf = 1024 | 21 | buf = 1024 |
22 | 22 | ||
23 | 23 | ||
24 | - def __init__(self, server_host:str="localhost", server_port:int=11110, buffer_size=1024, DEBUG=False): | 24 | + def __init__(self, server_host:str="localhost", server_port:int=11110, buffer_size=1024, DEBUG:bool=False): |
25 | ''' | 25 | ''' |
26 | :param server_host: server IP or hostname | 26 | :param server_host: server IP or hostname |
27 | :param server_port: server port | 27 | :param server_port: server port |
doc/PyROS software.docx deleted
No preview for this file type
doc/PyROS software.pdf deleted
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
src/majordome/start_agent_majordome_from_test.py deleted
@@ -1,26 +0,0 @@ | @@ -1,26 +0,0 @@ | ||
1 | -#!/usr/bin/env python | ||
2 | - | ||
3 | -import os | ||
4 | -import sys | ||
5 | - | ||
6 | -# DJANGO setup | ||
7 | -#sys.path.append('/PROJECTS/GFT/SOFT/PYROS_SOFT/PYROS201802') | ||
8 | -sys.path.append('..') | ||
9 | -#print("file is", __file__) | ||
10 | -mypath = os.getcwd() | ||
11 | - | ||
12 | -# Go into src/ | ||
13 | -##os.chdir('..') | ||
14 | -#print("Current directory : " + str(os.getcwd())) | ||
15 | -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "src.pyros.settings") | ||
16 | -#os.environ['SECRET_KEY'] = 'abc' | ||
17 | -#os.environ['ENVIRONMENT'] = 'production' | ||
18 | -import django | ||
19 | -django.setup() | ||
20 | - | ||
21 | -# MONITORING AGENT setup | ||
22 | -agent="majordome" | ||
23 | - | ||
24 | -if agent=="majordome": | ||
25 | - from majordome.tasks import Majordome | ||
26 | - Majordome().run() |
src/pyros/test_settings_NOTUSED.py deleted
@@ -1,290 +0,0 @@ | @@ -1,290 +0,0 @@ | ||
1 | -""" OBSOLETE FILE """ | ||
2 | -""" | ||
3 | -Django settings for pyros project. | ||
4 | - | ||
5 | -Generated by 'django-admin startproject' using Django 1.9.4. | ||
6 | - | ||
7 | -For more information on this file, see | ||
8 | -https://docs.djangoproject.com/en/1.9/topics/settings/ | ||
9 | - | ||
10 | -For the full list of settings and their values, see | ||
11 | -https://docs.djangoproject.com/en/1.9/ref/settings/ | ||
12 | -""" | ||
13 | - | ||
14 | -# Dictionary containing all the versions for the different modules | ||
15 | -# IMPORTANT : I must be updated at every commit ! | ||
16 | - | ||
17 | -MODULES_VERSIONS = { | ||
18 | - "Alert Manager" : "0.2.4", | ||
19 | - "Analyzer" : "0.1.2", | ||
20 | - "Dashboard" : "0.1.1", | ||
21 | - "Majordome" : "0.1.4", | ||
22 | - "Monitoring" : "0.1.3", | ||
23 | - "Observation Manager" : "0.1.3", | ||
24 | - "Routine Manager" : "0.1.2", | ||
25 | - "Scheduler" : "0.1.2", | ||
26 | - "User Manager" : "0.1.1", | ||
27 | - "Device" : "0.1.1" | ||
28 | -} | ||
29 | - | ||
30 | -# Set MYSQL to False if you want to use SQLITE | ||
31 | -# This line MUST NOT be changed at all except from changing True/False | ||
32 | -# (or install_requirements script will become invalid) | ||
33 | -MYSQL = True | ||
34 | - | ||
35 | -# YOU MUST CHANGE THIS VALUE IN PYROSRUN.SH TOO | ||
36 | -TEST_PORT = 8001 | ||
37 | -# YOU MUST CHANGE THIS VALUE IN PYROSRUN.SH TOO | ||
38 | - | ||
39 | - | ||
40 | -import os | ||
41 | - | ||
42 | -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
43 | -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
44 | - | ||
45 | - | ||
46 | -# Quick-start development settings - unsuitable for production | ||
47 | -# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ | ||
48 | - | ||
49 | -# SECURITY WARNING: keep the secret key used in production secret! | ||
50 | -SECRET_KEY = '0*@w)$rq4x1c2w!c#gn58*$*u$w=s8uw2zpr_c3nj*u%qlxc23' | ||
51 | - | ||
52 | -# SECURITY WARNING: don't run with debug turned on in production! | ||
53 | -DEBUG = True | ||
54 | - | ||
55 | -ALLOWED_HOSTS = ['localhost'] | ||
56 | - | ||
57 | - | ||
58 | -# Application definition | ||
59 | - | ||
60 | -INSTALLED_APPS = [ | ||
61 | - 'django.contrib.admin', | ||
62 | - 'django.contrib.auth', | ||
63 | - 'django.contrib.contenttypes', | ||
64 | - 'django.contrib.sessions', | ||
65 | - 'django.contrib.messages', | ||
66 | - 'django.contrib.staticfiles', | ||
67 | - | ||
68 | - # for using "./manage.py graph_models" with graphviz: | ||
69 | - # (https://projects.irap.omp.eu/projects/pyros/wiki/Project_Development#django-extensions-and-graphviz-useful-for-generating-an-image-of-all-the-models-and-their-relationships) | ||
70 | - 'django_extensions', | ||
71 | - 'test_without_migrations', | ||
72 | - 'bootstrap3', | ||
73 | - 'dashboard', | ||
74 | - 'scheduler', | ||
75 | - 'common', | ||
76 | - 'alert_manager', | ||
77 | - 'analyzer', | ||
78 | - 'majordome', | ||
79 | - 'monitoring', | ||
80 | - 'observation_manager', | ||
81 | - 'routine_manager', | ||
82 | - 'user_manager', | ||
83 | - 'devices' | ||
84 | -] | ||
85 | - | ||
86 | -MIDDLEWARE_CLASSES = [ | ||
87 | - 'django.middleware.security.SecurityMiddleware', | ||
88 | - 'django.contrib.sessions.middleware.SessionMiddleware', | ||
89 | - 'django.middleware.common.CommonMiddleware', | ||
90 | - 'django.middleware.csrf.CsrfViewMiddleware', | ||
91 | - 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
92 | - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | ||
93 | - 'django.contrib.messages.middleware.MessageMiddleware', | ||
94 | - 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
95 | -] | ||
96 | - | ||
97 | -ROOT_URLCONF = 'pyros.urls' | ||
98 | - | ||
99 | -TEMPLATES = [ | ||
100 | - { | ||
101 | - 'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
102 | - 'DIRS': ['misc/templates'], | ||
103 | - 'APP_DIRS': True, | ||
104 | - 'OPTIONS': { | ||
105 | - 'context_processors': [ | ||
106 | - 'django.template.context_processors.debug', | ||
107 | - 'django.template.context_processors.request', | ||
108 | - 'django.contrib.auth.context_processors.auth', | ||
109 | - 'django.contrib.messages.context_processors.messages', | ||
110 | - ], | ||
111 | - }, | ||
112 | - }, | ||
113 | -] | ||
114 | - | ||
115 | -WSGI_APPLICATION = 'pyros.wsgi.application' | ||
116 | - | ||
117 | -FIXTURE_DIRS = ( | ||
118 | - 'misc/fixtures/', | ||
119 | -) | ||
120 | - | ||
121 | -LOGIN_URL = "/" | ||
122 | - | ||
123 | -# Database | ||
124 | -# https://docs.djangoproject.com/en/1.9/ref/settings/#databases | ||
125 | - | ||
126 | -# EP modif | ||
127 | - | ||
128 | -CELERY_TEST = False | ||
129 | - | ||
130 | -if not CELERY_TEST: | ||
131 | - if not MYSQL: | ||
132 | - DATABASES = { | ||
133 | - 'default': { | ||
134 | - 'ENGINE': 'django.db.backends.sqlite3', | ||
135 | - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
136 | - } | ||
137 | - } | ||
138 | - else: | ||
139 | - DATABASES = { | ||
140 | - 'default': { | ||
141 | - 'ENGINE': 'django.db.backends.mysql', | ||
142 | - 'NAME': 'test_pyros', | ||
143 | - 'USER': 'pyros', | ||
144 | - 'PASSWORD': 'DjangoPyros', | ||
145 | - } | ||
146 | - } | ||
147 | -else: | ||
148 | - DATABASES = { | ||
149 | - 'default': { | ||
150 | - 'ENGINE': 'django.db.backends.sqlite3', | ||
151 | - 'NAME': os.path.join(BASE_DIR, 'testdb.sqlite3'), | ||
152 | - 'TEST': { | ||
153 | - 'NAME': os.path.join(BASE_DIR, 'testdb.sqlite3'), | ||
154 | - }, | ||
155 | - } | ||
156 | - } | ||
157 | - | ||
158 | - | ||
159 | -# Password validation | ||
160 | -# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators | ||
161 | - | ||
162 | -AUTH_PASSWORD_VALIDATORS = [ | ||
163 | - { | ||
164 | - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
165 | - }, | ||
166 | - { | ||
167 | - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
168 | - }, | ||
169 | - { | ||
170 | - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
171 | - }, | ||
172 | - { | ||
173 | - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
174 | - }, | ||
175 | -] | ||
176 | - | ||
177 | - | ||
178 | -# Internationalization | ||
179 | -# https://docs.djangoproject.com/en/1.9/topics/i18n/ | ||
180 | - | ||
181 | -#LANGUAGE_CODE = 'en-us' | ||
182 | -LANGUAGE_CODE = 'fr-FR' | ||
183 | - | ||
184 | -#TIME_ZONE = 'UTC' | ||
185 | -TIME_ZONE = 'Europe/Paris' | ||
186 | - | ||
187 | -USE_I18N = True | ||
188 | - | ||
189 | -USE_L10N = True | ||
190 | - | ||
191 | -USE_TZ = True | ||
192 | - | ||
193 | - | ||
194 | -# To find the media files {{ MEDIA_URL }} | ||
195 | -MEDIA_URL = '/public/static/media/' | ||
196 | - | ||
197 | - | ||
198 | -# To find the static files in the app/static/ap/... folders | ||
199 | -STATIC_URL = '/public/static/' | ||
200 | - | ||
201 | -# To find the static files in src/static/. Any local directory can be added to this list. | ||
202 | -STATICFILES_DIRS = ( | ||
203 | - os.path.join(BASE_DIR, "misc", "static"), | ||
204 | - ) | ||
205 | - | ||
206 | -# Used for deployment (DEBUG = False). Need to run "python manage.py collectstatic" to fill it. | ||
207 | -STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'public', 'static') | ||
208 | - | ||
209 | - | ||
210 | -# EP added | ||
211 | -if not DEBUG: | ||
212 | - ''' | ||
213 | - CACHES = { | ||
214 | - 'default': { | ||
215 | - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', | ||
216 | - 'LOCATION': '127.0.0.1:11211', | ||
217 | - } | ||
218 | - } | ||
219 | - ''' | ||
220 | - CACHES = { | ||
221 | - 'default': { | ||
222 | - 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', | ||
223 | - 'LOCATION': '/var/tmp/django_cache', | ||
224 | - } | ||
225 | - } | ||
226 | - | ||
227 | -else: | ||
228 | - CACHES = { | ||
229 | - 'default': { | ||
230 | - 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', | ||
231 | - } | ||
232 | - } | ||
233 | - | ||
234 | -# from django.core.cache import cache | ||
235 | -# cache.clear() | ||
236 | - | ||
237 | -# CELERY CONFIG | ||
238 | - | ||
239 | -# CELERY_RESULT_BACKEND = 'rpc://' | ||
240 | -CELERY_RESULT_BACKEND = 'amqp' | ||
241 | - | ||
242 | -CELERY_ACCEPT_CONTENT = ['json'] | ||
243 | -CELERY_TASK_SERIALIZER = 'json' | ||
244 | -CELERY_RESULT_SERIALIZER = 'json' | ||
245 | - | ||
246 | -CELERY_IMPORTS = ( | ||
247 | - "alert_manager.tasks", | ||
248 | - "analyzer.tasks", | ||
249 | - "majordome.tasks", | ||
250 | - "monitoring.tasks", | ||
251 | - "observation_manager.tasks", | ||
252 | - "scheduler.tasks", | ||
253 | -) | ||
254 | - | ||
255 | -# This config allows only 1 process / queue. We replace it by the -c option at celery workers creation. | ||
256 | -# CELERYD_CONCURRENCY = 1 | ||
257 | - | ||
258 | -''' Following config is needed for manual purge ''' | ||
259 | -CELERY_ACKS_LATE = False | ||
260 | -CELERYD_PREFETCH_MULTIPLIER = 1 | ||
261 | - | ||
262 | -CELERY_QUEUES = { | ||
263 | - "alert_listener_q": {"exchange": "alert_listener_q", "routing_key": "alert_listener_q"}, | ||
264 | - "analysis_q": {"exchange": "analysis_q", "routing_key": "analysis_q"}, | ||
265 | - "system_status_q": {"exchange": "system_status_q", "routing_key": "system_status_q"}, | ||
266 | - "change_obs_conditions_q": {"exchange": "change_obs_conditions_q", "routing_key": "change_obs_conditions_q"}, | ||
267 | - "monitoring_q": {"exchange": "monitoring_q", "routing_key": "monitoring_q"}, | ||
268 | - "scheduling_q": {"exchange": "scheduling_q", "routing_key": "scheduling_q"}, | ||
269 | - "execute_sequence_q": {"exchange": "execute_sequence_q", "routing_key": "execute_sequence_q"}, | ||
270 | - "execute_plan_vis_q": {"exchange": "execute_plan_vis_q", "routing_key": "execute_plan_vis_q"}, | ||
271 | - "execute_plan_nir_q": {"exchange": "execute_plan_nir_q", "routing_key": "execute_plan_nir_q"}, | ||
272 | - "create_calibrations_q": {"exchange": "create_calibrations_q", "routing_key": "create_calibrations_q"}, | ||
273 | -} | ||
274 | - | ||
275 | -CELERY_ROUTES = { | ||
276 | - "alert_manager.tasks.alert_listener": {"queue": "alert_listener_q"}, | ||
277 | - "analyzer.tasks.analysis": {"queue": "analysis_q"}, | ||
278 | - "majordome.tasks.execute_sequence": {"queue": "execute_sequence_q"}, | ||
279 | - "majordome.tasks.system_pause": {"queue": "system_status_q"}, | ||
280 | - "majordome.tasks.system_restart": {"queue": "system_status_q"}, | ||
281 | - "majordome.tasks.change_obs_conditions": {"queue": "change_obs_conditions_q"}, | ||
282 | - "monitoring.tasks.monitoring": {"queue": "monitoring_q"}, | ||
283 | - "observation_manager.tasks.execute_plan_vis": {"queue": "execute_plan_vis_q"}, | ||
284 | - "observation_manager.tasks.execute_plan_nir": {"queue": "execute_plan_nir_q"}, | ||
285 | - "observation_manager.tasks.create_calibrations": {"queue": "create_calibrations_q"}, | ||
286 | - "scheduler.tasks.scheduling": {"queue": "scheduling_q"}, | ||
287 | -} | ||
288 | - | ||
289 | -''' Removes pickle warning ''' | ||
290 | -CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml'] |
src/utils/celme/dates.py
@@ -2,6 +2,7 @@ import datetime | @@ -2,6 +2,7 @@ import datetime | ||
2 | import math | 2 | import math |
3 | import doctest | 3 | import doctest |
4 | import typing | 4 | import typing |
5 | +from typing import Union | ||
5 | try: | 6 | try: |
6 | from .durations import Duration | 7 | from .durations import Duration |
7 | except: | 8 | except: |
@@ -73,7 +74,7 @@ class Date: | @@ -73,7 +74,7 @@ class Date: | ||
73 | # === internal methods | 74 | # === internal methods |
74 | # ======================================================== | 75 | # ======================================================== |
75 | 76 | ||
76 | - def _init(self,date="") -> None: | 77 | + def _init(self,date: Union[str, float] = "") -> None: |
77 | """ Initialize internal attributes. | 78 | """ Initialize internal attributes. |
78 | 79 | ||
79 | :param date: date is a date in any supported format (cf. help(Date)) | 80 | :param date: date is a date in any supported format (cf. help(Date)) |
@@ -1053,7 +1054,7 @@ class Date: | @@ -1053,7 +1054,7 @@ class Date: | ||
1053 | """ | 1054 | """ |
1054 | return self + duration | 1055 | return self + duration |
1055 | 1056 | ||
1056 | - def __sub__(self, object_or_duration): | 1057 | + def __sub__(self, object_or_duration: Union["Date", float]) -> "Date": |
1057 | """ Subtract a duration to a date (returns an object date) or Compute the duration between two date objects. | 1058 | """ Subtract a duration to a date (returns an object date) or Compute the duration between two date objects. |
1058 | 1059 | ||
1059 | Inputs: | 1060 | Inputs: |
src/utils/plc/guitalens_observatory/maintenance_guide.odp
No preview for this file type
src/utils/report/doc/user_guide_module_report.odt
No preview for this file type
src/utils/report/status_json.py
@@ -11,6 +11,9 @@ if (py_pwd not in py_path): | @@ -11,6 +11,9 @@ if (py_pwd not in py_path): | ||
11 | py_pwd = os.getcwd() + "/.." | 11 | py_pwd = os.getcwd() + "/.." |
12 | if (py_pwd not in py_path): | 12 | if (py_pwd not in py_path): |
13 | (os.sys.path).append(py_pwd) | 13 | (os.sys.path).append(py_pwd) |
14 | +py_pwd = os.getcwd() + "/../.." | ||
15 | +if (py_pwd not in py_path): | ||
16 | + (os.sys.path).append(py_pwd) | ||
14 | 17 | ||
15 | import utils.celme as celme | 18 | import utils.celme as celme |
16 | 19 | ||
@@ -25,16 +28,16 @@ class Status_json: | @@ -25,16 +28,16 @@ class Status_json: | ||
25 | 28 | ||
26 | Example a a very wimple Json file report contents: | 29 | Example a a very wimple Json file report contents: |
27 | { | 30 | { |
28 | - "frame_model": "1.1", | ||
29 | - "name_creator": "PLC", | ||
30 | - "version_creator": "20180909", | 31 | + "frame_model": "1.2", |
32 | + "producer_name": "PLC", | ||
33 | + "producer_version": "20180909", | ||
31 | "entities": [ | 34 | "entities": [ |
32 | { | 35 | { |
33 | "entity_name": "PLC_STATUS", | 36 | "entity_name": "PLC_STATUS", |
34 | - "from": "Raspberry", | 37 | + "origin": "Raspberry", |
35 | "version_firmware": "20180924A", | 38 | "version_firmware": "20180924A", |
36 | "site": "MyObservatory", | 39 | "site": "MyObservatory", |
37 | - "date": "2018-09-25T22:24:16.387", | 40 | + "date": "2018-11-29T15:07:20.999", |
38 | "devices": [ | 41 | "devices": [ |
39 | { | 42 | { |
40 | "device_name": "DHT22", | 43 | "device_name": "DHT22", |
@@ -44,10 +47,10 @@ Example a a very wimple Json file report contents: | @@ -44,10 +47,10 @@ Example a a very wimple Json file report contents: | ||
44 | "device_values": [ | 47 | "device_values": [ |
45 | { | 48 | { |
46 | "name": "OutsideTemperature", | 49 | "name": "OutsideTemperature", |
47 | - "type": "float", | 50 | + "data_type": "float", |
48 | "value": "22", | 51 | "value": "22", |
49 | "unit": "degC", | 52 | "unit": "degC", |
50 | - "monitoring_name": "temperature", | 53 | + "monitoring_name": "Temperature_outside", |
51 | "comment": "Temperature" | 54 | "comment": "Temperature" |
52 | } | 55 | } |
53 | ] | 56 | ] |
@@ -56,7 +59,7 @@ Example a a very wimple Json file report contents: | @@ -56,7 +59,7 @@ Example a a very wimple Json file report contents: | ||
56 | } | 59 | } |
57 | ] | 60 | ] |
58 | } | 61 | } |
59 | - | 62 | + |
60 | A value is stored in a UFKI (Unique Four Key Identifier): | 63 | A value is stored in a UFKI (Unique Four Key Identifier): |
61 | UFKI = entity_name device_name serial_number name | 64 | UFKI = entity_name device_name serial_number name |
62 | 65 | ||
@@ -238,16 +241,16 @@ https://github.com/hjson/hjson-py | @@ -238,16 +241,16 @@ https://github.com/hjson/hjson-py | ||
238 | # To create a Status | 241 | # To create a Status |
239 | #################################################################### | 242 | #################################################################### |
240 | 243 | ||
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':[]} | 244 | + def _status_new(self, producer_name, producer_version): |
245 | + status_header = {'frame_model':'1.2', 'producer_name':producer_name, 'producer_version':producer_version, 'entities':[]} | ||
243 | #self._status = { 'statuses':[] } | 246 | #self._status = { 'statuses':[] } |
244 | #self._status['statuses'].append(status_header) | 247 | #self._status['statuses'].append(status_header) |
245 | self._status = status_header | 248 | self._status = status_header |
246 | 249 | ||
247 | - def _status_new_entity(self, entity_name, thefrom, version_firmware, site, date=""): | 250 | + def _status_new_entity(self, entity_name, theorigin, version_firmware, site, date=""): |
248 | if date=="": | 251 | if date=="": |
249 | date = (celme.Date("now")).iso() | 252 | date = (celme.Date("now")).iso() |
250 | - entity= {'entity_name':entity_name, 'from':thefrom, 'version_firmware':version_firmware, 'site':site, 'date':date, 'devices':[]} | 253 | + entity= {'entity_name':entity_name, 'origin':theorigin, 'version_firmware':version_firmware, 'site':site, 'date':date, 'devices':[]} |
251 | #self._status['statuses'][0]['entities'].append(entity); | 254 | #self._status['statuses'][0]['entities'].append(entity); |
252 | self._status['entities'].append(entity); | 255 | self._status['entities'].append(entity); |
253 | 256 | ||
@@ -260,7 +263,7 @@ https://github.com/hjson/hjson-py | @@ -260,7 +263,7 @@ https://github.com/hjson/hjson-py | ||
260 | #self._status['statuses'][0]['entities'][indicee]['devices'].append(device) | 263 | #self._status['statuses'][0]['entities'][indicee]['devices'].append(device) |
261 | self._status['entities'][indicee]['devices'].append(device) | 264 | self._status['entities'][indicee]['devices'].append(device) |
262 | 265 | ||
263 | - def _status_entity_device_new_value(self, entity_name, device_name, serial_number, name, thetype, value, unit="", monitoring_name="", comment=""): | 266 | + def _status_entity_device_new_value(self, entity_name, device_name, serial_number, name, data_type, value, unit="", monitoring_name="", comment=""): |
264 | entities = self._get_entity_names() | 267 | entities = self._get_entity_names() |
265 | indicee = self._get_indice_from_entities(entities,entity_name) | 268 | indicee = self._get_indice_from_entities(entities,entity_name) |
266 | if indicee == -1: | 269 | if indicee == -1: |
@@ -270,7 +273,7 @@ https://github.com/hjson/hjson-py | @@ -270,7 +273,7 @@ https://github.com/hjson/hjson-py | ||
270 | indiced = self._get_indice_from_devices(devices, device_name, serial_number) | 273 | indiced = self._get_indice_from_devices(devices, device_name, serial_number) |
271 | if indiced == -1: | 274 | if indiced == -1: |
272 | return "" | 275 | return "" |
273 | - dico = {'name':name, 'type':thetype, 'value':value, 'unit':unit, 'monitoring_name':monitoring_name, 'comment':comment} | 276 | + dico = {'name':name, 'data_type':data_type, 'value':value, 'unit':unit, 'monitoring_name':monitoring_name, 'comment':comment} |
274 | #self._status['statuses'][0]['entities'][indicee]['devices'][indiced]['device_values'].append(dico) | 277 | #self._status['statuses'][0]['entities'][indicee]['devices'][indiced]['device_values'].append(dico) |
275 | self._status['entities'][indicee]['devices'][indiced]['device_values'].append(dico) | 278 | self._status['entities'][indicee]['devices'][indiced]['device_values'].append(dico) |
276 | 279 | ||
@@ -278,7 +281,7 @@ https://github.com/hjson/hjson-py | @@ -278,7 +281,7 @@ https://github.com/hjson/hjson-py | ||
278 | # === status_json methods | 281 | # === status_json methods |
279 | # ======================================================== | 282 | # ======================================================== |
280 | 283 | ||
281 | - def new_status(self, name_creator, version_creator): | 284 | + def new_status(self, producer_name, producer_version): |
282 | """ Initialize a new status | 285 | """ Initialize a new status |
283 | 286 | ||
284 | Inputs: | 287 | Inputs: |
@@ -295,9 +298,9 @@ https://github.com/hjson/hjson-py | @@ -295,9 +298,9 @@ https://github.com/hjson/hjson-py | ||
295 | Method append_entity | 298 | Method append_entity |
296 | """ | 299 | """ |
297 | self._init() | 300 | self._init() |
298 | - self._status_new(name_creator, version_creator) | 301 | + self._status_new(producer_name, producer_version) |
299 | 302 | ||
300 | - def append_entity(self, entity_name, thefrom, version_firmware, site, date=""): | 303 | + def append_entity(self, entity_name, theorigin, version_firmware, site, date=""): |
301 | """ Append a new entity to a creator | 304 | """ Append a new entity to a creator |
302 | 305 | ||
303 | Inputs: | 306 | Inputs: |
@@ -314,7 +317,7 @@ https://github.com/hjson/hjson-py | @@ -314,7 +317,7 @@ https://github.com/hjson/hjson-py | ||
314 | --------------- | 317 | --------------- |
315 | Methods append_device, get_entities | 318 | Methods append_device, get_entities |
316 | """ | 319 | """ |
317 | - self._status_new_entity(entity_name, thefrom, version_firmware, site, date) | 320 | + self._status_new_entity(entity_name, theorigin, version_firmware, site, date) |
318 | self._entity_name = entity_name | 321 | self._entity_name = entity_name |
319 | 322 | ||
320 | def append_device(self, device_name, device_type, serial_number, error_code): | 323 | def append_device(self, device_name, device_type, serial_number, error_code): |
@@ -340,7 +343,7 @@ https://github.com/hjson/hjson-py | @@ -340,7 +343,7 @@ https://github.com/hjson/hjson-py | ||
340 | self._device_name = device_name | 343 | self._device_name = device_name |
341 | self._serial_number = serial_number | 344 | self._serial_number = serial_number |
342 | 345 | ||
343 | - def append_value(self, name, thetype, value, unit="", monitoring_name="", comment=""): | 346 | + def append_value(self, name, data_type, value, unit="", monitoring_name="", comment=""): |
344 | """ Append a new value to a device | 347 | """ Append a new value to a device |
345 | 348 | ||
346 | Inputs: | 349 | Inputs: |
@@ -362,7 +365,7 @@ https://github.com/hjson/hjson-py | @@ -362,7 +365,7 @@ https://github.com/hjson/hjson-py | ||
362 | entity_name = self._entity_name | 365 | entity_name = self._entity_name |
363 | device_name = self._device_name | 366 | device_name = self._device_name |
364 | serial_number = self._serial_number | 367 | serial_number = self._serial_number |
365 | - self._status_entity_device_new_value(entity_name, device_name, serial_number, name, thetype, value, unit, monitoring_name, comment) | 368 | + self._status_entity_device_new_value(entity_name, device_name, serial_number, name, data_type, value, unit, monitoring_name, comment) |
366 | 369 | ||
367 | def load_json(self, full_filename): | 370 | def load_json(self, full_filename): |
368 | """ Load a Json file as an object | 371 | """ Load a Json file as an object |
@@ -483,7 +486,7 @@ https://github.com/hjson/hjson-py | @@ -483,7 +486,7 @@ https://github.com/hjson/hjson-py | ||
483 | res.append(re) | 486 | res.append(re) |
484 | return res | 487 | return res |
485 | 488 | ||
486 | - def get_values(self, only_device_name="", only_serial_number="", getvalue=False): | 489 | + def get_ufkis(self, only_device_name="", only_serial_number="", getvalue=False): |
487 | """ Get the current values | 490 | """ Get the current values |
488 | 491 | ||
489 | Inputs: | 492 | Inputs: |
@@ -494,6 +497,7 @@ https://github.com/hjson/hjson-py | @@ -494,6 +497,7 @@ https://github.com/hjson/hjson-py | ||
494 | ------ | 497 | ------ |
495 | >>> report = report.Status_json() | 498 | >>> report = report.Status_json() |
496 | >>> print("{}",format(report.get_devices())) | 499 | >>> print("{}",format(report.get_devices())) |
500 | + >>> print("{}",format(report.get_ufkis("","",True)) | ||
497 | 501 | ||
498 | Related topics: | 502 | Related topics: |
499 | --------------- | 503 | --------------- |
@@ -521,6 +525,16 @@ https://github.com/hjson/hjson-py | @@ -521,6 +525,16 @@ https://github.com/hjson/hjson-py | ||
521 | res.append(re) | 525 | res.append(re) |
522 | return res | 526 | return res |
523 | 527 | ||
528 | + def get_sensors(self, only_device_name="", only_serial_number="", getvalue=False): | ||
529 | + """ Get the current values. Alias of get_ufkis. | ||
530 | + """ | ||
531 | + return self.get_ufkis(only_device_name, only_serial_number, getvalue); | ||
532 | + | ||
533 | + def get_values(self, only_device_name="", only_serial_number="", getvalue=False): | ||
534 | + """ Get the current values. Alias of get_ufkis. | ||
535 | + """ | ||
536 | + return self.get_ufkis(only_device_name, only_serial_number, getvalue); | ||
537 | + | ||
524 | 538 | ||
525 | # ======================================================== | 539 | # ======================================================== |
526 | # === debug methods | 540 | # === debug methods |
@@ -604,10 +618,10 @@ if __name__ == "__main__": | @@ -604,10 +618,10 @@ if __name__ == "__main__": | ||
604 | rep.append_device("DHT22", "meteo", "1", "0") | 618 | rep.append_device("DHT22", "meteo", "1", "0") |
605 | rep.append_value( "OutsideTemperature", "float","22","degC","Temperature_outside","Temperature") | 619 | rep.append_value( "OutsideTemperature", "float","22","degC","Temperature_outside","Temperature") |
606 | # --- List the UFKIs | 620 | # --- List the UFKIs |
607 | - ufiks = rep.get_values("","",False) | 621 | + ufkis = rep.get_ufkis("","",False) |
608 | print(" List of all UFKIs:") | 622 | print(" List of all UFKIs:") |
609 | - for ufik in ufiks: | ||
610 | - print(" UFKI = {}".format(ufik)) | 623 | + for ufki in ufkis: |
624 | + print(" UFKI = {}".format(ufki)) | ||
611 | # --- save the Json file | 625 | # --- save the Json file |
612 | rep.save_json("plc_verysimple.json") | 626 | rep.save_json("plc_verysimple.json") |
613 | 627 | ||
@@ -646,12 +660,10 @@ if __name__ == "__main__": | @@ -646,12 +660,10 @@ if __name__ == "__main__": | ||
646 | rep.append_value( "SkyTemperature", "float","-15.67","degC","Temperature_sky","Temperature of the sky") | 660 | rep.append_value( "SkyTemperature", "float","-15.67","degC","Temperature_sky","Temperature of the sky") |
647 | rep.append_value( "CanTemperature", "float","22.47","degC","","Temperature of the TO can") | 661 | rep.append_value( "CanTemperature", "float","22.47","degC","","Temperature of the TO can") |
648 | # --- List the UFKIs | 662 | # --- List the UFKIs |
649 | - ufiks = rep.get_values("","",False) | 663 | + ufkis = rep.get_ufkis("","",False) |
650 | print(" List of all UFKIs:") | 664 | print(" List of all UFKIs:") |
651 | - for ufik in ufiks: | ||
652 | - print(" UFKI = {}".format(ufik)) | ||
653 | - # --- read the value of one UFKI | ||
654 | - | 665 | + for ufki in ufkis: |
666 | + print(" UFKI = {}".format(ufki)) | ||
655 | # --- save the Json file | 667 | # --- save the Json file |
656 | rep.save_json("plc_guitalens.json") | 668 | rep.save_json("plc_guitalens.json") |
657 | 669 | ||
@@ -667,6 +679,6 @@ if __name__ == "__main__": | @@ -667,6 +679,6 @@ if __name__ == "__main__": | ||
667 | res = rep.get_devices() | 679 | res = rep.get_devices() |
668 | print(" devices = {}".format(res)) | 680 | print(" devices = {}".format(res)) |
669 | print(" List of all UFKIs:") | 681 | print(" List of all UFKIs:") |
670 | - ufiks = rep.get_values("","",False) | ||
671 | - for ufik in ufiks: | ||
672 | - print(" UFKI = {}".format(ufik)) | 682 | + ufkis = rep.get_ufkis("","",True) |
683 | + for ufki in ufkis: | ||
684 | + print(" UFKI = {}".format(ufki)) |