示例#1
0
        public void ConvertSevenDigitNumber()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("1521112");

            Assert.False(expectedResult.Trim().ToUpper().Equals("ONE MILLION FIVE HUNDRED TWENTY ONE THOUSAND ONE HUNDRED TWELVE"));
        }
 public static ConverterRepository AddTemperatureConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Temperature.Celsius, new LinearConverter())
            .Add(Temperature.Fahrenheit, new LinearConverter(offset: -32, ratio: 5.0 / 9, offsetFirst: true))
            );
 }
示例#3
0
        public void ConvertNegativeDigitCurrency()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("-7");

            Assert.True(expectedResult.Trim().ToUpper().Equals("MINUS SEVEN DOLLARS"));
        }
示例#4
0
        public void ConvertSixDigitCurrency()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("152111");

            Assert.True(expectedResult.Trim().ToUpper().Equals("ONE HUNDRED FIFTY TWO THOUSAND ONE HUNDRED ELEVEN DOLLARS"));
        }
示例#5
0
        public void ConvertDoubleDigitCurrency()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("52");

            Assert.True(expectedResult.Trim().ToUpper().Equals("FIFTY TWO DOLLARS"));
        }
示例#6
0
        public void ConvertBothDigitNumber()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("17.76");

            Assert.False(expectedResult.Trim().ToUpper().Equals("SEVENTEEN  POINT SEVEN SIX"));
        }
示例#7
0
        public void ConvertBothDigitCurrency()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("17.76");

            Assert.True(expectedResult.Trim().ToUpper().Equals("SEVENTEEN DOLLARS  AND SEVEN SIX CENT"));
        }
示例#8
0
        public void ConvertEightDigitCurrency()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("15211125");

            Assert.True(expectedResult.Trim().ToUpper().Equals("FIFTEEN MILLION TWO HUNDRED ELEVEN THOUSAND ONE HUNDRED TWENTY FIVE DOLLARS"));
        }
示例#9
0
        public void ConvertSingleDigitNumber()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("7");

            Assert.False(expectedResult.Trim().ToUpper().Equals("SEVEN"));
        }
 public static ConverterRepository AddVolumeConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Volume.CupUS, new LinearConverter(ratio: 236.588237))
            .Add(Volume.PintUS, new LinearConverter(ratio: 473.176473))
            .Add(Volume.PintUK, new LinearConverter(ratio: 568.26125))
            .Add(Volume.QuartUS, new LinearConverter(ratio: 946.352946))
            .Add(Volume.QuartUK, new LinearConverter(ratio: 1136.5225))
            .Add(Volume.GallonUS, new LinearConverter(ratio: 3785.411784))
            .Add(Volume.GallonUK, new LinearConverter(ratio: 4546.09))
            .Add(Volume.Liter, new LinearConverter(ratio: 1000))
            .Add(Volume.TeaspoonUS, new LinearConverter(ratio: 4.92892159375))
            .Add(Volume.TablespoonUS, new LinearConverter(ratio: 14.78676478125))
            .Add(Volume.CubicCentimeter, new LinearConverter())
            .Add(Volume.CubicYard, new LinearConverter(ratio: 764554.857984))
            .Add(Volume.CubicMeter, new LinearConverter(ratio: 1000000))
            .Add(Volume.Milliliter, new LinearConverter(ratio: 1))
            .Add(Volume.CubicInch, new LinearConverter(ratio: 16.387064))
            .Add(Volume.CubicFoot, new LinearConverter(ratio: 28316.846592))
            .Add(Volume.FluidOunceUS, new LinearConverter(ratio: 29.5735295625))
            .Add(Volume.FluidOunceUK, new LinearConverter(ratio: 28.4130625))
            .Add(Volume.TeaspoonUK, new LinearConverter(ratio: 5.91938802083333333333))
            .Add(Volume.TablespoonUK, new LinearConverter(ratio: 17.7581640625))
            .Add(Volume.CoffeeCup, new LinearConverter(ratio: 236.5882))
            .Add(Volume.Bathtub, new LinearConverter(ratio: 378541.2))
            .Add(Volume.SwimmingPool, new LinearConverter(ratio: 3750000000))
            );
 }
示例#11
0
        public void ConvertTripleDigitCurrency()
        {
            IConverterRepository converter = new ConverterRepository();
            string expectedResult          = converter.ConvertNumberToWord("152");

            Assert.That(expectedResult.Trim().ToUpper().Equals("ONE HUNDRED FIFTY TWO DOLLARS"));
        }
 public static ConverterRepository AddAngleConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Angle.Degree, new LinearConverter())
            .Add(Angle.Radian, new LinearConverter(ratio: 57.29577951308233))
            .Add(Angle.Gradian, new LinearConverter(ratio: 0.9))
            );
 }
示例#13
0
        public string GetResponseCommand(string command)
        {
            command = ConverterRepository.ConvertDecimalStringToHexString(command);
            string singleResponseTranslateByCommand = _rootOjectResponse.Answer.Where(x => string.Equals(x.Command, command, StringComparison.OrdinalIgnoreCase))
                                                      .Select(h => h.Translate).FirstOrDefault();

            return(singleResponseTranslateByCommand);
        }
 public static async Task <ConverterRepository> AddOrUpdateCurrencyConverters(this ConverterRepository converterRepository, ICurrencyDataLoader loader)
 {
     foreach (var item in await loader.LoadCurrencyConverterItem())
     {
         var unit = new Unit(DefaultCategories.Currency, item.CurrencyCode);
         converterRepository[unit] = new LinearConverter(ratio: 1.0 / item.Ratio);
     }
     return(converterRepository);
 }
示例#15
0
        public bool GetValidator(string data)
        {
            data = ConverterRepository.ConvertDecimalStringToHexString(data);
            bool singleResponseTranslate = _rootOjectResponse.Answer.Any(x => (string.Equals(x.Data, data, StringComparison.OrdinalIgnoreCase)) &&
                                                                         (string.Equals(x.Validation, "true", StringComparison.OrdinalIgnoreCase)));


            return(singleResponseTranslate);
        }
示例#16
0
        private static bool CheckRightEOF(string incomingByte)
        {
            incomingByte = ConverterRepository.ConvertDecimalStringToHexString(incomingByte);

            if (XmlFilter.Instance.GetEOF() == incomingByte)
            {
                return(true);
            }
            return(false);
        }
 public static ConverterRepository AddPressureConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Pressure.Atmosphere, new LinearConverter())
            .Add(Pressure.Bar, new LinearConverter(ratio: 0.9869232667160128))
            .Add(Pressure.KiloPascal, new LinearConverter(ratio: 0.0098692326671601))
            .Add(Pressure.MillimeterOfMercury, new LinearConverter(ratio: 0.0013155687145324))
            .Add(Pressure.Pascal, new LinearConverter(ratio: 9.869232667160128e-6))
            .Add(Pressure.PSI, new LinearConverter(ratio: 0.068045961016531))
            );
 }
示例#18
0
        public string GetResponseTranslate(string command, string data, string eof)
        {
            command = ConverterRepository.ConvertDecimalStringToHexString(command);
            data    = ConverterRepository.ConvertDecimalStringToHexString(data);
            eof     = ConverterRepository.ConvertDecimalStringToHexString(eof);
            string singleResponseTranslate = _rootOjectResponse.Answer.Where(x => (string.Equals(x.Data, data, StringComparison.OrdinalIgnoreCase)) &&
                                                                             (string.Equals(x.Command, command, StringComparison.OrdinalIgnoreCase)) &&
                                                                             (string.Equals(x.Eof, eof, StringComparison.OrdinalIgnoreCase)))
                                             .Select(n => n.Translate).FirstOrDefault();

            return(singleResponseTranslate);
        }
 public static ConverterRepository AddPowerConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Power.BritishThermalUnitPerMinute, new LinearConverter(ratio: 17.58426666666667))
            .Add(Power.FootPoundPerMinute, new LinearConverter(ratio: 0.0225969658055233))
            .Add(Power.Watt, new LinearConverter())
            .Add(Power.Kilowatt, new LinearConverter(ratio: 1000))
            .Add(Power.Horsepower, new LinearConverter(ratio: 745.69987158227022))
            .Add(Power.LightBulb, new LinearConverter(ratio: 60))
            .Add(Power.Horse, new LinearConverter(ratio: 745.7))
            .Add(Power.TrainEngine, new LinearConverter(ratio: 2982799.486329081))
            );
 }
 public static ConverterRepository AddTimeConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Time.Day, new LinearConverter(ratio: 86400))
            .Add(Time.Second, new LinearConverter())
            .Add(Time.Week, new LinearConverter(ratio: 604800))
            .Add(Time.Year, new LinearConverter(ratio: 31557600))
            .Add(Time.Millisecond, new LinearConverter(ratio: 0.001))
            .Add(Time.Microsecond, new LinearConverter(ratio: 0.000001))
            .Add(Time.Minute, new LinearConverter(ratio: 60))
            .Add(Time.Hour, new LinearConverter(ratio: 3600))
            );
 }
 public static ConverterRepository AddEnergyConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Energy.Calorie, new LinearConverter(ratio: 4.184))
            .Add(Energy.Kilocalorie, new LinearConverter(ratio: 4184))
            .Add(Energy.BritishThermalUnit, new LinearConverter(ratio: 1055.056))
            .Add(Energy.Kilojoule, new LinearConverter(ratio: 1000))
            .Add(Energy.ElectronVolt, new LinearConverter(ratio: 0.0000000000000000001602176565))
            .Add(Energy.Joule, new LinearConverter())
            .Add(Energy.FootPound, new LinearConverter(ratio: 1.3558179483314))
            .Add(Energy.Battery, new LinearConverter(ratio: 9000))
            .Add(Energy.Banana, new LinearConverter(ratio: 439614))
            .Add(Energy.SliceOfCake, new LinearConverter(ratio: 1046700))
            );
 }
 public static ConverterRepository AddSpeedConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Speed.CentimetersPerSecond, new LinearConverter())
            .Add(Speed.FeetPerSecond, new LinearConverter(ratio: 30.48))
            .Add(Speed.KilometersPerHour, new LinearConverter(ratio: 27.777777777777777777778))
            .Add(Speed.Knot, new LinearConverter(ratio: 51.44))
            .Add(Speed.Mach, new LinearConverter(ratio: 34030))
            .Add(Speed.MetersPerSecond, new LinearConverter(ratio: 100))
            .Add(Speed.MilesPerHour, new LinearConverter(ratio: 44.7))
            .Add(Speed.Turtle, new LinearConverter(ratio: 8.94))
            .Add(Speed.Horse, new LinearConverter(ratio: 2011.5))
            .Add(Speed.Jet, new LinearConverter(ratio: 24585))
            );
 }
 public static ConverterRepository AddLengthConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Length.Inch, new LinearConverter(ratio: 0.0254))
            .Add(Length.Foot, new LinearConverter(ratio: 0.3048))
            .Add(Length.Yard, new LinearConverter(ratio: 0.9144))
            .Add(Length.Mile, new LinearConverter(ratio: 1609.344))
            .Add(Length.Micron, new LinearConverter(ratio: 0.000001))
            .Add(Length.Millimeter, new LinearConverter(ratio: 0.001))
            .Add(Length.Nanometer, new LinearConverter(ratio: 0.000000001))
            .Add(Length.Centimeter, new LinearConverter(ratio: 0.01))
            .Add(Length.Meter, new LinearConverter())
            .Add(Length.Kilometer, new LinearConverter(ratio: 1000))
            .Add(Length.NauticalMile, new LinearConverter(ratio: 1852))
            .Add(Length.Paperclip, new LinearConverter(ratio: 0.035052))
            .Add(Length.Hand, new LinearConverter(ratio: 0.18669))
            .Add(Length.JumboJet, new LinearConverter(ratio: 76))
            );
 }
        public static ConverterRepository CreateRepository()
        {
            var res = new ConverterRepository();

            return(res
                   .AddAreaConverters()
                   .AddDataConverters()
                   .AddEnergyConverters()
                   .AddLengthConverters()
                   .AddPowerConverters()
                   .AddTimeConverters()
                   .AddVolumeConverters()
                   .AddWeightConverters()
                   .AddSpeedConverters()
                   .AddAngleConverters()
                   .AddPressureConverters()
                   .AddTemperatureConverters()
                   );
        }
 public static ConverterRepository AddDataConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Data.Bit, new LinearConverter(ratio: 0.000000125))
            .Add(Data.Byte, new LinearConverter(ratio: 0.000001))
            .Add(Data.Kilobyte, new LinearConverter(ratio: 0.001))
            .Add(Data.Megabyte, new LinearConverter())
            .Add(Data.Gigabyte, new LinearConverter(ratio: 1000))
            .Add(Data.Terabyte, new LinearConverter(ratio: 1000000))
            .Add(Data.Petabyte, new LinearConverter(ratio: 1000000000))
            .Add(Data.Exabytes, new LinearConverter(ratio: 1000000000000))
            .Add(Data.Zetabytes, new LinearConverter(ratio: 1000000000000000))
            .Add(Data.Yottabyte, new LinearConverter(ratio: 1000000000000000000))
            .Add(Data.Kilobit, new LinearConverter(ratio: 0.000125))
            .Add(Data.Megabit, new LinearConverter(ratio: 0.125))
            .Add(Data.Gigabit, new LinearConverter(ratio: 125))
            .Add(Data.Terabit, new LinearConverter(ratio: 125000))
            .Add(Data.Petabit, new LinearConverter(ratio: 125000000))
            .Add(Data.Exabits, new LinearConverter(ratio: 125000000000))
            .Add(Data.Zetabits, new LinearConverter(ratio: 125000000000000))
            .Add(Data.Yottabit, new LinearConverter(ratio: 125000000000000000))
            .Add(Data.Gibibits, new LinearConverter(ratio: 134.217728))
            .Add(Data.Gibibytes, new LinearConverter(ratio: 1073.741824))
            .Add(Data.Kibibits, new LinearConverter(ratio: 0.000128))
            .Add(Data.Kibibytes, new LinearConverter(ratio: 0.001024))
            .Add(Data.Mebibits, new LinearConverter(ratio: 0.131072))
            .Add(Data.Mebibytes, new LinearConverter(ratio: 1.048576))
            .Add(Data.Pebibits, new LinearConverter(ratio: 140737488.355328))
            .Add(Data.Pebibytes, new LinearConverter(ratio: 1125899906.842624))
            .Add(Data.Tebibits, new LinearConverter(ratio: 137438.953472))
            .Add(Data.Tebibytes, new LinearConverter(ratio: 1099511.627776))
            .Add(Data.Exbibits, new LinearConverter(ratio: 144115188075.855872))
            .Add(Data.Exbibytes, new LinearConverter(ratio: 1152921504606.846976))
            .Add(Data.Zebibits, new LinearConverter(ratio: 147573952589676.412928))
            .Add(Data.Zebibytes, new LinearConverter(ratio: 1180591620717411.303424))
            .Add(Data.Yobibits, new LinearConverter(ratio: 151115727451828646.838272))
            .Add(Data.Yobibytes, new LinearConverter(ratio: 1208925819614629174.706176))
            .Add(Data.FloppyDisk, new LinearConverter(ratio: 1.474560))
            .Add(Data.CD, new LinearConverter(ratio: 734.003200))
            .Add(Data.DVD, new LinearConverter(ratio: 5046.586573))
            );
 }
 public static ConverterRepository AddAreaConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Area.Acre, new LinearConverter(ratio: 4046.8564224))
            .Add(Area.SquareMeter, new LinearConverter())
            .Add(Area.SquareFoot, new LinearConverter(ratio: 0.09290304))
            .Add(Area.SquareYard, new LinearConverter(ratio: 0.83612736))
            .Add(Area.SquareMillimeter, new LinearConverter(ratio: 0.000001))
            .Add(Area.SquareCentimeter, new LinearConverter(ratio: 0.0001))
            .Add(Area.SquareInch, new LinearConverter(ratio: 0.00064516))
            .Add(Area.SquareMile, new LinearConverter(ratio: 2589988.110336))
            .Add(Area.SquareKilometer, new LinearConverter(ratio: 1000000))
            .Add(Area.Hectare, new LinearConverter(ratio: 10000))
            .Add(Area.Hand, new LinearConverter(ratio: 0.012516104))
            .Add(Area.Paper, new LinearConverter(ratio: 0.06032246))
            .Add(Area.SoccerField, new LinearConverter(ratio: 10869.66))
            .Add(Area.Castle, new LinearConverter(ratio: 100000))
            .Add(Area.Pyeong, new LinearConverter(ratio: 400.0 / 121.0))
            );
 }
示例#27
0
        public static string GeneralMessageRecivedTranslation(string customText, bool isAutoMeasure = false)
        {
            if (ByteMessages.Instance.MeasureModeIncoming[0] != null &&
                ByteMessages.Instance.MeasureModeIncoming[1] != null &&
                ByteMessages.Instance.MeasureModeIncoming[2] != null)
            {
                _getSelectCardTypeName = XmlFilter.Instance.GetSelectedCardTypeName
                                             (ConverterRepository.ConvertDecimalStringToHexString(ByteMessages.Instance.MeasureModeIncoming[0].ToString()));
                _getCurrentMeasurement = XmlFilter.Instance.GetCurrentMeasurement(XmlFilter.Instance.GetSelectedCardTypeName
                                                                                      (ConverterRepository.ConvertDecimalStringToHexString(ByteMessages.Instance.MeasureModeIncoming[0].ToString())), LoopCounter, isAutoMeasure);
                _getResponseData = XmlFilter.Instance.GetResponseData
                                       (ConverterRepository.ConvertDecimalStringToHexString(ByteMessages.Instance.MeasureModeIncoming[1].ToString()));
            }

            return("Info: " + DateTime.Now.ToString("HH:mm:ss").ToString() + " -> " +
                   _getSelectCardTypeName
                   + " -> " +
                   _getCurrentMeasurement
                   + " -> " +
                   _getResponseData
                   + customText + "\n");
        }
示例#28
0
        public IndexerTests()
        {
            _storageLocation = new DirectoryInfo("learning");
            if (_storageLocation.Exists)
            {
                _storageLocation.Delete(true);
                _storageLocation.Refresh();
            }

            _learningRepository = new FileSystemLearningRepository(_storageLocation);

            var indexLocation = new DirectoryInfo("index");

            if (indexLocation.Exists)
            {
                indexLocation.Delete(true);
                indexLocation.Refresh();
            }

            _converterRepository = new ConverterRepository(new TextItemConverter());

            _directory = FSDirectory.Open(indexLocation);
        }
 public static ConverterRepository AddWeightConverters(this ConverterRepository converterRepository)
 {
     return(converterRepository
            .Add(Weight.Kilogram, new LinearConverter())
            .Add(Weight.Hectogram, new LinearConverter(ratio: 0.1))
            .Add(Weight.Decagram, new LinearConverter(ratio: 0.01))
            .Add(Weight.Gram, new LinearConverter(ratio: 0.001))
            .Add(Weight.Pound, new LinearConverter(ratio: 0.45359237))
            .Add(Weight.Ounce, new LinearConverter(ratio: 0.028349523125))
            .Add(Weight.Milligram, new LinearConverter(ratio: 0.000001))
            .Add(Weight.Centigram, new LinearConverter(ratio: 0.00001))
            .Add(Weight.Decigram, new LinearConverter(ratio: 0.0001))
            .Add(Weight.LongTon, new LinearConverter(ratio: 1016.0469088))
            .Add(Weight.Tonne, new LinearConverter(ratio: 1000))
            .Add(Weight.Stone, new LinearConverter(ratio: 6.35029318))
            .Add(Weight.Carat, new LinearConverter(ratio: 0.0002))
            .Add(Weight.ShortTon, new LinearConverter(ratio: 907.18474))
            .Add(Weight.Snowflake, new LinearConverter(ratio: 0.000002))
            .Add(Weight.SoccerBall, new LinearConverter(ratio: 0.4325))
            .Add(Weight.Elephant, new LinearConverter(ratio: 4000))
            .Add(Weight.Whale, new LinearConverter(ratio: 90000))
            );
 }
示例#30
0
        private void DataRecieved(object sender, SerialDataReceivedEventArgs e)
        {
            if (SerialPortManager.Instance.IsOpen)
            {
                try
                {
                    byte received_byte = Convert.ToByte(SerialPortManager.Instance.ReadByte());

                    _receivedBytes[this.countBytes] = received_byte;
                    string incomingByte = received_byte.ToString();

                    ByteMessageBuilderRepository.SetStrArrayByIndex(ByteMessages.Instance.MeasureModeIncoming, countBytes, incomingByte);

                    //all bytes arrived
                    if (countBytes == 2)
                    {
                        countBytes = 0;
                        if (WasItRun)
                        {
                            IsRunningNow = GeneralMessageCollection.IsRunningStateChecker(true);

                            TimeOutValidator(TimeOutValidatorStates.Reset);

                            if (ValidatorIncomingMessage.ValidationEOF())
                            {
                                if (XmlFilter.Instance.IsCommonIncluded(SelectedCardType) == true)
                                {
                                    _commonMeasures = XmlFilter.Instance.GetNumberOfExpectedMeasureState(XmlFilter.Instance.GetDefaultName());
                                }
                                else
                                {
                                    _commonMeasures = 0;
                                }

                                if (XmlFilter.Instance.GetResponseCommand(this._receivedBytes[0].ToString()) == "VOIP_UDP_Start")
                                {
                                    this._udp           = new Udp();
                                    this._udp.IsEnabled = true;

                                    this._udp.SendBytes.Add(_receivedBytes[1]);
                                }
                                else if (XmlFilter.Instance.GetResponseCommand(this._receivedBytes[0].ToString()) == "VOIP_UDP_Cont")
                                {
                                    this._udp.IsEnabled = true;
                                    this._udp.SendBytes.Add(this._receivedBytes[1]);
                                }
                                else if (XmlFilter.Instance.GetResponseCommand(_receivedBytes[0].ToString()) == "VOIP_UDP_Stop")
                                {
                                    this._udp.IsEnabled = true;
                                    CTRL_udpClient.Send(this._udp.SendBytes.ToArray(), this._udp.SendBytes.Count, this._udp.IPADDRESS, this._udp.PORT);

                                    this._udp.IsFinished = true;
                                }

                                if (!this._udp.IsEnabled)
                                {
                                    //if the incoming messages's number is equle with the required number from XML file
                                    if (_incomingMeasureCounter == (XmlFilter.Instance.GetNumberOfExpectedMeasureState(SelectedCardType)) + _commonMeasures)
                                    {
                                        TimeOutValidator(TimeOutValidatorStates.Stop);
                                        MessageRecievedText = GeneralMessageCollection.GeneralMessageRecivedTranslation(" -> Validate OK", true) + MessageRecievedText;
                                        _validateFinished   = true;
                                        GeneralMessageCollection.LoopCounter = 0;
                                    }
                                    else
                                    {
                                        if (SelectedMeasureType != "AutoMeasure")
                                        {
                                            IEnumerable <String> _measureList = XmlFilter.Instance.GetMeasureListByCardTypeWithoutAuto(SelectedCardType);

                                            var index = _measureList.ToList().IndexOf(SelectedMeasureType);
                                            GeneralMessageCollection.LoopCounter = index;
                                            TimeOutValidator(TimeOutValidatorStates.Stop);
                                            MessageRecievedText = GeneralMessageCollection.GeneralMessageRecivedTranslation("") + MessageRecievedText;
                                            GeneralMessageCollection.LoopCounter = 0;
                                            _validateFinished = false;
                                        }
                                        else
                                        {
                                            //when it is not validated yet and AutoMeasure.
                                            TimeOutValidator(TimeOutValidatorStates.Reset);
                                            _incomingMeasureCounter++;
                                            MessageRecievedText = GeneralMessageCollection.GeneralMessageRecivedTranslation("", true) + MessageRecievedText;
                                            GeneralMessageCollection.LoopCounter++;
                                            _validateFinished = false;
                                        }
                                    }
                                }

                                //if incoming message returns with measure ok or not-> negative logic
                                if (IsMeasureModeIncomingReseted &&
                                    ValidatorIncomingMessage.ErrorMessageBack(ByteMessages.Instance.MeasureModeIncoming[1]) &&
                                    !this._udp.IsEnabled)
                                {
                                    TimeOutValidator(TimeOutValidatorStates.Stop);
                                    _validateFinished = true;
                                    GeneralMessageCollection.LoopCounter = 0;
                                }
                                if (ReportFieldState && !this._udp.IsEnabled)
                                {
                                    _savedMeasureCounter++;

                                    string reportInsertData = IsMeasureModeIncomingReseted ? XmlFilter.Instance.GetResponseData(
                                        ConverterRepository.ConvertDecimalStringToHexString(ByteMessages.Instance.MeasureModeIncoming[1].ToString())) : "";

                                    ReportDataCollector.AddToVertical(reportInsertData);

                                    if (ReportFieldState && _validateFinished)
                                    {
                                        ReportDataCollector.AddToVerticalAtIndex(0, SchauerNumber.ToString());
                                        ReportDataCollector.AddVerticalToHorizontal();
                                        ReportDataCollector.CleanerVertical();
                                        PopUpQuestionbox();
                                    }
                                }
                            }
                            else
                            {
                                TimeOutValidator(TimeOutValidatorStates.Stop);
                                _validateFinished = true;
                                GeneralMessageCollection.LoopCounter = 0;
                                MessageRecievedText = GeneralMessageCollection.GeneralMessageRecived("Validate Error -> Wrong EoF") + MessageRecievedText;
                            }
                        }
                        else
                        {
                            MessageRecievedText = "Info: " + DateTime.Now.ToString("HH:mm:ss").ToString() + " -> " +
                                                  XmlFilter.Instance.GetResponseTranslate
                                                      (ByteMessages.Instance.MeasureModeIncoming[0].ToString(),
                                                      ByteMessages.Instance.MeasureModeIncoming[1].ToString(),
                                                      ByteMessages.Instance.MeasureModeIncoming[2].ToString())
                                                  + "\n" + MessageRecievedText + "\n";
                        }
                        WasItDisconnect();
                        ByteMessageBuilderRepository.ClearArray(ByteMessages.Instance.MeasureModeIncoming);
                    }
                    else
                    {
                        countBytes++;
                    }

                    if (_validateFinished)
                    {
                        _incomingMeasureCounter = 1;
                        _validateFinished       = false;
                        IsRunningNow            = GeneralMessageCollection.IsRunningStateChecker(false);
                    }
                    if (this._udp.IsFinished)
                    {
                        this._udp.Reset();
                    }
                }
                catch (Exception ex)
                {
                    //throw;
                    MessageBox.Show(GeneralMessageCollection.LogIntoFile(ex));
                }
            }
        }