Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Pass Information from follower to the leader(C++)

you can use
static_cast<MSDevice_Car2Car*>(leader->getDevice(typeid(MSDevice_Car2Car)))->setParameter(...)

But please take these questions to sumo-dev (https://sumo.dlr.de/docs/Contact.html)

regards,
Jakob

Am Mi., 29. Jan. 2020 um 14:34 Uhr schrieb WTler <valentin.klamka@xxxxxxxxxxxxxx>:
Hi Jacob, hi community,

I want to pass Information from the follower to the leader:

void
MSDevice_Car2Car_Energy_Sharing::myMethod() {
         MSVehicle* holder =
libsumo::Helper::getVehicle(this->getHolder().getID());
         std::pair<const MSVehicle* const, double>result = holder->getLeader();
         const MSVehicle* leader = result.first;
         if (leader->hasDevice("MSDevice_Car2Car_Energy_Sharing") &&
!this->isPDLeader) {
                 leader->setDeviceParameter("MSDevice_Car2Car_Energy_Sharing", "pdLeader",
"true"); //relevant part
         }
}

This does not compile, it would compile however if I would do:
                 holder->setDeviceParameter("MSDevice_Car2Car_Energy_Sharing", "pdLeader",
"true");

The problem is obviously the "const" keyword, so it's not intended that we
change values with getLeader().
Is there another way I can pass Information to the leader?





--
Sent from: http://sumo-user-mailing-list.90755.n8.nabble.com/
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top