示例#1
0
        static void Main()
        {
            FEB1Histo = new List <HISTO_curve>();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //myRun = new Run();
            FEB1      = new Mu2e_FEB_client();
            FEB1.name = "FEB1";
            //FEB1.host_name_prop = "128.143.196.217";
            FEB1.host_name_prop = "131.225.52.177";

            FEB2                = new Mu2e_FEB_client();
            FEB2.name           = "FEB2";
            FEB2.host_name_prop = "DCRC5";
            //FEC = new Mu2e_FECC_client();

            /* For Mu2E Remove extra stuff */

            WC                = new WC_client();
            WC.name           = "WC";
            WC.host_name_prop = "FTBFWC01.FNAL.GOV";

            DAQ_server myDAQ_server = new DAQ_server(); // Does not appear to get used, DAQ_server doesn't even grab an IpEnd

            myDAQ_server.StartRC();

            myMain = new frmMain();
            Application.Run(myMain);
        }
示例#2
0
        static void Main()
        {
            FEB1Histo = new List <HISTO_curve>();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //myRun = new Run();
            FEB1                = new Mu2e_FEB_client();
            FEB1.name           = "FEB1";
            FEB1.host_name_prop = "172.16.10.10";

            FEB2                = new Mu2e_FEB_client();
            FEB2.name           = "FEB2";
            FEB2.host_name_prop = "DCRC3.fnal.gov";
            //FEC = new Mu2e_FECC_client();

            WC                = new WC_client();
            WC.name           = "WC";
            WC.host_name_prop = "FTBFWC03";

            DAQ_server myDAQ_server = new DAQ_server();

            myDAQ_server.StartRC();

            myMain = new frmMain();
            Application.Run(myMain);
        }
        static void Main()
        {
            FEB1Histo = new List <HISTO_curve>();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //myRun = new Run();
            FEB1      = new Mu2e_FEB_client();
            FEB1.name = "FEB1";
            //FEB1.host_name_prop = "131.225.52.181";
            //FEB1.host_name_prop = "128.143.196.218";
            FEB1.host_name_prop = "128.143.196.54";
            //FEB1.host_name_prop = "131.225.52.177";

            FEB2                = new Mu2e_FEB_client();
            FEB2.name           = "FEB2";
            FEB2.host_name_prop = "DCRC5";
            //FEC = new Mu2e_FECC_client();

            WC                = new WC_client();
            WC.name           = "WC";
            WC.host_name_prop = "FTBFWC01.FNAL.GOV";

            DAQ_server myDAQ_server = new DAQ_server();

            myDAQ_server.StartRC();

            myMain = new frmMain();
            Application.Run(myMain);
        }
示例#4
0
        private void btnAutomatic_Click(object sender, EventArgs e)
        {
            if (btnAutomatic.Text.Contains("to stop"))
            {
                if ((timer1.Enabled == true) && (!G_Spill_Active) && (!G_Reading_Out))
                {
                    timer1.Interval = 999;
                    timer1.Enabled  = false;
                    fs.Close();
                    //WC_fs.Close();
                    RC_client.Close();
                    WC_client.Close();
                    btnAutomatic.Text       = "ACTIVATE AUTO RUN";
                    btnUpdateStatus.Visible = false;
                }
                else
                {
                    btnAutomatic.Text = "waiting to stop. Click again!";
                    Application.DoEvents();
                }
            }
            else
            {
                timer1.Interval = 1000;
                button4_Click(null, null);
                btnAutomatic.Text = "AUTO ACTIVE (click to stop)";
                G_SPILL_NUM       = 0;

                Thread.Sleep(100);
                //try
                //{
                //    if (lblLastTime.Text.Substring(1, 2) == "10") { WC_client.EnableTrig(); }
                //}
                //catch { }
            }
        }
示例#5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string sz_trig;
            string sz_WC_time;
            bool   in_spill;

            WC_client.check_status(out in_spill, out sz_trig, out sz_WC_time);

            lblTrigEn.Text = "";
            if (G_Spill_Active)
            {
                lblTrigEn.Text += "TRIG ARMED";
            }
            if (G_Reading_Out)
            {
                lblTrigEn.Text += " and READING OUT";
            }

            if (in_spill)
            {
                lblSpillStatus.Text = "in spill"; time_of_last_spill = DateTime.Now;
            }
            else
            {
                lblSpillStatus.Text = "waiting..." + G_SPILL_NUM.ToString() + " spills so far";
            }

            //t = WC_client.ReadTrigEn();
            //lblTrigEn.Text = t;
            if (sz_trig.Length < 1)
            {
            }
            else
            {
                lblLastTime.Text = DateTime.Now.Subtract(time_of_last_spill).TotalSeconds.ToString("F0");

                if (!G_Spill_Active)
                {
                    if ((DateTime.Now.Subtract(time_of_last_spill).TotalSeconds > 40) && (DateTime.Now.Subtract(time_of_last_spill).TotalSeconds < 44))
                    {
                        G_Spill_Active = true;
                        btnStartSpill_Click(null, null);
                    }
                }
                else
                {
                    if (!G_Reading_Out)
                    {
                        if ((DateTime.Now.Subtract(time_of_last_spill).TotalSeconds < 4) && (DateTime.Now.Subtract(time_of_last_spill).TotalSeconds > 1))
                        {
                            //G_SPILL_NUM++;
                            //WC_fs.WriteLine("*** starting spill num " + G_SPILL_NUM.ToString() + " *** at " + DateTime.Now.ToString());
                            //fs.WriteLine("*** starting spill num " + G_SPILL_NUM.ToString() + " *** at " + DateTime.Now.ToString());
                            timer1.Enabled = false;
                            //timer1.Enabled = false;
                            int ret_len = 0;
                            //byte[] data = WC_client.read_TDC(out ret_len);
                            //string status = "Read " + ret_len + " bytes from WC";
                            //lblWC_status.Text = status;
                            //int j = 0;
                            //for (int i = 0; i < ret_len; i++)
                            //{
                            //    WC_fs.Write(data[i].ToString("X2") + " ");
                            //    j++;
                            //    if (j == 8)
                            //    {
                            //        j = 0; WC_fs.WriteLine();
                            //    }
                            //}
                            //WC_fs.WriteLine();
                            flgGotStatus   = false;
                            timer1.Enabled = true;
                            if ((DateTime.Now.Subtract(time_of_last_spill).TotalSeconds < 38) && (DateTime.Now.Subtract(time_of_last_spill).TotalSeconds > 1))
                            {
                                timer1.Enabled = false;
                                G_Reading_Out  = true;
                                btnStopSpill_Click(null, null);
                                timer1.Enabled = true;
                            }
                        }
                        else
                        {
                            if (!flgGotStatus)
                            {
                                string[] tt;
                                flgGotStatus = true;
                                int num_pade = RC_client.GetStatus(out tt);
                                if (tt.Length > 0)
                                {
                                    lblStat1.Text = tt[0];
                                }
                                else
                                {
                                    lblStat1.Text = "";
                                }
                                if (tt.Length > 1)
                                {
                                    lblStat2.Text = tt[1];
                                }
                                else
                                {
                                    lblStat2.Text = "";
                                }
                                if (tt.Length > 2)
                                {
                                    lblStat3.Text = tt[2];
                                }
                                else
                                {
                                    lblStat3.Text = "";
                                }
                                if (tt.Length > 3)
                                {
                                    lblStat4.Text = tt[3];
                                }
                                else
                                {
                                    lblStat4.Text = "";
                                }
                            }
                        }
                    }
                    else
                    {
                        lblStat1.Text = "currently reading..." + PP.myRun.Events.Count + " so far";
                    }
                }
            }
        }
示例#6
0
        private void btnStopSpill_Click(object sender, EventArgs e)
        {
            bool events_reading = true;
            int  old_count      = 0;
            int  timeout        = 0;
            int  timeout_max    = 20;

            string[] spill_stat;
            RC_client.Disarm();
            RC_client.GetStatus(out spill_stat);
            PP.myRun.spill_status = spill_stat;
            RC_client.ReadAll();

            while (events_reading)
            {
                this.lblDaqMessage.Visible = true;
                this.lblDaqMessage.Text    = "looking for events : timeout=" + timeout.ToString();
                //this.lblDaqMessage2.Text = "last event from " + PP.myRun.Events.Last.Value.RawBytes[0, 6].ToString();
                Thread.Sleep(50);
                Application.DoEvents();
                if (PP.myRun.Events.Count > old_count)
                {
                    events_reading          = true; old_count = PP.myRun.Events.Count; timeout = 0;
                    this.lblDaqMessage.Text = old_count + " events read so far";
                }
                else
                {
                    timeout++;
                    if (timeout < timeout_max)
                    {
                    }
                    else
                    {
                        events_reading = false;
                    }
                }
            }
            this.lblDaqMessage.Text = "all done";

            Event this_evt = new Event();
            LinkedListNode <Event> this_node = PP.myRun.Events.First;
            bool   in_spill;
            string sz_num_trig;
            string sz_WC_time;

            WC_client.check_status(out in_spill, out sz_num_trig, out sz_WC_time);
            G_SPILL_NUM++;
            fs.WriteLine("*** starting spill num " + G_SPILL_NUM.ToString() + " *** at " + DateTime.Now.ToString() + " WC says: num trig= " + sz_num_trig + " time = " + sz_WC_time);
            if (gFake)
            {
                fs.WriteLine("*** this spill is fake ***");
            }
            for (int i = 0; i < PP.myRun.spill_status.Length - 1; i++)
            {
                fs.WriteLine("*** spill status " + i + " " + PP.myRun.spill_status[i] + " ***");
            }
            for (int i = 0; i < PP.myRun.Events.Count; i++)
            {
                if (this_node != null)
                {
                    this_evt = this_node.Value;
                    for (int j = 0; j < 32; j++)
                    {
                        if (this_evt.RawBytes[j, 0] < 32)
                        {
                            string t = this_evt.Ticks[j].ToString();
                            for (int k = 0; k < 9; k++)
                            {
                                t += " " + this_evt.RawBytes[j, k].ToString("X2");
                            }
                            for (int k = 0; k < 120; k++)
                            {
                                t += " " + this_evt.Channels[j, k].ToString("X3");
                            }
                            fs.WriteLine(t);
                            lblDaqMessage2.Text = i.ToString();
                        }
                    }
                }
                this_node = this_node.Next;
            }
            RC_client.Clear();
            fs.Flush();
            G_Spill_Active = false;
            G_Reading_Out  = false;
        }
示例#7
0
        public static void Service()
        {
            while (gEnable_Remote_Service)
            {
                Socket soc = listener.AcceptSocket();

                try
                {
                    string[] delimeter = new string[64];
                    string[] tokens    = new string[64];

                    delimeter[0] = "<=";
                    delimeter[1] = "//";
                    delimeter[2] = ";";
                    delimeter[3] = "=";
                    delimeter[4] = "set ";
                    delimeter[5] = "dec";
                    delimeter[6] = "0x";
                    delimeter[7] = "(";
                    delimeter[8] = ")";
                    delimeter[9] = " ";
                    Stream       s  = new NetworkStream(soc);
                    StreamReader sr = new StreamReader(s);
                    StreamWriter sw = new StreamWriter(s);
                    sw.AutoFlush = true; // enable automatic flushing
                    string RCcmd = "";
                    sw.WriteLine("Hello NIU!");
                    while (RCcmd != "quit")
                    {
                        RCcmd = sr.ReadLine();
                        RCcmd = RCcmd.Trim().ToLower();
                        //sw.WriteLine("ok, I hear you.");
                        //crappy short cuts
                        if (RCcmd == "hello")
                        {
                            WC_client.FakeSpill(); sw.WriteLine("GO");
                        }
                        if (RCcmd == "done")
                        {
                            WC_client.FakeSpill(); sw.WriteLine("GO");
                        }
                        if (RCcmd == "help")
                        {
                            sw.WriteLine("I know nothing!");
                        }
                        if (RCcmd == "disarm")
                        {
                            DisArmAll(); sw.WriteLine(RCcmd);
                        }
                        if (RCcmd == "clear")
                        {
                            ClearAll(); sw.WriteLine(RCcmd);
                        }
                        if (RCcmd == "status")
                        {
                            string m = ReportStatus(); sw.WriteLine(m);
                        }
                        if (RCcmd.Contains("maxtrig"))
                        {
                            int      val = 1000;
                            string[] tok = RCcmd.Split(delimeter, StringSplitOptions.None);
                            if (tok.Length > 1)
                            {
                                try
                                {
                                    val = Convert.ToInt32(tok[1]);
                                    if (val < 1)
                                    {
                                        val = 1;
                                    }
                                    if (val > 1000)
                                    {
                                        val = 1000;
                                    }
                                }
                                catch
                                { val = 1000; }
                                g_commanded_max_trig = val;
                            }
                        }

                        if (RCcmd.Contains("read"))
                        {
                            string[] tok = RCcmd.Split(delimeter, StringSplitOptions.None);
                            if (tok.Length > 1)
                            {
                                if (tok[1].Contains("all"))
                                {
                                    ReadAll();
                                    sw.WriteLine(RCcmd);
                                }
                                else
                                {
                                }
                            }
                        }
                    }
                    s.Close();
                }
                catch (Exception e)
                {
                    if (PP.glbDebug)
                    {
                        Console.WriteLine("oops, connection lost");
                    }
                }

                soc.Close();
            }
        }