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")
def run_client(ip, dt, var): print(ip, dt, var) con = iec61850.IedConnection_create() timeout = iec61850.IedConnection_setConnectTimeout(con, 2000) error = iec61850.IedConnection_connect(con, ip, tcpPort) state = iec61850.IedConnection_getState(con) if (error == iec61850.IED_ERROR_OK and state): print("Good connection") if dt == 'b': [booleanValue, error] = iec61850.IedConnection_readBooleanValue( con, var, iec61850.IEC61850_FC_ST) print("booleanValue: ", booleanValue) elif dt == 'f': [analogValue, error ] = iec61850.IedConnection_readFloatValue(con, var, iec61850.IEC61850_FC_MX) print("Analog Value: ", analogValue) elif dt == 't': time = iec61850.Timestamp() [timeStampValue, error] = iec61850.IedConnection_readTimestampValue( con, var, iec61850.IEC61850_FC_MX, time) print("timeStampValue: ", iec61850.Timestamp_getTimeInSeconds(time)) elif dt == 'q': [qualityValue, error] = iec61850.IedConnection_readQualityValue( con, var, iec61850.IEC61850_FC_MX) print("qualityValue: ", qualityValue) else: print("Connection error status") sys.exit(-1) iec61850.IedConnection_destroy(con) print("Client OK")
LNobject = iec61850.LinkedList_getNext(LNobject) iec61850.LinkedList_destroy(LNobjects) logicalNode = iec61850.LinkedList_getNext(logicalNode) iec61850.LinkedList_destroy(logicalNodes) device = iec61850.LinkedList_getNext(device) iec61850.LinkedList_destroy(deviceList) running = 1; signal.signal(signal.SIGINT, signal_handler); while (running): #Read Data Object theVal = "testmodelSENSORS/TTMP1.Temp1.float" theValType = iec61850.IEC61850_FC_MX value = iec61850.IedConnection_readFloatValue(con, theVal, theValType); print("\n Read Value of TTMP1.Temp1.float: %s" % value[0]); assert(value[1]==0) newValue= value[0] err = iec61850.IedConnection_writeFloatValue(con, theVal, theValType, newValue) assert(err==25) # Accessing to ASG values theVal = "testmodelSENSORS/TTMP1.TmpSp.setMag.f" theValType = iec61850.IEC61850_FC_SP setpoint = iec61850.IedConnection_readFloatValue(con, theVal, theValType) assert(value[1]==0) newValue= 50 err = iec61850.IedConnection_writeFloatValue(con, theVal, theValType, newValue) assert(err==0)
def getInt32(self, var): [intValue, self.__error ] = iec61850.IedConnection_readFloatValue(self.__con, var, iec61850.IEC61850_FC_MX) return intValue
def read_float(self, var, fc): [float_val, self.__error] = iec61850.IedConnection_readFloatValue( self.__con, var, self.get_IEC61850_FC_by_fc(fc)) return float("{0:.3f}".format(float_val))