Commit 3d4ab326f5731439a7ddc7bedd5aade801666257
1 parent
68d2b8cc
Exists in
dev
adding new attributes to obsconfig, devices config
Showing
11 changed files
with
116 additions
and
53 deletions
Show diff stats
config/components/MountPointing.yml
... | ... | @@ -42,3 +42,21 @@ |
42 | 42 | is_editable: False |
43 | 43 | label: "Real mount" |
44 | 44 | description: "" |
45 | + | |
46 | +- attribute: | |
47 | + key: target | |
48 | + is_container: False | |
49 | + value: False | |
50 | + unit: "" | |
51 | + is_editable: False | |
52 | + label: "Target" | |
53 | + description: "" | |
54 | + | |
55 | +- attribute: | |
56 | + key: conformation | |
57 | + is_enum: True | |
58 | + value: ["None","WIDE", "NARROW"] | |
59 | + unit: "" | |
60 | + is_editable: False | |
61 | + label: "Conformation" | |
62 | + description: "" | |
45 | 63 | \ No newline at end of file | ... | ... |
config/devices/device_Astromecca_TM350_generic.yml
... | ... | @@ -35,6 +35,7 @@ DEVICE: |
35 | 35 | - attribute: |
36 | 36 | key: manufacturer |
37 | 37 | value: AstroMecCA |
38 | + is_editable: False | |
38 | 39 | |
39 | 40 | - attribute: |
40 | 41 | key: model |
... | ... | @@ -51,3 +52,14 @@ DEVICE: |
51 | 52 | - attribute: |
52 | 53 | key: connect_real_mount |
53 | 54 | value: False |
55 | + | |
56 | + - attribute: | |
57 | + key: target | |
58 | + placeholder: "RADEC 0H10M -15D" | |
59 | + is_editable: True | |
60 | + value: "RADEC 0H10M -15D" | |
61 | + | |
62 | + - attribute: | |
63 | + key: conformation | |
64 | + value: ["WIDE","NARROW"] | |
65 | + is_editable: True | ... | ... |
config/schemas/schema_device-2.0.yml
config/schemas/schema_observatory-2.0.yml
... | ... | @@ -54,6 +54,9 @@ schema;schema_GROUP: |
54 | 54 | mapping: |
55 | 55 | logic: |
56 | 56 | type: str |
57 | + name: | |
58 | + type: str | |
59 | + required: True | |
57 | 60 | channels: |
58 | 61 | type: seq |
59 | 62 | required: True |
... | ... | @@ -66,6 +69,7 @@ schema;schema_CHANNEL_GROUPS: |
66 | 69 | mapping: |
67 | 70 | logic: |
68 | 71 | type: str |
72 | + | |
69 | 73 | GROUPS: |
70 | 74 | type: seq |
71 | 75 | sequence: | ... | ... |
privatedev/config/default/observatory_default.yml
privatedev/config/guitalens/observatory_guitalens.yml
... | ... | @@ -107,7 +107,7 @@ OBSERVATORY: |
107 | 107 | - AGENT_DEVICE: |
108 | 108 | name: mount |
109 | 109 | computer: EtienneComputer |
110 | - comm_access: "//./COM3" # parameters of the comm: support of the device | |
110 | + comm_access: "//./COM3" # parameters of the comm: support of the device, here only for serial comm | |
111 | 111 | path: private/plugin/agent_devices |
112 | 112 | device: AstroMecCA_TM350 |
113 | 113 | protocol: private/plugin/agent_devices/mount_protocol.py |
... | ... | @@ -162,5 +162,6 @@ OBSERVATORY: |
162 | 162 | GROUPS: |
163 | 163 | - GROUP: |
164 | 164 | logic: 'and' # opt |
165 | + name: MainChannel | |
165 | 166 | channels: |
166 | 167 | - OpticalChannel_up | ... | ... |
privatedev/config/tnc/observatory_tnc.yml
... | ... | @@ -296,10 +296,11 @@ OBSERVATORY: |
296 | 296 | |
297 | 297 | CHANNEL_GROUPS: |
298 | 298 | |
299 | - logic: 'or' # opt | |
299 | + logic: 'or' # opt, for groups: or = xor + tous | |
300 | 300 | GROUPS: |
301 | 301 | - GROUP: |
302 | - logic: 'and' # opt | |
302 | + logic: 'and' # opt, within groups: and -> plan defined on all channels | |
303 | + name: "MainChannel" | |
303 | 304 | channels: |
304 | 305 | - OpticalChannel_up1 |
305 | 306 | - OpticalChannel_up2 | ... | ... |
src/core/pyros_django/obsconfig/configpyros.py
... | ... | @@ -66,56 +66,59 @@ class ConfigPyros: |
66 | 66 | return True |
67 | 67 | return False |
68 | 68 | |
69 | - def load(self,observatory_config_file): | |
70 | - does_pickle_needs_to_be_updated = self.verify_if_pickle_needs_to_be_updated(observatory_config_file) | |
71 | - if os.path.isfile(self.CONFIG_PATH+self.pickle_file) and does_pickle_needs_to_be_updated == False: | |
72 | - print("Reading pickle file") | |
73 | - try: | |
74 | - can_pickle_file_be_read = False | |
75 | - while can_pickle_file_be_read != True: | |
76 | - if os.access(self.CONFIG_PATH+self.pickle_file, os.R_OK): | |
77 | - pickle_dict = pickle.load(open(self.CONFIG_PATH+self.pickle_file,"rb")) | |
78 | - can_pickle_file_be_read = True | |
79 | - else: | |
80 | - time.sleep(0.5) | |
81 | - except IOError: | |
82 | - print("Error when reading the pickle file") | |
83 | - try: | |
84 | - self.obs_config = pickle_dict["obs_config"] | |
85 | - self.computers = pickle_dict["computers"] | |
86 | - self.devices = pickle_dict["devices"] | |
87 | - self.devices_links = pickle_dict["devices_links"] | |
88 | - self.obs_config_file_content = pickle_dict["obs_config_file_content"] | |
89 | - self.raw_config = pickle_dict["raw_config"] | |
90 | - except: | |
91 | - # we rewrite the pickle file, the content will be the same otherwise we would be in the else case | |
92 | - print("Rewritting the pickle file (an error occured while reading it, the content will be the same as it was") | |
69 | + def load(self, observatory_config_file): | |
70 | + pickle_needs_to_be_updated = self.verify_if_pickle_needs_to_be_updated(observatory_config_file) | |
71 | + if pickle_needs_to_be_updated == False and self.obs_config != None: | |
72 | + return None | |
73 | + else: | |
74 | + if os.path.isfile(self.CONFIG_PATH+self.pickle_file) and pickle_needs_to_be_updated == False: | |
75 | + print("Reading pickle file") | |
76 | + try: | |
77 | + can_pickle_file_be_read = False | |
78 | + while can_pickle_file_be_read != True: | |
79 | + if os.access(self.CONFIG_PATH+self.pickle_file, os.R_OK): | |
80 | + pickle_dict = pickle.load(open(self.CONFIG_PATH+self.pickle_file,"rb")) | |
81 | + can_pickle_file_be_read = True | |
82 | + else: | |
83 | + time.sleep(0.5) | |
84 | + except IOError: | |
85 | + print("Error when reading the pickle file") | |
86 | + try: | |
87 | + self.obs_config = pickle_dict["obs_config"] | |
88 | + self.computers = pickle_dict["computers"] | |
89 | + self.devices = pickle_dict["devices"] | |
90 | + self.devices_links = pickle_dict["devices_links"] | |
91 | + self.obs_config_file_content = pickle_dict["obs_config_file_content"] | |
92 | + self.raw_config = pickle_dict["raw_config"] | |
93 | + except: | |
94 | + # we rewrite the pickle file, the content will be the same otherwise we would be in the else case | |
95 | + print("Rewritting the pickle file (an error occured while reading it, the content will be the same as it was") | |
96 | + pickle_dict = {} | |
97 | + | |
98 | + self.obs_config = self.read_and_check_config_file(observatory_config_file) | |
99 | + obs_file = open(observatory_config_file,"r") | |
100 | + pickle_dict["raw_config"] = obs_file.read() | |
101 | + obs_file.close() | |
102 | + self.raw_config = pickle_dict["raw_config"] | |
103 | + pickle_dict["obs_config"] = self.obs_config | |
104 | + pickle_dict["devices"] = self.get_devices() | |
105 | + pickle_dict["computers"] = self.get_computers() | |
106 | + pickle_dict["devices_links"] = self.devices_links | |
107 | + pickle_dict["obs_config_file_content"] = self.read_and_check_config_file(observatory_config_file) | |
108 | + print("Writing pickle file") | |
109 | + pickle.dump(pickle_dict,open(self.CONFIG_PATH+self.pickle_file,"wb")) | |
110 | + else: | |
111 | + print("Pickle file needs to be created or updated") | |
93 | 112 | pickle_dict = {} |
94 | 113 | |
95 | 114 | self.obs_config = self.read_and_check_config_file(observatory_config_file) |
96 | - obs_file = open(observatory_config_file,"r") | |
97 | - pickle_dict["raw_config"] = obs_file.read() | |
98 | - obs_file.close() | |
99 | - self.raw_config = pickle_dict["raw_config"] | |
100 | 115 | pickle_dict["obs_config"] = self.obs_config |
101 | 116 | pickle_dict["devices"] = self.get_devices() |
102 | 117 | pickle_dict["computers"] = self.get_computers() |
103 | 118 | pickle_dict["devices_links"] = self.devices_links |
104 | 119 | pickle_dict["obs_config_file_content"] = self.read_and_check_config_file(observatory_config_file) |
105 | 120 | print("Writing pickle file") |
106 | - pickle.dump(pickle_dict,open(self.CONFIG_PATH+self.pickle_file,"wb")) | |
107 | - else: | |
108 | - print("Pickle file needs to be created or updated") | |
109 | - pickle_dict = {} | |
110 | - | |
111 | - self.obs_config = self.read_and_check_config_file(observatory_config_file) | |
112 | - pickle_dict["obs_config"] = self.obs_config | |
113 | - pickle_dict["devices"] = self.get_devices() | |
114 | - pickle_dict["computers"] = self.get_computers() | |
115 | - pickle_dict["devices_links"] = self.devices_links | |
116 | - pickle_dict["obs_config_file_content"] = self.read_and_check_config_file(observatory_config_file) | |
117 | - print("Writing pickle file") | |
118 | - pickle.dump(pickle_dict,open(self.CONFIG_PATH+self.pickle_file,"wb")) | |
121 | + pickle.dump(pickle_dict,open(self.CONFIG_PATH+self.pickle_file,"wb")) | |
119 | 122 | |
120 | 123 | def check_and_return_config(self,yaml_file:str,schema_file:str)->dict: |
121 | 124 | """ |
... | ... | @@ -581,7 +584,7 @@ class ConfigPyros: |
581 | 584 | info["groups"] = {} |
582 | 585 | for group_id in range(len(unit["TOPOLOGY"]["CHANNEL_GROUPS"]["GROUPS"])): |
583 | 586 | group = unit["TOPOLOGY"]["CHANNEL_GROUPS"]["GROUPS"][group_id]["GROUP"] |
584 | - info["groups"][group_id] = group | |
587 | + info["groups"][group["name"]] = group | |
585 | 588 | return info |
586 | 589 | |
587 | 590 | def get_channel_information(self, unit_name: str, channel_name: str) -> dict: |
... | ... | @@ -970,11 +973,28 @@ class ConfigPyros: |
970 | 973 | if len(attributes.keys()) > 0: |
971 | 974 | merged_result.append(attributes) |
972 | 975 | return merged_result |
976 | + | |
977 | + def getLogicOfChannelGroups(self,unit_name): | |
978 | + return self.get_channel_groups(unit_name)["global_group_logic"] | |
979 | + | |
980 | + | |
981 | + def getGroupOfChannelByName(self, unit_name:str, name_of_channel_group): | |
982 | + return self.get_channel_groups(unit_name)["groups"][name_of_channel_group] | |
983 | + | |
984 | + | |
985 | + def getEditableAttributesOfMount(self,unit_name): | |
986 | + capabilities = self.get_device_capabilities(self.get_device_for_agent(unit_name,"mount")["name"]) | |
987 | + merged_result = [] | |
988 | + for capability in capabilities: | |
989 | + attributes = self.getEditableAttributesOfCapability(capability) | |
990 | + if len(attributes.keys()) > 0: | |
991 | + merged_result.append(attributes) | |
992 | + return merged_result | |
973 | 993 | |
974 | 994 | def main(): |
975 | - config = ConfigPyros("../../../../privatedev/config/guitalens/observatory_guitalens.yml") | |
976 | - unit_name = config.get_units_name()[0] | |
977 | - dc = config.getDeviceControllerNameForAgent(unit_name,"mount")[0] | |
995 | + # config = ConfigPyros("../../../../privatedev/config/guitalens/observatory_guitalens.yml") | |
996 | + # unit_name = config.get_units_name()[0] | |
997 | + # dc = config.getDeviceControllerNameForAgent(unit_name,"mount")[0] | |
978 | 998 | #print(config.getDeviceConfigForDeviceController(dc)) |
979 | 999 | #print(config.getCommParamsForAgentDevice(unit_name,"mount")) |
980 | 1000 | # print(config.getChannelCapabilities(unit_name,"OpticalChannel_up")) |
... | ... | @@ -983,13 +1003,14 @@ def main(): |
983 | 1003 | # print(config.getEditableAttributesOfChannel(unit_name,"OpticalChannel_up")) |
984 | 1004 | config = ConfigPyros("../../../../privatedev/config/tnc/observatory_tnc.yml") |
985 | 1005 | unit_name = config.get_units_name()[0] |
986 | - dc = config.getDeviceControllerNameForAgent(unit_name,"mount")[0] | |
1006 | + #dc = config.getDeviceControllerNameForAgent(unit_name,"mount")[0] | |
987 | 1007 | #print(config.getDeviceConfigForDeviceController(dc)) |
988 | 1008 | #print(config.getCommParamsForAgentDevice(unit_name,"mount")) |
989 | - print(config.getChannelCapabilities(unit_name,"OpticalChannel_down2")) | |
990 | - print(config.get_channel_groups(unit_name)) | |
991 | - print(config.getEditableAttributesOfCapability(config.getChannelCapabilities(unit_name,"OpticalChannel_down2")[0])) | |
992 | - print(config.getEditableAttributesOfChannel(unit_name,"OpticalChannel_down2")) | |
1009 | + # print(config.getChannelCapabilities(unit_name,"OpticalChannel_down2")) | |
1010 | + # print(config.get_channel_groups(unit_name)) | |
1011 | + # print(config.getEditableAttributesOfCapability(config.getChannelCapabilities(unit_name,"OpticalChannel_down2")[0])) | |
1012 | + # print(config.getEditableAttributesOfChannel(unit_name,"OpticalChannel_down2")) | |
1013 | + print(config.getEditableAttributesOfMount(unit_name)) | |
993 | 1014 | #print(config.get_devices()["FLI-Kepler4040"]["device_config"]) |
994 | 1015 | #print(config.get_devices()["FLI-Kepler4040"]["device_config"]["CAPABILITIES"][1]["attributes"]["manufacturer"]) |
995 | 1016 | #print(config.get_devices()["FLI-Kepler4040"]["device_config"]["CAPABILITIES"]) | ... | ... |
src/core/pyros_django/obsconfig/fixtures/observatory_configuration_ko.yml
src/core/pyros_django/obsconfig/fixtures/observatory_configuration_ok_complex.yml