Пример #1
0
        }//Calculate_Checksum(string)

        private void SetEncodingSequence()
        {
            //reset to full ascii
            _startCode = StartStopCode.START1;
            _stopCode = StartStopCode.STOP1;
            _switchModeIndex = Raw_Data.Length;

            //starting number of 'numbers'
            var StartNumerics = 0;
            foreach (var c in Raw_Data)
            {
                if (Char.IsNumber(c))
                    StartNumerics++;
                else
                    break;
            }//foreach

            if (StartNumerics == Raw_Data.Length)
            {
                //Numeric only mode due to only numbers being present
                _startCode = StartStopCode.START2;
                _stopCode = StartStopCode.STOP2;

                if ((Raw_Data.Length % 2) > 0)
                    _switchModeIndex = RawData.Length - 1;
            }//if
            else
            {
                //ending number of numbers
                var EndNumerics = 0;
                for (var i = Raw_Data.Length - 1; i >= 0; i--)
                {
                    if (Char.IsNumber(Raw_Data[i]))
                        EndNumerics++;
                    else
                        break;
                }//for

                if (StartNumerics >= 4 || EndNumerics >= 4)
                {
                    //hybrid mode will be used
                    if (StartNumerics > EndNumerics)
                    {
                        //start in numeric switching to ascii
                        _startCode = StartStopCode.START2;
                        _stopCode = StartStopCode.STOP2;
                        _switchModeIndex = (StartNumerics % 2) == 1 ? StartNumerics - 1 : StartNumerics;
                    }//if
                    else
                    {
                        //start in ascii switching to numeric
                        _startCode = StartStopCode.START3;
                        _stopCode = StartStopCode.STOP3;
                        _switchModeIndex = (EndNumerics % 2) == 1 ? Raw_Data.Length - EndNumerics + 1 : Raw_Data.Length - EndNumerics;
                    }//else
                }//if
            }//else
        }//SetEncodingSequence
Пример #2
0
        }//Calculate_Checksum(string)

        private void SetEncodingSequence()
        {
            //reset to full ascii
            StartCode = StartStopCode.START1;
            StopCode = StartStopCode.STOP1;
            SwitchModeIndex = Raw_Data.Length;

            //starting number of 'numbers'
            int StartNumerics = 0;
            foreach (char c in Raw_Data)
            {
                if (Char.IsNumber(c))
                    StartNumerics++;
                else
                    break;
            }//foreach

            if (StartNumerics == Raw_Data.Length)
            {
                //Numeric only mode due to only numbers being present
                StartCode = StartStopCode.START2;
                StopCode = StartStopCode.STOP2;

                if ((Raw_Data.Length % 2) > 0)
                    SwitchModeIndex = RawData.Length - 1;
            }//if
            else
            {
                //ending number of numbers
                int EndNumerics = 0;
                for (int i = Raw_Data.Length - 1; i >= 0; i--)
                {
                    if (Char.IsNumber(Raw_Data[i]))
                        EndNumerics++;
                    else
                        break;
                }//for

                if (StartNumerics >= 4 || EndNumerics >= 4)
                {
                    //hybrid mode will be used
                    if (StartNumerics > EndNumerics)
                    {
                        //start in numeric switching to ascii
                        StartCode = StartStopCode.START2;
                        StopCode = StartStopCode.STOP2;
                        SwitchModeIndex = (StartNumerics % 2) == 1 ? StartNumerics - 1 : StartNumerics;
                    }//if
                    else
                    { 
                        //start in ascii switching to numeric
                        StartCode = StartStopCode.START3;
                        StopCode = StartStopCode.STOP3;
                        SwitchModeIndex = (EndNumerics % 2) == 1 ? Raw_Data.Length - EndNumerics + 1 : Raw_Data.Length - EndNumerics;
                    }//else
                }//if
            }//else
        }//SetEncodingSequence
Пример #3
0
        private void SetEncodingSequence()
        {
            StartCode       = StartStopCode.START1;
            StopCode        = StartStopCode.STOP1;
            SwitchModeIndex = Raw_Data.Length;

            int StartNumerics = 0;

            foreach (char c in Raw_Data)
            {
                if (Char.IsNumber(c))
                {
                    StartNumerics++;
                }
                else
                {
                    break;
                }
            }

            if (StartNumerics == Raw_Data.Length)
            {
                StartCode = StartStopCode.START2;
                StopCode  = StartStopCode.STOP2;

                if ((Raw_Data.Length % 2) > 0)
                {
                    SwitchModeIndex = RawData.Length - 1;
                }
            }
            else
            {
                int EndNumerics = 0;
                for (int i = Raw_Data.Length - 1; i >= 0; i--)
                {
                    if (Char.IsNumber(Raw_Data[i]))
                    {
                        EndNumerics++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (StartNumerics >= 4 || EndNumerics >= 4)
                {
                    if (StartNumerics > EndNumerics)
                    {
                        StartCode       = StartStopCode.START2;
                        StopCode        = StartStopCode.STOP2;
                        SwitchModeIndex = (StartNumerics % 2) == 1 ? StartNumerics - 1 : StartNumerics;
                    }
                    else
                    {
                        StartCode       = StartStopCode.START3;
                        StopCode        = StartStopCode.STOP3;
                        SwitchModeIndex = (EndNumerics % 2) == 1 ? Raw_Data.Length - EndNumerics + 1 : Raw_Data.Length - EndNumerics;
                    }
                }
            }
        }