/// <summary>
        /// GEt Vehicles List
        /// </summary>
        public void GetVehicles()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            VehicleParameters vehicleParameters = new VehicleParameters
            {
                WithPagination = true,
                Page           = 1,
                PerPage        = 10
            };

            // Run the query
            string            errorString = "";
            VehiclesPaginated vehicles    = route4Me.GetVehicles(vehicleParameters, out errorString);

            Console.WriteLine("");

            if (vehicles != null)
            {
                Console.WriteLine("GetVehicles executed successfully, {0} vehicles returned", vehicles.Total);
                Console.WriteLine("");

                foreach (VehicleV4Response vehicle in vehicles.Data)
                {
                    Console.WriteLine("Vehicle ID: {0}", vehicle.VehicleId);
                }

                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("GetVehicles error: {0}", errorString);
            }
        }
        public async Task <IActionResult> UpdateVehicleParametersAsync(VehicleParameters vehicleParameters)
        {
            try
            {
                //判断传过来的数据是否存在
                if (await dbContext.vehicleParametersRepository.IsExistAsync(vehicleParameters.VPId))
                {
                    //找到这条数据
                    VehicleParameters vehicle = await dbContext.vehicleParametersRepository.GetFirstInfo(vehicleParameters.VPId);

                    //修改数据
                    dbContext.vehicleParametersRepository.UpdateInfo(vehicle);
                    if (await dbContext.vehicleParametersRepository.SaveAsync())
                    {
                        return(Ok(1));
                    }
                }
                _logger.LogInformation($"{DateTime.Now.ToString("yyyyMMddHHmmssfff")}修改一条车辆参数信息");
                //如果不存在返回错误信息
                return(NotFound());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #3
0
    public void Update(float dt, VehicleParameters parameters)
    {
        float acceleration = parameters.MaxAcceleration * (1.0f - Mathf.Clamp01(Mathf.Abs(LocalVelocity.y) / parameters.MaxSpeed));

        if (Input.Forward > 0)
        {
            LocalVelocity += Vector3.forward * acceleration * dt;
        }

        if (Input.Back > 0)
        {
            LocalVelocity -= Vector3.forward * acceleration * dt;
        }

        if (Input.Turn != 0.0f)
        {
            float turnForwardFactor = Mathf.Clamp((LocalVelocity.z) / parameters.MaxTurnForwardVel, -1.0f, 1.0f);

            Rotation = Rotation * Quaternion.Euler(0.0f, parameters.TurnSpeed * Input.Turn * dt * turnForwardFactor, 0.0f);
        }

        LocalVelocity -= new Vector3(LocalVelocity.x * parameters.Drag.x,
            LocalVelocity.y * parameters.Drag.y,
            LocalVelocity.z * parameters.Drag.z);

        Position += Rotation * LocalVelocity * dt;
    }
Exemple #4
0
        public async Task <IActionResult> GetVehicles([FromQuery] VehicleParameters vehicleParameters)
        {
            var vehicles = await _unitOfWork.Vehicles.GetAllVehiclesWithInfoAsync(vehicleParameters);

            var result = vehicles.Select(_mapper.Map <Vehicle, VehicleResource>);

            var metaData = new
            {
                vehicles.TotalCount,
                vehicles.PageSize,
                vehicles.CurrentPage,
                vehicles.TotalPage,
                vehicles.HasNext,
                vehicles.HasPrevious
            };
            var serializerSettings = new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            Response.Headers.Add("X-Pagination",
                                 JsonConvert.SerializeObject(metaData, Formatting.None, serializerSettings));

            return(Ok(result));
        }
Exemple #5
0
        public Vehicle(VehicleSpecific vehicleSpecific, int tileX, int tileY, bool hasEmergencyLights, int debugNum)
        {
            vehicleState         = VehicleState.Chilling;
            this.vehicleSpecific = vehicleSpecific;

            vehicleParameters          = new VehicleParameters(hasEmergencyLights, this);
            actionList                 = new List <VAction>();
            location                   = new Location(tileX, tileY, vehicleParameters, vehicleSpecific.sprite);
            selectedMovingLine         = new SelectedMovingLine(location);
            vehicleParameters.debugNum = debugNum;
        }
        public void GetLatestVehicleLocationsTest()
        {
            var route4Me = new Route4MeManagerV5(c_ApiKey);

            var vehicleParams = new VehicleParameters()
            {
                VehicleIDs = lsVehicles.Select(x => x.VehicleId).ToArray()
            };

            var result = route4Me.GetVehicleLocations(vehicleParams, out ResultResponse resultResponse);

            Assert.NotNull(result);
            Assert.IsType <VehicleLocationResponse>(result);
        }
        public void GetVehiclesPaginatedListTest()
        {
            var route4Me = new Route4MeManagerV5(c_ApiKey);

            var vehParams = new VehicleParameters()
            {
                Page    = 1,
                PerPage = 10
            };

            var result = route4Me.GetPaginatedVehiclesList(vehParams, out ResultResponse resultResponse);

            Assert.NotNull(result);
            Assert.IsType <Vehicle[]>(result);
        }
Exemple #8
0
        /// <summary>
        /// Assign a vehicle to a route.
        /// </summary>
        public void AssignVehicleToRoute()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            #region Get Random Vehicle

            var vehicleParameters = new VehicleParameters
            {
                WithPagination = true,
                Page           = 1,
                PerPage        = 10
            };

            // Run the query
            var vehicles = route4Me.GetVehicles(
                vehicleParameters,
                out string errorString
                );

            int randomNumber = (new Random()).Next(0, vehicles.PerPage - 1);
            var vehicleId    = vehicles.Data[randomNumber].VehicleId;

            #endregion

            RunOptimizationSingleDriverRoute10Stops();
            OptimizationsToRemove = new List <string>()
            {
                SD10Stops_optimization_problem_id
            };

            string routeId = SD10Stops_route_id;

            var routeParameters = new RouteParametersQuery()
            {
                RouteId    = routeId,
                Parameters = new RouteParameters()
                {
                    VehicleId = vehicleId
                }
            };

            var route = route4Me.UpdateRoute(routeParameters, out errorString);

            PrintExampleRouteResult(route, errorString);

            RemoveTestOptimizations();
        }
Exemple #9
0
        /// <summary>
        /// GEt Vehicles List
        /// </summary>
        public void GetVehicles()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            var vehicleParameters = new VehicleParameters
            {
                WithPagination = true,
                Page           = 1,
                PerPage        = 10
            };

            // Run the query
            VehiclesPaginated vehicles = route4Me.GetVehicles(vehicleParameters, out string errorString);

            PrintTestVehciles(vehicles, errorString);
        }
        public void GetVehicleByLicensePlateTest()
        {
            var route4Me = new Route4MeManagerV5(c_ApiKey);

            var vehParams = new VehicleParameters()
            {
                VehicleLicensePlate = lsVehicles[0].VehicleLicensePlate
            };

            var result = route4Me.GetVehicleByLicensePlate(vehParams, out ResultResponse resultResponse);

            Assert.NotNull(result);
            Assert.IsType <VehicleResponse>(result);
            Assert.Equal(lsVehicles[0].VehicleLicensePlate, (result?.Data?.Vehicle?.VehicleLicensePlate ?? null));
            //Assert.IsType<Vehicle>(result);
            //Assert.Equal(lsVehicles[0].VehicleLicensePlate, result.VehicleLicensePlate);
        }
 public async Task <IActionResult> InsertVehicleParametersAsync(VehicleParameters vehicleParameters)
 {
     try
     {
         //自动计算当前里程和剩余里程,在前台计算,直接赋值,不可编辑
         dbContext.vehicleParametersRepository.CreateInfo(vehicleParameters);
         if (await dbContext.vehicleParametersRepository.SaveAsync())
         {
             return(Ok(1));
         }
         _logger.LogInformation($"{DateTime.Now.ToString("yyyyMMddHHmmssfff")}添加车辆参数信息");
         return(Ok("添加失败"));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        /// <summary>
        /// The example refers to the process of getting a vehicle using the vehicleID path parameter.
        /// </summary>
        public void GetVehicle()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            CreateTestVehcile();

            var vehicleParams = new VehicleParameters()
            {
                VehicleId = vehiclesToRemove[vehiclesToRemove.Count - 1]
            };

            // Run the query
            var vehicle = route4Me.GetVehicle(vehicleParams, out string errorString);

            PrintTestVehciles(vehicle, errorString);

            RemoveTestVehicles();
        }
        public async Task <IActionResult> GetFirstVehicleParameterAsync(int vehicleparameterId)
        {
            try
            {
                //判断传过来的值是否存在
                if (await dbContext.vehicleParametersRepository.IsExistAsync(vehicleparameterId))
                {
                    //找到这条数据
                    VehicleParameters vehicleParameters = await dbContext.vehicleParametersRepository.GetFirstInfo(vehicleparameterId);

                    _logger.LogInformation($"{DateTime.Now.ToString("yyyyMMddHHmmssfff")}显示一条车辆参数信息");
                    return(Ok(vehicleParameters));
                }
                //如果不存在返回错误信息
                return(NotFound());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 public override void DrawLighting(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters)
 {
     if (vehicleParameters.lightEmergencyOn)
     {
         if (vehicleParameters.isRedLightEmergency[timingIndex])
         {
             Vector2 worldPosition = CalcWorldPosition(redLightLocalRotation, redLightSpriteRotation + location.direction, redLightLocalDistance, location.position);
             redLight.DrawLighting(spriteBatch, worldPosition, location.direction + redLightLocalRotation);
         }
         if (vehicleParameters.isBlueLightEmergency[timingIndex])
         {
             Vector2 worldPosition = CalcWorldPosition(blueLightLocalRotation, blueLightSpriteRotation + location.direction, blueLightLocalDistance, location.position);
             blueLight.DrawLighting(spriteBatch, worldPosition, location.direction + blueLightLocalRotation);
         }
     }
 }
Exemple #15
0
 public virtual void DrawVisibleBlock(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters)
 {
 }
 public override void DrawGameViewAttachment(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters, float transparency)
 {
     if (vehicleParameters.lightEmergencyOn)
     {
         if (vehicleParameters.isRedLightEmergency[timingIndex])
         {
             Vector2 worldPosition = CalcWorldPosition(redLightLocalRotation, redLightSpriteRotation + location.direction, redLightLocalDistance, location.position);
             redLight.DrawGameViewLightBulb(spriteBatch, worldPosition, location.direction, transparency);
         }
         if (vehicleParameters.isBlueLightEmergency[timingIndex])
         {
             Vector2 worldPosition = CalcWorldPosition(blueLightLocalRotation, blueLightSpriteRotation + location.direction, blueLightLocalDistance, location.position);
             blueLight.DrawGameViewLightBulb(spriteBatch, worldPosition, location.direction, transparency);
         }
     }
 }
 public WaypointControl(Location location, VehicleParameters vehicleParameters)
 {
     this.location          = location;
     this.vehicleParameters = vehicleParameters;
 }
Exemple #18
0
 public virtual void DrawLighting(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters)
 {
 }
Exemple #19
0
        public override void DrawLighting(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters)
        {
            if (vehicleParameters.lightBrakingOn)
            {
                Vector2 worldPosition = CalcWorldPosition(oneLocalRotation, lightsSpriteRotation + location.direction, localDistance, location.position);
                lights.DrawLighting(spriteBatch, worldPosition, location.direction);

                worldPosition = CalcWorldPosition(twoLocalRotation, lightsSpriteRotation + location.direction, localDistance, location.position);
                lights.DrawLighting(spriteBatch, worldPosition, location.direction);
            }
        }
Exemple #20
0
        public override void DrawGameViewAttachment(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters, float transparency)
        {
            if (vehicleParameters.lightBrakingOn)
            {
                Vector2 worldPosition = CalcWorldPosition(oneLocalRotation, lightsSpriteRotation + location.direction, localDistance, location.position);
                lights.DrawGameViewLightBulb(spriteBatch, worldPosition, location.direction, transparency);

                worldPosition = CalcWorldPosition(twoLocalRotation, lightsSpriteRotation + location.direction, localDistance, location.position);
                lights.DrawGameViewLightBulb(spriteBatch, worldPosition, location.direction, transparency);
            }
        }
Exemple #21
0
        public override void DrawAttachment(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters)
        {
            //This is the lightbulb
            if (vehicleParameters.lightGeneralOn)
            {
                Vector2 worldPosition = CalcWorldPosition(oneLocalRotation, lightsSpriteRotation + location.direction, localDistance, location.position);
                lights.DrawLightBulb(spriteBatch, worldPosition, location.direction);

                worldPosition = CalcWorldPosition(twoLocalRotation, lightsSpriteRotation + location.direction, localDistance, location.position);
                lights.DrawLightBulb(spriteBatch, worldPosition, location.direction);
            }
        }
Exemple #22
0
 public override void DrawLighting(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters)
 {
     if (vehicleParameters.indicatorDirection == Direction.LEFT && vehicleParameters.isIndicatorFlash)
     {
         Vector2 worldPosition = CalcWorldPosition(leftLightLocalRotation, LeftLightSpriteRotation + location.direction, LeftLightLocalDistance, location.position);
         leftLight.DrawLighting(spriteBatch, worldPosition, location.direction);
     }
     else if (vehicleParameters.indicatorDirection == Direction.RIGHT && vehicleParameters.isIndicatorFlash)
     {
         Vector2 worldPosition = CalcWorldPosition(RightLightLocalRotation, RightLightSpriteRotation + location.direction, RightLightLocalDistance, location.position);
         rightLight.DrawLighting(spriteBatch, worldPosition, location.direction);
     }
 }
Exemple #23
0
 public virtual void DrawShadows(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters)
 {
 }
Exemple #24
0
 public virtual void DrawGameViewAttachment(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters, float transparency)
 {
 }
Exemple #25
0
 public virtual void DrawAttachment(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters)
 {
 }
Exemple #26
0
 public override void DrawGameViewAttachment(SpriteBatch spriteBatch, Location location, VehicleParameters vehicleParameters, float transparency)
 {
     //This is the lightbulb
     if (vehicleParameters.indicatorDirection == Direction.LEFT && vehicleParameters.isIndicatorFlash)
     {
         Vector2 worldPosition = CalcWorldPosition(leftLightLocalRotation, LeftLightSpriteRotation + location.direction, LeftLightLocalDistance, location.position);
         leftLight.DrawGameViewLightBulb(spriteBatch, worldPosition, location.direction, transparency);
     }
     else if (vehicleParameters.indicatorDirection == Direction.RIGHT && vehicleParameters.isIndicatorFlash)
     {
         Vector2 worldPosition = CalcWorldPosition(RightLightLocalRotation, RightLightSpriteRotation + location.direction, RightLightLocalDistance, location.position);
         rightLight.DrawGameViewLightBulb(spriteBatch, worldPosition, location.direction, transparency);
     }
 }
Exemple #27
0
 public virtual void Update(Vector2 location, float rotation, VehicleParameters vehicleParameters)
 {
 }