/// <summary> /// Factory Method for Events /// </summary> /// <param name="eventId"></param> /// <returns></returns> public GTSBizObjects.Events.TrackerEvents.TrackerEvent GetEvent(int eventId) { GPSTrackerEntities1 dbContext = new GPSTrackerEntities1(); GTSDataStorage.Event theEvent = dbContext.Events.Where(t => t.Id == eventId).FirstOrDefault(); Events.TrackerEvents.TrackerEvent retEvent; switch (theEvent.Type) { // Should find a better, more configurable way to get names for Inputs - TODO // Configurable by client and probably type, including tempat for description // TODO - Exception Handling case 1: retEvent = new TrackerEvents.Speeding(theEvent); break; case 2: retEvent = new TrackerEvents.ExcessiveIdling(theEvent); break; //case 3: retEvent = new TrackerEvents.EngineCutOn(theEvent); break; //case 4: retEvent = new TrackerEvents.EngineCutOff(theEvent); break; //case 5: retEvent = new TrackerEvents.EnterLocation(theEvent); break; //case 6: retEvent = new TrackerEvents.ExitLocation(theEvent); break; case 7: retEvent = new TrackerEvents.ExternalPowerCut(theEvent); break; case 8: retEvent = new TrackerEvents.GPSBlindAreaEntered(theEvent); break; case 9: retEvent = new TrackerEvents.GPSBlindAreaExited(theEvent); break; case 10: retEvent = new TrackerEvents.LowBattery(theEvent); break; case 11: retEvent = new TrackerEvents.TrackerTurnedOn(theEvent); break; case 12: retEvent = new TrackerEvents.GPSAntennaCut(theEvent); break; case 13: retEvent = new TrackerEvents.InputActive(theEvent); break; case 14: retEvent = new TrackerEvents.InputInactive(theEvent); break; case 15: retEvent = new TrackerEvents.InputActive(theEvent); break; case 16: retEvent = new TrackerEvents.InputInactive(theEvent); break; default: retEvent = new TrackerEvents.TrackerAlarm(theEvent); break; } return(retEvent); }
/// <summary> /// Gets the list of events from a location Message analysis for the vt310e /// </summary> /// <returns></returns> public List <Event> GetVT310eEvents(GTSLocationMessage locationMessage, GTSLocationMessage prevMessage) { List <Event> events = new List <Event>(); // should link geofence checking in here // Need to check all known events // Currently we have no case where an event can point to more than one event at a time - this may change when geo fencing is put in!!!! TODO // Wondering If there should be a separation of events by a level of priority for reporting here or in the DB? In the DB if (prevMessage != null && locationMessage.Id == 0) { locationMessage.Id = prevMessage.Id; } Event theEvent; if (locationMessage.Speed > 0) { theEvent = createSpeedingEvent(locationMessage, prevMessage); if (theEvent != null) { events.Add(theEvent); } } else { theEvent = createIdleEvent(locationMessage, prevMessage); if (theEvent != null) { events.Add(theEvent); } } // Get Alarms if (locationMessage.GetType() == (typeof(VT310eAlarmLocationMessage))) { VT310eAlarmLocationMessage msg = (VT310eAlarmLocationMessage)locationMessage; // tests for different alarm types switch (msg.AlarmID) { // Should find a better, more configurable way to get names for Inputs - TODO // Configurable by client and probably type, including tempat for description case "01": theEvent = new TrackerEvents.InputActive(msg, 1, "SOS Button"); break; case "02": theEvent = new TrackerEvents.InputActive(msg, 2); break; case "03": theEvent = new TrackerEvents.InputActive(msg, 3); break; case "04": theEvent = new TrackerEvents.InputActive(msg, 4); break; case "05": theEvent = new TrackerEvents.InputActive(msg, 5, "Engine"); break; case "10": theEvent = new TrackerEvents.LowBattery(msg); break; case "14": theEvent = new TrackerEvents.TrackerTurnedOn(msg); break; case "15": theEvent = new TrackerEvents.GPSBlindAreaEntered(msg); break; case "16": theEvent = new TrackerEvents.GPSBlindAreaExited(msg); break; case "31": theEvent = new TrackerEvents.InputInactive(msg, 1, "SOS Button"); break; case "32": theEvent = new TrackerEvents.InputInactive(msg, 2); break; case "33": theEvent = new TrackerEvents.InputInactive(msg, 3); break; case "34": theEvent = new TrackerEvents.InputInactive(msg, 4); break; case "35": theEvent = new TrackerEvents.InputInactive(msg, 5, "Engine"); break; case "50": theEvent = new TrackerEvents.ExternalPowerCut(msg); break; case "53": theEvent = new TrackerEvents.GPSAntennaCut(msg); break; default: theEvent = new TrackerEvents.TrackerAlarm(msg); break; } if (theEvent != null) { events.Add(theEvent); } } List <Event> entryExitEvents = new List <Event>(); try { entryExitEvents = retrieveGeoFenceEventList(locationMessage, prevMessage); } catch (System.Exception ex) { } foreach (Event item in entryExitEvents) { events.Add(item); } return(events); }