public MeasurementSampleDetailViewModel(object measurementSample)
 {
     if (measurementSample != null && measurementSample is RawMeasurements)
     {
         m_measurementSample = measurementSample as RawMeasurements;
     }
 }
Exemplo n.º 2
0
        private void ClearTestCaseButton_Click(object sender, EventArgs e)
        {
            // GOT IT
            DisableControls();

            // Clear Raw Measurements
            m_rawMeasurements = new RawMeasurements();
            RawMeasurementsTextBox.Enabled      = true;
            RawMeasurementsTextBox.Text         = "";
            BrowseRawMeasurementsButton.Enabled = true;

            // Clear Network Model
            m_network = null;
            m_networkIsInitialized           = false;
            NetworkModelTextBox.Enabled      = true;
            NetworkModelTextBox.Text         = "";
            BrowseNetworkModelButton.Enabled = true;

            m_measurementsAreMapped = false;
            m_activeCurrentFlowsHaveBeenDetermined = false;
            m_observedBussesHaveBeenResolved       = false;
            m_stateWasComputed = false;

            StatusLabel.Text = "Test case cleared.";
        }
        public override void Initialize()
        {
            base.Initialize();
            m_rawMeasurements = new RawMeasurements();

            Dictionary <string, string> settings = Settings;
            string setting;

            if (settings.TryGetValue("RawMeasurementsPathName", out setting))
            {
                m_rawMeasurementsPathName = setting;
                OnStatusMessage("Loaded RawMeasurementsPathName: " + setting);
            }
            else
            {
                m_rawMeasurementsFileNamePrefix = "RawMeasurements"; //bug
            }
            if (settings.TryGetValue("RawMeasurementsFileNamePrefix", out setting))
            {
                m_rawMeasurementsFileNamePrefix = setting;
                OnStatusMessage("Loaded RawMeasurementsFileNamePrefix: " + setting);
            }
            else
            {
                m_rawMeasurementsFileNamePrefix = "RawMeasurements";
            }
            if (settings.TryGetValue("UseUtcInFileNameTimestamp", out setting))
            {
                m_useUtcInFileName = Convert.ToBoolean(setting);
                OnStatusMessage("Loaded UseUtcInFileNameTimestamp: " + setting);
            }
            if (settings.TryGetValue("SnapshotPeriodicity", out setting))
            {
                m_snapshotPeriodicity = Convert.ToInt16(setting);
            }
            else
            {
                m_snapshotPeriodicity = 1; // hourly  // default: 3600  // bug
            }
            if (settings.TryGetValue("ExecutePeriodically", out setting))
            {
                m_takePeriodicSnapshots = Convert.ToBoolean(setting);
                OnStatusMessage("Loaded ExecutePeriodically: " + setting);
            }
            else
            {
                m_takePeriodicSnapshots = true;
            }

            m_totalFrames = 0;
        }
        public OfflineModule()
        {
            m_rawMeasurements = null;
            m_network         = null;

            m_networkIsInitialized  = false;
            m_measurementsAreMapped = false;
            m_activeCurrentFlowsHaveBeenDetermined = false;
            m_observedBussesHaveBeenResolved       = false;
            m_stateWasComputed = false;

            InitializeComponent();

            DisableControls();
        }
 private void UploadRawMeasurementsButton_Click(object sender, EventArgs e)
 {
     try
     {
         XmlSerializer deserializer = new XmlSerializer(typeof(RawMeasurements));
         StreamReader  reader       = new StreamReader(RawMeasurementsTextBox.Text);
         m_rawMeasurements = (RawMeasurements)deserializer.Deserialize(reader);
         reader.Close();
         StatusLabel.Text = "Raw measurements loaded successfully.";
         RawMeasurementsTextBox.Enabled      = false;
         BrowseRawMeasurementsButton.Enabled = false;
         EnableControls();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.ToString(), "Error!");
     }
 }
Exemplo n.º 6
0
        public void Execute()
        {
            if (ShouldTakeSample)
            {
                List <RawMeasurementsMeasurement> measurements = new List <RawMeasurementsMeasurement>();

                for (int i = 0; i < InputData.Digitals.Values.Length; i++)
                {
                    Guid   key   = InputMeta.Digitals.Values[i].ID;
                    string value = InputData.Digitals.Values[i].ToString();

                    if (key != Guid.Empty)
                    {
                        measurements.Add(new RawMeasurementsMeasurement()
                        {
                            Key   = key.ToString(),
                            Value = value
                        });
                    }
                }

                for (int i = 0; i < InputData.StatusWords.Values.Length; i++)
                {
                    Guid   key   = InputMeta.StatusWords.Values[i].ID;
                    string value = InputData.StatusWords.Values[i].ToString();

                    if (key != Guid.Empty)
                    {
                        measurements.Add(new RawMeasurementsMeasurement()
                        {
                            Key   = key.ToString(),
                            Value = value
                        });
                    }
                }

                for (int i = 0; i < InputData.VoltagePhasors.Phasors.Length; i++)
                {
                    Guid   magnitudeKey = InputMeta.VoltagePhasors.Phasors[i].Magnitude.ID;
                    string magnitude    = InputData.VoltagePhasors.Phasors[i].Magnitude.ToString();
                    Guid   angleKey     = InputMeta.VoltagePhasors.Phasors[i].Angle.ID;
                    string angle        = InputData.VoltagePhasors.Phasors[i].Angle.ToString();

                    if (magnitudeKey != Guid.Empty)
                    {
                        measurements.Add(new RawMeasurementsMeasurement()
                        {
                            Key   = magnitudeKey.ToString(),
                            Value = magnitude
                        });
                    }
                    if (angleKey != Guid.Empty)
                    {
                        measurements.Add(new RawMeasurementsMeasurement()
                        {
                            Key   = angleKey.ToString(),
                            Value = angle
                        });
                    }
                }

                for (int i = 0; i < InputData.CurrentPhasors.Phasors.Length; i++)
                {
                    Guid   magnitudeKey = InputMeta.CurrentPhasors.Phasors[i].Magnitude.ID;
                    string magnitude    = InputData.CurrentPhasors.Phasors[i].Magnitude.ToString();
                    Guid   angleKey     = InputMeta.CurrentPhasors.Phasors[i].Angle.ID;
                    string angle        = InputData.CurrentPhasors.Phasors[i].Angle.ToString();

                    if (magnitudeKey != Guid.Empty)
                    {
                        measurements.Add(new RawMeasurementsMeasurement()
                        {
                            Key   = magnitudeKey.ToString(),
                            Value = magnitude
                        });
                    }
                    if (angleKey != Guid.Empty)
                    {
                        measurements.Add(new RawMeasurementsMeasurement()
                        {
                            Key   = angleKey.ToString(),
                            Value = angle
                        });
                    }
                }

                RawMeasurements sample = new RawMeasurements();
                sample.Items = measurements.ToArray();

                (m_analyticHost as IAnalyticHost).AddMeasurementSample(sample);
                string message = GetStatusWordsStatisticsMessage(InputData, InputMeta);
                message += GetDigialsStatisticsMessage(InputData, InputMeta);
                message += GetVoltagePhasorStatisticsMessage(InputData, InputMeta);
                message += GetCurrentPhasorStatisticsMessage(InputData, InputMeta);
                (m_analyticHost as IAnalyticHost).CommunicationStatus = message;
                ShouldTakeSample = false;
            }
        }