// 按键 click 事件 - 处理函数 // 参数读取按键 private void BntRead_Click(object sender, EventArgs e) { // 从硬件设备读取参数 TempGetSetParamHandler getTempParam = new TempGetSetParamHandler(this.tpDev.UpdateParamFromDevice); getTempParam.BeginInvoke(null, null); Utils.Logger.Op("点击 查询参数 按键,从 " + tpDev.tpDeviceName + " 中读取温控设备的参数!"); Utils.Logger.Sys("点击 查询参数 按键,从 " + tpDev.tpDeviceName + " 中读取温控设备的参数!"); }
// 按键 click 事件 - 处理函数 // 参数设置按键 private void BntUpdate_Click(object sender, EventArgs e) { float[] paramCache = new float[7]; // 设置温控设备参数 for (int i = 0; i < 7; i++) { float newVal = 0.0f; if (float.TryParse(this.tpParam[i].Text, out newVal) != true) { // 参数数据格式错误哦 MessageBox.Show("参数 " + tpDev.tpParamNames[i] + " 格式错误!"); return; } // 将参数写入参数设置缓存 paramCache[i] = newVal; } // 限制温度点的设置范围 if (paramCache[0] > devicesAll.tempMaxValue || paramCache[0] < devicesAll.tempMinValue) { MessageBox.Show("温度点超出界限 ( " + devicesAll.tempMinValue.ToString("0.0000") + " - " + devicesAll.tempMaxValue.ToString("0.0000") + " ),请检查!"); return; } // 将参数写入温控设备缓存 paramCache.CopyTo(tpDev.tpParamToSet, 0); // 向硬件设备更新参数 TempGetSetParamHandler setTempParam = new TempGetSetParamHandler(this.tpDev.UpdateParamToDevice); setTempParam.BeginInvoke(null, null); Utils.Logger.Op("点击 更新参数 按键,向 " + tpDev.tpDeviceName + " 中写入温控设备的参数!"); Utils.Logger.Sys("点击 更新参数 按键,向 " + tpDev.tpDeviceName + " 中写入温控设备的参数!"); }