From 09612fdce62b21d98b0ae7d388380c06e8f2768f Mon Sep 17 00:00:00 2001 From: aaronlong Date: Fri, 5 Nov 2021 11:44:38 +0000 Subject: [PATCH] removed old emulator --- lewis_emulators/chtobisr/__init__.py | 5 - lewis_emulators/chtobisr/device.py | 163 ------------------ .../chtobisr/interfaces/__init__.py | 3 - .../chtobisr/interfaces/stream_interface.py | 80 --------- lewis_emulators/chtobisr/states.py | 5 - 5 files changed, 256 deletions(-) delete mode 100644 lewis_emulators/chtobisr/__init__.py delete mode 100644 lewis_emulators/chtobisr/device.py delete mode 100644 lewis_emulators/chtobisr/interfaces/__init__.py delete mode 100644 lewis_emulators/chtobisr/interfaces/stream_interface.py delete mode 100644 lewis_emulators/chtobisr/states.py diff --git a/lewis_emulators/chtobisr/__init__.py b/lewis_emulators/chtobisr/__init__.py deleted file mode 100644 index ab369a8d..00000000 --- a/lewis_emulators/chtobisr/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .device import SimulatedChtobisr -from ..lewis_versions import LEWIS_LATEST - -framework_version = LEWIS_LATEST -__all__ = ['SimulatedChtobisr'] diff --git a/lewis_emulators/chtobisr/device.py b/lewis_emulators/chtobisr/device.py deleted file mode 100644 index 9f1a040d..00000000 --- a/lewis_emulators/chtobisr/device.py +++ /dev/null @@ -1,163 +0,0 @@ -from collections import OrderedDict -from .states import DefaultState -from lewis.devices import StateMachineDevice -from lewis.core.logging import has_log - - -def build_code(codes_dict): - """ - Builds a code based on a codes dictionary - :param codes_dict: A dictionary with the code and whether it's flagged or not. - :return: The full code - """ - code = 0x00000000 - - for value in codes_dict.values(): - if value[0]: - code += value[1] - - return code - - -class SimulatedChtobisr(StateMachineDevice): - """ - Class to simulate Coherent OBIS Laser Remote - """ - - def _initialize_data(self): - """ - Initialize all of the device's attributes. - """ - - self.connected = True - self.id = "Coherent OBIS Laser Remote - EMULATOR" - self.interlock = "OFF" # "OFF" -> OPEN, "ON" -> CLOSED - - # Dictionary of form: - # {status_name: [whether_in_status, return_code]} - self.status = { - # Laser specific status bits - "laser_fault": [False, 0x00000001], - "laser_emission": [False, 0x00000002], - "laser_ready": [False, 0x00000004], - "laser_standby": [False, 0x00000008], - "cdrh_delay": [False, 0x00000010], - "laser_hardware_fault": [False, 0x00000020], - "laser_error": [False, 0x00000040], - "laser_power_calibration": [False, 0x00000080], - "laser_warm_up": [False, 0x00000100], - "laser_noise": [False, 0x00000200], - "external_operating_mode": [False, 0x00000400], - "field_calibration": [False, 0x00000800], - "laser_power_voltage": [False, 0x00001000], - # Controller specific status bits - "controller_standby": [False, 0x02000000], - "controller_interlock": [False, 0x04000000], - "controller_enumeration": [False, 0x08000000], - "controller_error": [False, 0x10000000], - "controller_fault": [False, 0x20000000], - "remote_active": [False, 0x40000000], - "controller_indicator": [False, 0x80000000], - } - - self.faults = { - # Laser specific fault bits - "base_plate_temp_fault": [False, 0x00000001], - "diode_temp_fault": [False, 0x00000002], - "internal_temp_fault": [False, 0x00000004], - "laser_power_supply_fault": [False, 0x00000008], - "i2c_error": [False, 0x00000010], - "over_current": [False, 0x00000020], - "laser_checksum_error": [False, 0x00000040], - "checksum_recovery": [False, 0x00000080], - "buffer_overflow": [False, 0x00000100], - "warm_up_limit_fault": [False, 0x00000200], - "tec_driver_error": [False, 0x00000400], - "ccb_error": [False, 0x00000800], - "diode_temp_limit_error": [False, 0x00001000], - "laser_ready_fault": [False, 0x00002000], - "photodiode_fault": [False, 0x00004000], - "fatal_fault": [False, 0x00008000], - "startup_fault": [False, 0x00010000], - "watchdog_timer_reset": [False, 0x00020000], - "field_calibration": [False, 0x00040000], - # ... - "over_power": [False, 0x00100000], - # Controller specific fault bits - # ... - "controller_checksum": [False, 0x40000000], - "controller_status": [False, 0x80000000], - } - - @has_log - def backdoor_set_interlock(self, value): - """ - Sets interlock via backdoor - :param value: "ON" or "OFF" - :return: none - """ - if value not in ["ON", "OFF"]: - self.log.error("Interlock can only be set to ON or OFF") - else: - self.interlock = value - - def reset(self): - """ - Resets all parameters by calling initialize function - """ - - self._initialize_data() - - def build_status_code(self): - """" - Builds the device status code - - :return: status code - """ - return build_code(self.status) - - def build_fault_code(self): - """" - Builds the device fault code - - :return: fault code - """ - return build_code(self.faults) - - @has_log - def backdoor_set_status(self, statusname, value): - """ - Sets status code via backdoor - :param statusname: name of status attribute - :param value: true or false - :return: none - """ - try: - self.status[statusname][0] = value - except KeyError: - self.log.error("An error occurred: " + KeyError.message) - - @has_log - def backdoor_set_fault(self, faultname, value): - """ - Sets fault code via backdoor - :param faultname: name of fault attribute - :param value: true or false - :return: none - """ - try: - self.faults[faultname][0] = value - except KeyError: - self.log.error("An error occurred: " + KeyError.message) - - def _get_state_handlers(self): - return { - 'default': DefaultState(), - } - - def _get_initial_state(self): - return 'default' - - def _get_transition_handlers(self): - return OrderedDict([ - ]) diff --git a/lewis_emulators/chtobisr/interfaces/__init__.py b/lewis_emulators/chtobisr/interfaces/__init__.py deleted file mode 100644 index 007631b7..00000000 --- a/lewis_emulators/chtobisr/interfaces/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .stream_interface import ChtobisrStreamInterface - -__all__ = ['ChtobisrStreamInterface'] diff --git a/lewis_emulators/chtobisr/interfaces/stream_interface.py b/lewis_emulators/chtobisr/interfaces/stream_interface.py deleted file mode 100644 index f9fc8145..00000000 --- a/lewis_emulators/chtobisr/interfaces/stream_interface.py +++ /dev/null @@ -1,80 +0,0 @@ -from lewis.adapters.stream import StreamInterface, Cmd -from lewis.core.logging import has_log - -from lewis.utils.command_builder import CmdBuilder -from lewis.utils.replies import conditional_reply - - -@has_log -class ChtobisrStreamInterface(StreamInterface): - """ - Stream interface for the Coherent OBIS Laser Remote - """ - - commands = { - CmdBuilder("get_id").escape("*IDN?").build(), - CmdBuilder("set_reset").escape("*RST").build(), - CmdBuilder("get_interlock").escape("SYSTEM:LOCK?").build(), - CmdBuilder("get_status").escape("SYSTEM:STATUS?").build(), - CmdBuilder("get_faults").escape("SYSTEM:FAULT?").build(), - } - - in_terminator = "\r\n" - out_terminator = "\r\n" - - def handle_error(self, request, error): - """ - If command is not recognised, print and error - - Args: - request: requested string - error: problem - """ - - self.log.error("An error occurred at request " + repr(request) + ": " + repr(error)) - - @conditional_reply("connected") - def get_id(self): - """ - Gets the device Identification string - - :return: Device ID string - """ - - return "{}".format(self._device.id) - - @conditional_reply("connected") - def set_reset(self): - """ - Resets the device - - :return: none - """ - - self._device.reset() - - @conditional_reply("connected") - def get_interlock(self): - """ - Gets the device interlock status - - :return: Interlock status - """ - - return "{}".format(self._device.interlock) - - @conditional_reply("connected") - def get_status(self): - """ - Returns status code - :return: Formatted status code - """ - return "{:08X}".format(self._device.build_status_code()) - - @conditional_reply("connected") - def get_faults(self): - """ - Returns faults code - :return: Formatted fault code - """ - return "{:08X}".format(self._device.build_fault_code()) diff --git a/lewis_emulators/chtobisr/states.py b/lewis_emulators/chtobisr/states.py deleted file mode 100644 index e4ca48e8..00000000 --- a/lewis_emulators/chtobisr/states.py +++ /dev/null @@ -1,5 +0,0 @@ -from lewis.core.statemachine import State - - -class DefaultState(State): - pass