Example #1
0
        public void SetupActionGroupBox()
        {
            EventGenerator eg     = (EventGenerator)SitesTreeView.SelectedNode.Tag;
            Action         action = null;

            foreach (Action otherAction in eg.GetActions())
            {
                if (otherAction.Name == ActionsComboBox.Text)
                {
                    action = otherAction;
                }
            }
            selectedAction         = action;
            ActionNameTextBox.Text = action.Name;
            if (action is AnalysisAction)
            {
                ActionTypeComboBox.Text = "Analysis";
                PopulateAnalysisPanels((AnalysisAction)action, eg);
            }
            else if (action is CommandAction)
            {
                ActionTypeComboBox.Text = "Command";
                PopulateCommandPanels((CommandAction)action, eg);
            }
        }
Example #2
0
 public Event(EventGenerator myGenerator, DateTime start, DateTime end)
 {
     eventGenerator  = myGenerator;
     StartTime       = start;
     EndTime         = end;
     analysisResults = new List <AnalysisResult>();
 }
Example #3
0
 public AnalysisAction(EventGenerator parent, string newName, uint id) : base(parent, newName, id)
 {
     actionType       = "Analysis";
     dataCompilers    = new List <DataCompiler>();
     analysis         = new Analysis();
     channels         = new List <Channel>();
     compiledFileName = "";
 }
Example #4
0
 public CoincidenceEG(DetectionSystem parent, string newName, uint id) : base(parent, newName, id)
 {
     eventGeneratorType = "Coincidence";
     coincidenceType    = CoincidenceType.A_THEN_B;
     timingType         = TimingType.START_TO_END;
     eventGeneratorA    = null;
     eventGeneratorB    = null;
     window             = TimeSpan.FromTicks(0);
     minDifference      = TimeSpan.FromTicks(0);
 }
Example #5
0
 public CoincidenceEG(DetectionSystem parent, string newName, CoincidenceType newCoincidenceType, TimingType newTimingType, uint id) : base(parent, newName, id)
 {
     eventGeneratorType = "Coincidence";
     coincidenceType    = newCoincidenceType;
     timingType         = newTimingType;
     eventGeneratorA    = null;
     eventGeneratorB    = null;
     window             = TimeSpan.FromTicks(0);
     minDifference      = TimeSpan.FromTicks(0);
 }
Example #6
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            TreeNode node = SitesTreeView.SelectedNode;
            Action   act  = null;

            if (node.Tag is EventGenerator)
            {
                DetectionSystem eventWatcher = (DetectionSystem)node.Parent.Tag;
                EventGenerator  eg           = (EventGenerator)node.Tag;
                if (eg.Name != NameTextBox.Text && siteMan.ContainsName(NameTextBox.Text))
                {
                    MessageBox.Show("All items in the Site Manager and Event Manager require a unique name!");
                    return;
                }
                if (!ParamListPanel.ValidateInput())
                {
                    return;
                }
                EventGeneratorHookup hookup = EventGenerator.GetHookup(eg.GetEventGeneratorType());

                int index = 0;
                List <EventGenerator> egs = (eg.Parent as DetectionSystem).GetEventGenerators();
                for (int i = 0; i < egs.Count; i++)
                {
                    if (eg.ID == egs[i].ID)
                    {
                        index = i;
                        break;
                    }
                }
                eg.Delete();
                eg = hookup.FromParameters(eventWatcher, NameTextBox.Text, ParamListPanel.Parameters, eg.ID);
                eg.SetIndex(index);

                foreach (Action action in eg.GetActions())
                {
                    if (action.Name == ActionsComboBox.Text)
                    {
                        SaveAction(eg, action);
                        act = action;
                        break;
                    }
                }

                siteMan.Save();
                UpdateSitesTree();
                siteManChanged             = true;
                SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(eg.Name, true)[0];
                if (act != null)
                {
                    ActionsComboBox.Text = act.Name;
                }
            }
        }
Example #7
0
        private void RemoveButton_Click(object sender, EventArgs e)
        {
            TreeNode     node         = SitesTreeView.SelectedNode;
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + node.Text + "?", "Delete Item", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            if (node.Tag is Site)
            {
                Site site = (Site)node.Tag;
                site.Delete();
                // G - Turn off other buttons if there are no longer any sites
                if (siteMan.GetSites().Count == 0)
                {
                    DisableButtons();
                }
            }
            else if (node.Tag is Facility)
            {
                Facility fac = (Facility)node.Tag;
                fac.Delete();
            }
            else if (node.Tag is DetectionSystem)
            {
                DetectionSystem sys = (DetectionSystem)node.Tag;
                sys.Delete();
            }
            else if (node.Tag is Instrument)
            {
                Instrument inst = (Instrument)node.Tag;
                inst.Delete();
            }
            else if (node.Tag is EventGenerator)
            {
                EventGenerator  eg  = (EventGenerator)node.Tag;
                DetectionSystem sys = (DetectionSystem)node.Parent.Tag;
                sys.GetEventGenerators().Remove(eg);
            }

            siteMan.Save();
            UpdateSitesTree();
            siteManChanged = true;

            // G - Select new node after deleting
            SitesTreeView.SelectedNode = SitesTreeView.TopNode;
        }
Example #8
0
        public override EventGenerator FromParameters(DetectionSystem parent, string newName, List <Parameter> parameters, uint id)
        {
            CoincidenceEG.CoincidenceType coincidenceType = CoincidenceEG.CoincidenceType.A_THEN_B;
            CoincidenceEG.TimingType      timingType      = CoincidenceEG.TimingType.END_TO_END;
            EventGenerator egA           = null;
            EventGenerator egB           = null;
            TimeSpan       window        = TimeSpan.FromTicks(0);
            TimeSpan       minDifference = TimeSpan.FromTicks(0);

            foreach (Parameter param in parameters)
            {
                switch (param.Name)
                {
                case "Coincidence Type":
                    coincidenceType = (CoincidenceEG.CoincidenceType)((EnumParameter)param).ToInt();
                    break;

                case "Timing Type":
                    timingType = (CoincidenceEG.TimingType)((EnumParameter)param).ToInt();
                    break;

                case "Event Generator A":
                    egA = ((SystemEventGeneratorParameter)param).ToEventGenerator();
                    break;

                case "Event Generator B":
                    egB = ((SystemEventGeneratorParameter)param).ToEventGenerator();
                    break;

                case "Window":
                    window = ((TimeSpanParameter)param).ToTimeSpan();
                    break;

                case "Min Difference":
                    minDifference = ((TimeSpanParameter)param).ToTimeSpan();
                    break;
                }
            }
            CoincidenceEG eg = new CoincidenceEG(parent, newName, coincidenceType, timingType, id);

            eg.SetEventGeneratorA(egA);
            eg.SetEventGeneratorB(egB);
            eg.SetWindow(window);
            eg.SetMinDifference(minDifference);
            return(eg);
        }
Example #9
0
        private void RemoveActionButton_Click(object sender, EventArgs e)
        {
            EventGenerator eg     = (EventGenerator)SitesTreeView.SelectedNode.Tag;
            Action         action = null;

            foreach (Action otherAction in eg.GetActions())
            {
                if (otherAction.Name == ActionsComboBox.Text)
                {
                    action = otherAction;
                }
            }
            action.Delete();
            siteMan.Save();
            UpdateSitesTree();
            siteManChanged             = true;
            SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(eg.Name, true)[0];
            ResetFields();
        }
Example #10
0
        private void DownButton_Click(object sender, EventArgs e)
        {
            TreeNode node = SitesTreeView.SelectedNode;

            if (node.Tag is EventGenerator)
            {
                EventGenerator  eg           = (EventGenerator)node.Tag;
                DetectionSystem eventWatcher = (DetectionSystem)node.Parent.Tag;
                int             index        = eventWatcher.GetEventGenerators().IndexOf(eg);
                if (index < eventWatcher.GetEventGenerators().Count - 1)
                {
                    eg.SetIndex(index + 1);

                    siteMan.Save();
                    UpdateSitesTree();
                    siteManChanged             = true;
                    SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(eg.Name, true)[0];
                }
            }
        }
Example #11
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            TreeNode node = SitesTreeView.SelectedNode;

            if (node.Tag is EventGenerator)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + node.Text + "?", "Delete Item", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }

                EventGenerator  eg  = (EventGenerator)node.Tag;
                DetectionSystem sys = (DetectionSystem)node.Parent.Tag;
                eg.Delete();

                siteMan.Save();
                UpdateSitesTree();
                siteManChanged = true;
            }
        }
Example #12
0
        private void AddActionButton_Click(object sender, EventArgs e)
        {
            EventGenerator eg         = (EventGenerator)SitesTreeView.SelectedNode.Tag;
            int            iteration  = 0;
            bool           uniqueName = false;
            string         name       = "";

            while (!uniqueName)
            {
                iteration++;
                name       = "New-Action-" + iteration.ToString();
                uniqueName = !siteMan.ContainsName(name);
            }
            CommandAction action = new CommandAction(eg, name, 0);

            siteMan.Save();
            UpdateSitesTree();
            siteManChanged             = true;
            SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(eg.Name, true)[0];
            ActionsComboBox.Text       = name;
            selectedAction             = action;
        }
Example #13
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";
            }
        }
Example #14
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;
            }
        }
Example #15
0
        public ReturnCode LoadFromXML(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return(ReturnCode.FILE_DOESNT_EXIST);
            }
            XmlDocument doc = new XmlDocument();

            doc.Load(fileName);
            Persister.TakenIDs.Clear();
            sites.Clear();

            if (doc.DocumentElement.Attributes["Omniscient_Version"] == null)
            {
                MessageBox.Show("Warning: SiteManager.xml was made by an older version of Omniscient.");
            }

            foreach (XmlNode siteNode in doc.DocumentElement.ChildNodes)
            {
                if (siteNode.Name != "Site")
                {
                    return(ReturnCode.CORRUPTED_FILE);
                }
                Site newSite = Site.FromXML(siteNode, this);
                foreach (XmlNode facilityNode in siteNode.ChildNodes)
                {
                    if (facilityNode.Name != "Facility")
                    {
                        return(ReturnCode.CORRUPTED_FILE);
                    }
                    Facility newFacility = Facility.FromXML(facilityNode, newSite);
                    foreach (XmlNode systemNode in facilityNode.ChildNodes)
                    {
                        if (systemNode.Name != "System")
                        {
                            return(ReturnCode.CORRUPTED_FILE);
                        }
                        DetectionSystem newSystem = DetectionSystem.FromXML(systemNode, newFacility);
                        foreach (XmlNode instrumentNode in systemNode.ChildNodes)
                        {
                            if (instrumentNode.Name == "Instrument")
                            {
                                Instrument newInstrument = Instrument.FromXML(instrumentNode, newSystem);
                                if (!newInstrument.Equals(null))
                                {
                                    int       channelCount = 0;
                                    Channel[] channels     = newInstrument.GetStandardChannels();
                                    foreach (XmlNode chanNode in instrumentNode.ChildNodes)
                                    {
                                        if (chanNode.Name == "Channel")
                                        {
                                            if (channelCount >= channels.Length)
                                            {
                                                return(ReturnCode.CORRUPTED_FILE);
                                            }
                                            channels[channelCount].ApplyXML(chanNode);
                                            channelCount++;
                                        }
                                        else if (chanNode.Name == "VirtualChannel")
                                        {
                                            try
                                            {
                                                if (chanNode.Attributes["type"]?.InnerText != "ROI")
                                                {
                                                    VirtualChannel chan = VirtualChannel.FromXML(chanNode, newInstrument);
                                                }
                                                else
                                                {
                                                    ROIChannel chan = new ROIChannel(chanNode.Attributes["name"]?.InnerText,
                                                                                     (MCAInstrument)newInstrument, Channel.ChannelType.DURATION_VALUE,
                                                                                     uint.Parse(siteNode.Attributes["ID"]?.InnerText, System.Globalization.NumberStyles.HexNumber));
                                                    ROI roi = chan.GetROI();
                                                    roi.SetROIStart(double.Parse(chanNode.Attributes["roi_start"]?.InnerText));
                                                    roi.SetROIEnd(double.Parse(chanNode.Attributes["roi_end"]?.InnerText));
                                                    roi.SetBG1Start(double.Parse(chanNode.Attributes["bg1_start"]?.InnerText));
                                                    roi.SetBG1End(double.Parse(chanNode.Attributes["bg1_end"]?.InnerText));
                                                    roi.SetBG2Start(double.Parse(chanNode.Attributes["bg2_start"]?.InnerText));
                                                    roi.SetBG2End(double.Parse(chanNode.Attributes["bg2_end"]?.InnerText));
                                                    switch (chanNode.Attributes["bg_type"]?.InnerText)
                                                    {
                                                    case "None":
                                                        roi.SetBGType(ROI.BG_Type.NONE);
                                                        break;

                                                    case "Flat":
                                                        roi.SetBGType(ROI.BG_Type.FLAT);
                                                        break;

                                                    case "Linear":
                                                        roi.SetBGType(ROI.BG_Type.LINEAR);
                                                        break;

                                                    default:
                                                        return(ReturnCode.CORRUPTED_FILE);
                                                    }
                                                }
                                            }
                                            catch { return(ReturnCode.CORRUPTED_FILE); }
                                        }
                                        else
                                        {
                                            return(ReturnCode.CORRUPTED_FILE);
                                        }
                                    }
                                }
                            }
                            else if (instrumentNode.Name == "EventGenerator")
                            {
                                XmlNode        eventNode = instrumentNode; // Correct some shoddy nomenclature...
                                EventGenerator eg        = EventGenerator.FromXML(eventNode, newSystem);
                                if (eg == null)
                                {
                                    return(ReturnCode.CORRUPTED_FILE);
                                }
                                foreach (XmlNode actionNode in eventNode.ChildNodes)
                                {
                                    if (actionNode.Name != "Action")
                                    {
                                        return(ReturnCode.CORRUPTED_FILE);
                                    }
                                    Action action = Action.FromXML(actionNode, eg);
                                }
                            }
                            else
                            {
                                return(ReturnCode.CORRUPTED_FILE);
                            }
                        }
                    }
                }
            }
            return(ReturnCode.SUCCESS);
        }
Example #16
0
        private void ResetFields()
        {
            selectedSystem         = null;
            selectedChannel        = null;
            selectedVirtualChannel = null;
            TreeNode node = SitesTreeView.SelectedNode;

            NameTextBox.Text = node.Text;

            if (node.Tag is Site)
            {
                Site site = (Site)node.Tag;
                TypeLabel.Text = "Site";

                SystemPanel.Visible         = false;
                InstrumentPanel.Visible     = false;
                NewInstrumentButton.Enabled = false;
                NewSystemButton.Enabled     = false;
                NewFacilityButton.Enabled   = true;
            }
            else if (node.Tag is Facility)
            {
                Facility fac = (Facility)node.Tag;
                TypeLabel.Text = "Facility";

                SystemPanel.Visible         = false;
                InstrumentPanel.Visible     = false;
                NewInstrumentButton.Enabled = false;
                NewSystemButton.Enabled     = true;
                NewFacilityButton.Enabled   = true;
            }
            else if (node.Tag is DetectionSystem)
            {
                DetectionSystem sys = (DetectionSystem)node.Tag;
                selectedSystem = sys;
                TypeLabel.Text = "System";

                SetupSystemPanel();

                SystemPanel.Visible         = true;
                InstrumentPanel.Visible     = false;
                NewInstrumentButton.Enabled = true;
                NewSystemButton.Enabled     = true;
                NewFacilityButton.Enabled   = true;
            }
            else if (node.Tag is Instrument)
            {
                Instrument inst = (Instrument)node.Tag;
                TypeLabel.Text = "Instrument";
                InstrumentParameterListPanel.LoadParameters(inst.GetParameters());
                InstTypeTextBox.Text = inst.InstrumentType;

                ChannelsComboBox.Items.Clear();
                Channel[] channels = inst.GetChannels();
                if (channels.Length > 0)
                {
                    foreach (Channel channel in channels)
                    {
                        ChannelsComboBox.Items.Add(channel.Name);
                    }
                    if (channels[0] is VirtualChannel)
                    {
                        selectedChannel               = null;
                        selectedVirtualChannel        = (VirtualChannel)channels[0];
                        ChannelsComboBox.SelectedItem = selectedVirtualChannel.Name;
                        SetupVirtualChannelGroupBox();
                    }
                    else
                    {
                        selectedChannel               = channels[0];
                        selectedVirtualChannel        = null;
                        ChannelsComboBox.SelectedItem = selectedChannel.Name;
                        SetupChannelGroupBox();
                    }
                }
                else
                {
                    VirtualChannelGroupBox.Visible = false;
                }

                SystemPanel.Visible         = false;
                InstrumentPanel.Visible     = true;
                NewInstrumentButton.Enabled = true;
                NewSystemButton.Enabled     = true;
                NewFacilityButton.Enabled   = true;
            }
            else if (node.Tag is EventGenerator)
            {
                EventGenerator eg = (EventGenerator)node.Tag;
                TypeLabel.Text = "Event Generator";

                SystemPanel.Visible         = false;
                InstrumentPanel.Visible     = false;
                NewInstrumentButton.Enabled = false;
                NewSystemButton.Enabled     = false;
            }
        }
Example #17
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            EventTypeDialog dialog = new EventTypeDialog();
            DialogResult    result = dialog.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            TreeNode        node = SitesTreeView.SelectedNode;
            DetectionSystem eventWatcher;

            int insertIndex = -1;

            if (node.Tag is DetectionSystem)
            {
                eventWatcher = (DetectionSystem)node.Tag;
            }
            else
            {
                eventWatcher = (DetectionSystem)node.Parent.Tag;
                insertIndex  = eventWatcher.GetEventGenerators().IndexOf((EventGenerator)node.Tag) + 1;
            }

            EventGeneratorHookup hookup = EventGenerator.GetHookup(dialog.eventType);
            string name = "";

            bool uniqueName = false;
            int  iteration  = 0;

            while (!uniqueName)
            {
                iteration++;
                name       = "New-" + hookup.Type + "-" + iteration.ToString();
                uniqueName = !siteMan.ContainsName(name);
            }

            List <string> validSystemChannels = new List <string>();

            foreach (Instrument inst in ((DetectionSystem)eventWatcher).GetInstruments())
            {
                foreach (Channel chan in inst.GetChannels())
                {
                    validSystemChannels.Add(chan.Name);
                }
            }

            List <string> validEGs = new List <string>();

            foreach (EventGenerator otherEG in eventWatcher.GetEventGenerators())
            {
                validEGs.Add(otherEG.Name);
            }

            List <Parameter> parameters = new List <Parameter>();

            foreach (ParameterTemplate paramTemp in hookup.TemplateParameters)
            {
                switch (paramTemp.Type)
                {
                case ParameterType.Double:
                    parameters.Add(new DoubleParameter(paramTemp.Name)
                    {
                        Value = "0"
                    });
                    break;

                case ParameterType.Enum:
                    parameters.Add(new EnumParameter(paramTemp.Name)
                    {
                        Value = paramTemp.ValidValues[0], ValidValues = paramTemp.ValidValues
                    });
                    break;

                case ParameterType.SystemChannel:
                    if (validSystemChannels.Count == 0)
                    {
                        MessageBox.Show("No channels to watch in this system!");
                        return;
                    }
                    parameters.Add(new SystemChannelParameter(paramTemp.Name, (DetectionSystem)eventWatcher)
                    {
                        Value       = validSystemChannels[0],
                        ValidValues = validSystemChannels
                    });
                    break;

                case ParameterType.SystemEventGenerator:
                    if (validEGs.Count == 0)
                    {
                        MessageBox.Show("No event generators to watch in this system!");
                        return;
                    }
                    parameters.Add(new SystemEventGeneratorParameter(paramTemp.Name, (DetectionSystem)eventWatcher)
                    {
                        Value       = validEGs[0],
                        ValidValues = validEGs
                    });
                    break;

                case ParameterType.TimeSpan:
                    parameters.Add(new TimeSpanParameter(paramTemp.Name)
                    {
                        Value = "0"
                    });
                    break;
                }
            }

            EventGenerator eg = hookup.FromParameters(eventWatcher, name, parameters, 0);

            siteMan.Save();
            UpdateSitesTree();
            siteManChanged             = true;
            SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(eg.Name, true)[0];
        }
Example #18
0
        public void ResetFields()
        {
            selectedAction        = null;
            selectedActionChannel = null;
            TreeNode node = SitesTreeView.SelectedNode;

            if (node.Tag is EventGenerator)
            {
                DetectionSystem eventWatcher = (DetectionSystem)node.Parent.Tag;

                NameTextBox.Enabled = true;

                EventGenerator   eg         = (EventGenerator)node.Tag;
                List <Parameter> parameters = eg.GetParameters();
                ParamListPanel.LoadParameters(parameters);
                ParamListPanel.Visible = true;
                NameTextBox.Text       = eg.Name;

                ActionPanel.Visible = true;
                ActionsComboBox.Items.Clear();
                ActionsComboBox.Text = "";
                if (eg.GetActions().Count > 0)
                {
                    foreach (Action action in eg.GetActions())
                    {
                        ActionsComboBox.Items.Add(action.Name);
                    }
                    ActionsComboBox.Text = eg.GetActions()[0].Name;
                    selectedAction       = eg.GetActions()[0];
                    SetupActionGroupBox();
                    ActionGroupBox.Visible = true;
                }
                else
                {
                    ActionGroupBox.Visible = false;
                }

                UpButton.Enabled     = true;
                DownButton.Enabled   = true;
                AddButton.Enabled    = true;
                DeleteButton.Enabled = true;
                SaveButton.Enabled   = true;
            }
            else if (node.Tag is DetectionSystem)
            {
                NameTextBox.Text    = "";
                NameTextBox.Enabled = false;

                ParamListPanel.Visible = false;
                ActionPanel.Visible    = false;

                UpButton.Enabled     = false;
                DownButton.Enabled   = false;
                AddButton.Enabled    = true;
                DeleteButton.Enabled = false;
                SaveButton.Enabled   = false;
            }
            else
            {
                NameTextBox.Text    = "";
                NameTextBox.Enabled = false;

                ParamListPanel.Visible = false;
                ActionPanel.Visible    = false;

                UpButton.Enabled     = false;
                DownButton.Enabled   = false;
                AddButton.Enabled    = false;
                DeleteButton.Enabled = false;
                SaveButton.Enabled   = false;
            }
        }
Example #19
0
 public void SetEventGeneratorB(EventGenerator newEg)
 {
     eventGeneratorB = newEg;
 }
Example #20
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;
            }
        }
Example #21
0
 private void PopulateCommandPanels(CommandAction action, EventGenerator eg)
 {
     ActionCommandTextBox.Text = action.GetCommand();
 }
Example #22
0
 public void SetEventGeneratorA(EventGenerator newEg)
 {
     eventGeneratorA = newEg;
 }
Example #23
0
 public Event(EventGenerator myGenerator)
 {
     eventGenerator  = myGenerator;
     analysisResults = new List <AnalysisResult>();
 }
Example #24
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);
 }
Example #25
0
 public CommandAction(EventGenerator parent, string newName, uint id) : base(parent, newName, id)
 {
     actionType = "Command";
     command    = "";
 }
Example #26
0
 /// <summary>
 /// Removes an EventGenerator from the list of ActiveEventGenerators
 /// </summary>
 /// <param name="eventGenerator"></param>
 public void DeactivateEventGenerator(EventGenerator eventGenerator)
 {
     ActiveEventGenerators.Remove(eventGenerator);
 }
Example #27
0
 public Action(EventGenerator parent, string name, uint id) : base(parent, name, id)
 {
     eventGenerator = parent;
     eventGenerator.GetActions().Add(this);
 }
Example #28
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);
        }
Example #29
0
 /// <summary>
 /// Adds an EventGenerator to the list of ActiveEventGenerators
 /// </summary>
 /// <param name="eventGenerator"></param>
 public void ActivateEventGenerator(EventGenerator eventGenerator)
 {
     ActiveEventGenerators.Add(eventGenerator);
 }