private void NewEventDialog_Load(object sender, EventArgs e) { DebounceComboBox.Text = "Seconds"; ChannelComboBox.Items.Clear(); foreach (Instrument inst in sys.GetInstruments()) { foreach (Channel ch in inst.GetChannels()) { ChannelComboBox.Items.Add(ch.Name); } } }
public override bool SetIndex(int index) { eventWatcher.GetEventGenerators().Remove(this); eventWatcher.GetEventGenerators().Insert(index, this); eventWatcher.Children.Remove(this); eventWatcher.Children.Insert(index + eventWatcher.GetInstruments().Count, this); return(true); }
public SystemChannelParameter(string name, DetectionSystem system) : base(name, ParameterType.SystemChannel) { System = system; ValidValues = new List <string>(); foreach (Instrument inst in System.GetInstruments()) { foreach (Channel ch in inst.GetChannels()) { ValidValues.Add(ch.Name); } } }
private void PopulateDataSourceTab(AnalysisAction action, int compiler) { DetectionSystem sys = (DetectionSystem)action.GetEventGenerator().GetEventWatcher(); DataSourceTabControl.TabPages.Add("Data Source " + (compiler + 1).ToString()); DataCompilerPanel compilerPanel = new DataCompilerPanel(); compilerPanel.Dock = DockStyle.Fill; DataSourceTabControl.TabPages[compiler].Controls.Add(compilerPanel); compilerPanel.ChannelComboBox.Items.Clear(); foreach (Instrument inst in sys.GetInstruments()) { foreach (Channel ch in inst.GetChannels()) { compilerPanel.ChannelComboBox.Items.Add(ch.Name); } } compilerPanel.ChannelComboBox.Text = action.GetChannels()[compiler].Name; }
private void DownButton_Click(object sender, EventArgs e) { TreeNode node = SitesTreeView.SelectedNode; if (node.Tag is Site) { Site site = (Site)node.Tag; int index = siteMan.GetSites().IndexOf(site); if (index < siteMan.GetSites().Count - 1) { site.SetIndex(index + 1); siteMan.Save(); UpdateSitesTree(); siteManChanged = true; SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(site.Name, true)[0]; } } else if (node.Tag is Facility) { Facility fac = (Facility)node.Tag; Site site = (Site)node.Parent.Tag; int index = site.GetFacilities().IndexOf(fac); if (index < site.GetFacilities().Count - 1) { site.SetIndex(index + 1); siteMan.Save(); UpdateSitesTree(); siteManChanged = true; SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(fac.Name, true)[0]; } } else if (node.Tag is DetectionSystem) { DetectionSystem sys = (DetectionSystem)node.Tag; Facility fac = (Facility)node.Parent.Tag; int index = fac.GetSystems().IndexOf(sys); if (index < fac.GetSystems().Count - 1) { fac.SetIndex(index + 1); siteMan.Save(); UpdateSitesTree(); siteManChanged = true; SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(sys.Name, true)[0]; } } else if (node.Tag is Instrument) { Instrument inst = (Instrument)node.Tag; DetectionSystem sys = (DetectionSystem)node.Parent.Tag; int index = sys.GetInstruments().IndexOf(inst); if (index < sys.GetInstruments().Count - 1) { inst.SetIndex(index + 1); siteMan.Save(); UpdateSitesTree(); siteManChanged = true; SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(inst.Name, true)[0]; } } }
public ReturnCode LoadFromXML(string fileName) { if (!File.Exists(fileName)) { return(ReturnCode.FILE_DOESNT_EXIST); } try { XmlDocument doc = new XmlDocument(); doc.Load(fileName); presets.Clear(); foreach (XmlNode presetNode in doc.DocumentElement.ChildNodes) { Preset newPreset = new Preset(presetNode.Attributes["name"]?.InnerText); foreach (XmlNode siteNode in presetNode.ChildNodes) { Site site = siteMan.GetSites().Single(s => s.Name == siteNode.Attributes["name"]?.InnerText); foreach (XmlNode facilityNode in siteNode.ChildNodes) { Facility fac = site.GetFacilities().Single(s => s.Name == facilityNode.Attributes["name"]?.InnerText); foreach (XmlNode systemNode in facilityNode.ChildNodes) { DetectionSystem sys = fac.GetSystems().Single(s => s.Name == systemNode.Attributes["name"]?.InnerText); foreach (XmlNode instrumentNode in systemNode.ChildNodes) { if (instrumentNode.Name == "Instrument") { Instrument inst = sys.GetInstruments().Single(i => i.Name == instrumentNode.Attributes["name"]?.InnerText); if (instrumentNode.Attributes["checked"] != null) { if (instrumentNode.Attributes["checked"].InnerText == "true") { newPreset.GetActiveInstruments().Add(inst); foreach (XmlNode chanNode in instrumentNode.ChildNodes) { Channel chan = inst.GetChannels().Single(c => c.Name == chanNode.Attributes["name"]?.InnerText); foreach (XmlNode checkNode in chanNode.ChildNodes) { if (checkNode.Attributes["checked"] != null) { if (checkNode.Attributes["checked"].InnerText == "true") { newPreset.AddChannel(chan, int.Parse(checkNode.Attributes["chart"].InnerText)); } } } } } } } else if (instrumentNode.Name == "EventGenerator") { XmlNode eventGenNode = instrumentNode; EventGenerator eventGenerator = sys.GetEventGenerators().Single(e => e.Name == eventGenNode.Attributes["name"]?.InnerText); if (eventGenNode.Attributes["checked"].InnerText == "true") { newPreset.GetActiveEventGenerators().Add(eventGenerator); } } else { return(ReturnCode.CORRUPTED_FILE); } } } } } presets.Add(newPreset); } } catch { return(ReturnCode.FAIL); } return(ReturnCode.SUCCESS); }
private void SaveAction(EventGenerator eg, Action action) { TreeNode node = SitesTreeView.SelectedNode; DetectionSystem eventWatcher = (DetectionSystem)node.Parent.Tag; DetectionSystem sys = (DetectionSystem)eventWatcher; if (action.Name != ActionsComboBox.Text && siteMan.ContainsName(ActionsComboBox.Text)) { MessageBox.Show("All items in the Site Manager require a unique name!"); return; } action.Name = ActionNameTextBox.Text; switch (ActionTypeComboBox.Text) { case "Analysis": AnalysisAction analysisAction = (AnalysisAction)action; analysisAction.GetChannels().Clear(); foreach (Instrument inst in sys.GetInstruments()) { foreach (Channel ch in inst.GetChannels()) { if (ch.Name == DataCompilerPanel1.ChannelComboBox.Text) { analysisAction.AddChannel(ch); break; } } } analysisAction.GetDataCompilers().Clear(); switch (DataCompilerPanel1.DataCompilersComboBox.Text) { case "Spectrum Compiler": analysisAction.GetDataCompilers().Add(new SpectrumCompiler("", new CHNParser(), new CHNWriter())); break; case "File List": analysisAction.GetDataCompilers().Add(new FileListCompiler("")); break; default: MessageBox.Show("Invalid data compiler type!"); return; } analysisAction.GetAnalysis().SetCommand(AnalysisCommandTextBox.Text); analysisAction.SetCompiledFileName(DataCompilerPanel1.CompiledFileTextBox.Text); switch (ResultParserComboBox.Text) { case "FRAM-Pu": analysisAction.GetAnalysis().SetResultParser(new FRAMPlutoniumResultParser()); break; case "FRAM-U": analysisAction.GetAnalysis().SetResultParser(new FRAMUraniumResultParser()); break; default: MessageBox.Show("Invalid result parser type!"); return; } analysisAction.GetAnalysis().SetResultsFile(ResultFileTextBox.Text); break; case "Command": ((CommandAction)action).SetCommand(ActionCommandTextBox.Text); break; default: MessageBox.Show("Invalid action type!"); return; } }