private void buttonReset_Click(object sender, EventArgs e) { try { if (MasterNow != null) { MasterNow.WriteSingleCoil(DeviceNow.BatchControllerAddress, AddressHelper.CoilResetReal, true); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonContinue_Click(object sender, EventArgs e) { try { var btn = sender as Button; if (MasterNow != null && DeviceNow.IsStart == true) { MasterNow.WriteSingleCoil(DeviceNow.BatchControllerAddress, AddressHelper.CoilResumeBacth, true); DeviceNow.IsPause = false; } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void btnPause_Click(object sender, EventArgs e) { try { if (MasterNow != null) { //打开阀门 MasterNow.WriteSingleCoil(DeviceNow.BatchControllerAddress, AddressHelper.CoilIsStartBacth, false); DeviceNow.IsPause = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnStop_Click(object sender, EventArgs e) { try { if (MasterNow != null) { if (DeviceNow.IsStart == true) { DeviceNow.EndTime = DateTime.Now; MasterNow.WriteSingleCoil(DeviceNow.BatchControllerAddress, AddressHelper.CoilEndBacth, true); DeviceNow.IsStart = false; MessageBox.Show(string.Format("{0} 结束加料!", DeviceNow.TypeName)); } } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 批控器不会控制 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnStart_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Device.All[Index].MaterialName) == true) { MessageBox.Show("未填写原料名称"); return; } if (MessageBox.Show(string.Format("确定将加料值设置为{0} Kg ?", DeviceNow.Goal), "消息", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { if (MasterNow != null) { //目标值 MasterNow.WriteMultipleRegisters(DeviceNow.BatchControllerAddress, AddressHelper.Goal, ModbusFloatHelper.FloatToUshort(DeviceNow.Goal)); if (MessageBox.Show("确定将阀门打开并开始加料?", "消息", MessageBoxButtons.YesNo) == DialogResult.Yes) { //打开阀门 MasterNow.WriteSingleCoil(DeviceNow.BatchControllerAddress, AddressHelper.CoilIsStartBacth, true); DeviceNow.StartTime = DateTime.Now; DeviceNow.IsStart = true; textBoxResidue.Text = "0"; } } else { MessageBox.Show("未连接设备!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }