Hello, using vehicle.getParameter(vehID, DEVICENAME.PARAMNAME) is currently the recommended way to access vehicle devices. To make this work, your device must override the device method deviceName() to return the value "Car2Car". regards, Jakob
Am So., 15. Dez. 2019 um 13:54 Uhr schrieb WTler < [email protected]>: > Hi, > I made a new device-class called MSDevice_Car2Car_Energy_Sharing which just > extends MSDevice_Battery. So far when I load additional parameters in my > type.add.xml file like that: > <additional> > <vType id="myType" emissionClass="Energy/unknown"> > > </vType> > </additional> > it just works. That means every car in my simulation has this device now. > Now to my problem: I want to implement a method which calculates something > and call it with traci from python. When I want to get parameters like > energyConsumed I previously did: > traci.vehicle.getParameter(vehID,"device.battery.energyConsumed") > Now I want to call it from my class. When I try: > traci.vehicle.getParameter(vehID,"device.Car2Car.energyConsumed") > I get: > Vehicle '102' does not support device parameter > 'device.Car2Car.energyConsumed' (No device of type 'Car2Car' exists). > How can I get a parameter of my class? > My insertOption method: > > void > MSDevice_Car2Car_Energy_Sharing::insertOptions(OptionsCont& oc) { > oc.addOptionSubTopic("Car2Car-Energy-Sharing"); > insertDefaultAssignmentOptions("Car2Car-Energy-Sharing", > "Car2Car-Energy-Sharing", oc); > > oc.doRegister("device.Car2Car.parameter", new Option_Float(0.0)); > oc.addDescription("device.Car2Car.parameter", > "Car2Car-Energy-Sharing", > "The Car2Car-Energy-Sharing Device"); > } > > Since my class MSDevice_Car2Car_Energy_Sharing extends MSDevice_Battery I > would assume that would return the parameter of MSDevice_Battery. When I > have that, I assume its possible to trigger my method with getParameter? > (is > this best practice anyway?). I appreciate any help > > > > > -- > Sent from: http://sumo-user-mailing-list.90755.n8.nabble.com/ > _______________________________________________ > sumo-user mailing list > [email protected] > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://www.eclipse.org/mailman/listinfo/sumo-user >
_______________________________________________ sumo-user mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
