1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2014-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
10 /// @file    MSSOTLMarchingPolicy.cpp
11 /// @author  Alessio Bonfietti
12 /// @author  Riccardo Belletti
13 /// @author  Federico Caselli
14 /// @date    2014-03-20
15 /// @version $Id$
16 ///
17 // The class for SOTL Marching logics
18 /****************************************************************************/
19 
20 #include "MSSOTLMarchingPolicy.h"
21 
MSSOTLMarchingPolicy(const std::map<std::string,std::string> & parameters)22 MSSOTLMarchingPolicy::MSSOTLMarchingPolicy(
23     const std::map<std::string, std::string>& parameters) :
24     MSSOTLPolicy("Marching", parameters) {
25     init();
26 }
27 
MSSOTLMarchingPolicy(MSSOTLPolicyDesirability * desirabilityAlgorithm)28 MSSOTLMarchingPolicy::MSSOTLMarchingPolicy(
29     MSSOTLPolicyDesirability* desirabilityAlgorithm) :
30     MSSOTLPolicy("Marching", desirabilityAlgorithm) {
31     getDesirabilityAlgorithm()->setKeyPrefix("MARCHING");
32     init();
33 }
34 
MSSOTLMarchingPolicy(MSSOTLPolicyDesirability * desirabilityAlgorithm,const std::map<std::string,std::string> & parameters)35 MSSOTLMarchingPolicy::MSSOTLMarchingPolicy(
36     MSSOTLPolicyDesirability* desirabilityAlgorithm,
37     const std::map<std::string, std::string>& parameters) :
38     MSSOTLPolicy("Marching", desirabilityAlgorithm, parameters) {
39     getDesirabilityAlgorithm()->setKeyPrefix("MARCHING");
40     init();
41 }
42 
canRelease(SUMOTime elapsed,bool,bool pushButtonPressed,const MSPhaseDefinition * stage,int)43 bool MSSOTLMarchingPolicy::canRelease(SUMOTime elapsed, bool /* thresholdPassed */, bool pushButtonPressed,
44                                       const MSPhaseDefinition* stage, int /* vehicleCount */) {
45     if (elapsed >= stage->minDuration && pushButtonLogic(elapsed, pushButtonPressed, stage)) {
46         return true;
47     }
48     return (elapsed >= stage->duration);
49 }
50 
init()51 void MSSOTLMarchingPolicy::init() {
52     PushButtonLogic::init("MSSOTLMarchingPolicy", this);
53 }
54