Esempio n. 1
0
 public void Touch(Node node, int rssi)
 {
     if(node.LatestValues == default(LatestValues))
         throw new ArgumentException("node should be loaded with its latestValues for Touch to work");
     node.LastSeen = _timeProvider.UtcNow;
     node.LatestValues.Rssi = rssi;
     node.LatestValues.MaxUpTime = Math.Max(
         node.LatestValues.MaxUpTime,
         (float) (_timeProvider.UtcNow - node.LatestValues.StartupTime).TotalDays);
 }
        public Node Execute(long signature, byte rfId)
        {
            var allIds = _listRfIdsQuery.Execute ();
            if (rfId <=0 || allIds.Contains (rfId))
                rfId = _rfIdGenerationStrategy.FindRfAddress (allIds);
            var node = new Node
            {
                Signature = signature,
                RfAddress = rfId,
                Configuration = new NodeConfiguration
                {
                    Name = "Newly created",
                },
                LatestValues = new LatestValues
                {
                    StartupTime = _timeProvider.UtcNow,
                    MaxUpTime = 0,
                }
            };
            _ctx.Nodes.Add(node);

            return node;
        }