Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Problem getting Parameter of my device(No device of type ' ' exists)

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/


Back to the top