Ejemplo n.º 1
0
def testClient():
    con = iec61850.IedConnection_create()
    error = iec61850.IedConnection_connect(con, "localhost", tcpPort)
    if (error == iec61850.IED_ERROR_OK):
        # Accessing to SAV values
        theVal = "testmodelSENSORS/TTMP1.TmpSv.instMag.f"
        theValType = iec61850.IEC61850_FC_MX
        temperatureValue = iec61850.IedConnection_readFloatValue(
            con, theVal, theValType)
        assert (temperatureValue[1] == 0)
        newValue = temperatureValue[0] + 10
        err = iec61850.IedConnection_writeFloatValue(con, theVal, theValType,
                                                     newValue)
        assert (err == 21)
        # Accessing to ASG values
        theVal = "testmodelSENSORS/TTMP1.TmpSp.setMag.f"
        theValType = iec61850.IEC61850_FC_SP
        temperatureSetpoint = iec61850.IedConnection_readFloatValue(
            con, theVal, theValType)
        print(temperatureSetpoint)
        assert (temperatureValue[1] == 0)
        newValue = temperatureValue[0] + 10
        err = iec61850.IedConnection_writeFloatValue(con, theVal, theValType,
                                                     newValue)
        assert (err == 0)
        temperatureSetpoint = iec61850.IedConnection_readFloatValue(
            con, theVal, theValType)
        print(temperatureSetpoint)
        assert (temperatureSetpoint[0] == newValue)
        iec61850.IedConnection_close(con)
    else:
        print("Connection error")
        sys.exit(-1)
    iec61850.IedConnection_destroy(con)
    print("client ok")
Ejemplo n.º 2
0
def getLNlist_fromIED(ip):
    res_list = []
    con = iec61850.IedConnection_create()
    error = iec61850.IedConnection_connect(con, ip, tcpPort)
    state = iec61850.IedConnection_getState(con)
    if (error == iec61850.IED_ERROR_OK):
        [deviceList, error] = iec61850.IedConnection_getLogicalDeviceList(con)
        device = iec61850.LinkedList_getNext(deviceList)
        size = iec61850.LinkedList_size(deviceList)
        while device:  #Iterate over each device from deviceList
            [logicalNodes,
             error] = iec61850.IedConnection_getLogicalDeviceDirectory(
                 con, iec61850.toCharP(device.data))
            lnode = iec61850.LinkedList_getNext(logicalNodes)
            while lnode:  #Iterate over each node from LNodeList
                LN_name = iec61850.toCharP(lnode.data)
                res_list.append(LN_name)
                lnode = iec61850.LinkedList_getNext(lnode)
            iec61850.LinkedList_destroy(logicalNodes)
            device = iec61850.LinkedList_getNext(device)
        iec61850.LinkedList_destroy(deviceList)
        iec61850.IedConnection_close(con)
    else:
        print("Connection error")
        sys.exit(-1)
    iec61850.IedConnection_destroy(con)
    return res_list
Ejemplo n.º 3
0
 def install_handler1(self):
     print("Start")
     hostname = "localhost"
     tcpPort = 102
     con = iec61850.IedConnection_create()
     error = iec61850.IedConnection_connect(con, hostname, tcpPort)
     print(str(error))
     CB_PROTO = CFUNCTYPE(None, c_void_p, c_void_p)
     cbinst = CB_PROTO(self.func_handler)
     val = c_int()
     api = CDLL("/home/ivan/Projects/libiec61850/build/src/libiec61850.so")
     ReportHandler = api.IedConnection_installReportHandlerAddr
     ReportHandler.argtypes = [
         c_uint, c_char_p, c_char_p, CB_PROTO, c_void_p
     ]
     ReportHandler.restype = None
     addr = iec61850.IedConnection_ToAddress(con)
     rcb, error = iec61850.IedConnection_getRCBValues(
         con, "TEMPLATELD0/LLN0.BR.brcbST0101", None)
     print("RCB:" + str(rcb))
     rid = iec61850.ClientReportControlBlock_getRptId(rcb)
     print("OriginalID: " + rid)
     rptRef = create_string_buffer(b"TEMPLATELD0/LLN0.BR.brcbST0101")
     rptID = create_string_buffer(b"TEMPLATELD0/LLN0$BR$brcbST0101")
     ReportHandler(addr, rptRef, rptID, cbinst, None)
     print("Enabled " +
           str(iec61850.ClientReportControlBlock_getRptEna(rcb)))
     iec61850.ClientReportControlBlock_setTrgOps(
         rcb, iec61850.TRG_OPT_DATA_UPDATE | iec61850.TRG_OPT_GI)
     iec61850.ClientReportControlBlock_setRptEna(rcb, True)
     error = iec61850.IedConnection_setRCBValues(
         con, rcb,
         iec61850.RCB_ELEMENT_RPT_ENA | iec61850.RCB_ELEMENT_TRG_OPS, True)
     print(error)
     if (error == iec61850.IED_ERROR_OK):
         print("Connection is OK")
     else:
         print("Connection error status")
     print("Enabled " +
           str(iec61850.ClientReportControlBlock_getRptEna(rcb)))
     input("Wait input ... ")
     iec61850.IedConnection_close(con)
     iec61850.IedConnection_destroy(con)
Ejemplo n.º 4
0
            value1 = iec61850.IedConnection_readStringValue(con, theVal1, theValType1);
            print(" Read Value of TTMP1.Temp1.string: %s" % value1[0]);
            
            assert(value1[1]==0)
            newValue1= value1[0]
            err1 = iec61850.IedConnection_writeVisibleStringValue(con, theVal1, theValType1, newValue1)
            assert(err1==21)
        
            # Accessing to VSG values
            theVal1 = "testmodelSENSORS/TTMP1.TmpSt.setVal"
            theValType1 = iec61850.IEC61850_FC_SP
            setpoint1 = iec61850.IedConnection_readStringValue(con, theVal1, theValType1)
            assert(value1[1]==0)
            newValue1= "Networked System Lab"
            err1 = iec61850.IedConnection_writeVisibleStringValue(con, theVal1, theValType1, newValue1)
            assert(err1==0)
			#Write Data Object with new value
            setpoint1 = iec61850.IedConnection_readStringValue(con, theVal1, theValType1)
            print(" Write Value of TTMP1.Temp1.string: %s" % setpoint1[0])
            assert(setpoint1[0]==newValue1)
            
            time.sleep(5)
        
    else:
        print("Connection error")
        sys.exit(-1)
    
    iec61850.IedConnection_close(con)
    iec61850.IedConnection_destroy(con)
    print("\n Client Disconnected.")
Ejemplo n.º 5
0
 def stop(self):
     iec61850.IedConnection_close(self.__con)
     iec61850.IedConnection_destroy(self.__con)
Ejemplo n.º 6
0
 def stop(self):
     self.logger.debug("stopping iec-61850 client")
     iec61850.IedConnection_close(self._con)
     iec61850.IedConnection_destroy(self._con)