Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new <see cref="PhasorDefinitionBase"/> 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 PhasorDefinitionBase(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     // Deserialize phasor definition
     m_type = (PhasorType)info.GetValue("type", typeof(PhasorType));
     m_voltageReference = (IPhasorDefinition)info.GetValue("voltageReference", typeof(IPhasorDefinition));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="PhasorDefinitionBase"/> from specified parameters.
        /// </summary>
        /// <param name="parent">The <see cref="IConfigurationCell"/> parent of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="label">The label of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="scale">The integer scaling value of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="offset">The offset of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="type">The <see cref="PhasorType"/> of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="voltageReference">The associated <see cref="IPhasorDefinition"/> that represents the voltage reference (if any).</param>
        protected PhasorDefinitionBase(IConfigurationCell parent, string label, uint scale, double offset, PhasorType type, IPhasorDefinition voltageReference)
            : base(parent, label, scale, offset)
        {
            m_type = type;

            if (type == PhasorType.Voltage)
                m_voltageReference = this;
            else
                m_voltageReference = voltageReference;
        }
Ejemplo n.º 3
0
        private void buttonPhasorMoveUp_Click(object sender, RoutedEventArgs e)
        {
            ConfigurationCell selectedDevice = this.SelectedDevice;

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

                if (selectedIndex > 0 && selectedIndex < selectedDevice.PhasorDefinitions.Count)
                {
                    IPhasorDefinition selectedPhasor = selectedDevice.PhasorDefinitions[selectedIndex];
                    selectedDevice.PhasorDefinitions.RemoveAt(selectedIndex);
                    selectedDevice.PhasorDefinitions.Insert(selectedIndex - 1, selectedPhasor);
                    listBoxPhasors.SelectedIndex = selectedIndex - 1;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new <see cref="PhasorDefinition3"/> from specified parameters.
        /// </summary>
        /// <param name="parent">The <see cref="ConfigurationCell3"/> parent of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="label">The label of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="scale">The integer scaling value of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="offset">The offset of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="type">The <see cref="PhasorType"/> of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="voltageReference">The associated <see cref="IPhasorDefinition"/> that represents the voltage reference (if any).</param>
        /// <param name="phase">The phase of this <see cref="PhasorDefinition3"/>.</param>
        public PhasorDefinition3(ConfigurationCell3 parent, string label, uint scale, double offset, PhasorType type, PhasorDefinition3 voltageReference, char phase)
            : base(parent, label, scale, offset)
        {
            PhasorType         = type;
            m_voltageReference = type == PhasorType.Voltage ? this : voltageReference;

            PhasorComponent = phase switch
            {
                'A' => PhasorComponent.PhaseA,
                'B' => PhasorComponent.PhaseB,
                'C' => PhasorComponent.PhaseC,
                '+' => PhasorComponent.PositiveSequence,
                '-' => PhasorComponent.NegativeSequence,
                '0' => PhasorComponent.ZeroSequence,
                _ => PhasorComponent.PositiveSequence,// If phase is not a value IEEE C37.118-2011 supports, default to positive sequence
            };
        }
        private void SavePhasorMeasurement(SignalType signalType, Device device, IPhasorDefinition phasorDefinition, char phase, int index, int baseKV, TableOperations <Measurement> measurementTable, ScanParameters scanParams)
        {
            string signalReference = $"{device.Acronym}-{signalType.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(signalReference);
            string      pointTag    = scanParams.CreatePhasorPointTag(device.Acronym, signalType.Acronym, phasorDefinition.Label, phase.ToString(), index, baseKV);

            measurement.DeviceID          = device.ID;
            measurement.PointTag          = pointTag;
            measurement.Description       = $"{device.Acronym} {phasorDefinition.Label} {signalType.Name}";
            measurement.PhasorSourceIndex = index;
            measurement.SignalReference   = signalReference;
            measurement.SignalTypeID      = signalType.ID;
            measurement.Internal          = true;
            measurement.Enabled           = true;

            measurementTable.AddNewOrUpdateMeasurement(measurement);
        }
Ejemplo n.º 6
0
        private void textBoxPhasorOffset_TextChanged(object sender, TextChangedEventArgs e)
        {
            textBoxPhasorOffset.Text = textBoxPhasorOffset.Text.RemoveCharacters(c => !Char.IsNumber(c) && c != '.' && c != '+' && c != '-');

            IPhasorDefinition selectedPhasor = this.SelectedPhasor;

            if (selectedPhasor != null)
            {
                double offset;

                if (double.TryParse(textBoxPhasorOffset.Text, out offset))
                {
                    selectedPhasor.Offset = offset;
                }
                else
                {
                    textBoxPhasorOffset.Text = "0";
                }
            }
        }
Ejemplo n.º 7
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("");
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new <see cref="PhasorDefinition3"/> from specified parameters.
        /// </summary>
        /// <param name="parent">The <see cref="ConfigurationCell3"/> parent of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="label">The label of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="scale">The integer scaling value of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="offset">The offset of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="type">The <see cref="PhasorType"/> of this <see cref="PhasorDefinition3"/>.</param>
        /// <param name="voltageReference">The associated <see cref="IPhasorDefinition"/> that represents the voltage reference (if any).</param>
        /// <param name="phase">The phase of this <see cref="PhasorDefinition3"/>.</param>
        public PhasorDefinition3(ConfigurationCell3 parent, string label, uint scale, double offset, PhasorType type, PhasorDefinition3 voltageReference, char phase)
            : base(parent, label, scale, offset)
        {
            PhasorType         = type;
            m_voltageReference = type == PhasorType.Voltage ? this : voltageReference;

            switch (phase)
            {
            case 'A':
                PhasorComponent = PhasorComponent.PhaseA;
                break;

            case 'B':
                PhasorComponent = PhasorComponent.PhaseB;
                break;

            case 'C':
                PhasorComponent = PhasorComponent.PhaseC;
                break;

            case '+':
                PhasorComponent = PhasorComponent.PositiveSequence;
                break;

            case '-':
                PhasorComponent = PhasorComponent.NegativeSequence;
                break;

            case '0':
                PhasorComponent = PhasorComponent.ZeroSequence;
                break;

            default:
                // If phase is not a value IEEE C37.118-2011 supports, default to positive sequence
                PhasorComponent = PhasorComponent.PositiveSequence;
                break;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new <see cref="PhasorDefinitionBase"/> from specified parameters.
        /// </summary>
        /// <param name="parent">The <see cref="IConfigurationCell"/> parent of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="label">The label of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="scale">The integer scaling value of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="offset">The offset of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="type">The <see cref="PhasorType"/> of this <see cref="PhasorDefinitionBase"/>.</param>
        /// <param name="voltageReference">The associated <see cref="IPhasorDefinition"/> that represents the voltage reference (if any).</param>
        protected PhasorDefinitionBase(IConfigurationCell parent, string label, uint scale, double offset, PhasorType type, IPhasorDefinition voltageReference)
            : base(parent, label, scale, offset)
        {
            m_type = type;

            if (type == PhasorType.Voltage)
            {
                m_voltageReference = this;
            }
            else
            {
                m_voltageReference = voltageReference;
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a new <see cref="PhasorValue"/>.
 /// </summary>
 /// <param name="parent">The <see cref="IDataCell"/> parent of this <see cref="PhasorValue"/>.</param>
 /// <param name="phasorDefinition">The <see cref="IPhasorDefinition"/> associated with this <see cref="PhasorValue"/>.</param>
 public PhasorValue(IDataCell parent, IPhasorDefinition phasorDefinition)
     : base(parent, phasorDefinition)
 {
 }
Ejemplo n.º 11
0
        // Static Methods

        // Delegate handler to create a new IEEE C37.118 phasor value
        internal static IPhasorValue CreateNewValue(IDataCell parent, IPhasorDefinition definition, byte[] buffer, int startIndex, out int parsedLength)
        {
            IPhasorValue phasor = new PhasorValue(parent, definition);

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

            return phasor;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a new <see cref="PhasorValue"/>.
 /// </summary>
 /// <param name="parent">The <see cref="IDataCell"/> parent of this <see cref="PhasorValue"/>.</param>
 /// <param name="phasorDefinition">The <see cref="IPhasorDefinition"/> associated with this <see cref="PhasorValue"/>.</param>
 public PhasorValue(IDataCell parent, IPhasorDefinition phasorDefinition)
     : base(parent, phasorDefinition)
 {
 }
Ejemplo n.º 13
0
        // Static Methods

        // Calculates binary length of a phasor value based on its definition
        internal static uint CalculateBinaryLength(IPhasorDefinition definition)
        {
            // The phasor definition will determine the binary length based on data format
            return (uint)(new PhasorValue(null, definition)).BinaryLength;
        }
Ejemplo n.º 14
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 "";
        }
Ejemplo n.º 15
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;

            return "";
        }
Ejemplo n.º 16
0
        // Static Methods

        // Calculates binary length of a phasor value based on its definition
        internal static uint CalculateBinaryLength(IPhasorDefinition definition)
        {
            // The phasor definition will determine the binary length based on data format
            return((uint)(new PhasorValue(null, definition)).BinaryLength);
        }