Ejemplo n.º 1
0
        private void startThread()
        {
            DateTime t = DateTime.Now;

            dt.Clear();
            l.Clear();
            wendu.Clear();
            maxFlow = -1;
            l.Add(0);//绘图从零点开始
            dt.Rows.Add(t.ToString("yyyy-MM-dd hh:mm:ss:fff"), TEMP, 0);
            pushedFlag   = false;
            first6l      = true;
            first9l      = true;
            loadDataFlag = true;
            firstadd0    = true;
            mr.write_coil("9", true, 1);
            mr.write_coil("10", false, 1);//开始累计流量
            Invoke(new Action(() =>
            {
                //pushWork.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
                hslCurve1.RemoveAllCurveData();
                hslPlay1.Text   = "停止";
                systemInfo.Text = "系统信息:";
            }));
        }
Ejemplo n.º 2
0
        private void Form2_Load(object sender, EventArgs e)
        {
            //ti=new  System.Threading.Timer(new TimerCallback(timer_Elapsed), null, 1000*10, 2000);

            first6l   = true;
            firstadd0 = true;
            first9l   = true;

            conf.botelv        = "19200";
            conf.zhanhao       = "1";
            conf.shujuwei      = "8";
            conf.tingzhiwei    = "1";
            conf.dataFromZero  = true;
            conf.stringReverse = false;
            conf.COM_Name      = "COM11";
            conf.checkInfo     = 2;
            mr = new M_485Rtu(conf);
            mr.connect();
            mr.write_coil("10", true, 1);//停止累计流量

            //MessageBox.Show("485连接成功");

            maxFlow    = -1;
            pushedFlag = false;

            loadDataFlag = false;



            c = new config();
            //c.channelCount = 3;
            c.convertClkRate    = 100;
            c.deviceDescription = "PCI-1710HG,BID#0";
            //c.deviceDescription = "DemoDevice,BID#0";
            //c.profilePath = "D:/demo.xml";
            c.sectionCount  = 0;//The 0 means setting 'streaming' mode.
            c.sectionLength = 100;
            c.startChannel  = 0;

            //初始化研华板卡的功能
            daq = new DAQ_profile(4, c);
            daq.InstantAo();
            daq.InstantDi();
            daq.InstantDo();
            doData = new byte[2] {
                0x00, 0x00
            };
            daq.InstantDo_Write(doData);
            l = new List <double>();
            l.Clear();
            wendu = new List <double>();
            wendu.Clear();
            //dp.Enabled = true;
            //bp.Enabled = false;
            bpqzt.Text = "变频器当前状态:变频";
            //sbzt.Text = "水泵当前状态:关闭";
            try
            {
                sbyali.Value         = Properties.Settings.Default.水泵压力;
                numericUpDown1.Value = Properties.Settings.Default.保持时间;
                startThreshold.Value = Properties.Settings.Default.开始计时阈值;
                stopThreshold.Value  = Properties.Settings.Default.停止阈值;
                qmin.Value           = Properties.Settings.Default.qmin;
            }
            catch { }
            doData = new byte[2] {
                0x00, 0x00
            };
            hslCurve1.SetLeftCurve("流量", null, Color.DodgerBlue);  //流量
            hslCurve1.SetRightCurve("温度", null, Color.DarkOrange); //温度
            hslCurve1.ValueMaxLeft       = 10;
            hslCurve1.ValueMaxRight      = 50;
            hslCurve1.StrechDataCountMax = 300;  //设置显示数据量
            hslCurve1.IsAbscissaStrech   = true; //这是数据全部显示
            dt = new DataTable();
            dt.Columns.Add("时间", typeof(string));
            dt.Columns.Add("温度", typeof(double));   //新建第一列
            dt.Columns.Add("流量", typeof(double));   //新建第二列    ElapsedEventHandler

            //t = new System.Timers.Timer(100);
            //t.Elapsed += new System.Timers.(theout);//到达时间的时候执行事件;
            //t.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
            //t.Enabled = false;
            daq.InstantAi();
            t2 = new System.Threading.Timer(new TimerCallback(theout), null, 200, 110);

            //monitor = new System.Timers.Timer(500);
            //monitor.Elapsed += new System.Timers.ElapsedEventHandler(monitorAction);//到达时间的时候执行事件;
            //monitor.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
            //monitor.Enabled = false;//是否执行System.Timers.Timer.Elapsed事件;
            //monitor2 = new System.Threading.Timer(new TimerCallback(monitorAction), null, 0, 1000);


            //pushWork = new System.Timers.Timer(10);
            //pushWork.Elapsed += new System.Timers.ElapsedEventHandler(pushWorkThread);//到达时间的时候执行事件;
            //pushWork.AutoReset = false;//设置是执行一次(false)还是一直执行(true);



            DateTime tt = DateTime.Now;

            maxFlow = -1;
            //hslCurve1.RemoveAllCurveData();
            //dt.Clear();
            //l.Clear();
            //wendu.Clear();
            l.Add(0);//绘图从零点开始
            dt.Rows.Add(tt.ToString("yyyy-MM-dd hh:mm:ss:fff"), TEMP, 0);
            pushedFlag = false;
            first6l    = true;
            first9l    = true;



            //t.Start();
        }