Ejemplo n.º 1
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.º 2
0
 internal bool addDevicePosition(string identifier, string mac, string roomname, double xpos, double ypos, double uncertainity, DateTime timestamp, Publisher.EventType evty)
 {
     return(performNonQuery("insert into devicespositions(identifier,mac,roomname,tm,xpos,ypos,uncertainty,outmovement,xhour,xday,xmonth,xyear) values(@identifier,@mac,@roomname,@tm,@xpos,@ypos,@uncertainty,@outmovement,@xhour,@xday,@xmonth,@xyear)",
                            "identifier", identifier,
                            "mac", mac,
                            "roomname", roomname,
                            "tm", timestamp,
                            "xpos", xpos,
                            "ypos", ypos,
                            "uncertainty", uncertainity,
                            "outmovement", (evty == Publisher.EventType.Disappear || evty == Publisher.EventType.MoveOut),
                            "xhour", timestamp.Hour,
                            "xday", timestamp.Day,
                            "xmonth", timestamp.Month,
                            "xyear", timestamp.Year));
 }
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);
         }
     }
 }