diff --git a/CHANGELOG b/CHANGELOG index 9a4be95..1c65804 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,12 @@ +01-09-2023 (AKo): V0.6.29.0 + - Add fn context to channels in obsconfig class + 28-07-2023 (AKo): V0.6.28.0 - Add command in A_SCP_Manager to generate ephemeris files of sun & moon for a period - Fix AgentSST start one agent - Fix config_pyros paths - Fix JS of agent_detail + - Add Scheduler models 26-07-2023 (AKo): V0.6.27.0 - Remove private & privatedev folder diff --git a/src/core/pyros_django/obs_config/obsconfig_class.py b/src/core/pyros_django/obs_config/obsconfig_class.py index 6b1ebc0..6a6b970 100644 --- a/src/core/pyros_django/obs_config/obsconfig_class.py +++ b/src/core/pyros_django/obs_config/obsconfig_class.py @@ -11,6 +11,8 @@ from datetime import datetime from pykwalify.errors import PyKwalifyException, SchemaError from pathlib import Path +sys.path.append(os.environ.get("PROJECT_ROOT_PATH", os.path.join(os.getcwd(),"../../../../"))) +from vendor.guitastro.src.guitastro import FileNames class OBSConfig: # (AKo) : Config file path is checked on the settings file, if the file isn't valid (i.e not found) the error will be launched by the settings file when starting the application @@ -296,7 +298,22 @@ class OBSConfig: except Exception as e: print(e) return None - + + + def channel_fn_context(self, fn_context:dict): + fn = FileNames() + for context, values in fn_context.items(): + fn.fcontext_create(context, values["description"]) + fn.fcontext = context + if values.get("naming"): + fn.naming(values["naming"]) + elif values.get("pathnaming"): + fn.pathnaming(values["pathnaming"]) + root_project_path = os.environ.get("PROJECT_ROOT_PATH", os.path.join(os.getcwd(), "../../../../")) + fn.rootdir = os.path.join(root_project_path, values["root_dir"]) + fn.extension = values["extension"] + return fn + def read_generic_component_and_return_attributes(self, component_name: str) -> dict: file_path = self.COMPONENT_PATH + component_name + ".yml" try: @@ -611,8 +628,13 @@ class OBSConfig: channels = {} for channel_id in range(len(unit["TOPOLOGY"]["CHANNELS"])): + channel_fcontext = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"].get("fn_contexts") + if channel_fcontext is not None: + fn = self.channel_fn_context(channel_fcontext) + channel_fcontext = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"]["fn_contexts"] = fn channel = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"] channels[channel["name"]] = channel + return channels def get_computers(self) -> dict: @@ -837,6 +859,7 @@ class OBSConfig: else: for channel in topology[element]: for component_agent in topology[element][channel]["AGENTS"]: + print(component_agent) component_name = list(component_agent.keys())[0] components_agents[component_name] = component_agent[component_name] return components_agents @@ -1359,6 +1382,21 @@ class OBSConfig: return computer_agent_name return agent_name + def get_channel_of_agent(self, agent_name:str)->dict: + """ + Return channel element of associated agent + + Args: + agent_name (str): name of agent + + Returns: + dict: Channel element + """ + channels = self.get_channels(self.unit_name) + for channel in channels: + if agent_name in channels[channel]["AGENTS"]: + return channels[channel] + return None class MissingMandatoryAgentException(Exception): """ @@ -1380,8 +1418,11 @@ def main(): # print(config.get_channel_groups(unit_name)) # print(config.getEditableAttributesOfCapability(config.getChannelCapabilities(unit_name,"OpticalChannel_up")[0])) # print(config.getEditableChannelAttributes(unit_name,"OpticalChannel_up")) - config = OBSConfig("../../../../privatedev/config/tnc/observatory_tnc.yml") + config = OBSConfig("../../../../../PYROS_OBSERVATORY/pyros_observatory_tnc/config/observatory_tnc.yml") unit_name = config.get_units_name()[0] + print(config.get_channel_of_agent("A_AgentImagesProcessor_up1_akz")) + # print(config.get_channels(unit_name)) + # print(config.get_components_agents(unit_name)) # dc = config.getDeviceControllerNameForAgent(unit_name,"mount")[0] # print(config.getDeviceConfigForDeviceController(dc)) # print(config.getCommParamsForAgentDevice(unit_name,"mount")) @@ -1390,11 +1431,11 @@ def main(): # print(config.getEditableAttributesOfCapability(config.getChannelCapabilities(unit_name,"OpticalChannel_down2")[0])) # print(config.getEditableChannelAttributesnit_name,"OpticalChannel_down2")) #print(config.getEditableMountAttributes(unit_name)) - config.get_devices() + # config.get_devices() #print(config.get_output_data_device("TAROT_meteo").get("CV7")) - print(config.get_device_for_agent(config.unit_name, "AgentDevicePLC_ako").get("device_config").F[0].get("output_data").get("Raspberry").keys()) - print(config.get_monitoring_devices()) + # print(config.get_device_for_agent(config.unit_name, "AgentDevicePLC_ako").get("device_config").F[0].get("output_data").get("Raspberry").keys()) + # print(config.get_monitoring_devices()) #.get("/entities/devices/CV7/Error_code").keys()) #print(config.get_device_capabilities("TAROT_meteo")) # print(config.get_devices()["FLI-Kepler4040"]["device_config"]) -- libgit2 0.21.2