private void btnStartLine_Click(object sender, EventArgs e) { PLC.setM(PLC_SLOT_Y3, 1); var data = PLC.GetPLCData(); writeLog("发出生产线启动命令"); }
private void startPlcInspection() { Task.Run(() => { while (runInspecting) { PLC.read_RCS(PLC_SLOT_Y0); var value = PLC.GetPLCData(); if (string.IsNullOrEmpty(value)) { Thread.Sleep(100); continue; } var state = parsePlcResult(value); if (state == 0 && isCameraReading) { this.Invoke((MethodInvoker) delegate { btnStop.PerformClick(); }); } if (state == 1 && !isCameraReading) { this.Invoke((MethodInvoker) delegate { btnRun.PerformClick(); }); } Thread.Sleep(1000); } writeLog("传送带检测线程停止。"); }); writeLog("启动传送带检测线程。"); }
private static void PlcStartLine() { PLC.setM(PLC_SLOT_Y0, 1); PLC.GetPLCData(); }