示例#1
0
        public void OBU1_SetVehicleCurrentSpeed(string vehID, [FromBody] string address, [FromBody] double speed)
        {
            if (string.IsNullOrEmpty(address))
            {
                address = "http://127.0.0.1:8080/TRAAS_WS"; //default address
            }
            TraasReference.ServiceImplClient client = new TraasReference.ServiceImplClient();
            client.Endpoint.Address = new EndpointAddress(address);

            try
            {
                if (speed <= 0)
                {
                    throw new FaultException("Hitrost more biti pozitivna!");
                }

                client.Open();
                if (isVehicleActive(address, vehID))
                {
                    client.Vehicle_setMaxSpeed(vehID, speed);
                    client.Vehicle_setSpeed(vehID, speed);
                }
            }
            catch (FaultException e)
            {
                client.Abort();
                throw new FaultException(e.Message);
            }
            catch (Exception e)
            {
                throw new FaultException(e.InnerException.ToString());
            }
            finally
            {
                client.Close();
            }
        }