private void _signatureStepSelected(object obj) { SignatureSettingViewModel step = obj as SignatureSettingViewModel; 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 SignatureSettings) { if (sig.StepCounter < lastNmberOfSteps) { stepsInputAsSignalHierachy.Add(sig.ThisStepInputsGroupedByType); } else { break; } } step.IsSelected = true; SelectedStep = step; SampleDataMngr.GroupedSignalBySignatureStepsInput = stepsInputAsSignalHierachy; SampleDataMngr.DetermineCheckStatusOfGroupedSignals(); } }
private void _deleteASignatureStep(object obj) { // Delete step SignatureSettingViewModel stepRemove = (SignatureSettingViewModel)obj; if (MessageBox.Show("Delete step " + stepRemove.StepCounter.ToString() + " in signature calculation: " + stepRemove.SignatureName + "?", "Warning!", MessageBoxButtons.OKCancel) == DialogResult.OK) { // Try to delete current step try { SignatureSettings.Remove(stepRemove); foreach (var step in SignatureSettings) { if (step.StepCounter > stepRemove.StepCounter) { step.StepCounter -= 1; } } Model.SignatureSettings.Remove(stepRemove.Model); } catch (Exception) { MessageBox.Show("Error deleting step"); } // Select a different step? if (SelectedStep != null) { SelectedStep.IsSelected = false; SelectedStep = null; } } }
private void _addASignatureStep(object obj) { var sig = ((SignatureCalMenu)obj).Signature; var newSig = new SignatureSettingViewModel(sig); newSig.WindowOverlapStr = WindowOverlapStr; newSig.WindowSizeStr = WindowSizeStr; newSig.StepCounter = SignatureSettings.Count + 1; newSig.ThisStepInputsGroupedByType = new SignalTree("Step " + newSig.StepCounter.ToString() + " _ " + newSig.SignatureName); newSig.ThisStepOutputsGroupedByPMU = new SignalTree("Step " + newSig.StepCounter.ToString() + " _ " + newSig.SignatureName); SampleDataMngr.GroupedSignalBySignatureStepsInput.Add(newSig.ThisStepInputsGroupedByType); SignatureSettings.Add(newSig); Model.SignatureSettings.Add(newSig.Model); _signatureStepSelected(newSig); }
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); } } }