Engineering-Research-and-Development / iotagent-opcua

IoT Agent for OPC UA protocol
https://iotagent-opcua.rtfd.io/
GNU Affero General Public License v3.0
41 stars 21 forks source link

Suggestion: Error handling when sending a command. #39

Closed rafaelalvesitm closed 3 years ago

rafaelalvesitm commented 4 years ago

Hi, I am using The IoT Agent OPC UA with a custum build FreeOpcUa server written in Python. I am able to connect both of them and they are working fine.

I am writing this issue regarding how the IoT Agent handles errors if a called method is failed to operate. The demonstrate what I mean I have the current lines of code in my OPC UA server.

def turn_pump_on(parent):
    if manualoperation.get_value() == True:
        pump_closed.set_value(False)
        pump_q.set_value(1) # Flowrate defined in project implementation
    else:  
        return ua.StatusCode(0x80990000) # Status code for BadConditionDisable error

This means that when executing the method if the variable "manual operation" is True it should turn the pump on by changing the closed and flow rate variables. If the "manual operation" variable is set to False it should return a "BadConditionDisable" error (I can get this error in UAExpert).

Even thou the method returns an error I can see that in the Orion the turn_pump_on_status has the value " pending". I would sugest that it change this value to failed in this case and as such returns an error when sending a Patch request thought IOT Agent for example.

manfredipist commented 4 years ago

Hello @rafaelalvesitm , the issue should now be resolved, please test again with our new release (1.3.8) and let us know how it goes.