detector_shutter.py 2.57 KB
#!/usr/bin/env python3

"""
Filter selector (abstract) implementation

To be used as a base class (interface) for any concrete Filter selector class
"""


import sys

# from sockets_tele/
#sys.path.append("..")
# from src_socket/client/
#import src.core.pyros_django.utils.celme as celme

#sys.path.append("../../..")
#import src.core.celme as celme


# Local application imports
#from device_controller.abstract_component.base import *
#sys.path.append("../..")
#from device_controller.abstract_component.base import *
from device_controller.abstract_component.device_controller import printd, DeviceController, Cmd, Gen2NatCmds


#class SocketClientTelescopeAbstract(SocketClientAbstract):
#class DeviceControllerFilterSelector(DeviceController):
class DC_DetectorShutter(DeviceController):

    _cmd_device_concrete = {}
    #_cmd_device_abstract = {
    GEN2NAT_CMDS_dict = {
        # (test only) will raise a NotImplementedException
        'do_unimplemented': [],

        'get_state': [],
        'do_open': [],
        'do_close': [],
        'do_sync': [],
    }
    GEN2NAT_CMDS_obj = Gen2NatCmds([
        # (test only) will raise a NotImplementedException
        Cmd('do_unimplemented'),

        Cmd('get_state'),
        Cmd('do_open'),
        Cmd('do_close'),
        Cmd('do_sync'),
    ])
    GEN2NAT_CMDS = GEN2NAT_CMDS_dict
    GEN2NAT_CMDS = GEN2NAT_CMDS_obj


    #TODO: remplacer PROTOCOL par "SOCKET-TCP", "SOCKET-UDP", "SERIAL", ou "USB"
    #def __init__(self, device_host:str="localhost", device_port:int=11110, PROTOCOL:str="TCP", buffer_size=1024, DEBUG=False, device_sim=None):
    def __init__(self, device_host:str="localhost", device_port:int=11110, channel:str=None, buffer_size=None, protoc=None, gen2nat_cmds={}, device_sim=None):
        '''
        :param device_host: server IP or hostname
        :param device_port: server port
        :param PROTOCOL: "UDP" or "TCP"
        '''
        #self._my_gen2nat_cmds = { **self.GEN2NAT_CMDS, **gen2nat_cmds }
        #my_gen2nat_cmds = { **self.GEN2NAT_CMDS, **gen2nat_cmds }
        #v4
        my_gen2nat_cmds = Gen2NatCmds({ **(self.GEN2NAT_CMDS.get_as_dict()), **(gen2nat_cmds.get_as_dict()) })
        
        #super().__init__(device_host, device_port, PROTOCOL, buffer_size, DEBUG, device_sim)
        super().__init__(device_host, device_port, channel, buffer_size, protoc=protoc, gen2nat_cmds=my_gen2nat_cmds, device_sim=device_sim)
        self.printd("IN DeviceControllerFilterSelector")

        # overwrite abstract _cmd dictionary with subclass native _cmd_native dictionary:
        #self._cmd = {**self._cmd, **self._cmd_native}