Ejemplo n.º 1
0
 internal override void publishPosition(Device d, PositionTools.Position p, EventType e)
 {
     if (linkedwindow != null && !killed)
     {
         if (p.room == linkedroom || e == EventType.Disappear || e == EventType.MoveOut)
         {
             Application.Current.Dispatcher.BeginInvoke((Action)(() => { if (!killed)
                                                                         {
                                                                             linkedwindow.updateDevicePosition(d, p, e);
                                                                         }
                                                                 }));
         }
     }
 }
 internal override void publishPosition(Device d, PositionTools.Position p, EventType e)
 {
     Interlocked.Increment(ref ongoingqueryes);
     if (!killed)
     {
         Task.Factory.StartNew(() =>
         {
             DBInt.addDevicePosition(d.identifier, d.MAC, p.room.roomName, p.X, p.Y, p.uncertainity, p.positionDate, e);
             Interlocked.Decrement(ref ongoingqueryes);
         });
     }
     else
     {
         Interlocked.Decrement(ref ongoingqueryes);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Add the device to its room and propagate the new position to the publishers
 /// </summary>
 private void placeInRoomAndPublish(Room room, Device d, PositionTools.Position p, Publisher.EventType action)
 {
     if (action == Publisher.EventType.Appear || action == Publisher.EventType.MoveIn)
     {
         room.addDevice(d);
     }
     else if (action != Publisher.EventType.Update)
     {
         room.removeDevice(d);
     }
     foreach (Publisher pb in publishers)
     {
         if (pb.supportsOperation(Publisher.DisplayableType.DeviceDevicePosition))
         {
             pb.publishPosition(d, p, action);
         }
         if (pb.supportsOperation(Publisher.DisplayableType.SimpleStat))
         {
             pb.publishStat(room.devicecount, room, p.positionDate, Publisher.StatType.InstantaneousDeviceCount);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Compute the device positions given the receivings of a packet
        /// </summary>
        private void locateAndPublish(Device d, Packet p)
        {
            Room oldRoom = (d.lastPosition != null)?d.lastPosition.room:null;

            PositionTools.Position newposition = PositionTools.triangulate(p.Receivings, p.Timestamp);
            Publisher.EventType    e           = Publisher.EventType.Update;
            newposition.positionDate = p.Timestamp;
            if (oldRoom == null)
            {
                d.firstPosition = newposition;
                e = Publisher.EventType.Appear;
            }
            else if (oldRoom != newposition.room)
            {
                PositionTools.Position oldpos = new PositionTools.Position(d.lastPosition);
                oldpos.positionDate = newposition.positionDate;
                placeInRoomAndPublish(oldRoom, d, oldpos, Publisher.EventType.MoveOut);
                e = Publisher.EventType.MoveIn;
            }
            d.lastPosition = newposition;
            placeInRoomAndPublish(d.lastPosition.room, d, newposition, e);
        }
Ejemplo n.º 5
0
 internal virtual void publishPosition(Device d, PositionTools.Position p, EventType e)
 {
     throw new NotSupportedException();
 }