//public void Update() //{ // Readcars(); //} void ReadCars() { Debug.Log("LLAMANDO"); carList.Clear(); /*int simtime = (int)*/ int simtime = ((Integer)(conn.do_job_get(Simulation.getCurrentTime()))).intValue(); carIds = (SumoStringList)conn.do_job_get(Vehicle.getIDList()); foreach (string id in carIds) { Debug.Log("id:" + id); position = (SumoPosition2D)conn.do_job_get(Vehicle.getPosition(id)); car = new Auto(position.x, position.y, Convert.ToInt32(id)); speed = ((java.lang.Double)conn.do_job_get(Vehicle.getSpeed(id))).doubleValue(); angle = ((java.lang.Double)conn.do_job_get(Vehicle.getAngle(id))).doubleValue(); car.setSpeed(speed); car.setAngle(angle); carList.Add(car); } //printCars(cars); conn.do_timestep(); }
void ReadCoches() { Debug.Log("LLAMANDO"); coches.Clear(); int simtime = (int)conn.do_job_get(Simulation.getCurrentTime()); carIds = (SumoStringList)conn.do_job_get(Vehicle.getIDList()); foreach (string id in carIds) { Debug.Log(id + " "); position = (SumoPosition2D)conn.do_job_get(Vehicle.getPosition(id)); coche = new Auto(position.x, position.y, Convert.ToInt32(id)); speed = (Double)conn.do_job_get(Vehicle.getSpeed(id)); coche.setSpeed(speed); coches.Add(coche); } pintarCoches(coches); conn.do_timestep(); }
bool ReadVehicles() { try { RemoveVehicles(); SumoStringList carIds = (SumoStringList)conn.do_job_get(de.tudresden.sumo.cmd.Vehicle.getIDList()); foreach (string id in carIds) { conn.do_timestep(); // create new car GameObject newVehicle = Instantiate(carPrefab); // assign id newVehicle.GetComponent <VehicleContainer>().setId(id); // get position SumoPosition2D position = (SumoPosition2D)conn.do_job_get(de.tudresden.sumo.cmd.Vehicle.getPosition(id)); // assign position newVehicle.transform.position = new Vector3((float)position.x, CarHeight, (float)position.y); // get speed double speed = double.Parse(conn.do_job_get(de.tudresden.sumo.cmd.Vehicle.getSpeed(id)).ToString()); // assign speed newVehicle.GetComponent <VehicleContainer>().setSpeed(speed); if (id.Contains("ev")) { // assign red color to EV newVehicle.GetComponent <Renderer>().material.color = Color.red; } newVehicle.transform.parent = vehicleParent.transform; // store vehicle vehicles.Add(newVehicle); } } catch (Exception e) { Debug.Log("Read Vehicles Exception : " + e.Message + " -- " + e.StackTrace); return(false); } return(true); }