When attribute_wrapper code goes through OFF->INIT->STANDBY->ON an exception gets thrown due to an unallowed state transition
This is the exception that gets thrown:
2021-04-02 19:05:45 [139678619518720] DEBUG lts/pcc/1 connected OPC ua node RCU_monitor_rate_RW of type Double to attribute with dimensions: 1 x 0
2021-04-02 19:05:45 [139678594340608] DEBUG lts/pcc/1 Connecting to server opc.tcp://okeanos:4842/
2021-04-02 19:05:45 [139678619518720] DEBUG lts/pcc/1 <- PCC.Initialise()
2021-04-02 19:05:45 [139678619518720] DEBUG lts/pcc/1 -> PCC.On()
2021-04-02 19:05:45 [139678619518720] DEBUG lts/pcc/1 <- PCC.On()
2021-04-02 19:05:45 [139678594340608] DEBUG lts/pcc/1 Connected to opc.tcp://okeanos:4842/. Initialising.
2021-04-02 19:05:45 [139678594340608] WARN lts/pcc/1 Illegal command: Function Standby can only be called in states [tango._tango.DevState.INIT]. Current state: ON
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/hosthome/workspace.astron/git/ASTRON/tango/devices/src/comms_client.py", line 48, in run
self.standby_func()
File "/hosthome/workspace.astron/git/ASTRON/tango/devices/src/wrappers.py", line 19, in state_check_wrapper
Except.throw_exception("IllegalCommand", "Function can only be called in states %s. Current state: %s" % (allowed_states, self.get_state()), func.__name__)
PyTango.DevFailed: DevFailed[
DevError[
desc = Function can only be called in states [tango._tango.DevState.INIT]. Current state: ON
origin = Standby
reason = IllegalCommand
severity = ERR]
I executed the startup function:
In [43]: pcc = startup(device = 'LTS/PCC/1', force_restart = False)
Device LTS/PCC/1 is in OFF, performing initialisation.
Device LTS/PCC/1 is in STANDBY, performing on.
Device LTS/PCC/1 has successfully reached ON state.
As can be seen the device reaches the ON state. But still the exception gets raised. Should not happen.
I believe that the problem lies in the passing of PCC.Standby as standby function to the CommsClient class but as On function to the OPCUAConnection class. It looks like this slipped through the cracks of a proper check.