示例#1
0
        private void Parse()
        {
            RxMsg_types parsed_msg  = RxMsg_types.UNDEFINED;
            object      parsed_data = null;

            if (RxBufferList.Count > 0)
            {
                if (String.Compare(RxBufferList[0], RxMsg.texts[RxMsg_types.K_LIVE_OK]) == 0)
                {
                    parsed_msg = RxMsg_types.K_LIVE_OK;
                }
                else if (RxBufferList[0].Length >= RxMsg.texts[RxMsg_types.K_DBG_PID_X].Length && String.Compare(RxBufferList[0].Substring(0, RxMsg.texts[RxMsg_types.K_DBG_PID_X].Length), RxMsg.texts[RxMsg_types.K_DBG_PID_X]) == 0)
                {
                    try
                    {
                        float[] hodnoty = new float[4];
                        parsed_msg = RxMsg_types.K_DBG_PID_X;
                        string[] subretezce = RxBufferList[0].Replace('.', ',').Split(' ');
                        hodnoty[0]  = float.Parse(subretezce[1]);
                        hodnoty[1]  = float.Parse(subretezce[2]);
                        hodnoty[2]  = float.Parse(subretezce[3]);
                        hodnoty[3]  = float.Parse(subretezce[4]);
                        parsed_data = (object)hodnoty;
                    }
                    catch
                    {
                        parsed_msg  = RxMsg_types.UNDEFINED;
                        parsed_data = null;
                    }
                }
                else if (RxBufferList[0].Length >= RxMsg.texts[RxMsg_types.K_DBG_PID_Y].Length && String.Compare(RxBufferList[0].Substring(0, RxMsg.texts[RxMsg_types.K_DBG_PID_Y].Length), RxMsg.texts[RxMsg_types.K_DBG_PID_Y]) == 0)
                {
                    try
                    {
                        float[] hodnoty = new float[4];
                        parsed_msg = RxMsg_types.K_DBG_PID_Y;
                        string[] subretezce = RxBufferList[0].Replace('.', ',').Split(' ');
                        hodnoty[0]  = float.Parse(subretezce[1]);
                        hodnoty[1]  = float.Parse(subretezce[2]);
                        hodnoty[2]  = float.Parse(subretezce[3]);
                        hodnoty[3]  = float.Parse(subretezce[4]);
                        parsed_data = (object)hodnoty;
                    }
                    catch
                    {
                        parsed_msg  = RxMsg_types.UNDEFINED;
                        parsed_data = null;
                    }
                }
                else if (String.Compare(RxBufferList[0], RxMsg.texts[RxMsg_types.K_DBG_RPM]) == 0)
                {
                    UInt32[] hodnoty = new UInt32[4];
                    parsed_msg = RxMsg_types.K_DBG_RPM;
                    string[] subretezce = RxBufferList[0].Split(' ');
                    hodnoty[0]  = UInt32.Parse(subretezce[1]);
                    hodnoty[1]  = UInt32.Parse(subretezce[2]);
                    hodnoty[2]  = UInt32.Parse(subretezce[3]);
                    hodnoty[3]  = UInt32.Parse(subretezce[4]);
                    parsed_data = (object)hodnoty;
                }
                else if (RxBufferList[0].Length >= RxMsg.texts[RxMsg_types.K_PID_SETTED].Length && String.Compare(RxBufferList[0].Substring(0, RxMsg.texts[RxMsg_types.K_PID_SETTED].Length), RxMsg.texts[RxMsg_types.K_PID_SETTED]) == 0)
                {
                    parsed_msg  = RxMsg_types.K_PID_SETTED;
                    parsed_data = (object)RxBufferList[0];
                }

                if (this.LogEvent != null)
                {
                    this.LogEvent(this, new LogArgs(this.RxBufferList[0]));
                }
                this.RxBufferList.RemoveAt(0);
                if (this.RxMessageReceived_event != null)
                {
                    RxMessageReceived_event(this, new ParseMessgaeArgs(parsed_msg, parsed_data));
                }
            }
        }
示例#2
0
 public ParseMessgaeArgs(RxMsg_types type, object data)
 {
     this.Msg_type = type;
     this.Msg_data = data;
 }
示例#3
0
 public ParseMessgaeArgs(RxMsg_types type, object data)
 {
     this.Msg_type = type;
     this.Msg_data = data;
 }