using System; using System.Collections.Generic; using System.Collections; using System.Drawing; using System.Text; //using XmlLibrary; /*================================================================================================== Revision History: Modification Tracking Author (email) Date Number Description of Changes ------------------------- ------------ ---------- ------------------------------------------- Ilie Luican August 18, 2006 x.x first commented version ilie@airadio.net ------------------------- ------------ ---------- ------------------------------------------- ------------------------- ------------ ---------- ------------------------------------------- ==================================================================================================*/ namespace Safedispatch_4_0 { /// /// This class implements a list of routes associated with a vehicle /// public class RoutesInfo { public ArrayList routes=null; public int nOfRoutes; public int nOfPositions; public double[] corners; public String IMEI=""; private String vehicleName; public Int32 minTime; public Int32 maxTime; static public uint iMaxPos = 0; /// /// The class constructor /// /// the IMEI of the associated vehicle public RoutesInfo(String paramIMEI, String vehNamePass) { routes = new ArrayList(); nOfRoutes = 0; nOfPositions = 0; corners = new double[4]; IMEI = paramIMEI; vehicleName = vehNamePass; } /// /// Adds a route to the routes list /// /// start time /// end time /// vehicle name /// color name /// route name /// minimum speed for select /// select cars with engine on public void AddRoute2(Int32 startTimeParam, Int32 endTimeParam, String vehNameParam, Color colorNameParam, String routeNameParam) { if (nOfRoutes==0) routes.Add(new RouteInfo(startTimeParam, endTimeParam, vehNameParam, colorNameParam, routeNameParam, true)); else routes.Add(new RouteInfo(startTimeParam, endTimeParam, vehNameParam, colorNameParam, routeNameParam, false)); nOfRoutes++; ComputeMinMaxTime(); } /// /// Removes a route from the routes list /// /// route name public void RemoveRoute(String routeNameParam) { foreach (RouteInfo obj in routes) { if (obj.routeName == routeNameParam) { nOfPositions = nOfPositions - obj.nOfPositions; routes.Remove(obj); nOfRoutes--; break; } } ComputeMinMaxTime(); } public void RemoveQuick() { foreach (RouteInfo obj in routes) { if (obj.routeName.Contains("_quick")) { nOfPositions = nOfPositions - obj.nOfPositions; routes.Remove(obj); nOfRoutes--; break; } } ComputeMinMaxTime(); } public void ComputeMinMaxTime() { minTime = Int32.MinValue; maxTime = Int32.MaxValue; foreach (RouteInfo obj in routes) { if (obj.startTime < minTime) minTime = obj.startTime; if (obj.endTime > maxTime) maxTime = obj.endTime; } } /// Determines if an interval is already contained within current intervals in routes /// /// Start time of the interval /// End time of the interval /// Returns true if interval is contained, and false otherwise public Boolean CheckInterval(uint param1, uint param2) { if (nOfRoutes > 0) { foreach (RouteInfo obj in routes) { if (param1 >= obj.startTime) { if (param1 <= obj.endTime) return true; } else { if (param2 >= obj.startTime) return true; } } return false; } else return false; } /// /// Computes the "boundaries" of the entire routes list /// public void ComputeCorners() { corners[0] = corners[2] = 181.00; corners[1] = corners[3] = -181.00; foreach (RouteInfo obj in routes) { if (obj.checkedRoute) { if (corners[0] > obj.corners[0]) corners[0] = obj.corners[0]; if (corners[1] < obj.corners[1]) corners[1] = obj.corners[1]; if (corners[2] > obj.corners[2]) corners[2] = obj.corners[2]; if (corners[3] < obj.corners[3]) corners[3] = obj.corners[3]; } } } /// /// Sets the checked flag to true/false for each route /// from the routes list /// /// public void SetCheckedRoutes(ArrayList paramSelectedRoutes) { bool found; found = false; foreach (RouteInfo obj2 in routes) { foreach (String obj in paramSelectedRoutes) { found = false; if (obj2.routeName == obj) { obj2.checkedRoute = true; found = true; break; } } if (!found) obj2.checkedRoute = false; } } } }