Пример #1
0
        /// <summary>
        /// This function allows to convert the User Inut String before storing the data in the ringbuffer
        /// </summary>
        /// <param name="stringMessage"></param>
        public MsgData getRawMsgWithCurrentViewSettings(string stringMessage)
        {
            // Define the needed Variables
            MsgData message = new MsgData();

            message.setCurrentTimeStamp();

            // Variables for the Split
            string[] splitValues = new string[] { ",", " " };
            string[] splitedMsg  = stringMessage.Split(splitValues, 1024, StringSplitOptions.RemoveEmptyEntries);
            byte[]   rawData     = new byte[splitedMsg.Length];

            // Convert the User Input to the Current Settings
            // Return the Msg with the Current View Configuration
            switch (viewSettings.dataPresentation)
            {
            default:    // ASCII Encoded Strings

                message.value = Converty.specialAsciiStringToMsgData(stringMessage);
                break;

            case 1:    // HEX Values of the Bytes recived

                for (int i = 0; i <= splitedMsg.Length - 1; i++)
                {
                    rawData[i] = Convert.ToByte(splitedMsg[i], 16);
                }

                message.value = rawData;

                break;

            case 2:    // DEC Values of the Bytes recived

                for (int i = 0; i <= splitedMsg.Length - 1; i++)
                {
                    rawData[i] = Convert.ToByte(splitedMsg[i], 10);
                }

                message.value = rawData;

                break;

            case 3:    // BIN Values of the Bytes recived

                for (int i = 0; i <= splitedMsg.Length - 1; i++)
                {
                    rawData[i] = Convert.ToByte(splitedMsg[i], 2);
                }

                message.value = rawData;

                break;
            }

            return(message);
        }
Пример #2
0
        /// <summary>
        /// Send the Data to the Eventhandler.. To update the Main UI and send the Data to teh Connection
        /// </summary>
        private void SendData(string data)
        {
            // Set the User Hint to the TextBox
            MsgData _logMessage = new MsgData();

            _logMessage.value = Converty.specialAsciiStringToMsgData(data);
            _logMessage.type  = MsgData.messageType.send;

            // Set the Event that the User Changed an Input
            MsgSendRecivedEventArgs _msgLogEventArgs = new MsgSendRecivedEventArgs();

            _msgLogEventArgs.msgData = _logMessage;
            msgSendRecived(_msgLogEventArgs);
        }
Пример #3
0
        /// <summary>
        /// Click of the Quick Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void QuickButton_Click(object sender, RoutedEventArgs e)
        {
            Button _quickButton = sender as Button;

            // Set the User Hint to the TextBox
            MsgData logMessage = new MsgData();

            logMessage.value = Converty.specialAsciiStringToMsgData((String)_quickButton.Resources["data"]);
            logMessage.type  = MsgData.messageType.send;

            // Set the Event that the User Changed an Input
            MsgSendRecivedEventArgs msgLogEventArgs = new MsgSendRecivedEventArgs();

            msgLogEventArgs.msgData = logMessage;
            msgSendRecived(msgLogEventArgs);
        }
Пример #4
0
        /// <summary>
        ///  Convert the given Msg to the current view Setting as a String
        /// </summary>
        /// <returns></returns>
        public List <MsgHighlightStruct> getMsgHighlightetListWithCurrentViewSettings(MsgData msg)
        {
            List <MsgHighlightStruct> _list = new List <MsgHighlightStruct>();
            MsgHighlightStruct        returnStruct;

            // Only change the view to the Sended and Recived Data
            if (msg.type == MsgData.messageType.recived || msg.type == MsgData.messageType.send)
            {
                // Return the Msg with the Current View Configuration
                switch (viewSettings.dataPresentation)
                {
                case 1:
                    returnStruct.msgAsString   = Converty.msgDataToHexData(msg);
                    returnStruct.msgStringType = 0;
                    _list.Add(returnStruct);
                    break;

                case 2:
                    returnStruct.msgAsString   = Converty.msgDataToDecData(msg);
                    returnStruct.msgStringType = 0;
                    _list.Add(returnStruct);
                    break;

                case 3:
                    returnStruct.msgAsString   = Converty.msgDataToBinData(msg);
                    returnStruct.msgStringType = 0;
                    _list.Add(returnStruct);
                    break;

                // Default View String with ASCII Chars
                default:
                    //returnMsg = Converty.msgDataToSpecialAsciiString(msg.value);
                    _list = Converty.getMsgDataAsStringWithHighlightetView(msg.value);

                    break;
                }
            }
            else
            {
                returnStruct.msgAsString   = Converty.msgDataToAsciiChar(msg);
                returnStruct.msgStringType = 0;
                _list.Add(returnStruct);
            }


            return(_list);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputKey"></param>
        public void KeyInpuEvent(Key inputKey)
        {
            foreach (Button _button in buttonList)
            {
                if ((Key)_button.Resources["shortCut"] == inputKey)
                {
                    // Set the User Hint to the TextBox
                    MsgData logMessage = new MsgData();
                    logMessage.value = Converty.specialAsciiStringToMsgData((String)_button.Resources["data"]);
                    logMessage.type  = MsgData.messageType.send;

                    // Set the Event that the User Changed an Input
                    MsgSendRecivedEventArgs msgLogEventArgs = new MsgSendRecivedEventArgs();
                    msgLogEventArgs.msgData = logMessage;
                    msgSendRecived(msgLogEventArgs);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Compare the simulation Data with the recived Data. With all the Fancy Placeholders and Special ASCII Chars
        /// </summary>
        /// <param name="recivedMsg"></param>
        /// <param name="simulationMsg"></param>
        /// <returns></returns>
        private bool compareRecivedAndSimMessage(MsgData recivedMsg, string simulationMsg)
        {
            // Clocking the Thread till we found what we are Searching for
            string _myData = Converty.msgDataToSpecialAsciiString(lastMsg.value);

            // Check if we got an Spacer int the String
            if (simulationMsg.IndexOf(SPACE_VALUE.ToString()) > -1)
            {
                string[] _splittedSimulationMsg = simulationMsg.Split(new Char[] { SPACE_VALUE });
                bool     dataValid = true;

                string _myString = _myData;

                foreach (string simulationMsgPart in _splittedSimulationMsg)
                {
                    if (!(_myString.IndexOf(simulationMsgPart) > -1))
                    {
                        // Cut the String that we fount out of the Buffer. So in this case we will check the Abendency in the Messages
                        _myString = _myString.Substring(_myString.IndexOf(simulationMsgPart) + simulationMsgPart.Length);
                        dataValid = false;
                    }
                }

                if (dataValid)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (_myData == simulationMsg)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        /// <summary>
        ///  Convert the given Msg to the current view Setting as a String
        /// </summary>
        /// <returns></returns>
        public string getMsgWithCurrentViewSettings(MsgData msg)
        {
            string returnMsg;

            // Only change the view to the Sended and Recived Data
            if (msg.type == MsgData.messageType.recived || msg.type == MsgData.messageType.send)
            {
                // Return the Msg with the Current View Configuration
                switch (viewSettings.dataPresentation)
                {
                case 1:
                    returnMsg = Converty.msgDataToHexData(msg);
                    break;

                case 2:
                    returnMsg = Converty.msgDataToDecData(msg);
                    break;

                case 3:
                    returnMsg = Converty.msgDataToBinData(msg);
                    break;

                // Default View String with ASCII Chars
                default:
                    returnMsg = Converty.msgDataToSpecialAsciiString(msg.value);
                    break;
                }
            }
            else
            {
                returnMsg = Converty.msgDataToAsciiChar(msg);
            }


            return(returnMsg);
        }
Пример #8
0
        /// <summary>
        /// Compare the simulation Data with the recived Data. With all the Fancy Placeholders and Special ASCII Chars
        /// </summary>
        /// <param name="recivedMsg"></param>
        /// <param name="simulationMsg"></param>
        /// <returns></returns>
        private bool compareRecivedAndSimMessage(MsgData recivedMsg, string simulationMsg)
        {
            // Clocking the Thread till we found what we are Searching for
            string myData = Converty.msgDataToSpecialAsciiString(lastMsg.value);

            // Check if we got an Spacer int the String
            if (simulationMsg.IndexOf(spaceValue.ToString()) > -1)
            {
                string[] splittedSimulationMsg = simulationMsg.Split(new Char[] { spaceValue });
                bool     dataValid             = true;

                string myString = myData;

                foreach (string simulationMsgPart in splittedSimulationMsg)
                {
                    if (!(myString.IndexOf(simulationMsgPart) > -1))
                    {
                        // Cut the String that we fount out of the Buffer. So in this case we will check the Abendency in the Messages
                        myString  = myString.Substring(myString.IndexOf(simulationMsgPart) + simulationMsgPart.Length);
                        dataValid = false;
                    }
                }



                if (dataValid)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (myData == simulationMsg)
            {
                return(true);
            }
            else
            {
                return(false);
            }

            /*
             *
             * int idx = 0;
             * int helper = 0;
             *
             * bool dataValid = false;
             *
             * foreach (string value in splittedData)
             * {
             *
             *  if (simulationMsg.IndexOf(value) == idx && helper == 0)
             *  {
             *      dataValid = true;
             *  }
             *  else if ()
             *  {
             *
             *  }
             *
             *  helper++;
             * }
             */
        }