libiec61850 icon indicating copy to clipboard operation
libiec61850 copied to clipboard

Python - how to write boolean value?

Open hanusek opened this issue 5 years ago • 3 comments

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

hanusek avatar Oct 03 '19 12:10 hanusek

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.

mzillgith avatar Oct 04 '19 05:10 mzillgith

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)

hanusek avatar Oct 10 '19 08:10 hanusek

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?

darkjhesus avatar May 01 '20 23:05 darkjhesus