/// <summary> /// TranslateEventData - Takes the LAN Event Data and translates it to something human readable /// </summary> /// <param name="uiCommEventCode">The Event Code of the Comm Event the Data belongs to</param> /// <param name="ArgumentReader">The raw data we are translating</param> /// <returns>The Human Readable text</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 05/13/08 KRC 1.50.24 Created // public virtual string TranslatedEventData(ushort uiCommEventCode, BinaryReader ArgumentReader) { string strData = ""; switch (uiCommEventCode) { case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_LINK_SWITCH: { strData = "New Link ID: " + ArgumentReader.ReadUInt16().ToString(CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_LINK_METRIC: { UInt16 gpd = ArgumentReader.ReadUInt16(); byte syncFatherRssi = ArgumentReader.ReadByte(); byte bestFatherRssi = ArgumentReader.ReadByte(); byte fatherCount = ArgumentReader.ReadByte(); strData = "gpd: " + gpd.ToString(CultureInfo.InvariantCulture) + "; Synch Father RSSI: " + syncFatherRssi.ToString(CultureInfo.InvariantCulture) + "; Best Father RSSI: " + bestFatherRssi.ToString(CultureInfo.InvariantCulture) + "; Father Count: " + fatherCount.ToString(CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_SEND_PERIODIC_READ_FAILED: { byte byReason = ArgumentReader.ReadByte(); if (byReason == 1) { strData = "Table Request Too Big"; } else if (byReason == 2) { strData = "Message is Invalid"; } else if (byReason == 3) { strData = "Send Failed"; } else if (byReason == 4) { strData = "Table 8 Response could not be added to EPSEM when starting report message"; } else if (byReason == 5) { strData = "Could not set user information into the message when starting periodic upload message"; } else if (byReason == 6) { strData = "EPSEM validation failed when checked when finishing the periodic upload message."; } else if (byReason == 7) { strData = "Could not locate app data in message at end of periodic upload generation"; } else if (byReason == 8) { strData = "Position EPSEM to end failed when padding EPSEM"; } else if (byReason == 9) { strData = "Could not force terminate EPSEM after add Table 8 response at beginning of message"; } break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_SEND_PERIODIC_READ_SUCCESS: case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_RECEIVED_REQUEST: case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_SEND_MESSAGE_SUCCEEDED: { strData = "Calling Application Invocation ID: " + ArgumentReader.ReadUInt16().ToString(CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_SEND_EXCEPTION_FAILED: { byte byReason = ArgumentReader.ReadByte(); if (byReason == 1) { strData = "Cannot Add to EPSEM"; } else if (byReason == 2) { strData = "Encryption Failed"; } else if (byReason == 3) { strData = "Send Failed"; } break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_SEND_EXCEPTION_SUCCESS: { strData = "Calling Application Invocation ID: " + ArgumentReader.ReadUInt16().ToString(CultureInfo.InvariantCulture) + "; Event ID: " + ArgumentReader.ReadUInt16().ToString(CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_SEND_RESPONSE_FAILED: case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_REGISTRATION_RESULT: case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_DEREGISTRATION_RESULT: { byte C1222MessageFailureCode = ArgumentReader.ReadByte(); strData = GetC1222MessageFailureCode(C1222MessageFailureCode); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_SENT_MESSAGE_FAILED: { UInt16 CallingApInvocationID = ArgumentReader.ReadUInt16(); byte C1222MessageFailureCode = ArgumentReader.ReadByte(); strData = "Calling Application Invocation ID: " + CallingApInvocationID.ToString(CultureInfo.InvariantCulture); strData += "; " + GetC1222MessageFailureCode(C1222MessageFailureCode); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_LEVEL_CHANGE: { strData = "New Level: " + ArgumentReader.ReadByte().ToString(CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_BEST_FATHER_CHANGE: { strData = "New Best Father: " + ArgumentReader.ReadUInt32().ToString("X8", CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_SYNCH_FATHER_CHANGE: { strData = "New Synch Father: " + ArgumentReader.ReadUInt32().ToString("X8", CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_PROCESS_RCVD_MSG_TIMING: { UInt32 firstSegReceived = ArgumentReader.ReadUInt32(); UInt32 lastSegReceived = ArgumentReader.ReadUInt32(); UInt32 avaiableforServer = ArgumentReader.ReadUInt32(); UInt32 responseBuiltPreEncryption = ArgumentReader.ReadUInt32(); UInt32 responseReadyToSend = ArgumentReader.ReadUInt32(); UInt32 uiSegReceiveTime = lastSegReceived - firstSegReceived; UInt32 uiDecryptionTime = avaiableforServer - lastSegReceived; UInt32 uiMeterProcessTime = responseBuiltPreEncryption - avaiableforServer; UInt32 uiEncryptionTime = responseReadyToSend - responseBuiltPreEncryption; strData = "Segement Receive Time: " + uiSegReceiveTime.ToString(CultureInfo.InvariantCulture) + "ms; Decryption Time: " + uiDecryptionTime.ToString(CultureInfo.InvariantCulture) + "ms; Meter Process Time: " + uiMeterProcessTime.ToString(CultureInfo.InvariantCulture) + "ms; Encryption Time: " + uiEncryptionTime.ToString(CultureInfo.InvariantCulture) + "ms"; break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_RECEIVED_INVALID_MESSAGE: { byte[] byRawAptitle = new byte[20]; byRawAptitle = ArgumentReader.ReadBytes(20); string strCallingAptitle = ESNConverter.Decode(byRawAptitle); UInt16 callingAppInvocationID = ArgumentReader.ReadUInt16(); byte C1222MessageValidationResult1 = ArgumentReader.ReadByte(); byte C1222MessageValidationResult2 = ArgumentReader.ReadByte(); strData = "Calling APTitle: " + strCallingAptitle.ToString(CultureInfo.InvariantCulture) + "; Result 1: " + C1222MessageValidationResult1.ToString(CultureInfo.InvariantCulture) + "; Result 2: " + C1222MessageValidationResult2.ToString(CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_C1222_RFLAN_CELL_CHANGE: { strData = "New Cell ID: " + ArgumentReader.ReadUInt16().ToString(CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_RECEIVED_MESSAGE_FROM: case (ushort)CENTRON_AMI.LANEvents.COMEVENT_SENT_MESSAGE_TO: { byte[] byRawAptitle = new byte[20]; byRawAptitle = ArgumentReader.ReadBytes(20); if (byRawAptitle[0] == 0x80) { // 0x80 is for the network message, it should be 0x0D. (per Steve Bardey) byRawAptitle[0] = 0x0D; } string strAptitle = ESNConverter.Decode(byRawAptitle); if (strAptitle == "1") { // "1" is the default - We should tell the user this is their own device (per Steve Bardey) strAptitle += " (Meter's Comm Module)"; } UInt16 CalledSeq = ArgumentReader.ReadUInt16(); byte C1222MessageType = ArgumentReader.ReadByte(); strData = "APTitle: " + strAptitle + "; Called Sequence: " + CalledSeq.ToString(CultureInfo.InvariantCulture) + "; " + GetC1222MessageType(C1222MessageType); break; } case (ushort)CENTRON_AMI.LANEvents.COMEVENT_PR_SEND_TABLE: case (ushort)CENTRON_AMI.LANEvents.COMEVENT_PR_SEND_TABLE_FAILED: { UInt16 table8ProcedureID = ArgumentReader.ReadUInt16(); byte table8Sequence = ArgumentReader.ReadByte(); byte table8Result = ArgumentReader.ReadByte(); byte table8TotalWriteCount = ArgumentReader.ReadByte(); UInt16 tableID = ArgumentReader.ReadUInt16(); UInt32 offset = ArgumentReader.ReadUInt32(); UInt16 length = ArgumentReader.ReadUInt16(); UInt16 result = ArgumentReader.ReadUInt16(); byte tableReadResult = ArgumentReader.ReadByte(); strData = "Table 8 Procedure ID: " + table8ProcedureID.ToString(CultureInfo.InvariantCulture) + "; Table 8 Sequence: " + table8Sequence.ToString(CultureInfo.InvariantCulture) + "; Table 8 Result: " + table8Result.ToString(CultureInfo.InvariantCulture) + "; Table 8 Write Count: " + table8TotalWriteCount.ToString(CultureInfo.InvariantCulture) + "; Table ID: " + tableID.ToString(CultureInfo.InvariantCulture) + "; Offset: " + offset.ToString(CultureInfo.InvariantCulture) + "; length: " + length.ToString(CultureInfo.InvariantCulture) + "; Table Send Result: " + GetC1222TableSendResult(result) + "; Table Read Result: " + tableReadResult.ToString(CultureInfo.InvariantCulture); break; } case (ushort)CENTRON_AMI.HANEvents.EVENT_ZIGBEE_DRLC_MSG: case (ushort)CENTRON_AMI.HANEvents.EVENT_ZIGBEE_KEY_EST_MSG: case (ushort)CENTRON_AMI.HANEvents.EVENT_ZIGBEE_MESSAGING_MSG: case (ushort)CENTRON_AMI.HANEvents.EVENT_ZIGBEE_MSG: case (ushort)CENTRON_AMI.HANEvents.EVENT_ZIGBEE_PREPAY_MSG: case (ushort)CENTRON_AMI.HANEvents.EVENT_ZIGBEE_PRICE_MSG: case (ushort)CENTRON_AMI.HANEvents.EVENT_ZIGBEE_SE_TUNNELING_MSG: case (ushort)CENTRON_AMI.HANEvents.EVENT_ZIGBEE_SIMPLE_METERING_MSG: { byte byMessageStatus = ArgumentReader.ReadByte(); byte byLQI = ArgumentReader.ReadByte(); byte byRSSI = ArgumentReader.ReadByte(); UInt16 SrcOrDest = ArgumentReader.ReadUInt16(); UInt16 ProfileID = ArgumentReader.ReadUInt16(); UInt16 ClusterID = ArgumentReader.ReadUInt16(); byte bySrcEndPoint = ArgumentReader.ReadByte(); byte byDestEndPoint = ArgumentReader.ReadByte(); UInt16 APSOptions = ArgumentReader.ReadUInt16(); UInt16 GroupID = ArgumentReader.ReadUInt16(); byte byAPSSeqNbr = ArgumentReader.ReadByte(); byte byMsgLen = ArgumentReader.ReadByte(); byte[] arrMsg = ArgumentReader.ReadBytes((int)byMsgLen); // There is a lot of information that can be retreived for this event. Right now we // are showing just a very small part. As we understand how these events are used // we can come in here and show more data if necessary. if ((byMessageStatus & RX_OR_TX_MASK) == 0) // (0 == Transmitted; 1 == Received) { strData = "Transmitted - "; } else { strData = "Received - "; } if ((byMessageStatus & SUCCESS_OR_FAIL_MASK) == 0) //(0 == Failure; 1 == Success) { strData += "Failed;"; } else { strData += "Succeeded;"; } break; } } return(strData); }
protected ProgramValidationItem ValidateItem(EDLValidationItem item, GatewayTables meterTables, GatewayTables programTables) { bool bItemsMatch = false; string strDisplayMeterValue = ""; string strDisplayProgramValue = ""; object objMeterValue; object objProgramValue; ProgramValidationItem InvalidItem = null; // Get the values objMeterValue = GetTableValue(item, meterTables); objProgramValue = GetTableValue(item, programTables); switch (item.Item) { case (long)StdTableEnum.STDTBL34_SEC_DISP_SOURCES: { if (objMeterValue != null) { if (String.Compare(objMeterValue.ToString(), "3", StringComparison.OrdinalIgnoreCase) == 0) { strDisplayMeterValue = "No Display Item"; } else { int iIndex = Convert.ToInt32(objMeterValue.ToString(), CultureInfo.InvariantCulture); strDisplayMeterValue = "Comm. Status Field " + (iIndex + 1).ToString(CultureInfo.InvariantCulture); } } if (objProgramValue != null) { if (String.Compare(objProgramValue.ToString(), "3", StringComparison.OrdinalIgnoreCase) == 0) { strDisplayProgramValue = "No Display Item"; } else { int iIndex = Convert.ToInt32(objProgramValue.ToString(), CultureInfo.InvariantCulture); strDisplayProgramValue = "Comm. Status Field " + (iIndex + 1).ToString(CultureInfo.InvariantCulture); } } if (strDisplayMeterValue.Equals(strDisplayProgramValue)) { bItemsMatch = true; } break; } case (long)StdTableEnum.STDTBL123_APTITLE_NOTIFY: { if (objMeterValue != null) { strDisplayMeterValue = ESNConverter.Decode((byte[])objMeterValue); } if (objProgramValue != null) { strDisplayProgramValue = ESNConverter.Decode((byte[])objProgramValue); } if (strDisplayMeterValue.Equals(strDisplayProgramValue)) { bItemsMatch = true; } break; } case (long)StdTableEnum.STDTBL53_TIME_ZONE_OFFSET: { TimeSpan tsOffset; short sOffset; if (objMeterValue != null) { sOffset = (short)objMeterValue; tsOffset = TimeSpan.FromMinutes((double)sOffset); strDisplayMeterValue = "GMT " + tsOffset.Hours + ":00"; } if (objProgramValue != null) { sOffset = (short)objProgramValue; tsOffset = TimeSpan.FromMinutes((double)sOffset); strDisplayProgramValue = "GMT " + tsOffset.Hours + ":00"; } // Compare the values if (strDisplayMeterValue == strDisplayProgramValue) { bItemsMatch = true; } break; } case (long)GatewayTblEnum.MFGTBL145_EXCEPTION_SECURITY_MODEL: { OpenWayMFGTable2193.SecurityFormat MeterValue = OpenWayMFGTable2193.SecurityFormat.None; OpenWayMFGTable2193.SecurityFormat ProgramValue = OpenWayMFGTable2193.SecurityFormat.None; if (objMeterValue != null) { MeterValue = (OpenWayMFGTable2193.SecurityFormat)(byte) objMeterValue; strDisplayMeterValue = OpenWayMFGTable2193.GetSecurityFormatString(MeterValue); } if (objProgramValue != null) { ProgramValue = (OpenWayMFGTable2193.SecurityFormat)(byte) objProgramValue; strDisplayProgramValue = OpenWayMFGTable2193.GetSecurityFormatString(ProgramValue); } bItemsMatch = ProgramValue == MeterValue; break; } case (long)GatewayTblEnum.MfgTbl145C1218OverZigBee: { bool bMeterValue = false; bool bProgramValue = false; strDisplayProgramValue = null; if (objMeterValue != null) { // We need to use the value of the bit bMeterValue = (bool)objMeterValue; } strDisplayMeterValue = bMeterValue.ToString(CultureInfo.CurrentCulture); if (objProgramValue != null) { bProgramValue = (bool)objProgramValue; strDisplayProgramValue = bProgramValue.ToString(CultureInfo.CurrentCulture); } bItemsMatch = strDisplayMeterValue.Equals(strDisplayProgramValue); break; } case (long)GatewayTblEnum.MFGTBL145_REQUIRE_ENHANCED_SECURITY: { strDisplayProgramValue = null; if (objMeterValue != null) { strDisplayMeterValue = ((bool)objMeterValue).ToString(CultureInfo.CurrentCulture); } if (objProgramValue != null) { strDisplayProgramValue = ((bool)objProgramValue).ToString(CultureInfo.CurrentCulture); } bItemsMatch = strDisplayMeterValue.Equals(strDisplayProgramValue); break; } case (long)GatewayTblEnum.MfgTbl58SecurityMode: { byte bySecurityMode; byte byDeviceAuthMode; byte byCBKEMode; // Get the Meter value if (objMeterValue != null && meterTables.IsCached((long)GatewayTblEnum.MfgTbl58DeviceAuthMode, null) && meterTables.IsCached((long)GatewayTblEnum.MfgTbl58CbkeMode, null)) { // We have already retrieved the Security Mode bySecurityMode = (byte)objMeterValue; // Get the other two modes meterTables.GetValue(GatewayTblEnum.MfgTbl58DeviceAuthMode, null, out objMeterValue); byDeviceAuthMode = (byte)objMeterValue; meterTables.GetValue(GatewayTblEnum.MfgTbl58CbkeMode, null, out objMeterValue); byCBKEMode = (byte)objMeterValue; // Get the HAN Profile Name strDisplayMeterValue = CHANMfgTable2106.GetHANSecurityProfile(bySecurityMode, byDeviceAuthMode, byCBKEMode); } // Get the Program value if (objProgramValue != null && programTables.IsCached((long)GatewayTblEnum.MfgTbl58DeviceAuthMode, null) && programTables.IsCached((long)GatewayTblEnum.MfgTbl58CbkeMode, null)) { // We have already retrieved the Security Mode bySecurityMode = (byte)objProgramValue; // Get the other two modes programTables.GetValue(GatewayTblEnum.MfgTbl58DeviceAuthMode, null, out objProgramValue); byDeviceAuthMode = (byte)objProgramValue; programTables.GetValue(GatewayTblEnum.MfgTbl58CbkeMode, null, out objProgramValue); byCBKEMode = (byte)objProgramValue; // Get the HAN Profile Name strDisplayProgramValue = CHANMfgTable2106.GetHANSecurityProfile(bySecurityMode, byDeviceAuthMode, byCBKEMode); } bItemsMatch = strDisplayMeterValue.Equals(strDisplayProgramValue); break; } case (long)GatewayTblEnum.MfgTbl58InterPanMode: { bool blnSkipComparison = false; // Get the Meter value if (objMeterValue != null) { // Get the Inter PAN Mode description strDisplayMeterValue = CHANMfgTable2106.GetInterPANMode((byte)objMeterValue); } // Get the Program value if (objProgramValue != null) { // Get the Inter PAN Mode description strDisplayProgramValue = CHANMfgTable2106.GetInterPANMode((byte)objProgramValue); } else if (programTables.IsCached((long)GatewayTblEnum.MFGTBL2045_CE_VERSION_NUMBER, null)) { object objValue = null; programTables.GetValue(GatewayTblEnum.MFGTBL2045_CE_VERSION_NUMBER, null, out objValue); string strValue = objValue as string; string[] astrCEVersion = strValue.Split(new char[] { ' ', '.', '-' }); float fltCEVersion = Convert.ToSingle(astrCEVersion[0] + "." + astrCEVersion[1]); if (0 <= VersionChecker.CompareTo(fltCEVersion, CE_VERSION_LITHIUM_3_9)) { //Only skipping comparison if program value is null and program's CE version is Lithium or greater blnSkipComparison = true; } } if (true == blnSkipComparison) { bItemsMatch = true; } else { bItemsMatch = strDisplayMeterValue.Equals(strDisplayProgramValue); } break; } default: { // The GatewayTables object may return null so make sure we don't // cause an exception first. if (objMeterValue != null) { // Trim spaces and null characters so that they will display and validate correctly strDisplayMeterValue = objMeterValue.ToString().Trim(new char[] { ' ', '\0' }); } if (objProgramValue != null) { // Trim spaces and null characters so that they will display and validate correctly strDisplayProgramValue = objProgramValue.ToString().Trim(new char[] { ' ', '\0' }); } // Compare the values if (strDisplayMeterValue == strDisplayProgramValue) { bItemsMatch = true; } break; } } if (bItemsMatch == false) { // There is a mismatch so add the item. InvalidItem = new ProgramValidationItem(item.Category, item.Name, strDisplayProgramValue, strDisplayMeterValue); } return(InvalidItem); }