Blame view

src/device_controller/abstract_component/plc.py 2.52 KB
ac0e5c70   Etienne Pallier   nouveau devices_c...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3

"""Socket Client Telescope (abstract) implementation

To be used as a base class (interface) for any concrete socket client telescope class
"""


# Standard library imports
#from enum import Enum
import functools
import logging
import socket
import sys
import time

# Third party imports

# from sockets_tele/
sys.path.append("..")
# from src_socket/client/
sys.path.append("../../..")
c6c8be74   Etienne Pallier   Restructuration d...
23
#import src.core.pyros_django.utils.celme as celme
252a8b01   Alexis Koralewski   Changing few guit...
24
import vendor.guitastro.src.guitastro as guitastro
ac0e5c70   Etienne Pallier   nouveau devices_c...
25
26
27
28
29


# Local application imports
#sys.path.append('../..')
#from src.client.socket_client_abstract import UnknownCommandException, SocketClientAbstract
4783e5b5   Etienne Pallier   GROS RENOMMAGE de...
30
from src_device.client.base import *
ac0e5c70   Etienne Pallier   nouveau devices_c...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61




# Execute also "set" and "do" commands
GET_ONLY=False
# Execute only "get" commands
#GET_ONLY=True

# Default timeouts
TIMEOUT_SEND = 10
TIMEOUT_RECEIVE = 10


'''
class c(Enum):

    # GET, SET
    DEC = 'DEC'
    RA = 'RA'
    RA_DEC = 'RA_DEC'
    
    # DO
    PARK = 'PARK'
    WARM_START = 'WARM_START'
'''





e0853b2e   Etienne Pallier   Bugfixes assert t...
62
class DeviceControllerPLC(DeviceController):
ac0e5c70   Etienne Pallier   nouveau devices_c...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    
    # @abstract (to be overriden)
    _cmd_native = {}
    _cmd = {
        # GET-SET commands:
        'get_ack': [],
        
        'get_timezone': [],
        'set_timezone': [],
        
        'get_date': [],
        'set_date': [],
        
        'get_time': [],
        'set_time': [],
        
        # DO commands:
    }


    
    def __init__(self, server_host:str="localhost", server_port:int=11110, PROTOCOL:str="TCP", buffer_size=1024, DEBUG=False):
        '''
        :param server_host: server IP or hostname
        :param server_port: server port
        :param PROTOCOL: "UDP" or "TCP"
        '''
        super().__init__(server_host, server_port, PROTOCOL, buffer_size, DEBUG)
        # overwrite abstract _cmd dictionary with subclass native _cmd_native dictionary:
        self._cmd = {**self._cmd, **self._cmd_native}

                

    
   

    '''
    ****************************
    ****************************
    GENERIC PLC COMMANDS (abstract methods)
    ****************************
    ****************************
    '''



    '''
    ****************************
     GENERIC GET & SET commands 
    **************************** 
    '''
    
    # @abstract
    @generic_cmd
    def get_ack(self): pass
    #return self.execute_generic_cmd("get_ack")



    '''
    ****************************
     GENERIC DO commands 
    **************************** 
    '''


        

# TODO: empecher de creer une instance de cette classe abstraite
# Avec ABC ?