@@ -112,9 +112,13 @@ ChargePointStatus Connector::getStatus() {
112112 } else {
113113 res = ChargePointStatus::Charging;
114114 }
115- } else if (model.getReservationService () && model.getReservationService ()->getReservation (connectorId)) {
115+ }
116+ #if MO_ENABLE_V16_RESERVATION
117+ else if (model.getReservationService () && model.getReservationService ()->getReservation (connectorId)) {
116118 res = ChargePointStatus::Reserved;
117- } else if ((!transaction || !transaction->isActive ()) && // no transaction preparation
119+ }
120+ #endif
121+ else if ((!transaction || !transaction->isActive ()) && // no transaction preparation
118122 (!connectorPluggedInput || !connectorPluggedInput ()) && // no vehicle plugged
119123 (!occupiedInput || !occupiedInput ())) { // occupied override clear
120124 res = ChargePointStatus::Available;
@@ -609,17 +613,22 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
609613 }
610614 }
611615
612- Reservation *reservation = nullptr ;
616+ int reservationId = - 1 ;
613617 bool offlineBlockedResv = false ; // if offline authorization will be blocked by reservation
614618
619+ #if MO_ENABLE_V16_RESERVATION
615620 // check if blocked by reservation
616621 if (model.getReservationService ()) {
617622 const char *parentIdTag = localAuth ? localAuth->getParentIdTag () : nullptr ;
618623
619- reservation = model.getReservationService ()->getReservation (
624+ auto reservation = model.getReservationService ()->getReservation (
620625 connectorId,
621626 idTag,
622627 parentIdTag);
628+
629+ if (reservation) {
630+ reservationId = reservation->getReservationId ();
631+ }
623632
624633 if (reservation && !reservation->matches (
625634 idTag,
@@ -640,6 +649,7 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
640649 }
641650 }
642651 }
652+ #endif // MO_ENABLE_V16_RESERVATION
643653
644654 transaction = allocateTransaction ();
645655
@@ -661,8 +671,8 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
661671 if (localAuth && localPreAuthorizeBool && localPreAuthorizeBool->getBool ()) {
662672 MO_DBG_DEBUG (" Begin transaction process (%s), preauthorized locally" , idTag != nullptr ? idTag : " " );
663673
664- if (reservation ) {
665- transaction->setReservationId (reservation-> getReservationId () );
674+ if (reservationId >= 0 ) {
675+ transaction->setReservationId (reservationId );
666676 }
667677 transaction->setAuthorized ();
668678
@@ -692,6 +702,7 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
692702 return ;
693703 }
694704
705+ #if MO_ENABLE_V16_RESERVATION
695706 if (model.getReservationService ()) {
696707 auto reservation = model.getReservationService ()->getReservation (
697708 connectorId,
@@ -714,6 +725,7 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
714725 }
715726 }
716727 }
728+ #endif // MO_ENABLE_V16_RESERVATION
717729
718730 MO_DBG_DEBUG (" Authorized transaction process (%s)" , tx->getIdTag ());
719731 tx->setAuthorized ();
@@ -724,13 +736,10 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
724736
725737 // capture local auth and reservation check in for timeout handler
726738 bool localAuthFound = localAuth;
727- bool reservationFound = reservation;
728- int reservationId = reservation ? reservation->getReservationId () : -1 ;
729739 authorize->setOnTimeoutListener ([this , tx,
730740 offlineBlockedAuth,
731741 offlineBlockedResv,
732742 localAuthFound,
733- reservationFound,
734743 reservationId] () {
735744
736745 if (offlineBlockedAuth) {
@@ -753,7 +762,7 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
753762
754763 if (localAuthFound && localAuthorizeOfflineBool && localAuthorizeOfflineBool->getBool ()) {
755764 MO_DBG_DEBUG (" Offline transaction process (%s), locally authorized" , tx->getIdTag ());
756- if (reservationFound ) {
765+ if (reservationId >= 0 ) {
757766 tx->setReservationId (reservationId);
758767 }
759768 tx->setAuthorized ();
@@ -765,7 +774,7 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
765774
766775 if (allowOfflineTxForUnknownIdBool && allowOfflineTxForUnknownIdBool->getBool ()) {
767776 MO_DBG_DEBUG (" Offline transaction process (%s), allow unknown ID" , tx->getIdTag ());
768- if (reservationFound ) {
777+ if (reservationId >= 0 ) {
769778 tx->setReservationId (reservationId);
770779 }
771780 tx->setAuthorized ();
@@ -811,14 +820,16 @@ std::shared_ptr<Transaction> Connector::beginTransaction_authorized(const char *
811820 MO_DBG_DEBUG (" Begin transaction process (%s), already authorized" , idTag != nullptr ? idTag : " " );
812821
813822 transaction->setAuthorized ();
814-
823+
824+ #if MO_ENABLE_V16_RESERVATION
815825 if (model.getReservationService ()) {
816826 if (auto reservation = model.getReservationService ()->getReservation (connectorId, idTag, parentIdTag)) {
817827 if (reservation->matches (idTag, parentIdTag)) {
818828 transaction->setReservationId (reservation->getReservationId ());
819829 }
820830 }
821831 }
832+ #endif // MO_ENABLE_V16_RESERVATION
822833
823834 transaction->commit ();
824835
0 commit comments