Inheritance: PhasorDefinitionBase
Beispiel #1
0
        // Delegate handler to create a new BPA PDCstream phasor definition
        internal static IPhasorDefinition CreateNewDefinition(IConfigurationCell parent, byte[] buffer, int startIndex, out int parsedLength)
        {
            IPhasorDefinition phasorDefinition = new PhasorDefinition(parent);

            parsedLength = phasorDefinition.ParseBinaryImage(buffer, startIndex, 0);

            return(phasorDefinition);
        }
Beispiel #2
0
        // Static Methods

        // Calculates a BPA PDCstream phasor's custom conversion factor
        internal static double CustomConversionFactor(PhasorDefinition phasor)
        {
            if (phasor.PhasorType == PhasorType.Voltage)
            {
                return(phasor.CalFactor * phasor.Ratio);
            }

            return(phasor.CalFactor * phasor.Ratio / phasor.Shunt);
        }
Beispiel #3
0
        // Creates phasor information for an INI based BPA PDCstream configuration file
        internal static string ConfigFileFormat(IPhasorDefinition definition)
        {
            PhasorDefinition phasor = definition as PhasorDefinition;

            if (phasor != null)
            {
                return((phasor.PhasorType == PhasorType.Voltage ? "V" : "I") + "," + phasor.Ratio + "," + phasor.CalFactor + "," + phasor.Offset + "," + phasor.Shunt + "," + phasor.VoltageReferenceIndex + "," + phasor.Label);
            }
            else if (definition != null)
            {
                if (definition.PhasorType == PhasorType.Voltage)
                {
                    return("V,4500.0,0.0060573,0,0,500," + definition.Label.ToNonNullString("Default 500kV"));
                }
                else
                {
                    return("I,600.00,0.000040382,0,1,1," + definition.Label.ToNonNullString("Default Current"));
                }
            }

            return("");
        }
Beispiel #4
0
 /// <summary>
 /// Creates a new <see cref="PhasorValue"/> from specified parameters.
 /// </summary>
 /// <param name="parent">The <see cref="DataCell"/> parent of this <see cref="PhasorValue"/>.</param>
 /// <param name="phasorDefinition">The <see cref="PhasorDefinition"/> associated with this <see cref="PhasorValue"/>.</param>
 /// <param name="angle">The <see cref="GSF.Units.Angle"/> value (a.k.a., the argument) of this <see cref="PhasorValue"/>, in radians.</param>
 /// <param name="magnitude">The magnitude value (a.k.a., the absolute value or modulus) of this <see cref="PhasorValue"/>.</param>
 public PhasorValue(DataCell parent, PhasorDefinition phasorDefinition, Angle angle, double magnitude)
     : base(parent, phasorDefinition, angle, magnitude)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new <see cref="PhasorValue"/> from specified parameters.
 /// </summary>
 /// <param name="parent">The <see cref="DataCell"/> parent of this <see cref="PhasorValue"/>.</param>
 /// <param name="phasorDefinition">The <see cref="PhasorDefinition"/> associated with this <see cref="PhasorValue"/>.</param>
 /// <param name="real">The real value of this <see cref="PhasorValue"/>.</param>
 /// <param name="imaginary">The imaginary value of this <see cref="PhasorValue"/>.</param>
 public PhasorValue(DataCell parent, PhasorDefinition phasorDefinition, double real, double imaginary)
     : base(parent, phasorDefinition, real, imaginary)
 {
 }
Beispiel #6
0
        // Static Methods

        /// <summary>
        /// Gets a generated INI configuration file image.
        /// </summary>
        public static string GetIniFileImage(IConfigurationFrame configFrame)
        {
            StringBuilder fileImage = new StringBuilder();

            fileImage.AppendLine("; BPA PDCstream IniFile for Configuration " + configFrame.IDCode);
            fileImage.AppendLine("; Auto-generated on " + DateTime.Now);
            fileImage.AppendLine(";    Assembly: " + AssemblyInfo.ExecutingAssembly.Name);
            fileImage.AppendLine(";    Compiled: " + File.GetLastWriteTime(AssemblyInfo.ExecutingAssembly.Location));
            fileImage.AppendLine(";");
            fileImage.AppendLine(";");
            fileImage.AppendLine("; Format:");
            fileImage.AppendLine(";   Each Column in data file is given a bracketed identifier, numbered in the order it");
            fileImage.AppendLine(";   appears in the data file, and identified by data type ( PMU, PDC, or other)");
            fileImage.AppendLine(";     PMU designates column data format from a single PMU");
            fileImage.AppendLine(";     PDC designates column data format from another PDC which is somewhat different from a single PMU");
            fileImage.AppendLine(";   Default gives default values for a processing algorithm in case quantities are omitted");
            fileImage.AppendLine(";   Name= gives the overall station name for print labels");
            fileImage.AppendLine(";   NumberPhasors= :  for PMU data, gives the number of phasors contained in column");
            fileImage.AppendLine(";                     for PDC data, gives the number of PMUs data included in the column");
            fileImage.AppendLine(";                     Note - for PDC data, there will be 2 phasors & 1 freq per PMU");
            fileImage.AppendLine(";   Quantities within the column are listed by PhasorI=, Frequency=, etc");
            fileImage.AppendLine(";   Each quantity has 7 comma separated fields followed by an optional comment");
            fileImage.AppendLine(";");
            fileImage.AppendLine(";   Phasor entry format:  Type, Ratio, Cal Factor, Offset, Shunt, VoltageRef/Class, Label  ;Comments");
            fileImage.AppendLine(";    Type:       Type of measurement, V=voltage, I=current, N=don\'t care, single ASCII character");
            fileImage.AppendLine(";    Ratio:      PT/CT ratio N:1 where N is a floating point number");
            fileImage.AppendLine(";    Cal Factor: Conversion factor between integer in file and secondary volts, floating point");
            fileImage.AppendLine(";    Offset:     Phase Offset to correct for phase angle measurement errors or differences, floating point");
            fileImage.AppendLine(";    Shunt:      Current- shunt resistence in ohms, or the equivalent ratio for aux CTs, floating point");
            fileImage.AppendLine(";                Voltage- empty, not used");
            fileImage.AppendLine(";    VoltageRef: Current- phasor number (1-10) of voltage phasor to use for power calculation, integer");
            fileImage.AppendLine(";                Voltage- voltage class, standard l-l voltages, 500, 230, 115, etc, integer");
            fileImage.AppendLine(";    Label:      Phasor quantity label for print label, text");
            fileImage.AppendLine(";    Comments:   All text after the semicolon on a line are optional comments not for processing");
            fileImage.AppendLine(";");
            fileImage.AppendLine(";   Voltage Magnitude = MAG(Real,Imaginary) * CalFactor * PTR (line-neutral)");
            fileImage.AppendLine(";   Current Magnitude = MAG(Real,Imaginary) * CalFactor * CTR / Shunt (phase current)");
            fileImage.AppendLine(";   Phase Angle = ATAN(Imaginary/Real) + Phase Offset (usually degrees)");
            fileImage.AppendLine(";     Note: Usually phase Offset is 0, but is sometimes required for comparing measurements");
            fileImage.AppendLine(";           from different systems or through transformer banks");
            fileImage.AppendLine(";");
            fileImage.AppendLine(";   Frequency entry format:  scale, offset, dF/dt scale, dF/dt offset, dummy, label  ;Comments");
            fileImage.AppendLine(";   Frequency = Number / scale + offset");
            fileImage.AppendLine(";   dF/dt = Number / (dF/dt scale) + (dF/dt offset)");
            fileImage.AppendLine(";");
            fileImage.AppendLine(";");

            fileImage.AppendLine("[DEFAULT]");
            fileImage.AppendLine("PhasorV=" + DefaultVoltagePhasorEntry); //PhasorDefinition.ConfigFileFormat(DefaultPhasorV));
            fileImage.AppendLine("PhasorI=" + DefaultCurrentPhasorEntry); //PhasorDefinition.ConfigFileFormat(DefaultPhasorI));
            fileImage.AppendLine("Frequency=" + DefaultFrequencyEntry);   //FrequencyDefinition.ConfigFileFormat(DefaultFrequency));
            fileImage.AppendLine();

            fileImage.AppendLine("[CONFIG]");
            fileImage.AppendLine("SampleRate=" + configFrame.FrameRate);
            fileImage.AppendLine("NumberOfPMUs=" + configFrame.Cells.Count);
            fileImage.AppendLine();

            for (int x = 0; x < configFrame.Cells.Count; x++)
            {
                fileImage.AppendLine("[" + configFrame.Cells[x].IDLabel + "]");
                fileImage.AppendLine("Name=" + configFrame.Cells[x].StationName);
                fileImage.AppendLine("PMU=" + x);
                fileImage.AppendLine("NumberPhasors=" + configFrame.Cells[x].PhasorDefinitions.Count);
                for (int y = 0; y < configFrame.Cells[x].PhasorDefinitions.Count; y++)
                {
                    fileImage.AppendLine("Phasor" + (y + 1) + "=" + PhasorDefinition.ConfigFileFormat(configFrame.Cells[x].PhasorDefinitions[y]));
                }
                fileImage.AppendLine("Frequency=" + FrequencyDefinition.ConfigFileFormat(configFrame.Cells[x].FrequencyDefinition));
                fileImage.AppendLine();
            }

            return(fileImage.ToString());
        }
Beispiel #7
0
        public void Refresh(bool refreshCausedByFrameParse)
        {
            // The only time we need an access lock is when we reload the config file...
            lock (m_iniFile)
            {
                if (File.Exists(m_iniFile.FileName))
                {
                    ConfigurationCell pmuCell;
                    int phasorCount, pmuCount, x, y;

                    m_defaultPhasorV   = new PhasorDefinition(null, 0, m_iniFile["DEFAULT", "PhasorV", DefaultVoltagePhasorEntry]);
                    m_defaultPhasorI   = new PhasorDefinition(null, 0, m_iniFile["DEFAULT", "PhasorI", DefaultCurrentPhasorEntry]);
                    m_defaultFrequency = new FrequencyDefinition(null, m_iniFile["DEFAULT", "Frequency", DefaultFrequencyEntry]);
                    FrameRate          = ushort.Parse(m_iniFile["CONFIG", "SampleRate", "30"]);

                    // We read all cells in the config file into their own configuration cell collection - cells parsed
                    // from the configuration frame will be mapped to their associated config file cell by ID label
                    // when the configuration cell is parsed from the configuration frame
                    if (m_configurationFileCells == null)
                    {
                        m_configurationFileCells = new ConfigurationCellCollection();
                    }

                    m_configurationFileCells.Clear();

                    // Load phasor data for each section in config file...
                    foreach (string section in m_iniFile.GetSectionNames())
                    {
                        if (section.Length > 0)
                        {
                            // Make sure this is not a special section
                            if (string.Compare(section, "DEFAULT", true) != 0 && string.Compare(section, "CONFIG", true) != 0)
                            {
                                // Create new PMU entry structure from config file settings...
                                phasorCount = int.Parse(m_iniFile[section, "NumberPhasors", "0"]);

                                // Check for PDC code
                                int pdcID = int.Parse(m_iniFile[section, "PDC", "-1"]);

                                if (pdcID == -1)
                                {
                                    // No PDC entry exists, assume this is a PMU
                                    pmuCell              = new ConfigurationCell(this, 0);
                                    pmuCell.IDCode       = ushort.Parse(m_iniFile[section, "PMU", Cells.Count.ToString()]);
                                    pmuCell.SectionEntry = section; // This will automatically assign ID label as first 4 digits of section
                                    pmuCell.StationName  = m_iniFile[section, "Name", section];

                                    for (x = 0; x < phasorCount; x++)
                                    {
                                        pmuCell.PhasorDefinitions.Add(new PhasorDefinition(pmuCell, x + 1, m_iniFile[section, "Phasor" + (x + 1), DefaultVoltagePhasorEntry]));
                                    }

                                    pmuCell.FrequencyDefinition = new FrequencyDefinition(pmuCell, m_iniFile[section, "Frequency", DefaultFrequencyEntry]);
                                    m_configurationFileCells.Add(pmuCell);
                                }
                                else
                                {
                                    // This is a PDC, need to define one virtual entry for each PMU
                                    pmuCount = int.Parse(m_iniFile[section, "NumberPMUs", "0"]);

                                    for (x = 0; x < pmuCount; x++)
                                    {
                                        // Create a new PMU cell for each PDC entry that exists
                                        pmuCell = new ConfigurationCell(this, 0);

                                        // For BPA INI files, PMUs tradionally have an ID number indexed starting at zero or one - so we multiply
                                        // ID by 1000 and add index to attempt to create a fairly unique ID to help optimize downstream parsing
                                        pmuCell.IDCode       = unchecked ((ushort)(pdcID * 1000 + x));
                                        pmuCell.SectionEntry = string.Format("{0}pmu{1}", section, x); // This will automatically assign ID label as first 4 digits of section
                                        pmuCell.StationName  = string.Format("{0} - Device {1}", m_iniFile[section, "Name", section], (x + 1));

                                        for (y = 0; y < 2; y++)
                                        {
                                            pmuCell.PhasorDefinitions.Add(new PhasorDefinition(pmuCell, y + 1, m_iniFile[section, "Phasor" + ((x * 2) + (y + 1)), DefaultVoltagePhasorEntry]));
                                        }

                                        pmuCell.FrequencyDefinition = new FrequencyDefinition(pmuCell, m_iniFile[section, "Frequency", DefaultFrequencyEntry]);
                                        m_configurationFileCells.Add(pmuCell);
                                    }
                                }
                            }
                        }
                    }

                    // Associate parsed cells with cells defined in INI file
                    if (m_configurationFileCells.Count > 0 && (Cells != null))
                    {
                        ConfigurationCell  configurationFileCell = null;
                        IConfigurationCell configurationCell     = null;

                        if (refreshCausedByFrameParse)
                        {
                            // Create a new configuration cell collection that will account for PDC block cells
                            ConfigurationCellCollection cellCollection = new ConfigurationCellCollection();
                            ConfigurationCell           cell;

                            // For freshly parsed configuration frames we'll have no PMU's in configuration
                            // frame for PDCxchng blocks - so we'll need to dynamically create them
                            for (x = 0; x < Cells.Count; x++)
                            {
                                // Get current configuration cell
                                cell = Cells[x];

                                // Lookup INI file configuration cell by ID label
                                m_configurationFileCells.TryGetByIDLabel(cell.IDLabel, out configurationCell);
                                configurationFileCell = (ConfigurationCell)configurationCell;

                                if (configurationFileCell == null)
                                {
                                    // Couldn't find associated INI file cell - just append the parsed cell to the collection
                                    cellCollection.Add(cell);
                                }
                                else
                                {
                                    if (configurationFileCell.IsPdcBlockSection)
                                    {
                                        // This looks like a PDC block section - so we'll keep adding cells for each defined PMU in the PDC block
                                        int index = 0;

                                        do
                                        {
                                            // Lookup PMU by section name
                                            m_configurationFileCells.TryGetBySectionEntry(string.Format("{0}pmu{1}", cell.IDLabel, index), ref configurationFileCell);

                                            // Add PDC block PMU configuration cell to the collection
                                            if (configurationFileCell != null)
                                            {
                                                cellCollection.Add(configurationFileCell);
                                            }

                                            index++;
                                        }while (configurationFileCell != null);
                                    }
                                    else
                                    {
                                        // As far as we can tell from INI file, this is just a regular PMU
                                        cell.ConfigurationFileCell = configurationFileCell;
                                        cellCollection.Add(cell);
                                    }
                                }
                            }

                            // Assign "new" cell collection which will include PMU's from defined PDC blocks
                            Cells.Clear();
                            Cells.AddRange(cellCollection);
                        }
                        else
                        {
                            // For simple INI file updates, we just re-assign INI file cells associating by section entry
                            foreach (ConfigurationCell cell in Cells)
                            {
                                // Attempt to associate this configuration cell with information read from external INI based configuration file
                                m_configurationFileCells.TryGetBySectionEntry(cell.SectionEntry, ref configurationFileCell);
                                cell.ConfigurationFileCell = configurationFileCell;
                            }
                        }
                    }
                }
                else
                {
                    throw new InvalidOperationException("PDC config file \"" + m_iniFile.FileName + "\" does not exist.");
                }
            }

            // In case other classes want to know, we send out a notification that the config file has been reloaded (make sure
            // you do this after the write lock has been released to avoid possible dead-lock situations)
            if (ConfigurationFileReloaded != null)
            {
                ConfigurationFileReloaded(this, EventArgs.Empty);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Creates a new <see cref="PhasorDefinition"/> from specified parameters.
        /// </summary>
        /// <param name="parent">The <see cref="ConfigurationCell"/> parent of this <see cref="PhasorDefinition"/>.</param>
        /// <param name="index">Index of phasor within INI based configuration file.</param>
        /// <param name="entryValue">The entry value from the INI based configuration file.</param>
        public PhasorDefinition(ConfigurationCell parent, int index, string entryValue)
            : base(parent)
        {
            string[]         entry     = entryValue.Split(',');
            string           entryType = entry[0].Trim().Substring(0, 1).ToUpper();
            PhasorDefinition defaultPhasor;
            double           dValue;

            if (parent != null)
            {
                ConfigurationFrame configFile = this.Parent.Parent;

                if (entryType == "V")
                {
                    PhasorType    = PhasorType.Voltage;
                    defaultPhasor = configFile.DefaultPhasorV;
                }
                else if (entryType == "I")
                {
                    PhasorType    = PhasorType.Current;
                    defaultPhasor = configFile.DefaultPhasorI;
                }
                else
                {
                    PhasorType    = PhasorType.Voltage;
                    defaultPhasor = configFile.DefaultPhasorV;
                }
            }
            else
            {
                defaultPhasor = new PhasorDefinition(null as ConfigurationCell);
            }

            if (entry.Length > 1 && double.TryParse(entry[1].Trim(), out dValue))
            {
                Ratio = dValue;
            }
            else
            {
                Ratio = defaultPhasor.Ratio;
            }

            if (entry.Length > 2 && double.TryParse(entry[2].Trim(), out dValue))
            {
                CalFactor = dValue;
            }
            else
            {
                CalFactor = defaultPhasor.CalFactor;
            }

            if (entry.Length > 3 && double.TryParse(entry[3].Trim(), out dValue))
            {
                Offset = dValue;
            }
            else
            {
                Offset = defaultPhasor.Offset;
            }

            if (entry.Length > 4 && double.TryParse(entry[4].Trim(), out dValue))
            {
                Shunt = dValue;
            }
            else
            {
                Shunt = defaultPhasor.Shunt;
            }

            if (entry.Length > 5 && double.TryParse(entry[5].Trim(), out dValue))
            {
                VoltageReferenceIndex = (int)dValue;
            }
            else
            {
                VoltageReferenceIndex = defaultPhasor.VoltageReferenceIndex;
            }

            if (entry.Length > 6)
            {
                Label = entry[6].Trim();
            }
            else
            {
                Label = defaultPhasor.Label;
            }

            this.Index = index;
        }
Beispiel #9
0
 /// <summary>
 /// Creates a new <see cref="PhasorDefinition"/> from specified parameters.
 /// </summary>
 /// <param name="parent">The <see cref="ConfigurationCell"/> parent of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="label">The label of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="scale">The integer scaling value of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="offset">The offset of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="type">The <see cref="PhasorType"/> of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="voltageReference">The associated <see cref="IPhasorDefinition"/> that represents the voltage reference (if any).</param>
 public PhasorDefinition(ConfigurationCell parent, string label, uint scale, double offset, PhasorType type, PhasorDefinition voltageReference)
     : base(parent, label, scale, offset, type, voltageReference)
 {
 }
 /// <summary>
 /// Creates a new <see cref="PhasorValue"/> from specified parameters.
 /// </summary>
 /// <param name="parent">The <see cref="DataCell"/> parent of this <see cref="PhasorValue"/>.</param>
 /// <param name="phasorDefinition">The <see cref="PhasorDefinition"/> associated with this <see cref="PhasorValue"/>.</param>
 /// <param name="real">The real value of this <see cref="PhasorValue"/>.</param>
 /// <param name="imaginary">The imaginary value of this <see cref="PhasorValue"/>.</param>
 public PhasorValue(DataCell parent, PhasorDefinition phasorDefinition, double real, double imaginary)
     : base(parent, phasorDefinition, real, imaginary)
 {
 }
 /// <summary>
 /// Creates a new <see cref="PhasorValue"/> from specified parameters.
 /// </summary>
 /// <param name="parent">The <see cref="DataCell"/> parent of this <see cref="PhasorValue"/>.</param>
 /// <param name="phasorDefinition">The <see cref="PhasorDefinition"/> associated with this <see cref="PhasorValue"/>.</param>
 /// <param name="angle">The <see cref="GSF.Units.Angle"/> value (a.k.a., the argument) of this <see cref="PhasorValue"/>, in radians.</param>
 /// <param name="magnitude">The magnitude value (a.k.a., the absolute value or modulus) of this <see cref="PhasorValue"/>.</param>
 public PhasorValue(DataCell parent, PhasorDefinition phasorDefinition, Angle angle, double magnitude)
     : base(parent, phasorDefinition, angle, magnitude)
 {
 }
Beispiel #12
0
        /// <summary>
        /// Creates a new <see cref="PhasorDefinition"/> from specified parameters.
        /// </summary>
        /// <param name="parent">The <see cref="ConfigurationCell"/> parent of this <see cref="PhasorDefinition"/>.</param>
        /// <param name="index">Index of phasor within INI based configuration file.</param>
        /// <param name="entryValue">The entry value from the INI based configuration file.</param>
        public PhasorDefinition(ConfigurationCell parent, int index, string entryValue)
            : base(parent)
        {
            string[] entry = entryValue.Split(',');
            string entryType = entry[0].Trim().Substring(0, 1).ToUpper();
            PhasorDefinition defaultPhasor;
            double dValue;

            if (parent != null)
            {
                ConfigurationFrame configFile = this.Parent.Parent;

                if (entryType == "V")
                {
                    PhasorType = PhasorType.Voltage;
                    defaultPhasor = configFile.DefaultPhasorV;
                }
                else if (entryType == "I")
                {
                    PhasorType = PhasorType.Current;
                    defaultPhasor = configFile.DefaultPhasorI;
                }
                else
                {
                    PhasorType = PhasorType.Voltage;
                    defaultPhasor = configFile.DefaultPhasorV;
                }
            }
            else
            {
                defaultPhasor = new PhasorDefinition(null as ConfigurationCell);
            }

            if (entry.Length > 1 && double.TryParse(entry[1].Trim(), out dValue))
                Ratio = dValue;
            else
                Ratio = defaultPhasor.Ratio;

            if (entry.Length > 2 && double.TryParse(entry[2].Trim(), out dValue))
                CalFactor = dValue;
            else
                CalFactor = defaultPhasor.CalFactor;

            if (entry.Length > 3 && double.TryParse(entry[3].Trim(), out dValue))
                Offset = dValue;
            else
                Offset = defaultPhasor.Offset;

            if (entry.Length > 4 && double.TryParse(entry[4].Trim(), out dValue))
                Shunt = dValue;
            else
                Shunt = defaultPhasor.Shunt;

            if (entry.Length > 5 && double.TryParse(entry[5].Trim(), out dValue))
                VoltageReferenceIndex = (int)dValue;
            else
                VoltageReferenceIndex = defaultPhasor.VoltageReferenceIndex;

            if (entry.Length > 6)
                Label = entry[6].Trim();
            else
                Label = defaultPhasor.Label;

            this.Index = index;
        }
Beispiel #13
0
 /// <summary>
 /// Creates a new <see cref="PhasorDefinition"/> from specified parameters.
 /// </summary>
 /// <param name="parent">The <see cref="ConfigurationCell"/> parent of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="label">The label of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="scale">The integer scaling value of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="offset">The offset of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="type">The <see cref="PhasorType"/> of this <see cref="PhasorDefinition"/>.</param>
 /// <param name="voltageReference">The associated <see cref="IPhasorDefinition"/> that represents the voltage reference (if any).</param>
 public PhasorDefinition(ConfigurationCell parent, string label, uint scale, double offset, PhasorType type, PhasorDefinition voltageReference)
     : base(parent, label, scale, offset, type, voltageReference)
 {
 }
Beispiel #14
0
        // Delegate handler to create a new BPA PDCstream phasor definition
        internal static IPhasorDefinition CreateNewDefinition(IConfigurationCell parent, byte[] buffer, int startIndex, out int parsedLength)
        {
            IPhasorDefinition phasorDefinition = new PhasorDefinition(parent);

            parsedLength = phasorDefinition.ParseBinaryImage(buffer, startIndex, 0);

            return phasorDefinition;
        }
Beispiel #15
0
        // Static Methods

        // Calculates a BPA PDCstream phasor's custom conversion factor
        internal static double CustomConversionFactor(PhasorDefinition phasor)
        {
            if (phasor.PhasorType == PhasorType.Voltage)
                return phasor.CalFactor * phasor.Ratio;

            return phasor.CalFactor * phasor.Ratio / phasor.Shunt;
        }
Beispiel #16
0
        /// <summary>
        /// Creates a new <see cref="PhasorDefinition"/> from specified parameters.
        /// </summary>
        /// <param name="parent">The <see cref="ConfigurationCell"/> parent of this <see cref="PhasorDefinition"/>.</param>
        /// <param name="index">Index of phasor within INI based configuration file.</param>
        /// <param name="entryValue">The entry value from the INI based configuration file.</param>
        public PhasorDefinition(ConfigurationCell parent, int index, string entryValue)
            : base(parent)
        {
            string[]         entry     = entryValue.Split(',');
            string           entryType = entry[0].Trim().Substring(0, 1).ToUpper();
            PhasorDefinition defaultPhasor;

            if (parent is null)
            {
                defaultPhasor = new PhasorDefinition(null);
            }
            else
            {
                ConfigurationFrame configFile = Parent.Parent;

                switch (entryType)
                {
                case "V":
                    PhasorType    = PhasorType.Voltage;
                    defaultPhasor = configFile.DefaultPhasorV;
                    break;

                case "I":
                    PhasorType    = PhasorType.Current;
                    defaultPhasor = configFile.DefaultPhasorI;
                    break;

                default:
                    PhasorType    = PhasorType.Voltage;
                    defaultPhasor = configFile.DefaultPhasorV;
                    break;
                }
            }

            if (entry.Length > 1 && double.TryParse(entry[1].Trim(), out double dValue))
            {
                Ratio = dValue;
            }
            else
            {
                Ratio = defaultPhasor.Ratio;
            }

            if (entry.Length > 2 && double.TryParse(entry[2].Trim(), out dValue))
            {
                CalFactor = dValue;
            }
            else
            {
                CalFactor = defaultPhasor.CalFactor;
            }

            if (entry.Length > 3 && double.TryParse(entry[3].Trim(), out dValue))
            {
                Offset = dValue;
            }
            else
            {
                Offset = defaultPhasor.Offset;
            }

            if (entry.Length > 4 && double.TryParse(entry[4].Trim(), out dValue))
            {
                Shunt = dValue;
            }
            else
            {
                Shunt = defaultPhasor.Shunt;
            }

            if (entry.Length > 5 && double.TryParse(entry[5].Trim(), out dValue))
            {
                VoltageReferenceIndex = (int)dValue;
            }
            else
            {
                VoltageReferenceIndex = defaultPhasor.VoltageReferenceIndex;
            }

            Label = entry.Length > 6 ? entry[6].Trim() : defaultPhasor.Label;

            Index = index;
        }