Exemplo n.º 1
0
        public Proxy()
        {
            _cts   = new CancellationTokenSource();
            _token = _cts.Token;

            var settings    = new Settings();
            var dbCache     = new DbCache();
            var inputCache  = new MessageCache();
            var outputCache = new MessageCache();

            var settingsInitTask = settings.InitAsync();
            var dbCacheInitTask  = dbCache.InitAsync();

            Task.WaitAll(new[] { settingsInitTask, dbCacheInitTask }, _token);

            _dbReceiver          = new DbReceiver(settings, dbCache);
            _sisposReceiver      = new SISPOSReceiver(settings, inputCache);
            _sisposDataProcessor = new SISPOSDataProcessor(settings, dbCache, inputCache, outputCache);
            _sisposTransmitter   = new SISPOSTransmitter(settings, outputCache);
        }
Exemplo n.º 2
0
        public void TagsCountFix()
        {
            var dbCache     = new DbCache();
            var inputCache  = new MessageCache();
            var outputCache = new MessageCache();

            dbCache.Save(new UdfPosMsg()
            {
                SectorId = 33,
                TagId    = 20
            });
            dbCache.Save(new UdfPosMsg()
            {
                SectorId = 33,
                TagId    = 21
            });

            var payloadWrong = Encoding.ASCII.GetBytes("$PANSPT,33,1,1*24\r\n$PANSPT,34,0,1*22\r\n$PANSPT,35,0,1*23\r\n");
            var payloadOk    = Encoding.ASCII.GetBytes("$PANSPT,33,2,1*27\r\n$PANSPT,34,0,1*22\r\n$PANSPT,35,0,1*23\r\n");

            using (var service = new SISPOSDataProcessor(_settings, dbCache, inputCache, outputCache))
            {
                service.Start();

                inputCache.Push(payloadWrong);

                Thread.Sleep(100);
            }

            var result    = outputCache.Pop();
            var resultStr = Encoding.ASCII.GetString(result);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Length > 1);
            Assert.IsTrue(result.ContainsSubArray(payloadOk), "Repared payload is not correct");
        }