예제 #1
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn		        AtOrPastCity
         *	\brief			This method determins if a truck is currently at or past a destination city
         *	\param[in]      FC_LocalContract inContract, FC_TripTicket inTicket
         *	\param[out]	    none
         *	\return		    bool
         * ---------------------------------------------------------------------------------------------------- */
        public bool AtOrPastCity(FC_LocalContract inContract, FC_TripTicket inTicket)
        {
            int OrginId = LoadCSV.ToCityID(inContract.Origin);
            int DestId  = LoadCSV.ToCityID(inContract.Destination);

            int current = LoadCSV.ToCityID(inTicket.CurrentLocation);

            if (OrginId > DestId)
            {
                //going west

                if (current <= DestId)
                {
                    return(true);
                }
            }
            else
            {
                if (current >= DestId)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        // GetTravelData METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			List<RouteData> GetTravelData(int OriginID, int DestinationID, bool FLTorLTL)
         *	\brief		This method will determine the info for a trip the between to cities.
         *	\details	A list of RouteData structs, each struct will hold all timing and KM data.
         *	            The timing for each element will keep track of the pick up time at the origin city, the drop off time at the destination, and the LTL time at intermediate cities.
         *	\param[in]	int OriginID, int DestinationID, bool FLTorLTL  The origin and destination cities, and if the trip is Flt or Ltl.
         *	\param[out]	null
         *	\exception	null
         *	\see		Struct: RouteData
         *	\return		List<RouteData> A list of the RouteData structs. The list all together will hold all the data for a trip.
         *
         * ---------------------------------------------------------------------------------------------------- */
        public List <FC_RouteSeg> GetTravelData(string Origin, string Destination, int inFTL, int InTicketID) //one is ltl
        {
            int OriginID      = LoadCSV.ToCityID(Origin);
            int DestinationID = LoadCSV.ToCityID(Destination);

            bool FTL = true;

            if (inFTL == 1)
            {
                FTL = false;
            }

            try
            {
                //figure out if we need to travel east or west
                CityNode           current = nodes.Find(x => x.CityID == OriginID);
                CityNode           nextCity;
                List <FC_RouteSeg> returnList = new List <FC_RouteSeg>();

                if (OriginID >= 0 && OriginID < Number_of_Cities && DestinationID >= 0 && DestinationID < Number_of_Cities && OriginID != DestinationID)
                {
                    do
                    {
                        FC_RouteSeg tripDataPassBack = new FC_RouteSeg(InTicketID, 0, 0, 0, 0, 0, 0, 0);

                        if (OriginID > DestinationID)
                        {
                            //going west
                            nextCity                    = current.West;
                            tripDataPassBack.KM         = current.WestKM;
                            tripDataPassBack.DrivenTime = current.WestHour;
                        }
                        else
                        {
                            //going east
                            nextCity                    = current.East;
                            tripDataPassBack.KM         = current.EastKM;
                            tripDataPassBack.DrivenTime = current.EastHour;
                        }

                        tripDataPassBack.CityA = current.CityID;
                        tripDataPassBack.CityB = nextCity.CityID;

                        if (current.CityID == OriginID)
                        {
                            tripDataPassBack.PickUpTime += 2;
                        }

                        if (nextCity.CityID == DestinationID)
                        {
                            tripDataPassBack.DropOffTime += 2;
                        }

                        if (!FTL && (nextCity.CityID != DestinationID))
                        {
                            tripDataPassBack.LtlTime += 2;
                        }


                        returnList.Add(tripDataPassBack);

                        current = nextCity;
                    } while (nextCity.CityID != DestinationID);

                    TMSLogger.LogIt(" | " + "MappingClass.cs" + " | " + "MappingClass" + " | " + "GetTravelData" + " | " + "Confirmation" + " | " + "Route List calculated" + " | ");

                    return(returnList);
                }
            }
            catch (Exception e)
            {
                TMSLogger.LogIt(" | " + "MappingClass.cs" + " | " + "MappingClass" + " | " + "GetTravelData" + " | " + e.GetType().ToString() + " | " + e.Message + " | ");
            }

            return(null);
        }