use of ocpp.cs._2015._10.IdTagInfo in project steve by RWTH-i5-IDSG.
the class CentralSystemService16_Service method stopTransaction.
public StopTransactionResponse stopTransaction(StopTransactionRequest parameters, String chargeBoxIdentity) {
int transactionId = parameters.getTransactionId();
String stopReason = parameters.isSetReason() ? parameters.getReason().value() : null;
UpdateTransactionParams params = UpdateTransactionParams.builder().chargeBoxId(chargeBoxIdentity).transactionId(transactionId).stopTimestamp(parameters.getTimestamp()).stopMeterValue(Integer.toString(parameters.getMeterStop())).stopReason(stopReason).build();
ocppServerRepository.updateTransaction(params);
if (parameters.isSetTransactionData()) {
ocppServerRepository.insertMeterValues(chargeBoxIdentity, parameters.getTransactionData(), transactionId);
}
// Get the authorization info of the user
if (parameters.isSetIdTag()) {
IdTagInfo idTagInfo = ocppTagService.getIdTagInfo(parameters.getIdTag());
return new StopTransactionResponse().withIdTagInfo(idTagInfo);
} else {
return new StopTransactionResponse();
}
}
use of ocpp.cs._2015._10.IdTagInfo in project steve by RWTH-i5-IDSG.
the class CentralSystemService16_Service method authorize.
public AuthorizeResponse authorize(AuthorizeRequest parameters, String chargeBoxIdentity) {
// Get the authorization info of the user
String idTag = parameters.getIdTag();
IdTagInfo idTagInfo = ocppTagService.getIdTagInfo(idTag);
return new AuthorizeResponse().withIdTagInfo(idTagInfo);
}
use of ocpp.cs._2015._10.IdTagInfo in project steve by RWTH-i5-IDSG.
the class CentralSystemService16_Service method startTransaction.
public StartTransactionResponse startTransaction(StartTransactionRequest parameters, String chargeBoxIdentity) {
InsertTransactionParams params = InsertTransactionParams.builder().chargeBoxId(chargeBoxIdentity).connectorId(parameters.getConnectorId()).idTag(parameters.getIdTag()).startTimestamp(parameters.getTimestamp()).startMeterValue(Integer.toString(parameters.getMeterStart())).reservationId(parameters.getReservationId()).build();
Integer transactionId = ocppServerRepository.insertTransaction(params);
IdTagInfo info = ocppTagService.getIdTagInfo(parameters.getIdTag());
return new StartTransactionResponse().withIdTagInfo(info).withTransactionId(transactionId);
}
use of ocpp.cs._2015._10.IdTagInfo in project steve by RWTH-i5-IDSG.
the class OcppTagServiceImpl method getIdTagInfo.
@Override
public IdTagInfo getIdTagInfo(String idTag) {
OcppTagRecord record = ocppTagRepository.getRecord(idTag);
IdTagInfo idTagInfo = new IdTagInfo();
if (record == null) {
log.error("The user with idTag '{}' is INVALID (not present in DB).", idTag);
idTagInfo.setStatus(AuthorizationStatus.INVALID);
invalidOcppTagService.processNewUnidentified(idTag);
} else {
DateTime expiryDate = record.getExpiryDate();
boolean isExpiryDateSet = expiryDate != null;
if (record.getBlocked()) {
log.error("The user with idTag '{}' is BLOCKED.", idTag);
idTagInfo.setStatus(AuthorizationStatus.BLOCKED);
// } else if (record.getInTransaction()) {
// log.warn("The user with idTag '{}' is ALREADY in another transaction.", idTag);
// idTagInfo.setStatus(ocpp.cs._2012._06.AuthorizationStatus.CONCURRENT_TX);
} else if (isExpiryDateSet && DateTime.now().isAfter(record.getExpiryDate())) {
log.error("The user with idTag '{}' is EXPIRED.", idTag);
idTagInfo.setStatus(AuthorizationStatus.EXPIRED);
} else {
log.debug("The user with idTag '{}' is ACCEPTED.", idTag);
idTagInfo.setStatus(AuthorizationStatus.ACCEPTED);
// If the database contains an actual expiry, use it. Otherwise, calculate an expiry for cached info
DateTime expiry = isExpiryDateSet ? expiryDate : DateTime.now().plusHours(settingsRepository.getHoursToExpire());
idTagInfo.setExpiryDate(expiry);
idTagInfo.setParentIdTag(record.getParentIdTag());
}
}
return idTagInfo;
}
Aggregations