Commit 004998329962ed8a0d7a9768b34448dcf55a4e95

Authored by Etienne Pallier
1 parent e58381a7
Exists in dev

refactorisation (3)

Suppression methode set_protoc_and_cmds() du simulator (DS), devenue
inutile car on passe le DC en paramètre au DS
src/device_controller/abstract_component/device_controller.py
... ... @@ -418,6 +418,7 @@ class DeviceController():
418 418 '''
419 419  
420 420 # WRAPPER methods
  421 + def getp(self)->Protocol: return self._protoc
421 422 def formated_cmd(self, cmd:str, value:str=None)->str:
422 423 ##return self._protoc.formated_cmd(self, cmd, value)
423 424 return self._protoc.formated_cmd(cmd, value)
... ... @@ -492,7 +493,7 @@ class DeviceController():
492 493 # Pass to my simulator a reference to myself
493 494 self._device_simulator.set_dc(self)
494 495 # TODO: a virer car plus necessaire vu qu'on passe le DC au simu
495   - self._device_simulator.set_protoc_and_cmds(protoc, self._my_cmds)
  496 + ##self._device_simulator.set_protoc_and_cmds(protoc, self._my_cmds)
496 497 print("SIMU IS", device_sim, self._device_simulator)
497 498 self._thread_device_simulator = threading.Thread(target=self.device_simulator_run)
498 499 self._thread_device_simulator.start()
... ...
src/device_controller/abstract_component/device_simulator.py
... ... @@ -21,8 +21,8 @@ class DeviceSimulator:
21 21  
22 22 # class attributes
23 23 myserver = None
24   - protoc = None
25   - gen2nat_cmds = None
  24 + #protoc = None
  25 + #gen2nat_cmds = None
26 26 # My associated Device Controller
27 27 my_dc = None
28 28  
... ... @@ -30,23 +30,28 @@ class DeviceSimulator:
30 30 @classmethod
31 31 def set_dc(cls, dc:DeviceController):
32 32 cls.my_dc = dc
  33 + cls.protoc = dc.getp()
33 34  
  35 + '''
34 36 # This method will be called by the DC when launching its simulator
35 37 @classmethod
36 38 def set_protoc_and_cmds(cls, protoc, gen2nat_cmds, DEBUG=False):
37 39 # (EP) This is a bit ugly but I had to do this...
38 40 # Set protoc and gen2nat_cmds class attributes for class DeviceSimulator
39   - '''
  41 + #''
40 42 DeviceSimulator.protoc = protoc
41 43 DeviceSimulator.gen2nat_cmds = gen2nat_cmds
42   - '''
  44 + #''
43 45 # Idem for subclasses (DS_Gemini, DS_SBIG, ...) class attributes
44 46 cls.protoc = protoc
45 47 cls.gen2nat_cmds = gen2nat_cmds
46 48 print("****** (SIM) my cmds are:", cls.gen2nat_cmds, "******")
  49 + '''
47 50  
  51 + '''
48 52 @classmethod
49   - def getp(cls): return cls.protoc
  53 + def getp(cls): return cls.my_dc.getp()
  54 + '''
50 55 '''
51 56 @classmethod
52 57 def getc(cls): return cls.gen2nat_cmds
... ...