Пример #1
0
        public Package Unpack(IPEndPoint iep, byte[] data)
        {
            BeginWriting();
            mWriter.Write(data);
            EndWriting();

            BinaryReader reader = BeginReading();
            char         cmd    = (char)reader.ReadByte();

            if (_GroundTruthCmdList.Contains(cmd))
            {
                StringPackage pkg = new StringPackage(null, iep, data);
                return(pkg);
            }
            else
            {
                Int16 frame = (Int16)reader.ReadInt16();
                Int16 len   = (Int16)reader.ReadInt16();

                byte[] rdata = null;
                if (len > 0)
                {
                    rdata = reader.ReadBytes(len);
                }


                TerminalPackage pkg = new TerminalPackage(null, iep, cmd, frame, len, rdata);


                return(pkg);
            }
        }
Пример #2
0
        void ParseByteFromString(StringPackage pkg)
        {

            QueueNeedRsp.Instance.RemovePackage(pkg._Cmd);


            if (pkg._Cmd == 'g')
            {

                ReceiveGroundTruth(pkg);
            }
            else if (pkg._Cmd == 'Y')
            {

                ReceiveSyncRsp(pkg);
            }


            else
            {

                Console.WriteLine("ReceiveData Empty");
            }

        }
Пример #3
0
        void ParseByteFromString(StringPackage pkg)
        {
            MainEntry._Logger.Debug("Receive ParseByteFromString:" + pkg._Cmd);
            QueueNeedRsp.Instance.RemovePackage(pkg._Cmd);


            if (pkg._Cmd == 'g')
            {
                //ReceiveGroundTruth(pkg);
            }
            else if (pkg._Cmd == 'Y')
            {
                //ReceiveSyncRsp(pkg);
            }
            else if (pkg._Cmd == 'y')
            {
                //DateTime now = DateTime.Now;
                //pkg._AddtionalData = now;
                //ReceiveSyncAutoRsp(pkg);
            }


            else
            {
                Console.WriteLine("ReceiveData Empty");
            }
        }
Пример #4
0
 void ReceiveSyncRsp(StringPackage pkg)
 {
     if (pkg._StringContent == "Y>o")
     {
         Console.WriteLine("ReceiveSyncRsp OK");
         MainEntry.SendCBParse("SendY", "");
     }
     else if (pkg._StringContent == "Y>e")
     {
         Console.WriteLine("ReceiveSyncRsp Failed");
         MainEntry.SendCBParse("SendY", "error");
     }
 }
Пример #5
0
        void ReceiveSyncRsp(StringPackage pkg)
        {
            if (pkg._StringContent == "Y>o")
            {

                Console.WriteLine("ReceiveSyncRsp OK");
                Program.SendToWeb(SendCmdJson("syncrsp", pkg._ReceiveFrom.Address.ToString(), "ok"));
            }
            else if (pkg._StringContent == "Y>e")
            {

                Console.WriteLine("ReceiveSyncRsp Failed");
                Program.SendToWeb(SendCmdJson("syncrsp", pkg._ReceiveFrom.Address.ToString(), "failed"));
            }
        }
Пример #6
0
        public StringPackage SendGroundTruthRsp(IPEndPoint iep,bool succ)
        {
            string str;
            if (succ)
            {
                str = "G>o";
            }
            else
            {
                str = "G>e";

            }
            StringPackage pkg = new StringPackage(iep, null, str);

            return pkg;
        }
Пример #7
0
        void ReceiveSyncAutoRsp(StringPackage pkg)
        {
            if (pkg._StringContent.StartsWith("y"))
            {
                string T1 = pkg._StringContent.Replace("y>", "Y>");

                DateTime recTime = (DateTime)pkg._AddtionalData;
                string   T2      = string.Format("+{0:D2}:{1:D2}:{2:D2}:{3}", recTime.Hour, recTime.Minute, recTime.Second, recTime.Millisecond);

                DateTime now = DateTime.Now;
                string   T3  = string.Format("+{0:D2}:{1:D2}:{2:D2}:{3}", now.Hour, now.Minute, now.Second, now.Millisecond);

                string str = T1 + T2 + T3;
                Console.WriteLine("ReceiveSyncAuto OK");
                MainEntry.SendToTerminal(new StringPackage(pkg._ReceiveFrom, null, str), false);
            }
        }
Пример #8
0
        void ReceiveGroundTruth(StringPackage pkg)
        {
            string s = pkg._StringContent;
            int start = s.IndexOf('>');
            int end = s.IndexOf('=');
            string time = s.Substring(start + 1, end - start - 1);
            string lr = s.Substring(end + 1, 1);

            string[] timeparam = time.Split(':');
            if(timeparam.Length == 4)
            {
                int hour = Convert.ToInt32(timeparam[0]);
                int min = Convert.ToInt32(timeparam[1]);
                int sec = Convert.ToInt32(timeparam[2]);
                int ms = Convert.ToInt32(timeparam[3]);
            }
            if (_MySqlConnector != null)
            {
                _MySqlConnector.InsertGroundTruth(pkg._ReceiveFrom.Address.ToString(), time, Convert.ToInt16(lr));

            }
        }