private void FormPressureTest_Load(object sender, EventArgs e) { //initialModbusConfig(); //modbusConnect(); monitor = new System.Timers.Timer(50); monitor.Elapsed += new System.Timers.ElapsedEventHandler(monitorAction); //到达时间的时候执行事件; monitor.AutoReset = true; //设置是执行一次(false)还是一直执行(true); monitor.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件; pressure = new System.Timers.Timer(2); //87/4 pressure.Elapsed += new System.Timers.ElapsedEventHandler(PressureAction); //到达时间的时候执行事件; pressure.AutoReset = false; //设置是执行一次(false)还是一直执行(true); pressure.Enabled = false; //是否执行System.Timers.Timer.Elapsed事件; dt = new DataTable(); dt.Clear(); dt.Columns.Add("时间", typeof(string)); dt.Columns.Add("冷水流量Qc", typeof(double)); //新建第一列 通道0 dt.Columns.Add("热水流量Qh", typeof(double)); //1 dt.Columns.Add("出水流量Qm", typeof(double)); //2 dt.Columns.Add("冷水温度Tc", typeof(double)); //3 dt.Columns.Add("热水温度Th", typeof(double)); //4 dt.Columns.Add("出水温度Tm", typeof(double)); //5 dt.Columns.Add("冷水压力Pc", typeof(double)); //6 dt.Columns.Add("热水压力Ph", typeof(double)); //7 dt.Columns.Add("出水压力Pm", typeof(double)); //8 dt.Columns.Add("出水重量Qm5", typeof(double)); //9 //Temp1Status.Text = "温度:10℃\n" + "状态:制冷中."; //Temp2Status.Text = "温度:10℃\n" + "状态:加热中."; //Temp3Status.Text = "温度:10℃\n" + "状态:加热中."; //Temp4Status.Text = "温度:10℃\n" + "状态:加热中."; //Temp5Status.Text = "温度:10℃\n" + "状态:无"; collectConfig = new config(); collectConfig.channelCount = 15; collectConfig.convertClkRate = 100; collectConfig.deviceDescription = "DemoDevice,BID#0"; // "PCI-1710HG,BID#0";//选择设备以这个为准,不用考虑设备序号 collectConfig.sectionCount = 0; //The 0 means setting 'streaming' mode. collectConfig.sectionLength = 100; collectConfig.startChannel = 0; controlConfig = new config(); controlConfig.deviceDescription = "DemoDevice,BID#0"; //"PCI-1756,BID#0"; controlConfig.sectionCount = 0; //The 0 means setting 'streaming' mode. collectData = new DAQ_profile(0, collectConfig); collectData.InstantAo(); aoData[0] = 1.1; collectData.InstantAo_Write(aoData);//输出模拟量函数 control = new DAQ_profile(0, controlConfig); control.InstantDo(); control.InstantDi(); for (int i = 0; i < 4; i++) { doData[i] = 0x00; }//初始化数字量输出 control.InstantDo_Write(doData);//输出数字量函数 control.InstantDi(); diData[0] = control.InstantDi_Read(); //读取数字量函数 Console.WriteLine("didata:" + diData[0]); WaveformAi(); // waveformAiCtrl1_Start(); //开始高速读取模拟量数据 loadData(); }
//构造函数 需要提供窗体里面的resource public DAQ_profile(int deviceNumber, config conf, System.ComponentModel.ComponentResourceManager resources = null) { this.conf = conf; this.deviceNumber = deviceNumber; this.resources = resources; }