def readAttributes(self): rcb = self.__rcb print("*" * 100) isEnabled = iec61850.ClientReportControlBlock_getRptEna(rcb) print("Enabled:", isEnabled) reserverTime = iec61850.ClientReportControlBlock_getResvTms(rcb) print("reserverTime:", reserverTime) CBref = iec61850.ClientReportControlBlock_getObjectReference(rcb) print("CBref:", CBref) reportID = iec61850.ClientReportControlBlock_getRptId(rcb) print("reportID:", reportID) dsRef = iec61850.ClientReportControlBlock_getDataSetReference(rcb) print("dsRef:", dsRef) trgOpt = iec61850.ClientReportControlBlock_getTrgOps(rcb) print("trgOpt:", trgOpt) bufTime = iec61850.ClientReportControlBlock_getBufTm(rcb) print("bufTime:", bufTime) isBuffered = iec61850.ClientReportControlBlock_isBuffered(rcb) print("isBuffered:", isBuffered) confRev = iec61850.ClientReportControlBlock_getConfRev(rcb) print("confRev:", confRev) intPeriod = iec61850.ClientReportControlBlock_getIntgPd(rcb) print("intPeriod:", intPeriod) owner = iec61850.ClientReportControlBlock_getOwner(rcb) print("Owner:", iec61850.MmsValue_getBitStringAsInteger(owner)) gi = iec61850.ClientReportControlBlock_getGI(rcb) print("GI:", gi) isReserved = iec61850.ClientReportControlBlock_getResv(rcb) print("isReserved:", isReserved) entryTime = iec61850.ClientReportControlBlock_getEntryTime(rcb) print("entryTime:", entryTime) print("-" * 100)
def install_handler(self, CBref, rID): CB_PROTO = CFUNCTYPE(None, c_void_p, c_void_p) cbinst = CB_PROTO(self.func_handler) api = CDLL("/home/ivan/Projects/libiec61850/debug/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(self.__con) rid = iec61850.ClientReportControlBlock_getRptId(self.__rcb) rptRef = create_string_buffer(bytes(CBref, encoding='UTF-8')) rptID = create_string_buffer(bytes(rID, encoding='UTF-8')) ReportHandler(addr, rptRef, rptID, cbinst, None) input("Wait input....")
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)
def get_rcb_dictionary(self, report_name): [self.__rcb, error] = iec61850.IedConnection_getRCBValues(self.__con, report_name, None) if (error == iec61850.IED_ERROR_OK): rcb_dict = {} rcb_dict[ 'buffered'] = iec61850.ClientReportControlBlock_isBuffered( self.__rcb) rcb_dict['bufTime'] = str( iec61850.ClientReportControlBlock_getBufTm(self.__rcb)) rcb_dict['confRev'] = str( iec61850.ClientReportControlBlock_getConfRev(self.__rcb)) rcb_dict[ 'datSet'] = iec61850.ClientReportControlBlock_getDataSetReference( self.__rcb) rcb_dict[ 'CBref'] = iec61850.ClientReportControlBlock_getObjectReference( self.__rcb) rcb_dict['rptID'] = iec61850.ClientReportControlBlock_getRptId( self.__rcb) rcb_dict['trgOpt'] = format( iec61850.ClientReportControlBlock_getTrgOps(self.__rcb), '04b') rcb_dict['OptFields'] = format( iec61850.ClientReportControlBlock_getOptFlds(self.__rcb), '05b') rcb_dict['dchg'] = bool(rcb_dict['trgOpt'][-1] == '1') rcb_dict['qchg'] = bool(rcb_dict['trgOpt'][-2] == '1') rcb_dict['dupd'] = bool(rcb_dict['trgOpt'][-3] == '1') rcb_dict['period'] = bool(rcb_dict['trgOpt'][-4] == '1') rcb_dict['seqNum'] = bool(rcb_dict['OptFields'][-1] == '1') rcb_dict['timeStamp'] = bool(rcb_dict['OptFields'][-2] == '1') rcb_dict['reasonCode'] = bool(rcb_dict['OptFields'][-3] == '1') rcb_dict['dataSet'] = bool(rcb_dict['OptFields'][-4] == '1') rcb_dict['dataRef'] = bool(rcb_dict['OptFields'][-5] == '1') return rcb_dict else: print("failed to read RCB") self.stop()
def install_handler2(self, CBref, rID): CB_PROTO = CFUNCTYPE(None, c_void_p, c_void_p) cbinst = CB_PROTO(self.func_handler) api = CDLL("/home/ivan/Projects/libiec61850/debug/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(self.__con) # self.__rcb, self.__error = iec61850.IedConnection_getRCBValues(self.__con, CBref, None) print("RCB:" + str(self.__rcb)) rid = iec61850.ClientReportControlBlock_getRptId(self.__rcb) print("OriginalID: " + rid) rptRef = create_string_buffer(bytes(CBref, encoding='UTF-8')) rptID = create_string_buffer(bytes(rID, encoding='UTF-8')) # rptRef = create_string_buffer(b"TEMPLATELD0/LLN0.BR.brcbST0101") # rptID = create_string_buffer(b"TEMPLATELD0/LLN0$BR$brcbST0101") ReportHandler(addr, rptRef, rptID, cbinst, None) # iec61850.ClientReportControlBlock_setTrgOps(self.__rcb, iec61850.TRG_OPT_DATA_CHANGED | iec61850.TRG_OPT_QUALITY_CHANGED | iec61850.TRG_OPT_INTEGRITY | iec61850.TRG_OPT_GI) # iec61850.ClientReportControlBlock_setRptEna(self.__rcb, True) # self.__error = iec61850.IedConnection_setRCBValues(self.__con, self.__rcb, iec61850.RCB_ELEMENT_RPT_ENA | iec61850.RCB_ELEMENT_TRG_OPS, True) # print("Enabled " + str(iec61850.ClientReportControlBlock_getRptEna(self.__rcb))) input("Wait input....")
val = c_int() #iec61850.IedConnection_installReportHandler(con,"111","111",cbinst, ctypes.byref(val)) api = CDLL("/home/ivan/Projects/libiec61850/build/src/libiec61850.so") #api=CDLL("/home/alexs/projects/libiec-dirty/debug/src/libiec61850-drt.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.brcbMX0101", None) print("RCB:" + str(rcb)) rid = iec61850.ClientReportControlBlock_getRptId(rcb) print("OriginalID: " + rid) rptRef = create_string_buffer(b"TEMPLATELD0/LLN0.BR.brcbMX0101") rptID = create_string_buffer(b"TEMPLATELD0/LLN0$BR$brcbMX0101") 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)