libiec61850
libiec61850 copied to clipboard
Python - how to write boolean value?
Hello. I have a problem with write to ### CSWI1.Pos.Oper.ctlVal. Whats wrong?
con = iec61850.IedConnection_create()
error = iec61850.IedConnection_connect(con, "127.0.0.1", 102)
if (error == iec61850.IED_ERROR_OK):
theVal = "IECLDevice/CSWI1.Pos.Oper.ctlVal"
theValType = iec61850.IEC61850_FC_CO
err = iec61850.IedConnection_writeBooleanValue(con, theVal, theValType, True)
print ("Error: " + str(err))
assert(err == 0), "IEC-61850 Cannot write bool"
iec61850.IedConnection_close(con)
iec61850.IedConnection_destroy(con)
print("IEC-61850 Write Bool OK")
Output :
Error: 21
Hello. You cannot directly write to "Oper.ctlVal". The server won't accept it as it requires the whole "Oper" structure to execute a command. The library has support for send correct commands with the ControlObjectClient functions. Please see iec61850_client_example_control. There is no example in Python for that.
I solved this problem.
con = iec61850.IedConnection_create()
error = iec61850.IedConnection_connect(con, "127.0.0.1", 102)
if (error != iec61850.IED_ERROR_OK):
iec61850.IedConnection_destroy(con)
assert False, "IEC-61850 connection failed!"
setVal = iec61850.MmsValue_newBoolean(True)
assert setVal is not None, "IEC-61850 MmsValue_newBoolean failed!"
var = "IECLDevice/CSWI1.Pos"
ctrlobj = iec61850.ControlObjectClient_create(var, con)
assert ctrlobj is not None, "IEC-61850 ControlObjectClient_create failed!"
print ("Operating : %s value : %s" % (var, value))
res = iec61850.ControlObjectClient_operate(ctrlobj, setVal, 0)
assert(res == False), "IEC-61850 Cannot operate."
iec61850.IedConnection_close(con)
iec61850.IedConnection_destroy(con)
Could you share the python library, I have problems trying to compile in python 3.6. When I impot the module I get the next error: ImportError: DLL load failed: No se puede encontrar el módulo especificado
Could you help me?