/// <summary> /// Writes the table to the meter as a pending table using an offset write /// </summary> /// <param name="pendingRecord">The pending event record to use for the table write</param> /// <param name="offset">The offset of the table to write</param> /// <param name="count">The number of bytes to write</param> /// <returns>The result of the write</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 11/21/11 RCG 2.53.12 Created public virtual PSEMResponse PendingTableWrite(PendingEventRecord pendingRecord, ushort offset, ushort count) { PSEMResponse Result = PSEMResponse.Iar; ushort PendingTableNumber = (ushort)(m_TableID | PENDING_BIT); if (m_PSEM != null) { if (count + offset <= m_Data.Length) { byte[] Data = new byte[count + pendingRecord.EntireRecord.Length]; Array.Copy(pendingRecord.EntireRecord, Data, pendingRecord.EntireRecord.Length); Array.Copy(m_Data, offset, Data, pendingRecord.EntireRecord.Length, count); m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Pending Table Offset Write to " + PendingTableNumber.ToString(CultureInfo.InvariantCulture) + " Offset: " + offset.ToString(CultureInfo.InvariantCulture) + " Count: " + count.ToString(CultureInfo.InvariantCulture)); Result = m_PSEM.OffsetWrite(PendingTableNumber, offset, Data); } } else { throw (new NotImplementedException("This Operation is not supported with a file")); } return(Result); }
/// <summary> /// Builds the pending table header /// </summary> /// <param name="strmPSEM">Stream to which the data is written</param> /// <param name="bSelfRead">tells whether or not to perform a self read /// before table is activated</param> /// <param name="bDemandReset">tells whether or not to perform a demand /// reset before table is activated</param> /// <param name="byMfgEventCode">Mfg assigned code identifying event for /// activating pending table</param> /// <param name="eCode">Event code for status bitfield. 2 => non-time activated</param> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 08/16/06 AF 7.35.00 N/A Created // 10/04/06 AF 7.40.00 N/A Moved from CENTRON_AMI.cs // 06/08/07 RCG 8.10.07 Changed to call BuildEventRecord protected void BuildPendingHeader(ref MemoryStream strmPSEM, bool bSelfRead, bool bDemandReset, byte byMfgEventCode, PendingEventRecord.PendingEventCode eCode) { PendingEventRecord EventRecord = new PendingEventRecord(); // Build the event record EventRecord = BuildPendingEventRecord(bSelfRead, bDemandReset, byMfgEventCode, eCode); // Write the event record to the stream strmPSEM.Write(EventRecord.EntireRecord, (int)strmPSEM.Position, EventRecord.EntireRecord.Length); }
/// <summary> /// Writes the table to the meter as a pending table /// </summary> /// <param name="pendingRecord">The pending event record to use for the table write</param> /// <returns>The result of the write.</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 11/21/11 RCG 2.53.12 Created public virtual PSEMResponse PendingTableWrite(PendingEventRecord pendingRecord) { PSEMResponse Result = PSEMResponse.Iar; ushort PendingTableNumber = (ushort)(m_TableID | PENDING_BIT); byte[] Data = new byte[m_Data.Length + pendingRecord.EntireRecord.Length]; if (m_PSEM != null) { // There is a maximum length that a pending table may be so if the table is longer we need to do multiple offset writes if (m_Data.Length <= MAX_PENDING_SIZE) { Array.Copy(pendingRecord.EntireRecord, Data, pendingRecord.EntireRecord.Length); Array.Copy(m_Data, 0, Data, pendingRecord.EntireRecord.Length, m_Data.Length); m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Pending Table Full Write to " + PendingTableNumber.ToString(CultureInfo.InvariantCulture)); Result = m_PSEM.FullWrite(PendingTableNumber, Data); } else { ushort CurrentOffset = 0; // Write the bulk of the data for (int Count = 0; Count < (m_Data.Length / MAX_PENDING_SIZE); Count++) { Result = PendingTableWrite(pendingRecord, CurrentOffset, (ushort)MAX_PENDING_SIZE); if (Result != PSEMResponse.Ok) { break; } CurrentOffset += MAX_PENDING_SIZE; } // Write the remaining data if (CurrentOffset < m_Data.Length && Result == PSEMResponse.Ok) { Result = PendingTableWrite(pendingRecord, CurrentOffset, (ushort)(m_Data.Length - CurrentOffset)); } } if (PSEMResponse.Ok == Result) { m_TableState = TableState.Loaded; } } else { throw (new NotImplementedException("This Operation is not supported with a file")); } return(Result); }
/// <summary> /// Activates the pending table with the specified Event Record /// </summary> /// <param name="pendingEvent">The Event Record for the event to activate</param> /// <returns>ProcedureResultCodes</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 05/07/07 RCG 8.10.07 Created public ProcedureResultCodes ActivatePendingTable(PendingEventRecord pendingEvent) { ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM; byte[] ProcResponse; ProcResult = ExecuteProcedure(Procedures.ACTIVATE_PENDING_TABLE, pendingEvent.EntireRecord, out ProcResponse); return(ProcResult); }
/// <summary> /// Clears the pending table with the specified Event Record /// </summary> /// <param name="pendingEvent">The Event Record for the event to clear</param> /// <returns>ProcedureResultCodes</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 05/07/07 RCG 8.10.07 Created public ProcedureResultCodes ClearPendingTable(PendingEventRecord pendingEvent) { ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM; byte[] ProcResponse; ProcResult = ExecuteProcedure(Procedures.CLEAR_SPECIFIC_PENDING_TABLE, pendingEvent.EntireRecord, out ProcResponse); return(ProcResult); }
/// <summary> /// Builds a PendingEventRecord object for a Non Time Activated pending event /// with the specified parameters. /// </summary> /// <param name="bSelfRead">Whether or not a Self Read should be performed on activation.</param> /// <param name="bDemandReset">Whether or not a Demand Reset should be performed on activation.</param> /// <param name="byMfgEventCode">The manufacturer event code for the pending event.</param> /// <param name="eCode">The event code for the pending event.</param> /// <returns>The EventRecord object.</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 06/07/07 RCG 8.10.07 Created // 02/05/09 AF -.--.00 Changed the access modifier from protected to public // for automated firmware testing project public PendingEventRecord BuildPendingEventRecord(bool bSelfRead, bool bDemandReset, byte byMfgEventCode, PendingEventRecord.PendingEventCode eCode) { PendingEventRecord EventRecord = new PendingEventRecord(); ASCIIEncoding AE = new ASCIIEncoding(); byte[] abyManufacturer = new byte[5]; // Set up the event selector bitfield EventRecord.EventCode = eCode; EventRecord.PerformSelfRead = bSelfRead; EventRecord.PerformDemandReset = bDemandReset; // Copy the manufacturer ID to the device storage AE.GetBytes(MANUFACTURER).CopyTo(abyManufacturer, 0); // Copy the manufaturer event code abyManufacturer[abyManufacturer.Length - 1] = byMfgEventCode; EventRecord.EventStorage = abyManufacturer; return(EventRecord); }