Esempio n. 1
0
        private bool GetPriority(Entity entity, Tick current, out float priority)
        {
            var lastSent = LastSent.GetLatest(entity.Id);

            return(lastSent.Tick.IsValid
                ? Evaluator.Evaluate(entity, current - lastSent.Tick, out priority)
                : Evaluator.Evaluate(entity, int.MaxValue, out priority));
        }
Esempio n. 2
0
        private void CheckLastSentAndDequeueIt(BaseDeviceCommand dc)
        {
            string LastCmd = LastSent.GetText(String.Empty);

            if (LastSent != null)
            {
                if (LastSent.IsExpired())
                {
                    LastSent = null;
                }
                else
                {
                    var lastDC = BaseDeviceCommand.createFrom(LastCmd, this, null);
                    var result = lastDC.isExpectedResponse(dc);
                    if (result == DeviceCommandResponseStatus.Valid)
                    {
                        Fota.Dequeue(this, lastDC.MessageId);
                    }
                }
            }
        }
Esempio n. 3
0
        // TODO: unificar GTEDeviceCommand e INodeMessage si se puede
        private void SendPendingFota(ref IMessage msg)
        {
            string pending = Fota.Peek(this);

            if (String.IsNullOrEmpty(pending))
            {
                return;
            }

            #region SendPending

            var gteDC = BaseDeviceCommand.createFrom(pending, this, null);
            pending = gteDC.ToString(true);

            msg = (msg ?? new UserMessage(Id, 0));
            msg.AddStringToPostSend(pending);

            if (LastSent == null || LastSent.GetText(null) != pending)
            {
                LastSent = new INodeMessage((ulong)Id, pending, DateTime.UtcNow);
            }

            #endregion SendPending
        }