Example #1
0
 public PLCSTATE GetPLCState()
 {
     _PLCstate = PLCSTATE.UNKNOWN;
     SendMessageToPlc("request state");
     //  Debug.WriteLine("request send done");
     eventWait.Reset();
     eventWait.WaitOne(2000);
     Debug.WriteLine("getplcstate: " + _PLCstate.ToString());
     return(_PLCstate);
 }
Example #2
0
        public void AnalyzePLCMessage(Object sender, TCPEventArgs e)
        {
            string recStr = e.receivedmessage;

            string[] recStrArr = recStr.Split(' ');
            //Debug.WriteLine(recStr);
            if (recStr == "control system is available")
            {
                _PLCstate = PLCSTATE.AVAILABLE;
            }
            else if (recStr == "control system and wpc is ready")
            {
                _PLCstate = PLCSTATE.READY;
            }
            else if (recStr == "control system is busy")
            {
                _PLCstate = PLCSTATE.BUSY;
            }
            else if (recStrArr[0] == "result:")
            {
                int taskResult        = 0;
                int checkRejectReason = 0;
                int.TryParse(recStrArr[1], out taskResult);
                int.TryParse(recStrArr[2], out checkRejectReason);

                if (CurrentMESTask.Force == 0)
                {
                    if (taskResult == 1)
                    {
                        TaskInfo.TaskResult = TASKRESULT.GOOD;
                    }
                    else
                    {
                        TaskInfo.TaskResult = TASKRESULT.NOTGOOD;
                    }

                    TaskInfo.RejectReason = (REJECTREASON)checkRejectReason;
                }
                else if (CurrentMESTask.Force == 1)
                {
                    TaskInfo.TaskResult   = TASKRESULT.GOOD;
                    TaskInfo.RejectReason = (REJECTREASON)0;
                }
                else if (CurrentMESTask.Force == 2)
                {
                    TaskInfo.TaskResult   = TASKRESULT.NOTGOOD;
                    TaskInfo.RejectReason = (REJECTREASON)REJECTREASON.ForceNG;
                }
                else
                {
                    Messages.WriteLine("Force Value Error Input");
                }


                TaskInfo.PQCFilePath = recStrArr[3];
                Debug.WriteLine("taskresult is :" + TaskInfo.TaskResult.ToString());
                Debug.WriteLine("rejectreason is :" + TaskInfo.RejectReason.ToString());
                Debug.WriteLine(recStr);
            }
            // Debug.WriteLine("anastate: "+ _PLCstate.ToString());

            eventWait.Set();
            //  Debug.WriteLine(recStr);
        }