Skip to content

Commit 8a67a97

Browse files
committed
Added default values for calibrator flows. Refs #17398
1 parent 9d8083f commit 8a67a97

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/netedit/dialogs/elements/GNECalibratorDialog.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,16 @@ GNECalibratorDialog::CalibratorFlowsList::addNewElement() {
9999
GNEDemandElement* vType = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, DEFAULT_VTYPE_ID);
100100
// get route
101101
GNEDemandElement* route = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_ROUTE).begin()->second;
102+
// calculate begin based in last calibrator flow
103+
SUMOTime begin = 0;
104+
for (const auto &child : myElementDialogParent->getElement()->getChildAdditionals()) {
105+
if (child->getTagProperty()->getTag() == GNE_TAG_CALIBRATOR_FLOW) {
106+
begin = GNEAttributeCarrier::parse<SUMOTime>(child->getAttribute(SUMO_ATTR_END));
107+
}
108+
}
109+
const SUMOTime duration = GNEAttributeCarrier::parse<SUMOTime>("3600");
102110
// create vType
103-
GNECalibratorFlow* calibratorFlow = new GNECalibratorFlow(myElementDialogParent->getElement(), vType, route);
111+
GNECalibratorFlow* calibratorFlow = new GNECalibratorFlow(myElementDialogParent->getElement(), begin, begin + duration, vType, route);
104112
// add using undo-redo
105113
insertElement(calibratorFlow);
106114
// open route dialog
@@ -109,6 +117,8 @@ GNECalibratorDialog::CalibratorFlowsList::addNewElement() {
109117
if (calibratorFlowDialog.getResult() != GNEDialog::Result::ACCEPT) {
110118
// add calibratorFlow
111119
return removeElement(calibratorFlow);
120+
} else {
121+
updateList();
112122
}
113123
return 1;
114124
}

src/netedit/elements/additional/GNECalibratorFlow.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ GNECalibratorFlow::GNECalibratorFlow(GNENet* net) :
4444
}
4545

4646

47-
GNECalibratorFlow::GNECalibratorFlow(GNEAdditional* calibratorParent, GNEDemandElement* vehicleType, GNEDemandElement* route) :
47+
GNECalibratorFlow::GNECalibratorFlow(GNEAdditional* calibratorParent, const SUMOTime begin, const SUMOTime end,
48+
GNEDemandElement* vehicleType, GNEDemandElement* route) :
4849
GNEAdditional(calibratorParent, GNE_TAG_CALIBRATOR_FLOW, ""),
4950
GNEAdditionalListed(this) {
5051
// set parents
@@ -54,6 +55,11 @@ GNECalibratorFlow::GNECalibratorFlow(GNEAdditional* calibratorParent, GNEDemandE
5455
updateCenteringBoundary(false);
5556
// reset ID
5657
id.clear();
58+
// set begin and end
59+
depart = begin;
60+
repetitionEnd = end;
61+
// set default vehsperhour
62+
setAttribute(SUMO_ATTR_VEHSPERHOUR, "1800");
5763
}
5864

5965

src/netedit/elements/additional/GNECalibratorFlow.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ class GNECalibratorFlow : public GNEAdditional, public SUMOVehicleParameter, pub
4242
GNECalibratorFlow(GNENet* net);
4343

4444
/// @brief default constructor (used only in GNECalibratorDialog)
45-
GNECalibratorFlow(GNEAdditional* calibratorParent, GNEDemandElement* vehicleType, GNEDemandElement* route);
45+
GNECalibratorFlow(GNEAdditional* calibratorParent, const SUMOTime begin, const SUMOTime end,
46+
GNEDemandElement* vehicleType, GNEDemandElement* route);
4647

4748
/// @brief parameter constructor
48-
GNECalibratorFlow(GNEAdditional* calibratorParent, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
49+
GNECalibratorFlow(GNEAdditional* calibratorParent, GNEDemandElement* vehicleType,
50+
GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
4951

5052
/// @brief destructor
5153
~GNECalibratorFlow();

0 commit comments

Comments
 (0)