Example #1
0
        public override EventGenerator FromParameters(DetectionSystem parent, string newName, List <Parameter> parameters, uint id)
        {
            Channel  channel      = null;
            double   threshold    = 0;
            TimeSpan debounceTime = TimeSpan.FromTicks(0);

            foreach (Parameter param in parameters)
            {
                switch (param.Name)
                {
                case "Channel":
                    channel = ((SystemChannelParameter)param).ToChannel();
                    break;

                case "Threshold":
                    threshold = ((DoubleParameter)param).ToDouble();
                    break;

                case "Debounce Time":
                    debounceTime = ((TimeSpanParameter)param).ToTimeSpan();
                    break;
                }
            }
            return(new ThresholdEG(parent, newName, channel, threshold, debounceTime, id));
        }
Example #2
0
 public ThresholdEG(DetectionSystem parent, string newName, Channel newChannel, double newThreshold, uint id) : base(parent, newName, id)
 {
     eventGeneratorType = "Threshold";
     channel            = newChannel;
     threshold          = newThreshold;
     debounceTime       = TimeSpan.FromTicks(0);
 }
Example #3
0
        public override Instrument FromParameters(DetectionSystem parent, string newName, List <Parameter> parameters, uint id)
        {
            GRANDInstrument instrument = new GRANDInstrument(parent, newName, id);

            Instrument.ApplyStandardInstrumentParameters(instrument, parameters);
            return(instrument);
        }
Example #4
0
 public ManualEG(DetectionSystem parent, string newName, uint id) : base(parent, newName, id)
 {
     eventGeneratorType = "Manual";
     dataFolder         = "Data\\" + id.ToString("X8");
     dataFile           = dataFolder + "\\Events.csv";
     CheckFoldersExist();
     LoadEvents();
 }
Example #5
0
        public EventGenerator(DetectionSystem parent, string name, uint id) : base(parent, name, id)
        {
            parent.GetEventGenerators().Add(this);

            eventWatcher = parent;
            events       = new List <Event>();
            actions      = new List <Action>();
        }
Example #6
0
 public SystemEventGeneratorParameter(string name, DetectionSystem system) : base(name, ParameterType.SystemEventGenerator)
 {
     System      = system;
     ValidValues = new List <string>();
     foreach (EventGenerator eg in System.GetEventGenerators())
     {
         ValidValues.Add(eg.Name);
     }
 }
Example #7
0
        public override Instrument FromParameters(DetectionSystem parent, string newName, List <Parameter> parameters, uint id)
        {
            int    nHeaders      = 0;
            int    nChannels     = 0;
            string tStampFormat  = "";
            string fileExtension = "csv";

            CSVParser.DelimiterType delimiter = CSVParser.DelimiterType.Comma;
            bool hasEndTimes = false;

            foreach (Parameter param in parameters)
            {
                switch (param.Name)
                {
                case "Delimiter":
                    switch (((EnumParameter)param).Value)
                    {
                    case "Comma":
                        delimiter = CSVParser.DelimiterType.Comma;
                        break;

                    case "Comma or Whitespace":
                        delimiter = CSVParser.DelimiterType.CommaOrWhitespace;
                        break;
                    }
                    break;

                case "Extension":
                    fileExtension = ((StringParameter)param).Value;
                    break;

                case "Headers":
                    nHeaders = ((IntParameter)param).ToInt();
                    break;

                case "Channels":
                    nChannels = ((IntParameter)param).ToInt();
                    break;

                case "Time Stamp Format":
                    tStampFormat = ((StringParameter)param).Value;
                    break;

                case "Has End Times":
                    hasEndTimes = (param as BoolParameter).ToBool();
                    break;
                }
            }
            CSVInstrument instrument = new CSVInstrument(parent, newName, nChannels, hasEndTimes, id);

            instrument.Delimiter       = delimiter;
            instrument.NumberOfHeaders = nHeaders;
            instrument.TimeStampFormat = tStampFormat;
            instrument.FileExtension   = fileExtension;
            Instrument.ApplyStandardInstrumentParameters(instrument, parameters);
            return(instrument);
        }
Example #8
0
        public ImageInstrument(DetectionSystem parent, string name, uint id) : base(parent, name, id)
        {
            InstrumentType = "Image";
            FileExtension  = FILE_EXTENSION;
            filePrefix     = "";

            numChannels = 1;
            channels    = new Channel[numChannels];
            channels[0] = new Channel(Name + "-Channel", this, Channel.ChannelType.VIDEO, 0);
        }
Example #9
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 #10
0
        public static DetectionSystem FromXML(XmlNode node, Facility parent)
        {
            string name;
            uint   id;

            Persister.StartFromXML(node, out name, out id);
            DetectionSystem system = new DetectionSystem(parent, name, id);

            return(system);
        }
Example #11
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 #12
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 #13
0
        public MCAInstrument(DetectionSystem parent, string name, uint id) : base(parent, name, id)
        {
            InstrumentType = "MCA";
            FileExtension  = FILE_EXTENSION;
            filePrefix     = "";
            spectrumParser = new CHNParser();

            numChannels          = NUM_CHANNELS;
            channels             = new Channel[numChannels];
            channels[COUNT_RATE] = new Channel(Name + "-Count_Rate", this, Channel.ChannelType.DURATION_VALUE, 0);
        }
Example #14
0
        public static EventGenerator FromXML(XmlNode eventNode, DetectionSystem system)
        {
            string name;
            uint   id;

            Persister.StartFromXML(eventNode, out name, out id);
            EventGeneratorHookup hookup     = GetHookup(eventNode.Attributes["Type"]?.InnerText);
            List <Parameter>     parameters = Parameter.FromXML(eventNode, hookup.TemplateParameters, system);

            return(hookup?.FromParameters(system, name, parameters, id));
        }
Example #15
0
 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);
         }
     }
 }
Example #16
0
        public SiteManagerForm(MainForm master, SiteManager newSiteMan)
        {
            main    = master;
            siteMan = newSiteMan;

            selectedSystem         = null;
            selectedChannel        = null;
            selectedVirtualChannel = null;

            this.StartPosition = FormStartPosition.CenterParent;
            InitializeComponent();
        }
Example #17
0
        public DeclarationInstrument(DetectionSystem parent, string name, uint id) : base(parent, name, id)
        {
            InstrumentType = "Declaration";
            filePrefix     = "";
            FileExtension  = "dec";
            decFiles       = new string[0];
            decDates       = new DateTime[0];
            decParser      = new DECFile();

            numChannels           = NUM_CHANNELS;
            channels              = new Channel[numChannels];
            channels[DECLARATION] = new Channel(Name + "-Declarations", this, Channel.ChannelType.DURATION_VALUE, 0);
        }
Example #18
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 #19
0
        public override EventGenerator FromParameters(DetectionSystem parent, string newName, List <Parameter> parameters, uint id)
        {
            Channel channel = null;

            foreach (Parameter param in parameters)
            {
                switch (param.Name)
                {
                case "Channel":
                    channel = ((SystemChannelParameter)param).ToChannel();
                    break;
                }
            }
            return(new DataPresentEG(parent, newName, channel, id));
        }
Example #20
0
        public ISRInstrument(DetectionSystem parent, string name, uint id) : base(parent, name, id)
        {
            InstrumentType = "ISR";
            FileExtension  = FILE_EXTENSION;
            filePrefix     = "";
            isrParser      = new ISRParser();

            numChannels              = NUM_CHANNELS;
            channels                 = new Channel[numChannels];
            channels[TOTALS1]        = new Channel(Name + "-Totals-1", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[TOTALS2]        = new Channel(Name + "-Totals-2", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[TOTALS3]        = new Channel(Name + "-Totals-3", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[REALS_PLUS_ACC] = new Channel(Name + "-Real+Acc", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[ACC]            = new Channel(Name + "-Acc", this, Channel.ChannelType.COUNT_RATE, 0);
        }
Example #21
0
        public CSVInstrument(DetectionSystem parent, string newName, int nChannels, bool hasEndTimes, uint id) : base(parent, newName, id)
        {
            InstrumentType = "CSV";
            numChannels    = nChannels;
            FileExtension  = FILE_EXTENSION;
            filePrefix     = "";

            Delimiter       = CSVParser.DelimiterType.Comma;
            NumberOfHeaders = 0;
            TimeStampFormat = "";
            HasEndTimes     = hasEndTimes;
            MakeNewParser();

            ReinitializeChannels();
        }
Example #22
0
        private void NewSystemButton_Click(object sender, EventArgs e)
        {
            // Get parent facility
            int      index = -1;
            TreeNode node  = SitesTreeView.SelectedNode;
            Facility fac;

            if (node.Tag is Facility)
            {
                fac = (Facility)node.Tag;
            }
            else if (node.Tag is DetectionSystem)
            {
                fac = (Facility)node.Parent.Tag;
                DetectionSystem sys = (DetectionSystem)node.Tag;
                index = fac.GetSystems().IndexOf(sys) + 1;
            }
            else
            {
                fac = (Facility)node.Parent.Parent.Tag;
                DetectionSystem sys = (DetectionSystem)node.Parent.Tag;
                index = fac.GetSystems().IndexOf(sys) + 1;
            }

            if (index < 0)
            {
                index = fac.GetSystems().Count;
            }

            bool uniqueName = false;
            int  iteration  = 0;

            string name = "";

            while (!uniqueName)
            {
                iteration++;
                name       = "New-System-" + iteration.ToString();
                uniqueName = !siteMan.ContainsName(name);
            }
            DetectionSystem newSys = new DetectionSystem(fac, name, 0);

            newSys.SetIndex(index);
            siteMan.Save();
            UpdateSitesTree();
            siteManChanged             = true;
            SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(name, true)[0];
        }
Example #23
0
        public override Instrument FromParameters(DetectionSystem parent, string newName, List <Parameter> parameters, uint id)
        {
            MCAInstrument instrument = new MCAInstrument(parent, newName, id);

            Instrument.ApplyStandardInstrumentParameters(instrument, parameters);
            foreach (Parameter param in parameters)
            {
                switch (param.Name)
                {
                case "File Extension":
                    instrument.FileExtension = param.Value;
                    break;
                }
            }
            return(instrument);
        }
Example #24
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 #25
0
        public override Instrument FromParameters(DetectionSystem parent, string newName, List <Parameter> parameters, uint id)
        {
            ImageInstrument instrument = new ImageInstrument(parent, newName, id);

            foreach (Parameter param in parameters)
            {
                switch (param.Name)
                {
                case "Date Pattern":
                    instrument.DatePattern      = param.Value;
                    instrument.DateRegexPattern = (param as DateTimeFormatParameter).GetRegexPattern();
                    break;
                }
            }
            Instrument.ApplyStandardInstrumentParameters(instrument, parameters);
            return(instrument);
        }
Example #26
0
        public NGAMInstrument(DetectionSystem parent, string name, uint id) : base(parent, name, id)
        {
            InstrumentType = "NGAM";
            FileExtension  = FILE_EXTENSION;
            filePrefix     = "";
            vbfParser      = new VBFParser();

            numChannels     = NUM_CHANNELS;
            channels        = new Channel[numChannels];
            channels[data0] = new Channel(Name + "-data0", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[data1] = new Channel(Name + "-data1", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[data2] = new Channel(Name + "-data2", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[data3] = new Channel(Name + "-data3", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[data4] = new Channel(Name + "-data4", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[data5] = new Channel(Name + "-data5", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[data6] = new Channel(Name + "-data6", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[data7] = new Channel(Name + "-data7", this, Channel.ChannelType.COUNT_RATE, 0);
        }
Example #27
0
        public GRANDInstrument(DetectionSystem parent, string name, uint id) : base(parent, name, id)
        {
            InstrumentType = "GRAND";
            FileExtension  = FILE_EXTENSION;
            filePrefix     = "";
            FileExtension  = "bid";
            bidParser      = new BIDParser();

            numChannels            = NUM_CHANNELS;
            channels               = new Channel[numChannels];
            channels[chACountRate] = new Channel(Name + "-Neutrons-A", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[chBCountRate] = new Channel(Name + "-Neutrons-B", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[chCCountRate] = new Channel(Name + "-Neutrons-C", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[gamInGamCh1]  = new Channel(Name + "-Gammas-1", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[gamCh1Sigma]  = new Channel(Name + "-Gammas-1-Sigma", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[gamInGamCh2]  = new Channel(Name + "-Gammas-2", this, Channel.ChannelType.COUNT_RATE, 0);
            channels[gamCh2Sigma]  = new Channel(Name + "-Gammas-2-Sigma", this, Channel.ChannelType.COUNT_RATE, 0);
        }
Example #28
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 #29
0
        public override EventGenerator FromParameters(DetectionSystem parent, string newName, List <Parameter> parameters, uint id)
        {
            Channel channel  = null;
            double  interval = 0;

            foreach (Parameter param in parameters)
            {
                switch (param.Name)
                {
                case "Channel":
                    channel = ((SystemChannelParameter)param).ToChannel();
                    break;

                case "Interval":
                    interval = ((TimeSpanParameter)param).ToTimeSpan().TotalSeconds;
                    break;
                }
            }
            return(new GapEG(parent, newName, channel, interval, id));
        }
Example #30
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;
        }