private void StartReadThread() { if (readThread != null) { System.Windows.Forms.MessageBox.Show("PAC read thread already assigned!"); } readThread = new Thread(() => { while (keepReadThreadAlive) { pac.Write32BitIntegerVariable("bVisionRunning", false, 1); var eMethodResponse = pac.ReadGroupItems(tagReadArray, 0, tagReadArray.Length); tagReadArray[0].GetData(out bPressurize); tagReadArray[1].GetData(out bAirFill); tagReadArray[2].GetData(out iHeadDown); tagReadArray[3].GetData(out bTesting); tagReadArray[4].GetData(out fPressure); tagReadArray[5].GetData(out bTareVisionSystem); tagReadArray[6].GetData(out fPercTargetPressure); tagReadArray[7].GetData(out bTestComplete); tagReadArray[8].GetData(out bFail1); tagReadArray[9].GetData(out bFail2); tagReadArray[10].GetData(out bFail3); tagReadArray[11].GetData(out bFail4); tagReadArray[12].GetData(out bFail5); tagReadArray[13].GetData(out bFail6); tagReadArray[14].GetData(out bFail7); tagReadArray[15].GetData(out bFail8); if (bTesting == 1 && bTestingLast == 0) { eMethodResponse = pac.ReadGroupItems(stringReadArray, 0, stringReadArray.Length); string[] s = Enumerable.Repeat <string>("null", stringReadArray.Length).ToArray(); for (int i = 0; i < stringReadArray.Length; i++) { stringReadArray[i].GetData(out s[i]); } StartTest?.Invoke(s, new EventArgs()); } bTestingLast = bTesting; if (iHeadDown == 1 && iHeadDownLast == 0) { HeadDown?.Invoke(this, new EventArgs()); } iHeadDownLast = iHeadDown; if (bTareVisionSystem == 1 && bTareVisionSystemLast == 0) { StartTakeThreshold?.Invoke(this, new EventArgs()); } if (bTareVisionSystem == 0 && bTareVisionSystemLast == 1 && bTesting == 1) { StopTakeThreshold?.Invoke(this, new EventArgs()); } bTareVisionSystemLast = bTareVisionSystem; if (bPressurize == 0 && bPressurizeLast == 1) { StopTest?.Invoke(this, new EventArgs()); } bPressurizeLast = bPressurize; if (bTestComplete == 1 && bTestCompleteLast == 0) { TestCompleted?.Invoke(this, new EventArgs()); } bTestCompleteLast = bTestComplete; Thread.Sleep(250); } }); keepReadThreadAlive = true; readThread.Start(); }
private void Handle(StopTest msg) { Logger.Debug("received the StopTest message."); Program.TestMainActorSystem.Terminate(); }