protected static ulong GetNTPTimestampFromTicks(Ticks timestamp) { timestamp -= GetBaseDateOffsetTicks(timestamp); uint seconds = (uint)Math.Truncate(timestamp.ToSeconds()); uint fraction = (uint)(timestamp.DistanceBeyondSecond().ToSeconds() * uint.MaxValue); return(Word.MakeQword(seconds, fraction)); }
/// <summary> /// Creates a new BPA PDCstream specific <see cref="DataFrame"/> for the given <paramref name="timestamp"/>. /// </summary> /// <param name="timestamp">Timestamp for new <see cref="IFrame"/> in <see cref="Ticks"/>.</param> /// <param name="configurationFrame">Associated <see cref="ConfigurationFrame"/> for the new <see cref="DataFrame"/>.</param> /// <returns>New IEEE C37.118 <see cref="DataFrame"/> at given <paramref name="timestamp"/>.</returns> public static DataFrame CreateDataFrame(Ticks timestamp, ConfigurationFrame configurationFrame) { // We create a new BPA PDCstream data frame based on current configuration frame ushort sampleNumber = (ushort)((timestamp.DistanceBeyondSecond() + 1.0D) / (double)configurationFrame.TicksPerFrame); DataFrame dataFrame = new DataFrame(timestamp, configurationFrame, 1, sampleNumber); foreach (ConfigurationCell configurationCell in configurationFrame.Cells) { // Create a new BPA PDCstream data cell (i.e., a PMU entry for this frame) DataCell dataCell = new DataCell(dataFrame, configurationCell, true); // Add data cell to the frame dataFrame.Cells.Add(dataCell); } return(dataFrame); }
/// <summary> /// Creates a new BPA PDCstream specific <see cref="DataFrame"/> for the given <paramref name="timestamp"/>. /// </summary> /// <param name="timestamp">Timestamp for new <see cref="IFrame"/> in <see cref="Ticks"/>.</param> /// <returns>New BPA PDCstream <see cref="DataFrame"/> at given <paramref name="timestamp"/>.</returns> /// <remarks> /// Note that the <see cref="ConcentratorBase"/> class (which the <see cref="ActionAdapterBase"/> is derived from) /// is designed to sort <see cref="IMeasurement"/> implementations into an <see cref="IFrame"/> which represents /// a collection of measurements at a given timestamp. The <c>CreateNewFrame</c> method allows consumers to create /// their own <see cref="IFrame"/> implementations, in our case this will be a BPA PDCstream data frame. /// </remarks> protected override IFrame CreateNewFrame(Ticks timestamp) { // We create a new BPA PDCstream data frame based on current configuration frame ushort sampleNumber = (ushort)((timestamp.DistanceBeyondSecond() + 1.0D) / base.TicksPerFrame); DataFrame dataFrame = new DataFrame(timestamp, m_configurationFrame, 1, sampleNumber); DataCell dataCell; foreach (ConfigurationCell configurationCell in m_configurationFrame.Cells) { // Create a new BPA PDCstream data cell (i.e., a PMU entry for this frame) dataCell = new DataCell(dataFrame, configurationCell, true); // Add data cell to the frame dataFrame.Cells.Add(dataCell); } return(dataFrame); }
/// <summary> /// Creates a new BPA PDCstream specific <see cref="DataFrame"/> for the given <paramref name="timestamp"/>. /// </summary> /// <param name="timestamp">Timestamp for new <see cref="IFrame"/> in <see cref="Ticks"/>.</param> /// <returns>New BPA PDCstream <see cref="DataFrame"/> at given <paramref name="timestamp"/>.</returns> /// <remarks> /// Note that the <see cref="ConcentratorBase"/> class (which the <see cref="ActionAdapterBase"/> is derived from) /// is designed to sort <see cref="IMeasurement"/> implementations into an <see cref="IFrame"/> which represents /// a collection of measurements at a given timestamp. The <c>CreateNewFrame</c> method allows consumers to create /// their own <see cref="IFrame"/> implementations, in our case this will be a BPA PDCstream data frame. /// </remarks> protected override IFrame CreateNewFrame(Ticks timestamp) { // We create a new BPA PDCstream data frame based on current configuration frame ushort sampleNumber = (ushort)((timestamp.DistanceBeyondSecond() + 1.0D) / base.TicksPerFrame); DataFrame dataFrame = new DataFrame(timestamp, m_configurationFrame, 1, sampleNumber); DataCell dataCell; foreach (ConfigurationCell configurationCell in m_configurationFrame.Cells) { // Create a new BPA PDCstream data cell (i.e., a PMU entry for this frame) dataCell = new DataCell(dataFrame, configurationCell, true); // Add data cell to the frame dataFrame.Cells.Add(dataCell); } return dataFrame; }
protected static ulong GetNTPTimestampFromTicks(Ticks timestamp) { timestamp -= GetBaseDateOffsetTicks(timestamp); uint seconds = (uint)Math.Truncate(timestamp.ToSeconds()); uint fraction = (uint)(timestamp.DistanceBeyondSecond().ToSeconds() * uint.MaxValue); return Word.MakeQword(seconds, fraction); }