Ejemplo n.º 1
0
        private IEnumerable <CellularTowerEvent> DetectEvent(string vehicleId, string linkId, long currentTick)
        {
            VehicleEvent vEvent = vehicleEvents[vehicleId];

            //if the linkId is null, it means the vehicle event is pre-defined (non-vehicular event)
            if (string.IsNullOrEmpty(linkId))
            {
                linkId = vEvent.CurLinkId;
            }
            else
            {
                vEvent.PreLinkId = vEvent.CurLinkId;
                vEvent.CurLinkId = linkId;
            }

            //find out the active event on this vehicle
            foreach (Event evt in vEvent.GetActiveEvent(currentTick))
            {
                //check if the event is happenning
                if (evt != null)
                {
                    ///current time.
                    Location  curLocation = null;
                    CellTower curCell     = null;
                    Location  preLocation = null;
                    CellTower preCell     = null;
                    curLocation = cellularNetwork.FindLocationByLinkId(vEvent.CurLinkId);
                    curCell     = cellularNetwork.FindCellTowerByLinkId(vEvent.CurLinkId);

                    preLocation = cellularNetwork.FindLocationByLinkId(vEvent.PreLinkId);
                    preCell     = cellularNetwork.FindCellTowerByLinkId(vEvent.PreLinkId);

                    switch (evt.EventType)
                    {
                    case EventType.OnCall:
                        //for any oncall events, just return the location
                        if (curCell != null && preCell != null && !curCell.Equals(preCell))
                        {
                            yield return(new CellularTowerEvent(vehicleId, curLocation.LocationId, curCell.CellTowerId, preLocation?.LocationId, preCell?.CellTowerId, evt, currentTick));
                        }
                        break;

                    case EventType.PowerOn:
                        if (curLocation != null && curCell != null &&
                            preLocation != null && preCell != null &&
                            !curCell.Equals(preCell))
                        {
                            //for now just use vechileId to represnet IMSI
                            yield return(new CellularTowerEvent(vehicleId, curLocation.LocationId, curCell.CellTowerId, preLocation.LocationId, preCell.CellTowerId, evt, currentTick));
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            yield return(null);
        }
Ejemplo n.º 2
0
        private CellularTowerEvent DetectEvent(string vehicleId, string linkId, long currentTick)
        {
            VehicleEvent vEvent = vehicleEvents[vehicleId];

            //find out the active event on this vehicle
            Event evt = vEvent.GetActiveEvent(currentTick);

            //check if the event is happenning
            if (evt != null)
            {
                ///current time.
                Location  curlocation = null;
                CellTower curCell     = null;
                switch (evt.EventType)
                {
                case EventType.PowerOn:     //this is a LU event
                    curlocation = cellularNetwork.FindLocationByLinkId(linkId);
                    curCell     = cellularNetwork.FindCellTowerByLinkId(linkId);
                    if (curlocation != null && curCell != null)
                    {
                        //for now just use vechileId to represnet IMSI
                        return(new CellularTowerEvent(vehicleId, curlocation.LocationId, curCell.CellTowerId, evt, currentTick));
                    }
                    break;

                case EventType.OnCall:     //this is a hand-off event
                    curlocation = cellularNetwork.FindLocationByLinkId(linkId);
                    curCell     = cellularNetwork.FindCellTowerByLinkId(linkId);
                    if (curlocation != null && curCell != null)
                    {
                        //for now just use vechileId to represnet IMSI
                        return(new CellularTowerEvent(vehicleId, curlocation.LocationId, curCell.CellTowerId, evt, currentTick));
                    }
                    break;

                default:
                    break;
                }
            }
            return(null);
        }