Search in sources :

Example 1 with IdTagInfo

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();
    }
}
Also used : IdTagInfo(ocpp.cs._2015._10.IdTagInfo) StopTransactionResponse(ocpp.cs._2015._10.StopTransactionResponse) UpdateTransactionParams(de.rwth.idsg.steve.repository.dto.UpdateTransactionParams)

Example 2 with IdTagInfo

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);
}
Also used : AuthorizeResponse(ocpp.cs._2015._10.AuthorizeResponse) IdTagInfo(ocpp.cs._2015._10.IdTagInfo)

Example 3 with 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);
}
Also used : InsertTransactionParams(de.rwth.idsg.steve.repository.dto.InsertTransactionParams) IdTagInfo(ocpp.cs._2015._10.IdTagInfo) StartTransactionResponse(ocpp.cs._2015._10.StartTransactionResponse)

Example 4 with IdTagInfo

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;
}
Also used : OcppTagRecord(jooq.steve.db.tables.records.OcppTagRecord) IdTagInfo(ocpp.cs._2015._10.IdTagInfo) DateTime(org.joda.time.DateTime)

Aggregations

IdTagInfo (ocpp.cs._2015._10.IdTagInfo)4 InsertTransactionParams (de.rwth.idsg.steve.repository.dto.InsertTransactionParams)1 UpdateTransactionParams (de.rwth.idsg.steve.repository.dto.UpdateTransactionParams)1 OcppTagRecord (jooq.steve.db.tables.records.OcppTagRecord)1 AuthorizeResponse (ocpp.cs._2015._10.AuthorizeResponse)1 StartTransactionResponse (ocpp.cs._2015._10.StartTransactionResponse)1 StopTransactionResponse (ocpp.cs._2015._10.StopTransactionResponse)1 DateTime (org.joda.time.DateTime)1