Пример #1
0
 /// <summary>
 /// 上工序校验
 /// </summary>
 /// <param name="session"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static bool CheckRoute(TransmitData data, string deviceID, bool first, string Result)
 {
     try
     {
         //上工序校验
         DM_SFCInterface DM_SFC      = new DM_SFCInterface();
         DataTable       dt          = DM_SFC.SFC_DM_CheckRoute(data.SN, string.IsNullOrWhiteSpace(deviceID) ? data.EquipmentID : deviceID, first ? data.WO : "", Result);//FAIL
         string          CheckStatus = dt.Rows[0][0].ToString().ToString();
         string          ReturnMsg   = dt.Rows[0][1].ToString().ToString();
         if (CheckStatus == "1") // 成功
         {
             data.CheckResult = CheckResult.OK.ToString();
             return(true);
         }
         else
         {
             data.CheckResult = CheckResult.ERROR.ToString();
             data.Description = ReturnMsg;
             return(false);
         }
     }
     catch (Exception e)
     {
         data.CheckResult = CheckResult.ERROR.ToString();
         data.Description = e.Message;
         return(false);
     }
 }
Пример #2
0
 /// <summary>
 /// 上工序校验
 /// </summary>
 /// <param name="session"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static bool CheckRouteOnlyCheck(TransmitData data)
 {
     try
     {
         //上工序校验
         DM_SFCInterface DM_SFC      = new DM_SFCInterface();
         DataTable       dt          = DM_SFC.SFC_DM_CheckRouteOnlyCheck(data.SN, data.EquipmentID, "", "");//FAIL
         string          CheckStatus = dt.Rows[0][0].ToString().ToString();
         string          ReturnMsg   = dt.Rows[0][1].ToString().ToString();
         if (CheckStatus == "1") // 成功
         {
             data.CheckResult = CheckResult.OK.ToString();
             return(true);
         }
         else
         {
             data.CheckResult = CheckResult.ERROR.ToString();
             data.Description = ReturnMsg;
             return(false);
         }
     }
     catch (Exception e)
     {
         data.CheckResult = CheckResult.ERROR.ToString();
         data.Description = e.Message;
         return(false);
     }
 }
Пример #3
0
        /// <summary>
        /// 关键字段为空时处理方法
        /// </summary>
        /// <param name="_session"></param>
        /// <param name="_transData"></param>
        /// <param name="_keyWord"></param>
        public static void KeyWordIsNullRecv(MesSession _session, TransmitData _transData, string _keyWord)
        {
            _transData.CheckResult = CheckResult.ERROR.ToString();
            _transData.Description = _keyWord + " is null or white space or format error ?";
            string msg = _transData.Func + " " + JsonHelper.Serialize(_transData) + Environment.NewLine;

            _session.Send(msg);
            _session.Logger.Error(_transData.CheckResult + "---" + _transData.Description);
        }
Пример #4
0
        public MesRequestInfo(string header, string body, string fullData, TransmitData tData)
        {
            Key    = header;
            Header = header;
            Body   = body;
            Data   = fullData;

            TData = new TransmitData();
            TData = tData;
        }
Пример #5
0
        protected override MesRequestInfo ProcessMatchedRequest(byte[] data, int offset, int length)
        {
            TransmitData TData       = new TransmitData();
            string       cmdFullText = string.Empty;
            string       key         = string.Empty;
            string       body        = string.Empty;
            string       strTData    = string.Empty;

            //string[] parameters = null;

            cmdFullText = System.Text.UTF8Encoding.UTF8.GetString(data, offset, length);// data.ReadString(data.Length, Encoding.UTF8);
            key         = Regex.Split(cmdFullText, "\u0020")[0];
            body        = string.Join("", cmdFullText.ToArray().Skip(key.ToArray().Length + 1).ToList());
            body        = body.TrimEnd("\r\n".ToCharArray());
            TData       = JsonHelper.Deserialize <TransmitData>(body);
            if (TData != null)
            {
                TData.Func = key;
            }
            return(new MesRequestInfo(key, body, cmdFullText, TData));
        }
Пример #6
0
        //

        #endregion

        #region 客户端发送消息

        private void SendFactory(string funCode)
        {
            try
            {
                MesSession mesSession = (MesSession)this.cmbClients.SelectedItem;
                if (mesSession == null)
                {
                    ShowMessage("没有选中任何在线设备!");
                    return;
                }
                if (!mesSession.Connected)
                {
                    ShowMessage("目标设备不在线!");
                    return;
                }

                TransmitData tData = null;
                switch (funCode)
                {
                case "ISR":
                    ShowMessage("询问设备是否具备开工条件.");
                    tData = new TransmitData(WO, GlobalData.EquipmentNO, null, null, null, null);
                    break;

                case "SND":
                    ShowMessage("彩盒规格校验ok,下发SN打印.");
                    tData = new TransmitData(WO, GlobalData.EquipmentNO, SN, null, null, null);
                    tData.Items.Add("url", GlobalData.URL);
                    break;
                }
                string msg  = funCode + GlobalData.SpacePoint + JsonHelper.Serialize(tData) + Environment.NewLine; //一定要加上分隔符
                byte[] bMsg = System.Text.Encoding.UTF8.GetBytes(msg);                                             //消息使用UTF-8编码
                mesSession.Send(new ArraySegment <byte>(bMsg, 0, bMsg.Length));
            }
            catch (Exception ee)
            {
                ShowMessage(ee.Message);
            }
        }
Пример #7
0
        private void SendFactory(string funCode)
        {
            try
            {
                if (GlobalData.currentMesSession == null)
                {
                    DelegateState.MsgView?.Invoke(ColorHelper.MsgOrange, "没有选中任何在线设备!");
                    return;
                }
                if (!GlobalData.currentMesSession.Connected)
                {
                    DelegateState.MsgView?.Invoke(ColorHelper.MsgOrange, "目标设备不在线!");
                    return;
                }

                TransmitData tData = null;
                switch (funCode)
                {
                case "ISR":
                    DelegateState.MsgView?.Invoke(ColorHelper.MsgOrange, "询问设备是否具备开工条件.");
                    tData = new TransmitData(WorkOrder, GlobalData.CH_1_DeviceID, null, null, null, null);
                    break;

                case "SND":
                    DelegateState.MsgView?.Invoke(ColorHelper.MsgOrange, "彩盒规格校验ok,下发SN打印.");
                    tData = new TransmitData(WorkOrder, GlobalData.CH_1_DeviceID, SerialNumber, null, null, null);
                    tData.TestItems.Add("url", GlobalData.URL);
                    break;
                }
                string msg  = funCode + " " + JsonHelper.Serialize(tData) + Environment.NewLine; //一定要加上分隔符
                byte[] bMsg = System.Text.Encoding.UTF8.GetBytes(msg);                           //消息使用UTF-8编码
                GlobalData.currentMesSession.Send(new ArraySegment <byte>(bMsg, 0, bMsg.Length));
            }
            catch (Exception ee)
            {
                DelegateState.MsgView?.Invoke(ColorHelper.MsgRed, ee.Message);
            }
        }