Commit 3d4ab326f5731439a7ddc7bedd5aade801666257

Authored by Alexis Koralewski
1 parent 68d2b8cc
Exists in dev

adding new attributes to obsconfig, devices config

config/components/MountPointing.yml
@@ -42,3 +42,21 @@ @@ -42,3 +42,21 @@
42 is_editable: False 42 is_editable: False
43 label: "Real mount" 43 label: "Real mount"
44 description: "" 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 \ No newline at end of file 63 \ No newline at end of file
config/devices/device_Astromecca_TM350_generic.yml
@@ -35,6 +35,7 @@ DEVICE: @@ -35,6 +35,7 @@ DEVICE:
35 - attribute: 35 - attribute:
36 key: manufacturer 36 key: manufacturer
37 value: AstroMecCA 37 value: AstroMecCA
  38 + is_editable: False
38 39
39 - attribute: 40 - attribute:
40 key: model 41 key: model
@@ -51,3 +52,14 @@ DEVICE: @@ -51,3 +52,14 @@ DEVICE:
51 - attribute: 52 - attribute:
52 key: connect_real_mount 53 key: connect_real_mount
53 value: False 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
@@ -29,6 +29,8 @@ schema;schema_component_attributes: @@ -29,6 +29,8 @@ schema;schema_component_attributes:
29 type: any 29 type: any
30 description: 30 description:
31 type: any 31 type: any
  32 + placeholder:
  33 + type: str
32 34
33 schema;schema_capability: 35 schema;schema_capability:
34 type: map 36 type: map
config/schemas/schema_observatory-2.0.yml
@@ -54,6 +54,9 @@ schema;schema_GROUP: @@ -54,6 +54,9 @@ schema;schema_GROUP:
54 mapping: 54 mapping:
55 logic: 55 logic:
56 type: str 56 type: str
  57 + name:
  58 + type: str
  59 + required: True
57 channels: 60 channels:
58 type: seq 61 type: seq
59 required: True 62 required: True
@@ -66,6 +69,7 @@ schema;schema_CHANNEL_GROUPS: @@ -66,6 +69,7 @@ schema;schema_CHANNEL_GROUPS:
66 mapping: 69 mapping:
67 logic: 70 logic:
68 type: str 71 type: str
  72 +
69 GROUPS: 73 GROUPS:
70 type: seq 74 type: seq
71 sequence: 75 sequence:
privatedev/config/default/observatory_default.yml
@@ -130,6 +130,7 @@ OBSERVATORY: @@ -130,6 +130,7 @@ OBSERVATORY:
130 GROUPS: 130 GROUPS:
131 - GROUP: 131 - GROUP:
132 logic: 'and' # opt 132 logic: 'and' # opt
  133 + name: MainChannel
133 channels: 134 channels:
134 - OpticalChannel 135 - OpticalChannel
135 136
privatedev/config/guitalens/observatory_guitalens.yml
@@ -107,7 +107,7 @@ OBSERVATORY: @@ -107,7 +107,7 @@ OBSERVATORY:
107 - AGENT_DEVICE: 107 - AGENT_DEVICE:
108 name: mount 108 name: mount
109 computer: EtienneComputer 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 path: private/plugin/agent_devices 111 path: private/plugin/agent_devices
112 device: AstroMecCA_TM350 112 device: AstroMecCA_TM350
113 protocol: private/plugin/agent_devices/mount_protocol.py 113 protocol: private/plugin/agent_devices/mount_protocol.py
@@ -162,5 +162,6 @@ OBSERVATORY: @@ -162,5 +162,6 @@ OBSERVATORY:
162 GROUPS: 162 GROUPS:
163 - GROUP: 163 - GROUP:
164 logic: 'and' # opt 164 logic: 'and' # opt
  165 + name: MainChannel
165 channels: 166 channels:
166 - OpticalChannel_up 167 - OpticalChannel_up
privatedev/config/tnc/observatory_tnc.yml
@@ -296,10 +296,11 @@ OBSERVATORY: @@ -296,10 +296,11 @@ OBSERVATORY:
296 296
297 CHANNEL_GROUPS: 297 CHANNEL_GROUPS:
298 298
299 - logic: 'or' # opt 299 + logic: 'or' # opt, for groups: or = xor + tous
300 GROUPS: 300 GROUPS:
301 - GROUP: 301 - GROUP:
302 - logic: 'and' # opt 302 + logic: 'and' # opt, within groups: and -> plan defined on all channels
  303 + name: "MainChannel"
303 channels: 304 channels:
304 - OpticalChannel_up1 305 - OpticalChannel_up1
305 - OpticalChannel_up2 306 - OpticalChannel_up2
src/core/pyros_django/obsconfig/configpyros.py
@@ -66,56 +66,59 @@ class ConfigPyros: @@ -66,56 +66,59 @@ class ConfigPyros:
66 return True 66 return True
67 return False 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 pickle_dict = {} 112 pickle_dict = {}
94 113
95 self.obs_config = self.read_and_check_config_file(observatory_config_file) 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 pickle_dict["obs_config"] = self.obs_config 115 pickle_dict["obs_config"] = self.obs_config
101 pickle_dict["devices"] = self.get_devices() 116 pickle_dict["devices"] = self.get_devices()
102 pickle_dict["computers"] = self.get_computers() 117 pickle_dict["computers"] = self.get_computers()
103 pickle_dict["devices_links"] = self.devices_links 118 pickle_dict["devices_links"] = self.devices_links
104 pickle_dict["obs_config_file_content"] = self.read_and_check_config_file(observatory_config_file) 119 pickle_dict["obs_config_file_content"] = self.read_and_check_config_file(observatory_config_file)
105 print("Writing pickle file") 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 def check_and_return_config(self,yaml_file:str,schema_file:str)->dict: 123 def check_and_return_config(self,yaml_file:str,schema_file:str)->dict:
121 """ 124 """
@@ -581,7 +584,7 @@ class ConfigPyros: @@ -581,7 +584,7 @@ class ConfigPyros:
581 info["groups"] = {} 584 info["groups"] = {}
582 for group_id in range(len(unit["TOPOLOGY"]["CHANNEL_GROUPS"]["GROUPS"])): 585 for group_id in range(len(unit["TOPOLOGY"]["CHANNEL_GROUPS"]["GROUPS"])):
583 group = unit["TOPOLOGY"]["CHANNEL_GROUPS"]["GROUPS"][group_id]["GROUP"] 586 group = unit["TOPOLOGY"]["CHANNEL_GROUPS"]["GROUPS"][group_id]["GROUP"]
584 - info["groups"][group_id] = group 587 + info["groups"][group["name"]] = group
585 return info 588 return info
586 589
587 def get_channel_information(self, unit_name: str, channel_name: str) -> dict: 590 def get_channel_information(self, unit_name: str, channel_name: str) -> dict:
@@ -970,11 +973,28 @@ class ConfigPyros: @@ -970,11 +973,28 @@ class ConfigPyros:
970 if len(attributes.keys()) > 0: 973 if len(attributes.keys()) > 0:
971 merged_result.append(attributes) 974 merged_result.append(attributes)
972 return merged_result 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 def main(): 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 #print(config.getDeviceConfigForDeviceController(dc)) 998 #print(config.getDeviceConfigForDeviceController(dc))
979 #print(config.getCommParamsForAgentDevice(unit_name,"mount")) 999 #print(config.getCommParamsForAgentDevice(unit_name,"mount"))
980 # print(config.getChannelCapabilities(unit_name,"OpticalChannel_up")) 1000 # print(config.getChannelCapabilities(unit_name,"OpticalChannel_up"))
@@ -983,13 +1003,14 @@ def main(): @@ -983,13 +1003,14 @@ def main():
983 # print(config.getEditableAttributesOfChannel(unit_name,"OpticalChannel_up")) 1003 # print(config.getEditableAttributesOfChannel(unit_name,"OpticalChannel_up"))
984 config = ConfigPyros("../../../../privatedev/config/tnc/observatory_tnc.yml") 1004 config = ConfigPyros("../../../../privatedev/config/tnc/observatory_tnc.yml")
985 unit_name = config.get_units_name()[0] 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 #print(config.getDeviceConfigForDeviceController(dc)) 1007 #print(config.getDeviceConfigForDeviceController(dc))
988 #print(config.getCommParamsForAgentDevice(unit_name,"mount")) 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 #print(config.get_devices()["FLI-Kepler4040"]["device_config"]) 1014 #print(config.get_devices()["FLI-Kepler4040"]["device_config"])
994 #print(config.get_devices()["FLI-Kepler4040"]["device_config"]["CAPABILITIES"][1]["attributes"]["manufacturer"]) 1015 #print(config.get_devices()["FLI-Kepler4040"]["device_config"]["CAPABILITIES"][1]["attributes"]["manufacturer"])
995 #print(config.get_devices()["FLI-Kepler4040"]["device_config"]["CAPABILITIES"]) 1016 #print(config.get_devices()["FLI-Kepler4040"]["device_config"]["CAPABILITIES"])
src/core/pyros_django/obsconfig/fixtures/observatory_configuration_ko.yml
@@ -130,5 +130,6 @@ OBSERVATORY: @@ -130,5 +130,6 @@ OBSERVATORY:
130 GROUPS: 130 GROUPS:
131 - GROUP: 131 - GROUP:
132 logic: 'and' # opt 132 logic: 'and' # opt
  133 + name: test
133 channels: 134 channels:
134 - OpticalChannel 135 - OpticalChannel
src/core/pyros_django/obsconfig/fixtures/observatory_configuration_ok_complex.yml
@@ -131,5 +131,6 @@ OBSERVATORY: @@ -131,5 +131,6 @@ OBSERVATORY:
131 GROUPS: 131 GROUPS:
132 - GROUP: 132 - GROUP:
133 logic: 'and' # opt 133 logic: 'and' # opt
  134 + name: MainChannel
134 channels: 135 channels:
135 - OpticalChannel 136 - OpticalChannel
src/core/pyros_django/obsconfig/fixtures/observatory_configuration_ok_simple.yml
@@ -127,5 +127,6 @@ OBSERVATORY: @@ -127,5 +127,6 @@ OBSERVATORY:
127 GROUPS: 127 GROUPS:
128 - GROUP: 128 - GROUP:
129 logic: 'and' # opt 129 logic: 'and' # opt
  130 + name: MainChannel
130 channels: 131 channels:
131 - OpticalChannel 132 - OpticalChannel