Exemplo n.º 1
0
    void Update()
    {
        TraCIResponse <List <string> > vehicleIDs = client.Vehicle.GetIdList();

        foreach (string vehicleId in vehicleIDs.Content)
        {
            if (!renderedVehicles.ContainsKey(vehicleId))
            {
                CreateRenderedVehicle(vehicleId);
            }
            Position3D position = client.Vehicle.GetPosition3D(vehicleId).Content;
            double     yawAngle = client.Vehicle.GetAngle(vehicleId).Content;
            UpdateRenderedVehicle(vehicleId, position, (float)yawAngle);
        }
        List <string> vehiclesToDestroy = new List <string>();

        foreach (string id in renderedVehicles.Keys)
        {
            if (!vehicleIDs.Content.Contains(id))
            {
                vehiclesToDestroy.Add(id);
            }
        }
        foreach (string id in vehiclesToDestroy)
        {
            DestroyRenderedVehicle(id);
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the links controlled by the traffic light, sorted by the signal index and described by giving
        /// the incoming, outgoing, and via lane.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public TraCIResponse <ControlledLinks> GetControlledLinks(string id)
        {
            var tmp = TraCICommandHelper.ExecuteGetCommand <CompoundObject>(
                Client,
                id,
                TraCIConstants.CMD_GET_TL_VARIABLE,
                TraCIConstants.TL_CONTROLLED_LINKS);

            var controlledLinks = TraCIDataConverter.ConvertToControlledLinks(tmp.Content.Value);

            var ret = new TraCIResponse <ControlledLinks>
            {
                Content            = controlledLinks,
                ErrorMessage       = tmp.ErrorMessage,
                Identifier         = tmp.Identifier,
                ResponseIdentifier = tmp.ResponseIdentifier,
                Result             = tmp.Result,
                Variable           = tmp.Variable
            };

            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the complete traffic light program, structure described under data types
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public TraCIResponse <TrafficCompleteLightProgram> GetCompleteDefinition(string id)
        {
            var tmp = TraCICommandHelper.ExecuteGetCommand <CompoundObject>(
                Client,
                id,
                TraCIConstants.CMD_GET_TL_VARIABLE,
                TraCIConstants.TL_COMPLETE_DEFINITION_RYG);

            var tmp2 = TraCIDataConverter.ConvertToTrafficLightCompleteProgramm(tmp.Content);

            var ret = new TraCIResponse <TrafficCompleteLightProgram>
            {
                Content            = tmp2,
                ErrorMessage       = tmp.ErrorMessage,
                Identifier         = tmp.Identifier,
                ResponseIdentifier = tmp.ResponseIdentifier,
                Result             = tmp.Result,
                Variable           = tmp.Variable
            };

            return(ret);
        }