Beispiel #1
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            //btnSoftTrig_Click(null, null);
            //Thread.Sleep(10);
            RC_client.SendStr("rdm 13 101");
            string t = "";
            int    rt;

            RC_client.ReadStr(out t, out rt);
            RC_client.Disarm();
            char[] sep = new char[2];
            sep[0] = ' ';
            //sep[1] = '\r';
            string[] tok = t.Split(sep, StringSplitOptions.RemoveEmptyEntries);
            Event    e13 = new Event();
            int      j = 0; int k = 0;

            for (int i = 0; i < tok.Length; i++)
            {
                if (j == 8)
                {
                    j = 0; k++;
                }
                else
                {
                    try
                    {
                        e13.RawBytes[0, j + 8 * k] = Convert.ToInt16(tok[i], 16);
                        if (e13.RawBytes[0, j + 8 * k] > 0x7ff)
                        {
                            e13.RawBytes[0, j + 8 * k] = (Int16)(e13.RawBytes[0, j + 8 * k] - 0xfff);
                        }
                    }
                    catch
                    {
                        e13.RawBytes[0, j + 8 * k] = -99;
                    }

                    e13.Channels[0, j + 8 * k] = e13.RawBytes[0, j + 8 * k] + 100;
                    j++;
                }
            }
            e13.EvNum = PP.myRun.Events.Count;
            PP.myRun.Events.AddLast(e13);
            plot_e      = PP.myRun.Events.Last.Value;
            txtEvt.Text = PP.myRun.Events.Count.ToString();
            Plot0_display();
            Application.DoEvents();
        }
Beispiel #2
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;
        }