protected ConfigurationResult ConfigureExtendedSelfRead(AMIConfigureDevice ConfigureDevice) { ConfigurationResult Result = ConfigurationResult.SUCCESS; ConfigurationError ConfigError = ConfigurationError.GENERAL_ERROR; if (Table00.IsTableUsed(2265) && (Table00.DeviceClass.ToUpper().Equals(ITRD_DEVICE_CLASS) || Table00.DeviceClass.ToUpper().Equals(ITRE_DEVICE_CLASS) || Table00.DeviceClass.ToUpper().Equals(ITRF_DEVICE_CLASS) || Table00.DeviceClass.ToUpper().Equals(ITRJ_DEVICE_CLASS) || Table00.DeviceClass.ToUpper().Equals(ITRK_DEVICE_CLASS))) { ConfigError = ConfigureDevice.WriteTableByElementRange( CentronTblEnum.MfgTbl217SelfReadTwoLogicalIdentifier, new int[1] { 0 }, CentronTblEnum.MfgTbl217SelfReadTwoLogicalIdentifierQualifier, new int[1] { ConfigureDevice.GetFieldArrayLastIndex(CentronTblEnum.MfgTbl217SelfReadTwoLogicalIdentifierQualifier) }); } else { ConfigError = ConfigurationError.OPERATION_NOT_POSSIBLE; } // Translate to the ItronDevice ConfigurationResult error code since // the factory is using ConfigurationError and we do not want to always // rely on having the version in AMIConfiguration.dll Result = TranslateConfigError(ConfigError); return(Result); }
/// <summary> /// Configures the meter instrumentation profile config block /// with the specified program /// </summary> /// <param name="ConfigureDevice">AMIConfigureDevice object with the correct table set already loaded</param> /// <returns></returns> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 03/06/12 JKW Created - Lithium /// protected ConfigurationResult ConfigureInstrumentationProfile(AMIConfigureDevice ConfigureDevice) { ConfigurationResult Result = ConfigurationResult.SUCCESS; ConfigurationError ConfigError = ConfigurationError.GENERAL_ERROR; if (Table00.IsTableUsed(2265)) { ConfigError = ConfigureDevice.WriteTableByElementRange( CentronTblEnum.MfgTbl217InstrumentationProfileIntervalLength, null, CentronTblEnum.MfgTbl217InstrumentationProfilePulseWeightSetTwo, new int[1] { ConfigureDevice.GetFieldArrayLastIndex(CentronTblEnum.MfgTbl217InstrumentationProfilePulseWeightSetTwo) }); } else { ConfigError = ConfigurationError.OPERATION_NOT_POSSIBLE; } // Translate to the ItronDevice ConfigurationResult error code since // the factory is using ConfigurationError and we do not want to always // rely on having the version in AMIConfiguration.dll Result = TranslateConfigError(ConfigError); return(Result); }
protected ConfigurationResult ConfigureNonBillingEnergyandLoadProfile(AMIConfigureDevice ConfigureDevice) { ConfigurationResult Result = ConfigurationResult.SUCCESS; ConfigurationError ConfigError = ConfigurationError.GENERAL_ERROR; if (Table00.IsTableUsed(2265) && (Table00.DeviceClass.ToUpper().Equals(ITRE_DEVICE_CLASS) || Table00.DeviceClass.ToUpper().Equals(ITRF_DEVICE_CLASS)) || (Table00.DeviceClass.ToUpper().Equals(ITRK_DEVICE_CLASS))) { ConfigError = ConfigureDevice.WriteTableByElementRange( CentronTblEnum.MfgTbl217NonBillableEnergyId, new int[1] { 0 }, CentronTblEnum.MfgTbl217NonBillableEnergyId, new int[1] { ConfigureDevice.GetFieldArrayLastIndex(CentronTblEnum.MfgTbl217NonBillableEnergyId) }); if (ConfigError == ConfigurationError.SUCCESS) { ConfigError = ConfigureDevice.WriteTableByElementRange( CentronTblEnum.MfgTbl217NonBillingLoadProfileIntervalLength, null, CentronTblEnum.MfgTbl217NonBillingLoadProfilePulseWeightSetTwo, new int[1] { ConfigureDevice.GetFieldArrayLastIndex(CentronTblEnum.MfgTbl217NonBillingLoadProfilePulseWeightSetTwo) }); } } else { ConfigError = ConfigurationError.OPERATION_NOT_POSSIBLE; } // Translate to the ItronDevice ConfigurationResult error code since // the factory is using ConfigurationError and we do not want to always // rely on having the version in AMIConfiguration.dll Result = TranslateConfigError(ConfigError); return(Result); }
/// <summary> /// Configures the meter VM tables with the specified program. Reads /// table 0 to see which VM tables are supported /// (101, 102, 105, 106 = Lithium, 101, 102 = pre-Lithium) /// </summary> /// <param name="ConfigureDevice">AMIConfigureDevice object with the correct table set already loaded</param> /// <returns></returns> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 03/06/12 JKW Created - Lithium /// protected ConfigurationResult ConfigureVoltageMonitoring(AMIConfigureDevice ConfigureDevice) { ConfigurationResult Result = ConfigurationResult.SUCCESS; ConfigurationError ConfigError = ConfigurationError.GENERAL_ERROR; ConfigureDevice.IsCanadian = IsCanadian; // pre-Lithium only uses 2149 + 2150 if (Table00.IsTableUsed(2149) && Table00.IsTableUsed(2150)) { ConfigError = ConfigureDevice.WriteTable(2149); if (ConfigError == ConfigurationError.SUCCESS) { ConfigError = ConfigureDevice.WriteTable(2150); } } // Lithium uses 2153 + 2154 if (Table00.IsTableUsed(2153) && Table00.IsTableUsed(2154)) { ConfigError = ConfigureDevice.WriteTable(2153); if (ConfigError == ConfigurationError.SUCCESS) { ConfigError = ConfigureDevice.WriteTable(2154); } } // Translate to the ItronDevice ConfigurationResult error code since // the factory is using ConfigurationError and we do not want to always // rely on having the version in AMIConfiguration.dll Result = TranslateConfigError(ConfigError); return(Result); }
/// <summary> /// Creates an EDL file with the specified sections. /// </summary> /// <param name="FileName">Path to the file where the EDL file will be written.</param> /// <param name="IncludedSections">The sections to include in the EDL file.</param> /// <returns>CreateEDLResult Code.</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 07/06/10 AF 2.42.02 Created // public override CreateEDLResult CreateEDLFromMeter(string FileName, EDLSections IncludedSections) { GatewayTables MeterTables = new GatewayTables(); List <ushort> TablesToRead; int iFileNameStart; string strDirectory; CreateEDLResult Result = CreateEDLResult.SUCCESS; PSEMResponse PSEMResult = PSEMResponse.Ok; // First check to make sure we can create the file iFileNameStart = FileName.LastIndexOf(@"\", StringComparison.Ordinal); if (iFileNameStart > 0) { strDirectory = FileName.Substring(0, iFileNameStart); if (Directory.Exists(strDirectory) == false) { Result = CreateEDLResult.INVALID_PATH; } } // Make sure we will be able to write to the file if (Result == CreateEDLResult.SUCCESS && File.Exists(FileName) == true) { FileInfo OutputFile = new FileInfo(FileName); if ((OutputFile.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { Result = CreateEDLResult.INVALID_PATH; } } if (Result == CreateEDLResult.SUCCESS) { // Read the data from the meter TablesToRead = GetTablesToRead(IncludedSections); OnShowProgress(new ShowProgressEventArgs(1, TablesToRead.Count, "Creating EDL file...", "Creating EDL file...")); foreach (ushort TableID in TablesToRead) { if (PSEMResult == PSEMResponse.Ok) { // Read the table if it exists if ((Table00.IsTableUsed(TableID) == true)) { if (MeterTables.GetTableDependencies(TableID).Contains(TableID) || MeterTables.GetTableLength(TableID) > 0) { PSEMResult = ReadTable(TableID, ref MeterTables); if (PSEMResult == PSEMResponse.Bsy || PSEMResult == PSEMResponse.Dnr || PSEMResult == PSEMResponse.Iar || PSEMResult == PSEMResponse.Onp || PSEMResult == PSEMResponse.Err) { // We can't read the table but we should be able to continue we just need to // clear out anything that is there. MeterTables.ClearTable(TableID); PSEMResult = PSEMResponse.Ok; } } } OnStepProgress(new ProgressEventArgs()); } } if (PSEMResult == PSEMResponse.Isc) { Result = CreateEDLResult.SECURITY_ERROR; } else if (PSEMResult != PSEMResponse.Ok) { Result = CreateEDLResult.PROTOCOL_ERROR; } } #if (WindowsCE) //The saving of the EDL file on the handheld can take over 6 seconds so we need //to send a wait before. m_PSEM.Wait(CPSEM.MAX_WAIT_TIME); #endif // Generate the EDL file if (Result == CreateEDLResult.SUCCESS) { XmlWriterSettings WriterSettings = new XmlWriterSettings(); WriterSettings.Encoding = Encoding.ASCII; WriterSettings.Indent = true; WriterSettings.CheckCharacters = false; XmlWriter EDLWriter = XmlWriter.Create(FileName, WriterSettings); MeterTables.SaveEDLFile(EDLWriter, null, AllowTableExport, AllowFieldExport); } OnHideProgress(new EventArgs()); return(Result); }
/// <summary> /// Returns a list of items that are not consistent between the configuration /// of the program and the device. /// </summary> /// <param name="strProgramName">The name of the program to validate against.</param> /// <returns> /// A list of items that failed the validation. Returns an empty list if /// all items match. /// </returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 07/08/10 AF 2.42.03 Created // public override List <ProgramValidationItem> ValidateProgram(string strProgramName) { PSEMResponse Response = PSEMResponse.Ok; List <ProgramValidationItem> InvalidItemsList = new List <ProgramValidationItem>(); List <EDLValidationItem> ItemsToValidate = GetValidationList(); List <ushort> ValidationTablesToRead = GetValidationTablesToRead(); FileStream EDLFileStream = new FileStream(strProgramName, FileMode.Open, FileAccess.Read, FileShare.Read); XmlTextReader EDLReader = new XmlTextReader(EDLFileStream); GatewayTables ProgramTables = new GatewayTables(); GatewayTables MeterTables = new GatewayTables(); OnShowProgress(new ShowProgressEventArgs(1, ValidationTablesToRead.Count)); // Read the data from the meter. // NOTE: ReadTable is defined in M2_Gateway_ICreateEDL so this will not compile if // that file is not included. We may want to move this method eventually, but // we are keeping Interfaces separate in case we wish to support OpenWay in HH-Pro foreach (ushort TableID in ValidationTablesToRead) { OnStepProgress(new ProgressEventArgs()); if (Response == PSEMResponse.Ok) { if (MeterTables.IsTableKnown(TableID) && Table00.IsTableUsed(TableID) && (TableID == 0 || MeterTables.GetTableLength(TableID) > 0)) { Response = ReadTable(TableID, ref MeterTables); } } } if (Response != PSEMResponse.Ok) { throw new PSEMException(PSEMException.PSEMCommands.PSEM_READ, Response, "Error reading device for validation."); } else { // Load the EDL file. ProgramTables.LoadEDLFile(EDLReader); // Compare the values foreach (EDLValidationItem Item in ItemsToValidate) { ProgramValidationItem InvalidItem; // Only compare items where the meter's FW version is greater than or equal to // the minimum required for that item and the FW version is less than // the version in which it became obsolete. Max set to high for active items. if ((VersionChecker.CompareTo(FWRevision, Item.MinFWVersion) >= 0) && (VersionChecker.CompareTo(FWRevision, Item.MaxFWVersion) < 0)) { // We need to handle the display items differently than the rest of the items since // there can be a different number of Normal and Test items. if (RequiresSpecialHandling(Item.Item) == false) { InvalidItem = ValidateItem(Item, MeterTables, ProgramTables); // Only add the item if it does not match. if (null != InvalidItem) { InvalidItemsList.Add(InvalidItem); } } else { InvalidItemsList.AddRange(HandleSpecialCases(Item.Item, MeterTables, ProgramTables)); } } } } return(InvalidItemsList); }
/// <summary> /// Adds event/exception validation items to the validation list. /// </summary> /// <param name="ValidationList">The list to add validaiton items to.</param> // Revision History // MM/DD/YY who Version ID Number Description // -------- --- ------- -- ------ --------------------------------------- // 12/09/13 jrf 3.50.16 TQ 9560 Created. // protected override void GetEventExceptionValidationItems(List <EDLValidationItem> ValidationList) { CENTRON_AMI_EventDictionary EventDictionary = new CENTRON_AMI_EventDictionary(); CENTRON_AMI_CommEventDictionary CommEventDictionary = new CENTRON_AMI_CommEventDictionary(); for (int iIndex = 0; iIndex < 280; iIndex++) { // Get the description from the EventDictionary string strDescription; bool bValidString; bValidString = EventDictionary.TryGetValue(iIndex, out strDescription); if (bValidString == false) { // It could be a MFG event since an event number is either STD or MFG but not both bValidString = EventDictionary.TryGetValue(2048 + iIndex, out strDescription); } if (bValidString == false) { // We don't have a description for the item. strDescription = "Unknown Event " + iIndex.ToString(CultureInfo.InvariantCulture); } ValidationList.Add(new EDLValidationItem((long)GatewayTblEnum.MFGTBL0_HISTORY_LOG_MONITORED_FLAGS, new int[] { iIndex }, strDescription, "Events")); } // Exceptions ValidationList.Add(new EDLValidationItem((long)StdTableEnum.STDTBL123_EXCEPTION_REPORT, null, "Exceptions", "Exceptions")); // Comm Log - Standard LAN Events // TODO: Implement Standard LAN Events when they exist // Comm Log - Mfg LAN Events for (int iIndex = (int)LANEvents.BEGIN_MFG_LAN_EVENTS; iIndex < (int)LANEvents.END_MFG_LAN_EVENTS; iIndex++) { // Get the description from the EventDictionary string strDescription; bool bValidString; bValidString = CommEventDictionary.TryGetValue(iIndex, out strDescription); if (bValidString == false) { // We don't have a description for the item. strDescription = "Unknown Event " + iIndex.ToString(CultureInfo.InvariantCulture); } // Items in the MFG_EVENTS_MONITORED_FLAGS field do not include the MFG Bit. (Must subtract off 2048) ValidationList.Add(new EDLValidationItem((long)GatewayTblEnum.MFGTBL113_MFG_EVENTS_MONITORED_FLAGS, new int[] { iIndex - 2048 }, strDescription, "Mfg LAN Events")); } // Comm Log - Standard HAN Events // TODO: Implement Standard HAN Events when they exist //If table is not supported in the meter then it doesn't make sense to validate these items. if (true == Table00.IsTableUsed(115)) { // Comm Log - Mfg HAN Events for (int iIndex = (int)HANEvents.BEGIN_MFG_HAN_EVENTS; iIndex < (int)HANEvents.END_MFG_HAN_EVENTS; iIndex++) { // Get the description from the EventDictionary string strDescription; bool bValidString; bValidString = CommEventDictionary.TryGetValue(iIndex, out strDescription); if (bValidString == false) { // We don't have a description for the item. strDescription = "Unknown Event " + iIndex.ToString(CultureInfo.InvariantCulture); } // Items in the MFG_EVENTS_MONITORED_FLAGS field do not include the MFG Bit. (Must subtract off 2048) ValidationList.Add(new EDLValidationItem((long)GatewayTblEnum.MFGTBL115_MFG_EVENTS_MONITORED_FLAGS, new int[] { iIndex - 2048 }, strDescription, "Mfg HAN Events")); } } // HAN 2 events CENTRON_AMI_DownstreamHANEventDictionary DownstreamEvtDictionary = new CENTRON_AMI_DownstreamHANEventDictionary(); for (int iIndex = 2305; iIndex < 2431; iIndex++) { string strDescription; bool bValidString; bValidString = DownstreamEvtDictionary.TryGetValue((ushort)iIndex, out strDescription); // We won't worry about unknown events for now if (bValidString) { ValidationList.Add(new EDLValidationItem((long)GatewayTblEnum.MfgTbl212Han2LoggerControl, new int[] { iIndex - 2048 - 256 }, strDescription, "HAN Events", VERSION_M2GTWY_2_0)); } } CENTRON_AMI_UpstreamHANEventDictionary UpstreamEvtDictionary = new CENTRON_AMI_UpstreamHANEventDictionary(); for (int iIndex = 2432; iIndex < 2559; iIndex++) { string strDescription; bool bValidString; bValidString = UpstreamEvtDictionary.TryGetValue((ushort)iIndex, out strDescription); // We won't worry about unknown events for now if (bValidString) { ValidationList.Add(new EDLValidationItem((long)GatewayTblEnum.MfgTbl212Han2LoggerControl, new int[] { iIndex - 2048 - 256 }, strDescription, "HAN Events", VERSION_M2GTWY_2_0)); } } }