Ejemplo n.º 1
0
        private void _deleteAdatawriter(object obj)
        {
            // Delete step
            DataWriterViewModel stepRemove = (DataWriterViewModel)obj;

            if (MessageBox.Show("Delete data writer " + stepRemove.StepCounter.ToString() + "?", "Warning!", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                // Try to delete current step
                try
                {
                    DataWriters.Remove(stepRemove);
                    foreach (var step in DataWriters)
                    {
                        if (step.StepCounter > stepRemove.StepCounter)
                        {
                            step.StepCounter -= 1;
                        }
                    }
                    Model.DataWriters.Remove(stepRemove.Model);
                }
                catch (Exception)
                {
                    MessageBox.Show("Error deleting a data writer");
                }
                // Select a different step?
                if (SelectedStep != null)
                {
                    SelectedStep.IsSelected = false;
                    SelectedStep            = null;
                }
            }
        }
Ejemplo n.º 2
0
        private void _dataWriterSelected(object obj)
        {
            DataWriterViewModel step = obj as DataWriterViewModel;

            if (SelectedStep != step)
            {
                if (SelectedStep != null)
                {
                    SelectedStep.ThisStepInputsGroupedByType.SignalList = SampleDataMngr.SortSignalsByType(SelectedStep.InputChannels);
                    SelectedStep.IsSelected = false;
                }
                var lastNmberOfSteps           = step.StepCounter;
                var stepsInputAsSignalHierachy = new ObservableCollection <SignalTree>();
                foreach (var sig in DataWriters)
                {
                    if (sig.StepCounter < lastNmberOfSteps)
                    {
                        stepsInputAsSignalHierachy.Add(sig.ThisStepInputsGroupedByType);
                    }
                    else
                    {
                        break;
                    }
                }
                step.IsSelected = true;
                SelectedStep    = step;
                SampleDataMngr.GroupedSignalByDataWriterStepsInput = stepsInputAsSignalHierachy;
                SampleDataMngr.DetermineCheckStatusOfGroupedSignals();
            }
        }
Ejemplo n.º 3
0
        private void _addDataWriter(object obj)
        {
            var newWriter = new DataWriterViewModel();

            newWriter.StepCounter = DataWriters.Count + 1;
            newWriter.ThisStepInputsGroupedByType = new SignalTree("Step " + newWriter.StepCounter.ToString() + " _ " + newWriter.Name);
            newWriter.ThisStepOutputsGroupedByPMU = new SignalTree("Step " + newWriter.StepCounter.ToString() + " _ " + newWriter.Name);
            SampleDataMngr.GroupedSignalByDataWriterStepsInput.Add(newWriter.ThisStepInputsGroupedByType);
            DataWriters.Add(newWriter);
            Model.DataWriters.Add(newWriter.Model);
            _dataWriterSelected(newWriter);
        }
Ejemplo n.º 4
0
 public void ReadConfigFile(string configFile)
 {
     using (StreamReader reader = File.OpenText(configFile))
     {
         JsonSerializer serializer = new JsonSerializer();
         var            config     = (SettingsViewModel)serializer.Deserialize(reader, typeof(SettingsViewModel));
         WindowOverlapStr          = config.WindowOverlapStr;
         WindowSizeStr             = config.WindowSizeStr;
         DataSourceVM              = config.DataSourceVM;
         DatawriteOutFrequencyStr  = config.DatawriteOutFrequencyStr;
         DatawriteOutFrequencyUnit = config.DatawriteOutFrequencyUnit;
         //SignatureOutputDir = config.SignatureOutputDir;
         PreProcessSteps   = new ObservableCollection <PreProcessStepViewModel>();
         SignatureSettings = new ObservableCollection <SignatureSettingViewModel>();
         DataWriters       = new ObservableCollection <DataWriterViewModel>();
         DateTimeStart     = config.DateTimeStart;
         DateTimeEnd       = config.DateTimeEnd;
         foreach (var pre in config.PreProcessSteps)
         {
             var newStep = new PreProcessStepViewModel(pre.Name);
             newStep.StepCounter = PreProcessSteps.Count + 1;
             PreProcessSteps.Add(newStep);
             if (newStep.Model is VoltPhasorFilt)
             {
                 newStep.NomVoltage = pre.NomVoltage;
                 newStep.VoltMin    = pre.VoltMin;
                 newStep.VoltMax    = pre.VoltMax;
             }
             if (newStep.Model is FreqFilt)
             {
                 newStep.FreqMaxChan = pre.FreqMaxChan;
                 newStep.FreqMinChan = pre.FreqMinChan;
                 newStep.FreqPctChan = pre.FreqPctChan;
                 newStep.FreqMaxSamp = pre.FreqMaxSamp;
                 newStep.FreqMinSamp = pre.FreqMinSamp;
             }
             // take care of all input output signals
             foreach (var sig in pre.InputChannels)
             {
                 var foundSig = SampleDataMngr.FindSignal(sig.PMUName, sig.SignalName);
                 if (foundSig != null)
                 {
                     newStep.AddSignal(foundSig);
                 }
             }
             //if (newStep.Model is Filter)
             //{
             //    newStep.OutputChannels = newStep.InputChannels;
             //}
             //else
             //{
             //    foreach (var sig in newStep.InputChannels)
             //    {
             //        // need to make up output signals from each input, which might depends on different customization and all differ
             //    }
             //}
             newStep.ThisStepInputsGroupedByType            = new SignalTree("Step " + newStep.StepCounter.ToString() + " _ " + newStep.Name);
             newStep.ThisStepOutputsGroupedByPMU            = new SignalTree("Step " + newStep.StepCounter.ToString() + " _ " + newStep.Name);
             newStep.ThisStepOutputsGroupedByPMU.SignalList = SampleDataMngr.SortSignalByPMU(newStep.OutputChannels);
             newStep.ThisStepInputsGroupedByType.SignalList = SampleDataMngr.SortSignalsByType(newStep.InputChannels);
             SampleDataMngr.GroupedSignalByPreProcessStepsInput.Add(newStep.ThisStepInputsGroupedByType);
             if (newStep.Model is Customization)
             {
                 SampleDataMngr.GroupedSignalByPreProcessStepsOutput.Add(newStep.ThisStepOutputsGroupedByPMU);
             }
         }
         foreach (var signature in config.SignatureSettings)
         {
             var newSig = new SignatureSettingViewModel(signature.SignatureName);
             newSig.WindowOverlapStr = WindowOverlapStr;
             newSig.WindowSizeStr    = WindowSizeStr;
             newSig.StepCounter      = SignatureSettings.Count + 1;
             newSig.OmitNan          = signature.OmitNan;
             if (newSig.Model is RootMeanSquare)
             {
                 newSig.RemoveMean = signature.RemoveMean;
             }
             if (newSig.Model is FrequencyBandRMS)
             {
                 newSig.CalculateFull  = signature.CalculateFull;
                 newSig.CalculateBand2 = signature.CalculateBand2;
                 newSig.CalculateBand3 = signature.CalculateBand3;
                 newSig.CalculateBand4 = signature.CalculateBand4;
                 newSig.Threshold      = signature.Threshold;
             }
             if (newSig.Model is Percentile)
             {
                 newSig.PercentileStr = signature.PercentileStr;
             }
             if (newSig.Model is Histogram)
             {
                 newSig.Minimum      = signature.Minimum;
                 newSig.Maximum      = signature.Maximum;
                 newSig.NumberOfBins = signature.NumberOfBins;
             }
             SignatureSettings.Add(newSig);
             Model.SignatureSettings.Add(newSig.Model);
             foreach (var sig in signature.InputChannels)
             {
                 var foundSig = SampleDataMngr.FindSignal(sig.PMUName, sig.SignalName);
                 if (foundSig != null)
                 {
                     newSig.InputChannels.Add(foundSig);
                 }
             }
             newSig.ThisStepInputsGroupedByType = new SignalTree("Step " + newSig.StepCounter.ToString() + " _ " + newSig.SignatureName);
             //newStep.ThisStepOutputsGroupedByPMU.SignalList = SampleDataMngr.SortSignalByPMU(newStep.OutputChannels);
             newSig.ThisStepInputsGroupedByType.SignalList = SampleDataMngr.SortSignalsByType(newSig.InputChannels);
             SampleDataMngr.GroupedSignalBySignatureStepsInput.Add(newSig.ThisStepInputsGroupedByType);
             //if (newStep.Model is Customization)
             //{
             //    SampleDataMngr.GroupedSignalByPreProcessStepsOutput.Add(newStep.ThisStepOutputsGroupedByPMU);
             //}
         }
         foreach (var writer in config.DataWriters)
         {
             var newWriter = new DataWriterViewModel(writer.Name);
             newWriter.StepCounter  = DataWriters.Count + 1;
             newWriter.Mnemonic     = writer.Mnemonic;
             newWriter.SeparatePMUs = writer.SeparatePMUs;
             newWriter.SavePath     = writer.SavePath;
             DataWriters.Add(newWriter);
             Model.DataWriters.Add(newWriter.Model);
             foreach (var sig in writer.InputChannels)
             {
                 var foundSig = SampleDataMngr.FindSignal(sig.PMUName, sig.SignalName);
                 if (foundSig != null)
                 {
                     newWriter.InputChannels.Add(foundSig);
                 }
             }
             newWriter.ThisStepInputsGroupedByType            = new SignalTree(newWriter.Name + " " + newWriter.StepCounter.ToString());
             newWriter.ThisStepInputsGroupedByType.SignalList = SampleDataMngr.SortSignalsByType(newWriter.InputChannels);
             SampleDataMngr.GroupedSignalByDataWriterStepsInput.Add(newWriter.ThisStepInputsGroupedByType);
         }
     }
 }