From d9f9c3058609e08796aecc3071c9001bb2930e3d Mon Sep 17 00:00:00 2001 From: aklotz Date: Mon, 5 Jul 2021 12:13:24 +0200 Subject: [PATCH] troisieme commit après le rearangement des fichiers de config. --- config/DetectorSensor.yml | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ config/DetectorShutter.yml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ config/OpticImager.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ config/definitions.txt | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ config/schema_computer-2.0.yml | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ config/schema_device-2.0.yml | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ config/schema_observatory-2.0.yml | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ config/schema_observatory_verify.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ privatedev/config/computer_XCY_X26A_snAA478.yml | 24 ------------------------ privatedev/config/definitions.txt | 169 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- privatedev/config/device_Astromecca_TM350_sn001.yml | 30 ------------------------------ privatedev/config/device_Raspberry_MiFe_sn004.yml | 37 ------------------------------------- privatedev/config/device_SkyWatcher_L80_snxx1.yml | 40 ---------------------------------------- privatedev/config/device_ZWO_ASI1600MM_snxx1.yml | 111 --------------------------------------------------------------------------------------------------------------- privatedev/config/guitalens/computer_XCY_X26A_snAA478.yml | 24 ++++++++++++++++++++++++ privatedev/config/guitalens/device_Astromecca_TM350_sn001.yml | 30 ++++++++++++++++++++++++++++++ privatedev/config/guitalens/device_Raspberry_MiFe_sn004.yml | 37 +++++++++++++++++++++++++++++++++++++ privatedev/config/guitalens/device_SkyWatcher_L80_snxx1.yml | 40 ++++++++++++++++++++++++++++++++++++++++ privatedev/config/guitalens/device_ZWO_ASI1600MM_snxx1.yml | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ privatedev/config/guitalens/observatory_guitalens.yml | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ privatedev/config/info_observatory.py | 57 --------------------------------------------------------- privatedev/config/observatory_guitalens.yml | 138 ------------------------------------------------------------------------------------------------------------------------------------------ privatedev/config/observatory_v1.yml | 69 --------------------------------------------------------------------- privatedev/config/schema_computer-2.0.yml | 59 ----------------------------------------------------------- privatedev/config/schema_device-2.0.yml | 126 ------------------------------------------------------------------------------------------------------------------------------ privatedev/config/schema_observatory-1.0.yml | 108 ------------------------------------------------------------------------------------------------------------ privatedev/config/schema_observatory-2.0.yml | 244 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- privatedev/config/schema_observatory_verify.py | 53 ----------------------------------------------------- privatedev/config/veirify_config.py | 51 --------------------------------------------------- 29 files changed, 1241 insertions(+), 1316 deletions(-) create mode 100644 config/DetectorSensor.yml create mode 100644 config/DetectorShutter.yml create mode 100644 config/OpticImager.yml create mode 100644 config/definitions.txt create mode 100644 config/schema_computer-2.0.yml create mode 100644 config/schema_device-2.0.yml create mode 100644 config/schema_observatory-2.0.yml create mode 100644 config/schema_observatory_verify.py delete mode 100644 privatedev/config/computer_XCY_X26A_snAA478.yml delete mode 100644 privatedev/config/definitions.txt delete mode 100644 privatedev/config/device_Astromecca_TM350_sn001.yml delete mode 100644 privatedev/config/device_Raspberry_MiFe_sn004.yml delete mode 100644 privatedev/config/device_SkyWatcher_L80_snxx1.yml delete mode 100644 privatedev/config/device_ZWO_ASI1600MM_snxx1.yml create mode 100644 privatedev/config/guitalens/computer_XCY_X26A_snAA478.yml create mode 100644 privatedev/config/guitalens/device_Astromecca_TM350_sn001.yml create mode 100644 privatedev/config/guitalens/device_Raspberry_MiFe_sn004.yml create mode 100644 privatedev/config/guitalens/device_SkyWatcher_L80_snxx1.yml create mode 100644 privatedev/config/guitalens/device_ZWO_ASI1600MM_snxx1.yml create mode 100644 privatedev/config/guitalens/observatory_guitalens.yml delete mode 100644 privatedev/config/info_observatory.py delete mode 100644 privatedev/config/observatory_guitalens.yml delete mode 100644 privatedev/config/observatory_v1.yml delete mode 100644 privatedev/config/schema_computer-2.0.yml delete mode 100644 privatedev/config/schema_device-2.0.yml delete mode 100644 privatedev/config/schema_observatory-1.0.yml delete mode 100644 privatedev/config/schema_observatory-2.0.yml delete mode 100644 privatedev/config/schema_observatory_verify.py delete mode 100644 privatedev/config/veirify_config.py diff --git a/config/DetectorSensor.yml b/config/DetectorSensor.yml new file mode 100644 index 0000000..1be436a --- /dev/null +++ b/config/DetectorSensor.yml @@ -0,0 +1,115 @@ +- attribute: + key: manufacturer + is_container: False + value: Panasonic + is_editable: True + unit: "" + label: manufacturer + +- attribute: + key: _model + is_container: False + value: MN34230 + unit: "" + is_editable: False + label: "model" + +- attribute: + key: _type + is_enum: True + value: ["CMOS","CCD"] + unit: "" + is_editable: True + label: "type" + +- attribute: + key: _celldimx + is_container: False + value : 3.8e-6 + unit: "m" + is_editable: False + label: "celldimx" + +- attribute: + key: _celldimy + is_container: False + value : 3.8e-6 + unit: "m" + is_editable: False + label: "celldimy" + +- attribute: + key: _cellnbx + is_container: False + value : 4656 + unit: "pix" + is_editable: False + label: "cellnbx" + +- attribute: + key: _cellnby + is_container: False + value : 3520 + unit: "pix" + is_editable: False + label: "celldnby" + +- attribute: + key: _color + is_enum: True + value : [ None, "bayerCFA"] + unit: "" + is_editable: True + label: "color" + +- attribute : + key : _qdes + is_container: True + value: + _wavelengths: [379e-9, 380e-9, 1100e-9, 1101e-9] + _qde: [0.0, 0.9, 0.9, 0.0] + unit: + _wavelengths: "m" + _qde: "electron/photon" + is_editable: False + label: "dqe response" + +- attribute: + key: _exposuretime + is_container: False + value: 1.0 + liminf: 0.001 + limsup: 600 + unit: "s" + is_editable: False + label: "exposure time" + +- attribute: + key: binnings + is_container: True + value: + _binxy: [ [1,1], [2,2], [3,3], [4,4] ] # form + _readouttime: [ 6, 4, 3, 1 ] + unit: + _binxy: "" + _readouttime: "s" + is_editable: False + label: "binning" + +- attribute: + key: electronic + is_container: True + value: + _gain_manufacturer: [0, 1, 20] + _gain_eadu: [1.0, 2.0, 5.0] # form + _readout_noise: [2.0, 2.0, 2.0] + _readout_signal: [250, 250, 250] + _saturation_level: [65535, 65535, 65535] + unit: + _gain_manufacturer: "" + _gain_eadu: "electron/adu" + _readout_noise: "electron/cell" + _readout_signal: "adu" + _saturation_level: "adu" + is_editable: False + label: "electronic" \ No newline at end of file diff --git a/config/DetectorShutter.yml b/config/DetectorShutter.yml new file mode 100644 index 0000000..20390b3 --- /dev/null +++ b/config/DetectorShutter.yml @@ -0,0 +1,47 @@ +- attribute: + key: manufacturer + is_container: False + value: Panasonic + is_editable: False + unit: "" + label: manufacturer + +- attribute: + key: _model + is_container: False + value: MN34230 + unit: "" + is_editable: False + label: "model" + +- attribute: + key: _type + is_enum: True + value: [None, "iris", "rolling"] + unit: "" + is_editable: False + label: "type" + +- attribute: + key: _modes + is_enum: True + value: ["opened", "closed", "synchro"] + unit: "" + is_editable: True + label: "type" + +- attribute: + key: _delayopening + is_container: False + value : 0 + unit: "s" + is_editable: False + label: "Delay to sweep charges after opening signal" + +- attribute: + key: _delayclosing + is_container: False + value : 0 + unit: "s" + is_editable: False + label: "Delay to read charges after closing signal" diff --git a/config/OpticImager.yml b/config/OpticImager.yml new file mode 100644 index 0000000..fae7b1a --- /dev/null +++ b/config/OpticImager.yml @@ -0,0 +1,48 @@ +# Equivalent focal length (m) +- attribute : + key : _foclen + is_editable: False + is_container: False + value : 0.503 + unit: "m" + label: "Equivalent focal length" + +# Total tranmission +- attribute : + key : _transmissions + is_editable: False + is_container: True + value: + _wavelengths: [379e-9, 380e-9, 1100e-9, 1101e-9] + _transmission: [0.0, 0.9, 0.9, 0.0] + unit: + _wavelengths: "m" + _transmission: "" + label: "Equivalent focal length" + +# Equivalent apperture diameter (m) +- attribute: + key: _appdiam + is_editable: False + is_container: False + value: 0.08 + unit: "m" + label: "Equivalent apperture diameter" + +# Mean sigma value of a Gaussian model of the psf (m) +- attribute: + key: _psf_sigma + is_editable: False + is_container: False + value : 10.0e-6 + unit: "m" + label: "Gaussian sigma of the PSF" + +# Focal reducer +- attribute : + key: reducer + is_editable: False + is_enum: True + value: ["x1","x0.7"] + unit: "" + label: "Focal reducer" diff --git a/config/definitions.txt b/config/definitions.txt new file mode 100644 index 0000000..53fce44 --- /dev/null +++ b/config/definitions.txt @@ -0,0 +1,169 @@ +================================================================================ +=== INTRODUCTION +================================================================================ + +definitions.txt = This file + +1) First version (V1.0) of config and verification +observatory_v1.yml +schema_observatory-1.0.yml +schema_observatory_verify.py + +2) Second version (V2.0) of config and verification + +observatory_guitalens.yml +computer_XCY_X26A_snAA478.yml +device_Astromecca_TM350_sn001.yml +device_Raspberry_MiFe_sn004.yml +device_SkyWatcher_L80_snxx1.yml +device_ZWO_ASI1600MM_snxx1.yml + +info_observatory.py = script to load the config files and display a summary. + +================================================================================ +=== DEFINITIONS +================================================================================ + +Device + Entitée hardware indissociable + Correspond a un matériel inventorié (pas nécessairement installé) + Contient une description et des DComp et décrit leur attributs + +Computer + Entitée hardware indissociable + Correspond a un ordinateur inventorié (pas nécessairement installé) + Contient une description et ses attributs + +DComp = Device Component + C'est une classe qui décrit un seul type de Component. + Liste des différentes classes de Component: + * Components de type SECURITY: + WeatherStation + BuildingCover + ElectricalManager + MountManager + * Components de type MOUNT: + MountPointing + * Components de type CHANNEL: + OpticImager + FilterSelector + DetectorSensor + DetectorShutter + DetectorTimer + DetectorFocuser + * Components de type MOTOR: + MotorAxis + Chaque DComp hérite d'un simulateur et de méthodes (commandes génériques) + Chaque DComp est associé à une série de devices d'une même marque (Astromecca, SBig, ZWO, etc.) + Chaque DComp est pourvue d'attributs de configuration + Chaque DComp recoit une commande générique et la traduit vers la commande en language natif + Chaque DComp peut inclure d'autres DComp: + ex. 1 MountPointing va inclure 2 MotorAxis + +DCrtl = Device Controller + C'est une classe qui contrôle un seul device. + Un DCrtl gère la communication du canal de communication avec le device réel. + Un DCrtl est constitué d'instances de classes de Component (DComp) qui partagent le même channel de communication. + +AD = Agent Device + C'est un processus. + Constitué de un seul DCtrl. + Recoit une commande générique et la transmet telle quelle vers le bon DComp. + +Observatory + Liste de hardware référencés (devices et computers). + Liste de Units. + +Unit + Assemblage de Database + Agents + Topology + +Topology + Assemblage de Security + Mount + Channels + Channel_groups + Possibilité de générer un diagramme pour visualiser l'assemblage de la topologie + +Appels depuis un agent PyROS + Exemples: + res = config.get_agent(channel = "OpticalChannel-up", component = "DetectorSensor") + res should be 'camera_up' + +================================================================================================================================ + +========================== +schema_observaotry-2.0.yml +-------------------------- + +schema;schema_DATABASE: +schema;schema_AGENT_DEVICE: +schema;schema_AGENT: +schema;schema_GROUP: +schema;schema_CHANNEL_GROUPS: + GROUPS: + type: seq + sequence: + - include: schema_GROUP +schema;schema_MOUNT: + +schema;schema_CHANNEL: + +schema;schema_SECURITY: + +schema;schema_TOPOLOGY: + SECURITY: + include: schema_SECURITY + MOUNT: + include: schema_MOUNT + CHANNELS: + include: schema_CHANNELS + CHANNEL_GROUPS: + include: schema_CHANNEL_GROUPS + +schema;schema_COMPUTER: + +schema;schema_AGENTS: + AGENT_DEVICE: + include: schema_AGENT_DEVICE + AGENT: + include: schema_AGENT + +schema;schema_COMPUTERS: + COMPUTER: + include: schema_COMPUTER + +schema;schema_UNIT: + DATABASE: + include: schema_DATABASE + AGENTS: + include: schema_AGENTS + TOPOLOGY: + include: schema_TOPOLOGY + + +schema;schema_UNITS: + UNIT: + include: schema_UNIT + + + +schema;schema_CHANNELS: + CHANNEL: + include: schema_CHANNEL + + + +schema;schema_DEVICE: + +schema;schema_DEVICES: + DEVICE: + include: schema_DEVICE + + +schema;schema_OBSERVATORY: + DEVICES: + include: schema_DEVICES + COMPUTERS: + include: schema_COMPUTERS + UNITS: + include: schema_UNITS + + OBSERVATORY: + include: schema_OBSERVATORY diff --git a/config/schema_computer-2.0.yml b/config/schema_computer-2.0.yml new file mode 100644 index 0000000..c3869e1 --- /dev/null +++ b/config/schema_computer-2.0.yml @@ -0,0 +1,59 @@ +schema;schema_computer: + type: map + required: True + mapping: + _inventory_label: + type: str + required: True + _manufacturer: + type: str + required: True + _model: + type: str + required: True + _description: + type: str + required: True + _sn: + type: str + required: True + _power: + type: map + required: True + mapping: + _voltage: + type: int + required: True + _intensity: + type: int + required: True + _socket: + type: str + required: True + + _hostname: + type: str + required: True + _virtual_machine: + type: bool + required: True + _os: + type: str + required: True + _os_version: + type: str + required: True + _network_interfaces: + type: seq + required: True + sequence: + - type: str + +type: map +required: True +mapping: + schema: + type: str + required: True + COMPUTER: + include: schema_computer \ No newline at end of file diff --git a/config/schema_device-2.0.yml b/config/schema_device-2.0.yml new file mode 100644 index 0000000..f14fff4 --- /dev/null +++ b/config/schema_device-2.0.yml @@ -0,0 +1,126 @@ +schema;schema_component_attributes: + type: map + required: True + mapping: + key: + type: str + required: True + # is_* are False by default + is_editable: + type: bool + is_container: + type: bool + is_enum: + type: bool + value: + type: any + required: True + liminf: + type: number + limsup: + type: number + label: + type: any + unit: + type: any + +schema;schema_capability: + type: map + required: True + mapping: + component: + type: str + required: True + attributes: + type: seq + required: False # True if we're not using default values + seq: + - include : schema_component_attributes + +# old version +# schema;schema_capability: +# type: map +# required: True +# mapping: + +schema;schema_capabilities: + type: seq + sequence: + - type: map + mapping: + CAPABILITY: + include: schema_capability + +schema;schema_device: + type: map + required: True + mapping: + _inventory_label: + type: str + required: True + _manufacturer: + type: str + required: True + _model: + type: str + required: True + _description: + type: str + required: True + _sn: + type: text + required: True + _power: + type: map + required: True + mapping: + _voltage: + type: int + _intensity: + type: int + _socket: + type: str + + _connector: + type: map + + mapping: + _input: + type: str + + _output: + type: str + + _os: + type: str + + _os_version: + type: str + + _protocol: + type: map + + mapping: + _transport: + type: str + + _langage: + type: str + + _read: + type: bool + + _write: + type: bool + + CAPABILITIES: + include: schema_capabilities + required: True + +type: map +mapping: + schema: + type: str + required: True + DEVICE: + include: schema_device \ No newline at end of file diff --git a/config/schema_observatory-2.0.yml b/config/schema_observatory-2.0.yml new file mode 100644 index 0000000..a49de0e --- /dev/null +++ b/config/schema_observatory-2.0.yml @@ -0,0 +1,244 @@ +schema;schema_DATABASE: + required: True + type: map + mapping: + _computer: + type: str + required: True + _file: + type: str + required: True + +schema;schema_AGENT_DEVICE: + type: map + required: True + mapping: + _computer: + type: str + required: True + _name: + type: str + required: True + _path: + type: str + _device: + type: str + _protocol: + type: str + +schema;schema_AGENT: + type: map + required: True + mapping: + _computer: + type: str + required: True + _name: + type: str + required: True + _path: + type: str + +schema;schema_GROUP: + type: map + required: True + mapping: + GROUP: + type: map + mapping: + _logic: + type: str + _channels: + type: seq + required: True + sequence: + - type: str + +schema;schema_CHANNEL_GROUPS: + type: map + required: True + mapping: + _logic: + type: str + GROUPS: + type: seq + sequence: + - include: schema_GROUP + +schema;schema_MOUNT: + type: map + mapping: + _name: + type: str + required: True + COMPONENT_AGENTS: + type: seq + required: True + sequence: + - type: any + +schema;schema_CHANNEL: + type: map + mapping: + _name: + type: str + required: True + COMPONENT_AGENTS: + type: seq + required: True + sequence: + - type: any + + +schema;schema_SECURITY: + type: map + required: True + mapping: + _name: + type: str + required: True + COMPONENT_AGENTS: + type: seq + required: True + sequence: + - type: any + + +schema;schema_TOPOLOGY: + required: True + type: map + mapping: + SECURITY: + include: schema_SECURITY + MOUNT: + include: schema_MOUNT + CHANNELS: + include: schema_CHANNELS + CHANNEL_GROUPS: + include: schema_CHANNEL_GROUPS + + + +schema;schema_COMPUTER: + type: map + mapping: + _name: + type: str + required: True + _file: + type: str + required: True + _role: + type: str + required: False + _network_interface_index: + type: text + _network_ip: + type: str + + +schema;schema_AGENTS: + required: True + type: seq + matching: "any" + sequence: + - type: map + mapping: + AGENT_DEVICE: + include: schema_AGENT_DEVICE + - type: map + mapping: + AGENT: + include: schema_AGENT + +schema;schema_COMPUTERS: + type: seq + sequence: + - type: map + mapping: + COMPUTER: + include: schema_COMPUTER + +schema;schema_UNIT: + type: map + required: True + mapping: + _name: + type: str + required: True + DATABASE: + include: schema_DATABASE + AGENTS: + include: schema_AGENTS + TOPOLOGY: + include: schema_TOPOLOGY + + +schema;schema_UNITS: + type: seq + required: True + sequence: + - type: map + mapping : + UNIT: + include: schema_UNIT + + + +schema;schema_CHANNELS: + type: seq + required: True + sequence: + - type : map + mapping: + CHANNEL: + include: schema_CHANNEL + + + +schema;schema_DEVICE: + type: map + required: True + mapping: + _name: + type: str + required: True + _file: + type: str + required: True + _network_interface_index: + type: text + _network_ip: + type: str + + +schema;schema_DEVICES: + type: seq + required: True + sequence: + - type: map + mapping: + DEVICE: + include: schema_DEVICE + + +schema;schema_OBSERVATORY: + type: map + required: True + mapping: + _name: + type: str + DEVICES: + include: schema_DEVICES + COMPUTERS: + include: schema_COMPUTERS + UNITS: + include: schema_UNITS + +type: map +mapping: + schema: + type: str + required: True + OBSERVATORY: + include: schema_OBSERVATORY diff --git a/config/schema_observatory_verify.py b/config/schema_observatory_verify.py new file mode 100644 index 0000000..e8772ed --- /dev/null +++ b/config/schema_observatory_verify.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +import pykwalify.core +from pykwalify.errors import SchemaError + +""" +Read yaml file : +import yaml +filename = "observatory_guitalens.yml" +with open(filename, 'r') as stream: + try: + a = yaml.safe_load(stream) + print(a) + except yaml.YAMLError as exc: + print(exc) + +# Write YAML file +with open('config2.yml', 'w', encoding='utf8') as outfile: + yaml.dump(a, outfile, default_flow_style=False, allow_unicode=True) +""" + +""" +import yaml +with open("config.yml", 'r') as stream: + try: + a = yaml.safe_load(stream) + print(a) + except yaml.YAMLError as exc: + print(exc) + + """ + +def check_and_return_config(yaml_file:str,schema_file:str)->dict: + """ + Check if yaml_file is valid for the schema_file + + Args: + yaml_file (str): Path to the config_file to be validated + schema_file (str): Path to the schema file + + Returns: + dict: Dictionnary of the config file (with values) + """ + try: + + c = pykwalify.core.Core(source_file=yaml_file, schema_files=[schema_file]) + return c.validate(raise_exception=True) + except SchemaError as error: + #TODO : find a way to retrieve message with path to error + print(error.path) + + +print(check_and_return_config("observatory_v1.yml","schema_observatory-1.0.yml")) \ No newline at end of file diff --git a/privatedev/config/computer_XCY_X26A_snAA478.yml b/privatedev/config/computer_XCY_X26A_snAA478.yml deleted file mode 100644 index 191e253..0000000 --- a/privatedev/config/computer_XCY_X26A_snAA478.yml +++ /dev/null @@ -1,24 +0,0 @@ -# Schema file to check the syntax of this config file -schema: schema_computer-2.0.yml - -# Here is the description of the configuration of an isolated computer -COMPUTER: - - _inventory_label: CPT-XCY-001 - _manufacturer: XCY - _model: X26A - _description: "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz 1.90 GHz RAM = 4 GB" - _sn: 00331-10000-00001-AA478 - _power: - _voltage: 12 - _intensity: 5 - _socket: "IEC 60130-10 Type A: 5.5 mm OD, 2.5 mm ID" - - _hostname: XCY1 - _virtual_machine: False - _os: Windows - _os_version: "10" - _network_interfaces: - - 00-A8-3D-68-22-87 # Gigabit 2 - - 00-A8-3D-68-22-86 # Gigabit 3 - - 16-82-FE-44-64-E8 # Wifi diff --git a/privatedev/config/definitions.txt b/privatedev/config/definitions.txt deleted file mode 100644 index 53fce44..0000000 --- a/privatedev/config/definitions.txt +++ /dev/null @@ -1,169 +0,0 @@ -================================================================================ -=== INTRODUCTION -================================================================================ - -definitions.txt = This file - -1) First version (V1.0) of config and verification -observatory_v1.yml -schema_observatory-1.0.yml -schema_observatory_verify.py - -2) Second version (V2.0) of config and verification - -observatory_guitalens.yml -computer_XCY_X26A_snAA478.yml -device_Astromecca_TM350_sn001.yml -device_Raspberry_MiFe_sn004.yml -device_SkyWatcher_L80_snxx1.yml -device_ZWO_ASI1600MM_snxx1.yml - -info_observatory.py = script to load the config files and display a summary. - -================================================================================ -=== DEFINITIONS -================================================================================ - -Device - Entitée hardware indissociable - Correspond a un matériel inventorié (pas nécessairement installé) - Contient une description et des DComp et décrit leur attributs - -Computer - Entitée hardware indissociable - Correspond a un ordinateur inventorié (pas nécessairement installé) - Contient une description et ses attributs - -DComp = Device Component - C'est une classe qui décrit un seul type de Component. - Liste des différentes classes de Component: - * Components de type SECURITY: - WeatherStation - BuildingCover - ElectricalManager - MountManager - * Components de type MOUNT: - MountPointing - * Components de type CHANNEL: - OpticImager - FilterSelector - DetectorSensor - DetectorShutter - DetectorTimer - DetectorFocuser - * Components de type MOTOR: - MotorAxis - Chaque DComp hérite d'un simulateur et de méthodes (commandes génériques) - Chaque DComp est associé à une série de devices d'une même marque (Astromecca, SBig, ZWO, etc.) - Chaque DComp est pourvue d'attributs de configuration - Chaque DComp recoit une commande générique et la traduit vers la commande en language natif - Chaque DComp peut inclure d'autres DComp: - ex. 1 MountPointing va inclure 2 MotorAxis - -DCrtl = Device Controller - C'est une classe qui contrôle un seul device. - Un DCrtl gère la communication du canal de communication avec le device réel. - Un DCrtl est constitué d'instances de classes de Component (DComp) qui partagent le même channel de communication. - -AD = Agent Device - C'est un processus. - Constitué de un seul DCtrl. - Recoit une commande générique et la transmet telle quelle vers le bon DComp. - -Observatory - Liste de hardware référencés (devices et computers). - Liste de Units. - -Unit - Assemblage de Database + Agents + Topology - -Topology - Assemblage de Security + Mount + Channels + Channel_groups - Possibilité de générer un diagramme pour visualiser l'assemblage de la topologie - -Appels depuis un agent PyROS - Exemples: - res = config.get_agent(channel = "OpticalChannel-up", component = "DetectorSensor") - res should be 'camera_up' - -================================================================================================================================ - -========================== -schema_observaotry-2.0.yml --------------------------- - -schema;schema_DATABASE: -schema;schema_AGENT_DEVICE: -schema;schema_AGENT: -schema;schema_GROUP: -schema;schema_CHANNEL_GROUPS: - GROUPS: - type: seq - sequence: - - include: schema_GROUP -schema;schema_MOUNT: - -schema;schema_CHANNEL: - -schema;schema_SECURITY: - -schema;schema_TOPOLOGY: - SECURITY: - include: schema_SECURITY - MOUNT: - include: schema_MOUNT - CHANNELS: - include: schema_CHANNELS - CHANNEL_GROUPS: - include: schema_CHANNEL_GROUPS - -schema;schema_COMPUTER: - -schema;schema_AGENTS: - AGENT_DEVICE: - include: schema_AGENT_DEVICE - AGENT: - include: schema_AGENT - -schema;schema_COMPUTERS: - COMPUTER: - include: schema_COMPUTER - -schema;schema_UNIT: - DATABASE: - include: schema_DATABASE - AGENTS: - include: schema_AGENTS - TOPOLOGY: - include: schema_TOPOLOGY - - -schema;schema_UNITS: - UNIT: - include: schema_UNIT - - - -schema;schema_CHANNELS: - CHANNEL: - include: schema_CHANNEL - - - -schema;schema_DEVICE: - -schema;schema_DEVICES: - DEVICE: - include: schema_DEVICE - - -schema;schema_OBSERVATORY: - DEVICES: - include: schema_DEVICES - COMPUTERS: - include: schema_COMPUTERS - UNITS: - include: schema_UNITS - - OBSERVATORY: - include: schema_OBSERVATORY diff --git a/privatedev/config/device_Astromecca_TM350_sn001.yml b/privatedev/config/device_Astromecca_TM350_sn001.yml deleted file mode 100644 index 555b3c3..0000000 --- a/privatedev/config/device_Astromecca_TM350_sn001.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Schema file to check the syntax of this config file -schema: schema_device-2.0.yml - -# Here is the description of the configuration of an isolated device -DEVICE: - - _inventory_label: MNT-AMC-001 - _manufacturer: AstroMecCA - _model: TM350 - _description: "" - _sn: xx1 - _power: - _voltage: 220 - _intensity: 5 - _socket: "CEE 7/7 2P+T" - - _connector: - _input: ground - _output: "2 plates" - - CAPABILITIES: - - - CAPABILITY: - component: MountPointing - _manufacturer: AstroMecCA - _model: TM350 - _orientation_type: HADEC - _velocity_profile: trapezium - _home: "GPS 2.0375 E 43.6443484725 136.9" - _connect_real_mount: False diff --git a/privatedev/config/device_Raspberry_MiFe_sn004.yml b/privatedev/config/device_Raspberry_MiFe_sn004.yml deleted file mode 100644 index d668aa8..0000000 --- a/privatedev/config/device_Raspberry_MiFe_sn004.yml +++ /dev/null @@ -1,37 +0,0 @@ -# Schema file to check the syntax of this config file -schema: schema_device-2.0.yml - -# Here is the description of the configuration of an isolated device -DEVICE: - - _inventory_label: SEC-RSP-001 - _manufacturer: Klotz - _model: MiFe - _description: "Opening and closing the roof is not available externally" - _sn: 004 - _power: - _voltage: 220 - _intensity: 1 - _socket: "CEE 7/7 2P+T" - - _hostname: "" - _virtual_machine: False - _os: Linux - _os_version: Raspbian - _network_interfaces: - - B8:27:EB:8B:99:BE # RJ45 - - b8:27:eb:de:cc:eb # Wifi - _protocol: - _transport: TCP - _langage: Json - _read: True - _write: False - - CAPABILITIES: - - - CAPABILITY: - component: WeatherStation - - - CAPABILITY: - component: BuildingCover - _type_cover: "RollingRoof" # Enum: None, RollingRoof, ClamShell, Dome diff --git a/privatedev/config/device_SkyWatcher_L80_snxx1.yml b/privatedev/config/device_SkyWatcher_L80_snxx1.yml deleted file mode 100644 index 1ea0efe..0000000 --- a/privatedev/config/device_SkyWatcher_L80_snxx1.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Schema file to check the syntax of this config file -schema: schema_device-2.0.yml - -# Here is the description of the configuration of an isolated device -DEVICE: - - _inventory_label: OPT-SKW-001 - _manufacturer: SkyWatcher - _model: L80 - _description: "Apochromatic refractor" - _sn: xx1 - _power: - _voltage: ~ - _intensity: ~ - _socket: ~ - - _connector: - _input: aperture - _output: "female 2 inches" - - CAPABILITIES: - - - CAPABILITY: - component: OpticImager - - attributes: - - - attribute: - key: _foclen - value: 0.503 - - - attribute: - key: _transmissions - value: - _wavelengths: [379e-9, 380e-9, 1100e-9, 1101e-9] - _transmission: [0.0, 0.9, 0.9, 0.0] - - - attribute: - key: _appdiam - value: 0.08 diff --git a/privatedev/config/device_ZWO_ASI1600MM_snxx1.yml b/privatedev/config/device_ZWO_ASI1600MM_snxx1.yml deleted file mode 100644 index 11f1aed..0000000 --- a/privatedev/config/device_ZWO_ASI1600MM_snxx1.yml +++ /dev/null @@ -1,111 +0,0 @@ -# Schema file to check the syntax of this config file -schema: schema_device-2.0.yml - -# Here is the description of the configuration of an isolated device -DEVICE: - - _inventory_label: CAM-ZWO-001 - _manufacturer: ZWO - _model: ASI1600MMPro - _description: "" # opt str - _sn: xx1 - _power: - _voltage: 12 - _intensity: 5 - _socket: "IEC 60130-10 Type A: 5.5 mm OD, 2.5 mm ID" - - _connector: - _input: "male 2 inches" - _output: USB3 - - CAPABILITIES: - - - CAPABILITY: - component: DetectorSensor - - attributes: - - - attribute: - key: manufacturer - value: Panasonic - - - attribute: - key: _model - value: MN34230 - - - attribute: - key: _type - value: CMOS - - - attribute: - key: _exposuretime - value: 1.0 - liminf: 0.001 - limsup: 600 - is_editable: True - - - attribute: - key: binnings - value: - _binxy: [ [1,1], [2,2], [3,3], [4,4] ] # form - _readouttime: [ 6, 4, 3, 1 ] - is_editable: True - - - attribute: - key: _celldimx - value: 3.8e-6 - - attribute: - key: _celldimy - value: 3.8e-6 - - - attribute: - key: _cellnbx - value: 4656 - - attribute: - key: _cellnby - value: 3520 - - - attribute: - key: _color - value: None - - - attribute: - key: _qdes - value: - _wavelengths: [379e-9, 380e-9, 1100e-9, 1101e-9] - _qde: [0.0, 0.9, 0.9, 0.0] - - - attribute: - key: _cellnbx - value: 4656 - - - attribute: - key: electronic - value: - _gain_manufacturer: [0, 1, 20] - _gain_eadu: [1.0, 2.0, 5.0] # form - _readout_noise: [2.0, 2.0, 2.0] - _readout_signal: [250, 250, 250] - _saturation_level: [65535, 65535, 65535] - - - CAPABILITY: - component: DetectorShutter - - attributes: - - - attribute: - key: manufacturer - value: None - - - attribute: - key: _model - value: None - - - attribute: - key: _type - value: ['rolling'] - - - attribute: - key: _modes - value: ["opened"] - is_editable: False diff --git a/privatedev/config/guitalens/computer_XCY_X26A_snAA478.yml b/privatedev/config/guitalens/computer_XCY_X26A_snAA478.yml new file mode 100644 index 0000000..191e253 --- /dev/null +++ b/privatedev/config/guitalens/computer_XCY_X26A_snAA478.yml @@ -0,0 +1,24 @@ +# Schema file to check the syntax of this config file +schema: schema_computer-2.0.yml + +# Here is the description of the configuration of an isolated computer +COMPUTER: + + _inventory_label: CPT-XCY-001 + _manufacturer: XCY + _model: X26A + _description: "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz 1.90 GHz RAM = 4 GB" + _sn: 00331-10000-00001-AA478 + _power: + _voltage: 12 + _intensity: 5 + _socket: "IEC 60130-10 Type A: 5.5 mm OD, 2.5 mm ID" + + _hostname: XCY1 + _virtual_machine: False + _os: Windows + _os_version: "10" + _network_interfaces: + - 00-A8-3D-68-22-87 # Gigabit 2 + - 00-A8-3D-68-22-86 # Gigabit 3 + - 16-82-FE-44-64-E8 # Wifi diff --git a/privatedev/config/guitalens/device_Astromecca_TM350_sn001.yml b/privatedev/config/guitalens/device_Astromecca_TM350_sn001.yml new file mode 100644 index 0000000..555b3c3 --- /dev/null +++ b/privatedev/config/guitalens/device_Astromecca_TM350_sn001.yml @@ -0,0 +1,30 @@ +# Schema file to check the syntax of this config file +schema: schema_device-2.0.yml + +# Here is the description of the configuration of an isolated device +DEVICE: + + _inventory_label: MNT-AMC-001 + _manufacturer: AstroMecCA + _model: TM350 + _description: "" + _sn: xx1 + _power: + _voltage: 220 + _intensity: 5 + _socket: "CEE 7/7 2P+T" + + _connector: + _input: ground + _output: "2 plates" + + CAPABILITIES: + + - CAPABILITY: + component: MountPointing + _manufacturer: AstroMecCA + _model: TM350 + _orientation_type: HADEC + _velocity_profile: trapezium + _home: "GPS 2.0375 E 43.6443484725 136.9" + _connect_real_mount: False diff --git a/privatedev/config/guitalens/device_Raspberry_MiFe_sn004.yml b/privatedev/config/guitalens/device_Raspberry_MiFe_sn004.yml new file mode 100644 index 0000000..d668aa8 --- /dev/null +++ b/privatedev/config/guitalens/device_Raspberry_MiFe_sn004.yml @@ -0,0 +1,37 @@ +# Schema file to check the syntax of this config file +schema: schema_device-2.0.yml + +# Here is the description of the configuration of an isolated device +DEVICE: + + _inventory_label: SEC-RSP-001 + _manufacturer: Klotz + _model: MiFe + _description: "Opening and closing the roof is not available externally" + _sn: 004 + _power: + _voltage: 220 + _intensity: 1 + _socket: "CEE 7/7 2P+T" + + _hostname: "" + _virtual_machine: False + _os: Linux + _os_version: Raspbian + _network_interfaces: + - B8:27:EB:8B:99:BE # RJ45 + - b8:27:eb:de:cc:eb # Wifi + _protocol: + _transport: TCP + _langage: Json + _read: True + _write: False + + CAPABILITIES: + + - CAPABILITY: + component: WeatherStation + + - CAPABILITY: + component: BuildingCover + _type_cover: "RollingRoof" # Enum: None, RollingRoof, ClamShell, Dome diff --git a/privatedev/config/guitalens/device_SkyWatcher_L80_snxx1.yml b/privatedev/config/guitalens/device_SkyWatcher_L80_snxx1.yml new file mode 100644 index 0000000..1ea0efe --- /dev/null +++ b/privatedev/config/guitalens/device_SkyWatcher_L80_snxx1.yml @@ -0,0 +1,40 @@ +# Schema file to check the syntax of this config file +schema: schema_device-2.0.yml + +# Here is the description of the configuration of an isolated device +DEVICE: + + _inventory_label: OPT-SKW-001 + _manufacturer: SkyWatcher + _model: L80 + _description: "Apochromatic refractor" + _sn: xx1 + _power: + _voltage: ~ + _intensity: ~ + _socket: ~ + + _connector: + _input: aperture + _output: "female 2 inches" + + CAPABILITIES: + + - CAPABILITY: + component: OpticImager + + attributes: + + - attribute: + key: _foclen + value: 0.503 + + - attribute: + key: _transmissions + value: + _wavelengths: [379e-9, 380e-9, 1100e-9, 1101e-9] + _transmission: [0.0, 0.9, 0.9, 0.0] + + - attribute: + key: _appdiam + value: 0.08 diff --git a/privatedev/config/guitalens/device_ZWO_ASI1600MM_snxx1.yml b/privatedev/config/guitalens/device_ZWO_ASI1600MM_snxx1.yml new file mode 100644 index 0000000..11f1aed --- /dev/null +++ b/privatedev/config/guitalens/device_ZWO_ASI1600MM_snxx1.yml @@ -0,0 +1,111 @@ +# Schema file to check the syntax of this config file +schema: schema_device-2.0.yml + +# Here is the description of the configuration of an isolated device +DEVICE: + + _inventory_label: CAM-ZWO-001 + _manufacturer: ZWO + _model: ASI1600MMPro + _description: "" # opt str + _sn: xx1 + _power: + _voltage: 12 + _intensity: 5 + _socket: "IEC 60130-10 Type A: 5.5 mm OD, 2.5 mm ID" + + _connector: + _input: "male 2 inches" + _output: USB3 + + CAPABILITIES: + + - CAPABILITY: + component: DetectorSensor + + attributes: + + - attribute: + key: manufacturer + value: Panasonic + + - attribute: + key: _model + value: MN34230 + + - attribute: + key: _type + value: CMOS + + - attribute: + key: _exposuretime + value: 1.0 + liminf: 0.001 + limsup: 600 + is_editable: True + + - attribute: + key: binnings + value: + _binxy: [ [1,1], [2,2], [3,3], [4,4] ] # form + _readouttime: [ 6, 4, 3, 1 ] + is_editable: True + + - attribute: + key: _celldimx + value: 3.8e-6 + - attribute: + key: _celldimy + value: 3.8e-6 + + - attribute: + key: _cellnbx + value: 4656 + - attribute: + key: _cellnby + value: 3520 + + - attribute: + key: _color + value: None + + - attribute: + key: _qdes + value: + _wavelengths: [379e-9, 380e-9, 1100e-9, 1101e-9] + _qde: [0.0, 0.9, 0.9, 0.0] + + - attribute: + key: _cellnbx + value: 4656 + + - attribute: + key: electronic + value: + _gain_manufacturer: [0, 1, 20] + _gain_eadu: [1.0, 2.0, 5.0] # form + _readout_noise: [2.0, 2.0, 2.0] + _readout_signal: [250, 250, 250] + _saturation_level: [65535, 65535, 65535] + + - CAPABILITY: + component: DetectorShutter + + attributes: + + - attribute: + key: manufacturer + value: None + + - attribute: + key: _model + value: None + + - attribute: + key: _type + value: ['rolling'] + + - attribute: + key: _modes + value: ["opened"] + is_editable: False diff --git a/privatedev/config/guitalens/observatory_guitalens.yml b/privatedev/config/guitalens/observatory_guitalens.yml new file mode 100644 index 0000000..f76fbbc --- /dev/null +++ b/privatedev/config/guitalens/observatory_guitalens.yml @@ -0,0 +1,138 @@ +# Schema file to check the syntax of this config file +schema: schema_observatory-2.0.yml + +# Here is the description of the configuration of an observatory +OBSERVATORY: + + _name: Guitalens + + # === Inventory of available devices + # A device is a hardware with a maximum of one connection to drive it with a computer. + # As a device can be shared with various units, it is defined at the observatory level. + DEVICES: + + # Each device is defined by a specific configuration file that enumarate the components. + + - DEVICE: + _name: AstroMecCA-TM350 + _file: device_Astromecca_TM350_sn001.yml + + - DEVICE: + _name: PLC-meteo + _file: device_Raspberry_MiFe_sn004.yml + # Describe here the configuration of the device in operation + _network_interface_index: 0 + _network_ip: 192.168.0.2 + + - DEVICE: + _name: SkyWatcher-refractor + _file: device_SkyWatcher_L80_snxx1.yml + + - DEVICE: + _name: Celestron-C11 + _file: device_Celestron_C11_sn974234.yml + + - DEVICE: + _name: ZWO-ASI1600MMPro + _file: device_ZWO_ASI1600MM_snxx1.yml + + - DEVICE: + _name: FLI-Kepler4040 + _file: device_FLI_Kepler4040_sn2821221.yml + + - DEVICE: + _name: FLI-KeplerGPS + _file: device_FLI_KITS_sn0x1.yml + + # === Inventory of available computers + # A computer is a hardware of a virtual machine. + # As a computer can be shared with various units, it is defined at the observatory level. + COMPUTERS: + + - COMPUTER: + + _name: MainComputer + _file: computer_XCY_X26A_snAA478.yml + # Describe here the configuration of the computer in operation + _role: Main + # Choice of the interface to connect the computer to the network (cf. _network_interfaces in _file) + _network_interface_index: 0 + # IP attributed by the Router + _network_ip: 192.168.0.11 + + # === Assembly of devices into units + # A unit is a robotic telescope + UNITS: + + - UNIT: + _name: TNC-prototype + + DATABASE: + _computer: MainComputer + _file: pyros/docker/.env + + AGENTS: + + - AGENT_DEVICE: + _computer: MainComputer + _name: plc + _path: private/plugin/agent_devices + _device: PLC-meteo + _protocol: private/plugin/agent_devices/plc_protocol.py + + - AGENT_DEVICE: + _computer: MainComputer + _name: mount + _path: private/plugin/agent_devices + _device: AstroMecCA-TM350 + _protocol: private/plugin/agent_devices/mount_protocol.py + + - AGENT_DEVICE: + _computer: None + _name: optic_up + _path: ~ + _device: Celestron-C11 + + - AGENT_DEVICE: + _computer: MainComputer + _name: camera_up + _path: private/plugin/agent_devices + _device: FLI-Kepler4040 + _protocol: private/plugin/agent_devices/camera_protocol.py + + - AGENT: + _computer: MainComputer + _name: majordome + _path: ~ + + TOPOLOGY: + + SECURITY: + _name: PLC + COMPONENT_AGENTS: + - WeatherStation: plc + - BuildingCover: plc + + MOUNT: + _name: TM350-prototype + COMPONENT_AGENTS: + - MountPointing: mount + + CHANNELS: + + - CHANNEL: + _name: OpticalChannel-up + COMPONENT_AGENTS: + - OpticImager: optic_up + - DetectorSensor: camera_up + - DetectorShutter: camera_up + - DetectorTimer: camera_up + + CHANNEL_GROUPS: + + _logic: 'or' # opt + GROUPS: + - GROUP: + _logic: 'and' # opt + _channels: + - OpticalChannel-up diff --git a/privatedev/config/info_observatory.py b/privatedev/config/info_observatory.py deleted file mode 100644 index a0e5b7b..0000000 --- a/privatedev/config/info_observatory.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- - -import pykwalify.core -from pykwalify.errors import SchemaError - -import yaml -filename = "observatory_guitalens.yml" -with open(filename, 'r') as stream: - try: - config = yaml.safe_load(stream) - #print(config) - except yaml.YAMLError as exc: - print(exc) - -t = config['OBSERVATORY']['_name'] -print("="*20) -print(f"Configuration of the observatory : {t}") - -ts = config['OBSERVATORY']['DEVICES'] -nt = len(ts) -print("="*20) -print(f"There are {nt} available devices:") -print("-"*20) -for kd in range(nt): - texte = "" - t = config['OBSERVATORY']['DEVICES'][kd]['DEVICE']['_name'] - texte += f"Device {t}: " - - filename = config['OBSERVATORY']['DEVICES'][kd]['DEVICE']['_file'] - with open(filename, 'r') as stream: - try: - subconfig = yaml.safe_load(stream) - #print(config) - except yaml.YAMLError as exc: - print(exc) - - # --- list of keys - cs = subconfig['DEVICE']['CAPABILITIES'] - nc = len(cs) - for kc in range(nc): - t = subconfig['DEVICE']['CAPABILITIES'][kc]['CAPABILITY']['component'] - texte += f" {t} " - - print(texte) - -ts = config['OBSERVATORY']['UNITS'] -nt = len(ts) -print("="*20) -print(f"There are {nt} units:") -ku = 0 -ts = config['OBSERVATORY']['UNITS'][ku]['UNIT']['_name'] -print(f"First unit is {ts}:") -print("-"*20) -ts = config['OBSERVATORY']['UNITS'][ku]['UNIT']['TOPOLOGY']['SECURITY']['_name'] -print(f"Security is {ts}:") -ts = config['OBSERVATORY']['UNITS'][ku]['UNIT']['TOPOLOGY']['MOUNT']['_name'] -print(f"Mount is {ts}:") diff --git a/privatedev/config/observatory_guitalens.yml b/privatedev/config/observatory_guitalens.yml deleted file mode 100644 index b3cf4f4..0000000 --- a/privatedev/config/observatory_guitalens.yml +++ /dev/null @@ -1,138 +0,0 @@ -# Schema file to check the syntax of this config file -schema: schema_observatory-2.0.yml - -# Here is the description of the configuration of an observatory -OBSERVATORY: - - _name: Guitalens - - # === Inventory of available devices - # A device is a hardware with a maximum of one connection to drive it with a computer. - # As a device can be shared with various units, it is defined at the observatory level. - DEVICES: - - # Each device is defined by a specific configuration file that enumarate the components. - - - DEVICE: - _name: AstroMecCA-TM350 - _file: device_Astromecca_TM350_sn001.yml - - - DEVICE: - _name: PLC-meteo - _file: device_Raspberry_MiFe_sn004.yml - # Describe here the configuration of the device in operation - _network_interface_index: 0 - _network_ip: 192.168.0.2 - - - DEVICE: - _name: SkyWatcher-refractor - _file: device_SkyWatcher_L80_snxx1.yml - - - DEVICE: - _name: Celestron-C11 - _file: device_Celestron_C11_sn974234.yml - - - DEVICE: - _name: ZWO-ASI1600MMPro - _file: device_ZWO_ASI1600MM_snxx1.yml - - - DEVICE: - _name: FLI-Kepler4040 - _file: device_FLI_Kepler4040_sn2821221.yml - - - DEVICE: - _name: FLI-KeplerGPS - _file: device_FLI_KITS_sn0x1.yml - - # === Inventory of available computers - # A computer is a hardware of a virtual machine. - # As a computer can be shared with various units, it is defined at the observatory level. - COMPUTERS: - - - COMPUTER: - - _name: MainComputer - _file: computer_XCY_X26A_snAA478.yml - # Describe here the configuration of the computer in operation - _role: Main - # Choice of the interface to connect the computer to the network (cf. _network_interfaces in _file) - _network_interface_index: 0 - # IP attributed by the Router - _network_ip: 192.168.0.11 - - # === Assembly of devices into units - # A unit is a robotic telescope - UNITS: - - - UNIT: - _name: TNC-prototype - - DATABASE: - _computer: MainComputer - _file: pyros/docker/.env - - AGENTS: - - - AGENT_DEVICE: - _computer: MainComputer - _name: plc - _path: private/plugin/agent_devices - _device: PLC-meteo - _protocol: private/plugin/agent_devices/plc_protocol.py - - - AGENT_DEVICE: - _computer: MainComputer - _name: mount - _path: private/plugin/agent_devices - _device: AstroMecCA-TM350 - _protocol: private/plugin/agent_devices/mount_protocol.py - - - AGENT_DEVICE: - _computer: None - _name: optic_up - _path: ~ - _device: Celestron-C11 - - - AGENT_DEVICE: - _computer: MainComputer - _name: camera_up - _path: private/plugin/agent_devices - _device: FLI-Kepler4040 - _protocol: private/plugin/agent_devices/camera_protocol.py - - - AGENT: - _computer: MainComputer - _name: majordome - _path: ~ - - TOPOLOGY: - - SECURITY: - _name: PLC - COMPONENT_AGENTS: - - WeatherStation: plc - - BuildingCover: plc - - MOUNT: - _name: TM350-prototype - COMPONENT_AGENTS: - - MountPointing: mount - - CHANNELS: - - - CHANNEL: - _name: OpticalChannel-up - COMPONENT_AGENTS: - - OpticImager: optic_up - - DetectorSensor: camera_up - - DetectorShutter: camera_up - - DetectorTimer: camera_up - - CHANNEL_GROUPS: - - _logic: 'or' # opt - GROUPS: - - GROUP: - _logic: 'and' # opt - _channels: - - OpticalChannel-up diff --git a/privatedev/config/observatory_v1.yml b/privatedev/config/observatory_v1.yml deleted file mode 100644 index 41dcf47..0000000 --- a/privatedev/config/observatory_v1.yml +++ /dev/null @@ -1,69 +0,0 @@ -# To verify this configuration file: -# yaml_schema: schema_observatory-1.0.yaml -OBSERVATORY: - _name: TNC - - UNITS: - - UNIT: - _name: TNC-Telescope - # _Site: (home, ligne d'horizon) - - MOUNT: - _name: TNC-Mount - _components: - - Mount_TM350-Astromecca_sn459.yml - - CHANNELS: - - - CHANNEL: - _name: TNC-NW - _components: - - Camera_FLIKepler4040_sn123.yml - - Focuser_Optec_sn341.yml - - Optic_TakahashiED180_sn445.yml - - - CHANNEL: - _name: TNC-NE - - - CHANNEL: - _name: TNC-SW - - - CHANNEL: - _name: TNC-SE - - COMPUTERS: - - - COMPUTER: - _name: PyROS_bdd - _file: Computer_DELL_PowerEdge7000_sn599.yml - _hostname: TNC_PC_DB - database: - name: MySQL - port: 3306 - - - COMPUTER: - _name: PyROS_principal - _file: Computer_DELL_E6430_sn000.yml - _hostname: TNC_PC1 - _role: Main - agents: - - Majordome: /home/pyros/private/majordome_perso - - Monitoring: ~ - - - COMPUTER: - _name: PyROS_spare - _file: Computer_DELL_E6430_sn001.yml - _hostname: TNC_PC2 - _role: Spare - _main: TNC_PC1 - agents: - - Majordome: ~ - - Monitoring: ~ - - - COMPUTER: - _name: PyROS_channel - _file: Computer_DELL_MiniPC_s772.yml - _hostname: TNC_MINIPC_SW - _role: Main - agents: - - Camera: ~ diff --git a/privatedev/config/schema_computer-2.0.yml b/privatedev/config/schema_computer-2.0.yml deleted file mode 100644 index c3869e1..0000000 --- a/privatedev/config/schema_computer-2.0.yml +++ /dev/null @@ -1,59 +0,0 @@ -schema;schema_computer: - type: map - required: True - mapping: - _inventory_label: - type: str - required: True - _manufacturer: - type: str - required: True - _model: - type: str - required: True - _description: - type: str - required: True - _sn: - type: str - required: True - _power: - type: map - required: True - mapping: - _voltage: - type: int - required: True - _intensity: - type: int - required: True - _socket: - type: str - required: True - - _hostname: - type: str - required: True - _virtual_machine: - type: bool - required: True - _os: - type: str - required: True - _os_version: - type: str - required: True - _network_interfaces: - type: seq - required: True - sequence: - - type: str - -type: map -required: True -mapping: - schema: - type: str - required: True - COMPUTER: - include: schema_computer \ No newline at end of file diff --git a/privatedev/config/schema_device-2.0.yml b/privatedev/config/schema_device-2.0.yml deleted file mode 100644 index f14a60d..0000000 --- a/privatedev/config/schema_device-2.0.yml +++ /dev/null @@ -1,126 +0,0 @@ -schema;schema_component_attributes: - type: map - required: True - mapping: - key: - type: str - required: True - # is_* are False by default - is_editable: - type: bool - is_container: - type: bool - is_enum: - type: bool - value: - type: any - required: True - liminf: - type: number - limsup: - type: number - label: - type: any - unit: - type: any - -schema;schema_capability: - type: map - required: True - mapping: - component: - type: str - required: True - attributes: - type: seq - required: False # True if we're not using default values - seq: - - include : schema_component_attributes - -# old version -# schema;schema_capability: -# type: map -# required: True -# mapping: - -schema;schema_capabilities: - type: seq - sequence: - - type: map - mapping: - CAPABILITY: - include: schema_capability - -schema;schema_device: - type: map - required: True - mapping: - _inventory_label: - type: str - required: True - _manufacturer: - type: str - required: True - _model: - type: str - required: True - _description: - type: str - required: True - _sn: - type: text - required: True - _power: - type: map - required: True - mapping: - _voltage: - type: int - _intensity: - type: int - _socket: - type: str - - _connector: - type: map - - mapping: - _input: - type: str - - _output: - type: str - - _os: - type: str - - _os_version: - type: str - - _protocol: - type: map - - mapping: - _transport: - type: str - - _langage: - type: str - - _read: - type: bool - - _write: - type: bool - - CAPABILITIES: - include: schema_capabilities - required: True - -type: map -mapping: - schema: - type: str - required: True - DEVICE: - include: schema_device \ No newline at end of file diff --git a/privatedev/config/schema_observatory-1.0.yml b/privatedev/config/schema_observatory-1.0.yml deleted file mode 100644 index 74be066..0000000 --- a/privatedev/config/schema_observatory-1.0.yml +++ /dev/null @@ -1,108 +0,0 @@ -schema;schema_UNIT: - type: map - required: True - mapping: - _name: - type: str - required: True - MOUNT: - include: schema_MOUNT - CHANNELS: - include: schema_CHANNELS - COMPUTERS: - include: schema_COMPUTERS - -schema;schema_MOUNT: - type: map - mapping: - _name: - type: str - required: True - _components: - type: seq - required: True - sequence: - - type: str - -schema;schema_CHANNEL: - type: map - mapping: - _name: - type: str - required: True - _components: - type: seq - required: False - sequence: - - type: str - -schema;schema_COMPUTER: - type: map - mapping: - _name: - type: str - required: True - _file: - type: str - required: True - _hostname: - type: str - required: False - _role: - type: str - required: False - database: - type: map - required: False - mapping: - name: - type: str - port: - type: int - _main: - type: str - required: False - agents: - type: any - required: False - -schema;schema_COMPUTERS: -# TODO: can be improved if we switch to sequence -> we can have any number of computers - type: seq - sequence: - - type: map - mapping: - COMPUTER: - include: schema_COMPUTER - -schema;schema_UNITS: - type: seq - required: True - sequence: - - type: map - mapping : - UNIT: - include: schema_UNIT - - - -schema;schema_CHANNELS: - type: seq - required: True - sequence: - - type : map - mapping: - CHANNEL: - include: schema_CHANNEL - - -type: map -mapping: - OBSERVATORY: - type: map - required: True - mapping: - _name: - type: str - UNITS: - include: schema_UNITS \ No newline at end of file diff --git a/privatedev/config/schema_observatory-2.0.yml b/privatedev/config/schema_observatory-2.0.yml deleted file mode 100644 index 7107b1f..0000000 --- a/privatedev/config/schema_observatory-2.0.yml +++ /dev/null @@ -1,244 +0,0 @@ -schema;schema_DATABASE: - required: True - type: map - mapping: - _computer: - type: str - required: True - _file: - type: str - required: True - -schema;schema_AGENT_DEVICE: - type: map - required: True - mapping: - _computer: - type: str - required: True - _name: - type: str - required: True - _path: - type: str - _device: - type: str - _protocol: - type: str - -schema;schema_AGENT: - type: map - required: True - mapping: - _computer: - type: str - required: True - _name: - type: str - required: True - _path: - type: str - -schema;schema_GROUP: - type: map - required: True - mapping: - GROUP: - type: map - mapping: - _logic: - type: str - _channels: - type: seq - required: True - sequence: - - type: str - -schema;schema_CHANNEL_GROUPS: - type: map - required: True - mapping: - _logic: - type: str - GROUPS: - type: seq - sequence: - - include: schema_GROUP - -schema;schema_MOUNT: - type: map - mapping: - _name: - type: str - required: True - COMPONENT_AGENTS: - type: seq - required: True - sequence: - - type: any - -schema;schema_CHANNEL: - type: map - mapping: - _name: - type: str - required: True - COMPONENT_AGENTS: - type: seq - required: True - sequence: - - type: any - - -schema;schema_SECURITY: - type: map - required: True - mapping: - _name: - type: str - required: True - COMPONENT_AGENTS: - type: seq - required: True - sequence: - - type: any - - -schema;schema_TOPOLOGY: - required: True - type: map - mapping: - SECURITY: - include: schema_SECURITY - MOUNT: - include: schema_MOUNT - CHANNELS: - include: schema_CHANNELS - CHANNEL_GROUPS: - include: schema_CHANNEL_GROUPS - - - -schema;schema_COMPUTER: - type: map - mapping: - _name: - type: str - required: True - _file: - type: str - required: True - _role: - type: str - required: False - _network_interface_index: - type: text - _network_ip: - type: str - - -schema;schema_AGENTS: - required: True - type: seq - matching: "any" - sequence: - - type: map - mapping: - AGENT_DEVICE: - include: schema_AGENT_DEVICE - - type: map - mapping: - AGENT: - include: schema_AGENT - -schema;schema_COMPUTERS: - type: seq - sequence: - - type: map - mapping: - COMPUTER: - include: schema_COMPUTER - -schema;schema_UNIT: - type: map - required: True - mapping: - _name: - type: str - required: True - DATABASE: - include: schema_DATABASE - AGENTS: - include: schema_AGENTS - TOPOLOGY: - include: schema_TOPOLOGY - - -schema;schema_UNITS: - type: seq - required: True - sequence: - - type: map - mapping : - UNIT: - include: schema_UNIT - - - -schema;schema_CHANNELS: - type: seq - required: True - sequence: - - type : map - mapping: - CHANNEL: - include: schema_CHANNEL - - - -schema;schema_DEVICE: - type: map - required: True - mapping: - _name: - type: str - required: True - _file: - type: str - required: True - _network_interface_index: - type: text - _network_ip: - type: str - - -schema;schema_DEVICES: - type: seq - required: True - sequence: - - type: map - mapping: - DEVICE: - include: schema_DEVICE - - -schema;schema_OBSERVATORY: - type: map - required: True - mapping: - _name: - type: str - DEVICES: - include: schema_DEVICES - COMPUTERS: - include: schema_COMPUTERS - UNITS: - include: schema_UNITS - -type: map -mapping: - schema: - type: str - required: True - OBSERVATORY: - include: schema_OBSERVATORY diff --git a/privatedev/config/schema_observatory_verify.py b/privatedev/config/schema_observatory_verify.py deleted file mode 100644 index e8772ed..0000000 --- a/privatedev/config/schema_observatory_verify.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- - -import pykwalify.core -from pykwalify.errors import SchemaError - -""" -Read yaml file : -import yaml -filename = "observatory_guitalens.yml" -with open(filename, 'r') as stream: - try: - a = yaml.safe_load(stream) - print(a) - except yaml.YAMLError as exc: - print(exc) - -# Write YAML file -with open('config2.yml', 'w', encoding='utf8') as outfile: - yaml.dump(a, outfile, default_flow_style=False, allow_unicode=True) -""" - -""" -import yaml -with open("config.yml", 'r') as stream: - try: - a = yaml.safe_load(stream) - print(a) - except yaml.YAMLError as exc: - print(exc) - - """ - -def check_and_return_config(yaml_file:str,schema_file:str)->dict: - """ - Check if yaml_file is valid for the schema_file - - Args: - yaml_file (str): Path to the config_file to be validated - schema_file (str): Path to the schema file - - Returns: - dict: Dictionnary of the config file (with values) - """ - try: - - c = pykwalify.core.Core(source_file=yaml_file, schema_files=[schema_file]) - return c.validate(raise_exception=True) - except SchemaError as error: - #TODO : find a way to retrieve message with path to error - print(error.path) - - -print(check_and_return_config("observatory_v1.yml","schema_observatory-1.0.yml")) \ No newline at end of file diff --git a/privatedev/config/veirify_config.py b/privatedev/config/veirify_config.py deleted file mode 100644 index 2d456e4..0000000 --- a/privatedev/config/veirify_config.py +++ /dev/null @@ -1,51 +0,0 @@ -import pykwalify.core -import yaml,sys,logging -from pykwalify.errors import PyKwalifyException,SchemaError - - -def check_and_return_config(yaml_file:str,schema_file:str)->dict: - """ - Check if yaml_file is valid for the schema_file and return an dictionnary of the config file - - Args: - yaml_file (str): Path to the config_file to be validated - schema_file (str): Path to the schema file - - Returns: - dict: Dictionnary of the config file (with values) - """ - # disable pykwalify error to clean the output - logging.disable(logging.ERROR) - try: - c = pykwalify.core.Core(source_file=yaml_file, schema_files=[schema_file]) - return c.validate(raise_exception=True) - except SchemaError: - for error in c.errors: - print("Error :",str(error).split(". Path")[0]) - print("Path to error :",error.path) - # error.value is the value causing the error - # print(error.value) - # error.scalar_type is the type (defined by schema) that the value should match - # print(error.scalar_type) - # error.path is the path to the error in the yaml file - # print(error.path) -def read_and_check_config_file(yaml_file:str): - """ - Read the schema key of the config file to retrieve schema name and proceed to the checking of that config file - Call check_and_return_config function and print its return. - - Args: - yaml_file (str): path to the config file - """ - with open(yaml_file, 'r') as stream: - try: - config_file = yaml.safe_load(stream) - result = check_and_return_config(yaml_file,config_file["schema"]) - if result is None: - print("Error when reading and validating config file, please check the errors right above") - else: - print(result) - except yaml.YAMLError as exc: - print(exc) - -read_and_check_config_file(sys.argv[1]) \ No newline at end of file -- libgit2 0.21.2