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); } } }
public void TryParseUdfSecMsgModel() { var model = new UdfSecMsg() { SectorId = 45, SectorStatus = SectorStatus.Ok }; var parsed = UdfSecMsg.TryParse(model.ToBytes(), out var result); Assert.IsTrue(parsed, "UdfSecMsg was not parsed"); Assert.IsNotNull(result, "result is null"); Assert.AreEqual(model.SectorId, result.SectorId, "SectorId is not equal"); Assert.AreEqual(model.SectorStatus, result.SectorStatus, "SectorStatus is not equal"); }