예제 #1
0
        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;
        }
예제 #2
0
        private void PopulateAnalysisPanels(AnalysisAction action, EventGenerator eg)
        {
            TreeNode node = SitesTreeView.SelectedNode;

            DataSourceTabControl.TabPages.Clear();
            for (int i = 0; i < action.GetDataCompilers().Count; ++i)
            {
                PopulateDataSourceTab(action, i);
            }

            selectedActionChannel = action.GetChannels()[0];
            DataCompilerPanel1.ChannelComboBox.Text     = action.GetChannels()[0].Name;
            AnalysisCommandTextBox.Text                 = action.GetAnalysis().GetCommand();
            DataCompilerPanel1.CompiledFileTextBox.Text = action.GetCompiledFileName();
            ResultFileTextBox.Text = action.GetAnalysis().GetResultsFile();
            if (action.GetAnalysis().GetResultParser() is FRAMPlutoniumResultParser)
            {
                ResultParserComboBox.Text = "FRAM-Pu";
            }
            else if (action.GetAnalysis().GetResultParser() is FRAMUraniumResultParser)
            {
                ResultParserComboBox.Text = "FRAM-U";
            }
        }
예제 #3
0
        public static Action FromXML(XmlNode actionNode, EventGenerator eg)
        {
            Action action;
            string name;
            uint   id;

            Persister.StartFromXML(actionNode, out name, out id);
            switch (actionNode.Attributes["type"]?.InnerText)
            {
            case "Analysis":
                AnalysisAction analysisAction = new AnalysisAction(eg, name, id);
                analysisAction.GetAnalysis().SetCommand(actionNode.Attributes["command"]?.InnerText);
                foreach (Instrument inst in (eg.Parent as DetectionSystem).GetInstruments())
                {
                    foreach (Channel ch in inst.GetChannels())
                    {
                        if (ch.Name == actionNode.Attributes["channel"]?.InnerText)
                        {
                            analysisAction.AddChannel(ch);
                        }
                    }
                }
                analysisAction.SetCompiledFileName(actionNode.Attributes["compiled_file"]?.InnerText);
                analysisAction.GetAnalysis().SetResultsFile(actionNode.Attributes["result_file"]?.InnerText);
                switch (actionNode.Attributes["result_parser"]?.InnerText)
                {
                case "FRAM-Pu":
                    analysisAction.GetAnalysis().SetResultParser(new FRAMPlutoniumResultParser());
                    break;

                case "FRAM-U":
                    analysisAction.GetAnalysis().SetResultParser(new FRAMUraniumResultParser());
                    break;

                default:
                    throw new ApplicationException("Corrupted XML node!");
                }
                foreach (XmlNode dataCompilerNode in actionNode.ChildNodes)
                {
                    if (dataCompilerNode.Name != "DataCompiler")
                    {
                        throw new ApplicationException("Corrupted XML node!");
                    }
                    switch (dataCompilerNode.Attributes["type"]?.InnerText)
                    {
                    case "SpectrumCompiler":
                        SpectrumCompiler spectrumCompiler = new SpectrumCompiler("");
                        switch (dataCompilerNode.Attributes["parser"]?.InnerText)
                        {
                        case "CHN":
                            spectrumCompiler.SetSpectrumParser(new CHNParser());
                            break;

                        default:
                            throw new ApplicationException("Corrupted XML node!");
                        }
                        switch (dataCompilerNode.Attributes["writer"]?.InnerText)
                        {
                        case "CHN":
                            spectrumCompiler.SetSpectrumWriter(new CHNWriter());
                            break;

                        default:
                            throw new ApplicationException("Corrupted XML node!");
                        }
                        analysisAction.GetDataCompilers().Add(spectrumCompiler);
                        break;

                    case "FileListCompiler":
                        analysisAction.GetDataCompilers().Add(new FileListCompiler(""));
                        break;

                    default:
                        throw new ApplicationException("Corrupted XML node!");
                    }
                }
                action = analysisAction;
                break;

            case "Command":
                action = new CommandAction(eg, name, id);
                ((CommandAction)action).SetCommand(actionNode.Attributes["command"]?.InnerText);
                break;

            default:
                throw new ApplicationException("Corrupted XML node!");
            }
            return(action);
        }
예제 #4
0
        private void ActionTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            EventGenerator  eg           = (EventGenerator)SitesTreeView.SelectedNode.Tag;
            DetectionSystem eventWatcher = (DetectionSystem)SitesTreeView.SelectedNode.Parent.Tag;
            Action          action       = null;

            foreach (Action otherAction in eg.GetActions())
            {
                if (otherAction.Name == ActionsComboBox.Text)
                {
                    action = otherAction;
                }
            }
            selectedAction = action;
            switch (ActionTypeComboBox.Text)
            {
            case "Analysis":
                if (!(action is AnalysisAction))
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure you want to switch action to a Analysis?\nThis will overwrite the current action.", "Switch to Analysis", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.No)
                    {
                        ActionTypeComboBox.Text = action.GetActionType();
                        return;
                    }
                    action.Delete();

                    AnalysisAction analysisAction = new AnalysisAction(eg, action.Name, 0);
                    analysisAction.AddChannel(((DetectionSystem)eventWatcher).GetInstruments()[0].GetChannels()[0]);
                    analysisAction.GetDataCompilers().Add(new SpectrumCompiler("", new CHNParser(), new CHNWriter()));
                    analysisAction.GetAnalysis().SetResultParser(new FRAMPlutoniumResultParser());

                    action = analysisAction;
                }
                PopulateAnalysisPanels((AnalysisAction)action, eg);
                AnalysisPanel.Visible = true;
                CommandPanel.Visible  = false;
                break;

            case "Command":
                if (!(action is CommandAction))
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure you want to switch action to a Command?\nThis will overwrite the current action.", "Switch to Command", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.No)
                    {
                        ActionTypeComboBox.Text = action.GetActionType();
                        return;
                    }
                    action.Delete();
                    CommandAction analysisAction = new CommandAction(eg, action.Name, 0);
                    action = analysisAction;
                }
                PopulateCommandPanels((CommandAction)action, eg);
                AnalysisPanel.Visible = false;
                CommandPanel.Visible  = true;
                break;

            default:
                MessageBox.Show("Invalid action type!");
                return;
            }
        }
예제 #5
0
        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;
            }
        }