Commit f6009f75b4ef6efb31d9fd20e54ce2bf40d05bbc

Authored by Etienne Pallier
1 parent 57621753
Exists in dev

Update diagramme UML pour NEW ARCHI DeviceController

src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu
... ... @@ -65,20 +65,34 @@ AgentMajordome -d-> AD_Sensor1 : sends cmd to
65 65 AgentMajordome -d-> AD_Shutter2 : sends cmd to
66 66  
67 67  
68   -/'
69   -======= Abstract Device Controllers =======
70   -class DeviceControllerAbstract
71   -class DC_FilterSelector
72   -class DC_DetectorShutter
73   -class DC_DetectorSensor
74   -'/
  68 +class DeviceController {
  69 + ip, port
  70 + channel: ClientChannel
  71 + protocol: Protocol
  72 + gen2nat_cmds # abstract
  73 +}
  74 +
  75 +class DC_Mount {
  76 + gen2nat_cmds # abstract
  77 +}
  78 +class DC_DetectorShutter {
  79 + gen2nat_cmds # abstract
  80 +}
  81 +class DC_DetectorSensor {
  82 + gen2nat_cmds # abstract
  83 +}
  84 +class DC_FilterSelector {
  85 + gen2nat_cmds # abstract
  86 +}
  87 +
  88 +
75 89  
76 90  
77 91 /' ======= CHANNELS ======= '/
78 92  
79   -DeviceControllerAbstract o-l- DeviceSimulator
  93 +DeviceController "1" o-r- "0..1" DeviceSimulator
80 94  
81   -DeviceControllerAbstract o-d- ClientChannel
  95 +DeviceController o-d- ClientChannel
82 96 class ClientChannelSerial #lightred
83 97 class ClientChannelSocket #lightred
84 98 class ClientChannelUSB #lightred
... ... @@ -89,33 +103,36 @@ ClientChannel <|-- ClientChannelUSB
89 103  
90 104 /' ======= GEMINI controllers (& sim) ======= '/
91 105  
92   -class AgentDeviceTelescopeGemini #lightblue
93   -AgentDeviceTelescopeGemini -u--|> AgentDevice
  106 +class AgentDeviceGemini #lightblue
  107 +AgentDeviceGemini -u--|> AgentDevice
94 108  
95 109 /' Components (only 1) '/
96   -AD_Telescope1 -d-> AgentDeviceTelescopeGemini :alias of
  110 +AD_Telescope1 -d-> AgentDeviceGemini :alias of
97 111  
98 112 /'DC_Mount o-left- DS_Mount'/
99 113  
100   -AgentDeviceTelescopeGemini --> DC_Gemini :use
101   -/'DC_Gemini o-left- DS_Gemini'/
  114 +/'AgentDeviceGemini ---> DC_Gemini :use'/
  115 +AgentDeviceGemini "1" o--- "1" DC_Gemini :use
102 116  
103 117 /' Controllers '/
  118 +class DC_Gemini {
  119 + (client)
  120 + protocol: Protocol
  121 + gen2nat_cmds # gemini
  122 +}
104 123 class DC_Gemini <<Singleton>> #lightblue
105   -class DC_MountGemini #lightblue
106 124 DC_Gemini <.l> gemini_device : channel/\nsocket
107   -DC_Gemini ---|> DeviceControllerAbstract
108   -DC_Gemini o-- DC_MountGemini
109   -DC_MountGemini --d|> DC_Mount
110   -DC_Mount --|> DeviceControllerAbstract
  125 +DC_Gemini ---|> DeviceController
  126 +DC_Gemini "*" o-- "1" DC_Mount
  127 +DC_Mount --|> DeviceController
111 128  
112 129 /' Simulators '/
  130 +class DS_Gemini {
  131 + (server)
  132 +}
113 133 class DS_Gemini #lightblue
114   -class DS_MountGemini #lightblue
115 134 DS_Gemini ---|> DeviceSimulator
116   -DS_Gemini o-down-> DS_MountGemini
117   -DS_MountGemini -d-|> DS_Mount
118   -DS_Mount --|> DeviceSimulator
  135 +DC_Gemini "1" o- "1" DS_Gemini
119 136  
120 137  
121 138  
... ... @@ -129,45 +146,34 @@ AD_FilterSelector1 --&gt; AgentDeviceSBIG :alias of
129 146 AD_Shutter1 --> AgentDeviceSBIG :alias of
130 147 AD_Sensor1 --> AgentDeviceSBIG :alias of
131 148  
132   -AgentDeviceSBIG -d-> DC_SBIG :use
133   -/'DC_SBIG o- DS_SBIG'/
  149 +AgentDeviceSBIG "1" o-d-> "1" DC_SBIG :use
  150 +DC_SBIG "1" o- "1" DS_SBIG
134 151  
135 152 /' Controllers '/
136 153  
  154 +class DC_SBIG {
  155 + (client)
  156 + protocol: Protocol
  157 + gen2nat_cmds # sbig
  158 +}
137 159 class DC_SBIG <<Singleton>> #lightgreen
138   -class DC_DetectorSensorSBIG #lightgreen
139   -class DC_DetectorShutterSBIG #lightgreen
140   -class DC_FilterSelectorSBIG #lightgreen
141 160  
142 161 DC_SBIG <.r> sbig_device : channel/\nsocket
143   -DC_SBIG ---|> DeviceControllerAbstract
144   -DC_SBIG "0..1" o-down- DC_DetectorSensorSBIG
145   -DC_SBIG "0..1" o-down- DC_DetectorShutterSBIG
146   -DC_SBIG "0..1" o-down- DC_FilterSelectorSBIG
147   -
148   -DC_DetectorSensorSBIG --d|> DC_DetectorSensor
149   -DC_DetectorShutterSBIG --d|> DC_DetectorShutter
150   -DC_FilterSelectorSBIG --d|> DC_FilterSelector
  162 +DC_SBIG ---|> DeviceController
  163 +DC_SBIG "*" o-down- "0..1" DC_DetectorSensor
  164 +DC_SBIG "*" o-down- "0..1" DC_DetectorShutter
  165 +DC_SBIG "*" o-down- "0..1" DC_FilterSelector
151 166  
152   -DC_DetectorSensor --|> DeviceControllerAbstract
153   -DC_DetectorShutter --|> DeviceControllerAbstract
154   -DC_FilterSelector --|> DeviceControllerAbstract
  167 +DC_DetectorSensor --|> DeviceController
  168 +DC_DetectorShutter --|> DeviceController
  169 +DC_FilterSelector --|> DeviceController
155 170  
156 171 /' Simulators '/
  172 +class DS_SBIG {
  173 + (server)
  174 +}
157 175 class DS_SBIG #lightgreen
158   -class DS_DetectorSensorSBIG #lightgreen
159   -class DS_DetectorShutterSBIG #lightgreen
160   -class DS_FilterSelectorSBIG #lightgreen
161 176 DS_SBIG ---|> DeviceSimulator
162   -DS_SBIG o-down- DS_DetectorShutterSBIG
163   -DS_SBIG o-down- DS_DetectorSensorSBIG
164   -DS_SBIG o-down- DS_FilterSelectorSBIG
165   -DS_DetectorShutterSBIG -d-|> DS_DetectorShutter
166   -DS_DetectorSensorSBIG -d-|> DS_DetectorSensor
167   -DS_FilterSelectorSBIG -d-|> DS_FilterSelector
168   -DS_DetectorShutter --|> DeviceSimulator
169   -DS_DetectorSensor --|> DeviceSimulator
170   -DS_FilterSelector --|> DeviceSimulator
171 177  
172 178  
173 179 /' ======= LEGEND ======= '/
... ... @@ -175,7 +181,7 @@ DS_FilterSelector --|&gt; DeviceSimulator
175 181 skinparam legendFontSize 11
176 182  
177 183 legend left
178   -<i>Version 22-10-2019 (E. Pallier)</i>
  184 +<i>Version 04-11-2019 (E. Pallier)</i>
179 185  
180 186 Colors: <b>yellow</b> : abstract classes ; <b>red</b> : real devices ; <b>blue</b> : Gemini concrete classes ; <b>green</b> : SBIG concrete classes
181 187  
... ... @@ -184,12 +190,12 @@ AD = &lt;b&gt;Agent Device&lt;/b&gt;
184 190 DC = <b>Device Controller</b> (Device <b>client</b>, pyros <b>generic commands only</b>):
185 191 - translates an agent <b>generic</b> command to a native command, and sends it to device
186 192 - receives device's native answer, translates it to <b>generic</b> and returns it back to agent
187   -(<i>every DC is composed of a <b>DS of the same name</b></i>)
  193 +(<i>every DC can be composed of a <b>DS of the same name</b></i>)
  194 +(<i>every DC contains a 'generic to native' commands dictionary named "gen2nat_cmds")</i>
188 195  
189 196 DS = <b>Device Simulator</b> (Device placeholder <b>server</b>, <b>native commands only</b>):
190 197 - receives <b>native</b> commands from client
191 198 - returns (simulated) <b>native</b> answer to client
192   -(<i>every DS contains a 'generic to native' dictionary named "gen2nat_qa")</i>
193 199 (<i>abstract DS receive only generic commands and return generic answers</i>)
194 200 endlegend
195 201  
... ...
src/device_controller/concrete_component/gemini/proof_of_concept_for_Protocol.py 0 โ†’ 100644
... ... @@ -0,0 +1,72 @@
  1 +
  2 +class DC:
  3 +
  4 + class Protoc:
  5 + def encap(self):
  6 + print("DC encap")
  7 + def uncap(self):
  8 + pass
  9 +
  10 + def encap(self):
  11 + ##self.Protoc.encap(self)
  12 + self._protoc.encap(self)
  13 +
  14 + def __init__(self, name, toto="dc toto", protoc=None):
  15 + self.toto = toto
  16 + self._protoc = protoc if protoc else self.Protoc
  17 + print("in DC")
  18 +
  19 +
  20 +class DC1(DC):
  21 + def __init__(self, name, protoc=None):
  22 + print("in DC1")
  23 + # @override
  24 + ##self._protoc = protoc
  25 + ##DC.__init__(self, name, protoc)
  26 + super().__init__(name, protoc=protoc)
  27 + #super().__init__(name, protoc)
  28 +
  29 +
  30 +class DC2(DC):
  31 + def __init__(self, name):
  32 + print("in DC2")
  33 + self.b = 'tata'
  34 + #super().__init__(name)
  35 + DC.__init__(self, name)
  36 +
  37 +
  38 +class DC3(DC):
  39 + def __init__(self, name):
  40 + print("in DC3")
  41 + #super().__init__(name)
  42 + DC.__init__(self, name)
  43 +
  44 +
  45 +class DCGem(DC):
  46 + # @override
  47 + class Protoc:
  48 + def encap(self):
  49 + DC.Protoc.encap(self)
  50 + #super().Protoc.encap(self)
  51 + # this is equivalent to
  52 + #super(DCGem,self).Protoc.encap(self)
  53 + print("DCGem encap")
  54 + def uncap(self):
  55 + pass
  56 +
  57 + def __init__(self):
  58 + super().__init__("nom_dcgem", "gem toto")
  59 + # same as :
  60 + #super().__init__("nom_dcgem", self.Protoc)
  61 + print("_protoc is:", self._protoc)
  62 + self.dc1 = DC1("nom_dc1", self.Protoc)
  63 + self.dc1.encap()
  64 +
  65 +
  66 +dcg = DCGem()
  67 +print ("gem toto is", dcg.toto)
  68 +print ("dc1 toto is", dcg.dc1.toto)
  69 +#dcg.Protoc.encap(dcg)
  70 +##dcg.encap()
  71 +
  72 +
... ...
src/device_controller/concrete_component/gemini/proof_of_concept_for_multi_inherit.py 0 โ†’ 100644
... ... @@ -0,0 +1,89 @@
  1 +
  2 +class DC:
  3 + def __init__(self, name):
  4 + print("in DC")
  5 + self.name = name
  6 +
  7 + def print_name(self): print(self.name)
  8 +
  9 + def toto(self):
  10 + print("\nI am", self)
  11 + print("DC toto")
  12 +
  13 +
  14 +
  15 +class DCGeneral(DC):
  16 + def __init__(self, name):
  17 + print("in DC1")
  18 + self.a = 'toto'
  19 + super().__init__(name)
  20 + #DC.__init__(self, name)
  21 +
  22 +class DC1(DC):
  23 + def __init__(self, name):
  24 + print("in DC1")
  25 + self.a = 'toto'
  26 + super().__init__(name)
  27 + #DC.__init__(self, name)
  28 + def goto(self):
  29 + print("DC1 goto")
  30 +
  31 +
  32 +class DC2(DC):
  33 + def __init__(self, name):
  34 + print("in DC2")
  35 + self.b = 'tata'
  36 + super().__init__(name)
  37 + #DC.__init__(self, name)
  38 + def goto(self):
  39 + print("DC2 goto")
  40 +
  41 +
  42 +class DC3(DC):
  43 + def __init__(self, name):
  44 + print("in DC3")
  45 + super().__init__(name)
  46 + #DC.__init__(self, name)
  47 +
  48 +class DCSBIG(DCGeneral, DC1,DC2,DC3):
  49 + def __init__(self):
  50 + # DC general
  51 + super().__init__("DC_general")
  52 + # DC components
  53 + DC1.__init__(self, "DC1")
  54 + DC2.__init__(self, "DC2")
  55 + DC3.__init__(self, "DC3")
  56 + self.name = "gem"
  57 +
  58 + def printall(self):
  59 + # by default, DC1 goto
  60 + self.goto()
  61 + # DC2 goto
  62 + DC2.goto(self)
  63 + # by default, DCSBIG toto
  64 + self.toto()
  65 + # DC toto AND NOT DCSBIG's, problem for the protocol !!!!!!!!!!!!!!!!
  66 + DC1.toto(self)
  67 + DC2.toto(self)
  68 +
  69 + # force to DCSBIG toto !!!
  70 + DC1.toto = self.toto
  71 + DC1.toto()
  72 +
  73 + def toto(self):
  74 + print("DCSBIG toto")
  75 +
  76 +
  77 +print(DCSBIG.mro())
  78 +#dc1 = DC1('toto')
  79 +#dc1.print_name()
  80 +#print(DCGem.__mro__)
  81 +dcs = DCSBIG()
  82 +dcs.print_name()
  83 +print(dcs.a)
  84 +print(dcs.b)
  85 +dcs.printall()
  86 +
  87 +# DC1 goto
  88 +#dcs.goto()
  89 +
... ...