/// <summary> /// Creates a new <see cref="ConfigurationCellBase"/> from serialization parameters. /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param> /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param> protected ConfigurationCellBase(SerializationInfo info, StreamingContext context) : base(info, context) { // Deserialize configuration cell values StationName = info.GetString("stationName"); IDLabel = info.GetString("idLabel"); m_phasorDefinitions = (PhasorDefinitionCollection)info.GetValue("phasorDefinitions", typeof(PhasorDefinitionCollection)); m_frequencyDefinition = (IFrequencyDefinition)info.GetValue("frequencyDefinition", typeof(IFrequencyDefinition)); m_analogDefinitions = (AnalogDefinitionCollection)info.GetValue("analogDefinitions", typeof(AnalogDefinitionCollection)); m_digitalDefinitions = (DigitalDefinitionCollection)info.GetValue("digitalDefinitions", typeof(DigitalDefinitionCollection)); m_nominalFrequency = (LineFrequency)info.GetValue("nominalFrequency", typeof(LineFrequency)); m_revisionCount = info.GetUInt16("revisionCount"); }
/// <summary> /// Creates a new <see cref="FrequencyValue"/>. /// </summary> /// <param name="parent">The <see cref="IDataCell"/> parent of this <see cref="FrequencyValue"/>.</param> /// <param name="frequencyDefinition">The <see cref="IFrequencyDefinition"/> associated with this <see cref="FrequencyValue"/>.</param> public FrequencyValue(IDataCell parent, IFrequencyDefinition frequencyDefinition) : base(parent, frequencyDefinition) { }
// Static Methods // Delegate handler to create a new IEEE 1344 frequency value internal static IFrequencyValue CreateNewValue(IDataCell parent, IFrequencyDefinition definition, byte[] buffer, int startIndex, out int parsedLength) { IFrequencyValue frequency = new FrequencyValue(parent, definition); parsedLength = frequency.ParseBinaryImage(buffer, startIndex, 0); return frequency; }
// Static Methods // Creates frequency information for an INI based BPA PDCstream configuration file internal static string ConfigFileFormat(IFrequencyDefinition definition) { FrequencyDefinition frequency = definition as FrequencyDefinition; // type, scale, offset, dF/dt scale, dF/dt offset, dummy, label // F, 1000, 60, 1000, 0, 0, Frequency if (frequency != null) return "F," + frequency.ScalingValue + "," + frequency.Offset + "," + frequency.DfDtScalingValue + "," + frequency.DfDtOffset + "," + frequency.m_dummy + "," + frequency.Label; else if (definition != null) return "F," + definition.ScalingValue + "," + definition.Offset + "," + definition.DfDtScalingValue + "," + definition.DfDtOffset + ",0," + definition.Label; return ""; }
/// <summary> /// Parses the binary footer image. /// </summary> /// <param name="binaryImage">Binary image to parse.</param> /// <param name="startIndex">Start index into <paramref name="binaryImage"/> to begin parsing.</param> /// <param name="length">Length of valid data within <paramref name="binaryImage"/>.</param> /// <returns>The length of the data that was parsed.</returns> protected override int ParseFooterImage(byte[] binaryImage, int startIndex, int length) { // Parse nominal frequency defintion from footer... int parsedLength; m_frequencyDefinition = State.CreateNewFrequencyDefinition(this, binaryImage, startIndex, out parsedLength); return parsedLength; }
// Static Methods // Calculates binary length of a frequency value based on its definition internal static int CalculateBinaryLength(IFrequencyDefinition definition) { // The frequency definition will determine the binary length based on data format return (new FrequencyValue(null, definition)).BinaryLength; }
public ConfigurationFrame LoadConfigurationFrame(string sourceData) { IConfigurationFrame sourceFrame = GetConfigurationFrame(sourceData, out string connectionString); if (sourceFrame is ConfigurationErrorFrame) { return(new ConfigurationFrame()); } // Create a new simple concrete configuration frame for JSON serialization converted from equivalent configuration information int protocolID = 0, deviceID = 0, phasorID = -1; // Start phasor ID's at less than -1 since associated voltage == -1 is reserved as unselected if (!string.IsNullOrWhiteSpace(connectionString)) { Dictionary <string, string> settings = connectionString.ParseKeyValuePairs(); protocolID = GetProtocolID(settings["phasorProtocol"]); } ConfigurationFrame derivedFrame = new ConfigurationFrame { IDCode = sourceFrame.IDCode, FrameRate = sourceFrame.FrameRate, ConnectionString = connectionString, ProtocolID = protocolID }; foreach (IConfigurationCell sourceCell in sourceFrame.Cells) { // Create new derived configuration cell ConfigurationCell derivedCell = new ConfigurationCell { ID = --deviceID, // Provide a negative index so any database lookup will return null ParentID = null, IDCode = sourceCell.IDCode, StationName = sourceCell.StationName, IDLabel = sourceCell.IDLabel }; // Create equivalent derived frequency definition IFrequencyDefinition sourceFrequency = sourceCell.FrequencyDefinition; if (sourceFrequency != null) { derivedCell.FrequencyDefinition = new FrequencyDefinition { Label = sourceFrequency.Label } } ; int sourceIndex = 0; // Create equivalent derived phasor definitions foreach (IPhasorDefinition sourcePhasor in sourceCell.PhasorDefinitions) { derivedCell.PhasorDefinitions.Add(new PhasorDefinition { ID = --phasorID, Label = sourcePhasor.Label, PhasorType = sourcePhasor.PhasorType.ToString(), SourceIndex = ++sourceIndex }); } // Create equivalent derived analog definitions (assuming analog type = SinglePointOnWave) foreach (IAnalogDefinition sourceAnalog in sourceCell.AnalogDefinitions) { derivedCell.AnalogDefinitions.Add(new AnalogDefinition { Label = sourceAnalog.Label, AnalogType = sourceAnalog.AnalogType.ToString() }); } // Create equivalent derived digital definitions foreach (IDigitalDefinition sourceDigital in sourceCell.DigitalDefinitions) { derivedCell.DigitalDefinitions.Add(new DigitalDefinition { Label = sourceDigital.Label }); } // Add cell to frame derivedFrame.Cells.Add(derivedCell); } derivedFrame.IsConcentrator = derivedFrame.Cells.Count > 1; return(derivedFrame); }
/// <summary> /// Creates a new <see cref="FrequencyValue"/>. /// </summary> /// <param name="parent">The <see cref="IDataCell"/> parent of this <see cref="FrequencyValue"/>.</param> /// <param name="frequencyDefinition">The <see cref="IFrequencyDefinition"/> associated with this <see cref="FrequencyValue"/>.</param> public FrequencyValue(IDataCell parent, IFrequencyDefinition frequencyDefinition) : base(parent, frequencyDefinition) { }
// Static Methods // Creates frequency information for an INI based BPA PDCstream configuration file internal static string ConfigFileFormat(IFrequencyDefinition definition) { FrequencyDefinition frequency = definition as FrequencyDefinition; if (frequency != null) return "F," + frequency.ScalingValue + "," + frequency.Offset + "," + frequency.DfDtScalingValue + "," + frequency.DfDtOffset + "," + frequency.m_dummy + "," + frequency.Label; return ""; }