Esempio n. 1
0
 protected override void InitializeControlStates()
 {
     ControlStateDict.Add(1, new ControlState(ControlStates.OFFLINE,
                                              "Off-Line/Equipment Off-Line"));
     ControlStateDict.Add(2, new ControlState(ControlStates.OFFLINE,
                                              "Off-Line/Attempt On-Line"));
     ControlStateDict.Add(3, new ControlState(ControlStates.OFFLINE,
                                              "Off-Line/Host Off-Line"));
     ControlStateDict.Add(4, new ControlState(ControlStates.LOCAL,
                                              "On-Line/Local"));
     ControlStateDict.Add(5, new ControlState(ControlStates.REMOTE,
                                              "On-Line/Remote"));
 }
Esempio n. 2
0
        public override bool QueryProcessAndControlState(out Globals.ControlState newControlState, out Globals.ProcessState newProcessState)
        {
            //TODO - look at evatec example - this could possible be moved to Tool.cs
            newControlState = new ControlState(ControlStates.UNDEFINED, "Undefined");
            newProcessState = new ProcessState(ProcessStates.UNDEFINED, "Undefined");
            S1F3 s1f3 = new S1F3(CurrentToolConfig.Toolid);

            s1f3.addSVID(CurrentToolConfig.ControlStateSVID.ToString(), DataType.U4, "ControlStateSVID");
            s1f3.addSVID(CurrentToolConfig.ProcessStateSVID.ToString(), DataType.U4, "ProcessStateSVID");
            try
            {
                MyLog.Information("Sending tool status query for SVID " + CurrentToolConfig.ControlStateSVID + ", " +
                                  CurrentToolConfig.ProcessStateSVID);
                s1f3.send(EqSrv, CurrentToolConfig.CommunicationTimeout);
                int controlState;
                int processState;

                if (s1f3.SV.Count != 2)
                {
                    MyLog.Warning("Status query response did not include expected values.");
                    return(false);
                }

                if (s1f3.SV[0].Type == DataType.L)
                {
                    MyLog.Warning("The configured SVID '" + CurrentToolConfig.ControlStateSVID + "' for Control State is not recognized by the tool");
                    return(false);
                }
                else
                {
                    controlState = Int32.Parse(s1f3.SV[0].Value);
                }

                if (s1f3.SV[1].Type == DataType.L)
                {
                    MyLog.Warning("The configured SVID '" + CurrentToolConfig.ProcessStateSVID + "' for Process State is not recognized by the tool");
                    return(false);
                }
                else
                {
                    processState = Int32.Parse(s1f3.SV[1].Value);
                }

                if (ControlStateDict.ContainsKey(controlState))
                {
                    newControlState = ControlStateDict[controlState];
                    if (newControlState.State != currentControlState)
                    {
                        Messenger.Default.Send(new ControlStateChangeMessage(newControlState.State, newControlState.Description));
                        MyLog.Debug("Control State changed to " + newControlState.Description);
                        currentControlState = newControlState.State;
                    }
                }
                else
                {
                    MyLog.Warning("Control State changed to undefined state " + controlState);
                    currentControlState = ControlStates.UNDEFINED;
                }
                if (ProcessStateDict.ContainsKey(processState))
                {
                    newProcessState = ProcessStateDict[processState];
                    if (newProcessState.State != currentProcessState)
                    {
                        Messenger.Default.Send(new ProcessStateChangeMessage(newProcessState.State, newProcessState.Description));
                        currentProcessState = newProcessState.State;
                    }
                }
                else
                {
                    MyLog.Warning("Process State changed to undefined state " + processState);
                    currentProcessState = ProcessStates.UNDEFINED;
                }
                MyLog.Debug("Status query returned Control State '" + controlState + "' Process State '" + processState + "'");
                return(true);
            }
            catch (BoundMessageTimeoutException)
            {
                MyLog.Warning("Tool status query (S1F3) timed out.");
            }
            catch (BoundMessageSendException e)
            {
                MyLog.Warning("Tool status query (S1F3) failed - " + e.Message);
            }
            catch (Exception e)
            {
                MyLog.Warning("Unexpected error in tool status query (S1F3); " + e.Message);
            }
            return(false);
        }