예제 #1
0
        private void hslButton3_Click(object sender, EventArgs e)
        {
            COMconfig conf;

            conf.botelv        = "9600";
            conf.zhanhao       = "1";
            conf.shujuwei      = "8";
            conf.tingzhiwei    = "1";
            conf.dataFromZero  = true;
            conf.stringReverse = false;
            conf.COM_Name      = "COM11";
            conf.checkInfo     = 0;
            mr = new M_485Rtu(conf);
            mr.connect();
        }
예제 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            bpqCOMConf.botelv        = "19200";
            bpqCOMConf.zhanhao       = "2";//站号
            bpqCOMConf.shujuwei      = "8";
            bpqCOMConf.tingzhiwei    = "1";
            bpqCOMConf.dataFromZero  = true;
            bpqCOMConf.stringReverse = false;
            bpqCOMConf.COM_Name      = "COM11";
            bpqCOMConf.checkInfo     = 2;
            bpqMR = new M_485Rtu(bpqCOMConf);
            bpqMR.connect();//变频器串口连接

            pushedFlag     = false;
            startFlag      = false;
            pushFlag       = false;
            maxHammer      = -1;
            maxPressure    = -1;
            c              = new config();
            c.channelCount = 4;//开启通道个数
            //通道0  压力 pressure
            //通道1  水冲击力  waterHammer
            //通道2  温度
            //通道3  变频器返回值
            //通道4  流量
            c.convertClkRate    = 1000;//每个通道的时钟频率
            c.deviceDescription = "PCI-1710HG,BID#0";
            c.profilePath       = "D:/demo.xml";
            c.sectionCount      = 0;    //The 0 means setting 'streaming' mode.
            c.sectionLength     = 1000; //每个通道的缓冲区长度
            c.startChannel      = 0;

            //初始化研华板卡的功能
            daq = new DAQ_profile(0, c);
            daq.InstantAo();
            daq.InstantDi();
            daq.InstantDo();
            doData = new byte[2] {
                0x00, 0x00
            };
            daq.InstantDo_Write(doData);

            bpqzt.Text   = "变频器当前状态:变频";
            sbzt.Text    = "水泵当前状态:";
            sbyali.Value = Properties.Settings.Default.水泵压力;
            try
            {
                numericUpDown1.Value = Properties.Settings.Default.保持时间;
                startThreshold.Value = Properties.Settings.Default.开始计时阈值;
                stopThreshold.Value  = Properties.Settings.Default.停止阈值;
            }
            catch { }
            hslCurve1.SetLeftCurve("压力", null, Color.DodgerBlue);
            hslCurve1.SetLeftCurve("冲击力", null, Color.DarkOrange);

            hslCurve1.ValueMaxLeft       = 10;
            hslCurve1.ValueMaxRight      = 10;
            hslCurve1.StrechDataCountMax = 1000;//设置显示数据量
            //hslCurve1.IsAbscissaStrech = true;//这是数据全部显示
            BindingSource bs = new BindingSource();

            bs.DataSource     = dt;
            monitor           = new System.Timers.Timer(500);
            monitor.Elapsed  += new System.Timers.ElapsedEventHandler(theout); //到达时间的时候执行事件;
            monitor.AutoReset = true;                                          //设置是执行一次(false)还是一直执行(true);
            monitor.Enabled   = true;                                          //是否执行System.Timers.Timer.Elapsed事件;

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

            dt.Columns.Add("时间", typeof(string));
            dt.Columns.Add("压力", typeof(double));   //新建第一列
            dt.Columns.Add("冲击力", typeof(double));  //新建第二列
            dt.Columns.Add("温度", typeof(double));

            WaveformAi();
            waveformAiCtrl1_Start();
        }
예제 #3
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();
        }