コード例 #1
0
        private void textBoxAnalogs_TextChanged(object sender, TextChangedEventArgs e)
        {
            textBoxAnalogs.Text = textBoxAnalogs.Text.RemoveCharacters(c => !Char.IsDigit(c));

            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                ushort analogCount;

                if (ushort.TryParse(textBoxAnalogs.Text, out analogCount))
                {
                    int difference = analogCount - selectedDevice.AnalogDefinitions.Count;

                    if (difference > 0)
                    {
                        for (int i = 0; i < difference; i++)
                        {
                            selectedDevice.AnalogDefinitions.Add(new AnalogDefinition(selectedDevice, "Analog " + selectedDevice.AnalogDefinitions.Count, 0, AnalogType.SinglePointOnWave));
                        }
                    }
                    else if (difference < 0)
                    {
                        for (int i = 0; i < difference; i++)
                        {
                            selectedDevice.AnalogDefinitions.RemoveAt(selectedDevice.AnalogDefinitions.Count - 1);
                        }
                    }
                }
                else
                {
                    selectedDevice.AnalogDefinitions.Clear();
                }
            }
        }
コード例 #2
0
        private void textBoxDigitals_TextChanged(object sender, TextChangedEventArgs e)
        {
            textBoxDigitals.Text = textBoxDigitals.Text.RemoveCharacters(c => !Char.IsDigit(c));

            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                ushort digitalCount;

                if (ushort.TryParse(textBoxDigitals.Text, out digitalCount))
                {
                    int difference = digitalCount - selectedDevice.DigitalDefinitions.Count;

                    if (difference > 0)
                    {
                        for (int i = 0; i < difference; i++)
                        {
                            selectedDevice.DigitalDefinitions.Add(new DigitalDefinition(selectedDevice, "Digital " + selectedDevice.DigitalDefinitions.Count, 0));
                        }
                    }
                    else if (difference < 0)
                    {
                        for (int i = 0; i < difference; i++)
                        {
                            selectedDevice.DigitalDefinitions.RemoveAt(selectedDevice.DigitalDefinitions.Count - 1);
                        }
                    }
                }
                else
                {
                    selectedDevice.DigitalDefinitions.Clear();
                }
            }
        }
コード例 #3
0
        private static void SavePMUDevice(ImportParameters importParams, ConfigurationCell configCell, Device parentDevice)
        {
            ConfigurationFrame       configFrame = importParams.TargetConfigFrame;
            TableOperations <Device> deviceTable = importParams.DeviceTable;
            Guid   nodeID        = importParams.NodeID;
            Device device        = s_devices.FindChildDeviceByIDCode(parentDevice.ID, configCell.IDCode) ?? deviceTable.NewDevice();
            string deviceAcronym = configCell.IDLabel;
            string deviceName    = null;

            if (string.IsNullOrWhiteSpace(deviceAcronym))
            {
                if (string.IsNullOrWhiteSpace(configCell.StationName))
                {
                    throw new InvalidOperationException("Unable to get station name or ID label for PMU from parsed device configuration cell");
                }

                deviceAcronym = configCell.StationName.GetCleanAcronym();
            }

            if (!string.IsNullOrWhiteSpace(configCell.StationName))
            {
                deviceName = configCell.StationName;
            }

            // Keep old device acronym for measurement updates
            device.OldAcronym = string.IsNullOrWhiteSpace(device.Acronym) ? deviceAcronym : device.Acronym;

            // Assign new device fields
            device.NodeID          = nodeID;
            device.ParentID        = parentDevice.ID;
            device.HistorianID     = configFrame.HistorianID;
            device.Acronym         = deviceAcronym;
            device.Name            = deviceName ?? deviceAcronym;
            device.ProtocolID      = importParams.IeeeC37_118ProtocolID;
            device.FramesPerSecond = configCell.FrameRate;
            device.AccessID        = configCell.IDCode;
            device.IsConcentrator  = false;
            device.Enabled         = true;

            // Check if this is a new device or an edit to an existing one
            if (device.ID == 0)
            {
                // Add new device record
                deviceTable.AddNewDevice(device);

                // Get newly added device with auto-incremented ID
                Device newDevice = deviceTable.QueryDevice(device.Acronym);

                // Save associated device records
                SaveDeviceRecords(importParams, configCell, newDevice);
            }
            else
            {
                // Update existing device record
                deviceTable.UpdateDevice(device);

                // Save associated device records
                SaveDeviceRecords(importParams, configCell, device);
            }
        }
コード例 #4
0
        // Static Methods

        /// <summary>
        /// Creates a new IEC 61850-90-5 (i.e., IEEE C37.118) <see cref="ConfigurationFrame"/> based on provided protocol independent <paramref name="baseConfigurationFrame"/>.
        /// </summary>
        /// <param name="baseConfigurationFrame">Protocol independent <see cref="GSF.PhasorProtocols.Anonymous.ConfigurationFrame"/>.</param>
        /// <param name="timeBase">Timebase to use for fraction second resolution.</param>
        /// <param name="nominalFrequency">The nominal <see cref="LineFrequency"/> to use for the new <see cref="ConfigurationFrame"/></param>.
        /// <returns>A new IEEE C37.118 <see cref="ConfigurationFrame"/>.</returns>
        public static ConfigurationFrame CreateConfigurationFrame(GSF.PhasorProtocols.Anonymous.ConfigurationFrame baseConfigurationFrame, uint timeBase, LineFrequency nominalFrequency)
        {
            ConfigurationCell newCell;
            uint maskValue;

            // Create a new IEEE C37.118 configuration frame 2 using base configuration
            ConfigurationFrame configurationFrame = new ConfigurationFrame(timeBase, baseConfigurationFrame.IDCode, DateTime.UtcNow.Ticks, baseConfigurationFrame.FrameRate);

            foreach (GSF.PhasorProtocols.Anonymous.ConfigurationCell baseCell in baseConfigurationFrame.Cells)
            {
                // Create a new IEEE C37.118 configuration cell (i.e., a PMU configuration)
                newCell = new ConfigurationCell(configurationFrame, baseCell.IDCode, nominalFrequency);

                // Update other cell level attributes
                newCell.StationName            = baseCell.StationName;
                newCell.IDLabel                = baseCell.IDLabel;
                newCell.PhasorDataFormat       = baseCell.PhasorDataFormat;
                newCell.PhasorCoordinateFormat = baseCell.PhasorCoordinateFormat;
                newCell.FrequencyDataFormat    = baseCell.FrequencyDataFormat;
                newCell.AnalogDataFormat       = baseCell.AnalogDataFormat;

                // Add phasor definitions
                foreach (IPhasorDefinition phasorDefinition in baseCell.PhasorDefinitions)
                {
                    newCell.PhasorDefinitions.Add(new PhasorDefinition(newCell, phasorDefinition.Label, phasorDefinition.ScalingValue, phasorDefinition.Offset, phasorDefinition.PhasorType, null));
                }

                // Add frequency definition
                newCell.FrequencyDefinition = new FrequencyDefinition(newCell, baseCell.FrequencyDefinition.Label);

                // Add analog definitions
                foreach (IAnalogDefinition analogDefinition in baseCell.AnalogDefinitions)
                {
                    newCell.AnalogDefinitions.Add(new AnalogDefinition(newCell, analogDefinition.Label, analogDefinition.ScalingValue, analogDefinition.Offset, analogDefinition.AnalogType));
                }

                // Add digital definitions
                foreach (IDigitalDefinition digitalDefinition in baseCell.DigitalDefinitions)
                {
                    // Attempt to derive user defined mask value if available
                    DigitalDefinition anonymousDigitalDefinition = digitalDefinition as DigitalDefinition;

                    if (anonymousDigitalDefinition != null)
                    {
                        maskValue = anonymousDigitalDefinition.MaskValue;
                    }
                    else
                    {
                        maskValue = 0U;
                    }

                    newCell.DigitalDefinitions.Add(new GSF.PhasorProtocols.IEC61850_90_5.DigitalDefinition(newCell, digitalDefinition.Label, maskValue.LowWord(), maskValue.HighWord()));
                }

                // Add new PMU configuration (cell) to protocol specific configuration frame
                configurationFrame.Cells.Add(newCell);
            }

            return(configurationFrame);
        }
コード例 #5
0
        private void listBoxDevices_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                textBoxDeviceName.Text   = selectedDevice.StationName;
                textBoxDeviceIDCode.Text = selectedDevice.IDCode.ToString();

                if (selectedDevice.PhasorCoordinateFormat == TVA.PhasorProtocols.CoordinateFormat.Polar)
                {
                    radioButtonPhasorPolar.IsChecked = true;
                }
                else
                {
                    radioButtonPhasorRectangular.IsChecked = true;
                }

                if (selectedDevice.PhasorDataFormat == TVA.PhasorProtocols.DataFormat.FloatingPoint)
                {
                    radioButtonPhasorFloatingPoint.IsChecked = true;
                }
                else
                {
                    radioButtonPhasorScaledInteger.IsChecked = true;
                }

                if (selectedDevice.FrequencyDataFormat == TVA.PhasorProtocols.DataFormat.FloatingPoint)
                {
                    radioButtonFrequencyFloatingPoint.IsChecked = true;
                }
                else
                {
                    radioButtonFrequencyScaledInteger.IsChecked = true;
                }

                if (selectedDevice.AnalogDataFormat == TVA.PhasorProtocols.DataFormat.FloatingPoint)
                {
                    radioButtonAnalogFloatingPoint.IsChecked = true;
                }
                else
                {
                    radioButtonAnalogScaledInteger.IsChecked = true;
                }

                textBoxAnalogs.Text = selectedDevice.AnalogDefinitions.Count.ToString();

                textBoxDigitals.Text = selectedDevice.DigitalDefinitions.Count.ToString();

                listBoxPhasors.ItemsSource       = selectedDevice.PhasorDefinitions;
                listBoxPhasors.SelectedValuePath = "@Index";

                if (selectedDevice.PhasorDefinitions.Count > 0)
                {
                    listBoxPhasors.SelectedIndex = 0;
                }
            }
        }
コード例 #6
0
        private void radioButtonAnalogFloatingPoint_Checked(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                selectedDevice.AnalogDataFormat = DataFormat.FloatingPoint;
            }
        }
コード例 #7
0
        private void radioButtonFrequencyScaledInteger_Checked(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                selectedDevice.FrequencyDataFormat = DataFormat.FixedInteger;
            }
        }
コード例 #8
0
        private void radioButtonAnalogScaledInteger_Checked(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                selectedDevice.AnalogDataFormat = TVA.PhasorProtocols.DataFormat.FixedInteger;
            }
        }
コード例 #9
0
        private void radioButtonFrequencyFloatingPoint_Checked(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                selectedDevice.FrequencyDataFormat = TVA.PhasorProtocols.DataFormat.FloatingPoint;
            }
        }
コード例 #10
0
        private void radioButtonPhasorRectangular_Checked(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                selectedDevice.PhasorCoordinateFormat = TVA.PhasorProtocols.CoordinateFormat.Rectangular;
            }
        }
コード例 #11
0
        private void textBoxName_TextChanged(object sender, TextChangedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                selectedDevice.StationName = textBoxDeviceName.Text;
                m_configurationFrame.Cells.RefreshBinding();
            }
        }
コード例 #12
0
        private void buttonDeviceAdd_Click(object sender, RoutedEventArgs e)
        {
            ConfigurationCell device = new ConfigurationCell(m_configurationFrame, 0);

            device.IDCode      = (ushort)m_configurationFrame.Cells.Count;
            device.StationName = "Device " + (device.IDCode + 1);

            m_configurationFrame.Cells.Add(device);
            listBoxDevices.SelectedIndex = (m_configurationFrame.Cells.Count - 1);
        }
コード例 #13
0
        private void buttonPhasorAdd_Click(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                PhasorDefinition phasor = new PhasorDefinition(selectedDevice, "Phasor " + (selectedDevice.PhasorDefinitions.Count + 1), 1, PhasorType.Current, null);
                selectedDevice.PhasorDefinitions.Add(phasor);
                listBoxPhasors.SelectedIndex = (selectedDevice.PhasorDefinitions.Count - 1);
            }
        }
コード例 #14
0
        private void textBoxPhasorLabel_TextChanged(object sender, TextChangedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;
            IPhasorDefinition selectedPhasor = this.SelectedPhasor;

            if (selectedDevice != null && selectedPhasor != null)
            {
                selectedPhasor.Label = textBoxPhasorLabel.Text;
                selectedDevice.PhasorDefinitions.RefreshBinding();
            }
        }
コード例 #15
0
        private void buttonDeviceMoveDown_Click(object sender, RoutedEventArgs e)
        {
            int selectedIndex = listBoxDevices.SelectedIndex;

            if (selectedIndex >= 0 && selectedIndex < m_configurationFrame.Cells.Count - 1)
            {
                ConfigurationCell selectedDevice = m_configurationFrame.Cells[selectedIndex];
                m_configurationFrame.Cells.RemoveAt(selectedIndex);
                m_configurationFrame.Cells.Insert(selectedIndex + 1, selectedDevice);
                listBoxDevices.SelectedIndex = selectedIndex + 1;
            }
        }
コード例 #16
0
        private void buttonPhasorDelete_Click(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                selectedDevice.PhasorDefinitions.Remove(listBoxPhasors.SelectedItem as IPhasorDefinition);

                if (selectedDevice.PhasorDefinitions.Count > 0)
                {
                    listBoxPhasors.SelectedIndex = 0;
                }
            }
        }
コード例 #17
0
        private void radioButtonPhasorTypeVoltage_Checked(object sender, RoutedEventArgs e)
        {
            IPhasorDefinition selectedPhasor = this.SelectedPhasor;

            if (selectedPhasor != null)
            {
                selectedPhasor.PhasorType = PhasorType.Voltage;
            }

            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                selectedDevice.PhasorDefinitions.RefreshBinding();
            }
        }
コード例 #18
0
        private void buttonPhasorMoveDown_Click(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                int selectedIndex = listBoxPhasors.SelectedIndex;

                if (selectedIndex >= 0 && selectedIndex < selectedDevice.PhasorDefinitions.Count - 1)
                {
                    IPhasorDefinition selectedPhasor = selectedDevice.PhasorDefinitions[selectedIndex];
                    selectedDevice.PhasorDefinitions.RemoveAt(selectedIndex);
                    selectedDevice.PhasorDefinitions.Insert(selectedIndex + 1, selectedPhasor);
                    listBoxPhasors.SelectedIndex = selectedIndex + 1;
                }
            }
        }
コード例 #19
0
        /// <summary>
        /// Creates a new <see cref="FrequencyDefinition"/> from the specified parameters.
        /// </summary>
        /// <param name="parent">The <see cref="ConfigurationCell"/> parent of this <see cref="FrequencyDefinition"/>.</param>
        /// <param name="entryValue">The entry value from the INI based configuration file.</param>
        public FrequencyDefinition(ConfigurationCell parent, string entryValue)
            : base(parent)
        {
            string[] entry = entryValue.Split(',');
            FrequencyDefinition defaultFrequency;
            int index = 0;

            if (parent != null)
                defaultFrequency = parent.Parent.DefaultFrequency;
            else
                defaultFrequency = new FrequencyDefinition(null as IConfigurationCell);

            // If initial entry is an F - we just ignore this
            if (string.Compare(entry[index].Trim(), "F", StringComparison.OrdinalIgnoreCase) == 0)
                index++;

            if (entry.Length > index)
                ScalingValue = uint.Parse(entry[index++].Trim());
            else
                ScalingValue = defaultFrequency.ScalingValue;

            if (entry.Length > index)
                Offset = double.Parse(entry[index++].Trim());
            else
                Offset = defaultFrequency.Offset;

            if (entry.Length > index)
                DfDtScalingValue = uint.Parse(entry[index++].Trim());
            else
                DfDtScalingValue = defaultFrequency.DfDtScalingValue;

            if (entry.Length > index)
                DfDtOffset = double.Parse(entry[index++].Trim());
            else
                DfDtOffset = defaultFrequency.DfDtOffset;

            if (entry.Length > index)
                m_dummy = int.Parse(entry[index++].Trim());
            else
                m_dummy = defaultFrequency.m_dummy;

            if (entry.Length > index)
                Label = entry[index++].Trim();
            else
                Label = defaultFrequency.Label;
        }
コード例 #20
0
ファイル: DataCell.cs プロジェクト: rmc00/gsf
        /// <summary>
        /// Creates a new <see cref="DataCell"/> from specified parameters.
        /// </summary>
        /// <param name="parent">The reference to parent <see cref="DataFrame"/> of this <see cref="DataCell"/>.</param>
        /// <param name="configurationCell">The <see cref="ConfigurationCell"/> associated with this <see cref="DataCell"/>.</param>
        /// <param name="addEmptyValues">If <c>true</c>, adds empty values for each defined configuration cell definition.</param>
        public DataCell(DataFrame parent, ConfigurationCell configurationCell, bool addEmptyValues)
            : this(parent, configurationCell)
        {
            if (addEmptyValues)
            {
                int x;

                // Define needed phasor values
                for (x = 0; x < configurationCell.PhasorDefinitions.Count; x++)
                {
                    PhasorValues.Add(new PhasorValue(this, configurationCell.PhasorDefinitions[x]));
                }

                // Define a frequency and df/dt
                FrequencyValue = new FrequencyValue(this, configurationCell.FrequencyDefinition);
            }
        }
コード例 #21
0
        private static void SaveDeviceRecords(ImportParameters importParams, ConfigurationCell configCell, Device device)
        {
            ConfigurationFrame            configFrame      = importParams.TargetConfigFrame;
            AdoDataConnection             connection       = importParams.Connection;
            TableOperations <Measurement> measurementTable = new(connection);

            // Add frequency
            SaveFixedMeasurement(importParams, s_deviceSignalTypes["FREQ"], device, measurementTable);

            // Add dF/dt
            SaveFixedMeasurement(importParams, s_deviceSignalTypes["DFDT"], device, measurementTable);

            // Add status flags
            SaveFixedMeasurement(importParams, s_deviceSignalTypes["FLAG"], device, measurementTable);

            // Add analogs
            SignalType analogSignalType = s_deviceSignalTypes["ALOG"];

            for (int i = 0; i < configCell.AnalogDefinitions.Count; i++)
            {
                if (configCell.AnalogDefinitions[i] is not AnalogDefinition analogDefinition)
                {
                    continue;
                }

                int    index = i + 1;
                string oldSignalReference = $"{device.OldAcronym}-{analogSignalType.Suffix}{index}";
                string newSignalReference = $"{device.Acronym}-{analogSignalType.Suffix}{index}";

                // Query existing measurement record for specified signal reference - function will create a new blank measurement record if one does not exist
                Measurement measurement = measurementTable.QueryMeasurement(oldSignalReference);
                string      pointTag    = importParams.CreateIndexedPointTag(device.Acronym, analogSignalType.Acronym, index);

                measurement.DeviceID        = device.ID;
                measurement.HistorianID     = configFrame.HistorianID;
                measurement.PointTag        = pointTag;
                measurement.AlternateTag    = analogDefinition.Label;
                measurement.Description     = $"{device.Acronym} Analog Value {index} {analogDefinition.AnalogType}: {analogDefinition.Label}{(string.IsNullOrWhiteSpace(analogDefinition.Description) ? "" : $" - {analogDefinition.Description}")}";
                measurement.SignalReference = newSignalReference;
                measurement.SignalTypeID    = analogSignalType.ID;
                measurement.Internal        = true;
                measurement.Enabled         = true;

                measurementTable.AddNewOrUpdateMeasurement(measurement);
            }
コード例 #22
0
        private void textBoxDeviceIDCode_TextChanged(object sender, TextChangedEventArgs e)
        {
            textBoxDeviceIDCode.Text = textBoxDeviceIDCode.Text.RemoveCharacters(c => !Char.IsDigit(c));

            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                ushort idCode;

                if (ushort.TryParse(textBoxDeviceIDCode.Text, out idCode))
                {
                    selectedDevice.IDCode = GenerateUniqueIDCode(idCode);
                }
                else
                {
                    textBoxDeviceIDCode.Text = GenerateUniqueIDCode((ushort)m_configurationFrame.Cells.Count).ToString();
                }
            }
        }
コード例 #23
0
ファイル: EditDetails.cs プロジェクト: lyrain2009/gsf
        private void ValidateChildDevice(TextBox targetTextBox, ConfigurationCell targetConfigCell)
        {
            string errorMessage = "";

            if (!ChildDeviceIsUnique(targetTextBox, targetConfigCell))
            {
                errorMessage = $"PMU acronym \"{targetTextBox.Text}\" already exists!";
            }

            if (!LocalIDCodeIsUnique(targetConfigCell.IDCode))
            {
                if (!string.IsNullOrWhiteSpace(errorMessage))
                {
                    errorMessage = $"{errorMessage.Substring(0, errorMessage.Length - 1)} and ";
                }

                errorMessage = $"{errorMessage}PMU \"{targetTextBox.Text}\" ID Code \"{targetConfigCell.IDCode}\" is not unique for this connection!";
            }

            errorProvider.SetError(targetTextBox, errorMessage);
        }
コード例 #24
0
        private void CopyDevice(ConfigurationCell sourceDevice)
        {
            // Create a new configuration cell to hold copied information
            ConfigurationCell copiedDevice = new ConfigurationCell(m_configurationFrame, 0);

            copiedDevice.IDCode      = (ushort)m_configurationFrame.Cells.Count;
            copiedDevice.StationName = "Device " + (copiedDevice.IDCode + 1);

            // Create equivalent derived phasor definitions
            foreach (PhasorDefinition sourcePhasor in sourceDevice.PhasorDefinitions)
            {
                copiedDevice.PhasorDefinitions.Add(new PhasorDefinition(copiedDevice, sourcePhasor.Label, sourcePhasor.ScalingValue, sourcePhasor.PhasorType, null));
            }

            // Create equivalent dervied frequency definition
            IFrequencyDefinition sourceFrequency = sourceDevice.FrequencyDefinition;

            if (sourceFrequency != null)
            {
                copiedDevice.FrequencyDefinition = new FrequencyDefinition(copiedDevice, sourceFrequency.Label);
            }

            // Create equivalent dervied analog definitions (assuming analog type = SinglePointOnWave)
            foreach (AnalogDefinition sourceAnalog in sourceDevice.AnalogDefinitions)
            {
                copiedDevice.AnalogDefinitions.Add(new AnalogDefinition(copiedDevice, sourceAnalog.Label, sourceAnalog.ScalingValue, sourceAnalog.AnalogType));
            }

            // Create equivalent dervied digital definitions
            foreach (DigitalDefinition sourceDigital in sourceDevice.DigitalDefinitions)
            {
                copiedDevice.DigitalDefinitions.Add(new DigitalDefinition(copiedDevice, sourceDigital.Label, sourceDigital.MaskValue));
            }

            // Add new copied cell to the list and select it
            m_configurationFrame.Cells.Add(copiedDevice);
            listBoxDevices.SelectedIndex = (m_configurationFrame.Cells.Count - 1);
        }
コード例 #25
0
        private void buttonPhasorCopy_Click(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

            if (selectedDevice != null)
            {
                if (listBoxPhasors.SelectedItems.Count > 0)
                {
                    IPhasorDefinition[] selectedPhasors = listBoxPhasors.SelectedItems.Cast <IPhasorDefinition>().ToArray();

                    foreach (IPhasorDefinition selectedPhasor in selectedPhasors)
                    {
                        if (selectedPhasor != null)
                        {
                            selectedDevice.PhasorDefinitions.Add(new PhasorDefinition(selectedDevice, "Phasor " + (selectedDevice.PhasorDefinitions.Count + 1), selectedPhasor.ScalingValue, selectedPhasor.PhasorType, null));
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No items were selected to copy.");
                }
            }
        }
コード例 #26
0
        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);
        }
コード例 #27
0
ファイル: Concentrator.cs プロジェクト: lyrain2009/gsf
        /// <summary>
        /// Creates a new BPA PDCstream specific <see cref="IConfigurationFrame"/> based on provided protocol independent <paramref name="baseConfigurationFrame"/>.
        /// </summary>
        /// <param name="baseConfigurationFrame">Protocol independent <see cref="GSF.PhasorProtocols.Anonymous.ConfigurationFrame"/>.</param>
        /// <returns>A new BPA PDCstream specific <see cref="IConfigurationFrame"/>.</returns>
        protected override IConfigurationFrame CreateNewConfigurationFrame(GSF.PhasorProtocols.Anonymous.ConfigurationFrame baseConfigurationFrame)
        {
            int count = 0;

            // Fix ID labels to use BPA PDCstream 4 character label
            foreach (GSF.PhasorProtocols.Anonymous.ConfigurationCell baseCell in baseConfigurationFrame.Cells)
            {
                baseCell.StationName = baseCell.IDLabel.TruncateLeft(baseCell.MaximumStationNameLength);
                baseCell.IDLabel     = DataSource.Tables["OutputStreamDevices"].Select($"IDCode={baseCell.IDCode}")[0]["BpaAcronym"].ToNonNullString(baseCell.IDLabel).TruncateLeft(4);

                // If no ID label was provided, we default to first 4 characters of station name
                if (string.IsNullOrEmpty(baseCell.IDLabel))
                {
                    string stationName = baseCell.StationName;
                    string pmuID       = count.ToString();

                    if (string.IsNullOrEmpty(stationName))
                    {
                        stationName = "PMU";
                    }

                    baseCell.IDLabel = stationName.Substring(0, 4 - pmuID.Length).ToUpper() + pmuID;
                }

                count++;
            }

            // Create a default INI file if one doesn't exist
            if (!File.Exists(IniFileName))
            {
                using (StreamWriter iniFile = File.CreateText(IniFileName))
                {
                    iniFile.Write(GSF.PhasorProtocols.BPAPDCstream.ConfigurationFrame.GetIniFileImage(baseConfigurationFrame));
                }
            }

            // Create a new BPA PDCstream configuration frame using base configuration
            ConfigurationFrame configurationFrame = new ConfigurationFrame(DateTime.UtcNow.Ticks, IniFileName, 1, RevisionNumber.Revision2, StreamType.Compact);

            foreach (GSF.PhasorProtocols.Anonymous.ConfigurationCell baseCell in baseConfigurationFrame.Cells)
            {
                // Create a new BPA PDCstream configuration cell (i.e., a PMU configuration)
                ConfigurationCell newCell = new ConfigurationCell(configurationFrame, baseCell.IDCode, NominalFrequency)
                {
                    // Update other cell level attributes
                    StationName            = baseCell.StationName,
                    IDLabel                = baseCell.IDLabel,
                    PhasorDataFormat       = DataFormat.FixedInteger,
                    PhasorCoordinateFormat = CoordinateFormat.Rectangular,
                    FrequencyDataFormat    = DataFormat.FixedInteger,
                    AnalogDataFormat       = DataFormat.FixedInteger
                };

                // Add phasor definitions
                foreach (IPhasorDefinition phasorDefinition in baseCell.PhasorDefinitions)
                {
                    newCell.PhasorDefinitions.Add(new PhasorDefinition(newCell, phasorDefinition.Label, phasorDefinition.ScalingValue, phasorDefinition.Offset, phasorDefinition.PhasorType, null));
                }

                // Add frequency definition
                newCell.FrequencyDefinition = new FrequencyDefinition(newCell, baseCell.FrequencyDefinition.Label);

                // Add analog definitions
                foreach (IAnalogDefinition analogDefinition in baseCell.AnalogDefinitions)
                {
                    newCell.AnalogDefinitions.Add(new AnalogDefinition(newCell, analogDefinition.Label, analogDefinition.ScalingValue, analogDefinition.Offset, analogDefinition.AnalogType));
                }

                // Add digital definitions
                foreach (IDigitalDefinition digitalDefinition in baseCell.DigitalDefinitions)
                {
                    newCell.DigitalDefinitions.Add(new DigitalDefinition(newCell, digitalDefinition.Label));
                }

                // Add new PMU configuration (cell) to protocol specific configuration frame
                configurationFrame.Cells.Add(newCell);
            }

            // Setup new configuration cells with their proper INI file settings
            configurationFrame.Refresh(true);

            // Cache new BPA PDCstream for later use
            Interlocked.Exchange(ref m_configurationFrame, configurationFrame);

            return(configurationFrame);
        }
コード例 #28
0
 public FrequencyDefinition(ConfigurationCell parent)
     : base(parent, null, 1000, 100, 0.0D)
 {
 }
コード例 #29
0
        public ConfigurationFrame ExtractConfigurationFrame(int deviceID)
        {
            Device device = QueryDeviceByID(deviceID);

            if (device.ID == 0)
            {
                return(new ConfigurationFrame());
            }

            ConfigurationFrame derivedFrame = new ConfigurationFrame
            {
                IDCode           = (ushort)device.AccessID,
                StationName      = device.Name,
                IDLabel          = device.Acronym,
                ConnectionString = device.ConnectionString,
                ProtocolID       = device.ProtocolID ?? IeeeC37_118ProtocolID
            };

            if ((device.FramesPerSecond ?? 0) > 0)
            {
                derivedFrame.FrameRate = (ushort)device.FramesPerSecond.GetValueOrDefault();
            }

            if (device.ParentID == null)
            {
                IEnumerable <Device> devices = QueryChildDevices(deviceID);

                foreach (Device childDevice in devices)
                {
                    // Create new configuration cell
                    ConfigurationCell derivedCell = new ConfigurationCell
                    {
                        ID          = childDevice.ID,
                        ParentID    = device.ID,
                        IDCode      = (ushort)childDevice.AccessID,
                        StationName = childDevice.Name,
                        IDLabel     = childDevice.Acronym
                    };

                    derivedCell.FrequencyDefinition = new FrequencyDefinition {
                        Label = "Frequency"
                    };

                    // Extract phasor definitions
                    foreach (Phasor phasor in QueryPhasorsForDevice(childDevice.ID))
                    {
                        derivedCell.PhasorDefinitions.Add(new PhasorDefinition {
                            ID = phasor.ID, Label = phasor.Label, PhasorType = phasor.Type == 'V' ? "Voltage" : "Current", Phase = phasor.Phase.ToString(), DestinationPhasorID = phasor.DestinationPhasorID, NominalVoltage = phasor.BaseKV, SourceIndex = phasor.SourceIndex
                        });
                    }

                    // Add cell to frame
                    derivedFrame.Cells.Add(derivedCell);
                }

                if (derivedFrame.Cells.Count > 0)
                {
                    derivedFrame.IsConcentrator = true;
                }
                else
                {
                    // This is a directly connected device
                    derivedFrame.IsConcentrator = false;

                    ConfigurationCell derivedCell = new ConfigurationCell
                    {
                        ID          = device.ID,
                        ParentID    = null,
                        IDCode      = derivedFrame.IDCode,
                        StationName = device.Name,
                        IDLabel     = device.Acronym
                    };

                    derivedCell.FrequencyDefinition = new FrequencyDefinition {
                        Label = "Frequency"
                    };

                    // Extract phasor definitions
                    foreach (Phasor phasor in QueryPhasorsForDevice(device.ID))
                    {
                        derivedCell.PhasorDefinitions.Add(new PhasorDefinition {
                            ID = phasor.ID, Label = phasor.Label, PhasorType = phasor.Type == 'V' ? "Voltage" : "Current", Phase = phasor.Phase.ToString(), DestinationPhasorID = phasor.DestinationPhasorID, NominalVoltage = phasor.BaseKV, SourceIndex = phasor.SourceIndex
                        });
                    }

                    // Add cell to frame
                    derivedFrame.Cells.Add(derivedCell);
                }
            }
            else
            {
                derivedFrame.IsConcentrator = true;

                // Create new configuration cell
                ConfigurationCell derivedCell = new ConfigurationCell
                {
                    ID          = device.ID,
                    ParentID    = null,
                    IDCode      = (ushort)device.AccessID,
                    StationName = device.Name,
                    IDLabel     = device.Acronym
                };

                derivedCell.FrequencyDefinition = new FrequencyDefinition {
                    Label = "Frequency"
                };

                // Extract phasor definitions
                foreach (Phasor phasor in QueryPhasorsForDevice(device.ID))
                {
                    derivedCell.PhasorDefinitions.Add(new PhasorDefinition {
                        ID = phasor.ID, Label = phasor.Label, PhasorType = phasor.Type == 'V' ? "Voltage" : "Current", Phase = phasor.Phase.ToString(), DestinationPhasorID = phasor.DestinationPhasorID, NominalVoltage = phasor.BaseKV, SourceIndex = phasor.SourceIndex
                    });
                }

                // Add cell to frame
                derivedFrame.Cells.Add(derivedCell);
            }

            return(derivedFrame);
        }
コード例 #30
0
        /// <summary>
        /// Attempts to retrieve a <see cref="ConfigurationCell"/> from this <see cref="ConfigurationCellCollection"/> with the specified <paramref name="sectionEntry"/>.
        /// </summary>
        /// <param name="sectionEntry"><see cref="ConfigurationCell.SectionEntry"/> value to try to find.</param>
        /// <param name="configurationCell"><see cref="ConfigurationCell"/> with the specified <paramref name="sectionEntry"/> if found; otherwise <c>null</c>.</param>
        /// <returns><c>true</c> if <see cref="ConfigurationCell"/> with the specified <paramref name="sectionEntry"/> is found; otherwise <c>false</c>.</returns>
        public bool TryGetBySectionEntry(string sectionEntry, ref ConfigurationCell configurationCell)
        {
            for (int i = 0; i < Count; i++)
            {
                configurationCell = this[i];
                if (string.Compare(configurationCell.SectionEntry, sectionEntry, true) == 0)
                    return true;
            }

            configurationCell = null;
            return false;
        }
コード例 #31
0
        public ConfigurationFrame LoadConfigurationFrame(string sourceData)
        {
            string connectionString = "";

            IConfigurationFrame GetConfigurationFrame()
            {
                try
                {
                    ConnectionSettings connectionSettings;
                    SoapFormatter      formatter = new SoapFormatter
                    {
                        AssemblyFormat = FormatterAssemblyStyle.Simple,
                        TypeFormat     = FormatterTypeStyle.TypesWhenNeeded,
                        Binder         = Serialization.LegacyBinder
                    };

                    using (MemoryStream source = new MemoryStream(Encoding.UTF8.GetBytes(sourceData)))
                        connectionSettings = formatter.Deserialize(source) as ConnectionSettings;

                    if ((object)connectionSettings != null)
                    {
                        connectionString = connectionSettings.ConnectionString;

                        Dictionary <string, string> connectionStringKeyValues = connectionString.ParseKeyValuePairs();

                        connectionString = "transportProtocol=" + connectionSettings.TransportProtocol + ";" + connectionStringKeyValues.JoinKeyValuePairs();

                        if ((object)connectionSettings.ConnectionParameters != null)
                        {
                            switch (connectionSettings.PhasorProtocol)
                            {
                            case PhasorProtocol.BPAPDCstream:
                                GSF.PhasorProtocols.BPAPDCstream.ConnectionParameters bpaParameters = connectionSettings.ConnectionParameters as GSF.PhasorProtocols.BPAPDCstream.ConnectionParameters;
                                if ((object)bpaParameters != null)
                                {
                                    connectionString += "; iniFileName=" + bpaParameters.ConfigurationFileName + "; refreshConfigFileOnChange=" + bpaParameters.RefreshConfigurationFileOnChange + "; parseWordCountFromByte=" + bpaParameters.ParseWordCountFromByte;
                                }
                                break;

                            case PhasorProtocol.FNET:
                                GSF.PhasorProtocols.FNET.ConnectionParameters fnetParameters = connectionSettings.ConnectionParameters as GSF.PhasorProtocols.FNET.ConnectionParameters;
                                if ((object)fnetParameters != null)
                                {
                                    connectionString += "; timeOffset=" + fnetParameters.TimeOffset + "; stationName=" + fnetParameters.StationName + "; frameRate=" + fnetParameters.FrameRate + "; nominalFrequency=" + (int)fnetParameters.NominalFrequency;
                                }
                                break;

                            case PhasorProtocol.SelFastMessage:
                                GSF.PhasorProtocols.SelFastMessage.ConnectionParameters selParameters = connectionSettings.ConnectionParameters as GSF.PhasorProtocols.SelFastMessage.ConnectionParameters;
                                if ((object)selParameters != null)
                                {
                                    connectionString += "; messagePeriod=" + selParameters.MessagePeriod;
                                }
                                break;

                            case PhasorProtocol.IEC61850_90_5:
                                GSF.PhasorProtocols.IEC61850_90_5.ConnectionParameters iecParameters = connectionSettings.ConnectionParameters as GSF.PhasorProtocols.IEC61850_90_5.ConnectionParameters;
                                if ((object)iecParameters != null)
                                {
                                    connectionString += "; useETRConfiguration=" + iecParameters.UseETRConfiguration + "; guessConfiguration=" + iecParameters.GuessConfiguration + "; parseRedundantASDUs=" + iecParameters.ParseRedundantASDUs + "; ignoreSignatureValidationFailures=" + iecParameters.IgnoreSignatureValidationFailures + "; ignoreSampleSizeValidationFailures=" + iecParameters.IgnoreSampleSizeValidationFailures;
                                }
                                break;

                            case PhasorProtocol.Macrodyne:
                                GSF.PhasorProtocols.Macrodyne.ConnectionParameters macrodyneParameters = connectionSettings.ConnectionParameters as GSF.PhasorProtocols.Macrodyne.ConnectionParameters;
                                if ((object)macrodyneParameters != null)
                                {
                                    connectionString += "; protocolVersion=" + macrodyneParameters.ProtocolVersion + "; iniFileName=" + macrodyneParameters.ConfigurationFileName + "; refreshConfigFileOnChange=" + macrodyneParameters.RefreshConfigurationFileOnChange + "; deviceLabel=" + macrodyneParameters.DeviceLabel;
                                }
                                break;
                            }
                        }

                        connectionString += "; accessID=" + connectionSettings.PmuID;
                        connectionString += "; phasorProtocol=" + connectionSettings.PhasorProtocol;

                        using (CommonPhasorServices phasorServices = new CommonPhasorServices())
                        {
                            phasorServices.StatusMessage    += (sender, e) => LogStatusMessage(e.Argument.Replace("**", ""));
                            phasorServices.ProcessException += (sender, e) => LogException(e.Argument);
                            return(phasorServices.RequestDeviceConfiguration(connectionString));
                        }
                    }

                    using (MemoryStream source = new MemoryStream(Encoding.UTF8.GetBytes(sourceData)))
                        return(formatter.Deserialize(source) as IConfigurationFrame);
                }
                catch
                {
                    return(new ConfigurationErrorFrame());
                }
            }

            IConfigurationFrame sourceFrame = GetConfigurationFrame();

            if (sourceFrame is ConfigurationErrorFrame)
            {
                return(new ConfigurationFrame());
            }

            ConfigurationFrame derivedFrame;

            // 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"]);
            }

            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);
        }
コード例 #32
0
ファイル: PhasorDefinition.cs プロジェクト: rmc00/gsf
 /// <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="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, PhasorType type, PhasorDefinition voltageReference)
     : base(parent, label, 1, 0.0D, type, voltageReference)
 {
 }
コード例 #33
0
 /// <summary>
 /// Creates a new <see cref="DigitalDefinition"/> from specified parameters.
 /// </summary>
 /// <param name="parent">The <see cref="ConfigurationCell"/> parent of this <see cref="DigitalDefinition"/>.</param>
 /// <param name="label">The label of this <see cref="DigitalDefinition"/>.</param>
 public DigitalDefinition(ConfigurationCell parent, string label)
     : base(parent, label)
 {
 }
コード例 #34
0
ファイル: EditDetails.cs プロジェクト: lyrain2009/gsf
 private bool ChildDeviceIsUnique(TextBox targetTextBox, ConfigurationCell targetConfigCell) =>
 targetConfigCell.Delete ||
 ImportParams.DeviceTable.ChildDeviceIsUnique(TargetConfigFrame.ID, targetTextBox.Text, targetConfigCell.IDCode) &&
 LocalAcronymIsUnique(targetTextBox.Text);
コード例 #35
0
 private static void DeletePMUDevice(ImportParameters importParams, ConfigurationCell configCell, Device parentDevice) =>
 s_devices.DeleteChildDeviceByIDCode(importParams.DeviceTable, parentDevice.ID, configCell.IDCode);
コード例 #36
0
ファイル: PhasorDefinition.cs プロジェクト: rmc00/gsf
        /// <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 != 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)
                Ratio = double.Parse(entry[1].Trim());
            else
                Ratio = defaultPhasor.Ratio;

            if (entry.Length > 2)
                CalFactor = double.Parse(entry[2].Trim());
            else
                ConversionFactor = defaultPhasor.ConversionFactor;

            if (entry.Length > 3)
                Offset = double.Parse(entry[3].Trim());
            else
                Offset = defaultPhasor.Offset;

            if (entry.Length > 4)
                Shunt = double.Parse(entry[4].Trim());
            else
                Shunt = defaultPhasor.Shunt;

            if (entry.Length > 5)
                VoltageReferenceIndex = (int)double.Parse(entry[5].Trim());
            else
                VoltageReferenceIndex = defaultPhasor.VoltageReferenceIndex;

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

            this.Index = index;
        }