コード例 #1
0
        public override void ReceivedAllData(string data)
        {
            ECString = data;
            WriteECCommLog("[RECEIVED], " + data);

            if (data.Trim() == "")
            {
                var sendData = new FASendData();
                sendData.Result = FAResult.FAIL;
                sendData.Msg = "EMPTY DATA";
                SendCommand(sendData);
                return;
            }

            if (data.Length < 16)
            {
                var sendData = new FASendData();
                sendData.Result = FAResult.FAIL;
                sendData.Msg = "NOT FOUND HEADER. DATA LENGTH IS TOO SHORT.(DATA LENGTH < 16)";
                SendCommand(sendData);
                return;
            }

            string[] splitData = new string[2];
            splitData[0] = data.Substring(0, 16);
            splitData[1] = data.Substring(16);
            //if (splitData.Length < 2) return;

            string head = splitData[0];
            string body = splitData[1];

            try
            {
                bool result = false;

                string command = GetCommand(body);
                string errMessage = string.Empty;

                if (command == "PRODUCT_INFO")
                {
                    List<string> err = new List<string>();
                    result = ReceivedDataInfo.ReceiveData.Parsing(body, out err);
                    errMessage = string.Join("\n", err);
                }

                ReceivedDataInfo.Error = !result;
                ReceivedDataInfo.ErrorMessage = string.Join("\n", errMessage);
                ReceivedDataInfo.Exist = true;

                FAReceivedDataInfo tempReceiveData = new FAReceivedDataInfo();
                ReceivedDataInfo.CopyTo(tempReceiveData);

                if (OnReceivedData != null)
                    OnReceivedData(this, new FAGenericEventArgs<FAReceivedDataInfo>(tempReceiveData));

                var sendData = new FASendData();
                if (result)
                    sendData.Result = FAResult.PASS;
                else
                {
                    sendData.Result = FAResult.FAIL;
                    sendData.Msg = errMessage;
                }

                SendCommand(sendData);
            }
            catch
            {
                return;
            }
        }
コード例 #2
0
        public void SendCommand(FASendData command)
        {
            try
            {
                string msg = command.ToCommand();
                string header = GetHeader(msg);

                this.SendData(header, msg);

                WriteECCommLog(string.Format("[SEND], {0}", header));
                WriteECCommLog(string.Format("[SEND], ", msg));
            }
            catch (Exception e)
            {
                FAFramework.Manager.LogManager.Instance.WriteSystemLog("VT8792 INTERFACE PART\n"
                    + this.FullName + "\n"
                    + e.ToString());
            }
        }