//Recieve Data from client public override void CycleRequest() { if (stack.CurrentDirect == FlowDirect.WaitingInput) { string strRec = null; strRec = (client as DCN500Client).RecieveData(); //strRec = (client as DCN500Client).RecievedData; BaseDCTAction action = null; if (strRec != null) { //strRec = strRec.Replace(System.Text.Encoding.ASCII.GetString(fixedMsg),"").Trim(); //strRec = strRec.Replace(System.Text.Encoding.ASCII.GetString(fixedMsg2),"").Trim(); //strRec = strRec.Replace(System.Text.Encoding.ASCII.GetString(fixedMsg3),"").Trim(); if ( //strRec.IndexOf(System.Text.Encoding.ASCII.GetString(fixedMsg)) < 0 && strRec != String.Empty) { try { DealSuperCommand(strRec); action = stack.GetNextAction(); stack.SendMessage(client, action.Do(client), ""); } catch (Exception ex) { UserControl.Messages msg = new UserControl.Messages(); msg.Add(new UserControl.Message(ex)); stack.SendMessage(client, msg, ""); if (action != null) { lock (stack) { //stack.CurrentDirect = action.FlowDirect; } } } } } } }
public Message GetActionDesc(BaseDCTAction action) { Message msg = null; string command = GetCommandByAction(action); if (command.Length > 0) { BaseModelFacade facade = new BaseModelFacade((SQLDomainDataProvider)DomainDataProviderManager.DomainDataProvider()); Dct dctAction = (Dct)facade.GetDCT(command); if (dctAction != null) { msg = new Message("$DCT_CurrentDCTCommand " + dctAction.Dctdesc); } } return(msg); }
public virtual BaseDCTAction GetNextAction() { BaseDCTAction ba = null; if (alWorkingAction.Count > 0) { ba = alWorkingAction[0] as BaseDCTAction; if (ba.NextAction != null) { alWorkingAction.Clear(); alWorkingAction.Add(ba.NextAction); ba = null; ba = alWorkingAction[0] as BaseDCTAction; } } return(ba); }
//从DCT Client获取用户请求 public override void CycleRequest() { if (stack.CurrentDirect == FlowDirect.WaitingInput) { try { //获取DCT输入 DCTMessage dctMessage = ((PCClient)client).RecieveData(); if (dctMessage != null) { //确保输入可用 BaseDCTAction action = stack.GetNextAction(); action.FlowDirect = FlowDirect.WaitingOutput; } } catch (Exception ex) { DealExcepion(ex); } } }
//从DCT Client获取用户请求 public override void CycleRequest() { if (stack.CurrentDirect == FlowDirect.WaitingInput) { try { //获取DCT输入 string strRec = (client as DT4000Client).RecieveData(); //确保输入可用 BaseDCTAction action = stack.GetNextAction(); if (strRec != null && strRec.Trim().Length > 0 && strRec.IndexOf("ALL RIGHTS") < 0) { action.FlowDirect = FlowDirect.WaitingOutput; } } catch (Exception ex) { DealExcepion(ex); } } }
//public override //Send Message to client public override void CycleResponse() { if (stack.CurrentDirect == FlowDirect.WaitingOutput) { BaseDCTAction action = stack.GetNextAction(); try { stack.SendMessage(client, action.Do(client), ""); lock (stack) { //stack.CurrentDirect = action.FlowDirect; } } catch (Exception ex) { UserControl.Messages msg = new UserControl.Messages(); msg.Add(new UserControl.Message(ex)); stack.SendMessage(client, msg, ""); } } }
//logon mes protected override void Login() { BaseDCTAction action = stack.GetNextAction(); // if(action == null) // { // action = new ActionUser(); // stack.Add(action); // } if (stack.CurrentDirect == FlowDirect.WaitingOutput && action == null) { action = new ActionUser(); if (bIsInitLoginMessage == true) { action.OutMesssage = new UserControl.Message(UserControl.MessageType.Normal, "$DCT_LOGIN"); bIsInitLoginMessage = false; } stack.Add(action); try { stack.SendMessage(client, action.Do(client), ""); //stack.CurrentDirect = action.FlowDirect; } catch (Exception ex) { UserControl.FileLog.FileLogOut("DCTControlPanel.log", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.StackTrace); UserControl.Messages msg = new UserControl.Messages(); msg.Add(new UserControl.Message(ex)); stack.SendMessage(client, msg, ""); } } }
public BaseDCTAction GetActionByCommand(string command) { BaseDCTAction action = null; Type actionType = (Type)_CommandToAction[command.Trim().ToUpper()]; if (actionType == null) { action = null; } else { action = (BaseDCTAction)actionType.Assembly.CreateInstance(actionType.FullName); } if (action != null) { action.Status = ActionStatus.Init; action.FlowDirect = FlowDirect.WaitingOutput; action.NextAction = null; } return(action); }
//logon mes protected override void Login() { BaseDCTAction action = stack.GetNextAction(); if (stack.CurrentDirect == FlowDirect.WaitingOutput && action == null) { action = new ActionUser(); stack.Add(action); try { stack.SendMessage(client, action.Do(client), ""); //stack.CurrentDirect = action.FlowDirect; } catch (Exception ex) { UserControl.Messages msg = new UserControl.Messages(); msg.Add(new UserControl.Message(ex)); stack.SendMessage(client, msg, ""); } } }
//Recieve Data from client public override void CycleRequest() { if (stack.CurrentDirect == FlowDirect.WaitingInput) { string strRec = null; strRec = (client as GW28Client).RecieveData(); BaseDCTAction action = null; if (strRec != null) { if (strRec.IndexOf("ALL RIGHTS") < 0 && strRec != String.Empty) { try { if (IsInputedLoginCmd == false && strRec == "10") { return; } string receivedData = strRec; if (receivedData == EXIT) { IsInputedLoginCmd = false; } else if (receivedData == LOGIN && IsInputedLoginCmd == true) // 输入LOGIN,要先退出 { receivedData = EXIT; IsInputedLoginCmd = false; } if (receivedData == EXIT || IsInputedLoginCmd == false) { stack = new BaseActionStack(); //stack.CurrentDirect = FlowDirect.WaitingOutPut; } DealSuperCommand(receivedData); if (!client.Authorized) { Login(); } bool bIsLoginCmd = false; if (IsInputedLoginCmd == false && !client.Authorized) // 如果还没有输入登录命令,而且客户端没有登录 { bIsLoginCmd = true; IsInputedLoginCmd = true; } if (client.Authorized || bIsLoginCmd == false) // 如果是登录命令,则不用再次执行Action,以免将命令当做用户名 { // 获取现在的Action action = stack.GetNextAction(); /* joe 20070903 GW28 输入和输出在一个界面,不需要输出原始输入 * // 输出原始输入 * UserControl.Messages inputMsg = new UserControl.Messages(); * string strInput = receivedData; * if (action is Action.ActionPassword) * { * strInput = new string('*', receivedData.Length); * } * inputMsg.Add(new UserControl.Message(strInput)); * stack.SendMessage(client, inputMsg); */ // 执行Action if (stack.CancelActionOutput == false) { stack.SendMessage(client, action.Do(client), ""); } else { action.Do(client); stack.CancelActionOutput = false; } //stack.CurrentDirect = action.FlowDirect; } /* * SuperCommand(strRec); * * action = stack.GetNextAction(); * stack.SendMessage(client,action.Do(client)); * stack.CurrentDirect = action.FlowDirect; */ } catch (Exception ex) { UserControl.FileLog.FileLogOut("DCTControlPanel.log", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.StackTrace); UserControl.Messages msg = new UserControl.Messages(); msg.Add(new UserControl.Message(ex)); stack.SendMessage(client, msg, ""); if (action != null) { //stack.CurrentDirect = action.FlowDirect; } } } } } }
public void RequestInputFromRoot(string receivedData) { BaseDCTAction action = null; if (receivedData != null) { ((DSC19Client)client).RecieveDataFromRoot(receivedData); if (receivedData.IndexOf("ALL RIGHTS") < 0 && receivedData != String.Empty) { client.RecievedData = receivedData; try { if (receivedData.IndexOf("DCS-19 SELF-RESET OK") >= 0) // 终端启动 { receivedData = "LOGIN"; UserControl.Messages loginMsg = new UserControl.Messages(); loginMsg.Add(new UserControl.Message("$DCT_LOGIN")); stack.SendMessage(client, loginMsg, ""); /* * if (timer == null) * { * timer = new System.Threading.Timer(new System.Threading.TimerCallback(this.ResponseTimerCallback), this, 0, System.Threading.Timeout.Infinite); * } */ if (threadResponse == null) { System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(this.ResponseTimerCallback); threadResponse = new System.Threading.Thread(threadStart); threadResponse.Start(); } return; } bInRequestExecute = true; if (receivedData == EXIT) { IsInputedLoginCmd = false; } else if (receivedData == LOGIN && IsInputedLoginCmd == true) // 输入LOGIN,要先退出 { receivedData = EXIT; IsInputedLoginCmd = false; } if (receivedData == EXIT) { this.RaiseAfterLogout(); /* * if (timer != null) * { * timer = null; * System.Threading.Thread.Sleep(20); * System.Windows.Forms.Application.DoEvents(); * } */ if (threadResponse != null) { threadResponse.Abort(); System.Threading.Thread.Sleep(20); System.Windows.Forms.Application.DoEvents(); threadResponse = null; } stack = new BaseActionStack(); } DealSuperCommand(receivedData); if (!client.Authorized) { Login(); } bool bIsLoginCmd = false; if (IsInputedLoginCmd == false && !client.Authorized) // 如果还没有输入登录命令,而且客户端没有登录 { bIsLoginCmd = true; IsInputedLoginCmd = true; } if (client.Authorized || bIsLoginCmd == false) // 如果是登录命令,则不用再次执行Action,以免将命令当做用户名 { // 获取现在的Action action = stack.GetNextAction(); // 输出原始输入 UserControl.Messages inputMsg = new UserControl.Messages(); string strInput = receivedData; if (action is Action.ActionPassword) { strInput = new string('*', receivedData.Length); } inputMsg.Add(new UserControl.Message(strInput)); stack.SendMessage(client, inputMsg, ""); // 执行Action if (stack.CancelActionOutput == false) { stack.SendMessage(client, action.Do(client), ""); } else { action.Do(client); stack.CancelActionOutput = false; } //stack.CurrentDirect = action.FlowDirect; } /* * if (timer == null) * { * timer = new System.Threading.Timer(new System.Threading.TimerCallback(this.ResponseTimerCallback), this, 0, System.Threading.Timeout.Infinite); * } */ if (threadResponse == null) { System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(this.ResponseTimerCallback); threadResponse = new System.Threading.Thread(threadStart); threadResponse.Start(); } } catch (Exception ex) { UserControl.Messages msg = new UserControl.Messages(); msg.Add(new UserControl.Message(ex)); stack.SendMessage(client, msg, ""); // Added by Icyer 2006/12/14 if (action != null && action.NeedCancel == true) { action.NeedCancel = false; //this.Cancel(); UserControl.Messages msgTmp = new UserControl.Messages(); msgTmp.Add(new UserControl.Message(UserControl.MessageType.Normal, "$DCT_Please_Input_SN_OR_Directive")); stack.SendMessage(client, msgTmp, ""); } // Added end if (action != null) { //stack.CurrentDirect = action.FlowDirect; } } bInRequestExecute = false; } } }
public override Messages Action(object act) { base.Action(act); Messages msg = new Messages(); if (act == null) { return(msg); } DataCollect.Action.ActionEventArgs args; if (ObjectState == null) { args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim(); //msg = CheckData(data); if (msg.IsSuccess()) { #region Key logic,Push next action and fill it with data args.RunningCard = data; ObjectState = args; Web.Helper.ActionType acttype = new Web.Helper.ActionType(); acttype.Items.Add(BaseDCTDriver.NEXTOP); ActionRCard acRcard = new ActionRCard(); if ((act as IDCTClient).CachedAction != null && !acttype.Items.Contains(args.RunningCard))//如果存在缓存的Action则利用缓存的Action { BaseDCTAction action = (act as IDCTClient).CachedAction; if (!(action is ActionCollectNG) && !(action is ActionCollectSMTNG) && !(action is ActionCollectOutlineNG) && !(action is ActionCollectKeyparts) && !(action is ActionBatchWithKeypaerts) && !(action is ActionCollectMix)) { action.ObjectState = ObjectState; } this.NextAction = action; } else if ((act as IDCTClient).CachedAction == null && !acttype.Items.Contains(args.RunningCard)) { ActionFactory acFac = new ActionFactory(); acFac.ObjectState = ObjectState; this.NextAction = acFac; } else if (acttype.Items.Contains(args.RunningCard)) { //ActionRCard acRcard = new ActionRCard(); //acRcard.ObjectState = ObjectState; this.NextAction = acRcard; } bool bIsAction = true; if (acttype.Items.Contains(args.RunningCard)) { switch (args.RunningCard) { //归属工单 case ActionType.DataCollectAction_GoMO: ActionGotoMO actionGotoMO = new ActionGotoMO(); //actionGotoMO.ObjectState = acRcrd.ObjectState; acRcard.NextAction = actionGotoMO; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_MOCode"); (act as IDCTClient).CachedAction = actionGotoMO; break; //采集GOOD, added by jessie lee case ActionType.DataCollectAction_GOOD: ActionCollectGood actionCollectGood = new ActionCollectGood(); //actionCollectGood.ObjectState = ObjectState; acRcard.NextAction = actionCollectGood; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_GOOD_Please_Input_GOOD_SN"); // Added by Icyer 2007/08/22 // 做良品采集时做归属工单 //changed by hiro 2008/08/27 //if ((act as IDCTClient).CachedAction is Action.ActionGotoMO) //{ // if (((Action.ActionGotoMO)(act as IDCTClient).CachedAction).moCode != string.Empty) // { // actionCollectGood.NeedGoMO = true; // actionCollectGood.NeedGoMOCode = ((Action.ActionGotoMO)(act as IDCTClient).CachedAction).moCode; // } //} // Added end (act as IDCTClient).CachedAction = actionCollectGood; break; //采集NG, added by jessie lee, 10/05/2006 case ActionType.DataCollectAction_NG: ActionCollectNG actionCollectNG = new ActionCollectNG(); //actionCollectNG.ObjectState = acRcard.ObjectState; acRcard.NextAction = actionCollectNG; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"); (act as IDCTClient).CachedAction = actionCollectNG; break; //采集SMTNG, added by jessie lee, 10/05/2006 case ActionType.DataCollectAction_SMTNG: ActionCollectSMTNG actionCollectSMTNG = new ActionCollectSMTNG(); //actionCollectSMTNG.ObjectState = acRcard.ObjectState; acRcard.NextAction = actionCollectSMTNG; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"); (act as IDCTClient).CachedAction = actionCollectSMTNG; break; //采集OutlineGOOD, added by jessie lee, 2006/8/21 case ActionType.DataCollectAction_OutLineGood: ActionCollectOutlineGood actionCollectOutlineGood = new ActionCollectOutlineGood(); //actionCollectGood.ObjectState = ObjectState; acRcard.NextAction = actionCollectOutlineGood; (act as IDCTClient).CachedAction = actionCollectOutlineGood; break; //采集OutlineNG, added by jessie lee, 2006/8/21 case ActionType.DataCollectAction_OutLineNG: ActionCollectOutlineNG actionCollectOutlineNG = new ActionCollectOutlineNG(); //actionCollectNG.ObjectState = acRcard.ObjectState; acRcard.NextAction = actionCollectOutlineNG; (act as IDCTClient).CachedAction = actionCollectOutlineNG; break; //Keyparts上料, added by jessie lee, 10/05/2006 case ActionType.DataCollectAction_CollectKeyParts: ActionCollectKeyparts actionCollectKeyparts = new ActionCollectKeyparts(); //actionCollectKeyparts.ObjectState = acRcard.ObjectState; acRcard.NextAction = actionCollectKeyparts; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"); // 如果上个采集是集成上料,则做KeyPart时同时做集成上料 if ((act as IDCTClient).CachedAction is Action.ActionCollectINNO) { if (((Action.ActionCollectINNO)(act as IDCTClient).CachedAction).INNOCode != string.Empty) { actionCollectKeyparts.NeedCollectINNO = true; actionCollectKeyparts.INNOCode = ((Action.ActionCollectINNO)(act as IDCTClient).CachedAction).INNOCode; } } else if ((act as IDCTClient).CachedAction is Action.ActionCollectKeyparts) { actionCollectKeyparts.NeedCollectINNO = ((Action.ActionCollectKeyparts)(act as IDCTClient).CachedAction).NeedCollectINNO; actionCollectKeyparts.INNOCode = ((Action.ActionCollectKeyparts)(act as IDCTClient).CachedAction).INNOCode; } // Added end (act as IDCTClient).CachedAction = actionCollectKeyparts; break; case ActionType.DataCollectAction_Split: ActionCollectIDMerge actionCollectIDMerge = new ActionCollectIDMerge(); acRcard.NextAction = actionCollectIDMerge; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_SN_For_Merge"); (act as IDCTClient).CachedAction = actionCollectIDMerge; break; case ActionType.DataCollectAction_CollectINNO: ActionCollectINNO actionCollectINNO = new ActionCollectINNO(); acRcard.NextAction = actionCollectINNO; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_CMPleaseInputINNOinEdt"); (act as IDCTClient).CachedAction = actionCollectINNO; break; case BaseDCTDriver.NEXTOP: ActionNextOP actionNextOP = new ActionNextOP(); acRcard.NextAction = actionNextOP; (act as IDCTClient).CachedAction = actionNextOP; break; case ActionType.DataCollectAction_CompareAppendix: ActionCompareApp actionCartonCompare = new ActionCompareApp(); acRcard.NextAction = actionCartonCompare; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_CARTONNO"); (act as IDCTClient).CachedAction = actionCartonCompare; break; case ActionType.DataCollectAction_Mix: ActionCollectMix actionCollectMix = new ActionCollectMix(); acRcard.NextAction = actionCollectMix; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"); break; case ActionType.DataCollectAction_KBatch: ActionBatchWithKeypaerts actionBatchWithKeypaerts = new ActionBatchWithKeypaerts(); acRcard.NextAction = actionBatchWithKeypaerts; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"); break; case ActionType.DataCollectAction_CompareProductCode: ActionCompareProductCode actionCompareProductCode = new ActionCompareProductCode(); acRcard.NextAction = actionCompareProductCode; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_CARTONNO"); (act as IDCTClient).CachedAction = actionCompareProductCode; break; case ActionType.DataCollectAction_CompareTwo: ActionCompareAppAndProductCode actionCompareAppAndProductCode = new ActionCompareAppAndProductCode(); acRcard.NextAction = actionCompareAppAndProductCode; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_CARTONNO"); (act as IDCTClient).CachedAction = actionCompareAppAndProductCode; break; case ActionType.DataCollectAction_AutoNG: ActionAutoNG actionAutoNG = new ActionAutoNG(); acRcard.NextAction = actionAutoNG; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"); (act as IDCTClient).CachedAction = actionAutoNG; break; case ActionType.DataCollectAction_FGPacking: ActionFGPacking actionFGPacking = new ActionFGPacking(); acRcard.NextAction = actionFGPacking; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"); (act as IDCTClient).CachedAction = actionFGPacking; break; case ActionType.DataCollectAction_MACID: ActionCollectMACID actionCollectMACID = new ActionCollectMACID(); acRcard.NextAction = actionCollectMACID; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"); (act as IDCTClient).CachedAction = actionCollectMACID; break; case ActionType.DataCollectAction_MACALL: ActionCollectMACALL actionCollectMACALL = new ActionCollectMACALL(); acRcard.NextAction = actionCollectMACALL; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"); (act as IDCTClient).CachedAction = actionCollectMACALL; break; case ActionType.DataCollectAction_ONPost: ActionCollectONPost actionCollectONPost = new ActionCollectONPost(); acRcard.NextAction = actionCollectONPost; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_UserCode"); (act as IDCTClient).CachedAction = actionCollectONPost; break; case ActionType.DataCollectAction_OffPost: ActionCollectOffPost actionCollectOffPost = new ActionCollectOffPost(); acRcard.NextAction = actionCollectOffPost; acRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_UserCode"); (act as IDCTClient).CachedAction = actionCollectOffPost; break; default: bIsAction = false; break; } } else { bIsAction = false; } if (NeedInputActionCommand == true) { if (bIsAction == false) { msg.Add(new Message(MessageType.Error, "$CS_SystemError_CheckIDNotSupportAction")); ActionRCard actRcard = new ActionRCard(); actRcard.OutMesssage = new Message(MessageType.Normal, "$DCT_PLEASE_ACTION"); actRcard.NeedInputActionCommand = true; this.NextAction = actRcard; } else { NeedInputActionCommand = false; } } #endregion msg.Add(new Message(MessageType.Data, "", new object[] { args })); } return(msg); }