Commit 514b20f7b488bd8b85bd9cbfd1110affbf6504c0
1 parent
1ad759ec
Exists in
dev
Correction bug dans ConfigPyro. L'agentX fonctionne !
Showing
3 changed files
with
34 additions
and
22 deletions
Show diff stats
config/config_unit_simulunit1.xml
... | ... | @@ -10,16 +10,23 @@ section, key, value, type, unit, access, comment, label, reference, timestamp |
10 | 10 | * Mandatory |
11 | 11 | section : Category of the keyword |
12 | 12 | key : Key of the keyword |
13 | -value : Useful value of the keyword | |
13 | +value : Useful value of the keyword (=default value when defining a HTML form) | |
14 | 14 | |
15 | 15 | * Optional |
16 | 16 | type : Python type to interpret the value |
17 | 17 | unit : Physical value to allow conversions |
18 | 18 | access : 0brwrwrw (rw for PI-Mount, rw for Maintenance, rw for Astronomers) |
19 | 19 | comment : Comment to be added as a popup in the web page |
20 | -label : Text to describe the value in a web page (e.g. forms) | |
20 | +label : Text to describe the value | |
21 | 21 | reference : Refere to the source of the value |
22 | 22 | timestamp : Date when the value has been last updated |
23 | +default_value : Default value (useful for web forms) | |
24 | + | |
25 | +* Optional to describe a HTML form <form> | |
26 | +label : HTML Text to describe the value in a web page (for forms) | |
27 | +element : HTML form element tag (input, select, etc.) | |
28 | +element_attribute : HTML form element attributes | |
29 | +options : HTML tag <option> contents in case of HTML element <select> | |
23 | 30 | |
24 | 31 | ============================================================================= |
25 | 32 | --> |
... | ... | @@ -125,12 +132,12 @@ timestamp : Date when the value has been last updated |
125 | 132 | <param section="horizon" key="amer_list" value="(0, 10), (50, 15), (60,10)" type="tuple" unit="Angle"/> |
126 | 133 | <!-- Plan description of this channel for the web form and observations --> |
127 | 134 | <plan> |
128 | - <param section="form" key="filter" label="Filter" default_value="" element="input" element_attribute=''/> | |
129 | - <param section="form" key="binning" label="Binning" default_value="" element="select" element_attribute="" options="param detector binnings"/> | |
130 | - <param section="form" key="exptime" label="Exposure time (s)" default_value="1" element="range" element_attribute='min="0.1" max="100"'/> | |
131 | - <param section="form" key="nb_images" label="Number image" default_value="1" element="range" element_attribute='min="1" max="10000"'/> | |
132 | - <param section="form" key="shutter" label="Shutter mode" default_value="1" element="select" element_attribute="" options="param detector shutter_mode"/> | |
133 | - <param section="form" key="delay" label="Delay start (s)" default_value="0" element="range" element_attribute='min="0" max="100"'/> | |
135 | + <param section="form" key="shutter" label="Shutter mode" value="1" element_tag="select" element_attributes='required' options="param DetectorShutter mode"/> | |
136 | + <param section="form" key="filter" label="Filter" value="" element_tag="select" element_attributes='required' options="param FilterSelector symbols"/> | |
137 | + <param section="form" key="binning" label="Binning" value="" element_tag="select" element_attributes='required' options="param DetectorSensor binnings"/> | |
138 | + <param section="form" key="exptime" label="Exposure time (s)" value="1" element_tag="input" element_attributes='type="number" step="any" min="0.1" max="100"'/> | |
139 | + <param section="form" key="nb_images" label="Number images" value="1" element_tag="input" element_attributes='type="number" step="1" min="1" max="10000"'/> | |
140 | + <param section="form" key="delay" label="Delay start (s)" value="0" element_tag="input" element_attributes='type="number" step="any" min="0" max="100"'/> | |
134 | 141 | </plan> |
135 | 142 | </channel> |
136 | 143 | ... | ... |
config/configpyros.py
... | ... | @@ -117,7 +117,7 @@ class ConfigPyros: |
117 | 117 | print("============== Aliases of <" + tag + ">") |
118 | 118 | |
119 | 119 | attrib_key_to_get = 'alias' |
120 | - aliases = config.get_attribute_level0(xpath,attrib_key_to_get) | |
120 | + aliases = self.get_attribute_level0(xpath,attrib_key_to_get) | |
121 | 121 | if (verbose==True): |
122 | 122 | print("<{} {}> = {}".format(xpath, attrib_key_to_get, aliases)) |
123 | 123 | if aliases == [None]: |
... | ... | @@ -134,7 +134,7 @@ class ConfigPyros: |
134 | 134 | tag_to_get = "param" |
135 | 135 | tag_attrib_to_select = {'section': 'assembly', 'key': 'alias'} |
136 | 136 | tag_attrib_key_to_get = 'value' |
137 | - assembled_aliases = config.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
137 | + assembled_aliases = self.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
138 | 138 | if (verbose==True): |
139 | 139 | print("{} <{} {}> = {}".format(attrib_to_select, tag_to_get, tag_attrib_to_select, assembled_aliases)) |
140 | 140 | |
... | ... | @@ -198,7 +198,7 @@ class ConfigPyros: |
198 | 198 | tag_attrib_key_to_get = 'value' |
199 | 199 | for alias in aliases: |
200 | 200 | attrib_to_select = {'alias': alias} |
201 | - hname = config.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
201 | + hname = self.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
202 | 202 | if hname[0] == hostname: |
203 | 203 | this_computer_alias = alias |
204 | 204 | |
... | ... | @@ -505,7 +505,7 @@ class ConfigPyros: |
505 | 505 | tag_attrib_to_select = "" |
506 | 506 | tag_attrib_key_to_get = "" |
507 | 507 | #print("get_params alias={} subtag={} xpath={}".format(alias,subtag,xpath)) |
508 | - value = config.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
508 | + value = self.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
509 | 509 | #print("{} <{} {}> = {}".format(attrib_to_select, tag_to_get, tag_attrib_to_select, value)) |
510 | 510 | if (len(value)>0): |
511 | 511 | return value |
... | ... | @@ -524,7 +524,7 @@ class ConfigPyros: |
524 | 524 | tag_attrib_to_select = {'section': section, 'key': key} |
525 | 525 | tag_attrib_key_to_get = "" |
526 | 526 | #print("get_param alias={} subtag={} xpath={}".format(alias,subtag,xpath)) |
527 | - value = config.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
527 | + value = self.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
528 | 528 | #print("{} <{} {}> = {}".format(attrib_to_select, tag_to_get, tag_attrib_to_select, value)) |
529 | 529 | if (len(value)>0): |
530 | 530 | return value[0] |
... | ... | @@ -543,7 +543,7 @@ class ConfigPyros: |
543 | 543 | tag_attrib_to_select = {'section': section, 'key': key} |
544 | 544 | tag_attrib_key_to_get = 'value' |
545 | 545 | #print("get_paramvalue alias={} subtag={} xpath={}".format(alias,subtag,xpath)) |
546 | - value = config.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
546 | + value = self.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
547 | 547 | #print("{} <{} {}> = {}".format(attrib_to_select, tag_to_get, tag_attrib_to_select, value)) |
548 | 548 | if (len(value)>0): |
549 | 549 | return value[0] |
... | ... | @@ -564,7 +564,7 @@ class ConfigPyros: |
564 | 564 | tag_attrib_to_select = "" |
565 | 565 | tag_attrib_key_to_get = "" |
566 | 566 | #print("get_plan alias={} subtag={} xpath={}".format(alias,subtag,xpath)) |
567 | - value = config.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
567 | + value = self.get_attribute_level1(xpath,attrib_to_select,tag_to_get,tag_attrib_to_select,tag_attrib_key_to_get) | |
568 | 568 | #print("{} <{} {}> = {}".format(attrib_to_select, tag_to_get, tag_attrib_to_select, value)) |
569 | 569 | if (len(value)>0): |
570 | 570 | return value |
... | ... | @@ -615,7 +615,7 @@ if __name__ == "__main__": |
615 | 615 | else: |
616 | 616 | |
617 | 617 | # --- Load the configuration file if needed only (i.e. modified) |
618 | - config.load() | |
618 | + config.load(False) | |
619 | 619 | |
620 | 620 | if config.get_last_errno() != config.NO_ERROR: |
621 | 621 | ... | ... |
src/agent/Agent.py
... | ... | @@ -107,9 +107,10 @@ class Agent: |
107 | 107 | #print("this file path :", __file__) |
108 | 108 | #print("config file path is", config_filename) |
109 | 109 | # Instantiate an object for configuration |
110 | + #print("config file path is ", config_abs_filename) | |
110 | 111 | self.config = ConfigPyros(config_abs_filename) |
111 | 112 | if self.config.get_last_errno() != self.config.NO_ERROR: |
112 | - raise Exception(f"Bad config file name '{config_abs_filename}', error code {str(self.config.get_last_errno())}") | |
113 | + raise Exception(f"Bad config file name '{config_abs_filename}', error {str(self.config.get_last_errno())}: {str(self.config.get_last_errmsg())}") | |
113 | 114 | |
114 | 115 | |
115 | 116 | def __str__(self): |
... | ... | @@ -260,12 +261,16 @@ class Agent: |
260 | 261 | #config_filename = 'c:/srv/develop/pyros/config/config_unit_simulunit1.xml' |
261 | 262 | #config.set_configfile(config_filename) |
262 | 263 | self.config.load() |
263 | - # --- get the parameter value of <mount1/localization/home> | |
264 | - instantiation = 'mount1' | |
265 | - section = 'localization' | |
264 | + if self.config.get_last_errno() != self.config.NO_ERROR: | |
265 | + raise Exception(f"error {str(self.config.get_last_errno())}: {str(self.config.get_last_errmsg())}") | |
266 | + # --- Get the home of the mount[0] | |
267 | + assembly_component = 'mount' | |
268 | + assembly_index = 0 | |
269 | + section = 'MountPointing' | |
266 | 270 | key = 'home' |
267 | - paramvalue = self.config.get_paramvalue(instantiation, section, key) | |
268 | - print("paramvalue <{}/{}/{}> = {}".format(instantiation, section, key,paramvalue)) | |
271 | + mount_alias = self.config.get_aliases(assembly_component)[assembly_index] | |
272 | + paramvalue = self.config.get_paramvalue(mount_alias,section, key) | |
273 | + print("paramvalue <{}/{}/{}> = {}".format(assembly_component, section, key, paramvalue)) | |
269 | 274 | |
270 | 275 | """ |
271 | 276 | # self.config = Config.objects.get(pk=1) | ... | ... |