Ejemplo n.º 1
0
        private void ProcessMessages(object obj)
        {
            while (!Token.IsCancellationRequested)
            {
                var nextmsg = _inputCache.Pop();

                if (nextmsg.Length == 0)
                {
                    if (_inputCache.Count == 0)
                    {
                        Thread.Sleep(ProcessMessagesSleepTimeout);
                    }

                    continue;
                }

                if (UdfTagMsg.TryParse(nextmsg, out var tagResult))
                {
                    _dbCache.Save(tagResult);
                }
                else if (UdfPosMsg.TryParse(nextmsg, out var posResult))
                {
                    _dbCache.Save(posResult);
                }
                else if (UdfSecMsg.TryParse(nextmsg, out var secResult))
                {
                    _dbCache.Save(secResult);
                }
            }
        }
Ejemplo n.º 2
0
        public void TryParseUdfPosMsgModel()
        {
            var model = new UdfPosMsg()
            {
                TagId    = 21,
                SectorId = 45
            };

            var parsed = UdfPosMsg.TryParse(model.ToBytes(), out var result);

            Assert.IsTrue(parsed, "UdfPosMsg was not parsed");
            Assert.IsNotNull(result, "result is null");
            Assert.AreEqual(model.TagId, result.TagId, "TagId is not equal");
            Assert.AreEqual(model.SectorId, result.SectorId, "SectorId is not equal");
        }