From febd153b08ae714923bb25fbed7743e7e71a3fd0 Mon Sep 17 00:00:00 2001 From: Robert Schlabbach Date: Fri, 12 Dec 2025 21:35:35 +0100 Subject: [PATCH 1/4] Add OCPP 2.1 support Add Java classes for all OCPP 2.1 messages and types as well as client and server event handler interfaces and function classes corresponding to the OCPP 2.1 "functional blocks." Add OCPP 2.1 to the ProtocolVersion enum. Specify UTF-8 encoding for the Java source files in build.gradle and pom.xml to avoid compiler warnings about the UTF-8 sequences in the source files. --- build.gradle | 4 + .../eu/chargetime/ocpp/ProtocolVersion.java | 3 +- ocpp-v1_6-test/pom.xml | 4 +- .../ocpp/v21/feature/AFRRSignalFeature.java | 54 + .../AdjustPeriodicEventStreamFeature.java | 54 + .../ocpp/v21/feature/AuthorizeFeature.java | 54 + .../ocpp/v21/feature/BatterySwapFeature.java | 54 + .../v21/feature/BootNotificationFeature.java | 54 + .../v21/feature/CancelReservationFeature.java | 54 + .../v21/feature/CertificateSignedFeature.java | 54 + .../feature/ChangeAvailabilityFeature.java | 54 + .../ChangeTransactionTariffFeature.java | 54 + .../ocpp/v21/feature/ClearCacheFeature.java | 54 + .../feature/ClearChargingProfileFeature.java | 54 + .../v21/feature/ClearDERControlFeature.java | 54 + .../feature/ClearDisplayMessageFeature.java | 54 + .../ocpp/v21/feature/ClearTariffsFeature.java | 54 + .../ClearVariableMonitoringFeature.java | 54 + .../feature/ClearedChargingLimitFeature.java | 54 + .../ClosePeriodicEventStreamFeature.java | 54 + .../ocpp/v21/feature/CostUpdatedFeature.java | 54 + .../feature/CustomerInformationFeature.java | 54 + .../ocpp/v21/feature/DataTransferFeature.java | 54 + .../v21/feature/DeleteCertificateFeature.java | 54 + .../FirmwareStatusNotificationFeature.java | 54 + .../feature/Get15118EVCertificateFeature.java | 54 + .../v21/feature/GetBaseReportFeature.java | 54 + .../GetCertificateChainStatusFeature.java | 54 + .../feature/GetCertificateStatusFeature.java | 54 + .../feature/GetChargingProfilesFeature.java | 54 + .../feature/GetCompositeScheduleFeature.java | 54 + .../v21/feature/GetDERControlFeature.java | 54 + .../feature/GetDisplayMessagesFeature.java | 54 + .../GetInstalledCertificateIdsFeature.java | 54 + .../feature/GetLocalListVersionFeature.java | 54 + .../ocpp/v21/feature/GetLogFeature.java | 54 + .../feature/GetMonitoringReportFeature.java | 54 + .../GetPeriodicEventStreamFeature.java | 54 + .../ocpp/v21/feature/GetReportFeature.java | 54 + .../ocpp/v21/feature/GetTariffsFeature.java | 54 + .../feature/GetTransactionStatusFeature.java | 54 + .../ocpp/v21/feature/GetVariablesFeature.java | 54 + .../ocpp/v21/feature/HeartbeatFeature.java | 54 + .../feature/InstallCertificateFeature.java | 54 + .../feature/LogStatusNotificationFeature.java | 54 + .../ocpp/v21/feature/MeterValuesFeature.java | 54 + .../NotifyAllowedEnergyTransferFeature.java | 54 + .../feature/NotifyChargingLimitFeature.java | 54 + .../NotifyCustomerInformationFeature.java | 54 + .../v21/feature/NotifyDERAlarmFeature.java | 54 + .../feature/NotifyDERStartStopFeature.java | 54 + .../feature/NotifyDisplayMessagesFeature.java | 54 + .../feature/NotifyEVChargingNeedsFeature.java | 54 + .../NotifyEVChargingScheduleFeature.java | 54 + .../ocpp/v21/feature/NotifyEventFeature.java | 54 + .../NotifyMonitoringReportFeature.java | 54 + .../NotifyPriorityChargingFeature.java | 54 + .../ocpp/v21/feature/NotifyReportFeature.java | 54 + .../v21/feature/NotifySettlementFeature.java | 54 + .../NotifyWebPaymentStartedFeature.java | 54 + .../OpenPeriodicEventStreamFeature.java | 54 + .../v21/feature/PublishFirmwareFeature.java | 54 + ...lishFirmwareStatusNotificationFeature.java | 54 + .../PullDynamicScheduleUpdateFeature.java | 54 + .../ReportChargingProfilesFeature.java | 54 + .../v21/feature/ReportDERControlFeature.java | 54 + .../feature/RequestBatterySwapFeature.java | 54 + .../RequestStartTransactionFeature.java | 54 + .../RequestStopTransactionFeature.java | 54 + .../ReservationStatusUpdateFeature.java | 54 + .../ocpp/v21/feature/ReserveNowFeature.java | 54 + .../ocpp/v21/feature/ResetFeature.java | 54 + .../SecurityEventNotificationFeature.java | 54 + .../v21/feature/SendLocalListFeature.java | 54 + .../feature/SetChargingProfileFeature.java | 54 + .../v21/feature/SetDERControlFeature.java | 54 + .../v21/feature/SetDefaultTariffFeature.java | 54 + .../v21/feature/SetDisplayMessageFeature.java | 54 + .../v21/feature/SetMonitoringBaseFeature.java | 54 + .../feature/SetMonitoringLevelFeature.java | 54 + .../v21/feature/SetNetworkProfileFeature.java | 54 + .../feature/SetVariableMonitoringFeature.java | 54 + .../ocpp/v21/feature/SetVariablesFeature.java | 54 + .../v21/feature/SignCertificateFeature.java | 54 + .../feature/StatusNotificationFeature.java | 54 + .../v21/feature/TransactionEventFeature.java | 54 + .../v21/feature/TriggerMessageFeature.java | 54 + .../v21/feature/UnlockConnectorFeature.java | 54 + .../v21/feature/UnpublishFirmwareFeature.java | 54 + .../feature/UpdateDynamicScheduleFeature.java | 54 + .../v21/feature/UpdateFirmwareFeature.java | 54 + .../feature/UsePriorityChargingFeature.java | 54 + .../feature/VatNumberValidationFeature.java | 54 + .../ClientAuthorizationEventHandler.java | 48 + .../function/ClientAuthorizationFunction.java | 109 + .../ClientAvailabilityEventHandler.java | 38 + .../function/ClientAvailabilityFunction.java | 95 + ...idirectionalPowerTransferEventHandler.java | 48 + ...entBidirectionalPowerTransferFunction.java | 69 + .../ClientDERControlEventHandler.java | 62 + .../function/ClientDERControlFunction.java | 99 + .../ClientDataTransferEventHandler.java | 38 + .../function/ClientDataTransferFunction.java | 71 + .../ClientDiagnosticsEventHandler.java | 120 + .../function/ClientDiagnosticsFunction.java | 148 ++ .../ClientDisplayMessageEventHandler.java | 54 + .../ClientDisplayMessageFunction.java | 78 + .../ClientFirmwareManagementEventHandler.java | 54 + .../ClientFirmwareManagementFunction.java | 91 + ...5118CertificateManagementEventHandler.java | 48 + ...ISO15118CertificateManagementFunction.java | 109 + ...thorizationListManagementEventHandler.java | 46 + ...alAuthorizationListManagementFunction.java | 68 + .../function/ClientMeterValuesFunction.java | 69 + .../ClientProvisioningEventHandler.java | 78 + .../function/ClientProvisioningFunction.java | 115 + .../ClientRemoteControlEventHandler.java | 66 + .../function/ClientRemoteControlFunction.java | 72 + .../ClientReservationEventHandler.java | 46 + .../function/ClientReservationFunction.java | 77 + .../function/ClientSecurityEventHandler.java | 46 + .../function/ClientSecurityFunction.java | 92 + .../ClientSmartChargingEventHandler.java | 82 + .../function/ClientSmartChargingFunction.java | 183 ++ .../ClientTariffAndCostEventHandler.java | 72 + .../function/ClientTariffAndCostFunction.java | 74 + .../ClientTransactionsEventHandler.java | 39 + .../function/ClientTransactionsFunction.java | 119 + .../ServerAuthorizationEventHandler.java | 60 + .../function/ServerAuthorizationFunction.java | 93 + .../ServerAvailabilityEventHandler.java | 50 + .../function/ServerAvailabilityFunction.java | 78 + ...verBidirectionalPowerTransferFunction.java | 84 + .../ServerDERControlEventHandler.java | 51 + .../function/ServerDERControlFunction.java | 113 + .../ServerDataTransferEventHandler.java | 40 + .../function/ServerDataTransferFunction.java | 71 + .../ServerDiagnosticsEventHandler.java | 75 + .../function/ServerDiagnosticsFunction.java | 197 ++ .../ServerDisplayMessageEventHandler.java | 42 + .../ServerDisplayMessageFunction.java | 95 + .../ServerFirmwareManagementEventHandler.java | 53 + .../ServerFirmwareManagementFunction.java | 106 + ...5118CertificateManagementEventHandler.java | 63 + ...ISO15118CertificateManagementFunction.java | 96 + ...alAuthorizationListManagementFunction.java | 83 + .../ServerMeterValuesEventHandler.java | 40 + .../function/ServerMeterValuesFunction.java | 61 + .../ServerProvisioningEventHandler.java | 59 + .../function/ServerProvisioningFunction.java | 139 ++ .../function/ServerRemoteControlFunction.java | 106 + .../ServerReservationEventHandler.java | 42 + .../function/ServerReservationFunction.java | 89 + .../function/ServerSecurityEventHandler.java | 52 + .../function/ServerSecurityFunction.java | 92 + .../ServerSmartChargingEventHandler.java | 106 + .../function/ServerSmartChargingFunction.java | 168 ++ .../function/ServerTariffAndCostFunction.java | 117 + .../ServerTransactionsEventHandler.java | 60 + .../function/ServerTransactionsFunction.java | 79 + .../v21/model/messages/AFRRSignalRequest.java | 205 ++ .../model/messages/AFRRSignalResponse.java | 211 ++ .../AdjustPeriodicEventStreamRequest.java | 205 ++ .../AdjustPeriodicEventStreamResponse.java | 211 ++ .../v21/model/messages/AuthorizeRequest.java | 293 +++ .../v21/model/messages/AuthorizeResponse.java | 345 +++ .../model/messages/BatterySwapRequest.java | 304 +++ .../model/messages/BatterySwapResponse.java | 120 + .../messages/BootNotificationRequest.java | 208 ++ .../messages/BootNotificationResponse.java | 303 +++ .../messages/CancelReservationRequest.java | 166 ++ .../messages/CancelReservationResponse.java | 211 ++ .../messages/CertificateSignedRequest.java | 269 +++ .../messages/CertificateSignedResponse.java | 211 ++ .../messages/ChangeAvailabilityRequest.java | 220 ++ .../messages/ChangeAvailabilityResponse.java | 211 ++ .../ChangeTransactionTariffRequest.java | 223 ++ .../ChangeTransactionTariffResponse.java | 211 ++ .../v21/model/messages/ClearCacheRequest.java | 124 + .../model/messages/ClearCacheResponse.java | 211 ++ .../messages/ClearChargingProfileRequest.java | 220 ++ .../ClearChargingProfileResponse.java | 211 ++ .../messages/ClearDERControlRequest.java | 252 ++ .../messages/ClearDERControlResponse.java | 211 ++ .../messages/ClearDisplayMessageRequest.java | 165 ++ .../messages/ClearDisplayMessageResponse.java | 211 ++ .../model/messages/ClearTariffsRequest.java | 223 ++ .../model/messages/ClearTariffsResponse.java | 165 ++ .../ClearVariableMonitoringRequest.java | 166 ++ .../ClearVariableMonitoringResponse.java | 166 ++ .../messages/ClearedChargingLimitRequest.java | 222 ++ .../ClearedChargingLimitResponse.java | 119 + .../ClosePeriodicEventStreamRequest.java | 165 ++ .../ClosePeriodicEventStreamResponse.java | 119 + .../model/messages/CostUpdatedRequest.java | 215 ++ .../model/messages/CostUpdatedResponse.java | 119 + .../messages/CustomerInformationRequest.java | 441 ++++ .../messages/CustomerInformationResponse.java | 211 ++ .../model/messages/DataTransferRequest.java | 257 ++ .../model/messages/DataTransferResponse.java | 246 ++ .../messages/DeleteCertificateRequest.java | 167 ++ .../messages/DeleteCertificateResponse.java | 211 ++ .../FirmwareStatusNotificationRequest.java | 264 +++ .../FirmwareStatusNotificationResponse.java | 119 + .../Get15118EVCertificateRequest.java | 388 ++++ .../Get15118EVCertificateResponse.java | 308 +++ .../model/messages/GetBaseReportRequest.java | 207 ++ .../model/messages/GetBaseReportResponse.java | 211 ++ .../GetCertificateChainStatusRequest.java | 178 ++ .../GetCertificateChainStatusResponse.java | 166 ++ .../messages/GetCertificateStatusRequest.java | 167 ++ .../GetCertificateStatusResponse.java | 272 +++ .../messages/GetChargingProfilesRequest.java | 284 +++ .../messages/GetChargingProfilesResponse.java | 219 ++ .../messages/GetCompositeScheduleRequest.java | 247 ++ .../GetCompositeScheduleResponse.java | 263 +++ .../model/messages/GetDERControlRequest.java | 287 +++ .../model/messages/GetDERControlResponse.java | 211 ++ .../messages/GetDisplayMessagesRequest.java | 304 +++ .../messages/GetDisplayMessagesResponse.java | 219 ++ .../GetInstalledCertificateIdsRequest.java | 175 ++ .../GetInstalledCertificateIdsResponse.java | 270 +++ .../messages/GetLocalListVersionRequest.java | 124 + .../messages/GetLocalListVersionResponse.java | 163 ++ .../v21/model/messages/GetLogRequest.java | 349 +++ .../v21/model/messages/GetLogResponse.java | 268 +++ .../messages/GetMonitoringReportRequest.java | 282 +++ .../messages/GetMonitoringReportResponse.java | 211 ++ .../GetPeriodicEventStreamRequest.java | 124 + .../GetPeriodicEventStreamResponse.java | 172 ++ .../v21/model/messages/GetReportRequest.java | 280 +++ .../v21/model/messages/GetReportResponse.java | 211 ++ .../v21/model/messages/GetTariffsRequest.java | 165 ++ .../model/messages/GetTariffsResponse.java | 266 +++ .../messages/GetTransactionStatusRequest.java | 172 ++ .../GetTransactionStatusResponse.java | 196 ++ .../model/messages/GetVariablesRequest.java | 170 ++ .../model/messages/GetVariablesResponse.java | 165 ++ .../v21/model/messages/HeartbeatRequest.java | 124 + .../v21/model/messages/HeartbeatResponse.java | 162 ++ .../messages/InstallCertificateRequest.java | 207 ++ .../messages/InstallCertificateResponse.java | 211 ++ .../LogStatusNotificationRequest.java | 261 +++ .../LogStatusNotificationResponse.java | 119 + .../model/messages/MeterValuesRequest.java | 221 ++ .../model/messages/MeterValuesResponse.java | 119 + .../NotifyAllowedEnergyTransferRequest.java | 210 ++ .../NotifyAllowedEnergyTransferResponse.java | 211 ++ .../messages/NotifyChargingLimitRequest.java | 300 +++ .../messages/NotifyChargingLimitResponse.java | 119 + .../NotifyCustomerInformationRequest.java | 332 +++ .../NotifyCustomerInformationResponse.java | 119 + .../model/messages/NotifyDERAlarmRequest.java | 328 +++ .../messages/NotifyDERAlarmResponse.java | 119 + .../messages/NotifyDERStartStopRequest.java | 307 +++ .../messages/NotifyDERStartStopResponse.java | 119 + .../NotifyDisplayMessagesRequest.java | 260 +++ .../NotifyDisplayMessagesResponse.java | 119 + .../NotifyEVChargingNeedsRequest.java | 303 +++ .../NotifyEVChargingNeedsResponse.java | 217 ++ .../NotifyEVChargingScheduleRequest.java | 377 +++ .../NotifyEVChargingScheduleResponse.java | 217 ++ .../model/messages/NotifyEventRequest.java | 290 +++ .../model/messages/NotifyEventResponse.java | 119 + .../NotifyMonitoringReportRequest.java | 339 +++ .../NotifyMonitoringReportResponse.java | 119 + .../messages/NotifyPeriodicEventStream.java | 283 +++ .../NotifyPriorityChargingRequest.java | 212 ++ .../NotifyPriorityChargingResponse.java | 119 + .../model/messages/NotifyReportRequest.java | 343 +++ .../model/messages/NotifyReportResponse.java | 119 + .../messages/NotifySettlementRequest.java | 614 +++++ .../messages/NotifySettlementResponse.java | 223 ++ .../NotifyWebPaymentStartedRequest.java | 212 ++ .../NotifyWebPaymentStartedResponse.java | 119 + .../OpenPeriodicEventStreamRequest.java | 167 ++ .../OpenPeriodicEventStreamResponse.java | 211 ++ .../messages/PublishFirmwareRequest.java | 365 +++ .../messages/PublishFirmwareResponse.java | 211 ++ ...lishFirmwareStatusNotificationRequest.java | 331 +++ ...ishFirmwareStatusNotificationResponse.java | 119 + .../PullDynamicScheduleUpdateRequest.java | 166 ++ .../PullDynamicScheduleUpdateResponse.java | 264 +++ .../ReportChargingProfilesRequest.java | 372 +++ .../ReportChargingProfilesResponse.java | 119 + .../messages/ReportDERControlRequest.java | 642 +++++ .../messages/ReportDERControlResponse.java | 119 + .../messages/RequestBatterySwapRequest.java | 213 ++ .../messages/RequestBatterySwapResponse.java | 211 ++ .../RequestStartTransactionRequest.java | 400 ++++ .../RequestStartTransactionResponse.java | 278 +++ .../RequestStopTransactionRequest.java | 168 ++ .../RequestStopTransactionResponse.java | 213 ++ .../ReservationStatusUpdateRequest.java | 210 ++ .../ReservationStatusUpdateResponse.java | 119 + .../v21/model/messages/ReserveNowRequest.java | 412 ++++ .../model/messages/ReserveNowResponse.java | 211 ++ .../ocpp/v21/model/messages/ResetRequest.java | 218 ++ .../v21/model/messages/ResetResponse.java | 211 ++ .../SecurityEventNotificationRequest.java | 257 ++ .../SecurityEventNotificationResponse.java | 119 + .../model/messages/SendLocalListRequest.java | 271 +++ .../model/messages/SendLocalListResponse.java | 219 ++ .../messages/SetChargingProfileRequest.java | 232 ++ .../messages/SetChargingProfileResponse.java | 222 ++ .../model/messages/SetDERControlRequest.java | 657 ++++++ .../model/messages/SetDERControlResponse.java | 266 +++ .../messages/SetDefaultTariffRequest.java | 221 ++ .../messages/SetDefaultTariffResponse.java | 211 ++ .../messages/SetDisplayMessageRequest.java | 166 ++ .../messages/SetDisplayMessageResponse.java | 211 ++ .../messages/SetMonitoringBaseRequest.java | 167 ++ .../messages/SetMonitoringBaseResponse.java | 211 ++ .../messages/SetMonitoringLevelRequest.java | 205 ++ .../messages/SetMonitoringLevelResponse.java | 211 ++ .../messages/SetNetworkProfileRequest.java | 216 ++ .../messages/SetNetworkProfileResponse.java | 211 ++ .../SetVariableMonitoringRequest.java | 170 ++ .../SetVariableMonitoringResponse.java | 165 ++ .../model/messages/SetVariablesRequest.java | 170 ++ .../model/messages/SetVariablesResponse.java | 165 ++ .../messages/SignCertificateRequest.java | 309 +++ .../messages/SignCertificateResponse.java | 211 ++ .../messages/StatusNotificationRequest.java | 292 +++ .../messages/StatusNotificationResponse.java | 119 + .../messages/TransactionEventRequest.java | 864 +++++++ .../messages/TransactionEventResponse.java | 455 ++++ .../model/messages/TriggerMessageRequest.java | 276 +++ .../messages/TriggerMessageResponse.java | 211 ++ .../messages/UnlockConnectorRequest.java | 206 ++ .../messages/UnlockConnectorResponse.java | 211 ++ .../messages/UnpublishFirmwareRequest.java | 167 ++ .../messages/UnpublishFirmwareResponse.java | 161 ++ .../UpdateDynamicScheduleRequest.java | 208 ++ .../UpdateDynamicScheduleResponse.java | 211 ++ .../model/messages/UpdateFirmwareRequest.java | 309 +++ .../messages/UpdateFirmwareResponse.java | 211 ++ .../messages/UsePriorityChargingRequest.java | 206 ++ .../messages/UsePriorityChargingResponse.java | 211 ++ .../messages/VatNumberValidationRequest.java | 214 ++ .../messages/VatNumberValidationResponse.java | 351 +++ .../v21/model/types/ACChargingParameters.java | 305 +++ .../chargetime/ocpp/v21/model/types/APN.java | 431 ++++ .../model/types/APNAuthenticationEnum.java | 33 + .../model/types/AbsolutePriceSchedule.java | 708 ++++++ .../ocpp/v21/model/types/AdditionalInfo.java | 212 ++ .../types/AdditionalSelectedServices.java | 193 ++ .../ocpp/v21/model/types/Address.java | 369 +++ .../ocpp/v21/model/types/AttributeEnum.java | 33 + .../v21/model/types/AuthorizationData.java | 221 ++ .../model/types/AuthorizationStatusEnum.java | 39 + .../types/AuthorizeCertificateStatusEnum.java | 43 + .../ocpp/v21/model/types/BatteryData.java | 356 +++ .../v21/model/types/BatterySwapEventEnum.java | 32 + .../ocpp/v21/model/types/BootReasonEnum.java | 38 + .../types/CancelReservationStatusEnum.java | 31 + .../model/types/CertificateActionEnum.java | 31 + .../v21/model/types/CertificateHashData.java | 299 +++ .../model/types/CertificateHashDataChain.java | 255 ++ .../types/CertificateSignedStatusEnum.java | 31 + .../types/CertificateSigningUseEnum.java | 35 + .../v21/model/types/CertificateStatus.java | 276 +++ .../model/types/CertificateStatusEnum.java | 33 + .../types/CertificateStatusRequestInfo.java | 237 ++ .../types/CertificateStatusSourceEnum.java | 31 + .../types/ChangeAvailabilityStatusEnum.java | 32 + .../ocpp/v21/model/types/ChargingLimit.java | 238 ++ .../ocpp/v21/model/types/ChargingNeeds.java | 662 ++++++ .../ocpp/v21/model/types/ChargingPeriod.java | 271 +++ .../ocpp/v21/model/types/ChargingProfile.java | 824 +++++++ .../model/types/ChargingProfileCriterion.java | 339 +++ .../model/types/ChargingProfileKindEnum.java | 33 + .../types/ChargingProfilePurposeEnum.java | 35 + .../types/ChargingProfileStatusEnum.java | 31 + .../v21/model/types/ChargingRateUnitEnum.java | 31 + .../v21/model/types/ChargingSchedule.java | 907 ++++++++ .../model/types/ChargingSchedulePeriod.java | 1120 +++++++++ .../model/types/ChargingScheduleUpdate.java | 662 ++++++ .../v21/model/types/ChargingStateEnum.java | 37 + .../ocpp/v21/model/types/ChargingStation.java | 348 +++ .../v21/model/types/ClearCacheStatusEnum.java | 31 + .../v21/model/types/ClearChargingProfile.java | 279 +++ .../types/ClearChargingProfileStatusEnum.java | 31 + .../model/types/ClearMessageStatusEnum.java | 32 + .../model/types/ClearMonitoringResult.java | 242 ++ .../types/ClearMonitoringStatusEnum.java | 32 + .../v21/model/types/ClearTariffsResult.java | 258 +++ .../ocpp/v21/model/types/Component.java | 264 +++ .../model/types/ComponentCriterionEnum.java | 33 + .../v21/model/types/ComponentVariable.java | 203 ++ .../v21/model/types/CompositeSchedule.java | 338 +++ .../v21/model/types/ConnectorStatusEnum.java | 34 + .../v21/model/types/ConstantStreamData.java | 235 ++ .../ocpp/v21/model/types/ConsumptionCost.java | 203 ++ .../ocpp/v21/model/types/ControlModeEnum.java | 39 + .../chargetime/ocpp/v21/model/types/Cost.java | 234 ++ .../ocpp/v21/model/types/CostDetails.java | 366 +++ .../ocpp/v21/model/types/CostDimension.java | 191 ++ .../v21/model/types/CostDimensionEnum.java | 36 + .../ocpp/v21/model/types/CostKindEnum.java | 32 + .../ocpp/v21/model/types/CustomData.java | 104 + .../types/CustomerInformationStatusEnum.java | 32 + .../v21/model/types/DCChargingParameters.java | 519 +++++ .../model/types/DERChargingParameters.java | 2062 +++++++++++++++++ .../ocpp/v21/model/types/DERControlEnum.java | 51 + .../v21/model/types/DERControlStatusEnum.java | 33 + .../ocpp/v21/model/types/DERCurve.java | 512 ++++ .../ocpp/v21/model/types/DERCurveGet.java | 322 +++ .../ocpp/v21/model/types/DERCurvePoints.java | 204 ++ .../ocpp/v21/model/types/DERUnitEnum.java | 35 + .../ocpp/v21/model/types/DataEnum.java | 40 + .../model/types/DataTransferStatusEnum.java | 33 + .../ocpp/v21/model/types/DayOfWeekEnum.java | 36 + .../types/DeleteCertificateStatusEnum.java | 32 + .../model/types/DisplayMessageStatusEnum.java | 36 + .../model/types/EVAbsolutePriceSchedule.java | 291 +++ .../types/EVAbsolutePriceScheduleEntry.java | 197 ++ .../ocpp/v21/model/types/EVEnergyOffer.java | 211 ++ .../ocpp/v21/model/types/EVPowerSchedule.java | 211 ++ .../v21/model/types/EVPowerScheduleEntry.java | 204 ++ .../ocpp/v21/model/types/EVPriceRule.java | 205 ++ .../chargetime/ocpp/v21/model/types/EVSE.java | 209 ++ .../model/types/EnergyTransferModeEnum.java | 40 + .../ocpp/v21/model/types/EnterService.java | 425 ++++ .../ocpp/v21/model/types/EnterServiceGet.java | 191 ++ .../ocpp/v21/model/types/EventData.java | 776 +++++++ .../model/types/EventNotificationEnum.java | 33 + .../v21/model/types/EventTriggerEnum.java | 32 + .../ocpp/v21/model/types/EvseKindEnum.java | 31 + .../ocpp/v21/model/types/Firmware.java | 328 +++ .../v21/model/types/FirmwareStatusEnum.java | 43 + .../ocpp/v21/model/types/FixedPF.java | 311 +++ .../ocpp/v21/model/types/FixedPFGet.java | 271 +++ .../ocpp/v21/model/types/FixedVar.java | 315 +++ .../ocpp/v21/model/types/FixedVarGet.java | 271 +++ .../ocpp/v21/model/types/FreqDroop.java | 435 ++++ .../ocpp/v21/model/types/FreqDroopGet.java | 278 +++ .../types/GenericDeviceModelStatusEnum.java | 33 + .../v21/model/types/GenericStatusEnum.java | 31 + .../model/types/GetCertificateIdUseEnum.java | 35 + .../model/types/GetCertificateStatusEnum.java | 31 + .../types/GetChargingProfileStatusEnum.java | 34 + .../types/GetDisplayMessagesStatusEnum.java | 34 + .../GetInstalledCertificateStatusEnum.java | 31 + .../ocpp/v21/model/types/GetVariableData.java | 227 ++ .../v21/model/types/GetVariableResult.java | 386 +++ .../model/types/GetVariableStatusEnum.java | 34 + .../ocpp/v21/model/types/Gradient.java | 232 ++ .../ocpp/v21/model/types/GradientGet.java | 191 ++ .../v21/model/types/GridEventFaultEnum.java | 40 + .../v21/model/types/HashAlgorithmEnum.java | 32 + .../ocpp/v21/model/types/Hysteresis.java | 286 +++ .../ocpp/v21/model/types/IdToken.java | 266 +++ .../ocpp/v21/model/types/IdTokenInfo.java | 524 +++++ .../types/InstallCertificateStatusEnum.java | 32 + .../types/InstallCertificateUseEnum.java | 34 + .../model/types/IslandingDetectionEnum.java | 44 + .../Iso15118EVCertificateStatusEnum.java | 31 + .../ocpp/v21/model/types/LimitAtSoC.java | 197 ++ .../v21/model/types/LimitMaxDischarge.java | 316 +++ .../v21/model/types/LimitMaxDischargeGet.java | 279 +++ .../ocpp/v21/model/types/LocationEnum.java | 35 + .../ocpp/v21/model/types/LogEnum.java | 32 + .../ocpp/v21/model/types/LogParameters.java | 230 ++ .../ocpp/v21/model/types/LogStatusEnum.java | 32 + .../ocpp/v21/model/types/MeasurandEnum.java | 140 ++ .../ocpp/v21/model/types/MessageContent.java | 247 ++ .../v21/model/types/MessageFormatEnum.java | 34 + .../ocpp/v21/model/types/MessageInfo.java | 526 +++++ .../v21/model/types/MessagePriorityEnum.java | 32 + .../v21/model/types/MessageStateEnum.java | 38 + .../v21/model/types/MessageTriggerEnum.java | 42 + .../ocpp/v21/model/types/MeterValue.java | 207 ++ .../model/types/MobilityNeedsModeEnum.java | 40 + .../ocpp/v21/model/types/Modem.java | 207 ++ .../ocpp/v21/model/types/MonitorEnum.java | 36 + .../v21/model/types/MonitoringBaseEnum.java | 32 + .../model/types/MonitoringCriterionEnum.java | 32 + .../ocpp/v21/model/types/MonitoringData.java | 236 ++ .../ocpp/v21/model/types/MutabilityEnum.java | 32 + .../model/types/NetworkConnectionProfile.java | 621 +++++ ...NotifyAllowedEnergyTransferStatusEnum.java | 31 + .../NotifyEVChargingNeedsStatusEnum.java | 36 + .../v21/model/types/OCPPInterfaceEnum.java | 41 + .../v21/model/types/OCPPTransportEnum.java | 34 + .../ocpp/v21/model/types/OCPPVersionEnum.java | 38 + .../ocpp/v21/model/types/OCSPRequestData.java | 340 +++ .../v21/model/types/OperationModeEnum.java | 37 + .../model/types/OperationalStatusEnum.java | 31 + .../ocpp/v21/model/types/OverstayRule.java | 290 +++ .../v21/model/types/OverstayRuleList.java | 245 ++ .../v21/model/types/PaymentStatusEnum.java | 33 + .../types/PeriodicEventStreamParams.java | 207 ++ .../ocpp/v21/model/types/PhaseEnum.java | 51 + .../model/types/PowerDuringCessationEnum.java | 34 + .../types/PreconditioningStatusEnum.java | 33 + .../ocpp/v21/model/types/Price.java | 233 ++ .../v21/model/types/PriceLevelSchedule.java | 346 +++ .../model/types/PriceLevelScheduleEntry.java | 207 ++ .../ocpp/v21/model/types/PriceRule.java | 395 ++++ .../ocpp/v21/model/types/PriceRuleStack.java | 203 ++ .../types/PriorityChargingStatusEnum.java | 32 + .../types/PublishFirmwareStatusEnum.java | 39 + .../ocpp/v21/model/types/RationalNumber.java | 191 ++ .../v21/model/types/ReactivePowerParams.java | 226 ++ .../v21/model/types/ReadingContextEnum.java | 45 + .../ocpp/v21/model/types/ReasonEnum.java | 57 + .../v21/model/types/RecurrencyKindEnum.java | 31 + .../model/types/RegistrationStatusEnum.java | 32 + .../v21/model/types/RelativeTimeInterval.java | 188 ++ .../ocpp/v21/model/types/ReportBaseEnum.java | 32 + .../ocpp/v21/model/types/ReportData.java | 294 +++ .../types/RequestStartStopStatusEnum.java | 31 + .../types/ReservationUpdateStatusEnum.java | 32 + .../v21/model/types/ReserveNowStatusEnum.java | 34 + .../ocpp/v21/model/types/ResetEnum.java | 32 + .../ocpp/v21/model/types/ResetStatusEnum.java | 32 + .../ocpp/v21/model/types/SalesTariff.java | 315 +++ .../v21/model/types/SalesTariffEntry.java | 268 +++ .../ocpp/v21/model/types/SampledValue.java | 406 ++++ .../model/types/SendLocalListStatusEnum.java | 35 + .../v21/model/types/SetMonitoringData.java | 511 ++++ .../v21/model/types/SetMonitoringResult.java | 465 ++++ .../model/types/SetMonitoringStatusEnum.java | 38 + .../types/SetNetworkProfileStatusEnum.java | 32 + .../ocpp/v21/model/types/SetVariableData.java | 276 +++ .../v21/model/types/SetVariableResult.java | 317 +++ .../model/types/SetVariableStatusEnum.java | 35 + .../v21/model/types/SignedMeterValue.java | 315 +++ .../ocpp/v21/model/types/StatusInfo.java | 209 ++ .../v21/model/types/StreamDataElement.java | 192 ++ .../ocpp/v21/model/types/Tariff.java | 698 ++++++ .../v21/model/types/TariffAssignment.java | 335 +++ .../model/types/TariffChangeStatusEnum.java | 35 + .../model/types/TariffClearStatusEnum.java | 32 + .../v21/model/types/TariffConditions.java | 955 ++++++++ .../model/types/TariffConditionsFixed.java | 501 ++++ .../ocpp/v21/model/types/TariffCostEnum.java | 32 + .../ocpp/v21/model/types/TariffEnergy.java | 207 ++ .../v21/model/types/TariffEnergyPrice.java | 227 ++ .../ocpp/v21/model/types/TariffFixed.java | 207 ++ .../v21/model/types/TariffFixedPrice.java | 213 ++ .../v21/model/types/TariffGetStatusEnum.java | 32 + .../ocpp/v21/model/types/TariffKindEnum.java | 31 + .../v21/model/types/TariffSetStatusEnum.java | 34 + .../ocpp/v21/model/types/TariffTime.java | 207 ++ .../ocpp/v21/model/types/TariffTimePrice.java | 227 ++ .../ocpp/v21/model/types/TaxRate.java | 250 ++ .../ocpp/v21/model/types/TaxRule.java | 450 ++++ .../ocpp/v21/model/types/TotalCost.java | 545 +++++ .../ocpp/v21/model/types/TotalPrice.java | 184 ++ .../ocpp/v21/model/types/TotalUsage.java | 283 +++ .../ocpp/v21/model/types/Transaction.java | 479 ++++ .../v21/model/types/TransactionEventEnum.java | 35 + .../v21/model/types/TransactionLimit.java | 264 +++ .../model/types/TriggerMessageStatusEnum.java | 32 + .../v21/model/types/TriggerReasonEnum.java | 58 + .../ocpp/v21/model/types/UnitOfMeasure.java | 211 ++ .../v21/model/types/UnlockStatusEnum.java | 33 + .../types/UnpublishFirmwareStatusEnum.java | 32 + .../ocpp/v21/model/types/UpdateEnum.java | 31 + .../model/types/UpdateFirmwareStatusEnum.java | 34 + .../v21/model/types/UploadLogStatusEnum.java | 37 + .../model/types/V2XChargingParameters.java | 1213 ++++++++++ .../v21/model/types/V2XFreqWattPoint.java | 191 ++ .../v21/model/types/V2XSignalWattPoint.java | 191 ++ .../chargetime/ocpp/v21/model/types/VPN.java | 359 +++ .../ocpp/v21/model/types/VPNEnum.java | 33 + .../ocpp/v21/model/types/Variable.java | 213 ++ .../v21/model/types/VariableAttribute.java | 313 +++ .../model/types/VariableCharacteristics.java | 453 ++++ .../v21/model/types/VariableMonitoring.java | 405 ++++ .../ocpp/v21/model/types/VoltageParams.java | 251 ++ pom.xml | 6 +- 574 files changed, 98450 insertions(+), 4 deletions(-) create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AFRRSignalFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AdjustPeriodicEventStreamFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AuthorizeFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/BatterySwapFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/BootNotificationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CancelReservationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CertificateSignedFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ChangeAvailabilityFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ChangeTransactionTariffFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearCacheFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearChargingProfileFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearDERControlFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearDisplayMessageFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearTariffsFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearVariableMonitoringFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearedChargingLimitFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClosePeriodicEventStreamFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CostUpdatedFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CustomerInformationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/DataTransferFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/DeleteCertificateFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/FirmwareStatusNotificationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/Get15118EVCertificateFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetBaseReportFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCertificateChainStatusFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCertificateStatusFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetChargingProfilesFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCompositeScheduleFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetDERControlFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetDisplayMessagesFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetInstalledCertificateIdsFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetLocalListVersionFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetLogFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetMonitoringReportFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetPeriodicEventStreamFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetReportFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetTariffsFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetTransactionStatusFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetVariablesFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/HeartbeatFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/InstallCertificateFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/LogStatusNotificationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/MeterValuesFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyAllowedEnergyTransferFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyChargingLimitFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyCustomerInformationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDERAlarmFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDERStartStopFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDisplayMessagesFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEVChargingNeedsFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEVChargingScheduleFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEventFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyMonitoringReportFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyPriorityChargingFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyReportFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifySettlementFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyWebPaymentStartedFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/OpenPeriodicEventStreamFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PublishFirmwareFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PublishFirmwareStatusNotificationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PullDynamicScheduleUpdateFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReportChargingProfilesFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReportDERControlFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestBatterySwapFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestStartTransactionFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestStopTransactionFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReservationStatusUpdateFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReserveNowFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ResetFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SecurityEventNotificationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SendLocalListFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetChargingProfileFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDERControlFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDefaultTariffFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDisplayMessageFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetMonitoringBaseFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetMonitoringLevelFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetNetworkProfileFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetVariableMonitoringFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetVariablesFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SignCertificateFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/StatusNotificationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/TransactionEventFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/TriggerMessageFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UnlockConnectorFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UnpublishFirmwareFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UpdateDynamicScheduleFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UpdateFirmwareFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UsePriorityChargingFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/VatNumberValidationFeature.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAuthorizationEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAuthorizationFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAvailabilityEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAvailabilityFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientBidirectionalPowerTransferEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientBidirectionalPowerTransferFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDERControlEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDERControlFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDataTransferEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDataTransferFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDisplayMessageEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDisplayMessageFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientFirmwareManagementEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientFirmwareManagementFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientISO15118CertificateManagementEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientISO15118CertificateManagementFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientLocalAuthorizationListManagementEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientLocalAuthorizationListManagementFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientMeterValuesFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientProvisioningEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientProvisioningFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientRemoteControlEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientRemoteControlFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientReservationEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientReservationFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSecurityEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSecurityFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSmartChargingEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSmartChargingFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTariffAndCostEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTariffAndCostFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTransactionsEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTransactionsFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAuthorizationEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAuthorizationFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAvailabilityEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAvailabilityFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerBidirectionalPowerTransferFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDERControlEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDERControlFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDataTransferEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDataTransferFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDisplayMessageEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDisplayMessageFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerFirmwareManagementEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerFirmwareManagementFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerISO15118CertificateManagementEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerISO15118CertificateManagementFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerLocalAuthorizationListManagementFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerMeterValuesEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerMeterValuesFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerProvisioningEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerProvisioningFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerRemoteControlFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerReservationEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerReservationFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSecurityEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSecurityFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSmartChargingEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSmartChargingFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTariffAndCostFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTransactionsEventHandler.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTransactionsFunction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AFRRSignalRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AFRRSignalResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AdjustPeriodicEventStreamRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AdjustPeriodicEventStreamResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AuthorizeRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AuthorizeResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BatterySwapRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BatterySwapResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BootNotificationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BootNotificationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CancelReservationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CancelReservationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CertificateSignedRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CertificateSignedResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeAvailabilityRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeAvailabilityResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeTransactionTariffRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeTransactionTariffResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearCacheRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearCacheResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearChargingProfileRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearChargingProfileResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDERControlRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDERControlResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDisplayMessageRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDisplayMessageResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearTariffsRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearTariffsResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearVariableMonitoringRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearVariableMonitoringResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearedChargingLimitRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearedChargingLimitResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClosePeriodicEventStreamRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClosePeriodicEventStreamResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CostUpdatedRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CostUpdatedResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CustomerInformationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CustomerInformationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DataTransferRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DataTransferResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DeleteCertificateRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DeleteCertificateResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/FirmwareStatusNotificationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/FirmwareStatusNotificationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/Get15118EVCertificateRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/Get15118EVCertificateResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetBaseReportRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetBaseReportResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateChainStatusRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateChainStatusResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateStatusRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateStatusResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetChargingProfilesRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetChargingProfilesResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCompositeScheduleRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCompositeScheduleResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDERControlRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDERControlResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDisplayMessagesRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDisplayMessagesResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetInstalledCertificateIdsRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetInstalledCertificateIdsResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLocalListVersionRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLocalListVersionResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLogRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLogResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetMonitoringReportRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetMonitoringReportResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetPeriodicEventStreamRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetPeriodicEventStreamResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetReportRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetReportResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTariffsRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTariffsResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTransactionStatusRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTransactionStatusResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetVariablesRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetVariablesResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/HeartbeatRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/HeartbeatResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/InstallCertificateRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/InstallCertificateResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/LogStatusNotificationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/LogStatusNotificationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/MeterValuesRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/MeterValuesResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyAllowedEnergyTransferRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyAllowedEnergyTransferResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyChargingLimitRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyChargingLimitResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyCustomerInformationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyCustomerInformationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERAlarmRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERAlarmResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERStartStopRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERStartStopResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDisplayMessagesRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDisplayMessagesResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingNeedsRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingNeedsResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingScheduleRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingScheduleResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEventRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEventResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyMonitoringReportRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyMonitoringReportResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPeriodicEventStream.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPriorityChargingRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPriorityChargingResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyReportRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyReportResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifySettlementRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifySettlementResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyWebPaymentStartedRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyWebPaymentStartedResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/OpenPeriodicEventStreamRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/OpenPeriodicEventStreamResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareStatusNotificationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareStatusNotificationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PullDynamicScheduleUpdateRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PullDynamicScheduleUpdateResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportChargingProfilesRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportChargingProfilesResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportDERControlRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportDERControlResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestBatterySwapRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestBatterySwapResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStartTransactionRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStartTransactionResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStopTransactionRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStopTransactionResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReservationStatusUpdateRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReservationStatusUpdateResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReserveNowRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReserveNowResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ResetRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ResetResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SecurityEventNotificationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SecurityEventNotificationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SendLocalListRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SendLocalListResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetChargingProfileRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetChargingProfileResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDERControlRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDERControlResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDefaultTariffRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDefaultTariffResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDisplayMessageRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDisplayMessageResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringBaseRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringBaseResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringLevelRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringLevelResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetNetworkProfileRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetNetworkProfileResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariableMonitoringRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariableMonitoringResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariablesRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariablesResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SignCertificateRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SignCertificateResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/StatusNotificationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/StatusNotificationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TransactionEventRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TransactionEventResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TriggerMessageRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TriggerMessageResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnlockConnectorRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnlockConnectorResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnpublishFirmwareRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnpublishFirmwareResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateDynamicScheduleRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateDynamicScheduleResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateFirmwareRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateFirmwareResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UsePriorityChargingRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UsePriorityChargingResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/VatNumberValidationRequest.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/VatNumberValidationResponse.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ACChargingParameters.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/APN.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/APNAuthenticationEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AbsolutePriceSchedule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AdditionalInfo.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AdditionalSelectedServices.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Address.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AttributeEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizationData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizationStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizeCertificateStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BatteryData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BatterySwapEventEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BootReasonEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CancelReservationStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateActionEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateHashData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateHashDataChain.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateSignedStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateSigningUseEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatus.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusRequestInfo.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusSourceEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChangeAvailabilityStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingLimit.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingNeeds.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingPeriod.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfile.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileCriterion.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileKindEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfilePurposeEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingRateUnitEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingSchedule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingSchedulePeriod.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingScheduleUpdate.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingStateEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingStation.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearCacheStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearChargingProfile.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearChargingProfileStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMessageStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMonitoringResult.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMonitoringStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearTariffsResult.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Component.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ComponentCriterionEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ComponentVariable.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CompositeSchedule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConnectorStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConstantStreamData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConsumptionCost.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ControlModeEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Cost.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDetails.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDimension.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDimensionEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostKindEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CustomData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CustomerInformationStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DCChargingParameters.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERChargingParameters.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERControlEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERControlStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurve.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurveGet.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurvePoints.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERUnitEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DataEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DataTransferStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DayOfWeekEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DeleteCertificateStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DisplayMessageStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVAbsolutePriceSchedule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVAbsolutePriceScheduleEntry.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVEnergyOffer.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPowerSchedule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPowerScheduleEntry.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPriceRule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVSE.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnergyTransferModeEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnterService.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnterServiceGet.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventNotificationEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventTriggerEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EvseKindEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Firmware.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FirmwareStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedPF.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedPFGet.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedVar.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedVarGet.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FreqDroop.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FreqDroopGet.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GenericDeviceModelStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GenericStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetCertificateIdUseEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetCertificateStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetChargingProfileStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetDisplayMessagesStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetInstalledCertificateStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableResult.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Gradient.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GradientGet.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GridEventFaultEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/HashAlgorithmEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Hysteresis.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IdToken.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IdTokenInfo.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/InstallCertificateStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/InstallCertificateUseEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IslandingDetectionEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Iso15118EVCertificateStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitAtSoC.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitMaxDischarge.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitMaxDischargeGet.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LocationEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogParameters.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MeasurandEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageContent.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageFormatEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageInfo.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessagePriorityEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageStateEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageTriggerEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MeterValue.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MobilityNeedsModeEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Modem.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitorEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringBaseEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringCriterionEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MutabilityEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NetworkConnectionProfile.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NotifyAllowedEnergyTransferStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NotifyEVChargingNeedsStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPInterfaceEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPTransportEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPVersionEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCSPRequestData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OperationModeEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OperationalStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OverstayRule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OverstayRuleList.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PaymentStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PeriodicEventStreamParams.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PhaseEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PowerDuringCessationEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PreconditioningStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Price.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceLevelSchedule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceLevelScheduleEntry.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceRule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceRuleStack.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriorityChargingStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PublishFirmwareStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RationalNumber.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReactivePowerParams.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReadingContextEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReasonEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RecurrencyKindEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RegistrationStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RelativeTimeInterval.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReportBaseEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReportData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RequestStartStopStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReservationUpdateStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReserveNowStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ResetEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ResetStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SalesTariff.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SalesTariffEntry.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SampledValue.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SendLocalListStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringResult.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetNetworkProfileStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableData.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableResult.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SignedMeterValue.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/StatusInfo.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/StreamDataElement.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Tariff.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffAssignment.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffChangeStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffClearStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffConditions.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffConditionsFixed.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffCostEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffEnergy.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffEnergyPrice.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffFixed.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffFixedPrice.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffGetStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffKindEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffSetStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffTime.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffTimePrice.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TaxRate.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TaxRule.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalCost.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalPrice.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalUsage.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Transaction.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TransactionEventEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TransactionLimit.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TriggerMessageStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TriggerReasonEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnitOfMeasure.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnlockStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnpublishFirmwareStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UpdateEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UpdateFirmwareStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UploadLogStatusEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XChargingParameters.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XFreqWattPoint.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XSignalWattPoint.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VPN.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VPNEnum.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Variable.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableAttribute.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableCharacteristics.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableMonitoring.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VoltageParams.java diff --git a/build.gradle b/build.gradle index 358bb8d6..972f5565 100644 --- a/build.gradle +++ b/build.gradle @@ -32,6 +32,10 @@ subprojects { sourceCompatibility = '1.8' + tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' + } + publishing { publications { maven(MavenPublication) { diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/ProtocolVersion.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/ProtocolVersion.java index 5ec693c6..792bd32b 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/ProtocolVersion.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/ProtocolVersion.java @@ -32,7 +32,8 @@ /** enum of protocol versions along with their registered WebSocket sub-protocol names */ public enum ProtocolVersion { OCPP1_6("ocpp1.6"), - OCPP2_0_1("ocpp2.0.1"); + OCPP2_0_1("ocpp2.0.1"), + OCPP2_1("ocpp2.1"); private static final Map MAP = new HashMap<>(); diff --git a/ocpp-v1_6-test/pom.xml b/ocpp-v1_6-test/pom.xml index 982ce3b0..64cf9d53 100644 --- a/ocpp-v1_6-test/pom.xml +++ b/ocpp-v1_6-test/pom.xml @@ -54,7 +54,7 @@ 4.13.2 test - + org.spockframework spock-core 2.3-groovy-4.0 @@ -63,7 +63,7 @@ org.apache.groovy groovy - 4.0.24 + 4.0.24 test diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AFRRSignalFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AFRRSignalFeature.java new file mode 100644 index 00000000..032395f9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AFRRSignalFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.AFRRSignalRequest; +import eu.chargetime.ocpp.v21.model.messages.AFRRSignalResponse; + +public class AFRRSignalFeature extends FunctionFeature { + + public AFRRSignalFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return AFRRSignalRequest.class; + } + + @Override + public Class getConfirmationType() { + return AFRRSignalResponse.class; + } + + @Override + public String getAction() { + return "AFRRSignal"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AdjustPeriodicEventStreamFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AdjustPeriodicEventStreamFeature.java new file mode 100644 index 00000000..0b2f840b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AdjustPeriodicEventStreamFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.AdjustPeriodicEventStreamRequest; +import eu.chargetime.ocpp.v21.model.messages.AdjustPeriodicEventStreamResponse; + +public class AdjustPeriodicEventStreamFeature extends FunctionFeature { + + public AdjustPeriodicEventStreamFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return AdjustPeriodicEventStreamRequest.class; + } + + @Override + public Class getConfirmationType() { + return AdjustPeriodicEventStreamResponse.class; + } + + @Override + public String getAction() { + return "AdjustPeriodicEventStream"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AuthorizeFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AuthorizeFeature.java new file mode 100644 index 00000000..55310138 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/AuthorizeFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.AuthorizeRequest; +import eu.chargetime.ocpp.v21.model.messages.AuthorizeResponse; + +public class AuthorizeFeature extends FunctionFeature { + + public AuthorizeFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return AuthorizeRequest.class; + } + + @Override + public Class getConfirmationType() { + return AuthorizeResponse.class; + } + + @Override + public String getAction() { + return "Authorize"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/BatterySwapFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/BatterySwapFeature.java new file mode 100644 index 00000000..10e03ce3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/BatterySwapFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.BatterySwapRequest; +import eu.chargetime.ocpp.v21.model.messages.BatterySwapResponse; + +public class BatterySwapFeature extends FunctionFeature { + + public BatterySwapFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return BatterySwapRequest.class; + } + + @Override + public Class getConfirmationType() { + return BatterySwapResponse.class; + } + + @Override + public String getAction() { + return "BatterySwap"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/BootNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/BootNotificationFeature.java new file mode 100644 index 00000000..e1372ca1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/BootNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.BootNotificationRequest; +import eu.chargetime.ocpp.v21.model.messages.BootNotificationResponse; + +public class BootNotificationFeature extends FunctionFeature { + + public BootNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return BootNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return BootNotificationResponse.class; + } + + @Override + public String getAction() { + return "BootNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CancelReservationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CancelReservationFeature.java new file mode 100644 index 00000000..f28ca676 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CancelReservationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.CancelReservationRequest; +import eu.chargetime.ocpp.v21.model.messages.CancelReservationResponse; + +public class CancelReservationFeature extends FunctionFeature { + + public CancelReservationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return CancelReservationRequest.class; + } + + @Override + public Class getConfirmationType() { + return CancelReservationResponse.class; + } + + @Override + public String getAction() { + return "CancelReservation"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CertificateSignedFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CertificateSignedFeature.java new file mode 100644 index 00000000..8c57c06d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CertificateSignedFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.CertificateSignedRequest; +import eu.chargetime.ocpp.v21.model.messages.CertificateSignedResponse; + +public class CertificateSignedFeature extends FunctionFeature { + + public CertificateSignedFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return CertificateSignedRequest.class; + } + + @Override + public Class getConfirmationType() { + return CertificateSignedResponse.class; + } + + @Override + public String getAction() { + return "CertificateSigned"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ChangeAvailabilityFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ChangeAvailabilityFeature.java new file mode 100644 index 00000000..f65d299a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ChangeAvailabilityFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ChangeAvailabilityRequest; +import eu.chargetime.ocpp.v21.model.messages.ChangeAvailabilityResponse; + +public class ChangeAvailabilityFeature extends FunctionFeature { + + public ChangeAvailabilityFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ChangeAvailabilityRequest.class; + } + + @Override + public Class getConfirmationType() { + return ChangeAvailabilityResponse.class; + } + + @Override + public String getAction() { + return "ChangeAvailability"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ChangeTransactionTariffFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ChangeTransactionTariffFeature.java new file mode 100644 index 00000000..a0f4999d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ChangeTransactionTariffFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ChangeTransactionTariffRequest; +import eu.chargetime.ocpp.v21.model.messages.ChangeTransactionTariffResponse; + +public class ChangeTransactionTariffFeature extends FunctionFeature { + + public ChangeTransactionTariffFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ChangeTransactionTariffRequest.class; + } + + @Override + public Class getConfirmationType() { + return ChangeTransactionTariffResponse.class; + } + + @Override + public String getAction() { + return "ChangeTransactionTariff"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearCacheFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearCacheFeature.java new file mode 100644 index 00000000..e728445c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearCacheFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ClearCacheRequest; +import eu.chargetime.ocpp.v21.model.messages.ClearCacheResponse; + +public class ClearCacheFeature extends FunctionFeature { + + public ClearCacheFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearCacheRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearCacheResponse.class; + } + + @Override + public String getAction() { + return "ClearCache"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearChargingProfileFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearChargingProfileFeature.java new file mode 100644 index 00000000..332346fb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearChargingProfileFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ClearChargingProfileRequest; +import eu.chargetime.ocpp.v21.model.messages.ClearChargingProfileResponse; + +public class ClearChargingProfileFeature extends FunctionFeature { + + public ClearChargingProfileFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearChargingProfileRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearChargingProfileResponse.class; + } + + @Override + public String getAction() { + return "ClearChargingProfile"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearDERControlFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearDERControlFeature.java new file mode 100644 index 00000000..63bc4aa5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearDERControlFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ClearDERControlRequest; +import eu.chargetime.ocpp.v21.model.messages.ClearDERControlResponse; + +public class ClearDERControlFeature extends FunctionFeature { + + public ClearDERControlFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearDERControlRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearDERControlResponse.class; + } + + @Override + public String getAction() { + return "ClearDERControl"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearDisplayMessageFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearDisplayMessageFeature.java new file mode 100644 index 00000000..887906da --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearDisplayMessageFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ClearDisplayMessageRequest; +import eu.chargetime.ocpp.v21.model.messages.ClearDisplayMessageResponse; + +public class ClearDisplayMessageFeature extends FunctionFeature { + + public ClearDisplayMessageFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearDisplayMessageRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearDisplayMessageResponse.class; + } + + @Override + public String getAction() { + return "ClearDisplayMessage"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearTariffsFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearTariffsFeature.java new file mode 100644 index 00000000..86bbe191 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearTariffsFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ClearTariffsRequest; +import eu.chargetime.ocpp.v21.model.messages.ClearTariffsResponse; + +public class ClearTariffsFeature extends FunctionFeature { + + public ClearTariffsFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearTariffsRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearTariffsResponse.class; + } + + @Override + public String getAction() { + return "ClearTariffs"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearVariableMonitoringFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearVariableMonitoringFeature.java new file mode 100644 index 00000000..2830b207 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearVariableMonitoringFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ClearVariableMonitoringRequest; +import eu.chargetime.ocpp.v21.model.messages.ClearVariableMonitoringResponse; + +public class ClearVariableMonitoringFeature extends FunctionFeature { + + public ClearVariableMonitoringFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearVariableMonitoringRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearVariableMonitoringResponse.class; + } + + @Override + public String getAction() { + return "ClearVariableMonitoring"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearedChargingLimitFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearedChargingLimitFeature.java new file mode 100644 index 00000000..bfe49854 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClearedChargingLimitFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ClearedChargingLimitRequest; +import eu.chargetime.ocpp.v21.model.messages.ClearedChargingLimitResponse; + +public class ClearedChargingLimitFeature extends FunctionFeature { + + public ClearedChargingLimitFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearedChargingLimitRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearedChargingLimitResponse.class; + } + + @Override + public String getAction() { + return "ClearedChargingLimit"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClosePeriodicEventStreamFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClosePeriodicEventStreamFeature.java new file mode 100644 index 00000000..772a1dc6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ClosePeriodicEventStreamFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ClosePeriodicEventStreamRequest; +import eu.chargetime.ocpp.v21.model.messages.ClosePeriodicEventStreamResponse; + +public class ClosePeriodicEventStreamFeature extends FunctionFeature { + + public ClosePeriodicEventStreamFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClosePeriodicEventStreamRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClosePeriodicEventStreamResponse.class; + } + + @Override + public String getAction() { + return "ClosePeriodicEventStream"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CostUpdatedFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CostUpdatedFeature.java new file mode 100644 index 00000000..f8fad40e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CostUpdatedFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.CostUpdatedRequest; +import eu.chargetime.ocpp.v21.model.messages.CostUpdatedResponse; + +public class CostUpdatedFeature extends FunctionFeature { + + public CostUpdatedFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return CostUpdatedRequest.class; + } + + @Override + public Class getConfirmationType() { + return CostUpdatedResponse.class; + } + + @Override + public String getAction() { + return "CostUpdated"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CustomerInformationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CustomerInformationFeature.java new file mode 100644 index 00000000..187c57b2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/CustomerInformationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.CustomerInformationRequest; +import eu.chargetime.ocpp.v21.model.messages.CustomerInformationResponse; + +public class CustomerInformationFeature extends FunctionFeature { + + public CustomerInformationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return CustomerInformationRequest.class; + } + + @Override + public Class getConfirmationType() { + return CustomerInformationResponse.class; + } + + @Override + public String getAction() { + return "CustomerInformation"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/DataTransferFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/DataTransferFeature.java new file mode 100644 index 00000000..f8e73867 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/DataTransferFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.DataTransferRequest; +import eu.chargetime.ocpp.v21.model.messages.DataTransferResponse; + +public class DataTransferFeature extends FunctionFeature { + + public DataTransferFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return DataTransferRequest.class; + } + + @Override + public Class getConfirmationType() { + return DataTransferResponse.class; + } + + @Override + public String getAction() { + return "DataTransfer"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/DeleteCertificateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/DeleteCertificateFeature.java new file mode 100644 index 00000000..d7580fad --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/DeleteCertificateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.DeleteCertificateRequest; +import eu.chargetime.ocpp.v21.model.messages.DeleteCertificateResponse; + +public class DeleteCertificateFeature extends FunctionFeature { + + public DeleteCertificateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return DeleteCertificateRequest.class; + } + + @Override + public Class getConfirmationType() { + return DeleteCertificateResponse.class; + } + + @Override + public String getAction() { + return "DeleteCertificate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/FirmwareStatusNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/FirmwareStatusNotificationFeature.java new file mode 100644 index 00000000..e644a94e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/FirmwareStatusNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.FirmwareStatusNotificationRequest; +import eu.chargetime.ocpp.v21.model.messages.FirmwareStatusNotificationResponse; + +public class FirmwareStatusNotificationFeature extends FunctionFeature { + + public FirmwareStatusNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return FirmwareStatusNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return FirmwareStatusNotificationResponse.class; + } + + @Override + public String getAction() { + return "FirmwareStatusNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/Get15118EVCertificateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/Get15118EVCertificateFeature.java new file mode 100644 index 00000000..6062c2e5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/Get15118EVCertificateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.Get15118EVCertificateRequest; +import eu.chargetime.ocpp.v21.model.messages.Get15118EVCertificateResponse; + +public class Get15118EVCertificateFeature extends FunctionFeature { + + public Get15118EVCertificateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return Get15118EVCertificateRequest.class; + } + + @Override + public Class getConfirmationType() { + return Get15118EVCertificateResponse.class; + } + + @Override + public String getAction() { + return "Get15118EVCertificate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetBaseReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetBaseReportFeature.java new file mode 100644 index 00000000..a51357e4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetBaseReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetBaseReportRequest; +import eu.chargetime.ocpp.v21.model.messages.GetBaseReportResponse; + +public class GetBaseReportFeature extends FunctionFeature { + + public GetBaseReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetBaseReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetBaseReportResponse.class; + } + + @Override + public String getAction() { + return "GetBaseReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCertificateChainStatusFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCertificateChainStatusFeature.java new file mode 100644 index 00000000..3bcbd4db --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCertificateChainStatusFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetCertificateChainStatusRequest; +import eu.chargetime.ocpp.v21.model.messages.GetCertificateChainStatusResponse; + +public class GetCertificateChainStatusFeature extends FunctionFeature { + + public GetCertificateChainStatusFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetCertificateChainStatusRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetCertificateChainStatusResponse.class; + } + + @Override + public String getAction() { + return "GetCertificateChainStatus"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCertificateStatusFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCertificateStatusFeature.java new file mode 100644 index 00000000..09dd48c5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCertificateStatusFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetCertificateStatusRequest; +import eu.chargetime.ocpp.v21.model.messages.GetCertificateStatusResponse; + +public class GetCertificateStatusFeature extends FunctionFeature { + + public GetCertificateStatusFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetCertificateStatusRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetCertificateStatusResponse.class; + } + + @Override + public String getAction() { + return "GetCertificateStatus"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetChargingProfilesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetChargingProfilesFeature.java new file mode 100644 index 00000000..880beb29 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetChargingProfilesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetChargingProfilesRequest; +import eu.chargetime.ocpp.v21.model.messages.GetChargingProfilesResponse; + +public class GetChargingProfilesFeature extends FunctionFeature { + + public GetChargingProfilesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetChargingProfilesRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetChargingProfilesResponse.class; + } + + @Override + public String getAction() { + return "GetChargingProfiles"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCompositeScheduleFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCompositeScheduleFeature.java new file mode 100644 index 00000000..d396ab98 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetCompositeScheduleFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetCompositeScheduleRequest; +import eu.chargetime.ocpp.v21.model.messages.GetCompositeScheduleResponse; + +public class GetCompositeScheduleFeature extends FunctionFeature { + + public GetCompositeScheduleFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetCompositeScheduleRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetCompositeScheduleResponse.class; + } + + @Override + public String getAction() { + return "GetCompositeSchedule"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetDERControlFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetDERControlFeature.java new file mode 100644 index 00000000..6f523bb8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetDERControlFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetDERControlRequest; +import eu.chargetime.ocpp.v21.model.messages.GetDERControlResponse; + +public class GetDERControlFeature extends FunctionFeature { + + public GetDERControlFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetDERControlRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetDERControlResponse.class; + } + + @Override + public String getAction() { + return "GetDERControl"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetDisplayMessagesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetDisplayMessagesFeature.java new file mode 100644 index 00000000..c38177a1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetDisplayMessagesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetDisplayMessagesRequest; +import eu.chargetime.ocpp.v21.model.messages.GetDisplayMessagesResponse; + +public class GetDisplayMessagesFeature extends FunctionFeature { + + public GetDisplayMessagesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetDisplayMessagesRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetDisplayMessagesResponse.class; + } + + @Override + public String getAction() { + return "GetDisplayMessages"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetInstalledCertificateIdsFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetInstalledCertificateIdsFeature.java new file mode 100644 index 00000000..4e2f9261 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetInstalledCertificateIdsFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetInstalledCertificateIdsRequest; +import eu.chargetime.ocpp.v21.model.messages.GetInstalledCertificateIdsResponse; + +public class GetInstalledCertificateIdsFeature extends FunctionFeature { + + public GetInstalledCertificateIdsFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetInstalledCertificateIdsRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetInstalledCertificateIdsResponse.class; + } + + @Override + public String getAction() { + return "GetInstalledCertificateIds"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetLocalListVersionFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetLocalListVersionFeature.java new file mode 100644 index 00000000..01edb693 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetLocalListVersionFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetLocalListVersionRequest; +import eu.chargetime.ocpp.v21.model.messages.GetLocalListVersionResponse; + +public class GetLocalListVersionFeature extends FunctionFeature { + + public GetLocalListVersionFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetLocalListVersionRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetLocalListVersionResponse.class; + } + + @Override + public String getAction() { + return "GetLocalListVersion"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetLogFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetLogFeature.java new file mode 100644 index 00000000..b6b9c1d5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetLogFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetLogRequest; +import eu.chargetime.ocpp.v21.model.messages.GetLogResponse; + +public class GetLogFeature extends FunctionFeature { + + public GetLogFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetLogRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetLogResponse.class; + } + + @Override + public String getAction() { + return "GetLog"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetMonitoringReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetMonitoringReportFeature.java new file mode 100644 index 00000000..b3e3d0ce --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetMonitoringReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetMonitoringReportRequest; +import eu.chargetime.ocpp.v21.model.messages.GetMonitoringReportResponse; + +public class GetMonitoringReportFeature extends FunctionFeature { + + public GetMonitoringReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetMonitoringReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetMonitoringReportResponse.class; + } + + @Override + public String getAction() { + return "GetMonitoringReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetPeriodicEventStreamFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetPeriodicEventStreamFeature.java new file mode 100644 index 00000000..bf750095 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetPeriodicEventStreamFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetPeriodicEventStreamRequest; +import eu.chargetime.ocpp.v21.model.messages.GetPeriodicEventStreamResponse; + +public class GetPeriodicEventStreamFeature extends FunctionFeature { + + public GetPeriodicEventStreamFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetPeriodicEventStreamRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetPeriodicEventStreamResponse.class; + } + + @Override + public String getAction() { + return "GetPeriodicEventStream"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetReportFeature.java new file mode 100644 index 00000000..b0dc5e30 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetReportRequest; +import eu.chargetime.ocpp.v21.model.messages.GetReportResponse; + +public class GetReportFeature extends FunctionFeature { + + public GetReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetReportResponse.class; + } + + @Override + public String getAction() { + return "GetReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetTariffsFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetTariffsFeature.java new file mode 100644 index 00000000..d0743f79 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetTariffsFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetTariffsRequest; +import eu.chargetime.ocpp.v21.model.messages.GetTariffsResponse; + +public class GetTariffsFeature extends FunctionFeature { + + public GetTariffsFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetTariffsRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetTariffsResponse.class; + } + + @Override + public String getAction() { + return "GetTariffs"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetTransactionStatusFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetTransactionStatusFeature.java new file mode 100644 index 00000000..977ab797 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetTransactionStatusFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetTransactionStatusRequest; +import eu.chargetime.ocpp.v21.model.messages.GetTransactionStatusResponse; + +public class GetTransactionStatusFeature extends FunctionFeature { + + public GetTransactionStatusFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetTransactionStatusRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetTransactionStatusResponse.class; + } + + @Override + public String getAction() { + return "GetTransactionStatus"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetVariablesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetVariablesFeature.java new file mode 100644 index 00000000..12eaf376 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/GetVariablesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.GetVariablesRequest; +import eu.chargetime.ocpp.v21.model.messages.GetVariablesResponse; + +public class GetVariablesFeature extends FunctionFeature { + + public GetVariablesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetVariablesRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetVariablesResponse.class; + } + + @Override + public String getAction() { + return "GetVariables"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/HeartbeatFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/HeartbeatFeature.java new file mode 100644 index 00000000..70df3718 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/HeartbeatFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.HeartbeatRequest; +import eu.chargetime.ocpp.v21.model.messages.HeartbeatResponse; + +public class HeartbeatFeature extends FunctionFeature { + + public HeartbeatFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return HeartbeatRequest.class; + } + + @Override + public Class getConfirmationType() { + return HeartbeatResponse.class; + } + + @Override + public String getAction() { + return "Heartbeat"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/InstallCertificateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/InstallCertificateFeature.java new file mode 100644 index 00000000..7e39ed2d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/InstallCertificateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.InstallCertificateRequest; +import eu.chargetime.ocpp.v21.model.messages.InstallCertificateResponse; + +public class InstallCertificateFeature extends FunctionFeature { + + public InstallCertificateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return InstallCertificateRequest.class; + } + + @Override + public Class getConfirmationType() { + return InstallCertificateResponse.class; + } + + @Override + public String getAction() { + return "InstallCertificate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/LogStatusNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/LogStatusNotificationFeature.java new file mode 100644 index 00000000..b9ba89e8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/LogStatusNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.LogStatusNotificationRequest; +import eu.chargetime.ocpp.v21.model.messages.LogStatusNotificationResponse; + +public class LogStatusNotificationFeature extends FunctionFeature { + + public LogStatusNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return LogStatusNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return LogStatusNotificationResponse.class; + } + + @Override + public String getAction() { + return "LogStatusNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/MeterValuesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/MeterValuesFeature.java new file mode 100644 index 00000000..4f01f471 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/MeterValuesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.MeterValuesRequest; +import eu.chargetime.ocpp.v21.model.messages.MeterValuesResponse; + +public class MeterValuesFeature extends FunctionFeature { + + public MeterValuesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return MeterValuesRequest.class; + } + + @Override + public Class getConfirmationType() { + return MeterValuesResponse.class; + } + + @Override + public String getAction() { + return "MeterValues"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyAllowedEnergyTransferFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyAllowedEnergyTransferFeature.java new file mode 100644 index 00000000..e9bfa472 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyAllowedEnergyTransferFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyAllowedEnergyTransferRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyAllowedEnergyTransferResponse; + +public class NotifyAllowedEnergyTransferFeature extends FunctionFeature { + + public NotifyAllowedEnergyTransferFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyAllowedEnergyTransferRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyAllowedEnergyTransferResponse.class; + } + + @Override + public String getAction() { + return "NotifyAllowedEnergyTransfer"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyChargingLimitFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyChargingLimitFeature.java new file mode 100644 index 00000000..159d4bfb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyChargingLimitFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyChargingLimitRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyChargingLimitResponse; + +public class NotifyChargingLimitFeature extends FunctionFeature { + + public NotifyChargingLimitFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyChargingLimitRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyChargingLimitResponse.class; + } + + @Override + public String getAction() { + return "NotifyChargingLimit"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyCustomerInformationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyCustomerInformationFeature.java new file mode 100644 index 00000000..77b00da8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyCustomerInformationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyCustomerInformationRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyCustomerInformationResponse; + +public class NotifyCustomerInformationFeature extends FunctionFeature { + + public NotifyCustomerInformationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyCustomerInformationRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyCustomerInformationResponse.class; + } + + @Override + public String getAction() { + return "NotifyCustomerInformation"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDERAlarmFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDERAlarmFeature.java new file mode 100644 index 00000000..678de3bd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDERAlarmFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyDERAlarmRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyDERAlarmResponse; + +public class NotifyDERAlarmFeature extends FunctionFeature { + + public NotifyDERAlarmFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyDERAlarmRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyDERAlarmResponse.class; + } + + @Override + public String getAction() { + return "NotifyDERAlarm"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDERStartStopFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDERStartStopFeature.java new file mode 100644 index 00000000..864692a6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDERStartStopFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyDERStartStopRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyDERStartStopResponse; + +public class NotifyDERStartStopFeature extends FunctionFeature { + + public NotifyDERStartStopFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyDERStartStopRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyDERStartStopResponse.class; + } + + @Override + public String getAction() { + return "NotifyDERStartStop"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDisplayMessagesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDisplayMessagesFeature.java new file mode 100644 index 00000000..72637beb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyDisplayMessagesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyDisplayMessagesRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyDisplayMessagesResponse; + +public class NotifyDisplayMessagesFeature extends FunctionFeature { + + public NotifyDisplayMessagesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyDisplayMessagesRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyDisplayMessagesResponse.class; + } + + @Override + public String getAction() { + return "NotifyDisplayMessages"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEVChargingNeedsFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEVChargingNeedsFeature.java new file mode 100644 index 00000000..fd74c782 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEVChargingNeedsFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyEVChargingNeedsRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyEVChargingNeedsResponse; + +public class NotifyEVChargingNeedsFeature extends FunctionFeature { + + public NotifyEVChargingNeedsFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyEVChargingNeedsRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyEVChargingNeedsResponse.class; + } + + @Override + public String getAction() { + return "NotifyEVChargingNeeds"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEVChargingScheduleFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEVChargingScheduleFeature.java new file mode 100644 index 00000000..cca1f954 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEVChargingScheduleFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyEVChargingScheduleRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyEVChargingScheduleResponse; + +public class NotifyEVChargingScheduleFeature extends FunctionFeature { + + public NotifyEVChargingScheduleFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyEVChargingScheduleRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyEVChargingScheduleResponse.class; + } + + @Override + public String getAction() { + return "NotifyEVChargingSchedule"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEventFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEventFeature.java new file mode 100644 index 00000000..534c1367 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyEventFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyEventRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyEventResponse; + +public class NotifyEventFeature extends FunctionFeature { + + public NotifyEventFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyEventRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyEventResponse.class; + } + + @Override + public String getAction() { + return "NotifyEvent"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyMonitoringReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyMonitoringReportFeature.java new file mode 100644 index 00000000..8cb39879 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyMonitoringReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyMonitoringReportRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyMonitoringReportResponse; + +public class NotifyMonitoringReportFeature extends FunctionFeature { + + public NotifyMonitoringReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyMonitoringReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyMonitoringReportResponse.class; + } + + @Override + public String getAction() { + return "NotifyMonitoringReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyPriorityChargingFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyPriorityChargingFeature.java new file mode 100644 index 00000000..8fc6c30f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyPriorityChargingFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyPriorityChargingRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyPriorityChargingResponse; + +public class NotifyPriorityChargingFeature extends FunctionFeature { + + public NotifyPriorityChargingFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyPriorityChargingRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyPriorityChargingResponse.class; + } + + @Override + public String getAction() { + return "NotifyPriorityCharging"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyReportFeature.java new file mode 100644 index 00000000..8a59a35f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyReportRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyReportResponse; + +public class NotifyReportFeature extends FunctionFeature { + + public NotifyReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyReportResponse.class; + } + + @Override + public String getAction() { + return "NotifyReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifySettlementFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifySettlementFeature.java new file mode 100644 index 00000000..fec8bf9b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifySettlementFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifySettlementRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifySettlementResponse; + +public class NotifySettlementFeature extends FunctionFeature { + + public NotifySettlementFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifySettlementRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifySettlementResponse.class; + } + + @Override + public String getAction() { + return "NotifySettlement"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyWebPaymentStartedFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyWebPaymentStartedFeature.java new file mode 100644 index 00000000..bb0f4f6b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyWebPaymentStartedFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyWebPaymentStartedRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyWebPaymentStartedResponse; + +public class NotifyWebPaymentStartedFeature extends FunctionFeature { + + public NotifyWebPaymentStartedFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyWebPaymentStartedRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyWebPaymentStartedResponse.class; + } + + @Override + public String getAction() { + return "NotifyWebPaymentStarted"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/OpenPeriodicEventStreamFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/OpenPeriodicEventStreamFeature.java new file mode 100644 index 00000000..01211a8d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/OpenPeriodicEventStreamFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.OpenPeriodicEventStreamRequest; +import eu.chargetime.ocpp.v21.model.messages.OpenPeriodicEventStreamResponse; + +public class OpenPeriodicEventStreamFeature extends FunctionFeature { + + public OpenPeriodicEventStreamFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return OpenPeriodicEventStreamRequest.class; + } + + @Override + public Class getConfirmationType() { + return OpenPeriodicEventStreamResponse.class; + } + + @Override + public String getAction() { + return "OpenPeriodicEventStream"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PublishFirmwareFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PublishFirmwareFeature.java new file mode 100644 index 00000000..a400205c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PublishFirmwareFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.PublishFirmwareRequest; +import eu.chargetime.ocpp.v21.model.messages.PublishFirmwareResponse; + +public class PublishFirmwareFeature extends FunctionFeature { + + public PublishFirmwareFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return PublishFirmwareRequest.class; + } + + @Override + public Class getConfirmationType() { + return PublishFirmwareResponse.class; + } + + @Override + public String getAction() { + return "PublishFirmware"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PublishFirmwareStatusNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PublishFirmwareStatusNotificationFeature.java new file mode 100644 index 00000000..49448041 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PublishFirmwareStatusNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.PublishFirmwareStatusNotificationRequest; +import eu.chargetime.ocpp.v21.model.messages.PublishFirmwareStatusNotificationResponse; + +public class PublishFirmwareStatusNotificationFeature extends FunctionFeature { + + public PublishFirmwareStatusNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return PublishFirmwareStatusNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return PublishFirmwareStatusNotificationResponse.class; + } + + @Override + public String getAction() { + return "PublishFirmwareStatusNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PullDynamicScheduleUpdateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PullDynamicScheduleUpdateFeature.java new file mode 100644 index 00000000..966c47e1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/PullDynamicScheduleUpdateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.PullDynamicScheduleUpdateRequest; +import eu.chargetime.ocpp.v21.model.messages.PullDynamicScheduleUpdateResponse; + +public class PullDynamicScheduleUpdateFeature extends FunctionFeature { + + public PullDynamicScheduleUpdateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return PullDynamicScheduleUpdateRequest.class; + } + + @Override + public Class getConfirmationType() { + return PullDynamicScheduleUpdateResponse.class; + } + + @Override + public String getAction() { + return "PullDynamicScheduleUpdate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReportChargingProfilesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReportChargingProfilesFeature.java new file mode 100644 index 00000000..307b3a70 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReportChargingProfilesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ReportChargingProfilesRequest; +import eu.chargetime.ocpp.v21.model.messages.ReportChargingProfilesResponse; + +public class ReportChargingProfilesFeature extends FunctionFeature { + + public ReportChargingProfilesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ReportChargingProfilesRequest.class; + } + + @Override + public Class getConfirmationType() { + return ReportChargingProfilesResponse.class; + } + + @Override + public String getAction() { + return "ReportChargingProfiles"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReportDERControlFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReportDERControlFeature.java new file mode 100644 index 00000000..8cd3e020 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReportDERControlFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ReportDERControlRequest; +import eu.chargetime.ocpp.v21.model.messages.ReportDERControlResponse; + +public class ReportDERControlFeature extends FunctionFeature { + + public ReportDERControlFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ReportDERControlRequest.class; + } + + @Override + public Class getConfirmationType() { + return ReportDERControlResponse.class; + } + + @Override + public String getAction() { + return "ReportDERControl"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestBatterySwapFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestBatterySwapFeature.java new file mode 100644 index 00000000..a04d6f72 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestBatterySwapFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.RequestBatterySwapRequest; +import eu.chargetime.ocpp.v21.model.messages.RequestBatterySwapResponse; + +public class RequestBatterySwapFeature extends FunctionFeature { + + public RequestBatterySwapFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return RequestBatterySwapRequest.class; + } + + @Override + public Class getConfirmationType() { + return RequestBatterySwapResponse.class; + } + + @Override + public String getAction() { + return "RequestBatterySwap"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestStartTransactionFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestStartTransactionFeature.java new file mode 100644 index 00000000..be498b8a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestStartTransactionFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.RequestStartTransactionRequest; +import eu.chargetime.ocpp.v21.model.messages.RequestStartTransactionResponse; + +public class RequestStartTransactionFeature extends FunctionFeature { + + public RequestStartTransactionFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return RequestStartTransactionRequest.class; + } + + @Override + public Class getConfirmationType() { + return RequestStartTransactionResponse.class; + } + + @Override + public String getAction() { + return "RequestStartTransaction"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestStopTransactionFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestStopTransactionFeature.java new file mode 100644 index 00000000..dba83f78 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/RequestStopTransactionFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.RequestStopTransactionRequest; +import eu.chargetime.ocpp.v21.model.messages.RequestStopTransactionResponse; + +public class RequestStopTransactionFeature extends FunctionFeature { + + public RequestStopTransactionFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return RequestStopTransactionRequest.class; + } + + @Override + public Class getConfirmationType() { + return RequestStopTransactionResponse.class; + } + + @Override + public String getAction() { + return "RequestStopTransaction"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReservationStatusUpdateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReservationStatusUpdateFeature.java new file mode 100644 index 00000000..8ba8c45a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReservationStatusUpdateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ReservationStatusUpdateRequest; +import eu.chargetime.ocpp.v21.model.messages.ReservationStatusUpdateResponse; + +public class ReservationStatusUpdateFeature extends FunctionFeature { + + public ReservationStatusUpdateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ReservationStatusUpdateRequest.class; + } + + @Override + public Class getConfirmationType() { + return ReservationStatusUpdateResponse.class; + } + + @Override + public String getAction() { + return "ReservationStatusUpdate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReserveNowFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReserveNowFeature.java new file mode 100644 index 00000000..f97b5ef0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ReserveNowFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ReserveNowRequest; +import eu.chargetime.ocpp.v21.model.messages.ReserveNowResponse; + +public class ReserveNowFeature extends FunctionFeature { + + public ReserveNowFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ReserveNowRequest.class; + } + + @Override + public Class getConfirmationType() { + return ReserveNowResponse.class; + } + + @Override + public String getAction() { + return "ReserveNow"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ResetFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ResetFeature.java new file mode 100644 index 00000000..ea345907 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/ResetFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.ResetRequest; +import eu.chargetime.ocpp.v21.model.messages.ResetResponse; + +public class ResetFeature extends FunctionFeature { + + public ResetFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ResetRequest.class; + } + + @Override + public Class getConfirmationType() { + return ResetResponse.class; + } + + @Override + public String getAction() { + return "Reset"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SecurityEventNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SecurityEventNotificationFeature.java new file mode 100644 index 00000000..c33eb03e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SecurityEventNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SecurityEventNotificationRequest; +import eu.chargetime.ocpp.v21.model.messages.SecurityEventNotificationResponse; + +public class SecurityEventNotificationFeature extends FunctionFeature { + + public SecurityEventNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SecurityEventNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return SecurityEventNotificationResponse.class; + } + + @Override + public String getAction() { + return "SecurityEventNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SendLocalListFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SendLocalListFeature.java new file mode 100644 index 00000000..c9904d14 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SendLocalListFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SendLocalListRequest; +import eu.chargetime.ocpp.v21.model.messages.SendLocalListResponse; + +public class SendLocalListFeature extends FunctionFeature { + + public SendLocalListFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SendLocalListRequest.class; + } + + @Override + public Class getConfirmationType() { + return SendLocalListResponse.class; + } + + @Override + public String getAction() { + return "SendLocalList"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetChargingProfileFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetChargingProfileFeature.java new file mode 100644 index 00000000..1c68a0be --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetChargingProfileFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetChargingProfileRequest; +import eu.chargetime.ocpp.v21.model.messages.SetChargingProfileResponse; + +public class SetChargingProfileFeature extends FunctionFeature { + + public SetChargingProfileFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetChargingProfileRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetChargingProfileResponse.class; + } + + @Override + public String getAction() { + return "SetChargingProfile"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDERControlFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDERControlFeature.java new file mode 100644 index 00000000..b8e767c1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDERControlFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetDERControlRequest; +import eu.chargetime.ocpp.v21.model.messages.SetDERControlResponse; + +public class SetDERControlFeature extends FunctionFeature { + + public SetDERControlFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetDERControlRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetDERControlResponse.class; + } + + @Override + public String getAction() { + return "SetDERControl"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDefaultTariffFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDefaultTariffFeature.java new file mode 100644 index 00000000..e90ef5da --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDefaultTariffFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetDefaultTariffRequest; +import eu.chargetime.ocpp.v21.model.messages.SetDefaultTariffResponse; + +public class SetDefaultTariffFeature extends FunctionFeature { + + public SetDefaultTariffFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetDefaultTariffRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetDefaultTariffResponse.class; + } + + @Override + public String getAction() { + return "SetDefaultTariff"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDisplayMessageFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDisplayMessageFeature.java new file mode 100644 index 00000000..6fe4f01f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetDisplayMessageFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetDisplayMessageRequest; +import eu.chargetime.ocpp.v21.model.messages.SetDisplayMessageResponse; + +public class SetDisplayMessageFeature extends FunctionFeature { + + public SetDisplayMessageFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetDisplayMessageRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetDisplayMessageResponse.class; + } + + @Override + public String getAction() { + return "SetDisplayMessage"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetMonitoringBaseFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetMonitoringBaseFeature.java new file mode 100644 index 00000000..8c48d684 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetMonitoringBaseFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetMonitoringBaseRequest; +import eu.chargetime.ocpp.v21.model.messages.SetMonitoringBaseResponse; + +public class SetMonitoringBaseFeature extends FunctionFeature { + + public SetMonitoringBaseFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetMonitoringBaseRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetMonitoringBaseResponse.class; + } + + @Override + public String getAction() { + return "SetMonitoringBase"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetMonitoringLevelFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetMonitoringLevelFeature.java new file mode 100644 index 00000000..1b43f101 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetMonitoringLevelFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetMonitoringLevelRequest; +import eu.chargetime.ocpp.v21.model.messages.SetMonitoringLevelResponse; + +public class SetMonitoringLevelFeature extends FunctionFeature { + + public SetMonitoringLevelFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetMonitoringLevelRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetMonitoringLevelResponse.class; + } + + @Override + public String getAction() { + return "SetMonitoringLevel"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetNetworkProfileFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetNetworkProfileFeature.java new file mode 100644 index 00000000..c25071bb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetNetworkProfileFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetNetworkProfileRequest; +import eu.chargetime.ocpp.v21.model.messages.SetNetworkProfileResponse; + +public class SetNetworkProfileFeature extends FunctionFeature { + + public SetNetworkProfileFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetNetworkProfileRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetNetworkProfileResponse.class; + } + + @Override + public String getAction() { + return "SetNetworkProfile"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetVariableMonitoringFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetVariableMonitoringFeature.java new file mode 100644 index 00000000..d3f8f6eb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetVariableMonitoringFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetVariableMonitoringRequest; +import eu.chargetime.ocpp.v21.model.messages.SetVariableMonitoringResponse; + +public class SetVariableMonitoringFeature extends FunctionFeature { + + public SetVariableMonitoringFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetVariableMonitoringRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetVariableMonitoringResponse.class; + } + + @Override + public String getAction() { + return "SetVariableMonitoring"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetVariablesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetVariablesFeature.java new file mode 100644 index 00000000..a323de9d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SetVariablesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SetVariablesRequest; +import eu.chargetime.ocpp.v21.model.messages.SetVariablesResponse; + +public class SetVariablesFeature extends FunctionFeature { + + public SetVariablesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetVariablesRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetVariablesResponse.class; + } + + @Override + public String getAction() { + return "SetVariables"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SignCertificateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SignCertificateFeature.java new file mode 100644 index 00000000..ba8ad2e9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/SignCertificateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.SignCertificateRequest; +import eu.chargetime.ocpp.v21.model.messages.SignCertificateResponse; + +public class SignCertificateFeature extends FunctionFeature { + + public SignCertificateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SignCertificateRequest.class; + } + + @Override + public Class getConfirmationType() { + return SignCertificateResponse.class; + } + + @Override + public String getAction() { + return "SignCertificate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/StatusNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/StatusNotificationFeature.java new file mode 100644 index 00000000..bca2d3a8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/StatusNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.StatusNotificationRequest; +import eu.chargetime.ocpp.v21.model.messages.StatusNotificationResponse; + +public class StatusNotificationFeature extends FunctionFeature { + + public StatusNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return StatusNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return StatusNotificationResponse.class; + } + + @Override + public String getAction() { + return "StatusNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/TransactionEventFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/TransactionEventFeature.java new file mode 100644 index 00000000..13e011e3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/TransactionEventFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.TransactionEventRequest; +import eu.chargetime.ocpp.v21.model.messages.TransactionEventResponse; + +public class TransactionEventFeature extends FunctionFeature { + + public TransactionEventFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return TransactionEventRequest.class; + } + + @Override + public Class getConfirmationType() { + return TransactionEventResponse.class; + } + + @Override + public String getAction() { + return "TransactionEvent"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/TriggerMessageFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/TriggerMessageFeature.java new file mode 100644 index 00000000..8fe71835 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/TriggerMessageFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.TriggerMessageRequest; +import eu.chargetime.ocpp.v21.model.messages.TriggerMessageResponse; + +public class TriggerMessageFeature extends FunctionFeature { + + public TriggerMessageFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return TriggerMessageRequest.class; + } + + @Override + public Class getConfirmationType() { + return TriggerMessageResponse.class; + } + + @Override + public String getAction() { + return "TriggerMessage"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UnlockConnectorFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UnlockConnectorFeature.java new file mode 100644 index 00000000..2913807c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UnlockConnectorFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.UnlockConnectorRequest; +import eu.chargetime.ocpp.v21.model.messages.UnlockConnectorResponse; + +public class UnlockConnectorFeature extends FunctionFeature { + + public UnlockConnectorFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return UnlockConnectorRequest.class; + } + + @Override + public Class getConfirmationType() { + return UnlockConnectorResponse.class; + } + + @Override + public String getAction() { + return "UnlockConnector"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UnpublishFirmwareFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UnpublishFirmwareFeature.java new file mode 100644 index 00000000..61b728a5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UnpublishFirmwareFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.UnpublishFirmwareRequest; +import eu.chargetime.ocpp.v21.model.messages.UnpublishFirmwareResponse; + +public class UnpublishFirmwareFeature extends FunctionFeature { + + public UnpublishFirmwareFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return UnpublishFirmwareRequest.class; + } + + @Override + public Class getConfirmationType() { + return UnpublishFirmwareResponse.class; + } + + @Override + public String getAction() { + return "UnpublishFirmware"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UpdateDynamicScheduleFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UpdateDynamicScheduleFeature.java new file mode 100644 index 00000000..71547d9c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UpdateDynamicScheduleFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.UpdateDynamicScheduleRequest; +import eu.chargetime.ocpp.v21.model.messages.UpdateDynamicScheduleResponse; + +public class UpdateDynamicScheduleFeature extends FunctionFeature { + + public UpdateDynamicScheduleFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return UpdateDynamicScheduleRequest.class; + } + + @Override + public Class getConfirmationType() { + return UpdateDynamicScheduleResponse.class; + } + + @Override + public String getAction() { + return "UpdateDynamicSchedule"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UpdateFirmwareFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UpdateFirmwareFeature.java new file mode 100644 index 00000000..65af34e8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UpdateFirmwareFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.UpdateFirmwareRequest; +import eu.chargetime.ocpp.v21.model.messages.UpdateFirmwareResponse; + +public class UpdateFirmwareFeature extends FunctionFeature { + + public UpdateFirmwareFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return UpdateFirmwareRequest.class; + } + + @Override + public Class getConfirmationType() { + return UpdateFirmwareResponse.class; + } + + @Override + public String getAction() { + return "UpdateFirmware"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UsePriorityChargingFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UsePriorityChargingFeature.java new file mode 100644 index 00000000..09851c08 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/UsePriorityChargingFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.UsePriorityChargingRequest; +import eu.chargetime.ocpp.v21.model.messages.UsePriorityChargingResponse; + +public class UsePriorityChargingFeature extends FunctionFeature { + + public UsePriorityChargingFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return UsePriorityChargingRequest.class; + } + + @Override + public Class getConfirmationType() { + return UsePriorityChargingResponse.class; + } + + @Override + public String getAction() { + return "UsePriorityCharging"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/VatNumberValidationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/VatNumberValidationFeature.java new file mode 100644 index 00000000..fa2081ee --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/VatNumberValidationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.VatNumberValidationRequest; +import eu.chargetime.ocpp.v21.model.messages.VatNumberValidationResponse; + +public class VatNumberValidationFeature extends FunctionFeature { + + public VatNumberValidationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return VatNumberValidationRequest.class; + } + + @Override + public Class getConfirmationType() { + return VatNumberValidationResponse.class; + } + + @Override + public String getAction() { + return "VatNumberValidation"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAuthorizationEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAuthorizationEventHandler.java new file mode 100644 index 00000000..76a83e76 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAuthorizationEventHandler.java @@ -0,0 +1,48 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the Authorization functional block. */ +public interface ClientAuthorizationEventHandler { + /** + * Handle a {@link ClearCacheRequest} and return a {@link ClearCacheResponse}. + * + * @param request incoming {@link ClearCacheRequest} to handle. + * @return outgoing {@link ClearCacheResponse} to reply with. + */ + ClearCacheResponse handleClearCacheRequest(ClearCacheRequest request); + + /** + * Handle a {@link NotifyWebPaymentStartedRequest} and return a {@link + * NotifyWebPaymentStartedResponse}. + * + * @param request incoming {@link NotifyWebPaymentStartedRequest} to handle. + * @return outgoing {@link NotifyWebPaymentStartedResponse} to reply with. + */ + NotifyWebPaymentStartedResponse handleNotifyWebPaymentStartedRequest( + NotifyWebPaymentStartedRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAuthorizationFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAuthorizationFunction.java new file mode 100644 index 00000000..2af7d93c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAuthorizationFunction.java @@ -0,0 +1,109 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Authorization functional block. */ +public class ClientAuthorizationFunction implements Function { + + private final ClientAuthorizationEventHandler eventHandler; + private final ArrayList features; + + public ClientAuthorizationFunction(ClientAuthorizationEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new AuthorizeFeature(null)); + features.add(new ClearCacheFeature(this)); + features.add(new NotifySettlementFeature(null)); + features.add(new NotifyWebPaymentStartedFeature(this)); + features.add(new VatNumberValidationFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearCacheRequest) { + return eventHandler.handleClearCacheRequest((ClearCacheRequest) request); + } else if (request instanceof NotifyWebPaymentStartedRequest) { + return eventHandler.handleNotifyWebPaymentStartedRequest( + (NotifyWebPaymentStartedRequest) request); + } + return null; + } + + /** + * Create a client {@link AuthorizeRequest} with all required fields. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @return an instance of {@link AuthorizeRequest} + */ + public AuthorizeRequest createAuthorizeRequest(IdToken idToken) { + return new AuthorizeRequest(idToken); + } + + /** + * Create a client {@link NotifySettlementRequest} with all required fields. + * + * @param pspRef The payment reference received from the payment terminal and is used as the value + * for idToken. + * @param status The status of the settlement attempt. + * @param settlementAmount The amount that was settled, or attempted to be settled (in case of + * failure). + * @param settlementTime The time when the settlement was done. + * @return an instance of {@link NotifySettlementRequest} + */ + public NotifySettlementRequest createNotifySettlementRequest( + String pspRef, + PaymentStatusEnum status, + Double settlementAmount, + ZonedDateTime settlementTime) { + return new NotifySettlementRequest(pspRef, status, settlementAmount, settlementTime); + } + + /** + * Create a client {@link VatNumberValidationRequest} with all required fields. + * + * @param vatNumber VAT number to check. + * @return an instance of {@link VatNumberValidationRequest} + */ + public VatNumberValidationRequest createVatNumberValidationRequest(String vatNumber) { + return new VatNumberValidationRequest(vatNumber); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAvailabilityEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAvailabilityEventHandler.java new file mode 100644 index 00000000..8be1d3cc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAvailabilityEventHandler.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the Availability functional block. */ +public interface ClientAvailabilityEventHandler { + /** + * Handle a {@link ChangeAvailabilityRequest} and return a {@link ChangeAvailabilityResponse}. + * + * @param request incoming {@link ChangeAvailabilityRequest} to handle. + * @return outgoing {@link ChangeAvailabilityResponse} to reply with. + */ + ChangeAvailabilityResponse handleChangeAvailabilityRequest(ChangeAvailabilityRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAvailabilityFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAvailabilityFunction.java new file mode 100644 index 00000000..e0dfc829 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientAvailabilityFunction.java @@ -0,0 +1,95 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Availability functional block. */ +public class ClientAvailabilityFunction implements Function { + + private final ClientAvailabilityEventHandler eventHandler; + private final ArrayList features; + + public ClientAvailabilityFunction(ClientAvailabilityEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ChangeAvailabilityFeature(this)); + features.add(new NotifyEventFeature(null)); + features.add(new StatusNotificationFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ChangeAvailabilityRequest) { + return eventHandler.handleChangeAvailabilityRequest((ChangeAvailabilityRequest) request); + } + return null; + } + + /** + * Create a client {@link NotifyEventRequest} with all required fields. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param eventData Class to report an event notification for a component-variable. + * @return an instance of {@link NotifyEventRequest} + */ + public NotifyEventRequest createNotifyEventRequest( + ZonedDateTime generatedAt, Integer seqNo, EventData[] eventData) { + return new NotifyEventRequest(generatedAt, seqNo, eventData); + } + + /** + * Create a client {@link StatusNotificationRequest} with all required fields. + * + * @param timestamp The time for which the status is reported. + * @param connectorStatus The current status of the Connector. + * @param evseId The id of the EVSE to which the connector belongs for which the the status is + * reported. + * @param connectorId The id of the connector within the EVSE for which the status is reported. + * @return an instance of {@link StatusNotificationRequest} + */ + public StatusNotificationRequest createStatusNotificationRequest( + ZonedDateTime timestamp, + ConnectorStatusEnum connectorStatus, + Integer evseId, + Integer connectorId) { + return new StatusNotificationRequest(timestamp, connectorStatus, evseId, connectorId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientBidirectionalPowerTransferEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientBidirectionalPowerTransferEventHandler.java new file mode 100644 index 00000000..7e8927b9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientBidirectionalPowerTransferEventHandler.java @@ -0,0 +1,48 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the BidirectionalPowerTransfer functional block. */ +public interface ClientBidirectionalPowerTransferEventHandler { + /** + * Handle a {@link AFRRSignalRequest} and return a {@link AFRRSignalResponse}. + * + * @param request incoming {@link AFRRSignalRequest} to handle. + * @return outgoing {@link AFRRSignalResponse} to reply with. + */ + AFRRSignalResponse handleAFRRSignalRequest(AFRRSignalRequest request); + + /** + * Handle a {@link NotifyAllowedEnergyTransferRequest} and return a {@link + * NotifyAllowedEnergyTransferResponse}. + * + * @param request incoming {@link NotifyAllowedEnergyTransferRequest} to handle. + * @return outgoing {@link NotifyAllowedEnergyTransferResponse} to reply with. + */ + NotifyAllowedEnergyTransferResponse handleNotifyAllowedEnergyTransferRequest( + NotifyAllowedEnergyTransferRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientBidirectionalPowerTransferFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientBidirectionalPowerTransferFunction.java new file mode 100644 index 00000000..20e69270 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientBidirectionalPowerTransferFunction.java @@ -0,0 +1,69 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with client request creators and handlers for the BidirectionalPowerTransfer functional + * block. + */ +public class ClientBidirectionalPowerTransferFunction implements Function { + + private final ClientBidirectionalPowerTransferEventHandler eventHandler; + private final ArrayList features; + + public ClientBidirectionalPowerTransferFunction( + ClientBidirectionalPowerTransferEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new AFRRSignalFeature(this)); + features.add(new NotifyAllowedEnergyTransferFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof AFRRSignalRequest) { + return eventHandler.handleAFRRSignalRequest((AFRRSignalRequest) request); + } else if (request instanceof NotifyAllowedEnergyTransferRequest) { + return eventHandler.handleNotifyAllowedEnergyTransferRequest( + (NotifyAllowedEnergyTransferRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDERControlEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDERControlEventHandler.java new file mode 100644 index 00000000..fbf62591 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDERControlEventHandler.java @@ -0,0 +1,62 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the DERControl functional block. */ +public interface ClientDERControlEventHandler { + /** + * Handle a {@link ClearDERControlRequest} and return a {@link ClearDERControlResponse}. + * + * @param request incoming {@link ClearDERControlRequest} to handle. + * @return outgoing {@link ClearDERControlResponse} to reply with. + */ + ClearDERControlResponse handleClearDERControlRequest(ClearDERControlRequest request); + + /** + * Handle a {@link GetDERControlRequest} and return a {@link GetDERControlResponse}. + * + * @param request incoming {@link GetDERControlRequest} to handle. + * @return outgoing {@link GetDERControlResponse} to reply with. + */ + GetDERControlResponse handleGetDERControlRequest(GetDERControlRequest request); + + /** + * Handle a {@link ReportDERControlRequest} and return a {@link ReportDERControlResponse}. + * + * @param request incoming {@link ReportDERControlRequest} to handle. + * @return outgoing {@link ReportDERControlResponse} to reply with. + */ + ReportDERControlResponse handleReportDERControlRequest(ReportDERControlRequest request); + + /** + * Handle a {@link SetDERControlRequest} and return a {@link SetDERControlResponse}. + * + * @param request incoming {@link SetDERControlRequest} to handle. + * @return outgoing {@link SetDERControlResponse} to reply with. + */ + SetDERControlResponse handleSetDERControlRequest(SetDERControlRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDERControlFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDERControlFunction.java new file mode 100644 index 00000000..c22bf8ec --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDERControlFunction.java @@ -0,0 +1,99 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the DERControl functional block. */ +public class ClientDERControlFunction implements Function { + + private final ClientDERControlEventHandler eventHandler; + private final ArrayList features; + + public ClientDERControlFunction(ClientDERControlEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearDERControlFeature(this)); + features.add(new GetDERControlFeature(this)); + features.add(new NotifyDERAlarmFeature(null)); + features.add(new NotifyDERStartStopFeature(null)); + features.add(new ReportDERControlFeature(this)); + features.add(new SetDERControlFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearDERControlRequest) { + return eventHandler.handleClearDERControlRequest((ClearDERControlRequest) request); + } else if (request instanceof GetDERControlRequest) { + return eventHandler.handleGetDERControlRequest((GetDERControlRequest) request); + } else if (request instanceof ReportDERControlRequest) { + return eventHandler.handleReportDERControlRequest((ReportDERControlRequest) request); + } else if (request instanceof SetDERControlRequest) { + return eventHandler.handleSetDERControlRequest((SetDERControlRequest) request); + } + return null; + } + + /** + * Create a client {@link NotifyDERAlarmRequest} with all required fields. + * + * @param controlType Name of DER control, e.g. LFMustTrip + * @param timestamp Time of start or end of alarm. + * @return an instance of {@link NotifyDERAlarmRequest} + */ + public NotifyDERAlarmRequest createNotifyDERAlarmRequest( + DERControlEnum controlType, ZonedDateTime timestamp) { + return new NotifyDERAlarmRequest(controlType, timestamp); + } + + /** + * Create a client {@link NotifyDERStartStopRequest} with all required fields. + * + * @param controlId Id of the started or stopped DER control. Corresponds to the controlId of the + * SetDERControlRequest. + * @param started True if DER control has started. False if it has ended. + * @param timestamp Time of start or end of event. + * @return an instance of {@link NotifyDERStartStopRequest} + */ + public NotifyDERStartStopRequest createNotifyDERStartStopRequest( + String controlId, Boolean started, ZonedDateTime timestamp) { + return new NotifyDERStartStopRequest(controlId, started, timestamp); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDataTransferEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDataTransferEventHandler.java new file mode 100644 index 00000000..0083daf3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDataTransferEventHandler.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the DataTransfer functional block. */ +public interface ClientDataTransferEventHandler { + /** + * Handle a {@link DataTransferRequest} and return a {@link DataTransferResponse}. + * + * @param request incoming {@link DataTransferRequest} to handle. + * @return outgoing {@link DataTransferResponse} to reply with. + */ + DataTransferResponse handleDataTransferRequest(DataTransferRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDataTransferFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDataTransferFunction.java new file mode 100644 index 00000000..ee28d5dd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDataTransferFunction.java @@ -0,0 +1,71 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the DataTransfer functional block. */ +public class ClientDataTransferFunction implements Function { + + private final ClientDataTransferEventHandler eventHandler; + private final ArrayList features; + + public ClientDataTransferFunction(ClientDataTransferEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new DataTransferFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof DataTransferRequest) { + return eventHandler.handleDataTransferRequest((DataTransferRequest) request); + } + return null; + } + + /** + * Create a client {@link DataTransferRequest} with all required fields. + * + * @param vendorId The identifier of the Vendor specific implementation + * @return an instance of {@link DataTransferRequest} + */ + public DataTransferRequest createDataTransferRequest(String vendorId) { + return new DataTransferRequest(vendorId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsEventHandler.java new file mode 100644 index 00000000..797b6341 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsEventHandler.java @@ -0,0 +1,120 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the Diagnostics functional block. */ +public interface ClientDiagnosticsEventHandler { + /** + * Handle a {@link AdjustPeriodicEventStreamRequest} and return a {@link + * AdjustPeriodicEventStreamResponse}. + * + * @param request incoming {@link AdjustPeriodicEventStreamRequest} to handle. + * @return outgoing {@link AdjustPeriodicEventStreamResponse} to reply with. + */ + AdjustPeriodicEventStreamResponse handleAdjustPeriodicEventStreamRequest( + AdjustPeriodicEventStreamRequest request); + + /** + * Handle a {@link ClearVariableMonitoringRequest} and return a {@link + * ClearVariableMonitoringResponse}. + * + * @param request incoming {@link ClearVariableMonitoringRequest} to handle. + * @return outgoing {@link ClearVariableMonitoringResponse} to reply with. + */ + ClearVariableMonitoringResponse handleClearVariableMonitoringRequest( + ClearVariableMonitoringRequest request); + + /** + * Handle a {@link ClosePeriodicEventStreamRequest} and return a {@link + * ClosePeriodicEventStreamResponse}. + * + * @param request incoming {@link ClosePeriodicEventStreamRequest} to handle. + * @return outgoing {@link ClosePeriodicEventStreamResponse} to reply with. + */ + ClosePeriodicEventStreamResponse handleClosePeriodicEventStreamRequest( + ClosePeriodicEventStreamRequest request); + + /** + * Handle a {@link CustomerInformationRequest} and return a {@link CustomerInformationResponse}. + * + * @param request incoming {@link CustomerInformationRequest} to handle. + * @return outgoing {@link CustomerInformationResponse} to reply with. + */ + CustomerInformationResponse handleCustomerInformationRequest(CustomerInformationRequest request); + + /** + * Handle a {@link GetLogRequest} and return a {@link GetLogResponse}. + * + * @param request incoming {@link GetLogRequest} to handle. + * @return outgoing {@link GetLogResponse} to reply with. + */ + GetLogResponse handleGetLogRequest(GetLogRequest request); + + /** + * Handle a {@link GetMonitoringReportRequest} and return a {@link GetMonitoringReportResponse}. + * + * @param request incoming {@link GetMonitoringReportRequest} to handle. + * @return outgoing {@link GetMonitoringReportResponse} to reply with. + */ + GetMonitoringReportResponse handleGetMonitoringReportRequest(GetMonitoringReportRequest request); + + /** + * Handle a {@link GetPeriodicEventStreamRequest} and return a {@link + * GetPeriodicEventStreamResponse}. + * + * @param request incoming {@link GetPeriodicEventStreamRequest} to handle. + * @return outgoing {@link GetPeriodicEventStreamResponse} to reply with. + */ + GetPeriodicEventStreamResponse handleGetPeriodicEventStreamRequest( + GetPeriodicEventStreamRequest request); + + /** + * Handle a {@link SetMonitoringBaseRequest} and return a {@link SetMonitoringBaseResponse}. + * + * @param request incoming {@link SetMonitoringBaseRequest} to handle. + * @return outgoing {@link SetMonitoringBaseResponse} to reply with. + */ + SetMonitoringBaseResponse handleSetMonitoringBaseRequest(SetMonitoringBaseRequest request); + + /** + * Handle a {@link SetMonitoringLevelRequest} and return a {@link SetMonitoringLevelResponse}. + * + * @param request incoming {@link SetMonitoringLevelRequest} to handle. + * @return outgoing {@link SetMonitoringLevelResponse} to reply with. + */ + SetMonitoringLevelResponse handleSetMonitoringLevelRequest(SetMonitoringLevelRequest request); + + /** + * Handle a {@link SetVariableMonitoringRequest} and return a {@link + * SetVariableMonitoringResponse}. + * + * @param request incoming {@link SetVariableMonitoringRequest} to handle. + * @return outgoing {@link SetVariableMonitoringResponse} to reply with. + */ + SetVariableMonitoringResponse handleSetVariableMonitoringRequest( + SetVariableMonitoringRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsFunction.java new file mode 100644 index 00000000..5e23660f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsFunction.java @@ -0,0 +1,148 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Diagnostics functional block. */ +public class ClientDiagnosticsFunction implements Function { + + private final ClientDiagnosticsEventHandler eventHandler; + private final ArrayList features; + + public ClientDiagnosticsFunction(ClientDiagnosticsEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new AdjustPeriodicEventStreamFeature(this)); + features.add(new ClearVariableMonitoringFeature(this)); + features.add(new ClosePeriodicEventStreamFeature(this)); + features.add(new CustomerInformationFeature(this)); + features.add(new GetLogFeature(this)); + features.add(new GetMonitoringReportFeature(this)); + features.add(new GetPeriodicEventStreamFeature(this)); + features.add(new LogStatusNotificationFeature(null)); + features.add(new NotifyCustomerInformationFeature(null)); + features.add(new NotifyMonitoringReportFeature(null)); + features.add(new OpenPeriodicEventStreamFeature(null)); + features.add(new SetMonitoringBaseFeature(this)); + features.add(new SetMonitoringLevelFeature(this)); + features.add(new SetVariableMonitoringFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof AdjustPeriodicEventStreamRequest) { + return eventHandler.handleAdjustPeriodicEventStreamRequest( + (AdjustPeriodicEventStreamRequest) request); + } else if (request instanceof ClearVariableMonitoringRequest) { + return eventHandler.handleClearVariableMonitoringRequest( + (ClearVariableMonitoringRequest) request); + } else if (request instanceof ClosePeriodicEventStreamRequest) { + return eventHandler.handleClosePeriodicEventStreamRequest( + (ClosePeriodicEventStreamRequest) request); + } else if (request instanceof CustomerInformationRequest) { + return eventHandler.handleCustomerInformationRequest((CustomerInformationRequest) request); + } else if (request instanceof GetLogRequest) { + return eventHandler.handleGetLogRequest((GetLogRequest) request); + } else if (request instanceof GetMonitoringReportRequest) { + return eventHandler.handleGetMonitoringReportRequest((GetMonitoringReportRequest) request); + } else if (request instanceof GetPeriodicEventStreamRequest) { + return eventHandler.handleGetPeriodicEventStreamRequest( + (GetPeriodicEventStreamRequest) request); + } else if (request instanceof SetMonitoringBaseRequest) { + return eventHandler.handleSetMonitoringBaseRequest((SetMonitoringBaseRequest) request); + } else if (request instanceof SetMonitoringLevelRequest) { + return eventHandler.handleSetMonitoringLevelRequest((SetMonitoringLevelRequest) request); + } else if (request instanceof SetVariableMonitoringRequest) { + return eventHandler.handleSetVariableMonitoringRequest( + (SetVariableMonitoringRequest) request); + } + return null; + } + + /** + * Create a client {@link LogStatusNotificationRequest} with all required fields. + * + * @param status The status of the log upload. + * @return an instance of {@link LogStatusNotificationRequest} + */ + public LogStatusNotificationRequest createLogStatusNotificationRequest( + UploadLogStatusEnum status) { + return new LogStatusNotificationRequest(status); + } + + /** + * Create a client {@link NotifyCustomerInformationRequest} with all required fields. + * + * @param data (Part of) the requested data. No format specified in which the data is returned. + * Should be human readable. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param requestId The Id of the request. + * @return an instance of {@link NotifyCustomerInformationRequest} + */ + public NotifyCustomerInformationRequest createNotifyCustomerInformationRequest( + String data, Integer seqNo, ZonedDateTime generatedAt, Integer requestId) { + return new NotifyCustomerInformationRequest(data, seqNo, generatedAt, requestId); + } + + /** + * Create a client {@link NotifyMonitoringReportRequest} with all required fields. + * + * @param requestId The id of the GetMonitoringRequest that requested this report. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @return an instance of {@link NotifyMonitoringReportRequest} + */ + public NotifyMonitoringReportRequest createNotifyMonitoringReportRequest( + Integer requestId, Integer seqNo, ZonedDateTime generatedAt) { + return new NotifyMonitoringReportRequest(requestId, seqNo, generatedAt); + } + + /** + * Create a client {@link OpenPeriodicEventStreamRequest} with all required fields. + * + * @param constantStreamData constantStreamData + * @return an instance of {@link OpenPeriodicEventStreamRequest} + */ + public OpenPeriodicEventStreamRequest createOpenPeriodicEventStreamRequest( + ConstantStreamData constantStreamData) { + return new OpenPeriodicEventStreamRequest(constantStreamData); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDisplayMessageEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDisplayMessageEventHandler.java new file mode 100644 index 00000000..3a216c38 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDisplayMessageEventHandler.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the DisplayMessage functional block. */ +public interface ClientDisplayMessageEventHandler { + /** + * Handle a {@link ClearDisplayMessageRequest} and return a {@link ClearDisplayMessageResponse}. + * + * @param request incoming {@link ClearDisplayMessageRequest} to handle. + * @return outgoing {@link ClearDisplayMessageResponse} to reply with. + */ + ClearDisplayMessageResponse handleClearDisplayMessageRequest(ClearDisplayMessageRequest request); + + /** + * Handle a {@link GetDisplayMessagesRequest} and return a {@link GetDisplayMessagesResponse}. + * + * @param request incoming {@link GetDisplayMessagesRequest} to handle. + * @return outgoing {@link GetDisplayMessagesResponse} to reply with. + */ + GetDisplayMessagesResponse handleGetDisplayMessagesRequest(GetDisplayMessagesRequest request); + + /** + * Handle a {@link SetDisplayMessageRequest} and return a {@link SetDisplayMessageResponse}. + * + * @param request incoming {@link SetDisplayMessageRequest} to handle. + * @return outgoing {@link SetDisplayMessageResponse} to reply with. + */ + SetDisplayMessageResponse handleSetDisplayMessageRequest(SetDisplayMessageRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDisplayMessageFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDisplayMessageFunction.java new file mode 100644 index 00000000..3f80dfc7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDisplayMessageFunction.java @@ -0,0 +1,78 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the DisplayMessage functional block. */ +public class ClientDisplayMessageFunction implements Function { + + private final ClientDisplayMessageEventHandler eventHandler; + private final ArrayList features; + + public ClientDisplayMessageFunction(ClientDisplayMessageEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearDisplayMessageFeature(this)); + features.add(new GetDisplayMessagesFeature(this)); + features.add(new NotifyDisplayMessagesFeature(null)); + features.add(new SetDisplayMessageFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearDisplayMessageRequest) { + return eventHandler.handleClearDisplayMessageRequest((ClearDisplayMessageRequest) request); + } else if (request instanceof GetDisplayMessagesRequest) { + return eventHandler.handleGetDisplayMessagesRequest((GetDisplayMessagesRequest) request); + } else if (request instanceof SetDisplayMessageRequest) { + return eventHandler.handleSetDisplayMessageRequest((SetDisplayMessageRequest) request); + } + return null; + } + + /** + * Create a client {@link NotifyDisplayMessagesRequest} with all required fields. + * + * @param requestId The id of the GetDisplayMessagesRequest that requested this message. + * @return an instance of {@link NotifyDisplayMessagesRequest} + */ + public NotifyDisplayMessagesRequest createNotifyDisplayMessagesRequest(Integer requestId) { + return new NotifyDisplayMessagesRequest(requestId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientFirmwareManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientFirmwareManagementEventHandler.java new file mode 100644 index 00000000..407b10e2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientFirmwareManagementEventHandler.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the FirmwareManagement functional block. */ +public interface ClientFirmwareManagementEventHandler { + /** + * Handle a {@link PublishFirmwareRequest} and return a {@link PublishFirmwareResponse}. + * + * @param request incoming {@link PublishFirmwareRequest} to handle. + * @return outgoing {@link PublishFirmwareResponse} to reply with. + */ + PublishFirmwareResponse handlePublishFirmwareRequest(PublishFirmwareRequest request); + + /** + * Handle a {@link UnpublishFirmwareRequest} and return a {@link UnpublishFirmwareResponse}. + * + * @param request incoming {@link UnpublishFirmwareRequest} to handle. + * @return outgoing {@link UnpublishFirmwareResponse} to reply with. + */ + UnpublishFirmwareResponse handleUnpublishFirmwareRequest(UnpublishFirmwareRequest request); + + /** + * Handle a {@link UpdateFirmwareRequest} and return a {@link UpdateFirmwareResponse}. + * + * @param request incoming {@link UpdateFirmwareRequest} to handle. + * @return outgoing {@link UpdateFirmwareResponse} to reply with. + */ + UpdateFirmwareResponse handleUpdateFirmwareRequest(UpdateFirmwareRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientFirmwareManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientFirmwareManagementFunction.java new file mode 100644 index 00000000..c077f5ed --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientFirmwareManagementFunction.java @@ -0,0 +1,91 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the FirmwareManagement functional block. */ +public class ClientFirmwareManagementFunction implements Function { + + private final ClientFirmwareManagementEventHandler eventHandler; + private final ArrayList features; + + public ClientFirmwareManagementFunction(ClientFirmwareManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new FirmwareStatusNotificationFeature(null)); + features.add(new PublishFirmwareFeature(this)); + features.add(new PublishFirmwareStatusNotificationFeature(null)); + features.add(new UnpublishFirmwareFeature(this)); + features.add(new UpdateFirmwareFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof PublishFirmwareRequest) { + return eventHandler.handlePublishFirmwareRequest((PublishFirmwareRequest) request); + } else if (request instanceof UnpublishFirmwareRequest) { + return eventHandler.handleUnpublishFirmwareRequest((UnpublishFirmwareRequest) request); + } else if (request instanceof UpdateFirmwareRequest) { + return eventHandler.handleUpdateFirmwareRequest((UpdateFirmwareRequest) request); + } + return null; + } + + /** + * Create a client {@link FirmwareStatusNotificationRequest} with all required fields. + * + * @param status The progress status of the firmware installation. + * @return an instance of {@link FirmwareStatusNotificationRequest} + */ + public FirmwareStatusNotificationRequest createFirmwareStatusNotificationRequest( + FirmwareStatusEnum status) { + return new FirmwareStatusNotificationRequest(status); + } + + /** + * Create a client {@link PublishFirmwareStatusNotificationRequest} with all required fields. + * + * @param status The progress status of the publishfirmware installation. + * @return an instance of {@link PublishFirmwareStatusNotificationRequest} + */ + public PublishFirmwareStatusNotificationRequest createPublishFirmwareStatusNotificationRequest( + PublishFirmwareStatusEnum status) { + return new PublishFirmwareStatusNotificationRequest(status); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientISO15118CertificateManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientISO15118CertificateManagementEventHandler.java new file mode 100644 index 00000000..f608d985 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientISO15118CertificateManagementEventHandler.java @@ -0,0 +1,48 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the ISO15118CertificateManagement functional block. */ +public interface ClientISO15118CertificateManagementEventHandler { + /** + * Handle a {@link DeleteCertificateRequest} and return a {@link DeleteCertificateResponse}. + * + * @param request incoming {@link DeleteCertificateRequest} to handle. + * @return outgoing {@link DeleteCertificateResponse} to reply with. + */ + DeleteCertificateResponse handleDeleteCertificateRequest(DeleteCertificateRequest request); + + /** + * Handle a {@link GetInstalledCertificateIdsRequest} and return a {@link + * GetInstalledCertificateIdsResponse}. + * + * @param request incoming {@link GetInstalledCertificateIdsRequest} to handle. + * @return outgoing {@link GetInstalledCertificateIdsResponse} to reply with. + */ + GetInstalledCertificateIdsResponse handleGetInstalledCertificateIdsRequest( + GetInstalledCertificateIdsRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientISO15118CertificateManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientISO15118CertificateManagementFunction.java new file mode 100644 index 00000000..3f751999 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientISO15118CertificateManagementFunction.java @@ -0,0 +1,109 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with client request creators and handlers for the ISO15118CertificateManagement functional + * block. + */ +public class ClientISO15118CertificateManagementFunction implements Function { + + private final ClientISO15118CertificateManagementEventHandler eventHandler; + private final ArrayList features; + + public ClientISO15118CertificateManagementFunction( + ClientISO15118CertificateManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new DeleteCertificateFeature(this)); + features.add(new Get15118EVCertificateFeature(null)); + features.add(new GetCertificateChainStatusFeature(null)); + features.add(new GetCertificateStatusFeature(null)); + features.add(new GetInstalledCertificateIdsFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof DeleteCertificateRequest) { + return eventHandler.handleDeleteCertificateRequest((DeleteCertificateRequest) request); + } else if (request instanceof GetInstalledCertificateIdsRequest) { + return eventHandler.handleGetInstalledCertificateIdsRequest( + (GetInstalledCertificateIdsRequest) request); + } + return null; + } + + /** + * Create a client {@link Get15118EVCertificateRequest} with all required fields. + * + * @param iso15118SchemaVersion Schema version currently used for the 15118 session between EV and + * Charging Station. Needed for parsing of the EXI stream by the CSMS. + * @param action Whether certificate needs to be installed or updated. + * @param exiRequest Raw CertificateInstallationReq request from EV, Base64 encoded. + * @return an instance of {@link Get15118EVCertificateRequest} + */ + public Get15118EVCertificateRequest createGet15118EVCertificateRequest( + String iso15118SchemaVersion, CertificateActionEnum action, String exiRequest) { + return new Get15118EVCertificateRequest(iso15118SchemaVersion, action, exiRequest); + } + + /** + * Create a client {@link GetCertificateChainStatusRequest} with all required fields. + * + * @param certificateStatusRequests Data necessary to request the revocation status of a + * certificate. + * @return an instance of {@link GetCertificateChainStatusRequest} + */ + public GetCertificateChainStatusRequest createGetCertificateChainStatusRequest( + CertificateStatusRequestInfo[] certificateStatusRequests) { + return new GetCertificateChainStatusRequest(certificateStatusRequests); + } + + /** + * Create a client {@link GetCertificateStatusRequest} with all required fields. + * + * @param ocspRequestData Information about a certificate for an OCSP check. + * @return an instance of {@link GetCertificateStatusRequest} + */ + public GetCertificateStatusRequest createGetCertificateStatusRequest( + OCSPRequestData ocspRequestData) { + return new GetCertificateStatusRequest(ocspRequestData); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientLocalAuthorizationListManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientLocalAuthorizationListManagementEventHandler.java new file mode 100644 index 00000000..61350c0b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientLocalAuthorizationListManagementEventHandler.java @@ -0,0 +1,46 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the LocalAuthorizationListManagement functional block. */ +public interface ClientLocalAuthorizationListManagementEventHandler { + /** + * Handle a {@link GetLocalListVersionRequest} and return a {@link GetLocalListVersionResponse}. + * + * @param request incoming {@link GetLocalListVersionRequest} to handle. + * @return outgoing {@link GetLocalListVersionResponse} to reply with. + */ + GetLocalListVersionResponse handleGetLocalListVersionRequest(GetLocalListVersionRequest request); + + /** + * Handle a {@link SendLocalListRequest} and return a {@link SendLocalListResponse}. + * + * @param request incoming {@link SendLocalListRequest} to handle. + * @return outgoing {@link SendLocalListResponse} to reply with. + */ + SendLocalListResponse handleSendLocalListRequest(SendLocalListRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientLocalAuthorizationListManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientLocalAuthorizationListManagementFunction.java new file mode 100644 index 00000000..8527d15e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientLocalAuthorizationListManagementFunction.java @@ -0,0 +1,68 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with client request creators and handlers for the LocalAuthorizationListManagement + * functional block. + */ +public class ClientLocalAuthorizationListManagementFunction implements Function { + + private final ClientLocalAuthorizationListManagementEventHandler eventHandler; + private final ArrayList features; + + public ClientLocalAuthorizationListManagementFunction( + ClientLocalAuthorizationListManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new GetLocalListVersionFeature(this)); + features.add(new SendLocalListFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof GetLocalListVersionRequest) { + return eventHandler.handleGetLocalListVersionRequest((GetLocalListVersionRequest) request); + } else if (request instanceof SendLocalListRequest) { + return eventHandler.handleSendLocalListRequest((SendLocalListRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientMeterValuesFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientMeterValuesFunction.java new file mode 100644 index 00000000..15d82e78 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientMeterValuesFunction.java @@ -0,0 +1,69 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the MeterValues functional block. */ +public class ClientMeterValuesFunction implements Function { + + private final ArrayList features; + + public ClientMeterValuesFunction() { + features = new ArrayList<>(); + features.add(new MeterValuesFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a client {@link MeterValuesRequest} with all required fields. + * + * @param evseId A number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) + * is used to designate the main power meter. + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time. + * @return an instance of {@link MeterValuesRequest} + */ + public MeterValuesRequest createMeterValuesRequest(Integer evseId, MeterValue[] meterValue) { + return new MeterValuesRequest(evseId, meterValue); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientProvisioningEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientProvisioningEventHandler.java new file mode 100644 index 00000000..0c4c784e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientProvisioningEventHandler.java @@ -0,0 +1,78 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the Provisioning functional block. */ +public interface ClientProvisioningEventHandler { + /** + * Handle a {@link GetBaseReportRequest} and return a {@link GetBaseReportResponse}. + * + * @param request incoming {@link GetBaseReportRequest} to handle. + * @return outgoing {@link GetBaseReportResponse} to reply with. + */ + GetBaseReportResponse handleGetBaseReportRequest(GetBaseReportRequest request); + + /** + * Handle a {@link GetReportRequest} and return a {@link GetReportResponse}. + * + * @param request incoming {@link GetReportRequest} to handle. + * @return outgoing {@link GetReportResponse} to reply with. + */ + GetReportResponse handleGetReportRequest(GetReportRequest request); + + /** + * Handle a {@link GetVariablesRequest} and return a {@link GetVariablesResponse}. + * + * @param request incoming {@link GetVariablesRequest} to handle. + * @return outgoing {@link GetVariablesResponse} to reply with. + */ + GetVariablesResponse handleGetVariablesRequest(GetVariablesRequest request); + + /** + * Handle a {@link ResetRequest} and return a {@link ResetResponse}. + * + * @param request incoming {@link ResetRequest} to handle. + * @return outgoing {@link ResetResponse} to reply with. + */ + ResetResponse handleResetRequest(ResetRequest request); + + /** + * Handle a {@link SetNetworkProfileRequest} and return a {@link SetNetworkProfileResponse}. + * + * @param request incoming {@link SetNetworkProfileRequest} to handle. + * @return outgoing {@link SetNetworkProfileResponse} to reply with. + */ + SetNetworkProfileResponse handleSetNetworkProfileRequest(SetNetworkProfileRequest request); + + /** + * Handle a {@link SetVariablesRequest} and return a {@link SetVariablesResponse}. + * + * @param request incoming {@link SetVariablesRequest} to handle. + * @return outgoing {@link SetVariablesResponse} to reply with. + */ + SetVariablesResponse handleSetVariablesRequest(SetVariablesRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientProvisioningFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientProvisioningFunction.java new file mode 100644 index 00000000..3f967818 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientProvisioningFunction.java @@ -0,0 +1,115 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Provisioning functional block. */ +public class ClientProvisioningFunction implements Function { + + private final ClientProvisioningEventHandler eventHandler; + private final ArrayList features; + + public ClientProvisioningFunction(ClientProvisioningEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new BootNotificationFeature(null)); + features.add(new GetBaseReportFeature(this)); + features.add(new GetReportFeature(this)); + features.add(new GetVariablesFeature(this)); + features.add(new HeartbeatFeature(null)); + features.add(new NotifyReportFeature(null)); + features.add(new ResetFeature(this)); + features.add(new SetNetworkProfileFeature(this)); + features.add(new SetVariablesFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof GetBaseReportRequest) { + return eventHandler.handleGetBaseReportRequest((GetBaseReportRequest) request); + } else if (request instanceof GetReportRequest) { + return eventHandler.handleGetReportRequest((GetReportRequest) request); + } else if (request instanceof GetVariablesRequest) { + return eventHandler.handleGetVariablesRequest((GetVariablesRequest) request); + } else if (request instanceof ResetRequest) { + return eventHandler.handleResetRequest((ResetRequest) request); + } else if (request instanceof SetNetworkProfileRequest) { + return eventHandler.handleSetNetworkProfileRequest((SetNetworkProfileRequest) request); + } else if (request instanceof SetVariablesRequest) { + return eventHandler.handleSetVariablesRequest((SetVariablesRequest) request); + } + return null; + } + + /** + * Create a client {@link BootNotificationRequest} with all required fields. + * + * @param chargingStation The physical system where an Electrical Vehicle (EV) can be charged. + * @param reason The reason for sending this message to the CSMS. + * @return an instance of {@link BootNotificationRequest} + */ + public BootNotificationRequest createBootNotificationRequest( + ChargingStation chargingStation, BootReasonEnum reason) { + return new BootNotificationRequest(chargingStation, reason); + } + + /** + * Create a client {@link HeartbeatRequest}. + * + * @return an instance of {@link HeartbeatRequest} + */ + public HeartbeatRequest createHeartbeatRequest() { + return new HeartbeatRequest(); + } + + /** + * Create a client {@link NotifyReportRequest} with all required fields. + * + * @param requestId The id of the GetReportRequest or GetBaseReportRequest that requested this + * report + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param seqNo Sequence number of this message. First message starts at 0. + * @return an instance of {@link NotifyReportRequest} + */ + public NotifyReportRequest createNotifyReportRequest( + Integer requestId, ZonedDateTime generatedAt, Integer seqNo) { + return new NotifyReportRequest(requestId, generatedAt, seqNo); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientRemoteControlEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientRemoteControlEventHandler.java new file mode 100644 index 00000000..2bc3be75 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientRemoteControlEventHandler.java @@ -0,0 +1,66 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the RemoteControl functional block. */ +public interface ClientRemoteControlEventHandler { + /** + * Handle a {@link RequestStartTransactionRequest} and return a {@link + * RequestStartTransactionResponse}. + * + * @param request incoming {@link RequestStartTransactionRequest} to handle. + * @return outgoing {@link RequestStartTransactionResponse} to reply with. + */ + RequestStartTransactionResponse handleRequestStartTransactionRequest( + RequestStartTransactionRequest request); + + /** + * Handle a {@link RequestStopTransactionRequest} and return a {@link + * RequestStopTransactionResponse}. + * + * @param request incoming {@link RequestStopTransactionRequest} to handle. + * @return outgoing {@link RequestStopTransactionResponse} to reply with. + */ + RequestStopTransactionResponse handleRequestStopTransactionRequest( + RequestStopTransactionRequest request); + + /** + * Handle a {@link TriggerMessageRequest} and return a {@link TriggerMessageResponse}. + * + * @param request incoming {@link TriggerMessageRequest} to handle. + * @return outgoing {@link TriggerMessageResponse} to reply with. + */ + TriggerMessageResponse handleTriggerMessageRequest(TriggerMessageRequest request); + + /** + * Handle a {@link UnlockConnectorRequest} and return a {@link UnlockConnectorResponse}. + * + * @param request incoming {@link UnlockConnectorRequest} to handle. + * @return outgoing {@link UnlockConnectorResponse} to reply with. + */ + UnlockConnectorResponse handleUnlockConnectorRequest(UnlockConnectorRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientRemoteControlFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientRemoteControlFunction.java new file mode 100644 index 00000000..7f9872e2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientRemoteControlFunction.java @@ -0,0 +1,72 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the RemoteControl functional block. */ +public class ClientRemoteControlFunction implements Function { + + private final ClientRemoteControlEventHandler eventHandler; + private final ArrayList features; + + public ClientRemoteControlFunction(ClientRemoteControlEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new RequestStartTransactionFeature(this)); + features.add(new RequestStopTransactionFeature(this)); + features.add(new TriggerMessageFeature(this)); + features.add(new UnlockConnectorFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof RequestStartTransactionRequest) { + return eventHandler.handleRequestStartTransactionRequest( + (RequestStartTransactionRequest) request); + } else if (request instanceof RequestStopTransactionRequest) { + return eventHandler.handleRequestStopTransactionRequest( + (RequestStopTransactionRequest) request); + } else if (request instanceof TriggerMessageRequest) { + return eventHandler.handleTriggerMessageRequest((TriggerMessageRequest) request); + } else if (request instanceof UnlockConnectorRequest) { + return eventHandler.handleUnlockConnectorRequest((UnlockConnectorRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientReservationEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientReservationEventHandler.java new file mode 100644 index 00000000..df6a8b1d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientReservationEventHandler.java @@ -0,0 +1,46 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the Reservation functional block. */ +public interface ClientReservationEventHandler { + /** + * Handle a {@link CancelReservationRequest} and return a {@link CancelReservationResponse}. + * + * @param request incoming {@link CancelReservationRequest} to handle. + * @return outgoing {@link CancelReservationResponse} to reply with. + */ + CancelReservationResponse handleCancelReservationRequest(CancelReservationRequest request); + + /** + * Handle a {@link ReserveNowRequest} and return a {@link ReserveNowResponse}. + * + * @param request incoming {@link ReserveNowRequest} to handle. + * @return outgoing {@link ReserveNowResponse} to reply with. + */ + ReserveNowResponse handleReserveNowRequest(ReserveNowRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientReservationFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientReservationFunction.java new file mode 100644 index 00000000..f38c5a65 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientReservationFunction.java @@ -0,0 +1,77 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Reservation functional block. */ +public class ClientReservationFunction implements Function { + + private final ClientReservationEventHandler eventHandler; + private final ArrayList features; + + public ClientReservationFunction(ClientReservationEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CancelReservationFeature(this)); + features.add(new ReservationStatusUpdateFeature(null)); + features.add(new ReserveNowFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof CancelReservationRequest) { + return eventHandler.handleCancelReservationRequest((CancelReservationRequest) request); + } else if (request instanceof ReserveNowRequest) { + return eventHandler.handleReserveNowRequest((ReserveNowRequest) request); + } + return null; + } + + /** + * Create a client {@link ReservationStatusUpdateRequest} with all required fields. + * + * @param reservationId The ID of the reservation. + * @param reservationUpdateStatus The updated reservation status. + * @return an instance of {@link ReservationStatusUpdateRequest} + */ + public ReservationStatusUpdateRequest createReservationStatusUpdateRequest( + Integer reservationId, ReservationUpdateStatusEnum reservationUpdateStatus) { + return new ReservationStatusUpdateRequest(reservationId, reservationUpdateStatus); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSecurityEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSecurityEventHandler.java new file mode 100644 index 00000000..fdfb1f90 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSecurityEventHandler.java @@ -0,0 +1,46 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the Security functional block. */ +public interface ClientSecurityEventHandler { + /** + * Handle a {@link CertificateSignedRequest} and return a {@link CertificateSignedResponse}. + * + * @param request incoming {@link CertificateSignedRequest} to handle. + * @return outgoing {@link CertificateSignedResponse} to reply with. + */ + CertificateSignedResponse handleCertificateSignedRequest(CertificateSignedRequest request); + + /** + * Handle a {@link InstallCertificateRequest} and return a {@link InstallCertificateResponse}. + * + * @param request incoming {@link InstallCertificateRequest} to handle. + * @return outgoing {@link InstallCertificateResponse} to reply with. + */ + InstallCertificateResponse handleInstallCertificateRequest(InstallCertificateRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSecurityFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSecurityFunction.java new file mode 100644 index 00000000..1a3797fe --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSecurityFunction.java @@ -0,0 +1,92 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Security functional block. */ +public class ClientSecurityFunction implements Function { + + private final ClientSecurityEventHandler eventHandler; + private final ArrayList features; + + public ClientSecurityFunction(ClientSecurityEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CertificateSignedFeature(this)); + features.add(new InstallCertificateFeature(this)); + features.add(new SecurityEventNotificationFeature(null)); + features.add(new SignCertificateFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof CertificateSignedRequest) { + return eventHandler.handleCertificateSignedRequest((CertificateSignedRequest) request); + } else if (request instanceof InstallCertificateRequest) { + return eventHandler.handleInstallCertificateRequest((InstallCertificateRequest) request); + } + return null; + } + + /** + * Create a client {@link SecurityEventNotificationRequest} with all required fields. + * + * @param type Type of the security event. This value should be taken from the Security events + * list. + * @param timestamp Date and time at which the event occurred. + * @return an instance of {@link SecurityEventNotificationRequest} + */ + public SecurityEventNotificationRequest createSecurityEventNotificationRequest( + String type, ZonedDateTime timestamp) { + return new SecurityEventNotificationRequest(type, timestamp); + } + + /** + * Create a client {@link SignCertificateRequest} with all required fields. + * + * @param csr The Charging Station SHALL send the public key in form of a Certificate Signing + * Request (CSR) as described in RFC 2986 [22] and then PEM encoded, using the + * SignCertificateRequest message. + * @return an instance of {@link SignCertificateRequest} + */ + public SignCertificateRequest createSignCertificateRequest(String csr) { + return new SignCertificateRequest(csr); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSmartChargingEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSmartChargingEventHandler.java new file mode 100644 index 00000000..2a431436 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSmartChargingEventHandler.java @@ -0,0 +1,82 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the SmartCharging functional block. */ +public interface ClientSmartChargingEventHandler { + /** + * Handle a {@link ClearChargingProfileRequest} and return a {@link ClearChargingProfileResponse}. + * + * @param request incoming {@link ClearChargingProfileRequest} to handle. + * @return outgoing {@link ClearChargingProfileResponse} to reply with. + */ + ClearChargingProfileResponse handleClearChargingProfileRequest( + ClearChargingProfileRequest request); + + /** + * Handle a {@link GetChargingProfilesRequest} and return a {@link GetChargingProfilesResponse}. + * + * @param request incoming {@link GetChargingProfilesRequest} to handle. + * @return outgoing {@link GetChargingProfilesResponse} to reply with. + */ + GetChargingProfilesResponse handleGetChargingProfilesRequest(GetChargingProfilesRequest request); + + /** + * Handle a {@link GetCompositeScheduleRequest} and return a {@link GetCompositeScheduleResponse}. + * + * @param request incoming {@link GetCompositeScheduleRequest} to handle. + * @return outgoing {@link GetCompositeScheduleResponse} to reply with. + */ + GetCompositeScheduleResponse handleGetCompositeScheduleRequest( + GetCompositeScheduleRequest request); + + /** + * Handle a {@link SetChargingProfileRequest} and return a {@link SetChargingProfileResponse}. + * + * @param request incoming {@link SetChargingProfileRequest} to handle. + * @return outgoing {@link SetChargingProfileResponse} to reply with. + */ + SetChargingProfileResponse handleSetChargingProfileRequest(SetChargingProfileRequest request); + + /** + * Handle a {@link UpdateDynamicScheduleRequest} and return a {@link + * UpdateDynamicScheduleResponse}. + * + * @param request incoming {@link UpdateDynamicScheduleRequest} to handle. + * @return outgoing {@link UpdateDynamicScheduleResponse} to reply with. + */ + UpdateDynamicScheduleResponse handleUpdateDynamicScheduleRequest( + UpdateDynamicScheduleRequest request); + + /** + * Handle a {@link UsePriorityChargingRequest} and return a {@link UsePriorityChargingResponse}. + * + * @param request incoming {@link UsePriorityChargingRequest} to handle. + * @return outgoing {@link UsePriorityChargingResponse} to reply with. + */ + UsePriorityChargingResponse handleUsePriorityChargingRequest(UsePriorityChargingRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSmartChargingFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSmartChargingFunction.java new file mode 100644 index 00000000..029db1cf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientSmartChargingFunction.java @@ -0,0 +1,183 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the SmartCharging functional block. */ +public class ClientSmartChargingFunction implements Function { + + private final ClientSmartChargingEventHandler eventHandler; + private final ArrayList features; + + public ClientSmartChargingFunction(ClientSmartChargingEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearChargingProfileFeature(this)); + features.add(new ClearedChargingLimitFeature(null)); + features.add(new GetChargingProfilesFeature(this)); + features.add(new GetCompositeScheduleFeature(this)); + features.add(new NotifyChargingLimitFeature(null)); + features.add(new NotifyEVChargingNeedsFeature(null)); + features.add(new NotifyEVChargingScheduleFeature(null)); + features.add(new NotifyPriorityChargingFeature(null)); + features.add(new PullDynamicScheduleUpdateFeature(null)); + features.add(new ReportChargingProfilesFeature(null)); + features.add(new SetChargingProfileFeature(this)); + features.add(new UpdateDynamicScheduleFeature(this)); + features.add(new UsePriorityChargingFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearChargingProfileRequest) { + return eventHandler.handleClearChargingProfileRequest((ClearChargingProfileRequest) request); + } else if (request instanceof GetChargingProfilesRequest) { + return eventHandler.handleGetChargingProfilesRequest((GetChargingProfilesRequest) request); + } else if (request instanceof GetCompositeScheduleRequest) { + return eventHandler.handleGetCompositeScheduleRequest((GetCompositeScheduleRequest) request); + } else if (request instanceof SetChargingProfileRequest) { + return eventHandler.handleSetChargingProfileRequest((SetChargingProfileRequest) request); + } else if (request instanceof UpdateDynamicScheduleRequest) { + return eventHandler.handleUpdateDynamicScheduleRequest( + (UpdateDynamicScheduleRequest) request); + } else if (request instanceof UsePriorityChargingRequest) { + return eventHandler.handleUsePriorityChargingRequest((UsePriorityChargingRequest) request); + } + return null; + } + + /** + * Create a client {@link ClearedChargingLimitRequest} with all required fields. + * + * @param chargingLimitSource Source of the charging limit. Allowed values defined in Appendix as + * ChargingLimitSourceEnumStringType. + * @return an instance of {@link ClearedChargingLimitRequest} + */ + public ClearedChargingLimitRequest createClearedChargingLimitRequest(String chargingLimitSource) { + return new ClearedChargingLimitRequest(chargingLimitSource); + } + + /** + * Create a client {@link NotifyChargingLimitRequest} with all required fields. + * + * @param chargingLimit chargingLimit + * @return an instance of {@link NotifyChargingLimitRequest} + */ + public NotifyChargingLimitRequest createNotifyChargingLimitRequest(ChargingLimit chargingLimit) { + return new NotifyChargingLimitRequest(chargingLimit); + } + + /** + * Create a client {@link NotifyEVChargingNeedsRequest} with all required fields. + * + * @param evseId The EVSE and connector to which the EV is connected. EvseId may not be 0. + * @param chargingNeeds chargingNeeds + * @return an instance of {@link NotifyEVChargingNeedsRequest} + */ + public NotifyEVChargingNeedsRequest createNotifyEVChargingNeedsRequest( + Integer evseId, ChargingNeeds chargingNeeds) { + return new NotifyEVChargingNeedsRequest(evseId, chargingNeeds); + } + + /** + * Create a client {@link NotifyEVChargingScheduleRequest} with all required fields. + * + * @param timeBase Periods contained in the charging profile are relative to this point in time. + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * @param evseId The charging schedule contained in this notification applies to an EVSE. EvseId + * must be greater than 0. + * @return an instance of {@link NotifyEVChargingScheduleRequest} + */ + public NotifyEVChargingScheduleRequest createNotifyEVChargingScheduleRequest( + ZonedDateTime timeBase, ChargingSchedule chargingSchedule, Integer evseId) { + return new NotifyEVChargingScheduleRequest(timeBase, chargingSchedule, evseId); + } + + /** + * Create a client {@link NotifyPriorityChargingRequest} with all required fields. + * + * @param transactionId The transaction for which priority charging is requested. + * @param activated True if priority charging was activated. False if it has stopped using the + * priority charging profile. + * @return an instance of {@link NotifyPriorityChargingRequest} + */ + public NotifyPriorityChargingRequest createNotifyPriorityChargingRequest( + String transactionId, Boolean activated) { + return new NotifyPriorityChargingRequest(transactionId, activated); + } + + /** + * Create a client {@link PullDynamicScheduleUpdateRequest} with all required fields. + * + * @param chargingProfileId Id of charging profile to update. + * @return an instance of {@link PullDynamicScheduleUpdateRequest} + */ + public PullDynamicScheduleUpdateRequest createPullDynamicScheduleUpdateRequest( + Integer chargingProfileId) { + return new PullDynamicScheduleUpdateRequest(chargingProfileId); + } + + /** + * Create a client {@link ReportChargingProfilesRequest} with all required fields. + * + * @param requestId Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + * @param chargingLimitSource Source that has installed this charging profile. Values defined in + * Appendix as ChargingLimitSourceEnumStringType. + * @param chargingProfile A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval. + * @param evseId The evse to which the charging profile applies. If evseId = 0, the message + * contains an overall limit for the Charging Station. + * @return an instance of {@link ReportChargingProfilesRequest} + */ + public ReportChargingProfilesRequest createReportChargingProfilesRequest( + Integer requestId, + String chargingLimitSource, + ChargingProfile[] chargingProfile, + Integer evseId) { + return new ReportChargingProfilesRequest( + requestId, chargingLimitSource, chargingProfile, evseId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTariffAndCostEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTariffAndCostEventHandler.java new file mode 100644 index 00000000..b2740c75 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTariffAndCostEventHandler.java @@ -0,0 +1,72 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the TariffAndCost functional block. */ +public interface ClientTariffAndCostEventHandler { + /** + * Handle a {@link ChangeTransactionTariffRequest} and return a {@link + * ChangeTransactionTariffResponse}. + * + * @param request incoming {@link ChangeTransactionTariffRequest} to handle. + * @return outgoing {@link ChangeTransactionTariffResponse} to reply with. + */ + ChangeTransactionTariffResponse handleChangeTransactionTariffRequest( + ChangeTransactionTariffRequest request); + + /** + * Handle a {@link ClearTariffsRequest} and return a {@link ClearTariffsResponse}. + * + * @param request incoming {@link ClearTariffsRequest} to handle. + * @return outgoing {@link ClearTariffsResponse} to reply with. + */ + ClearTariffsResponse handleClearTariffsRequest(ClearTariffsRequest request); + + /** + * Handle a {@link CostUpdatedRequest} and return a {@link CostUpdatedResponse}. + * + * @param request incoming {@link CostUpdatedRequest} to handle. + * @return outgoing {@link CostUpdatedResponse} to reply with. + */ + CostUpdatedResponse handleCostUpdatedRequest(CostUpdatedRequest request); + + /** + * Handle a {@link GetTariffsRequest} and return a {@link GetTariffsResponse}. + * + * @param request incoming {@link GetTariffsRequest} to handle. + * @return outgoing {@link GetTariffsResponse} to reply with. + */ + GetTariffsResponse handleGetTariffsRequest(GetTariffsRequest request); + + /** + * Handle a {@link SetDefaultTariffRequest} and return a {@link SetDefaultTariffResponse}. + * + * @param request incoming {@link SetDefaultTariffRequest} to handle. + * @return outgoing {@link SetDefaultTariffResponse} to reply with. + */ + SetDefaultTariffResponse handleSetDefaultTariffRequest(SetDefaultTariffRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTariffAndCostFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTariffAndCostFunction.java new file mode 100644 index 00000000..408a4034 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTariffAndCostFunction.java @@ -0,0 +1,74 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the TariffAndCost functional block. */ +public class ClientTariffAndCostFunction implements Function { + + private final ClientTariffAndCostEventHandler eventHandler; + private final ArrayList features; + + public ClientTariffAndCostFunction(ClientTariffAndCostEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ChangeTransactionTariffFeature(this)); + features.add(new ClearTariffsFeature(this)); + features.add(new CostUpdatedFeature(this)); + features.add(new GetTariffsFeature(this)); + features.add(new SetDefaultTariffFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ChangeTransactionTariffRequest) { + return eventHandler.handleChangeTransactionTariffRequest( + (ChangeTransactionTariffRequest) request); + } else if (request instanceof ClearTariffsRequest) { + return eventHandler.handleClearTariffsRequest((ClearTariffsRequest) request); + } else if (request instanceof CostUpdatedRequest) { + return eventHandler.handleCostUpdatedRequest((CostUpdatedRequest) request); + } else if (request instanceof GetTariffsRequest) { + return eventHandler.handleGetTariffsRequest((GetTariffsRequest) request); + } else if (request instanceof SetDefaultTariffRequest) { + return eventHandler.handleSetDefaultTariffRequest((SetDefaultTariffRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTransactionsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTransactionsEventHandler.java new file mode 100644 index 00000000..e4cb0f16 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTransactionsEventHandler.java @@ -0,0 +1,39 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; + +/** Call back handler for client events of the Transactions functional block. */ +public interface ClientTransactionsEventHandler { + /** + * Handle a {@link GetTransactionStatusRequest} and return a {@link GetTransactionStatusResponse}. + * + * @param request incoming {@link GetTransactionStatusRequest} to handle. + * @return outgoing {@link GetTransactionStatusResponse} to reply with. + */ + GetTransactionStatusResponse handleGetTransactionStatusRequest( + GetTransactionStatusRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTransactionsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTransactionsFunction.java new file mode 100644 index 00000000..a9497a02 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientTransactionsFunction.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Transactions functional block. */ +public class ClientTransactionsFunction implements Function { + + private final ClientTransactionsEventHandler eventHandler; + private final ArrayList features; + + public ClientTransactionsFunction(ClientTransactionsEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new BatterySwapFeature(null)); + features.add(new GetTransactionStatusFeature(this)); + features.add(new RequestBatterySwapFeature(null)); + features.add(new TransactionEventFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof GetTransactionStatusRequest) { + return eventHandler.handleGetTransactionStatusRequest((GetTransactionStatusRequest) request); + } + return null; + } + + /** + * Create a client {@link BatterySwapRequest} with all required fields. + * + * @param batteryData batteryData + * @param eventType Battery in/out + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @param requestId RequestId to correlate BatteryIn/Out events and optional + * RequestBatterySwapRequest. + * @return an instance of {@link BatterySwapRequest} + */ + public BatterySwapRequest createBatterySwapRequest( + BatteryData[] batteryData, + BatterySwapEventEnum eventType, + IdToken idToken, + Integer requestId) { + return new BatterySwapRequest(batteryData, eventType, idToken, requestId); + } + + /** + * Create a client {@link RequestBatterySwapRequest} with all required fields. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @param requestId Request id to match with BatterySwapRequest. + * @return an instance of {@link RequestBatterySwapRequest} + */ + public RequestBatterySwapRequest createRequestBatterySwapRequest( + IdToken idToken, Integer requestId) { + return new RequestBatterySwapRequest(idToken, requestId); + } + + /** + * Create a client {@link TransactionEventRequest} with all required fields. + * + * @param eventType The type of this event. The first TransactionEvent of a transaction SHALL + * contain: "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All + * others SHALL contain: "Updated" + * @param timestamp The date and time at which this transaction event occurred. + * @param triggerReason Reason the Charging Station sends this message to the CSMS + * @param seqNo Incremental sequence number, helps with determining if all messages of a + * transaction have been received. + * @param transactionInfo transactionInfo + * @return an instance of {@link TransactionEventRequest} + */ + public TransactionEventRequest createTransactionEventRequest( + TransactionEventEnum eventType, + ZonedDateTime timestamp, + TriggerReasonEnum triggerReason, + Integer seqNo, + Transaction transactionInfo) { + return new TransactionEventRequest(eventType, timestamp, triggerReason, seqNo, transactionInfo); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAuthorizationEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAuthorizationEventHandler.java new file mode 100644 index 00000000..3cafaca4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAuthorizationEventHandler.java @@ -0,0 +1,60 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Authorization functional block. */ +public interface ServerAuthorizationEventHandler { + /** + * Handle a {@link AuthorizeRequest} and return a {@link AuthorizeResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link AuthorizeRequest} to handle. + * @return outgoing {@link AuthorizeResponse} to reply with. + */ + AuthorizeResponse handleAuthorizeRequest(UUID sessionIndex, AuthorizeRequest request); + + /** + * Handle a {@link NotifySettlementRequest} and return a {@link NotifySettlementResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifySettlementRequest} to handle. + * @return outgoing {@link NotifySettlementResponse} to reply with. + */ + NotifySettlementResponse handleNotifySettlementRequest( + UUID sessionIndex, NotifySettlementRequest request); + + /** + * Handle a {@link VatNumberValidationRequest} and return a {@link VatNumberValidationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link VatNumberValidationRequest} to handle. + * @return outgoing {@link VatNumberValidationResponse} to reply with. + */ + VatNumberValidationResponse handleVatNumberValidationRequest( + UUID sessionIndex, VatNumberValidationRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAuthorizationFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAuthorizationFunction.java new file mode 100644 index 00000000..709a6204 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAuthorizationFunction.java @@ -0,0 +1,93 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Authorization functional block. */ +public class ServerAuthorizationFunction implements Function { + + private final ServerAuthorizationEventHandler eventHandler; + private final ArrayList features; + + public ServerAuthorizationFunction(ServerAuthorizationEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new AuthorizeFeature(this)); + features.add(new ClearCacheFeature(null)); + features.add(new NotifySettlementFeature(this)); + features.add(new NotifyWebPaymentStartedFeature(null)); + features.add(new VatNumberValidationFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof AuthorizeRequest) { + return eventHandler.handleAuthorizeRequest(sessionIndex, (AuthorizeRequest) request); + } else if (request instanceof NotifySettlementRequest) { + return eventHandler.handleNotifySettlementRequest( + sessionIndex, (NotifySettlementRequest) request); + } else if (request instanceof VatNumberValidationRequest) { + return eventHandler.handleVatNumberValidationRequest( + sessionIndex, (VatNumberValidationRequest) request); + } + return null; + } + + /** + * Create a server {@link ClearCacheRequest}. + * + * @return an instance of {@link ClearCacheRequest} + */ + public ClearCacheRequest createClearCacheRequest() { + return new ClearCacheRequest(); + } + + /** + * Create a server {@link NotifyWebPaymentStartedRequest} with all required fields. + * + * @param evseId EVSE id for which transaction is requested. + * @param timeout Timeout value in seconds after which no result of web payment process (e.g. QR + * code scanning) is to be expected anymore. + * @return an instance of {@link NotifyWebPaymentStartedRequest} + */ + public NotifyWebPaymentStartedRequest createNotifyWebPaymentStartedRequest( + Integer evseId, Integer timeout) { + return new NotifyWebPaymentStartedRequest(evseId, timeout); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAvailabilityEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAvailabilityEventHandler.java new file mode 100644 index 00000000..c7953b88 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAvailabilityEventHandler.java @@ -0,0 +1,50 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Availability functional block. */ +public interface ServerAvailabilityEventHandler { + /** + * Handle a {@link NotifyEventRequest} and return a {@link NotifyEventResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyEventRequest} to handle. + * @return outgoing {@link NotifyEventResponse} to reply with. + */ + NotifyEventResponse handleNotifyEventRequest(UUID sessionIndex, NotifyEventRequest request); + + /** + * Handle a {@link StatusNotificationRequest} and return a {@link StatusNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link StatusNotificationRequest} to handle. + * @return outgoing {@link StatusNotificationResponse} to reply with. + */ + StatusNotificationResponse handleStatusNotificationRequest( + UUID sessionIndex, StatusNotificationRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAvailabilityFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAvailabilityFunction.java new file mode 100644 index 00000000..a2e6f1b2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerAvailabilityFunction.java @@ -0,0 +1,78 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Availability functional block. */ +public class ServerAvailabilityFunction implements Function { + + private final ServerAvailabilityEventHandler eventHandler; + private final ArrayList features; + + public ServerAvailabilityFunction(ServerAvailabilityEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ChangeAvailabilityFeature(null)); + features.add(new NotifyEventFeature(this)); + features.add(new StatusNotificationFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof NotifyEventRequest) { + return eventHandler.handleNotifyEventRequest(sessionIndex, (NotifyEventRequest) request); + } else if (request instanceof StatusNotificationRequest) { + return eventHandler.handleStatusNotificationRequest( + sessionIndex, (StatusNotificationRequest) request); + } + return null; + } + + /** + * Create a server {@link ChangeAvailabilityRequest} with all required fields. + * + * @param operationalStatus The type of availability change that the Charging Station should + * perform. + * @return an instance of {@link ChangeAvailabilityRequest} + */ + public ChangeAvailabilityRequest createChangeAvailabilityRequest( + OperationalStatusEnum operationalStatus) { + return new ChangeAvailabilityRequest(operationalStatus); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerBidirectionalPowerTransferFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerBidirectionalPowerTransferFunction.java new file mode 100644 index 00000000..47101ffa --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerBidirectionalPowerTransferFunction.java @@ -0,0 +1,84 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with server request creators and handlers for the BidirectionalPowerTransfer functional + * block. + */ +public class ServerBidirectionalPowerTransferFunction implements Function { + + private final ArrayList features; + + public ServerBidirectionalPowerTransferFunction() { + features = new ArrayList<>(); + features.add(new AFRRSignalFeature(null)); + features.add(new NotifyAllowedEnergyTransferFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a server {@link AFRRSignalRequest} with all required fields. + * + * @param timestamp Time when signal becomes active. + * @param signal Value of signal in v2xSignalWattCurve. + * @return an instance of {@link AFRRSignalRequest} + */ + public AFRRSignalRequest createAFRRSignalRequest(ZonedDateTime timestamp, Integer signal) { + return new AFRRSignalRequest(timestamp, signal); + } + + /** + * Create a server {@link NotifyAllowedEnergyTransferRequest} with all required fields. + * + * @param transactionId The transaction for which the allowed energy transfer is allowed. + * @param allowedEnergyTransfer Modes of energy transfer that are accepted by CSMS. + * @return an instance of {@link NotifyAllowedEnergyTransferRequest} + */ + public NotifyAllowedEnergyTransferRequest createNotifyAllowedEnergyTransferRequest( + String transactionId, EnergyTransferModeEnum[] allowedEnergyTransfer) { + return new NotifyAllowedEnergyTransferRequest(transactionId, allowedEnergyTransfer); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDERControlEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDERControlEventHandler.java new file mode 100644 index 00000000..875b053b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDERControlEventHandler.java @@ -0,0 +1,51 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the DERControl functional block. */ +public interface ServerDERControlEventHandler { + /** + * Handle a {@link NotifyDERAlarmRequest} and return a {@link NotifyDERAlarmResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyDERAlarmRequest} to handle. + * @return outgoing {@link NotifyDERAlarmResponse} to reply with. + */ + NotifyDERAlarmResponse handleNotifyDERAlarmRequest( + UUID sessionIndex, NotifyDERAlarmRequest request); + + /** + * Handle a {@link NotifyDERStartStopRequest} and return a {@link NotifyDERStartStopResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyDERStartStopRequest} to handle. + * @return outgoing {@link NotifyDERStartStopResponse} to reply with. + */ + NotifyDERStartStopResponse handleNotifyDERStartStopRequest( + UUID sessionIndex, NotifyDERStartStopRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDERControlFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDERControlFunction.java new file mode 100644 index 00000000..5614d63e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDERControlFunction.java @@ -0,0 +1,113 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the DERControl functional block. */ +public class ServerDERControlFunction implements Function { + + private final ServerDERControlEventHandler eventHandler; + private final ArrayList features; + + public ServerDERControlFunction(ServerDERControlEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearDERControlFeature(null)); + features.add(new GetDERControlFeature(null)); + features.add(new NotifyDERAlarmFeature(this)); + features.add(new NotifyDERStartStopFeature(this)); + features.add(new ReportDERControlFeature(null)); + features.add(new SetDERControlFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof NotifyDERAlarmRequest) { + return eventHandler.handleNotifyDERAlarmRequest( + sessionIndex, (NotifyDERAlarmRequest) request); + } else if (request instanceof NotifyDERStartStopRequest) { + return eventHandler.handleNotifyDERStartStopRequest( + sessionIndex, (NotifyDERStartStopRequest) request); + } + return null; + } + + /** + * Create a server {@link ClearDERControlRequest} with all required fields. + * + * @param isDefault True: clearing default DER controls. False: clearing scheduled controls. + * @return an instance of {@link ClearDERControlRequest} + */ + public ClearDERControlRequest createClearDERControlRequest(Boolean isDefault) { + return new ClearDERControlRequest(isDefault); + } + + /** + * Create a server {@link GetDERControlRequest} with all required fields. + * + * @param requestId RequestId to be used in ReportDERControlRequest. + * @return an instance of {@link GetDERControlRequest} + */ + public GetDERControlRequest createGetDERControlRequest(Integer requestId) { + return new GetDERControlRequest(requestId); + } + + /** + * Create a server {@link ReportDERControlRequest} with all required fields. + * + * @param requestId RequestId from GetDERControlRequest. + * @return an instance of {@link ReportDERControlRequest} + */ + public ReportDERControlRequest createReportDERControlRequest(Integer requestId) { + return new ReportDERControlRequest(requestId); + } + + /** + * Create a server {@link SetDERControlRequest} with all required fields. + * + * @param isDefault True if this is a default DER control + * @param controlId Unique id of this control, e.g. UUID + * @param controlType Type of control. Determines which setting field below is used. + * @return an instance of {@link SetDERControlRequest} + */ + public SetDERControlRequest createSetDERControlRequest( + Boolean isDefault, String controlId, DERControlEnum controlType) { + return new SetDERControlRequest(isDefault, controlId, controlType); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDataTransferEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDataTransferEventHandler.java new file mode 100644 index 00000000..91d34d1b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDataTransferEventHandler.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the DataTransfer functional block. */ +public interface ServerDataTransferEventHandler { + /** + * Handle a {@link DataTransferRequest} and return a {@link DataTransferResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link DataTransferRequest} to handle. + * @return outgoing {@link DataTransferResponse} to reply with. + */ + DataTransferResponse handleDataTransferRequest(UUID sessionIndex, DataTransferRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDataTransferFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDataTransferFunction.java new file mode 100644 index 00000000..77750136 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDataTransferFunction.java @@ -0,0 +1,71 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the DataTransfer functional block. */ +public class ServerDataTransferFunction implements Function { + + private final ServerDataTransferEventHandler eventHandler; + private final ArrayList features; + + public ServerDataTransferFunction(ServerDataTransferEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new DataTransferFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof DataTransferRequest) { + return eventHandler.handleDataTransferRequest(sessionIndex, (DataTransferRequest) request); + } + return null; + } + + /** + * Create a server {@link DataTransferRequest} with all required fields. + * + * @param vendorId The identifier of the Vendor specific implementation + * @return an instance of {@link DataTransferRequest} + */ + public DataTransferRequest createDataTransferRequest(String vendorId) { + return new DataTransferRequest(vendorId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsEventHandler.java new file mode 100644 index 00000000..95e71fb2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsEventHandler.java @@ -0,0 +1,75 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Diagnostics functional block. */ +public interface ServerDiagnosticsEventHandler { + /** + * Handle a {@link LogStatusNotificationRequest} and return a {@link + * LogStatusNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link LogStatusNotificationRequest} to handle. + * @return outgoing {@link LogStatusNotificationResponse} to reply with. + */ + LogStatusNotificationResponse handleLogStatusNotificationRequest( + UUID sessionIndex, LogStatusNotificationRequest request); + + /** + * Handle a {@link NotifyCustomerInformationRequest} and return a {@link + * NotifyCustomerInformationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyCustomerInformationRequest} to handle. + * @return outgoing {@link NotifyCustomerInformationResponse} to reply with. + */ + NotifyCustomerInformationResponse handleNotifyCustomerInformationRequest( + UUID sessionIndex, NotifyCustomerInformationRequest request); + + /** + * Handle a {@link NotifyMonitoringReportRequest} and return a {@link + * NotifyMonitoringReportResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyMonitoringReportRequest} to handle. + * @return outgoing {@link NotifyMonitoringReportResponse} to reply with. + */ + NotifyMonitoringReportResponse handleNotifyMonitoringReportRequest( + UUID sessionIndex, NotifyMonitoringReportRequest request); + + /** + * Handle a {@link OpenPeriodicEventStreamRequest} and return a {@link + * OpenPeriodicEventStreamResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link OpenPeriodicEventStreamRequest} to handle. + * @return outgoing {@link OpenPeriodicEventStreamResponse} to reply with. + */ + OpenPeriodicEventStreamResponse handleOpenPeriodicEventStreamRequest( + UUID sessionIndex, OpenPeriodicEventStreamRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsFunction.java new file mode 100644 index 00000000..30f4d280 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsFunction.java @@ -0,0 +1,197 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Diagnostics functional block. */ +public class ServerDiagnosticsFunction implements Function { + + private final ServerDiagnosticsEventHandler eventHandler; + private final ArrayList features; + + public ServerDiagnosticsFunction(ServerDiagnosticsEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new AdjustPeriodicEventStreamFeature(null)); + features.add(new ClearVariableMonitoringFeature(null)); + features.add(new ClosePeriodicEventStreamFeature(null)); + features.add(new CustomerInformationFeature(null)); + features.add(new GetLogFeature(null)); + features.add(new GetMonitoringReportFeature(null)); + features.add(new GetPeriodicEventStreamFeature(null)); + features.add(new LogStatusNotificationFeature(this)); + features.add(new NotifyCustomerInformationFeature(this)); + features.add(new NotifyMonitoringReportFeature(this)); + features.add(new OpenPeriodicEventStreamFeature(this)); + features.add(new SetMonitoringBaseFeature(null)); + features.add(new SetMonitoringLevelFeature(null)); + features.add(new SetVariableMonitoringFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof LogStatusNotificationRequest) { + return eventHandler.handleLogStatusNotificationRequest( + sessionIndex, (LogStatusNotificationRequest) request); + } else if (request instanceof NotifyCustomerInformationRequest) { + return eventHandler.handleNotifyCustomerInformationRequest( + sessionIndex, (NotifyCustomerInformationRequest) request); + } else if (request instanceof NotifyMonitoringReportRequest) { + return eventHandler.handleNotifyMonitoringReportRequest( + sessionIndex, (NotifyMonitoringReportRequest) request); + } else if (request instanceof OpenPeriodicEventStreamRequest) { + return eventHandler.handleOpenPeriodicEventStreamRequest( + sessionIndex, (OpenPeriodicEventStreamRequest) request); + } + return null; + } + + /** + * Create a server {@link AdjustPeriodicEventStreamRequest} with all required fields. + * + * @param id id + * @param params params + * @return an instance of {@link AdjustPeriodicEventStreamRequest} + */ + public AdjustPeriodicEventStreamRequest createAdjustPeriodicEventStreamRequest( + Integer id, PeriodicEventStreamParams params) { + return new AdjustPeriodicEventStreamRequest(id, params); + } + + /** + * Create a server {@link ClearVariableMonitoringRequest} with all required fields. + * + * @param id List of the monitors to be cleared, identified by there Id. + * @return an instance of {@link ClearVariableMonitoringRequest} + */ + public ClearVariableMonitoringRequest createClearVariableMonitoringRequest(Integer[] id) { + return new ClearVariableMonitoringRequest(id); + } + + /** + * Create a server {@link ClosePeriodicEventStreamRequest} with all required fields. + * + * @param id Id of stream to close. + * @return an instance of {@link ClosePeriodicEventStreamRequest} + */ + public ClosePeriodicEventStreamRequest createClosePeriodicEventStreamRequest(Integer id) { + return new ClosePeriodicEventStreamRequest(id); + } + + /** + * Create a server {@link CustomerInformationRequest} with all required fields. + * + * @param requestId The Id of the request. + * @param report Flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer + * referred to. + * @param clear Flag indicating whether the Charging Station should clear all information about + * the customer referred to. + * @return an instance of {@link CustomerInformationRequest} + */ + public CustomerInformationRequest createCustomerInformationRequest( + Integer requestId, Boolean report, Boolean clear) { + return new CustomerInformationRequest(requestId, report, clear); + } + + /** + * Create a server {@link GetLogRequest} with all required fields. + * + * @param log Generic class for the configuration of logging entries. + * @param logType The type of log file that the Charging Station should send. + * @param requestId The Id of this request + * @return an instance of {@link GetLogRequest} + */ + public GetLogRequest createGetLogRequest(LogParameters log, LogEnum logType, Integer requestId) { + return new GetLogRequest(log, logType, requestId); + } + + /** + * Create a server {@link GetMonitoringReportRequest} with all required fields. + * + * @param requestId The Id of the request. + * @return an instance of {@link GetMonitoringReportRequest} + */ + public GetMonitoringReportRequest createGetMonitoringReportRequest(Integer requestId) { + return new GetMonitoringReportRequest(requestId); + } + + /** + * Create a server {@link GetPeriodicEventStreamRequest}. + * + * @return an instance of {@link GetPeriodicEventStreamRequest} + */ + public GetPeriodicEventStreamRequest createGetPeriodicEventStreamRequest() { + return new GetPeriodicEventStreamRequest(); + } + + /** + * Create a server {@link SetMonitoringBaseRequest} with all required fields. + * + * @param monitoringBase Specify which monitoring base will be set + * @return an instance of {@link SetMonitoringBaseRequest} + */ + public SetMonitoringBaseRequest createSetMonitoringBaseRequest( + MonitoringBaseEnum monitoringBase) { + return new SetMonitoringBaseRequest(monitoringBase); + } + + /** + * Create a server {@link SetMonitoringLevelRequest} with all required fields. + * + * @param severity The Charging Station SHALL only report events with a severity number lower than + * or equal to this severity. The severity range is 0-9, with 0 as the highest and 9 as the + * lowest severity level. + * @return an instance of {@link SetMonitoringLevelRequest} + */ + public SetMonitoringLevelRequest createSetMonitoringLevelRequest(Integer severity) { + return new SetMonitoringLevelRequest(severity); + } + + /** + * Create a server {@link SetVariableMonitoringRequest} with all required fields. + * + * @param setMonitoringData Class to hold parameters of SetVariableMonitoring request. + * @return an instance of {@link SetVariableMonitoringRequest} + */ + public SetVariableMonitoringRequest createSetVariableMonitoringRequest( + SetMonitoringData[] setMonitoringData) { + return new SetVariableMonitoringRequest(setMonitoringData); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDisplayMessageEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDisplayMessageEventHandler.java new file mode 100644 index 00000000..9dddba1a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDisplayMessageEventHandler.java @@ -0,0 +1,42 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the DisplayMessage functional block. */ +public interface ServerDisplayMessageEventHandler { + /** + * Handle a {@link NotifyDisplayMessagesRequest} and return a {@link + * NotifyDisplayMessagesResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyDisplayMessagesRequest} to handle. + * @return outgoing {@link NotifyDisplayMessagesResponse} to reply with. + */ + NotifyDisplayMessagesResponse handleNotifyDisplayMessagesRequest( + UUID sessionIndex, NotifyDisplayMessagesRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDisplayMessageFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDisplayMessageFunction.java new file mode 100644 index 00000000..63b7b5c0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDisplayMessageFunction.java @@ -0,0 +1,95 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the DisplayMessage functional block. */ +public class ServerDisplayMessageFunction implements Function { + + private final ServerDisplayMessageEventHandler eventHandler; + private final ArrayList features; + + public ServerDisplayMessageFunction(ServerDisplayMessageEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearDisplayMessageFeature(null)); + features.add(new GetDisplayMessagesFeature(null)); + features.add(new NotifyDisplayMessagesFeature(this)); + features.add(new SetDisplayMessageFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof NotifyDisplayMessagesRequest) { + return eventHandler.handleNotifyDisplayMessagesRequest( + sessionIndex, (NotifyDisplayMessagesRequest) request); + } + return null; + } + + /** + * Create a server {@link ClearDisplayMessageRequest} with all required fields. + * + * @param id Id of the message that SHALL be removed from the Charging Station. + * @return an instance of {@link ClearDisplayMessageRequest} + */ + public ClearDisplayMessageRequest createClearDisplayMessageRequest(Integer id) { + return new ClearDisplayMessageRequest(id); + } + + /** + * Create a server {@link GetDisplayMessagesRequest} with all required fields. + * + * @param requestId The Id of this request. + * @return an instance of {@link GetDisplayMessagesRequest} + */ + public GetDisplayMessagesRequest createGetDisplayMessagesRequest(Integer requestId) { + return new GetDisplayMessagesRequest(requestId); + } + + /** + * Create a server {@link SetDisplayMessageRequest} with all required fields. + * + * @param message Message details, for a message to be displayed on a Charging Station. + * @return an instance of {@link SetDisplayMessageRequest} + */ + public SetDisplayMessageRequest createSetDisplayMessageRequest(MessageInfo message) { + return new SetDisplayMessageRequest(message); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerFirmwareManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerFirmwareManagementEventHandler.java new file mode 100644 index 00000000..ca49c5ba --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerFirmwareManagementEventHandler.java @@ -0,0 +1,53 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the FirmwareManagement functional block. */ +public interface ServerFirmwareManagementEventHandler { + /** + * Handle a {@link FirmwareStatusNotificationRequest} and return a {@link + * FirmwareStatusNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link FirmwareStatusNotificationRequest} to handle. + * @return outgoing {@link FirmwareStatusNotificationResponse} to reply with. + */ + FirmwareStatusNotificationResponse handleFirmwareStatusNotificationRequest( + UUID sessionIndex, FirmwareStatusNotificationRequest request); + + /** + * Handle a {@link PublishFirmwareStatusNotificationRequest} and return a {@link + * PublishFirmwareStatusNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link PublishFirmwareStatusNotificationRequest} to handle. + * @return outgoing {@link PublishFirmwareStatusNotificationResponse} to reply with. + */ + PublishFirmwareStatusNotificationResponse handlePublishFirmwareStatusNotificationRequest( + UUID sessionIndex, PublishFirmwareStatusNotificationRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerFirmwareManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerFirmwareManagementFunction.java new file mode 100644 index 00000000..efa7c8ba --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerFirmwareManagementFunction.java @@ -0,0 +1,106 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the FirmwareManagement functional block. */ +public class ServerFirmwareManagementFunction implements Function { + + private final ServerFirmwareManagementEventHandler eventHandler; + private final ArrayList features; + + public ServerFirmwareManagementFunction(ServerFirmwareManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new FirmwareStatusNotificationFeature(this)); + features.add(new PublishFirmwareFeature(null)); + features.add(new PublishFirmwareStatusNotificationFeature(this)); + features.add(new UnpublishFirmwareFeature(null)); + features.add(new UpdateFirmwareFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof FirmwareStatusNotificationRequest) { + return eventHandler.handleFirmwareStatusNotificationRequest( + sessionIndex, (FirmwareStatusNotificationRequest) request); + } else if (request instanceof PublishFirmwareStatusNotificationRequest) { + return eventHandler.handlePublishFirmwareStatusNotificationRequest( + sessionIndex, (PublishFirmwareStatusNotificationRequest) request); + } + return null; + } + + /** + * Create a server {@link PublishFirmwareRequest} with all required fields. + * + * @param location A string containing a URI pointing to a location from which to retrieve the + * firmware. + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32. + * @param requestId The Id of the request. + * @return an instance of {@link PublishFirmwareRequest} + */ + public PublishFirmwareRequest createPublishFirmwareRequest( + String location, String checksum, Integer requestId) { + return new PublishFirmwareRequest(location, checksum, requestId); + } + + /** + * Create a server {@link UnpublishFirmwareRequest} with all required fields. + * + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32. + * @return an instance of {@link UnpublishFirmwareRequest} + */ + public UnpublishFirmwareRequest createUnpublishFirmwareRequest(String checksum) { + return new UnpublishFirmwareRequest(checksum); + } + + /** + * Create a server {@link UpdateFirmwareRequest} with all required fields. + * + * @param requestId The Id of this request + * @param firmware A copy of the firmware that can be loaded/updated on the Charging Station. + * @return an instance of {@link UpdateFirmwareRequest} + */ + public UpdateFirmwareRequest createUpdateFirmwareRequest(Integer requestId, Firmware firmware) { + return new UpdateFirmwareRequest(requestId, firmware); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerISO15118CertificateManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerISO15118CertificateManagementEventHandler.java new file mode 100644 index 00000000..e6272ada --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerISO15118CertificateManagementEventHandler.java @@ -0,0 +1,63 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the ISO15118CertificateManagement functional block. */ +public interface ServerISO15118CertificateManagementEventHandler { + /** + * Handle a {@link Get15118EVCertificateRequest} and return a {@link + * Get15118EVCertificateResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link Get15118EVCertificateRequest} to handle. + * @return outgoing {@link Get15118EVCertificateResponse} to reply with. + */ + Get15118EVCertificateResponse handleGet15118EVCertificateRequest( + UUID sessionIndex, Get15118EVCertificateRequest request); + + /** + * Handle a {@link GetCertificateChainStatusRequest} and return a {@link + * GetCertificateChainStatusResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link GetCertificateChainStatusRequest} to handle. + * @return outgoing {@link GetCertificateChainStatusResponse} to reply with. + */ + GetCertificateChainStatusResponse handleGetCertificateChainStatusRequest( + UUID sessionIndex, GetCertificateChainStatusRequest request); + + /** + * Handle a {@link GetCertificateStatusRequest} and return a {@link GetCertificateStatusResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link GetCertificateStatusRequest} to handle. + * @return outgoing {@link GetCertificateStatusResponse} to reply with. + */ + GetCertificateStatusResponse handleGetCertificateStatusRequest( + UUID sessionIndex, GetCertificateStatusRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerISO15118CertificateManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerISO15118CertificateManagementFunction.java new file mode 100644 index 00000000..63bc3487 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerISO15118CertificateManagementFunction.java @@ -0,0 +1,96 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with server request creators and handlers for the ISO15118CertificateManagement functional + * block. + */ +public class ServerISO15118CertificateManagementFunction implements Function { + + private final ServerISO15118CertificateManagementEventHandler eventHandler; + private final ArrayList features; + + public ServerISO15118CertificateManagementFunction( + ServerISO15118CertificateManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new DeleteCertificateFeature(null)); + features.add(new Get15118EVCertificateFeature(this)); + features.add(new GetCertificateChainStatusFeature(this)); + features.add(new GetCertificateStatusFeature(this)); + features.add(new GetInstalledCertificateIdsFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof Get15118EVCertificateRequest) { + return eventHandler.handleGet15118EVCertificateRequest( + sessionIndex, (Get15118EVCertificateRequest) request); + } else if (request instanceof GetCertificateChainStatusRequest) { + return eventHandler.handleGetCertificateChainStatusRequest( + sessionIndex, (GetCertificateChainStatusRequest) request); + } else if (request instanceof GetCertificateStatusRequest) { + return eventHandler.handleGetCertificateStatusRequest( + sessionIndex, (GetCertificateStatusRequest) request); + } + return null; + } + + /** + * Create a server {@link DeleteCertificateRequest} with all required fields. + * + * @param certificateHashData certificateHashData + * @return an instance of {@link DeleteCertificateRequest} + */ + public DeleteCertificateRequest createDeleteCertificateRequest( + CertificateHashData certificateHashData) { + return new DeleteCertificateRequest(certificateHashData); + } + + /** + * Create a server {@link GetInstalledCertificateIdsRequest}. + * + * @return an instance of {@link GetInstalledCertificateIdsRequest} + */ + public GetInstalledCertificateIdsRequest createGetInstalledCertificateIdsRequest() { + return new GetInstalledCertificateIdsRequest(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerLocalAuthorizationListManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerLocalAuthorizationListManagementFunction.java new file mode 100644 index 00000000..ce9ed857 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerLocalAuthorizationListManagementFunction.java @@ -0,0 +1,83 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with server request creators and handlers for the LocalAuthorizationListManagement + * functional block. + */ +public class ServerLocalAuthorizationListManagementFunction implements Function { + + private final ArrayList features; + + public ServerLocalAuthorizationListManagementFunction() { + features = new ArrayList<>(); + features.add(new GetLocalListVersionFeature(null)); + features.add(new SendLocalListFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a server {@link GetLocalListVersionRequest}. + * + * @return an instance of {@link GetLocalListVersionRequest} + */ + public GetLocalListVersionRequest createGetLocalListVersionRequest() { + return new GetLocalListVersionRequest(); + } + + /** + * Create a server {@link SendLocalListRequest} with all required fields. + * + * @param versionNumber In case of a full update this is the version number of the full list. In + * case of a differential update it is the version number of the list after the update has + * been applied. + * @param updateType The type of update (full or differential) of this request. + * @return an instance of {@link SendLocalListRequest} + */ + public SendLocalListRequest createSendLocalListRequest( + Integer versionNumber, UpdateEnum updateType) { + return new SendLocalListRequest(versionNumber, updateType); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerMeterValuesEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerMeterValuesEventHandler.java new file mode 100644 index 00000000..45225d06 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerMeterValuesEventHandler.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the MeterValues functional block. */ +public interface ServerMeterValuesEventHandler { + /** + * Handle a {@link MeterValuesRequest} and return a {@link MeterValuesResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link MeterValuesRequest} to handle. + * @return outgoing {@link MeterValuesResponse} to reply with. + */ + MeterValuesResponse handleMeterValuesRequest(UUID sessionIndex, MeterValuesRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerMeterValuesFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerMeterValuesFunction.java new file mode 100644 index 00000000..9bc76052 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerMeterValuesFunction.java @@ -0,0 +1,61 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the MeterValues functional block. */ +public class ServerMeterValuesFunction implements Function { + + private final ServerMeterValuesEventHandler eventHandler; + private final ArrayList features; + + public ServerMeterValuesFunction(ServerMeterValuesEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new MeterValuesFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof MeterValuesRequest) { + return eventHandler.handleMeterValuesRequest(sessionIndex, (MeterValuesRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerProvisioningEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerProvisioningEventHandler.java new file mode 100644 index 00000000..23295a09 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerProvisioningEventHandler.java @@ -0,0 +1,59 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Provisioning functional block. */ +public interface ServerProvisioningEventHandler { + /** + * Handle a {@link BootNotificationRequest} and return a {@link BootNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link BootNotificationRequest} to handle. + * @return outgoing {@link BootNotificationResponse} to reply with. + */ + BootNotificationResponse handleBootNotificationRequest( + UUID sessionIndex, BootNotificationRequest request); + + /** + * Handle a {@link HeartbeatRequest} and return a {@link HeartbeatResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link HeartbeatRequest} to handle. + * @return outgoing {@link HeartbeatResponse} to reply with. + */ + HeartbeatResponse handleHeartbeatRequest(UUID sessionIndex, HeartbeatRequest request); + + /** + * Handle a {@link NotifyReportRequest} and return a {@link NotifyReportResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyReportRequest} to handle. + * @return outgoing {@link NotifyReportResponse} to reply with. + */ + NotifyReportResponse handleNotifyReportRequest(UUID sessionIndex, NotifyReportRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerProvisioningFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerProvisioningFunction.java new file mode 100644 index 00000000..846edf91 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerProvisioningFunction.java @@ -0,0 +1,139 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Provisioning functional block. */ +public class ServerProvisioningFunction implements Function { + + private final ServerProvisioningEventHandler eventHandler; + private final ArrayList features; + + public ServerProvisioningFunction(ServerProvisioningEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new BootNotificationFeature(this)); + features.add(new GetBaseReportFeature(null)); + features.add(new GetReportFeature(null)); + features.add(new GetVariablesFeature(null)); + features.add(new HeartbeatFeature(this)); + features.add(new NotifyReportFeature(this)); + features.add(new ResetFeature(null)); + features.add(new SetNetworkProfileFeature(null)); + features.add(new SetVariablesFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof BootNotificationRequest) { + return eventHandler.handleBootNotificationRequest( + sessionIndex, (BootNotificationRequest) request); + } else if (request instanceof HeartbeatRequest) { + return eventHandler.handleHeartbeatRequest(sessionIndex, (HeartbeatRequest) request); + } else if (request instanceof NotifyReportRequest) { + return eventHandler.handleNotifyReportRequest(sessionIndex, (NotifyReportRequest) request); + } + return null; + } + + /** + * Create a server {@link GetBaseReportRequest} with all required fields. + * + * @param requestId The Id of the request. + * @param reportBase The report base. + * @return an instance of {@link GetBaseReportRequest} + */ + public GetBaseReportRequest createGetBaseReportRequest( + Integer requestId, ReportBaseEnum reportBase) { + return new GetBaseReportRequest(requestId, reportBase); + } + + /** + * Create a server {@link GetReportRequest} with all required fields. + * + * @param requestId The Id of the request. + * @return an instance of {@link GetReportRequest} + */ + public GetReportRequest createGetReportRequest(Integer requestId) { + return new GetReportRequest(requestId); + } + + /** + * Create a server {@link GetVariablesRequest} with all required fields. + * + * @param getVariableData Class to hold parameters for GetVariables request. + * @return an instance of {@link GetVariablesRequest} + */ + public GetVariablesRequest createGetVariablesRequest(GetVariableData[] getVariableData) { + return new GetVariablesRequest(getVariableData); + } + + /** + * Create a server {@link ResetRequest} with all required fields. + * + * @param type The type of reset that the Charging Station or EVSE should perform. + * @return an instance of {@link ResetRequest} + */ + public ResetRequest createResetRequest(ResetEnum type) { + return new ResetRequest(type); + } + + /** + * Create a server {@link SetNetworkProfileRequest} with all required fields. + * + * @param configurationSlot Slot in which the configuration should be stored. + * @param connectionData The NetworkConnectionProfile defines the functional and technical + * parameters of a communication link. + * @return an instance of {@link SetNetworkProfileRequest} + */ + public SetNetworkProfileRequest createSetNetworkProfileRequest( + Integer configurationSlot, NetworkConnectionProfile connectionData) { + return new SetNetworkProfileRequest(configurationSlot, connectionData); + } + + /** + * Create a server {@link SetVariablesRequest} with all required fields. + * + * @param setVariableData setVariableData + * @return an instance of {@link SetVariablesRequest} + */ + public SetVariablesRequest createSetVariablesRequest(SetVariableData[] setVariableData) { + return new SetVariablesRequest(setVariableData); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerRemoteControlFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerRemoteControlFunction.java new file mode 100644 index 00000000..624c0e26 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerRemoteControlFunction.java @@ -0,0 +1,106 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the RemoteControl functional block. */ +public class ServerRemoteControlFunction implements Function { + + private final ArrayList features; + + public ServerRemoteControlFunction() { + features = new ArrayList<>(); + features.add(new RequestStartTransactionFeature(null)); + features.add(new RequestStopTransactionFeature(null)); + features.add(new TriggerMessageFeature(null)); + features.add(new UnlockConnectorFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a server {@link RequestStartTransactionRequest} with all required fields. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @param remoteStartId Id given by the server to this start request. The Charging Station will + * return this in the TransactionEventRequest, letting the server know which transaction was + * started for this request. Use to start a transaction. + * @return an instance of {@link RequestStartTransactionRequest} + */ + public RequestStartTransactionRequest createRequestStartTransactionRequest( + IdToken idToken, Integer remoteStartId) { + return new RequestStartTransactionRequest(idToken, remoteStartId); + } + + /** + * Create a server {@link RequestStopTransactionRequest} with all required fields. + * + * @param transactionId The identifier of the transaction which the Charging Station is requested + * to stop. + * @return an instance of {@link RequestStopTransactionRequest} + */ + public RequestStopTransactionRequest createRequestStopTransactionRequest(String transactionId) { + return new RequestStopTransactionRequest(transactionId); + } + + /** + * Create a server {@link TriggerMessageRequest} with all required fields. + * + * @param requestedMessage Type of message to be triggered. + * @return an instance of {@link TriggerMessageRequest} + */ + public TriggerMessageRequest createTriggerMessageRequest(MessageTriggerEnum requestedMessage) { + return new TriggerMessageRequest(requestedMessage); + } + + /** + * Create a server {@link UnlockConnectorRequest} with all required fields. + * + * @param evseId The identifier of the EVSE for which a connector needs to be unlocked. + * @param connectorId The identifier of the connector that needs to be unlocked. + * @return an instance of {@link UnlockConnectorRequest} + */ + public UnlockConnectorRequest createUnlockConnectorRequest(Integer evseId, Integer connectorId) { + return new UnlockConnectorRequest(evseId, connectorId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerReservationEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerReservationEventHandler.java new file mode 100644 index 00000000..4edfd90f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerReservationEventHandler.java @@ -0,0 +1,42 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Reservation functional block. */ +public interface ServerReservationEventHandler { + /** + * Handle a {@link ReservationStatusUpdateRequest} and return a {@link + * ReservationStatusUpdateResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link ReservationStatusUpdateRequest} to handle. + * @return outgoing {@link ReservationStatusUpdateResponse} to reply with. + */ + ReservationStatusUpdateResponse handleReservationStatusUpdateRequest( + UUID sessionIndex, ReservationStatusUpdateRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerReservationFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerReservationFunction.java new file mode 100644 index 00000000..3d52d22f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerReservationFunction.java @@ -0,0 +1,89 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Reservation functional block. */ +public class ServerReservationFunction implements Function { + + private final ServerReservationEventHandler eventHandler; + private final ArrayList features; + + public ServerReservationFunction(ServerReservationEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CancelReservationFeature(null)); + features.add(new ReservationStatusUpdateFeature(this)); + features.add(new ReserveNowFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ReservationStatusUpdateRequest) { + return eventHandler.handleReservationStatusUpdateRequest( + sessionIndex, (ReservationStatusUpdateRequest) request); + } + return null; + } + + /** + * Create a server {@link CancelReservationRequest} with all required fields. + * + * @param reservationId Id of the reservation to cancel. + * @return an instance of {@link CancelReservationRequest} + */ + public CancelReservationRequest createCancelReservationRequest(Integer reservationId) { + return new CancelReservationRequest(reservationId); + } + + /** + * Create a server {@link ReserveNowRequest} with all required fields. + * + * @param id Id of reservation. + * @param expiryDateTime Date and time at which the reservation expires. + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @return an instance of {@link ReserveNowRequest} + */ + public ReserveNowRequest createReserveNowRequest( + Integer id, ZonedDateTime expiryDateTime, IdToken idToken) { + return new ReserveNowRequest(id, expiryDateTime, idToken); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSecurityEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSecurityEventHandler.java new file mode 100644 index 00000000..f5dc16a2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSecurityEventHandler.java @@ -0,0 +1,52 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Security functional block. */ +public interface ServerSecurityEventHandler { + /** + * Handle a {@link SecurityEventNotificationRequest} and return a {@link + * SecurityEventNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link SecurityEventNotificationRequest} to handle. + * @return outgoing {@link SecurityEventNotificationResponse} to reply with. + */ + SecurityEventNotificationResponse handleSecurityEventNotificationRequest( + UUID sessionIndex, SecurityEventNotificationRequest request); + + /** + * Handle a {@link SignCertificateRequest} and return a {@link SignCertificateResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link SignCertificateRequest} to handle. + * @return outgoing {@link SignCertificateResponse} to reply with. + */ + SignCertificateResponse handleSignCertificateRequest( + UUID sessionIndex, SignCertificateRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSecurityFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSecurityFunction.java new file mode 100644 index 00000000..28647a31 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSecurityFunction.java @@ -0,0 +1,92 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Security functional block. */ +public class ServerSecurityFunction implements Function { + + private final ServerSecurityEventHandler eventHandler; + private final ArrayList features; + + public ServerSecurityFunction(ServerSecurityEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CertificateSignedFeature(null)); + features.add(new InstallCertificateFeature(null)); + features.add(new SecurityEventNotificationFeature(this)); + features.add(new SignCertificateFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof SecurityEventNotificationRequest) { + return eventHandler.handleSecurityEventNotificationRequest( + sessionIndex, (SecurityEventNotificationRequest) request); + } else if (request instanceof SignCertificateRequest) { + return eventHandler.handleSignCertificateRequest( + sessionIndex, (SignCertificateRequest) request); + } + return null; + } + + /** + * Create a server {@link CertificateSignedRequest} with all required fields. + * + * @param certificateChain The signed PEM encoded X.509 certificate. This SHALL also contain the + * necessary sub CA certificates, when applicable. The order of the bundle follows the + * certificate chain, starting from the leaf certificate. + * @return an instance of {@link CertificateSignedRequest} + */ + public CertificateSignedRequest createCertificateSignedRequest(String certificateChain) { + return new CertificateSignedRequest(certificateChain); + } + + /** + * Create a server {@link InstallCertificateRequest} with all required fields. + * + * @param certificateType The certificate type that is sent. + * @param certificate A PEM encoded X.509 certificate. + * @return an instance of {@link InstallCertificateRequest} + */ + public InstallCertificateRequest createInstallCertificateRequest( + InstallCertificateUseEnum certificateType, String certificate) { + return new InstallCertificateRequest(certificateType, certificate); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSmartChargingEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSmartChargingEventHandler.java new file mode 100644 index 00000000..ff6c4f6e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSmartChargingEventHandler.java @@ -0,0 +1,106 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the SmartCharging functional block. */ +public interface ServerSmartChargingEventHandler { + /** + * Handle a {@link ClearedChargingLimitRequest} and return a {@link ClearedChargingLimitResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link ClearedChargingLimitRequest} to handle. + * @return outgoing {@link ClearedChargingLimitResponse} to reply with. + */ + ClearedChargingLimitResponse handleClearedChargingLimitRequest( + UUID sessionIndex, ClearedChargingLimitRequest request); + + /** + * Handle a {@link NotifyChargingLimitRequest} and return a {@link NotifyChargingLimitResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyChargingLimitRequest} to handle. + * @return outgoing {@link NotifyChargingLimitResponse} to reply with. + */ + NotifyChargingLimitResponse handleNotifyChargingLimitRequest( + UUID sessionIndex, NotifyChargingLimitRequest request); + + /** + * Handle a {@link NotifyEVChargingNeedsRequest} and return a {@link + * NotifyEVChargingNeedsResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyEVChargingNeedsRequest} to handle. + * @return outgoing {@link NotifyEVChargingNeedsResponse} to reply with. + */ + NotifyEVChargingNeedsResponse handleNotifyEVChargingNeedsRequest( + UUID sessionIndex, NotifyEVChargingNeedsRequest request); + + /** + * Handle a {@link NotifyEVChargingScheduleRequest} and return a {@link + * NotifyEVChargingScheduleResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyEVChargingScheduleRequest} to handle. + * @return outgoing {@link NotifyEVChargingScheduleResponse} to reply with. + */ + NotifyEVChargingScheduleResponse handleNotifyEVChargingScheduleRequest( + UUID sessionIndex, NotifyEVChargingScheduleRequest request); + + /** + * Handle a {@link NotifyPriorityChargingRequest} and return a {@link + * NotifyPriorityChargingResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyPriorityChargingRequest} to handle. + * @return outgoing {@link NotifyPriorityChargingResponse} to reply with. + */ + NotifyPriorityChargingResponse handleNotifyPriorityChargingRequest( + UUID sessionIndex, NotifyPriorityChargingRequest request); + + /** + * Handle a {@link PullDynamicScheduleUpdateRequest} and return a {@link + * PullDynamicScheduleUpdateResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link PullDynamicScheduleUpdateRequest} to handle. + * @return outgoing {@link PullDynamicScheduleUpdateResponse} to reply with. + */ + PullDynamicScheduleUpdateResponse handlePullDynamicScheduleUpdateRequest( + UUID sessionIndex, PullDynamicScheduleUpdateRequest request); + + /** + * Handle a {@link ReportChargingProfilesRequest} and return a {@link + * ReportChargingProfilesResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link ReportChargingProfilesRequest} to handle. + * @return outgoing {@link ReportChargingProfilesResponse} to reply with. + */ + ReportChargingProfilesResponse handleReportChargingProfilesRequest( + UUID sessionIndex, ReportChargingProfilesRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSmartChargingFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSmartChargingFunction.java new file mode 100644 index 00000000..7ab2388c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerSmartChargingFunction.java @@ -0,0 +1,168 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the SmartCharging functional block. */ +public class ServerSmartChargingFunction implements Function { + + private final ServerSmartChargingEventHandler eventHandler; + private final ArrayList features; + + public ServerSmartChargingFunction(ServerSmartChargingEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearChargingProfileFeature(null)); + features.add(new ClearedChargingLimitFeature(this)); + features.add(new GetChargingProfilesFeature(null)); + features.add(new GetCompositeScheduleFeature(null)); + features.add(new NotifyChargingLimitFeature(this)); + features.add(new NotifyEVChargingNeedsFeature(this)); + features.add(new NotifyEVChargingScheduleFeature(this)); + features.add(new NotifyPriorityChargingFeature(this)); + features.add(new PullDynamicScheduleUpdateFeature(this)); + features.add(new ReportChargingProfilesFeature(this)); + features.add(new SetChargingProfileFeature(null)); + features.add(new UpdateDynamicScheduleFeature(null)); + features.add(new UsePriorityChargingFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearedChargingLimitRequest) { + return eventHandler.handleClearedChargingLimitRequest( + sessionIndex, (ClearedChargingLimitRequest) request); + } else if (request instanceof NotifyChargingLimitRequest) { + return eventHandler.handleNotifyChargingLimitRequest( + sessionIndex, (NotifyChargingLimitRequest) request); + } else if (request instanceof NotifyEVChargingNeedsRequest) { + return eventHandler.handleNotifyEVChargingNeedsRequest( + sessionIndex, (NotifyEVChargingNeedsRequest) request); + } else if (request instanceof NotifyEVChargingScheduleRequest) { + return eventHandler.handleNotifyEVChargingScheduleRequest( + sessionIndex, (NotifyEVChargingScheduleRequest) request); + } else if (request instanceof NotifyPriorityChargingRequest) { + return eventHandler.handleNotifyPriorityChargingRequest( + sessionIndex, (NotifyPriorityChargingRequest) request); + } else if (request instanceof PullDynamicScheduleUpdateRequest) { + return eventHandler.handlePullDynamicScheduleUpdateRequest( + sessionIndex, (PullDynamicScheduleUpdateRequest) request); + } else if (request instanceof ReportChargingProfilesRequest) { + return eventHandler.handleReportChargingProfilesRequest( + sessionIndex, (ReportChargingProfilesRequest) request); + } + return null; + } + + /** + * Create a server {@link ClearChargingProfileRequest}. + * + * @return an instance of {@link ClearChargingProfileRequest} + */ + public ClearChargingProfileRequest createClearChargingProfileRequest() { + return new ClearChargingProfileRequest(); + } + + /** + * Create a server {@link GetChargingProfilesRequest} with all required fields. + * + * @param requestId Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + * @param chargingProfile A ChargingProfileCriterionType is a filter for charging profiles to be + * selected by a GetChargingProfilesRequest. + * @return an instance of {@link GetChargingProfilesRequest} + */ + public GetChargingProfilesRequest createGetChargingProfilesRequest( + Integer requestId, ChargingProfileCriterion chargingProfile) { + return new GetChargingProfilesRequest(requestId, chargingProfile); + } + + /** + * Create a server {@link GetCompositeScheduleRequest} with all required fields. + * + * @param duration Length of the requested schedule in seconds. + * @param evseId The ID of the EVSE for which the schedule is requested. When evseid=0, the + * Charging Station will calculate the expected consumption for the grid connection. + * @return an instance of {@link GetCompositeScheduleRequest} + */ + public GetCompositeScheduleRequest createGetCompositeScheduleRequest( + Integer duration, Integer evseId) { + return new GetCompositeScheduleRequest(duration, evseId); + } + + /** + * Create a server {@link SetChargingProfileRequest} with all required fields. + * + * @param evseId For TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an + * overal limit for the whole Charging Station. + * @param chargingProfile A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval. + * @return an instance of {@link SetChargingProfileRequest} + */ + public SetChargingProfileRequest createSetChargingProfileRequest( + Integer evseId, ChargingProfile chargingProfile) { + return new SetChargingProfileRequest(evseId, chargingProfile); + } + + /** + * Create a server {@link UpdateDynamicScheduleRequest} with all required fields. + * + * @param chargingProfileId Id of charging profile to update. + * @param scheduleUpdate Updates to a ChargingSchedulePeriodType for dynamic charging profiles. + * @return an instance of {@link UpdateDynamicScheduleRequest} + */ + public UpdateDynamicScheduleRequest createUpdateDynamicScheduleRequest( + Integer chargingProfileId, ChargingScheduleUpdate scheduleUpdate) { + return new UpdateDynamicScheduleRequest(chargingProfileId, scheduleUpdate); + } + + /** + * Create a server {@link UsePriorityChargingRequest} with all required fields. + * + * @param transactionId The transaction for which priority charging is requested. + * @param activate True to request priority charging. False to request stopping priority charging. + * @return an instance of {@link UsePriorityChargingRequest} + */ + public UsePriorityChargingRequest createUsePriorityChargingRequest( + String transactionId, Boolean activate) { + return new UsePriorityChargingRequest(transactionId, activate); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTariffAndCostFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTariffAndCostFunction.java new file mode 100644 index 00000000..2e78e5b3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTariffAndCostFunction.java @@ -0,0 +1,117 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the TariffAndCost functional block. */ +public class ServerTariffAndCostFunction implements Function { + + private final ArrayList features; + + public ServerTariffAndCostFunction() { + features = new ArrayList<>(); + features.add(new ChangeTransactionTariffFeature(null)); + features.add(new ClearTariffsFeature(null)); + features.add(new CostUpdatedFeature(null)); + features.add(new GetTariffsFeature(null)); + features.add(new SetDefaultTariffFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a server {@link ChangeTransactionTariffRequest} with all required fields. + * + * @param tariff A tariff is described by fields with prices for: energy, charging time, idle + * time, fixed fee, reservation time, + * @param transactionId Transaction id for new tariff. + * @return an instance of {@link ChangeTransactionTariffRequest} + */ + public ChangeTransactionTariffRequest createChangeTransactionTariffRequest( + Tariff tariff, String transactionId) { + return new ChangeTransactionTariffRequest(tariff, transactionId); + } + + /** + * Create a server {@link ClearTariffsRequest}. + * + * @return an instance of {@link ClearTariffsRequest} + */ + public ClearTariffsRequest createClearTariffsRequest() { + return new ClearTariffsRequest(); + } + + /** + * Create a server {@link CostUpdatedRequest} with all required fields. + * + * @param totalCost Current total cost, based on the information known by the CSMS, of the + * transaction including taxes. In the currency configured with the configuration Variable: + * [Currency] + * @param transactionId Transaction Id of the transaction the current cost are asked for. + * @return an instance of {@link CostUpdatedRequest} + */ + public CostUpdatedRequest createCostUpdatedRequest(Double totalCost, String transactionId) { + return new CostUpdatedRequest(totalCost, transactionId); + } + + /** + * Create a server {@link GetTariffsRequest} with all required fields. + * + * @param evseId EVSE id to get tariff from. When evseId = 0, this gets tariffs from all EVSEs. + * @return an instance of {@link GetTariffsRequest} + */ + public GetTariffsRequest createGetTariffsRequest(Integer evseId) { + return new GetTariffsRequest(evseId); + } + + /** + * Create a server {@link SetDefaultTariffRequest} with all required fields. + * + * @param evseId EVSE that tariff applies to. When evseId = 0, then tarriff applies to all EVSEs. + * @param tariff A tariff is described by fields with prices for: energy, charging time, idle + * time, fixed fee, reservation time, + * @return an instance of {@link SetDefaultTariffRequest} + */ + public SetDefaultTariffRequest createSetDefaultTariffRequest(Integer evseId, Tariff tariff) { + return new SetDefaultTariffRequest(evseId, tariff); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTransactionsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTransactionsEventHandler.java new file mode 100644 index 00000000..58b07616 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTransactionsEventHandler.java @@ -0,0 +1,60 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.v21.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Transactions functional block. */ +public interface ServerTransactionsEventHandler { + /** + * Handle a {@link BatterySwapRequest} and return a {@link BatterySwapResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link BatterySwapRequest} to handle. + * @return outgoing {@link BatterySwapResponse} to reply with. + */ + BatterySwapResponse handleBatterySwapRequest(UUID sessionIndex, BatterySwapRequest request); + + /** + * Handle a {@link RequestBatterySwapRequest} and return a {@link RequestBatterySwapResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link RequestBatterySwapRequest} to handle. + * @return outgoing {@link RequestBatterySwapResponse} to reply with. + */ + RequestBatterySwapResponse handleRequestBatterySwapRequest( + UUID sessionIndex, RequestBatterySwapRequest request); + + /** + * Handle a {@link TransactionEventRequest} and return a {@link TransactionEventResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link TransactionEventRequest} to handle. + * @return outgoing {@link TransactionEventResponse} to reply with. + */ + TransactionEventResponse handleTransactionEventRequest( + UUID sessionIndex, TransactionEventRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTransactionsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTransactionsFunction.java new file mode 100644 index 00000000..b4af3ad4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerTransactionsFunction.java @@ -0,0 +1,79 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.*; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Transactions functional block. */ +public class ServerTransactionsFunction implements Function { + + private final ServerTransactionsEventHandler eventHandler; + private final ArrayList features; + + public ServerTransactionsFunction(ServerTransactionsEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new BatterySwapFeature(this)); + features.add(new GetTransactionStatusFeature(null)); + features.add(new RequestBatterySwapFeature(this)); + features.add(new TransactionEventFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof BatterySwapRequest) { + return eventHandler.handleBatterySwapRequest(sessionIndex, (BatterySwapRequest) request); + } else if (request instanceof RequestBatterySwapRequest) { + return eventHandler.handleRequestBatterySwapRequest( + sessionIndex, (RequestBatterySwapRequest) request); + } else if (request instanceof TransactionEventRequest) { + return eventHandler.handleTransactionEventRequest( + sessionIndex, (TransactionEventRequest) request); + } + return null; + } + + /** + * Create a server {@link GetTransactionStatusRequest}. + * + * @return an instance of {@link GetTransactionStatusRequest} + */ + public GetTransactionStatusRequest createGetTransactionStatusRequest() { + return new GetTransactionStatusRequest(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AFRRSignalRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AFRRSignalRequest.java new file mode 100644 index 00000000..12c26014 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AFRRSignalRequest.java @@ -0,0 +1,205 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AFRRSignalRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class AFRRSignalRequest extends RequestWithId { + /** Time when signal becomes active. */ + private ZonedDateTime timestamp; + + /** Value of signal in v2xSignalWattCurve. */ + private Integer signal; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AFRRSignalRequest class + * + * @param timestamp Time when signal becomes active. + * @param signal Value of signal in v2xSignalWattCurve. + */ + public AFRRSignalRequest(ZonedDateTime timestamp, Integer signal) { + setTimestamp(timestamp); + setSignal(signal); + } + + /** + * Gets time when signal becomes active. + * + * @return Time when signal becomes active + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets time when signal becomes active. + * + * @param timestamp Time when signal becomes active + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets value of signal in v2xSignalWattCurve. + * + * @return Value of signal in v2xSignalWattCurve + */ + public Integer getSignal() { + return signal; + } + + /** + * Sets value of signal in v2xSignalWattCurve. + * + * @param signal Value of signal in v2xSignalWattCurve + */ + public void setSignal(Integer signal) { + if (!isValidSignal(signal)) { + throw new PropertyConstraintException(signal, "signal is invalid"); + } + this.signal = signal; + } + + /** + * Returns whether the given signal is valid + * + * @param signal the signal to check the validity of + * @return {@code true} if signal is valid, {@code false} if not + */ + private boolean isValidSignal(Integer signal) { + return signal != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AFRRSignalRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTimestamp(timestamp) && isValidSignal(signal) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AFRRSignalRequest that = (AFRRSignalRequest) o; + return Objects.equals(timestamp, that.timestamp) + && Objects.equals(signal, that.signal) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, signal, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("timestamp", timestamp) + .add("signal", signal) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AFRRSignalResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AFRRSignalResponse.java new file mode 100644 index 00000000..70747989 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AFRRSignalResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AFRRSignalResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class AFRRSignalResponse extends Confirmation { + /** status */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AFRRSignalResponse class + * + * @param status status + */ + public AFRRSignalResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets status + * + * @return status + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets status + * + * @param status status + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public AFRRSignalResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AFRRSignalResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AFRRSignalResponse that = (AFRRSignalResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AdjustPeriodicEventStreamRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AdjustPeriodicEventStreamRequest.java new file mode 100644 index 00000000..6903c65c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AdjustPeriodicEventStreamRequest.java @@ -0,0 +1,205 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.PeriodicEventStreamParams; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AdjustPeriodicEventStreamRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class AdjustPeriodicEventStreamRequest extends RequestWithId { + /** id */ + private Integer id; + + /** params */ + private PeriodicEventStreamParams params; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AdjustPeriodicEventStreamRequest class + * + * @param id id + * @param params params + */ + public AdjustPeriodicEventStreamRequest(Integer id, PeriodicEventStreamParams params) { + setId(id); + setParams(params); + } + + /** + * Gets id + * + * @return id + */ + public Integer getId() { + return id; + } + + /** + * Sets id + * + * @param id id + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets params + * + * @return params + */ + public PeriodicEventStreamParams getParams() { + return params; + } + + /** + * Sets params + * + * @param params params + */ + public void setParams(PeriodicEventStreamParams params) { + if (!isValidParams(params)) { + throw new PropertyConstraintException(params, "params is invalid"); + } + this.params = params; + } + + /** + * Returns whether the given params is valid + * + * @param params the params to check the validity of + * @return {@code true} if params is valid, {@code false} if not + */ + private boolean isValidParams(PeriodicEventStreamParams params) { + return params != null && params.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AdjustPeriodicEventStreamRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidId(id) && isValidParams(params) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdjustPeriodicEventStreamRequest that = (AdjustPeriodicEventStreamRequest) o; + return Objects.equals(id, that.id) + && Objects.equals(params, that.params) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(id, params, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("params", params) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AdjustPeriodicEventStreamResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AdjustPeriodicEventStreamResponse.java new file mode 100644 index 00000000..8ccaf408 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AdjustPeriodicEventStreamResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AdjustPeriodicEventStreamResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class AdjustPeriodicEventStreamResponse extends Confirmation { + /** Status of operation. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AdjustPeriodicEventStreamResponse class + * + * @param status Status of operation. + */ + public AdjustPeriodicEventStreamResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets status of operation. + * + * @return Status of operation + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets status of operation. + * + * @param status Status of operation + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public AdjustPeriodicEventStreamResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AdjustPeriodicEventStreamResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdjustPeriodicEventStreamResponse that = (AdjustPeriodicEventStreamResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AuthorizeRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AuthorizeRequest.java new file mode 100644 index 00000000..23afb9f0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AuthorizeRequest.java @@ -0,0 +1,293 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.IdToken; +import eu.chargetime.ocpp.v21.model.types.OCSPRequestData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AuthorizeRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class AuthorizeRequest extends RequestWithId { + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** + * The X.509 certificate chain presented by EV and encoded in PEM format. Order of certificates in + * chain is from leaf up to (but excluding) root certificate. + * + *

Only needed in case of central contract validation when Charging Station cannot validate the + * contract certificate. + */ + @Nullable private String certificate; + + /** Information about a certificate for an OCSP check. */ + @Nullable private OCSPRequestData[] iso15118CertificateHashData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AuthorizeRequest class + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + */ + public AuthorizeRequest(IdToken idToken) { + setIdToken(idToken); + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets the X.509 certificate chain presented by EV and encoded in PEM format. Order of + * certificates in chain is from leaf up to (but excluding) root certificate. + * + * @return The X.509 certificate chain presented by EV and encoded in PEM format + */ + @Nullable + public String getCertificate() { + return certificate; + } + + /** + * Sets the X.509 certificate chain presented by EV and encoded in PEM format. Order of + * certificates in chain is from leaf up to (but excluding) root certificate. + * + * @param certificate The X.509 certificate chain presented by EV and encoded in PEM format + */ + public void setCertificate(@Nullable String certificate) { + if (!isValidCertificate(certificate)) { + throw new PropertyConstraintException(certificate, "certificate is invalid"); + } + this.certificate = certificate; + } + + /** + * Returns whether the given certificate is valid + * + * @param certificate the certificate to check the validity of + * @return {@code true} if certificate is valid, {@code false} if not + */ + private boolean isValidCertificate(@Nullable String certificate) { + return certificate == null || certificate.length() <= 10000; + } + + /** + * Adds the X.509 certificate chain presented by EV and encoded in PEM format. Order of + * certificates in chain is from leaf up to (but excluding) root certificate. + * + * @param certificate The X.509 certificate chain presented by EV and encoded in PEM format + * @return this + */ + public AuthorizeRequest withCertificate(@Nullable String certificate) { + setCertificate(certificate); + return this; + } + + /** + * Gets information about a certificate for an OCSP check. + * + * @return Information about a certificate for an OCSP check + */ + @Nullable + public OCSPRequestData[] getIso15118CertificateHashData() { + return iso15118CertificateHashData; + } + + /** + * Sets information about a certificate for an OCSP check. + * + * @param iso15118CertificateHashData Information about a certificate for an OCSP check + */ + public void setIso15118CertificateHashData( + @Nullable OCSPRequestData[] iso15118CertificateHashData) { + if (!isValidIso15118CertificateHashData(iso15118CertificateHashData)) { + throw new PropertyConstraintException( + iso15118CertificateHashData, "iso15118CertificateHashData is invalid"); + } + this.iso15118CertificateHashData = iso15118CertificateHashData; + } + + /** + * Returns whether the given iso15118CertificateHashData is valid + * + * @param iso15118CertificateHashData the iso15118CertificateHashData to check the validity of + * @return {@code true} if iso15118CertificateHashData is valid, {@code false} if not + */ + private boolean isValidIso15118CertificateHashData( + @Nullable OCSPRequestData[] iso15118CertificateHashData) { + return iso15118CertificateHashData == null + || (iso15118CertificateHashData.length >= 1 + && iso15118CertificateHashData.length <= 4 + && Arrays.stream(iso15118CertificateHashData).allMatch(item -> item.validate())); + } + + /** + * Adds information about a certificate for an OCSP check. + * + * @param iso15118CertificateHashData Information about a certificate for an OCSP check + * @return this + */ + public AuthorizeRequest withIso15118CertificateHashData( + @Nullable OCSPRequestData[] iso15118CertificateHashData) { + setIso15118CertificateHashData(iso15118CertificateHashData); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AuthorizeRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidIdToken(idToken) + && isValidCertificate(certificate) + && isValidIso15118CertificateHashData(iso15118CertificateHashData) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthorizeRequest that = (AuthorizeRequest) o; + return Objects.equals(idToken, that.idToken) + && Objects.equals(certificate, that.certificate) + && Arrays.equals(iso15118CertificateHashData, that.iso15118CertificateHashData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + idToken, certificate, Arrays.hashCode(iso15118CertificateHashData), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("idToken", idToken) + .add("certificate", certificate) + .add("iso15118CertificateHashData", iso15118CertificateHashData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AuthorizeResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AuthorizeResponse.java new file mode 100644 index 00000000..2be381e6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/AuthorizeResponse.java @@ -0,0 +1,345 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.AuthorizeCertificateStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.EnergyTransferModeEnum; +import eu.chargetime.ocpp.v21.model.types.IdTokenInfo; +import eu.chargetime.ocpp.v21.model.types.Tariff; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AuthorizeResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class AuthorizeResponse extends Confirmation { + /** + * Status information about an identifier. It is advised to not stop charging for a token that + * expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not + * given, the status has no end date. + */ + private IdTokenInfo idTokenInfo; + + /** + * Certificate status information. + * + *

+   * - if all certificates are valid: return 'Accepted'.
+   * - if one of the certificates was revoked, return 'CertificateRevoked'.
+   * 
+ */ + @Nullable private AuthorizeCertificateStatusEnum certificateStatus; + + /** + * List of allowed energy transfer modes the EV can choose from. If omitted this defaults to + * charging only. + */ + @Nullable private EnergyTransferModeEnum[] allowedEnergyTransfer; + + /** + * A tariff is described by fields with prices for: energy, charging time, idle time, fixed fee, + * reservation time, + * + *
+   * reservation fixed fee.
+   * Each of these fields may have (optional) conditions that specify when a price is applicable.
+   * The description contains a human-readable explanation of the tariff to be shown to the user.
+   * The other fields are parameters that define the tariff. These are used by the charging station
+   * to calculate the price.
+   * 
+ */ + @Nullable private Tariff tariff; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AuthorizeResponse class + * + * @param idTokenInfo Status information about an identifier. It is advised to not stop charging + * for a token that expires during charging, as ExpiryDate is only used for caching purposes. + * If ExpiryDate is not given, the status has no end date. + */ + public AuthorizeResponse(IdTokenInfo idTokenInfo) { + setIdTokenInfo(idTokenInfo); + } + + /** + * Gets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @return Status information about an identifier + */ + public IdTokenInfo getIdTokenInfo() { + return idTokenInfo; + } + + /** + * Sets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + */ + public void setIdTokenInfo(IdTokenInfo idTokenInfo) { + if (!isValidIdTokenInfo(idTokenInfo)) { + throw new PropertyConstraintException(idTokenInfo, "idTokenInfo is invalid"); + } + this.idTokenInfo = idTokenInfo; + } + + /** + * Returns whether the given idTokenInfo is valid + * + * @param idTokenInfo the idTokenInfo to check the validity of + * @return {@code true} if idTokenInfo is valid, {@code false} if not + */ + private boolean isValidIdTokenInfo(IdTokenInfo idTokenInfo) { + return idTokenInfo != null && idTokenInfo.validate(); + } + + /** + * Gets certificate status information. + * + * @return Certificate status information + */ + @Nullable + public AuthorizeCertificateStatusEnum getCertificateStatus() { + return certificateStatus; + } + + /** + * Sets certificate status information. + * + * @param certificateStatus Certificate status information + */ + public void setCertificateStatus(@Nullable AuthorizeCertificateStatusEnum certificateStatus) { + this.certificateStatus = certificateStatus; + } + + /** + * Adds certificate status information. + * + * @param certificateStatus Certificate status information + * @return this + */ + public AuthorizeResponse withCertificateStatus( + @Nullable AuthorizeCertificateStatusEnum certificateStatus) { + setCertificateStatus(certificateStatus); + return this; + } + + /** + * Gets list of allowed energy transfer modes the EV can choose from. If omitted this defaults to + * charging only. + * + * @return List of allowed energy transfer modes the EV can choose from + */ + @Nullable + public EnergyTransferModeEnum[] getAllowedEnergyTransfer() { + return allowedEnergyTransfer; + } + + /** + * Sets list of allowed energy transfer modes the EV can choose from. If omitted this defaults to + * charging only. + * + * @param allowedEnergyTransfer List of allowed energy transfer modes the EV can choose from + */ + public void setAllowedEnergyTransfer(@Nullable EnergyTransferModeEnum[] allowedEnergyTransfer) { + if (!isValidAllowedEnergyTransfer(allowedEnergyTransfer)) { + throw new PropertyConstraintException( + allowedEnergyTransfer, "allowedEnergyTransfer is invalid"); + } + this.allowedEnergyTransfer = allowedEnergyTransfer; + } + + /** + * Returns whether the given allowedEnergyTransfer is valid + * + * @param allowedEnergyTransfer the allowedEnergyTransfer to check the validity of + * @return {@code true} if allowedEnergyTransfer is valid, {@code false} if not + */ + private boolean isValidAllowedEnergyTransfer( + @Nullable EnergyTransferModeEnum[] allowedEnergyTransfer) { + return allowedEnergyTransfer == null || (allowedEnergyTransfer.length >= 1); + } + + /** + * Adds list of allowed energy transfer modes the EV can choose from. If omitted this defaults to + * charging only. + * + * @param allowedEnergyTransfer List of allowed energy transfer modes the EV can choose from + * @return this + */ + public AuthorizeResponse withAllowedEnergyTransfer( + @Nullable EnergyTransferModeEnum[] allowedEnergyTransfer) { + setAllowedEnergyTransfer(allowedEnergyTransfer); + return this; + } + + /** + * Gets a tariff is described by fields with prices for: energy, charging time, idle time, fixed + * fee, reservation time, + * + * @return A tariff is described by fields with prices for: energy, charging time, idle time, + * fixed fee, reservation time, + */ + @Nullable + public Tariff getTariff() { + return tariff; + } + + /** + * Sets a tariff is described by fields with prices for: energy, charging time, idle time, fixed + * fee, reservation time, + * + * @param tariff A tariff is described by fields with prices for: energy, charging time, idle + * time, fixed fee, reservation time, + */ + public void setTariff(@Nullable Tariff tariff) { + if (!isValidTariff(tariff)) { + throw new PropertyConstraintException(tariff, "tariff is invalid"); + } + this.tariff = tariff; + } + + /** + * Returns whether the given tariff is valid + * + * @param tariff the tariff to check the validity of + * @return {@code true} if tariff is valid, {@code false} if not + */ + private boolean isValidTariff(@Nullable Tariff tariff) { + return tariff == null || tariff.validate(); + } + + /** + * Adds a tariff is described by fields with prices for: energy, charging time, idle time, fixed + * fee, reservation time, + * + * @param tariff A tariff is described by fields with prices for: energy, charging time, idle + * time, fixed fee, reservation time, + * @return this + */ + public AuthorizeResponse withTariff(@Nullable Tariff tariff) { + setTariff(tariff); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AuthorizeResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidIdTokenInfo(idTokenInfo) + && isValidAllowedEnergyTransfer(allowedEnergyTransfer) + && isValidTariff(tariff) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthorizeResponse that = (AuthorizeResponse) o; + return Objects.equals(idTokenInfo, that.idTokenInfo) + && Objects.equals(certificateStatus, that.certificateStatus) + && Arrays.equals(allowedEnergyTransfer, that.allowedEnergyTransfer) + && Objects.equals(tariff, that.tariff) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + idTokenInfo, certificateStatus, Arrays.hashCode(allowedEnergyTransfer), tariff, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("idTokenInfo", idTokenInfo) + .add("certificateStatus", certificateStatus) + .add("allowedEnergyTransfer", allowedEnergyTransfer) + .add("tariff", tariff) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BatterySwapRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BatterySwapRequest.java new file mode 100644 index 00000000..281a1594 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BatterySwapRequest.java @@ -0,0 +1,304 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.BatteryData; +import eu.chargetime.ocpp.v21.model.types.BatterySwapEventEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.IdToken; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * BatterySwapRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class BatterySwapRequest extends RequestWithId { + /** batteryData */ + private BatteryData[] batteryData; + + /** Battery in/out */ + private BatterySwapEventEnum eventType; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** RequestId to correlate BatteryIn/Out events and optional RequestBatterySwapRequest. */ + private Integer requestId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the BatterySwapRequest class + * + * @param batteryData batteryData + * @param eventType Battery in/out + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @param requestId RequestId to correlate BatteryIn/Out events and optional + * RequestBatterySwapRequest. + */ + public BatterySwapRequest( + BatteryData[] batteryData, + BatterySwapEventEnum eventType, + IdToken idToken, + Integer requestId) { + setBatteryData(batteryData); + setEventType(eventType); + setIdToken(idToken); + setRequestId(requestId); + } + + /** + * Gets batteryData + * + * @return batteryData + */ + public BatteryData[] getBatteryData() { + return batteryData; + } + + /** + * Sets batteryData + * + * @param batteryData batteryData + */ + public void setBatteryData(BatteryData[] batteryData) { + if (!isValidBatteryData(batteryData)) { + throw new PropertyConstraintException(batteryData, "batteryData is invalid"); + } + this.batteryData = batteryData; + } + + /** + * Returns whether the given batteryData is valid + * + * @param batteryData the batteryData to check the validity of + * @return {@code true} if batteryData is valid, {@code false} if not + */ + private boolean isValidBatteryData(BatteryData[] batteryData) { + return batteryData != null + && batteryData.length >= 1 + && Arrays.stream(batteryData).allMatch(item -> item.validate()); + } + + /** + * Gets battery in/out + * + * @return Battery in/out + */ + public BatterySwapEventEnum getEventType() { + return eventType; + } + + /** + * Sets battery in/out + * + * @param eventType Battery in/out + */ + public void setEventType(BatterySwapEventEnum eventType) { + if (!isValidEventType(eventType)) { + throw new PropertyConstraintException(eventType, "eventType is invalid"); + } + this.eventType = eventType; + } + + /** + * Returns whether the given eventType is valid + * + * @param eventType the eventType to check the validity of + * @return {@code true} if eventType is valid, {@code false} if not + */ + private boolean isValidEventType(BatterySwapEventEnum eventType) { + return eventType != null; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets requestId to correlate BatteryIn/Out events and optional RequestBatterySwapRequest. + * + * @return RequestId to correlate BatteryIn/Out events and optional RequestBatterySwapRequest + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets requestId to correlate BatteryIn/Out events and optional RequestBatterySwapRequest. + * + * @param requestId RequestId to correlate BatteryIn/Out events and optional + * RequestBatterySwapRequest + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public BatterySwapRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidBatteryData(batteryData) + && isValidEventType(eventType) + && isValidIdToken(idToken) + && isValidRequestId(requestId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatterySwapRequest that = (BatterySwapRequest) o; + return Arrays.equals(batteryData, that.batteryData) + && Objects.equals(eventType, that.eventType) + && Objects.equals(idToken, that.idToken) + && Objects.equals(requestId, that.requestId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(batteryData), eventType, idToken, requestId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("batteryData", batteryData) + .add("eventType", eventType) + .add("idToken", idToken) + .add("requestId", requestId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BatterySwapResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BatterySwapResponse.java new file mode 100644 index 00000000..dd3aa26d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BatterySwapResponse.java @@ -0,0 +1,120 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * This is an empty response that just acknowledges receipt of the request. (The request cannot be + * rejected). + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class BatterySwapResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the BatterySwapResponse class */ + public BatterySwapResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public BatterySwapResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatterySwapResponse that = (BatterySwapResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BootNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BootNotificationRequest.java new file mode 100644 index 00000000..9734ead3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BootNotificationRequest.java @@ -0,0 +1,208 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.BootReasonEnum; +import eu.chargetime.ocpp.v21.model.types.ChargingStation; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * BootNotificationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class BootNotificationRequest extends RequestWithId { + /** The physical system where an Electrical Vehicle (EV) can be charged. */ + private ChargingStation chargingStation; + + /** The reason for sending this message to the CSMS. */ + private BootReasonEnum reason; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the BootNotificationRequest class + * + * @param chargingStation The physical system where an Electrical Vehicle (EV) can be charged. + * @param reason The reason for sending this message to the CSMS. + */ + public BootNotificationRequest(ChargingStation chargingStation, BootReasonEnum reason) { + setChargingStation(chargingStation); + setReason(reason); + } + + /** + * Gets the physical system where an Electrical Vehicle (EV) can be charged. + * + * @return The physical system where an Electrical Vehicle (EV) can be charged + */ + public ChargingStation getChargingStation() { + return chargingStation; + } + + /** + * Sets the physical system where an Electrical Vehicle (EV) can be charged. + * + * @param chargingStation The physical system where an Electrical Vehicle (EV) can be charged + */ + public void setChargingStation(ChargingStation chargingStation) { + if (!isValidChargingStation(chargingStation)) { + throw new PropertyConstraintException(chargingStation, "chargingStation is invalid"); + } + this.chargingStation = chargingStation; + } + + /** + * Returns whether the given chargingStation is valid + * + * @param chargingStation the chargingStation to check the validity of + * @return {@code true} if chargingStation is valid, {@code false} if not + */ + private boolean isValidChargingStation(ChargingStation chargingStation) { + return chargingStation != null && chargingStation.validate(); + } + + /** + * Gets the reason for sending this message to the CSMS. + * + * @return The reason for sending this message to the CSMS + */ + public BootReasonEnum getReason() { + return reason; + } + + /** + * Sets the reason for sending this message to the CSMS. + * + * @param reason The reason for sending this message to the CSMS + */ + public void setReason(BootReasonEnum reason) { + if (!isValidReason(reason)) { + throw new PropertyConstraintException(reason, "reason is invalid"); + } + this.reason = reason; + } + + /** + * Returns whether the given reason is valid + * + * @param reason the reason to check the validity of + * @return {@code true} if reason is valid, {@code false} if not + */ + private boolean isValidReason(BootReasonEnum reason) { + return reason != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public BootNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidChargingStation(chargingStation) + && isValidReason(reason) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BootNotificationRequest that = (BootNotificationRequest) o; + return Objects.equals(chargingStation, that.chargingStation) + && Objects.equals(reason, that.reason) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(chargingStation, reason, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingStation", chargingStation) + .add("reason", reason) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BootNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BootNotificationResponse.java new file mode 100644 index 00000000..71068e03 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/BootNotificationResponse.java @@ -0,0 +1,303 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.RegistrationStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * BootNotificationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class BootNotificationResponse extends Confirmation { + /** The CSMS’s current time. */ + private ZonedDateTime currentTime; + + /** + * When Status is Accepted, this contains the heartbeat interval in seconds. If the CSMS returns + * something other than Accepted, the value of the interval field indicates the minimum wait time + * before sending a next BootNotification request. + */ + private Integer interval; + + /** Whether the Charging Station has been registered within the CSMS. */ + private RegistrationStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the BootNotificationResponse class + * + * @param currentTime The CSMS’s current time. + * @param interval When Status is Accepted, this contains the heartbeat interval in seconds. If + * the CSMS returns something other than Accepted, the value of the interval field indicates + * the minimum wait time before sending a next BootNotification request. + * @param status Whether the Charging Station has been registered within the CSMS. + */ + public BootNotificationResponse( + ZonedDateTime currentTime, Integer interval, RegistrationStatusEnum status) { + setCurrentTime(currentTime); + setInterval(interval); + setStatus(status); + } + + /** + * Gets the CSMS’s current time. + * + * @return The CSMS’s current time + */ + public ZonedDateTime getCurrentTime() { + return currentTime; + } + + /** + * Sets the CSMS’s current time. + * + * @param currentTime The CSMS’s current time + */ + public void setCurrentTime(ZonedDateTime currentTime) { + if (!isValidCurrentTime(currentTime)) { + throw new PropertyConstraintException(currentTime, "currentTime is invalid"); + } + this.currentTime = currentTime; + } + + /** + * Returns whether the given currentTime is valid + * + * @param currentTime the currentTime to check the validity of + * @return {@code true} if currentTime is valid, {@code false} if not + */ + private boolean isValidCurrentTime(ZonedDateTime currentTime) { + return currentTime != null; + } + + /** + * Gets when Status is Accepted, this contains the heartbeat interval in seconds. If the CSMS + * returns something other than Accepted, the value of the interval field indicates the minimum + * wait time before sending a next BootNotification request. + * + * @return When Status is Accepted, this contains the heartbeat interval in seconds + */ + public Integer getInterval() { + return interval; + } + + /** + * Sets when Status is Accepted, this contains the heartbeat interval in seconds. If the CSMS + * returns something other than Accepted, the value of the interval field indicates the minimum + * wait time before sending a next BootNotification request. + * + * @param interval When Status is Accepted, this contains the heartbeat interval in seconds + */ + public void setInterval(Integer interval) { + if (!isValidInterval(interval)) { + throw new PropertyConstraintException(interval, "interval is invalid"); + } + this.interval = interval; + } + + /** + * Returns whether the given interval is valid + * + * @param interval the interval to check the validity of + * @return {@code true} if interval is valid, {@code false} if not + */ + private boolean isValidInterval(Integer interval) { + return interval != null; + } + + /** + * Gets whether the Charging Station has been registered within the CSMS. + * + * @return Whether the Charging Station has been registered within the CSMS + */ + public RegistrationStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station has been registered within the CSMS. + * + * @param status Whether the Charging Station has been registered within the CSMS + */ + public void setStatus(RegistrationStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(RegistrationStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public BootNotificationResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public BootNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCurrentTime(currentTime) + && isValidInterval(interval) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BootNotificationResponse that = (BootNotificationResponse) o; + return Objects.equals(currentTime, that.currentTime) + && Objects.equals(interval, that.interval) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(currentTime, interval, status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("currentTime", currentTime) + .add("interval", interval) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CancelReservationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CancelReservationRequest.java new file mode 100644 index 00000000..f9155363 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CancelReservationRequest.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CancelReservationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class CancelReservationRequest extends RequestWithId { + /** Id of the reservation to cancel. */ + private Integer reservationId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CancelReservationRequest class + * + * @param reservationId Id of the reservation to cancel. + */ + public CancelReservationRequest(Integer reservationId) { + setReservationId(reservationId); + } + + /** + * Gets id of the reservation to cancel. + * + * @return Id of the reservation to cancel + */ + public Integer getReservationId() { + return reservationId; + } + + /** + * Sets id of the reservation to cancel. + * + * @param reservationId Id of the reservation to cancel + */ + public void setReservationId(Integer reservationId) { + if (!isValidReservationId(reservationId)) { + throw new PropertyConstraintException(reservationId, "reservationId is invalid"); + } + this.reservationId = reservationId; + } + + /** + * Returns whether the given reservationId is valid + * + * @param reservationId the reservationId to check the validity of + * @return {@code true} if reservationId is valid, {@code false} if not + */ + private boolean isValidReservationId(Integer reservationId) { + return reservationId != null && reservationId >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CancelReservationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidReservationId(reservationId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CancelReservationRequest that = (CancelReservationRequest) o; + return Objects.equals(reservationId, that.reservationId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(reservationId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("reservationId", reservationId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CancelReservationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CancelReservationResponse.java new file mode 100644 index 00000000..46c68ee3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CancelReservationResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CancelReservationStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CancelReservationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class CancelReservationResponse extends Confirmation { + /** The success or failure of the canceling of a reservation by CSMS. */ + private CancelReservationStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CancelReservationResponse class + * + * @param status The success or failure of the canceling of a reservation by CSMS. + */ + public CancelReservationResponse(CancelReservationStatusEnum status) { + setStatus(status); + } + + /** + * Gets the success or failure of the canceling of a reservation by CSMS. + * + * @return The success or failure of the canceling of a reservation by CSMS + */ + public CancelReservationStatusEnum getStatus() { + return status; + } + + /** + * Sets the success or failure of the canceling of a reservation by CSMS. + * + * @param status The success or failure of the canceling of a reservation by CSMS + */ + public void setStatus(CancelReservationStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(CancelReservationStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public CancelReservationResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CancelReservationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CancelReservationResponse that = (CancelReservationResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CertificateSignedRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CertificateSignedRequest.java new file mode 100644 index 00000000..31d40cc9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CertificateSignedRequest.java @@ -0,0 +1,269 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateSigningUseEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CertificateSignedRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class CertificateSignedRequest extends RequestWithId { + /** + * The signed PEM encoded X.509 certificate. This SHALL also contain the necessary sub CA + * certificates, when applicable. The order of the bundle follows the certificate chain, starting + * from the leaf certificate. + * + *

The Configuration Variable MaxCertificateChainSize can be used to limit the maximum size of + * this field. + */ + private String certificateChain; + + /** + * The type of the signed certificate that is returned. When omitted the certificate is used for + * both the 15118 connection (if implemented) and the Charging Station to CSMS connection. This + * field is required when a typeOfCertificate was included in the SignCertificateRequest that + * requested this certificate to be signed AND both the 15118 connection and the Charging Station + * connection are implemented. + */ + @Nullable private CertificateSigningUseEnum certificateType; + + /** RequestId to correlate this message with the SignCertificateRequest. */ + @Nullable private Integer requestId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CertificateSignedRequest class + * + * @param certificateChain The signed PEM encoded X.509 certificate. This SHALL also contain the + * necessary sub CA certificates, when applicable. The order of the bundle follows the + * certificate chain, starting from the leaf certificate. + */ + public CertificateSignedRequest(String certificateChain) { + setCertificateChain(certificateChain); + } + + /** + * Gets the signed PEM encoded X.509 certificate. This SHALL also contain the necessary sub CA + * certificates, when applicable. The order of the bundle follows the certificate chain, starting + * from the leaf certificate. + * + * @return The signed PEM encoded X.509 certificate + */ + public String getCertificateChain() { + return certificateChain; + } + + /** + * Sets the signed PEM encoded X.509 certificate. This SHALL also contain the necessary sub CA + * certificates, when applicable. The order of the bundle follows the certificate chain, starting + * from the leaf certificate. + * + * @param certificateChain The signed PEM encoded X.509 certificate + */ + public void setCertificateChain(String certificateChain) { + if (!isValidCertificateChain(certificateChain)) { + throw new PropertyConstraintException(certificateChain, "certificateChain is invalid"); + } + this.certificateChain = certificateChain; + } + + /** + * Returns whether the given certificateChain is valid + * + * @param certificateChain the certificateChain to check the validity of + * @return {@code true} if certificateChain is valid, {@code false} if not + */ + private boolean isValidCertificateChain(String certificateChain) { + return certificateChain != null && certificateChain.length() <= 10000; + } + + /** + * Gets the type of the signed certificate that is returned. When omitted the certificate is used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * This field is required when a typeOfCertificate was included in the SignCertificateRequest that + * requested this certificate to be signed AND both the 15118 connection and the Charging Station + * connection are implemented. + * + * @return The type of the signed certificate that is returned + */ + @Nullable + public CertificateSigningUseEnum getCertificateType() { + return certificateType; + } + + /** + * Sets the type of the signed certificate that is returned. When omitted the certificate is used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * This field is required when a typeOfCertificate was included in the SignCertificateRequest that + * requested this certificate to be signed AND both the 15118 connection and the Charging Station + * connection are implemented. + * + * @param certificateType The type of the signed certificate that is returned + */ + public void setCertificateType(@Nullable CertificateSigningUseEnum certificateType) { + this.certificateType = certificateType; + } + + /** + * Adds the type of the signed certificate that is returned. When omitted the certificate is used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * This field is required when a typeOfCertificate was included in the SignCertificateRequest that + * requested this certificate to be signed AND both the 15118 connection and the Charging Station + * connection are implemented. + * + * @param certificateType The type of the signed certificate that is returned + * @return this + */ + public CertificateSignedRequest withCertificateType( + @Nullable CertificateSigningUseEnum certificateType) { + setCertificateType(certificateType); + return this; + } + + /** + * Gets requestId to correlate this message with the SignCertificateRequest. + * + * @return RequestId to correlate this message with the SignCertificateRequest + */ + @Nullable + public Integer getRequestId() { + return requestId; + } + + /** + * Sets requestId to correlate this message with the SignCertificateRequest. + * + * @param requestId RequestId to correlate this message with the SignCertificateRequest + */ + public void setRequestId(@Nullable Integer requestId) { + this.requestId = requestId; + } + + /** + * Adds requestId to correlate this message with the SignCertificateRequest. + * + * @param requestId RequestId to correlate this message with the SignCertificateRequest + * @return this + */ + public CertificateSignedRequest withRequestId(@Nullable Integer requestId) { + setRequestId(requestId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateSignedRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCertificateChain(certificateChain) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateSignedRequest that = (CertificateSignedRequest) o; + return Objects.equals(certificateChain, that.certificateChain) + && Objects.equals(certificateType, that.certificateType) + && Objects.equals(requestId, that.requestId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(certificateChain, certificateType, requestId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateChain", certificateChain) + .add("certificateType", certificateType) + .add("requestId", requestId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CertificateSignedResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CertificateSignedResponse.java new file mode 100644 index 00000000..f22bc145 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CertificateSignedResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateSignedStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CertificateSignedResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class CertificateSignedResponse extends Confirmation { + /** Returns whether certificate signing has been accepted, otherwise rejected. */ + private CertificateSignedStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CertificateSignedResponse class + * + * @param status Returns whether certificate signing has been accepted, otherwise rejected. + */ + public CertificateSignedResponse(CertificateSignedStatusEnum status) { + setStatus(status); + } + + /** + * Gets returns whether certificate signing has been accepted, otherwise rejected. + * + * @return Returns whether certificate signing has been accepted, otherwise rejected + */ + public CertificateSignedStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether certificate signing has been accepted, otherwise rejected. + * + * @param status Returns whether certificate signing has been accepted, otherwise rejected + */ + public void setStatus(CertificateSignedStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(CertificateSignedStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public CertificateSignedResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateSignedResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateSignedResponse that = (CertificateSignedResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeAvailabilityRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeAvailabilityRequest.java new file mode 100644 index 00000000..174e86ec --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeAvailabilityRequest.java @@ -0,0 +1,220 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.EVSE; +import eu.chargetime.ocpp.v21.model.types.OperationalStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ChangeAvailabilityRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ChangeAvailabilityRequest extends RequestWithId { + /** Electric Vehicle Supply Equipment */ + @Nullable private EVSE evse; + + /** The type of availability change that the Charging Station should perform. */ + private OperationalStatusEnum operationalStatus; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChangeAvailabilityRequest class + * + * @param operationalStatus The type of availability change that the Charging Station should + * perform. + */ + public ChangeAvailabilityRequest(OperationalStatusEnum operationalStatus) { + setOperationalStatus(operationalStatus); + } + + /** + * Gets electric Vehicle Supply Equipment + * + * @return Electric Vehicle Supply Equipment + */ + @Nullable + public EVSE getEvse() { + return evse; + } + + /** + * Sets electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + */ + public void setEvse(@Nullable EVSE evse) { + if (!isValidEvse(evse)) { + throw new PropertyConstraintException(evse, "evse is invalid"); + } + this.evse = evse; + } + + /** + * Returns whether the given evse is valid + * + * @param evse the evse to check the validity of + * @return {@code true} if evse is valid, {@code false} if not + */ + private boolean isValidEvse(@Nullable EVSE evse) { + return evse == null || evse.validate(); + } + + /** + * Adds electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + * @return this + */ + public ChangeAvailabilityRequest withEvse(@Nullable EVSE evse) { + setEvse(evse); + return this; + } + + /** + * Gets the type of availability change that the Charging Station should perform. + * + * @return The type of availability change that the Charging Station should perform + */ + public OperationalStatusEnum getOperationalStatus() { + return operationalStatus; + } + + /** + * Sets the type of availability change that the Charging Station should perform. + * + * @param operationalStatus The type of availability change that the Charging Station should + * perform + */ + public void setOperationalStatus(OperationalStatusEnum operationalStatus) { + if (!isValidOperationalStatus(operationalStatus)) { + throw new PropertyConstraintException(operationalStatus, "operationalStatus is invalid"); + } + this.operationalStatus = operationalStatus; + } + + /** + * Returns whether the given operationalStatus is valid + * + * @param operationalStatus the operationalStatus to check the validity of + * @return {@code true} if operationalStatus is valid, {@code false} if not + */ + private boolean isValidOperationalStatus(OperationalStatusEnum operationalStatus) { + return operationalStatus != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChangeAvailabilityRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvse(evse) + && isValidOperationalStatus(operationalStatus) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeAvailabilityRequest that = (ChangeAvailabilityRequest) o; + return Objects.equals(evse, that.evse) + && Objects.equals(operationalStatus, that.operationalStatus) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evse, operationalStatus, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evse", evse) + .add("operationalStatus", operationalStatus) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeAvailabilityResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeAvailabilityResponse.java new file mode 100644 index 00000000..53e8ed68 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeAvailabilityResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChangeAvailabilityStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ChangeAvailabilityResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ChangeAvailabilityResponse extends Confirmation { + /** Whether the Charging Station is able to perform the availability change. */ + private ChangeAvailabilityStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChangeAvailabilityResponse class + * + * @param status Whether the Charging Station is able to perform the availability change. + */ + public ChangeAvailabilityResponse(ChangeAvailabilityStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station is able to perform the availability change. + * + * @return Whether the Charging Station is able to perform the availability change + */ + public ChangeAvailabilityStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to perform the availability change. + * + * @param status Whether the Charging Station is able to perform the availability change + */ + public void setStatus(ChangeAvailabilityStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ChangeAvailabilityStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ChangeAvailabilityResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChangeAvailabilityResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeAvailabilityResponse that = (ChangeAvailabilityResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeTransactionTariffRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeTransactionTariffRequest.java new file mode 100644 index 00000000..2d642f4b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeTransactionTariffRequest.java @@ -0,0 +1,223 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.Tariff; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ChangeTransactionTariffRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ChangeTransactionTariffRequest extends RequestWithId { + /** + * A tariff is described by fields with prices for: energy, charging time, idle time, fixed fee, + * reservation time, + * + *

+   * reservation fixed fee.
+   * Each of these fields may have (optional) conditions that specify when a price is applicable.
+   * The description contains a human-readable explanation of the tariff to be shown to the user.
+   * The other fields are parameters that define the tariff. These are used by the charging station
+   * to calculate the price.
+   * 
+ */ + private Tariff tariff; + + /** Transaction id for new tariff. */ + private String transactionId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChangeTransactionTariffRequest class + * + * @param tariff A tariff is described by fields with prices for: energy, charging time, idle + * time, fixed fee, reservation time, + * @param transactionId Transaction id for new tariff. + */ + public ChangeTransactionTariffRequest(Tariff tariff, String transactionId) { + setTariff(tariff); + setTransactionId(transactionId); + } + + /** + * Gets a tariff is described by fields with prices for: energy, charging time, idle time, fixed + * fee, reservation time, + * + * @return A tariff is described by fields with prices for: energy, charging time, idle time, + * fixed fee, reservation time, + */ + public Tariff getTariff() { + return tariff; + } + + /** + * Sets a tariff is described by fields with prices for: energy, charging time, idle time, fixed + * fee, reservation time, + * + * @param tariff A tariff is described by fields with prices for: energy, charging time, idle + * time, fixed fee, reservation time, + */ + public void setTariff(Tariff tariff) { + if (!isValidTariff(tariff)) { + throw new PropertyConstraintException(tariff, "tariff is invalid"); + } + this.tariff = tariff; + } + + /** + * Returns whether the given tariff is valid + * + * @param tariff the tariff to check the validity of + * @return {@code true} if tariff is valid, {@code false} if not + */ + private boolean isValidTariff(Tariff tariff) { + return tariff != null && tariff.validate(); + } + + /** + * Gets transaction id for new tariff. + * + * @return Transaction id for new tariff + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets transaction id for new tariff. + * + * @param transactionId Transaction id for new tariff + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChangeTransactionTariffRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTariff(tariff) + && isValidTransactionId(transactionId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeTransactionTariffRequest that = (ChangeTransactionTariffRequest) o; + return Objects.equals(tariff, that.tariff) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(tariff, transactionId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("tariff", tariff) + .add("transactionId", transactionId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeTransactionTariffResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeTransactionTariffResponse.java new file mode 100644 index 00000000..1ac0b15a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ChangeTransactionTariffResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import eu.chargetime.ocpp.v21.model.types.TariffChangeStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ChangeTransactionTariffResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ChangeTransactionTariffResponse extends Confirmation { + /** Status of the operation */ + private TariffChangeStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChangeTransactionTariffResponse class + * + * @param status Status of the operation + */ + public ChangeTransactionTariffResponse(TariffChangeStatusEnum status) { + setStatus(status); + } + + /** + * Gets status of the operation + * + * @return Status of the operation + */ + public TariffChangeStatusEnum getStatus() { + return status; + } + + /** + * Sets status of the operation + * + * @param status Status of the operation + */ + public void setStatus(TariffChangeStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(TariffChangeStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ChangeTransactionTariffResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChangeTransactionTariffResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeTransactionTariffResponse that = (ChangeTransactionTariffResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearCacheRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearCacheRequest.java new file mode 100644 index 00000000..20bbdeab --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearCacheRequest.java @@ -0,0 +1,124 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearCacheRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearCacheRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ClearCacheRequest class */ + public ClearCacheRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearCacheRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearCacheRequest that = (ClearCacheRequest) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearCacheResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearCacheResponse.java new file mode 100644 index 00000000..5f896bde --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearCacheResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ClearCacheStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearCacheResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearCacheResponse extends Confirmation { + /** Accepted if the Charging Station has executed the request, otherwise rejected. */ + private ClearCacheStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearCacheResponse class + * + * @param status Accepted if the Charging Station has executed the request, otherwise rejected. + */ + public ClearCacheResponse(ClearCacheStatusEnum status) { + setStatus(status); + } + + /** + * Gets accepted if the Charging Station has executed the request, otherwise rejected. + * + * @return Accepted if the Charging Station has executed the request, otherwise rejected + */ + public ClearCacheStatusEnum getStatus() { + return status; + } + + /** + * Sets accepted if the Charging Station has executed the request, otherwise rejected. + * + * @param status Accepted if the Charging Station has executed the request, otherwise rejected + */ + public void setStatus(ClearCacheStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ClearCacheStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearCacheResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearCacheResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearCacheResponse that = (ClearCacheResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearChargingProfileRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearChargingProfileRequest.java new file mode 100644 index 00000000..1ef6fdb6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearChargingProfileRequest.java @@ -0,0 +1,220 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ClearChargingProfile; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearChargingProfileRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearChargingProfileRequest extends RequestWithId { + /** The Id of the charging profile to clear. */ + @Nullable private Integer chargingProfileId; + + /** + * A ClearChargingProfileType is a filter for charging profiles to be cleared by + * ClearChargingProfileRequest. + */ + @Nullable private ClearChargingProfile chargingProfileCriteria; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ClearChargingProfileRequest class */ + public ClearChargingProfileRequest() {} + + /** + * Gets the Id of the charging profile to clear. + * + * @return The Id of the charging profile to clear + */ + @Nullable + public Integer getChargingProfileId() { + return chargingProfileId; + } + + /** + * Sets the Id of the charging profile to clear. + * + * @param chargingProfileId The Id of the charging profile to clear + */ + public void setChargingProfileId(@Nullable Integer chargingProfileId) { + this.chargingProfileId = chargingProfileId; + } + + /** + * Adds the Id of the charging profile to clear. + * + * @param chargingProfileId The Id of the charging profile to clear + * @return this + */ + public ClearChargingProfileRequest withChargingProfileId(@Nullable Integer chargingProfileId) { + setChargingProfileId(chargingProfileId); + return this; + } + + /** + * Gets a ClearChargingProfileType is a filter for charging profiles to be cleared by + * ClearChargingProfileRequest. + * + * @return A ClearChargingProfileType is a filter for charging profiles to be cleared by + * ClearChargingProfileRequest + */ + @Nullable + public ClearChargingProfile getChargingProfileCriteria() { + return chargingProfileCriteria; + } + + /** + * Sets a ClearChargingProfileType is a filter for charging profiles to be cleared by + * ClearChargingProfileRequest. + * + * @param chargingProfileCriteria A ClearChargingProfileType is a filter for charging profiles to + * be cleared by ClearChargingProfileRequest + */ + public void setChargingProfileCriteria(@Nullable ClearChargingProfile chargingProfileCriteria) { + if (!isValidChargingProfileCriteria(chargingProfileCriteria)) { + throw new PropertyConstraintException( + chargingProfileCriteria, "chargingProfileCriteria is invalid"); + } + this.chargingProfileCriteria = chargingProfileCriteria; + } + + /** + * Returns whether the given chargingProfileCriteria is valid + * + * @param chargingProfileCriteria the chargingProfileCriteria to check the validity of + * @return {@code true} if chargingProfileCriteria is valid, {@code false} if not + */ + private boolean isValidChargingProfileCriteria( + @Nullable ClearChargingProfile chargingProfileCriteria) { + return chargingProfileCriteria == null || chargingProfileCriteria.validate(); + } + + /** + * Adds a ClearChargingProfileType is a filter for charging profiles to be cleared by + * ClearChargingProfileRequest. + * + * @param chargingProfileCriteria A ClearChargingProfileType is a filter for charging profiles to + * be cleared by ClearChargingProfileRequest + * @return this + */ + public ClearChargingProfileRequest withChargingProfileCriteria( + @Nullable ClearChargingProfile chargingProfileCriteria) { + setChargingProfileCriteria(chargingProfileCriteria); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearChargingProfileRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidChargingProfileCriteria(chargingProfileCriteria) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearChargingProfileRequest that = (ClearChargingProfileRequest) o; + return Objects.equals(chargingProfileId, that.chargingProfileId) + && Objects.equals(chargingProfileCriteria, that.chargingProfileCriteria) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(chargingProfileId, chargingProfileCriteria, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingProfileId", chargingProfileId) + .add("chargingProfileCriteria", chargingProfileCriteria) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearChargingProfileResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearChargingProfileResponse.java new file mode 100644 index 00000000..ab9e9222 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearChargingProfileResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ClearChargingProfileStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearChargingProfileResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearChargingProfileResponse extends Confirmation { + /** Whether the Charging Station was able to execute the request. */ + private ClearChargingProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearChargingProfileResponse class + * + * @param status Whether the Charging Station was able to execute the request. + */ + public ClearChargingProfileResponse(ClearChargingProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station was able to execute the request. + * + * @return Whether the Charging Station was able to execute the request + */ + public ClearChargingProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station was able to execute the request. + * + * @param status Whether the Charging Station was able to execute the request + */ + public void setStatus(ClearChargingProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ClearChargingProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearChargingProfileResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearChargingProfileResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearChargingProfileResponse that = (ClearChargingProfileResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDERControlRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDERControlRequest.java new file mode 100644 index 00000000..cedfbe87 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDERControlRequest.java @@ -0,0 +1,252 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DERControlEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearDERControlRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearDERControlRequest extends RequestWithId { + /** True: clearing default DER controls. False: clearing scheduled controls. */ + private Boolean isDefault; + + /** Name of control settings to clear. Not used when controlId is provided. */ + @Nullable private DERControlEnum controlType; + + /** Id of control setting to clear. When omitted all settings for controlType are cleared. */ + @Nullable private String controlId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearDERControlRequest class + * + * @param isDefault True: clearing default DER controls. False: clearing scheduled controls. + */ + public ClearDERControlRequest(Boolean isDefault) { + setIsDefault(isDefault); + } + + /** + * Gets true: clearing default DER controls. False: clearing scheduled controls. + * + * @return True: clearing default DER controls + */ + public Boolean getIsDefault() { + return isDefault; + } + + /** + * Sets true: clearing default DER controls. False: clearing scheduled controls. + * + * @param isDefault True: clearing default DER controls + */ + public void setIsDefault(Boolean isDefault) { + if (!isValidIsDefault(isDefault)) { + throw new PropertyConstraintException(isDefault, "isDefault is invalid"); + } + this.isDefault = isDefault; + } + + /** + * Returns whether the given isDefault is valid + * + * @param isDefault the isDefault to check the validity of + * @return {@code true} if isDefault is valid, {@code false} if not + */ + private boolean isValidIsDefault(Boolean isDefault) { + return isDefault != null; + } + + /** + * Gets name of control settings to clear. Not used when controlId is provided. + * + * @return Name of control settings to clear + */ + @Nullable + public DERControlEnum getControlType() { + return controlType; + } + + /** + * Sets name of control settings to clear. Not used when controlId is provided. + * + * @param controlType Name of control settings to clear + */ + public void setControlType(@Nullable DERControlEnum controlType) { + this.controlType = controlType; + } + + /** + * Adds name of control settings to clear. Not used when controlId is provided. + * + * @param controlType Name of control settings to clear + * @return this + */ + public ClearDERControlRequest withControlType(@Nullable DERControlEnum controlType) { + setControlType(controlType); + return this; + } + + /** + * Gets id of control setting to clear. When omitted all settings for controlType are cleared. + * + * @return Id of control setting to clear + */ + @Nullable + public String getControlId() { + return controlId; + } + + /** + * Sets id of control setting to clear. When omitted all settings for controlType are cleared. + * + * @param controlId Id of control setting to clear + */ + public void setControlId(@Nullable String controlId) { + if (!isValidControlId(controlId)) { + throw new PropertyConstraintException(controlId, "controlId is invalid"); + } + this.controlId = controlId; + } + + /** + * Returns whether the given controlId is valid + * + * @param controlId the controlId to check the validity of + * @return {@code true} if controlId is valid, {@code false} if not + */ + private boolean isValidControlId(@Nullable String controlId) { + return controlId == null || controlId.length() <= 36; + } + + /** + * Adds id of control setting to clear. When omitted all settings for controlType are cleared. + * + * @param controlId Id of control setting to clear + * @return this + */ + public ClearDERControlRequest withControlId(@Nullable String controlId) { + setControlId(controlId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearDERControlRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidIsDefault(isDefault) + && isValidControlId(controlId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearDERControlRequest that = (ClearDERControlRequest) o; + return Objects.equals(isDefault, that.isDefault) + && Objects.equals(controlType, that.controlType) + && Objects.equals(controlId, that.controlId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(isDefault, controlType, controlId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("isDefault", isDefault) + .add("controlType", controlType) + .add("controlId", controlId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDERControlResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDERControlResponse.java new file mode 100644 index 00000000..a0fa43fa --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDERControlResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DERControlStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearDERControlResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearDERControlResponse extends Confirmation { + /** Result of operation. */ + private DERControlStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearDERControlResponse class + * + * @param status Result of operation. + */ + public ClearDERControlResponse(DERControlStatusEnum status) { + setStatus(status); + } + + /** + * Gets result of operation. + * + * @return Result of operation + */ + public DERControlStatusEnum getStatus() { + return status; + } + + /** + * Sets result of operation. + * + * @param status Result of operation + */ + public void setStatus(DERControlStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DERControlStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearDERControlResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearDERControlResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearDERControlResponse that = (ClearDERControlResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDisplayMessageRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDisplayMessageRequest.java new file mode 100644 index 00000000..671cf12a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDisplayMessageRequest.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearDisplayMessageRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearDisplayMessageRequest extends RequestWithId { + /** Id of the message that SHALL be removed from the Charging Station. */ + private Integer id; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearDisplayMessageRequest class + * + * @param id Id of the message that SHALL be removed from the Charging Station. + */ + public ClearDisplayMessageRequest(Integer id) { + setId(id); + } + + /** + * Gets id of the message that SHALL be removed from the Charging Station. + * + * @return Id of the message that SHALL be removed from the Charging Station + */ + public Integer getId() { + return id; + } + + /** + * Sets id of the message that SHALL be removed from the Charging Station. + * + * @param id Id of the message that SHALL be removed from the Charging Station + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearDisplayMessageRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidId(id) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearDisplayMessageRequest that = (ClearDisplayMessageRequest) o; + return Objects.equals(id, that.id) && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(id, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDisplayMessageResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDisplayMessageResponse.java new file mode 100644 index 00000000..31b11560 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearDisplayMessageResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ClearMessageStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearDisplayMessageResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearDisplayMessageResponse extends Confirmation { + /** Returns whether the Charging Station has been able to remove the message. */ + private ClearMessageStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearDisplayMessageResponse class + * + * @param status Returns whether the Charging Station has been able to remove the message. + */ + public ClearDisplayMessageResponse(ClearMessageStatusEnum status) { + setStatus(status); + } + + /** + * Gets returns whether the Charging Station has been able to remove the message. + * + * @return Returns whether the Charging Station has been able to remove the message + */ + public ClearMessageStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether the Charging Station has been able to remove the message. + * + * @param status Returns whether the Charging Station has been able to remove the message + */ + public void setStatus(ClearMessageStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ClearMessageStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearDisplayMessageResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearDisplayMessageResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearDisplayMessageResponse that = (ClearDisplayMessageResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearTariffsRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearTariffsRequest.java new file mode 100644 index 00000000..0a5330c8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearTariffsRequest.java @@ -0,0 +1,223 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearTariffsRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearTariffsRequest extends RequestWithId { + /** List of tariff Ids to clear. When absent clears all tariffs at evseId. */ + @Nullable private String[] tariffIds; + + /** When present only clear tariffs matching tariffIds at EVSE evseId. */ + @Nullable private Integer evseId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ClearTariffsRequest class */ + public ClearTariffsRequest() {} + + /** + * Gets list of tariff Ids to clear. When absent clears all tariffs at evseId. + * + * @return List of tariff Ids to clear + */ + @Nullable + public String[] getTariffIds() { + return tariffIds; + } + + /** + * Sets list of tariff Ids to clear. When absent clears all tariffs at evseId. + * + * @param tariffIds List of tariff Ids to clear + */ + public void setTariffIds(@Nullable String[] tariffIds) { + if (!isValidTariffIds(tariffIds)) { + throw new PropertyConstraintException(tariffIds, "tariffIds is invalid"); + } + this.tariffIds = tariffIds; + } + + /** + * Returns whether the given tariffIds is valid + * + * @param tariffIds the tariffIds to check the validity of + * @return {@code true} if tariffIds is valid, {@code false} if not + */ + private boolean isValidTariffIds(@Nullable String[] tariffIds) { + return tariffIds == null + || (tariffIds.length >= 1 + && Arrays.stream(tariffIds).allMatch(item -> item.length() <= 60)); + } + + /** + * Adds list of tariff Ids to clear. When absent clears all tariffs at evseId. + * + * @param tariffIds List of tariff Ids to clear + * @return this + */ + public ClearTariffsRequest withTariffIds(@Nullable String[] tariffIds) { + setTariffIds(tariffIds); + return this; + } + + /** + * Gets when present only clear tariffs matching tariffIds at EVSE evseId. + * + * @return When present only clear tariffs matching tariffIds at EVSE evseId + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets when present only clear tariffs matching tariffIds at EVSE evseId. + * + * @param evseId When present only clear tariffs matching tariffIds at EVSE evseId + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds when present only clear tariffs matching tariffIds at EVSE evseId. + * + * @param evseId When present only clear tariffs matching tariffIds at EVSE evseId + * @return this + */ + public ClearTariffsRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearTariffsRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTariffIds(tariffIds) && isValidEvseId(evseId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearTariffsRequest that = (ClearTariffsRequest) o; + return Arrays.equals(tariffIds, that.tariffIds) + && Objects.equals(evseId, that.evseId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(tariffIds), evseId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("tariffIds", tariffIds) + .add("evseId", evseId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearTariffsResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearTariffsResponse.java new file mode 100644 index 00000000..f49e6f63 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearTariffsResponse.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ClearTariffsResult; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearTariffsResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearTariffsResponse extends Confirmation { + /** clearTariffsResult */ + private ClearTariffsResult[] clearTariffsResult; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearTariffsResponse class + * + * @param clearTariffsResult clearTariffsResult + */ + public ClearTariffsResponse(ClearTariffsResult[] clearTariffsResult) { + setClearTariffsResult(clearTariffsResult); + } + + /** + * Gets clearTariffsResult + * + * @return clearTariffsResult + */ + public ClearTariffsResult[] getClearTariffsResult() { + return clearTariffsResult; + } + + /** + * Sets clearTariffsResult + * + * @param clearTariffsResult clearTariffsResult + */ + public void setClearTariffsResult(ClearTariffsResult[] clearTariffsResult) { + if (!isValidClearTariffsResult(clearTariffsResult)) { + throw new PropertyConstraintException(clearTariffsResult, "clearTariffsResult is invalid"); + } + this.clearTariffsResult = clearTariffsResult; + } + + /** + * Returns whether the given clearTariffsResult is valid + * + * @param clearTariffsResult the clearTariffsResult to check the validity of + * @return {@code true} if clearTariffsResult is valid, {@code false} if not + */ + private boolean isValidClearTariffsResult(ClearTariffsResult[] clearTariffsResult) { + return clearTariffsResult != null + && clearTariffsResult.length >= 1 + && Arrays.stream(clearTariffsResult).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearTariffsResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidClearTariffsResult(clearTariffsResult) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearTariffsResponse that = (ClearTariffsResponse) o; + return Arrays.equals(clearTariffsResult, that.clearTariffsResult) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(clearTariffsResult), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("clearTariffsResult", clearTariffsResult) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearVariableMonitoringRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearVariableMonitoringRequest.java new file mode 100644 index 00000000..de8d54e3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearVariableMonitoringRequest.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearVariableMonitoringRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearVariableMonitoringRequest extends RequestWithId { + /** List of the monitors to be cleared, identified by there Id. */ + private Integer[] id; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearVariableMonitoringRequest class + * + * @param id List of the monitors to be cleared, identified by there Id. + */ + public ClearVariableMonitoringRequest(Integer[] id) { + setId(id); + } + + /** + * Gets list of the monitors to be cleared, identified by there Id. + * + * @return List of the monitors to be cleared, identified by there Id + */ + public Integer[] getId() { + return id; + } + + /** + * Sets list of the monitors to be cleared, identified by there Id. + * + * @param id List of the monitors to be cleared, identified by there Id + */ + public void setId(Integer[] id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer[] id) { + return id != null && id.length >= 1; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearVariableMonitoringRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidId(id) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearVariableMonitoringRequest that = (ClearVariableMonitoringRequest) o; + return Arrays.equals(id, that.id) && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(id), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearVariableMonitoringResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearVariableMonitoringResponse.java new file mode 100644 index 00000000..01ddedc6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearVariableMonitoringResponse.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ClearMonitoringResult; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearVariableMonitoringResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearVariableMonitoringResponse extends Confirmation { + /** clearMonitoringResult */ + private ClearMonitoringResult[] clearMonitoringResult; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearVariableMonitoringResponse class + * + * @param clearMonitoringResult clearMonitoringResult + */ + public ClearVariableMonitoringResponse(ClearMonitoringResult[] clearMonitoringResult) { + setClearMonitoringResult(clearMonitoringResult); + } + + /** + * Gets clearMonitoringResult + * + * @return clearMonitoringResult + */ + public ClearMonitoringResult[] getClearMonitoringResult() { + return clearMonitoringResult; + } + + /** + * Sets clearMonitoringResult + * + * @param clearMonitoringResult clearMonitoringResult + */ + public void setClearMonitoringResult(ClearMonitoringResult[] clearMonitoringResult) { + if (!isValidClearMonitoringResult(clearMonitoringResult)) { + throw new PropertyConstraintException( + clearMonitoringResult, "clearMonitoringResult is invalid"); + } + this.clearMonitoringResult = clearMonitoringResult; + } + + /** + * Returns whether the given clearMonitoringResult is valid + * + * @param clearMonitoringResult the clearMonitoringResult to check the validity of + * @return {@code true} if clearMonitoringResult is valid, {@code false} if not + */ + private boolean isValidClearMonitoringResult(ClearMonitoringResult[] clearMonitoringResult) { + return clearMonitoringResult != null + && clearMonitoringResult.length >= 1 + && Arrays.stream(clearMonitoringResult).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearVariableMonitoringResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidClearMonitoringResult(clearMonitoringResult) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearVariableMonitoringResponse that = (ClearVariableMonitoringResponse) o; + return Arrays.equals(clearMonitoringResult, that.clearMonitoringResult) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(clearMonitoringResult), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("clearMonitoringResult", clearMonitoringResult) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearedChargingLimitRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearedChargingLimitRequest.java new file mode 100644 index 00000000..85d69560 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearedChargingLimitRequest.java @@ -0,0 +1,222 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearedChargingLimitRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearedChargingLimitRequest extends RequestWithId { + /** + * Source of the charging limit. Allowed values defined in Appendix as + * ChargingLimitSourceEnumStringType. + */ + private String chargingLimitSource; + + /** EVSE Identifier. */ + @Nullable private Integer evseId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearedChargingLimitRequest class + * + * @param chargingLimitSource Source of the charging limit. Allowed values defined in Appendix as + * ChargingLimitSourceEnumStringType. + */ + public ClearedChargingLimitRequest(String chargingLimitSource) { + setChargingLimitSource(chargingLimitSource); + } + + /** + * Gets source of the charging limit. Allowed values defined in Appendix as + * ChargingLimitSourceEnumStringType. + * + * @return Source of the charging limit + */ + public String getChargingLimitSource() { + return chargingLimitSource; + } + + /** + * Sets source of the charging limit. Allowed values defined in Appendix as + * ChargingLimitSourceEnumStringType. + * + * @param chargingLimitSource Source of the charging limit + */ + public void setChargingLimitSource(String chargingLimitSource) { + if (!isValidChargingLimitSource(chargingLimitSource)) { + throw new PropertyConstraintException(chargingLimitSource, "chargingLimitSource is invalid"); + } + this.chargingLimitSource = chargingLimitSource; + } + + /** + * Returns whether the given chargingLimitSource is valid + * + * @param chargingLimitSource the chargingLimitSource to check the validity of + * @return {@code true} if chargingLimitSource is valid, {@code false} if not + */ + private boolean isValidChargingLimitSource(String chargingLimitSource) { + return chargingLimitSource != null && chargingLimitSource.length() <= 20; + } + + /** + * Gets EVSE Identifier. + * + * @return EVSE Identifier + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets EVSE Identifier. + * + * @param evseId EVSE Identifier + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds EVSE Identifier. + * + * @param evseId EVSE Identifier + * @return this + */ + public ClearedChargingLimitRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearedChargingLimitRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidChargingLimitSource(chargingLimitSource) + && isValidEvseId(evseId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearedChargingLimitRequest that = (ClearedChargingLimitRequest) o; + return Objects.equals(chargingLimitSource, that.chargingLimitSource) + && Objects.equals(evseId, that.evseId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(chargingLimitSource, evseId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingLimitSource", chargingLimitSource) + .add("evseId", evseId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearedChargingLimitResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearedChargingLimitResponse.java new file mode 100644 index 00000000..616c108f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClearedChargingLimitResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearedChargingLimitResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClearedChargingLimitResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ClearedChargingLimitResponse class */ + public ClearedChargingLimitResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearedChargingLimitResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearedChargingLimitResponse that = (ClearedChargingLimitResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClosePeriodicEventStreamRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClosePeriodicEventStreamRequest.java new file mode 100644 index 00000000..b7d932c2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClosePeriodicEventStreamRequest.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClosePeriodicEventStreamRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClosePeriodicEventStreamRequest extends RequestWithId { + /** Id of stream to close. */ + private Integer id; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClosePeriodicEventStreamRequest class + * + * @param id Id of stream to close. + */ + public ClosePeriodicEventStreamRequest(Integer id) { + setId(id); + } + + /** + * Gets id of stream to close. + * + * @return Id of stream to close + */ + public Integer getId() { + return id; + } + + /** + * Sets id of stream to close. + * + * @param id Id of stream to close + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClosePeriodicEventStreamRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidId(id) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClosePeriodicEventStreamRequest that = (ClosePeriodicEventStreamRequest) o; + return Objects.equals(id, that.id) && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(id, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClosePeriodicEventStreamResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClosePeriodicEventStreamResponse.java new file mode 100644 index 00000000..44a46be5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ClosePeriodicEventStreamResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClosePeriodicEventStreamResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ClosePeriodicEventStreamResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ClosePeriodicEventStreamResponse class */ + public ClosePeriodicEventStreamResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClosePeriodicEventStreamResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClosePeriodicEventStreamResponse that = (ClosePeriodicEventStreamResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CostUpdatedRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CostUpdatedRequest.java new file mode 100644 index 00000000..5893493c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CostUpdatedRequest.java @@ -0,0 +1,215 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CostUpdatedRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class CostUpdatedRequest extends RequestWithId { + /** + * Current total cost, based on the information known by the CSMS, of the transaction including + * taxes. In the currency configured with the configuration Variable: [Currency] + */ + private Double totalCost; + + /** Transaction Id of the transaction the current cost are asked for. */ + private String transactionId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CostUpdatedRequest class + * + * @param totalCost Current total cost, based on the information known by the CSMS, of the + * transaction including taxes. In the currency configured with the configuration Variable: + * [Currency] + * @param transactionId Transaction Id of the transaction the current cost are asked for. + */ + public CostUpdatedRequest(Double totalCost, String transactionId) { + setTotalCost(totalCost); + setTransactionId(transactionId); + } + + /** + * Gets current total cost, based on the information known by the CSMS, of the transaction + * including taxes. In the currency configured with the configuration Variable: [Currency] + * + * @return Current total cost, based on the information known by the CSMS, of the transaction + * including taxes + */ + public Double getTotalCost() { + return totalCost; + } + + /** + * Sets current total cost, based on the information known by the CSMS, of the transaction + * including taxes. In the currency configured with the configuration Variable: [Currency] + * + * @param totalCost Current total cost, based on the information known by the CSMS, of the + * transaction including taxes + */ + public void setTotalCost(Double totalCost) { + if (!isValidTotalCost(totalCost)) { + throw new PropertyConstraintException(totalCost, "totalCost is invalid"); + } + this.totalCost = totalCost; + } + + /** + * Returns whether the given totalCost is valid + * + * @param totalCost the totalCost to check the validity of + * @return {@code true} if totalCost is valid, {@code false} if not + */ + private boolean isValidTotalCost(Double totalCost) { + return totalCost != null; + } + + /** + * Gets transaction Id of the transaction the current cost are asked for. + * + * @return Transaction Id of the transaction the current cost are asked for + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets transaction Id of the transaction the current cost are asked for. + * + * @param transactionId Transaction Id of the transaction the current cost are asked for + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CostUpdatedRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTotalCost(totalCost) + && isValidTransactionId(transactionId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostUpdatedRequest that = (CostUpdatedRequest) o; + return Objects.equals(totalCost, that.totalCost) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(totalCost, transactionId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("totalCost", totalCost) + .add("transactionId", transactionId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CostUpdatedResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CostUpdatedResponse.java new file mode 100644 index 00000000..09c02c1f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CostUpdatedResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CostUpdatedResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class CostUpdatedResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the CostUpdatedResponse class */ + public CostUpdatedResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CostUpdatedResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostUpdatedResponse that = (CostUpdatedResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CustomerInformationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CustomerInformationRequest.java new file mode 100644 index 00000000..697353bc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CustomerInformationRequest.java @@ -0,0 +1,441 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateHashData; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.IdToken; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CustomerInformationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class CustomerInformationRequest extends RequestWithId { + /** customerCertificate */ + @Nullable private CertificateHashData customerCertificate; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken idToken; + + /** The Id of the request. */ + private Integer requestId; + + /** + * Flag indicating whether the Charging Station should return NotifyCustomerInformationRequest + * messages containing information about the customer referred to. + */ + private Boolean report; + + /** + * Flag indicating whether the Charging Station should clear all information about the customer + * referred to. + */ + private Boolean clear; + + /** + * A (e.g. vendor specific) identifier of the customer this request refers to. This field contains + * a custom identifier other than IdToken and Certificate. One of the possible identifiers + * (customerIdentifier, customerIdToken or customerCertificate) should be in the request message. + */ + @Nullable private String customerIdentifier; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CustomerInformationRequest class + * + * @param requestId The Id of the request. + * @param report Flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer + * referred to. + * @param clear Flag indicating whether the Charging Station should clear all information about + * the customer referred to. + */ + public CustomerInformationRequest(Integer requestId, Boolean report, Boolean clear) { + setRequestId(requestId); + setReport(report); + setClear(clear); + } + + /** + * Gets customerCertificate + * + * @return customerCertificate + */ + @Nullable + public CertificateHashData getCustomerCertificate() { + return customerCertificate; + } + + /** + * Sets customerCertificate + * + * @param customerCertificate customerCertificate + */ + public void setCustomerCertificate(@Nullable CertificateHashData customerCertificate) { + if (!isValidCustomerCertificate(customerCertificate)) { + throw new PropertyConstraintException(customerCertificate, "customerCertificate is invalid"); + } + this.customerCertificate = customerCertificate; + } + + /** + * Returns whether the given customerCertificate is valid + * + * @param customerCertificate the customerCertificate to check the validity of + * @return {@code true} if customerCertificate is valid, {@code false} if not + */ + private boolean isValidCustomerCertificate(@Nullable CertificateHashData customerCertificate) { + return customerCertificate == null || customerCertificate.validate(); + } + + /** + * Adds customerCertificate + * + * @param customerCertificate customerCertificate + * @return this + */ + public CustomerInformationRequest withCustomerCertificate( + @Nullable CertificateHashData customerCertificate) { + setCustomerCertificate(customerCertificate); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(@Nullable IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(@Nullable IdToken idToken) { + return idToken == null || idToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public CustomerInformationRequest withIdToken(@Nullable IdToken idToken) { + setIdToken(idToken); + return this; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null && requestId >= 0; + } + + /** + * Gets flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer referred + * to. + * + * @return Flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer + * referred to + */ + public Boolean getReport() { + return report; + } + + /** + * Sets flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer referred + * to. + * + * @param report Flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer + * referred to + */ + public void setReport(Boolean report) { + if (!isValidReport(report)) { + throw new PropertyConstraintException(report, "report is invalid"); + } + this.report = report; + } + + /** + * Returns whether the given report is valid + * + * @param report the report to check the validity of + * @return {@code true} if report is valid, {@code false} if not + */ + private boolean isValidReport(Boolean report) { + return report != null; + } + + /** + * Gets flag indicating whether the Charging Station should clear all information about the + * customer referred to. + * + * @return Flag indicating whether the Charging Station should clear all information about the + * customer referred to + */ + public Boolean getClear() { + return clear; + } + + /** + * Sets flag indicating whether the Charging Station should clear all information about the + * customer referred to. + * + * @param clear Flag indicating whether the Charging Station should clear all information about + * the customer referred to + */ + public void setClear(Boolean clear) { + if (!isValidClear(clear)) { + throw new PropertyConstraintException(clear, "clear is invalid"); + } + this.clear = clear; + } + + /** + * Returns whether the given clear is valid + * + * @param clear the clear to check the validity of + * @return {@code true} if clear is valid, {@code false} if not + */ + private boolean isValidClear(Boolean clear) { + return clear != null; + } + + /** + * Gets a (e.g. vendor specific) identifier of the customer this request refers to. This field + * contains a custom identifier other than IdToken and Certificate. One of the possible + * identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the + * request message. + * + * @return A (e.g. vendor specific) identifier of the customer this request refers to + */ + @Nullable + public String getCustomerIdentifier() { + return customerIdentifier; + } + + /** + * Sets a (e.g. vendor specific) identifier of the customer this request refers to. This field + * contains a custom identifier other than IdToken and Certificate. One of the possible + * identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the + * request message. + * + * @param customerIdentifier A (e.g. vendor specific) identifier of the customer this request + * refers to + */ + public void setCustomerIdentifier(@Nullable String customerIdentifier) { + if (!isValidCustomerIdentifier(customerIdentifier)) { + throw new PropertyConstraintException(customerIdentifier, "customerIdentifier is invalid"); + } + this.customerIdentifier = customerIdentifier; + } + + /** + * Returns whether the given customerIdentifier is valid + * + * @param customerIdentifier the customerIdentifier to check the validity of + * @return {@code true} if customerIdentifier is valid, {@code false} if not + */ + private boolean isValidCustomerIdentifier(@Nullable String customerIdentifier) { + return customerIdentifier == null || customerIdentifier.length() <= 64; + } + + /** + * Adds a (e.g. vendor specific) identifier of the customer this request refers to. This field + * contains a custom identifier other than IdToken and Certificate. One of the possible + * identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the + * request message. + * + * @param customerIdentifier A (e.g. vendor specific) identifier of the customer this request + * refers to + * @return this + */ + public CustomerInformationRequest withCustomerIdentifier(@Nullable String customerIdentifier) { + setCustomerIdentifier(customerIdentifier); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CustomerInformationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomerCertificate(customerCertificate) + && isValidIdToken(idToken) + && isValidRequestId(requestId) + && isValidReport(report) + && isValidClear(clear) + && isValidCustomerIdentifier(customerIdentifier) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomerInformationRequest that = (CustomerInformationRequest) o; + return Objects.equals(customerCertificate, that.customerCertificate) + && Objects.equals(idToken, that.idToken) + && Objects.equals(requestId, that.requestId) + && Objects.equals(report, that.report) + && Objects.equals(clear, that.clear) + && Objects.equals(customerIdentifier, that.customerIdentifier) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + customerCertificate, idToken, requestId, report, clear, customerIdentifier, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customerCertificate", customerCertificate) + .add("idToken", idToken) + .add("requestId", requestId) + .add("report", report) + .add("clear", clear) + .add("customerIdentifier", customerIdentifier) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CustomerInformationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CustomerInformationResponse.java new file mode 100644 index 00000000..f8038d1c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/CustomerInformationResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.CustomerInformationStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CustomerInformationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class CustomerInformationResponse extends Confirmation { + /** Whether the request was accepted. */ + private CustomerInformationStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CustomerInformationResponse class + * + * @param status Whether the request was accepted. + */ + public CustomerInformationResponse(CustomerInformationStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the request was accepted. + * + * @return Whether the request was accepted + */ + public CustomerInformationStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the request was accepted. + * + * @param status Whether the request was accepted + */ + public void setStatus(CustomerInformationStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(CustomerInformationStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public CustomerInformationResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CustomerInformationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomerInformationResponse that = (CustomerInformationResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DataTransferRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DataTransferRequest.java new file mode 100644 index 00000000..c88dc6b5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DataTransferRequest.java @@ -0,0 +1,257 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DataTransferRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class DataTransferRequest extends RequestWithId { + /** May be used to indicate a specific message or implementation. */ + @Nullable private String messageId; + + /** + * Data without specified length or format. This needs to be decided by both parties (Open to + * implementation). + */ + @Nullable private Object data; + + /** The identifier of the Vendor specific implementation */ + private String vendorId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the DataTransferRequest class + * + * @param vendorId The identifier of the Vendor specific implementation + */ + public DataTransferRequest(String vendorId) { + setVendorId(vendorId); + } + + /** + * Gets may be used to indicate a specific message or implementation. + * + * @return May be used to indicate a specific message or implementation + */ + @Nullable + public String getMessageId() { + return messageId; + } + + /** + * Sets may be used to indicate a specific message or implementation. + * + * @param messageId May be used to indicate a specific message or implementation + */ + public void setMessageId(@Nullable String messageId) { + if (!isValidMessageId(messageId)) { + throw new PropertyConstraintException(messageId, "messageId is invalid"); + } + this.messageId = messageId; + } + + /** + * Returns whether the given messageId is valid + * + * @param messageId the messageId to check the validity of + * @return {@code true} if messageId is valid, {@code false} if not + */ + private boolean isValidMessageId(@Nullable String messageId) { + return messageId == null || messageId.length() <= 50; + } + + /** + * Adds may be used to indicate a specific message or implementation. + * + * @param messageId May be used to indicate a specific message or implementation + * @return this + */ + public DataTransferRequest withMessageId(@Nullable String messageId) { + setMessageId(messageId); + return this; + } + + /** + * Gets data without specified length or format. This needs to be decided by both parties (Open to + * implementation). + * + * @return Data without specified length or format + */ + @Nullable + public Object getData() { + return data; + } + + /** + * Sets data without specified length or format. This needs to be decided by both parties (Open to + * implementation). + * + * @param data Data without specified length or format + */ + public void setData(@Nullable Object data) { + this.data = data; + } + + /** + * Adds data without specified length or format. This needs to be decided by both parties (Open to + * implementation). + * + * @param data Data without specified length or format + * @return this + */ + public DataTransferRequest withData(@Nullable Object data) { + setData(data); + return this; + } + + /** + * Gets the identifier of the Vendor specific implementation + * + * @return The identifier of the Vendor specific implementation + */ + public String getVendorId() { + return vendorId; + } + + /** + * Sets the identifier of the Vendor specific implementation + * + * @param vendorId The identifier of the Vendor specific implementation + */ + public void setVendorId(String vendorId) { + if (!isValidVendorId(vendorId)) { + throw new PropertyConstraintException(vendorId, "vendorId is invalid"); + } + this.vendorId = vendorId; + } + + /** + * Returns whether the given vendorId is valid + * + * @param vendorId the vendorId to check the validity of + * @return {@code true} if vendorId is valid, {@code false} if not + */ + private boolean isValidVendorId(String vendorId) { + return vendorId != null && vendorId.length() <= 255; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DataTransferRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidMessageId(messageId) + && isValidVendorId(vendorId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataTransferRequest that = (DataTransferRequest) o; + return Objects.equals(messageId, that.messageId) + && Objects.equals(data, that.data) + && Objects.equals(vendorId, that.vendorId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(messageId, data, vendorId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("messageId", messageId) + .add("data", data) + .add("vendorId", vendorId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DataTransferResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DataTransferResponse.java new file mode 100644 index 00000000..05fc7f22 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DataTransferResponse.java @@ -0,0 +1,246 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DataTransferStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DataTransferResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class DataTransferResponse extends Confirmation { + /** The success or failure of the data transfer. */ + private DataTransferStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Data without specified length or format, in response to request. */ + @Nullable private Object data; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the DataTransferResponse class + * + * @param status The success or failure of the data transfer. + */ + public DataTransferResponse(DataTransferStatusEnum status) { + setStatus(status); + } + + /** + * Gets the success or failure of the data transfer. + * + * @return The success or failure of the data transfer + */ + public DataTransferStatusEnum getStatus() { + return status; + } + + /** + * Sets the success or failure of the data transfer. + * + * @param status The success or failure of the data transfer + */ + public void setStatus(DataTransferStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DataTransferStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public DataTransferResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets data without specified length or format, in response to request. + * + * @return Data without specified length or format, in response to request + */ + @Nullable + public Object getData() { + return data; + } + + /** + * Sets data without specified length or format, in response to request. + * + * @param data Data without specified length or format, in response to request + */ + public void setData(@Nullable Object data) { + this.data = data; + } + + /** + * Adds data without specified length or format, in response to request. + * + * @param data Data without specified length or format, in response to request + * @return this + */ + public DataTransferResponse withData(@Nullable Object data) { + setData(data); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DataTransferResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataTransferResponse that = (DataTransferResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(data, that.data) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, data, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("data", data) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DeleteCertificateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DeleteCertificateRequest.java new file mode 100644 index 00000000..8bf25675 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DeleteCertificateRequest.java @@ -0,0 +1,167 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateHashData; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DeleteCertificateRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class DeleteCertificateRequest extends RequestWithId { + /** certificateHashData */ + private CertificateHashData certificateHashData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the DeleteCertificateRequest class + * + * @param certificateHashData certificateHashData + */ + public DeleteCertificateRequest(CertificateHashData certificateHashData) { + setCertificateHashData(certificateHashData); + } + + /** + * Gets certificateHashData + * + * @return certificateHashData + */ + public CertificateHashData getCertificateHashData() { + return certificateHashData; + } + + /** + * Sets certificateHashData + * + * @param certificateHashData certificateHashData + */ + public void setCertificateHashData(CertificateHashData certificateHashData) { + if (!isValidCertificateHashData(certificateHashData)) { + throw new PropertyConstraintException(certificateHashData, "certificateHashData is invalid"); + } + this.certificateHashData = certificateHashData; + } + + /** + * Returns whether the given certificateHashData is valid + * + * @param certificateHashData the certificateHashData to check the validity of + * @return {@code true} if certificateHashData is valid, {@code false} if not + */ + private boolean isValidCertificateHashData(CertificateHashData certificateHashData) { + return certificateHashData != null && certificateHashData.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DeleteCertificateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCertificateHashData(certificateHashData) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteCertificateRequest that = (DeleteCertificateRequest) o; + return Objects.equals(certificateHashData, that.certificateHashData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(certificateHashData, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateHashData", certificateHashData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DeleteCertificateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DeleteCertificateResponse.java new file mode 100644 index 00000000..a22151f7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/DeleteCertificateResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DeleteCertificateStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DeleteCertificateResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class DeleteCertificateResponse extends Confirmation { + /** Charging Station indicates if it can process the request. */ + private DeleteCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the DeleteCertificateResponse class + * + * @param status Charging Station indicates if it can process the request. + */ + public DeleteCertificateResponse(DeleteCertificateStatusEnum status) { + setStatus(status); + } + + /** + * Gets charging Station indicates if it can process the request. + * + * @return Charging Station indicates if it can process the request + */ + public DeleteCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets charging Station indicates if it can process the request. + * + * @param status Charging Station indicates if it can process the request + */ + public void setStatus(DeleteCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DeleteCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public DeleteCertificateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DeleteCertificateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteCertificateResponse that = (DeleteCertificateResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/FirmwareStatusNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/FirmwareStatusNotificationRequest.java new file mode 100644 index 00000000..abda192d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/FirmwareStatusNotificationRequest.java @@ -0,0 +1,264 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.FirmwareStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * FirmwareStatusNotificationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class FirmwareStatusNotificationRequest extends RequestWithId { + /** The progress status of the firmware installation. */ + private FirmwareStatusEnum status; + + /** + * The request id that was provided in the UpdateFirmwareRequest that started this firmware + * update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest + * AND there is no firmware update ongoing. + */ + @Nullable private Integer requestId; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the FirmwareStatusNotificationRequest class + * + * @param status The progress status of the firmware installation. + */ + public FirmwareStatusNotificationRequest(FirmwareStatusEnum status) { + setStatus(status); + } + + /** + * Gets the progress status of the firmware installation. + * + * @return The progress status of the firmware installation + */ + public FirmwareStatusEnum getStatus() { + return status; + } + + /** + * Sets the progress status of the firmware installation. + * + * @param status The progress status of the firmware installation + */ + public void setStatus(FirmwareStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(FirmwareStatusEnum status) { + return status != null; + } + + /** + * Gets the request id that was provided in the UpdateFirmwareRequest that started this firmware + * update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest + * AND there is no firmware update ongoing. + * + * @return The request id that was provided in the UpdateFirmwareRequest that started this + * firmware update + */ + @Nullable + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the request id that was provided in the UpdateFirmwareRequest that started this firmware + * update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest + * AND there is no firmware update ongoing. + * + * @param requestId The request id that was provided in the UpdateFirmwareRequest that started + * this firmware update + */ + public void setRequestId(@Nullable Integer requestId) { + this.requestId = requestId; + } + + /** + * Adds the request id that was provided in the UpdateFirmwareRequest that started this firmware + * update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest + * AND there is no firmware update ongoing. + * + * @param requestId The request id that was provided in the UpdateFirmwareRequest that started + * this firmware update + * @return this + */ + public FirmwareStatusNotificationRequest withRequestId(@Nullable Integer requestId) { + setRequestId(requestId); + return this; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public FirmwareStatusNotificationRequest withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FirmwareStatusNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FirmwareStatusNotificationRequest that = (FirmwareStatusNotificationRequest) o; + return Objects.equals(status, that.status) + && Objects.equals(requestId, that.requestId) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, requestId, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("requestId", requestId) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/FirmwareStatusNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/FirmwareStatusNotificationResponse.java new file mode 100644 index 00000000..500d82d0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/FirmwareStatusNotificationResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * FirmwareStatusNotificationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class FirmwareStatusNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the FirmwareStatusNotificationResponse class */ + public FirmwareStatusNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FirmwareStatusNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FirmwareStatusNotificationResponse that = (FirmwareStatusNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/Get15118EVCertificateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/Get15118EVCertificateRequest.java new file mode 100644 index 00000000..1b579d04 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/Get15118EVCertificateRequest.java @@ -0,0 +1,388 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateActionEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Get15118EVCertificateRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class Get15118EVCertificateRequest extends RequestWithId { + /** + * Schema version currently used for the 15118 session between EV and Charging Station. Needed for + * parsing of the EXI stream by the CSMS. + */ + private String iso15118SchemaVersion; + + /** Whether certificate needs to be installed or updated. */ + private CertificateActionEnum action; + + /** + * Raw CertificateInstallationReq request from EV, Base64 encoded. + * + *

Extended to support ISO 15118-20 certificates. The minimum supported length is 11000. If a + * longer exiRequest is supported, then the supported length must be communicated in variable + * OCPPCommCtrlr.FieldLength[ "Get15118EVCertificateRequest.exiRequest" ]. + */ + private String exiRequest; + + /** + * Absent during ISO 15118-2 session. Required during ISO 15118-20 session. + * + *

Maximum number of contracts that EV wants to install. + */ + @Nullable private Integer maximumContractCertificateChains; + + /** + * Absent during ISO 15118-2 session. Optional during ISO 15118-20 session. List of EMAIDs for + * which contract certificates must be requested first, in case there are more certificates than + * allowed by maximumContractCertificateChains. + */ + @Nullable private String[] prioritizedEMAIDs; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Get15118EVCertificateRequest class + * + * @param iso15118SchemaVersion Schema version currently used for the 15118 session between EV and + * Charging Station. Needed for parsing of the EXI stream by the CSMS. + * @param action Whether certificate needs to be installed or updated. + * @param exiRequest Raw CertificateInstallationReq request from EV, Base64 encoded. + */ + public Get15118EVCertificateRequest( + String iso15118SchemaVersion, CertificateActionEnum action, String exiRequest) { + setIso15118SchemaVersion(iso15118SchemaVersion); + setAction(action); + setExiRequest(exiRequest); + } + + /** + * Gets schema version currently used for the 15118 session between EV and Charging Station. + * Needed for parsing of the EXI stream by the CSMS. + * + * @return Schema version currently used for the 15118 session between EV and Charging Station + */ + public String getIso15118SchemaVersion() { + return iso15118SchemaVersion; + } + + /** + * Sets schema version currently used for the 15118 session between EV and Charging Station. + * Needed for parsing of the EXI stream by the CSMS. + * + * @param iso15118SchemaVersion Schema version currently used for the 15118 session between EV and + * Charging Station + */ + public void setIso15118SchemaVersion(String iso15118SchemaVersion) { + if (!isValidIso15118SchemaVersion(iso15118SchemaVersion)) { + throw new PropertyConstraintException( + iso15118SchemaVersion, "iso15118SchemaVersion is invalid"); + } + this.iso15118SchemaVersion = iso15118SchemaVersion; + } + + /** + * Returns whether the given iso15118SchemaVersion is valid + * + * @param iso15118SchemaVersion the iso15118SchemaVersion to check the validity of + * @return {@code true} if iso15118SchemaVersion is valid, {@code false} if not + */ + private boolean isValidIso15118SchemaVersion(String iso15118SchemaVersion) { + return iso15118SchemaVersion != null && iso15118SchemaVersion.length() <= 50; + } + + /** + * Gets whether certificate needs to be installed or updated. + * + * @return Whether certificate needs to be installed or updated + */ + public CertificateActionEnum getAction() { + return action; + } + + /** + * Sets whether certificate needs to be installed or updated. + * + * @param action Whether certificate needs to be installed or updated + */ + public void setAction(CertificateActionEnum action) { + if (!isValidAction(action)) { + throw new PropertyConstraintException(action, "action is invalid"); + } + this.action = action; + } + + /** + * Returns whether the given action is valid + * + * @param action the action to check the validity of + * @return {@code true} if action is valid, {@code false} if not + */ + private boolean isValidAction(CertificateActionEnum action) { + return action != null; + } + + /** + * Gets raw CertificateInstallationReq request from EV, Base64 encoded. + * + * @return Raw CertificateInstallationReq request from EV, Base64 encoded + */ + public String getExiRequest() { + return exiRequest; + } + + /** + * Sets raw CertificateInstallationReq request from EV, Base64 encoded. + * + * @param exiRequest Raw CertificateInstallationReq request from EV, Base64 encoded + */ + public void setExiRequest(String exiRequest) { + if (!isValidExiRequest(exiRequest)) { + throw new PropertyConstraintException(exiRequest, "exiRequest is invalid"); + } + this.exiRequest = exiRequest; + } + + /** + * Returns whether the given exiRequest is valid + * + * @param exiRequest the exiRequest to check the validity of + * @return {@code true} if exiRequest is valid, {@code false} if not + */ + private boolean isValidExiRequest(String exiRequest) { + return exiRequest != null && exiRequest.length() <= 11000; + } + + /** + * Gets absent during ISO 15118-2 session. Required during ISO 15118-20 session. + * + * @return Absent during ISO 15118-2 session + */ + @Nullable + public Integer getMaximumContractCertificateChains() { + return maximumContractCertificateChains; + } + + /** + * Sets absent during ISO 15118-2 session. Required during ISO 15118-20 session. + * + * @param maximumContractCertificateChains Absent during ISO 15118-2 session + */ + public void setMaximumContractCertificateChains( + @Nullable Integer maximumContractCertificateChains) { + if (!isValidMaximumContractCertificateChains(maximumContractCertificateChains)) { + throw new PropertyConstraintException( + maximumContractCertificateChains, "maximumContractCertificateChains is invalid"); + } + this.maximumContractCertificateChains = maximumContractCertificateChains; + } + + /** + * Returns whether the given maximumContractCertificateChains is valid + * + * @param maximumContractCertificateChains the maximumContractCertificateChains to check the + * validity of + * @return {@code true} if maximumContractCertificateChains is valid, {@code false} if not + */ + private boolean isValidMaximumContractCertificateChains( + @Nullable Integer maximumContractCertificateChains) { + return maximumContractCertificateChains == null || (maximumContractCertificateChains >= 0); + } + + /** + * Adds absent during ISO 15118-2 session. Required during ISO 15118-20 session. + * + * @param maximumContractCertificateChains Absent during ISO 15118-2 session + * @return this + */ + public Get15118EVCertificateRequest withMaximumContractCertificateChains( + @Nullable Integer maximumContractCertificateChains) { + setMaximumContractCertificateChains(maximumContractCertificateChains); + return this; + } + + /** + * Gets absent during ISO 15118-2 session. Optional during ISO 15118-20 session. List of EMAIDs + * for which contract certificates must be requested first, in case there are more certificates + * than allowed by maximumContractCertificateChains. + * + * @return Absent during ISO 15118-2 session + */ + @Nullable + public String[] getPrioritizedEMAIDs() { + return prioritizedEMAIDs; + } + + /** + * Sets absent during ISO 15118-2 session. Optional during ISO 15118-20 session. List of EMAIDs + * for which contract certificates must be requested first, in case there are more certificates + * than allowed by maximumContractCertificateChains. + * + * @param prioritizedEMAIDs Absent during ISO 15118-2 session + */ + public void setPrioritizedEMAIDs(@Nullable String[] prioritizedEMAIDs) { + if (!isValidPrioritizedEMAIDs(prioritizedEMAIDs)) { + throw new PropertyConstraintException(prioritizedEMAIDs, "prioritizedEMAIDs is invalid"); + } + this.prioritizedEMAIDs = prioritizedEMAIDs; + } + + /** + * Returns whether the given prioritizedEMAIDs is valid + * + * @param prioritizedEMAIDs the prioritizedEMAIDs to check the validity of + * @return {@code true} if prioritizedEMAIDs is valid, {@code false} if not + */ + private boolean isValidPrioritizedEMAIDs(@Nullable String[] prioritizedEMAIDs) { + return prioritizedEMAIDs == null + || (prioritizedEMAIDs.length >= 1 + && prioritizedEMAIDs.length <= 8 + && Arrays.stream(prioritizedEMAIDs).allMatch(item -> item.length() <= 255)); + } + + /** + * Adds absent during ISO 15118-2 session. Optional during ISO 15118-20 session. List of EMAIDs + * for which contract certificates must be requested first, in case there are more certificates + * than allowed by maximumContractCertificateChains. + * + * @param prioritizedEMAIDs Absent during ISO 15118-2 session + * @return this + */ + public Get15118EVCertificateRequest withPrioritizedEMAIDs(@Nullable String[] prioritizedEMAIDs) { + setPrioritizedEMAIDs(prioritizedEMAIDs); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Get15118EVCertificateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidIso15118SchemaVersion(iso15118SchemaVersion) + && isValidAction(action) + && isValidExiRequest(exiRequest) + && isValidMaximumContractCertificateChains(maximumContractCertificateChains) + && isValidPrioritizedEMAIDs(prioritizedEMAIDs) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Get15118EVCertificateRequest that = (Get15118EVCertificateRequest) o; + return Objects.equals(iso15118SchemaVersion, that.iso15118SchemaVersion) + && Objects.equals(action, that.action) + && Objects.equals(exiRequest, that.exiRequest) + && Objects.equals(maximumContractCertificateChains, that.maximumContractCertificateChains) + && Arrays.equals(prioritizedEMAIDs, that.prioritizedEMAIDs) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + iso15118SchemaVersion, + action, + exiRequest, + maximumContractCertificateChains, + Arrays.hashCode(prioritizedEMAIDs), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("iso15118SchemaVersion", iso15118SchemaVersion) + .add("action", action) + .add("exiRequest", exiRequest) + .add("maximumContractCertificateChains", maximumContractCertificateChains) + .add("prioritizedEMAIDs", prioritizedEMAIDs) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/Get15118EVCertificateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/Get15118EVCertificateResponse.java new file mode 100644 index 00000000..2037327d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/Get15118EVCertificateResponse.java @@ -0,0 +1,308 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.Iso15118EVCertificateStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Get15118EVCertificateResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class Get15118EVCertificateResponse extends Confirmation { + /** Whether the message was processed properly. */ + private Iso15118EVCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * *(2/1)* Raw CertificateInstallationRes response for the EV, Base64 encoded. + * + *

Extended to support ISO 15118-20 certificates. The minimum supported length is 17000. If a + * longer exiResponse is supported, then the supported length must be communicated in variable + * OCPPCommCtrlr.FieldLength[ "Get15118EVCertificateResponse.exiResponse" ]. + */ + private String exiResponse; + + /** Number of contracts that can be retrieved with additional requests. */ + @Nullable private Integer remainingContracts; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Get15118EVCertificateResponse class + * + * @param status Whether the message was processed properly. + * @param exiResponse *(2/1)* Raw CertificateInstallationRes response for the EV, Base64 encoded. + */ + public Get15118EVCertificateResponse(Iso15118EVCertificateStatusEnum status, String exiResponse) { + setStatus(status); + setExiResponse(exiResponse); + } + + /** + * Gets whether the message was processed properly. + * + * @return Whether the message was processed properly + */ + public Iso15118EVCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the message was processed properly. + * + * @param status Whether the message was processed properly + */ + public void setStatus(Iso15118EVCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(Iso15118EVCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public Get15118EVCertificateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets *(2/1)* Raw CertificateInstallationRes response for the EV, Base64 encoded. + * + * @return *(2/1)* Raw CertificateInstallationRes response for the EV, Base64 encoded + */ + public String getExiResponse() { + return exiResponse; + } + + /** + * Sets *(2/1)* Raw CertificateInstallationRes response for the EV, Base64 encoded. + * + * @param exiResponse *(2/1)* Raw CertificateInstallationRes response for the EV, Base64 encoded + */ + public void setExiResponse(String exiResponse) { + if (!isValidExiResponse(exiResponse)) { + throw new PropertyConstraintException(exiResponse, "exiResponse is invalid"); + } + this.exiResponse = exiResponse; + } + + /** + * Returns whether the given exiResponse is valid + * + * @param exiResponse the exiResponse to check the validity of + * @return {@code true} if exiResponse is valid, {@code false} if not + */ + private boolean isValidExiResponse(String exiResponse) { + return exiResponse != null && exiResponse.length() <= 17000; + } + + /** + * Gets number of contracts that can be retrieved with additional requests. + * + * @return Number of contracts that can be retrieved with additional requests + */ + @Nullable + public Integer getRemainingContracts() { + return remainingContracts; + } + + /** + * Sets number of contracts that can be retrieved with additional requests. + * + * @param remainingContracts Number of contracts that can be retrieved with additional requests + */ + public void setRemainingContracts(@Nullable Integer remainingContracts) { + if (!isValidRemainingContracts(remainingContracts)) { + throw new PropertyConstraintException(remainingContracts, "remainingContracts is invalid"); + } + this.remainingContracts = remainingContracts; + } + + /** + * Returns whether the given remainingContracts is valid + * + * @param remainingContracts the remainingContracts to check the validity of + * @return {@code true} if remainingContracts is valid, {@code false} if not + */ + private boolean isValidRemainingContracts(@Nullable Integer remainingContracts) { + return remainingContracts == null || (remainingContracts >= 0); + } + + /** + * Adds number of contracts that can be retrieved with additional requests. + * + * @param remainingContracts Number of contracts that can be retrieved with additional requests + * @return this + */ + public Get15118EVCertificateResponse withRemainingContracts( + @Nullable Integer remainingContracts) { + setRemainingContracts(remainingContracts); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Get15118EVCertificateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidExiResponse(exiResponse) + && isValidRemainingContracts(remainingContracts) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Get15118EVCertificateResponse that = (Get15118EVCertificateResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(exiResponse, that.exiResponse) + && Objects.equals(remainingContracts, that.remainingContracts) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, exiResponse, remainingContracts, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("exiResponse", exiResponse) + .add("remainingContracts", remainingContracts) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetBaseReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetBaseReportRequest.java new file mode 100644 index 00000000..46d9dd4a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetBaseReportRequest.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.ReportBaseEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetBaseReportRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetBaseReportRequest extends RequestWithId { + /** The Id of the request. */ + private Integer requestId; + + /** The report base. */ + private ReportBaseEnum reportBase; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetBaseReportRequest class + * + * @param requestId The Id of the request. + * @param reportBase The report base. + */ + public GetBaseReportRequest(Integer requestId, ReportBaseEnum reportBase) { + setRequestId(requestId); + setReportBase(reportBase); + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets the report base. + * + * @return The report base + */ + public ReportBaseEnum getReportBase() { + return reportBase; + } + + /** + * Sets the report base. + * + * @param reportBase The report base + */ + public void setReportBase(ReportBaseEnum reportBase) { + if (!isValidReportBase(reportBase)) { + throw new PropertyConstraintException(reportBase, "reportBase is invalid"); + } + this.reportBase = reportBase; + } + + /** + * Returns whether the given reportBase is valid + * + * @param reportBase the reportBase to check the validity of + * @return {@code true} if reportBase is valid, {@code false} if not + */ + private boolean isValidReportBase(ReportBaseEnum reportBase) { + return reportBase != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetBaseReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidRequestId(requestId) + && isValidReportBase(reportBase) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetBaseReportRequest that = (GetBaseReportRequest) o; + return Objects.equals(requestId, that.requestId) + && Objects.equals(reportBase, that.reportBase) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(requestId, reportBase, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("requestId", requestId) + .add("reportBase", reportBase) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetBaseReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetBaseReportResponse.java new file mode 100644 index 00000000..bf3e7299 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetBaseReportResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetBaseReportResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetBaseReportResponse extends Confirmation { + /** Whether the Charging Station is able to accept this request. */ + private GenericDeviceModelStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetBaseReportResponse class + * + * @param status Whether the Charging Station is able to accept this request. + */ + public GetBaseReportResponse(GenericDeviceModelStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station is able to accept this request. + * + * @return Whether the Charging Station is able to accept this request + */ + public GenericDeviceModelStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to accept this request. + * + * @param status Whether the Charging Station is able to accept this request + */ + public void setStatus(GenericDeviceModelStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericDeviceModelStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetBaseReportResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetBaseReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetBaseReportResponse that = (GetBaseReportResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateChainStatusRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateChainStatusRequest.java new file mode 100644 index 00000000..c94cf664 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateChainStatusRequest.java @@ -0,0 +1,178 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateStatusRequestInfo; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCertificateChainStatusRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetCertificateChainStatusRequest extends RequestWithId { + /** Data necessary to request the revocation status of a certificate. */ + private CertificateStatusRequestInfo[] certificateStatusRequests; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetCertificateChainStatusRequest class + * + * @param certificateStatusRequests Data necessary to request the revocation status of a + * certificate. + */ + public GetCertificateChainStatusRequest( + CertificateStatusRequestInfo[] certificateStatusRequests) { + setCertificateStatusRequests(certificateStatusRequests); + } + + /** + * Gets data necessary to request the revocation status of a certificate. + * + * @return Data necessary to request the revocation status of a certificate + */ + public CertificateStatusRequestInfo[] getCertificateStatusRequests() { + return certificateStatusRequests; + } + + /** + * Sets data necessary to request the revocation status of a certificate. + * + * @param certificateStatusRequests Data necessary to request the revocation status of a + * certificate + */ + public void setCertificateStatusRequests( + CertificateStatusRequestInfo[] certificateStatusRequests) { + if (!isValidCertificateStatusRequests(certificateStatusRequests)) { + throw new PropertyConstraintException( + certificateStatusRequests, "certificateStatusRequests is invalid"); + } + this.certificateStatusRequests = certificateStatusRequests; + } + + /** + * Returns whether the given certificateStatusRequests is valid + * + * @param certificateStatusRequests the certificateStatusRequests to check the validity of + * @return {@code true} if certificateStatusRequests is valid, {@code false} if not + */ + private boolean isValidCertificateStatusRequests( + CertificateStatusRequestInfo[] certificateStatusRequests) { + return certificateStatusRequests != null + && certificateStatusRequests.length >= 1 + && certificateStatusRequests.length <= 4 + && Arrays.stream(certificateStatusRequests).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCertificateChainStatusRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCertificateStatusRequests(certificateStatusRequests) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCertificateChainStatusRequest that = (GetCertificateChainStatusRequest) o; + return Arrays.equals(certificateStatusRequests, that.certificateStatusRequests) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(certificateStatusRequests), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateStatusRequests", certificateStatusRequests) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateChainStatusResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateChainStatusResponse.java new file mode 100644 index 00000000..00697a46 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateChainStatusResponse.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateStatus; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCertificateChainStatusResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetCertificateChainStatusResponse extends Confirmation { + /** Revocation status of certificate */ + private CertificateStatus[] certificateStatus; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetCertificateChainStatusResponse class + * + * @param certificateStatus Revocation status of certificate + */ + public GetCertificateChainStatusResponse(CertificateStatus[] certificateStatus) { + setCertificateStatus(certificateStatus); + } + + /** + * Gets revocation status of certificate + * + * @return Revocation status of certificate + */ + public CertificateStatus[] getCertificateStatus() { + return certificateStatus; + } + + /** + * Sets revocation status of certificate + * + * @param certificateStatus Revocation status of certificate + */ + public void setCertificateStatus(CertificateStatus[] certificateStatus) { + if (!isValidCertificateStatus(certificateStatus)) { + throw new PropertyConstraintException(certificateStatus, "certificateStatus is invalid"); + } + this.certificateStatus = certificateStatus; + } + + /** + * Returns whether the given certificateStatus is valid + * + * @param certificateStatus the certificateStatus to check the validity of + * @return {@code true} if certificateStatus is valid, {@code false} if not + */ + private boolean isValidCertificateStatus(CertificateStatus[] certificateStatus) { + return certificateStatus != null + && certificateStatus.length >= 1 + && certificateStatus.length <= 4 + && Arrays.stream(certificateStatus).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCertificateChainStatusResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCertificateStatus(certificateStatus) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCertificateChainStatusResponse that = (GetCertificateChainStatusResponse) o; + return Arrays.equals(certificateStatus, that.certificateStatus) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(certificateStatus), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateStatus", certificateStatus) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateStatusRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateStatusRequest.java new file mode 100644 index 00000000..8ad033ca --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateStatusRequest.java @@ -0,0 +1,167 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.OCSPRequestData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCertificateStatusRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetCertificateStatusRequest extends RequestWithId { + /** Information about a certificate for an OCSP check. */ + private OCSPRequestData ocspRequestData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetCertificateStatusRequest class + * + * @param ocspRequestData Information about a certificate for an OCSP check. + */ + public GetCertificateStatusRequest(OCSPRequestData ocspRequestData) { + setOcspRequestData(ocspRequestData); + } + + /** + * Gets information about a certificate for an OCSP check. + * + * @return Information about a certificate for an OCSP check + */ + public OCSPRequestData getOcspRequestData() { + return ocspRequestData; + } + + /** + * Sets information about a certificate for an OCSP check. + * + * @param ocspRequestData Information about a certificate for an OCSP check + */ + public void setOcspRequestData(OCSPRequestData ocspRequestData) { + if (!isValidOcspRequestData(ocspRequestData)) { + throw new PropertyConstraintException(ocspRequestData, "ocspRequestData is invalid"); + } + this.ocspRequestData = ocspRequestData; + } + + /** + * Returns whether the given ocspRequestData is valid + * + * @param ocspRequestData the ocspRequestData to check the validity of + * @return {@code true} if ocspRequestData is valid, {@code false} if not + */ + private boolean isValidOcspRequestData(OCSPRequestData ocspRequestData) { + return ocspRequestData != null && ocspRequestData.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCertificateStatusRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidOcspRequestData(ocspRequestData) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCertificateStatusRequest that = (GetCertificateStatusRequest) o; + return Objects.equals(ocspRequestData, that.ocspRequestData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(ocspRequestData, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("ocspRequestData", ocspRequestData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateStatusResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateStatusResponse.java new file mode 100644 index 00000000..0746bdcf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCertificateStatusResponse.java @@ -0,0 +1,272 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GetCertificateStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCertificateStatusResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetCertificateStatusResponse extends Confirmation { + /** Whether the charging station was able to retrieve the OCSP certificate status. */ + private GetCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), and + * then base64 encoded. MAY only be omitted when status is not Accepted. + * + *

The minimum supported length is 18000. If a longer ocspResult is supported, then the + * supported length must be communicated in variable OCPPCommCtrlr.FieldLength[ + * "GetCertificateStatusResponse.ocspResult" ]. + */ + @Nullable private String ocspResult; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetCertificateStatusResponse class + * + * @param status Whether the charging station was able to retrieve the OCSP certificate status. + */ + public GetCertificateStatusResponse(GetCertificateStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the charging station was able to retrieve the OCSP certificate status. + * + * @return Whether the charging station was able to retrieve the OCSP certificate status + */ + public GetCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the charging station was able to retrieve the OCSP certificate status. + * + * @param status Whether the charging station was able to retrieve the OCSP certificate status + */ + public void setStatus(GetCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GetCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetCertificateStatusResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), + * and then base64 encoded. MAY only be omitted when status is not Accepted. + * + * @return OCSPResponse class as defined in IETF RFC 6960 + */ + @Nullable + public String getOcspResult() { + return ocspResult; + } + + /** + * Sets OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), + * and then base64 encoded. MAY only be omitted when status is not Accepted. + * + * @param ocspResult OCSPResponse class as defined in IETF RFC 6960 + */ + public void setOcspResult(@Nullable String ocspResult) { + if (!isValidOcspResult(ocspResult)) { + throw new PropertyConstraintException(ocspResult, "ocspResult is invalid"); + } + this.ocspResult = ocspResult; + } + + /** + * Returns whether the given ocspResult is valid + * + * @param ocspResult the ocspResult to check the validity of + * @return {@code true} if ocspResult is valid, {@code false} if not + */ + private boolean isValidOcspResult(@Nullable String ocspResult) { + return ocspResult == null || ocspResult.length() <= 18000; + } + + /** + * Adds OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), + * and then base64 encoded. MAY only be omitted when status is not Accepted. + * + * @param ocspResult OCSPResponse class as defined in IETF RFC 6960 + * @return this + */ + public GetCertificateStatusResponse withOcspResult(@Nullable String ocspResult) { + setOcspResult(ocspResult); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCertificateStatusResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidOcspResult(ocspResult) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCertificateStatusResponse that = (GetCertificateStatusResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(ocspResult, that.ocspResult) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, ocspResult, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("ocspResult", ocspResult) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetChargingProfilesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetChargingProfilesRequest.java new file mode 100644 index 00000000..352f2b68 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetChargingProfilesRequest.java @@ -0,0 +1,284 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingProfileCriterion; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetChargingProfilesRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetChargingProfilesRequest extends RequestWithId { + /** + * Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + */ + private Integer requestId; + + /** + * For which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles + * installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, + * all installed charging profiles SHALL be reported. + * + *

Reported charging profiles SHALL match the criteria in field chargingProfile. + */ + @Nullable private Integer evseId; + + /** + * A ChargingProfileCriterionType is a filter for charging profiles to be selected by a + * GetChargingProfilesRequest. + */ + private ChargingProfileCriterion chargingProfile; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetChargingProfilesRequest class + * + * @param requestId Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + * @param chargingProfile A ChargingProfileCriterionType is a filter for charging profiles to be + * selected by a GetChargingProfilesRequest. + */ + public GetChargingProfilesRequest(Integer requestId, ChargingProfileCriterion chargingProfile) { + setRequestId(requestId); + setChargingProfile(chargingProfile); + } + + /** + * Gets reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + * + * @return Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + * + * @param requestId Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets for which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles + * installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, + * all installed charging profiles SHALL be reported. + * + * @return For which EVSE installed charging profiles SHALL be reported + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets for which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles + * installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, + * all installed charging profiles SHALL be reported. + * + * @param evseId For which EVSE installed charging profiles SHALL be reported + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds for which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles + * installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, + * all installed charging profiles SHALL be reported. + * + * @param evseId For which EVSE installed charging profiles SHALL be reported + * @return this + */ + public GetChargingProfilesRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets a ChargingProfileCriterionType is a filter for charging profiles to be selected by a + * GetChargingProfilesRequest. + * + * @return A ChargingProfileCriterionType is a filter for charging profiles to be selected by a + * GetChargingProfilesRequest + */ + public ChargingProfileCriterion getChargingProfile() { + return chargingProfile; + } + + /** + * Sets a ChargingProfileCriterionType is a filter for charging profiles to be selected by a + * GetChargingProfilesRequest. + * + * @param chargingProfile A ChargingProfileCriterionType is a filter for charging profiles to be + * selected by a GetChargingProfilesRequest + */ + public void setChargingProfile(ChargingProfileCriterion chargingProfile) { + if (!isValidChargingProfile(chargingProfile)) { + throw new PropertyConstraintException(chargingProfile, "chargingProfile is invalid"); + } + this.chargingProfile = chargingProfile; + } + + /** + * Returns whether the given chargingProfile is valid + * + * @param chargingProfile the chargingProfile to check the validity of + * @return {@code true} if chargingProfile is valid, {@code false} if not + */ + private boolean isValidChargingProfile(ChargingProfileCriterion chargingProfile) { + return chargingProfile != null && chargingProfile.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetChargingProfilesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidRequestId(requestId) + && isValidEvseId(evseId) + && isValidChargingProfile(chargingProfile) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetChargingProfilesRequest that = (GetChargingProfilesRequest) o; + return Objects.equals(requestId, that.requestId) + && Objects.equals(evseId, that.evseId) + && Objects.equals(chargingProfile, that.chargingProfile) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(requestId, evseId, chargingProfile, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("requestId", requestId) + .add("evseId", evseId) + .add("chargingProfile", chargingProfile) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetChargingProfilesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetChargingProfilesResponse.java new file mode 100644 index 00000000..88246777 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetChargingProfilesResponse.java @@ -0,0 +1,219 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GetChargingProfileStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetChargingProfilesResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetChargingProfilesResponse extends Confirmation { + /** + * Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + */ + private GetChargingProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetChargingProfilesResponse class + * + * @param status Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + */ + public GetChargingProfilesResponse(GetChargingProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + * + * @return Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages + */ + public GetChargingProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + * + * @param status Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages + */ + public void setStatus(GetChargingProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GetChargingProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetChargingProfilesResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetChargingProfilesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetChargingProfilesResponse that = (GetChargingProfilesResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCompositeScheduleRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCompositeScheduleRequest.java new file mode 100644 index 00000000..ae917aa1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCompositeScheduleRequest.java @@ -0,0 +1,247 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingRateUnitEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCompositeScheduleRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetCompositeScheduleRequest extends RequestWithId { + /** Length of the requested schedule in seconds. */ + private Integer duration; + + /** Can be used to force a power or current profile. */ + @Nullable private ChargingRateUnitEnum chargingRateUnit; + + /** + * The ID of the EVSE for which the schedule is requested. When evseid=0, the Charging Station + * will calculate the expected consumption for the grid connection. + */ + private Integer evseId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetCompositeScheduleRequest class + * + * @param duration Length of the requested schedule in seconds. + * @param evseId The ID of the EVSE for which the schedule is requested. When evseid=0, the + * Charging Station will calculate the expected consumption for the grid connection. + */ + public GetCompositeScheduleRequest(Integer duration, Integer evseId) { + setDuration(duration); + setEvseId(evseId); + } + + /** + * Gets length of the requested schedule in seconds. + * + * @return Length of the requested schedule in seconds + */ + public Integer getDuration() { + return duration; + } + + /** + * Sets length of the requested schedule in seconds. + * + * @param duration Length of the requested schedule in seconds + */ + public void setDuration(Integer duration) { + if (!isValidDuration(duration)) { + throw new PropertyConstraintException(duration, "duration is invalid"); + } + this.duration = duration; + } + + /** + * Returns whether the given duration is valid + * + * @param duration the duration to check the validity of + * @return {@code true} if duration is valid, {@code false} if not + */ + private boolean isValidDuration(Integer duration) { + return duration != null; + } + + /** + * Gets can be used to force a power or current profile. + * + * @return Can be used to force a power or current profile + */ + @Nullable + public ChargingRateUnitEnum getChargingRateUnit() { + return chargingRateUnit; + } + + /** + * Sets can be used to force a power or current profile. + * + * @param chargingRateUnit Can be used to force a power or current profile + */ + public void setChargingRateUnit(@Nullable ChargingRateUnitEnum chargingRateUnit) { + this.chargingRateUnit = chargingRateUnit; + } + + /** + * Adds can be used to force a power or current profile. + * + * @param chargingRateUnit Can be used to force a power or current profile + * @return this + */ + public GetCompositeScheduleRequest withChargingRateUnit( + @Nullable ChargingRateUnitEnum chargingRateUnit) { + setChargingRateUnit(chargingRateUnit); + return this; + } + + /** + * Gets the ID of the EVSE for which the schedule is requested. When evseid=0, the Charging + * Station will calculate the expected consumption for the grid connection. + * + * @return The ID of the EVSE for which the schedule is requested + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the ID of the EVSE for which the schedule is requested. When evseid=0, the Charging + * Station will calculate the expected consumption for the grid connection. + * + * @param evseId The ID of the EVSE for which the schedule is requested + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCompositeScheduleRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidDuration(duration) && isValidEvseId(evseId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCompositeScheduleRequest that = (GetCompositeScheduleRequest) o; + return Objects.equals(duration, that.duration) + && Objects.equals(chargingRateUnit, that.chargingRateUnit) + && Objects.equals(evseId, that.evseId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(duration, chargingRateUnit, evseId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("duration", duration) + .add("chargingRateUnit", chargingRateUnit) + .add("evseId", evseId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCompositeScheduleResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCompositeScheduleResponse.java new file mode 100644 index 00000000..24c4a847 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetCompositeScheduleResponse.java @@ -0,0 +1,263 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CompositeSchedule; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCompositeScheduleResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetCompositeScheduleResponse extends Confirmation { + /** The Charging Station will indicate if it was able to process the request */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** schedule */ + @Nullable private CompositeSchedule schedule; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetCompositeScheduleResponse class + * + * @param status The Charging Station will indicate if it was able to process the request + */ + public GetCompositeScheduleResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets the Charging Station will indicate if it was able to process the request + * + * @return The Charging Station will indicate if it was able to process the request + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets the Charging Station will indicate if it was able to process the request + * + * @param status The Charging Station will indicate if it was able to process the request + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetCompositeScheduleResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets schedule + * + * @return schedule + */ + @Nullable + public CompositeSchedule getSchedule() { + return schedule; + } + + /** + * Sets schedule + * + * @param schedule schedule + */ + public void setSchedule(@Nullable CompositeSchedule schedule) { + if (!isValidSchedule(schedule)) { + throw new PropertyConstraintException(schedule, "schedule is invalid"); + } + this.schedule = schedule; + } + + /** + * Returns whether the given schedule is valid + * + * @param schedule the schedule to check the validity of + * @return {@code true} if schedule is valid, {@code false} if not + */ + private boolean isValidSchedule(@Nullable CompositeSchedule schedule) { + return schedule == null || schedule.validate(); + } + + /** + * Adds schedule + * + * @param schedule schedule + * @return this + */ + public GetCompositeScheduleResponse withSchedule(@Nullable CompositeSchedule schedule) { + setSchedule(schedule); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCompositeScheduleResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidSchedule(schedule) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCompositeScheduleResponse that = (GetCompositeScheduleResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(schedule, that.schedule) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, schedule, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("schedule", schedule) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDERControlRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDERControlRequest.java new file mode 100644 index 00000000..22e14633 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDERControlRequest.java @@ -0,0 +1,287 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DERControlEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetDERControlRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetDERControlRequest extends RequestWithId { + /** RequestId to be used in ReportDERControlRequest. */ + private Integer requestId; + + /** True: get a default DER control. False: get a scheduled control. */ + @Nullable private Boolean isDefault; + + /** Type of control settings to retrieve. Not used when controlId is provided. */ + @Nullable private DERControlEnum controlType; + + /** Id of setting to get. When omitted all settings for controlType are retrieved. */ + @Nullable private String controlId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetDERControlRequest class + * + * @param requestId RequestId to be used in ReportDERControlRequest. + */ + public GetDERControlRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets requestId to be used in ReportDERControlRequest. + * + * @return RequestId to be used in ReportDERControlRequest + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets requestId to be used in ReportDERControlRequest. + * + * @param requestId RequestId to be used in ReportDERControlRequest + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets true: get a default DER control. False: get a scheduled control. + * + * @return True: get a default DER control + */ + @Nullable + public Boolean getIsDefault() { + return isDefault; + } + + /** + * Sets true: get a default DER control. False: get a scheduled control. + * + * @param isDefault True: get a default DER control + */ + public void setIsDefault(@Nullable Boolean isDefault) { + this.isDefault = isDefault; + } + + /** + * Adds true: get a default DER control. False: get a scheduled control. + * + * @param isDefault True: get a default DER control + * @return this + */ + public GetDERControlRequest withIsDefault(@Nullable Boolean isDefault) { + setIsDefault(isDefault); + return this; + } + + /** + * Gets type of control settings to retrieve. Not used when controlId is provided. + * + * @return Type of control settings to retrieve + */ + @Nullable + public DERControlEnum getControlType() { + return controlType; + } + + /** + * Sets type of control settings to retrieve. Not used when controlId is provided. + * + * @param controlType Type of control settings to retrieve + */ + public void setControlType(@Nullable DERControlEnum controlType) { + this.controlType = controlType; + } + + /** + * Adds type of control settings to retrieve. Not used when controlId is provided. + * + * @param controlType Type of control settings to retrieve + * @return this + */ + public GetDERControlRequest withControlType(@Nullable DERControlEnum controlType) { + setControlType(controlType); + return this; + } + + /** + * Gets id of setting to get. When omitted all settings for controlType are retrieved. + * + * @return Id of setting to get + */ + @Nullable + public String getControlId() { + return controlId; + } + + /** + * Sets id of setting to get. When omitted all settings for controlType are retrieved. + * + * @param controlId Id of setting to get + */ + public void setControlId(@Nullable String controlId) { + if (!isValidControlId(controlId)) { + throw new PropertyConstraintException(controlId, "controlId is invalid"); + } + this.controlId = controlId; + } + + /** + * Returns whether the given controlId is valid + * + * @param controlId the controlId to check the validity of + * @return {@code true} if controlId is valid, {@code false} if not + */ + private boolean isValidControlId(@Nullable String controlId) { + return controlId == null || controlId.length() <= 36; + } + + /** + * Adds id of setting to get. When omitted all settings for controlType are retrieved. + * + * @param controlId Id of setting to get + * @return this + */ + public GetDERControlRequest withControlId(@Nullable String controlId) { + setControlId(controlId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetDERControlRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidRequestId(requestId) + && isValidControlId(controlId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetDERControlRequest that = (GetDERControlRequest) o; + return Objects.equals(requestId, that.requestId) + && Objects.equals(isDefault, that.isDefault) + && Objects.equals(controlType, that.controlType) + && Objects.equals(controlId, that.controlId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(requestId, isDefault, controlType, controlId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("requestId", requestId) + .add("isDefault", isDefault) + .add("controlType", controlType) + .add("controlId", controlId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDERControlResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDERControlResponse.java new file mode 100644 index 00000000..c9d4da29 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDERControlResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DERControlStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetDERControlResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetDERControlResponse extends Confirmation { + /** Result of operation. */ + private DERControlStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetDERControlResponse class + * + * @param status Result of operation. + */ + public GetDERControlResponse(DERControlStatusEnum status) { + setStatus(status); + } + + /** + * Gets result of operation. + * + * @return Result of operation + */ + public DERControlStatusEnum getStatus() { + return status; + } + + /** + * Sets result of operation. + * + * @param status Result of operation + */ + public void setStatus(DERControlStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DERControlStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetDERControlResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetDERControlResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetDERControlResponse that = (GetDERControlResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDisplayMessagesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDisplayMessagesRequest.java new file mode 100644 index 00000000..72b27c4c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDisplayMessagesRequest.java @@ -0,0 +1,304 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.MessagePriorityEnum; +import eu.chargetime.ocpp.v21.model.types.MessageStateEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetDisplayMessagesRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetDisplayMessagesRequest extends RequestWithId { + /** + * If provided the Charging Station shall return Display Messages of the given ids. This field + * SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit + */ + @Nullable private Integer[] id; + + /** The Id of this request. */ + private Integer requestId; + + /** + * If provided the Charging Station shall return Display Messages with the given priority only. + */ + @Nullable private MessagePriorityEnum priority; + + /** If provided the Charging Station shall return Display Messages with the given state only. */ + @Nullable private MessageStateEnum state; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetDisplayMessagesRequest class + * + * @param requestId The Id of this request. + */ + public GetDisplayMessagesRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets if provided the Charging Station shall return Display Messages of the given ids. This + * field SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit + * + * @return If provided the Charging Station shall return Display Messages of the given ids + */ + @Nullable + public Integer[] getId() { + return id; + } + + /** + * Sets if provided the Charging Station shall return Display Messages of the given ids. This + * field SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit + * + * @param id If provided the Charging Station shall return Display Messages of the given ids + */ + public void setId(@Nullable Integer[] id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(@Nullable Integer[] id) { + return id == null || (id.length >= 1); + } + + /** + * Adds if provided the Charging Station shall return Display Messages of the given ids. This + * field SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit + * + * @param id If provided the Charging Station shall return Display Messages of the given ids + * @return this + */ + public GetDisplayMessagesRequest withId(@Nullable Integer[] id) { + setId(id); + return this; + } + + /** + * Gets the Id of this request. + * + * @return The Id of this request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of this request. + * + * @param requestId The Id of this request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets if provided the Charging Station shall return Display Messages with the given priority + * only. + * + * @return If provided the Charging Station shall return Display Messages with the given priority + * only + */ + @Nullable + public MessagePriorityEnum getPriority() { + return priority; + } + + /** + * Sets if provided the Charging Station shall return Display Messages with the given priority + * only. + * + * @param priority If provided the Charging Station shall return Display Messages with the given + * priority only + */ + public void setPriority(@Nullable MessagePriorityEnum priority) { + this.priority = priority; + } + + /** + * Adds if provided the Charging Station shall return Display Messages with the given priority + * only. + * + * @param priority If provided the Charging Station shall return Display Messages with the given + * priority only + * @return this + */ + public GetDisplayMessagesRequest withPriority(@Nullable MessagePriorityEnum priority) { + setPriority(priority); + return this; + } + + /** + * Gets if provided the Charging Station shall return Display Messages with the given state only. + * + * @return If provided the Charging Station shall return Display Messages with the given state + * only + */ + @Nullable + public MessageStateEnum getState() { + return state; + } + + /** + * Sets if provided the Charging Station shall return Display Messages with the given state only. + * + * @param state If provided the Charging Station shall return Display Messages with the given + * state only + */ + public void setState(@Nullable MessageStateEnum state) { + this.state = state; + } + + /** + * Adds if provided the Charging Station shall return Display Messages with the given state only. + * + * @param state If provided the Charging Station shall return Display Messages with the given + * state only + * @return this + */ + public GetDisplayMessagesRequest withState(@Nullable MessageStateEnum state) { + setState(state); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetDisplayMessagesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidId(id) && isValidRequestId(requestId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetDisplayMessagesRequest that = (GetDisplayMessagesRequest) o; + return Arrays.equals(id, that.id) + && Objects.equals(requestId, that.requestId) + && Objects.equals(priority, that.priority) + && Objects.equals(state, that.state) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(id), requestId, priority, state, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("requestId", requestId) + .add("priority", priority) + .add("state", state) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDisplayMessagesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDisplayMessagesResponse.java new file mode 100644 index 00000000..d6a54269 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetDisplayMessagesResponse.java @@ -0,0 +1,219 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GetDisplayMessagesStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetDisplayMessagesResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetDisplayMessagesResponse extends Confirmation { + /** + * Whether the Charging Station has Display Messages that match the request criteria in the + * GetDisplayMessagesRequest + */ + private GetDisplayMessagesStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetDisplayMessagesResponse class + * + * @param status Whether the Charging Station has Display Messages that match the request criteria + * in the GetDisplayMessagesRequest + */ + public GetDisplayMessagesResponse(GetDisplayMessagesStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station has Display Messages that match the request criteria in the + * GetDisplayMessagesRequest + * + * @return Whether the Charging Station has Display Messages that match the request criteria in + * the GetDisplayMessagesRequest + */ + public GetDisplayMessagesStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station has Display Messages that match the request criteria in the + * GetDisplayMessagesRequest + * + * @param status Whether the Charging Station has Display Messages that match the request criteria + * in the GetDisplayMessagesRequest + */ + public void setStatus(GetDisplayMessagesStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GetDisplayMessagesStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetDisplayMessagesResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetDisplayMessagesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetDisplayMessagesResponse that = (GetDisplayMessagesResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetInstalledCertificateIdsRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetInstalledCertificateIdsRequest.java new file mode 100644 index 00000000..7d060357 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetInstalledCertificateIdsRequest.java @@ -0,0 +1,175 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GetCertificateIdUseEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetInstalledCertificateIdsRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetInstalledCertificateIdsRequest extends RequestWithId { + /** The type of certificates requested. When omitted, all certificate types are requested. */ + @Nullable private GetCertificateIdUseEnum[] certificateType; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the GetInstalledCertificateIdsRequest class */ + public GetInstalledCertificateIdsRequest() {} + + /** + * Gets the type of certificates requested. When omitted, all certificate types are requested. + * + * @return The type of certificates requested + */ + @Nullable + public GetCertificateIdUseEnum[] getCertificateType() { + return certificateType; + } + + /** + * Sets the type of certificates requested. When omitted, all certificate types are requested. + * + * @param certificateType The type of certificates requested + */ + public void setCertificateType(@Nullable GetCertificateIdUseEnum[] certificateType) { + if (!isValidCertificateType(certificateType)) { + throw new PropertyConstraintException(certificateType, "certificateType is invalid"); + } + this.certificateType = certificateType; + } + + /** + * Returns whether the given certificateType is valid + * + * @param certificateType the certificateType to check the validity of + * @return {@code true} if certificateType is valid, {@code false} if not + */ + private boolean isValidCertificateType(@Nullable GetCertificateIdUseEnum[] certificateType) { + return certificateType == null || (certificateType.length >= 1); + } + + /** + * Adds the type of certificates requested. When omitted, all certificate types are requested. + * + * @param certificateType The type of certificates requested + * @return this + */ + public GetInstalledCertificateIdsRequest withCertificateType( + @Nullable GetCertificateIdUseEnum[] certificateType) { + setCertificateType(certificateType); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetInstalledCertificateIdsRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCertificateType(certificateType) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetInstalledCertificateIdsRequest that = (GetInstalledCertificateIdsRequest) o; + return Arrays.equals(certificateType, that.certificateType) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(certificateType), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateType", certificateType) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetInstalledCertificateIdsResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetInstalledCertificateIdsResponse.java new file mode 100644 index 00000000..76fabb8a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetInstalledCertificateIdsResponse.java @@ -0,0 +1,270 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateHashDataChain; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GetInstalledCertificateStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetInstalledCertificateIdsResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetInstalledCertificateIdsResponse extends Confirmation { + /** Charging Station indicates if it can process the request. */ + private GetInstalledCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** certificateHashDataChain */ + @Nullable private CertificateHashDataChain[] certificateHashDataChain; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetInstalledCertificateIdsResponse class + * + * @param status Charging Station indicates if it can process the request. + */ + public GetInstalledCertificateIdsResponse(GetInstalledCertificateStatusEnum status) { + setStatus(status); + } + + /** + * Gets charging Station indicates if it can process the request. + * + * @return Charging Station indicates if it can process the request + */ + public GetInstalledCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets charging Station indicates if it can process the request. + * + * @param status Charging Station indicates if it can process the request + */ + public void setStatus(GetInstalledCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GetInstalledCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetInstalledCertificateIdsResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets certificateHashDataChain + * + * @return certificateHashDataChain + */ + @Nullable + public CertificateHashDataChain[] getCertificateHashDataChain() { + return certificateHashDataChain; + } + + /** + * Sets certificateHashDataChain + * + * @param certificateHashDataChain certificateHashDataChain + */ + public void setCertificateHashDataChain( + @Nullable CertificateHashDataChain[] certificateHashDataChain) { + if (!isValidCertificateHashDataChain(certificateHashDataChain)) { + throw new PropertyConstraintException( + certificateHashDataChain, "certificateHashDataChain is invalid"); + } + this.certificateHashDataChain = certificateHashDataChain; + } + + /** + * Returns whether the given certificateHashDataChain is valid + * + * @param certificateHashDataChain the certificateHashDataChain to check the validity of + * @return {@code true} if certificateHashDataChain is valid, {@code false} if not + */ + private boolean isValidCertificateHashDataChain( + @Nullable CertificateHashDataChain[] certificateHashDataChain) { + return certificateHashDataChain == null + || (certificateHashDataChain.length >= 1 + && Arrays.stream(certificateHashDataChain).allMatch(item -> item.validate())); + } + + /** + * Adds certificateHashDataChain + * + * @param certificateHashDataChain certificateHashDataChain + * @return this + */ + public GetInstalledCertificateIdsResponse withCertificateHashDataChain( + @Nullable CertificateHashDataChain[] certificateHashDataChain) { + setCertificateHashDataChain(certificateHashDataChain); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetInstalledCertificateIdsResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidCertificateHashDataChain(certificateHashDataChain) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetInstalledCertificateIdsResponse that = (GetInstalledCertificateIdsResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Arrays.equals(certificateHashDataChain, that.certificateHashDataChain) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, Arrays.hashCode(certificateHashDataChain), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("certificateHashDataChain", certificateHashDataChain) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLocalListVersionRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLocalListVersionRequest.java new file mode 100644 index 00000000..f0491e57 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLocalListVersionRequest.java @@ -0,0 +1,124 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetLocalListVersionRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetLocalListVersionRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the GetLocalListVersionRequest class */ + public GetLocalListVersionRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetLocalListVersionRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLocalListVersionRequest that = (GetLocalListVersionRequest) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLocalListVersionResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLocalListVersionResponse.java new file mode 100644 index 00000000..61e3c49a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLocalListVersionResponse.java @@ -0,0 +1,163 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetLocalListVersionResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetLocalListVersionResponse extends Confirmation { + /** The current version number of the local authorization list in the Charging Station. */ + private Integer versionNumber; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetLocalListVersionResponse class + * + * @param versionNumber The current version number of the local authorization list in the Charging + * Station. + */ + public GetLocalListVersionResponse(Integer versionNumber) { + setVersionNumber(versionNumber); + } + + /** + * Gets the current version number of the local authorization list in the Charging Station. + * + * @return The current version number of the local authorization list in the Charging Station + */ + public Integer getVersionNumber() { + return versionNumber; + } + + /** + * Sets the current version number of the local authorization list in the Charging Station. + * + * @param versionNumber The current version number of the local authorization list in the Charging + * Station + */ + public void setVersionNumber(Integer versionNumber) { + if (!isValidVersionNumber(versionNumber)) { + throw new PropertyConstraintException(versionNumber, "versionNumber is invalid"); + } + this.versionNumber = versionNumber; + } + + /** + * Returns whether the given versionNumber is valid + * + * @param versionNumber the versionNumber to check the validity of + * @return {@code true} if versionNumber is valid, {@code false} if not + */ + private boolean isValidVersionNumber(Integer versionNumber) { + return versionNumber != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetLocalListVersionResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidVersionNumber(versionNumber) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLocalListVersionResponse that = (GetLocalListVersionResponse) o; + return Objects.equals(versionNumber, that.versionNumber) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(versionNumber, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("versionNumber", versionNumber) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLogRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLogRequest.java new file mode 100644 index 00000000..b0fc8ee8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLogRequest.java @@ -0,0 +1,349 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.LogEnum; +import eu.chargetime.ocpp.v21.model.types.LogParameters; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetLogRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetLogRequest extends RequestWithId { + /** Generic class for the configuration of logging entries. */ + private LogParameters log; + + /** The type of log file that the Charging Station should send. */ + private LogEnum logType; + + /** The Id of this request */ + private Integer requestId; + + /** + * How many times the Charging Station must retry to upload the log before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + */ + @Nullable private Integer retries; + + /** + * The interval in seconds after which a retry may be attempted. If this field is not present, it + * is left to Charging Station to decide how long to wait between attempts. + */ + @Nullable private Integer retryInterval; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetLogRequest class + * + * @param log Generic class for the configuration of logging entries. + * @param logType The type of log file that the Charging Station should send. + * @param requestId The Id of this request + */ + public GetLogRequest(LogParameters log, LogEnum logType, Integer requestId) { + setLog(log); + setLogType(logType); + setRequestId(requestId); + } + + /** + * Gets generic class for the configuration of logging entries. + * + * @return Generic class for the configuration of logging entries + */ + public LogParameters getLog() { + return log; + } + + /** + * Sets generic class for the configuration of logging entries. + * + * @param log Generic class for the configuration of logging entries + */ + public void setLog(LogParameters log) { + if (!isValidLog(log)) { + throw new PropertyConstraintException(log, "log is invalid"); + } + this.log = log; + } + + /** + * Returns whether the given log is valid + * + * @param log the log to check the validity of + * @return {@code true} if log is valid, {@code false} if not + */ + private boolean isValidLog(LogParameters log) { + return log != null && log.validate(); + } + + /** + * Gets the type of log file that the Charging Station should send. + * + * @return The type of log file that the Charging Station should send + */ + public LogEnum getLogType() { + return logType; + } + + /** + * Sets the type of log file that the Charging Station should send. + * + * @param logType The type of log file that the Charging Station should send + */ + public void setLogType(LogEnum logType) { + if (!isValidLogType(logType)) { + throw new PropertyConstraintException(logType, "logType is invalid"); + } + this.logType = logType; + } + + /** + * Returns whether the given logType is valid + * + * @param logType the logType to check the validity of + * @return {@code true} if logType is valid, {@code false} if not + */ + private boolean isValidLogType(LogEnum logType) { + return logType != null; + } + + /** + * Gets the Id of this request + * + * @return The Id of this request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of this request + * + * @param requestId The Id of this request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets how many times the Charging Station must retry to upload the log before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @return How many times the Charging Station must retry to upload the log before giving up + */ + @Nullable + public Integer getRetries() { + return retries; + } + + /** + * Sets how many times the Charging Station must retry to upload the log before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @param retries How many times the Charging Station must retry to upload the log before giving + * up + */ + public void setRetries(@Nullable Integer retries) { + if (!isValidRetries(retries)) { + throw new PropertyConstraintException(retries, "retries is invalid"); + } + this.retries = retries; + } + + /** + * Returns whether the given retries is valid + * + * @param retries the retries to check the validity of + * @return {@code true} if retries is valid, {@code false} if not + */ + private boolean isValidRetries(@Nullable Integer retries) { + return retries == null || (retries >= 0); + } + + /** + * Adds how many times the Charging Station must retry to upload the log before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @param retries How many times the Charging Station must retry to upload the log before giving + * up + * @return this + */ + public GetLogRequest withRetries(@Nullable Integer retries) { + setRetries(retries); + return this; + } + + /** + * Gets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @return The interval in seconds after which a retry may be attempted + */ + @Nullable + public Integer getRetryInterval() { + return retryInterval; + } + + /** + * Sets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + */ + public void setRetryInterval(@Nullable Integer retryInterval) { + this.retryInterval = retryInterval; + } + + /** + * Adds the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + * @return this + */ + public GetLogRequest withRetryInterval(@Nullable Integer retryInterval) { + setRetryInterval(retryInterval); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetLogRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidLog(log) + && isValidLogType(logType) + && isValidRequestId(requestId) + && isValidRetries(retries) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLogRequest that = (GetLogRequest) o; + return Objects.equals(log, that.log) + && Objects.equals(logType, that.logType) + && Objects.equals(requestId, that.requestId) + && Objects.equals(retries, that.retries) + && Objects.equals(retryInterval, that.retryInterval) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(log, logType, requestId, retries, retryInterval, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("log", log) + .add("logType", logType) + .add("requestId", requestId) + .add("retries", retries) + .add("retryInterval", retryInterval) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLogResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLogResponse.java new file mode 100644 index 00000000..ca87b1cb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetLogResponse.java @@ -0,0 +1,268 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.LogStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetLogResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetLogResponse extends Confirmation { + /** This field indicates whether the Charging Station was able to accept the request. */ + private LogStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * The name of the log file that will be uploaded. This field is not present when no logging + * information is available. + */ + @Nullable private String filename; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetLogResponse class + * + * @param status This field indicates whether the Charging Station was able to accept the request. + */ + public GetLogResponse(LogStatusEnum status) { + setStatus(status); + } + + /** + * Gets this field indicates whether the Charging Station was able to accept the request. + * + * @return This field indicates whether the Charging Station was able to accept the request + */ + public LogStatusEnum getStatus() { + return status; + } + + /** + * Sets this field indicates whether the Charging Station was able to accept the request. + * + * @param status This field indicates whether the Charging Station was able to accept the request + */ + public void setStatus(LogStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(LogStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetLogResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets the name of the log file that will be uploaded. This field is not present when no logging + * information is available. + * + * @return The name of the log file that will be uploaded + */ + @Nullable + public String getFilename() { + return filename; + } + + /** + * Sets the name of the log file that will be uploaded. This field is not present when no logging + * information is available. + * + * @param filename The name of the log file that will be uploaded + */ + public void setFilename(@Nullable String filename) { + if (!isValidFilename(filename)) { + throw new PropertyConstraintException(filename, "filename is invalid"); + } + this.filename = filename; + } + + /** + * Returns whether the given filename is valid + * + * @param filename the filename to check the validity of + * @return {@code true} if filename is valid, {@code false} if not + */ + private boolean isValidFilename(@Nullable String filename) { + return filename == null || filename.length() <= 255; + } + + /** + * Adds the name of the log file that will be uploaded. This field is not present when no logging + * information is available. + * + * @param filename The name of the log file that will be uploaded + * @return this + */ + public GetLogResponse withFilename(@Nullable String filename) { + setFilename(filename); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetLogResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidFilename(filename) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLogResponse that = (GetLogResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(filename, that.filename) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, filename, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("filename", filename) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetMonitoringReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetMonitoringReportRequest.java new file mode 100644 index 00000000..e075e28b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetMonitoringReportRequest.java @@ -0,0 +1,282 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ComponentVariable; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.MonitoringCriterionEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetMonitoringReportRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetMonitoringReportRequest extends RequestWithId { + /** Class to report components, variables and variable attributes and characteristics. */ + @Nullable private ComponentVariable[] componentVariable; + + /** The Id of the request. */ + private Integer requestId; + + /** This field contains criteria for components for which a monitoring report is requested */ + @Nullable private MonitoringCriterionEnum[] monitoringCriteria; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetMonitoringReportRequest class + * + * @param requestId The Id of the request. + */ + public GetMonitoringReportRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets class to report components, variables and variable attributes and characteristics. + * + * @return Class to report components, variables and variable attributes and characteristics + */ + @Nullable + public ComponentVariable[] getComponentVariable() { + return componentVariable; + } + + /** + * Sets class to report components, variables and variable attributes and characteristics. + * + * @param componentVariable Class to report components, variables and variable attributes and + * characteristics + */ + public void setComponentVariable(@Nullable ComponentVariable[] componentVariable) { + if (!isValidComponentVariable(componentVariable)) { + throw new PropertyConstraintException(componentVariable, "componentVariable is invalid"); + } + this.componentVariable = componentVariable; + } + + /** + * Returns whether the given componentVariable is valid + * + * @param componentVariable the componentVariable to check the validity of + * @return {@code true} if componentVariable is valid, {@code false} if not + */ + private boolean isValidComponentVariable(@Nullable ComponentVariable[] componentVariable) { + return componentVariable == null + || (componentVariable.length >= 1 + && Arrays.stream(componentVariable).allMatch(item -> item.validate())); + } + + /** + * Adds class to report components, variables and variable attributes and characteristics. + * + * @param componentVariable Class to report components, variables and variable attributes and + * characteristics + * @return this + */ + public GetMonitoringReportRequest withComponentVariable( + @Nullable ComponentVariable[] componentVariable) { + setComponentVariable(componentVariable); + return this; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets this field contains criteria for components for which a monitoring report is requested + * + * @return This field contains criteria for components for which a monitoring report is requested + */ + @Nullable + public MonitoringCriterionEnum[] getMonitoringCriteria() { + return monitoringCriteria; + } + + /** + * Sets this field contains criteria for components for which a monitoring report is requested + * + * @param monitoringCriteria This field contains criteria for components for which a monitoring + * report is requested + */ + public void setMonitoringCriteria(@Nullable MonitoringCriterionEnum[] monitoringCriteria) { + if (!isValidMonitoringCriteria(monitoringCriteria)) { + throw new PropertyConstraintException(monitoringCriteria, "monitoringCriteria is invalid"); + } + this.monitoringCriteria = monitoringCriteria; + } + + /** + * Returns whether the given monitoringCriteria is valid + * + * @param monitoringCriteria the monitoringCriteria to check the validity of + * @return {@code true} if monitoringCriteria is valid, {@code false} if not + */ + private boolean isValidMonitoringCriteria( + @Nullable MonitoringCriterionEnum[] monitoringCriteria) { + return monitoringCriteria == null + || (monitoringCriteria.length >= 1 && monitoringCriteria.length <= 3); + } + + /** + * Adds this field contains criteria for components for which a monitoring report is requested + * + * @param monitoringCriteria This field contains criteria for components for which a monitoring + * report is requested + * @return this + */ + public GetMonitoringReportRequest withMonitoringCriteria( + @Nullable MonitoringCriterionEnum[] monitoringCriteria) { + setMonitoringCriteria(monitoringCriteria); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetMonitoringReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidComponentVariable(componentVariable) + && isValidRequestId(requestId) + && isValidMonitoringCriteria(monitoringCriteria) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetMonitoringReportRequest that = (GetMonitoringReportRequest) o; + return Arrays.equals(componentVariable, that.componentVariable) + && Objects.equals(requestId, that.requestId) + && Arrays.equals(monitoringCriteria, that.monitoringCriteria) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(componentVariable), + requestId, + Arrays.hashCode(monitoringCriteria), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("componentVariable", componentVariable) + .add("requestId", requestId) + .add("monitoringCriteria", monitoringCriteria) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetMonitoringReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetMonitoringReportResponse.java new file mode 100644 index 00000000..e78534d3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetMonitoringReportResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetMonitoringReportResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetMonitoringReportResponse extends Confirmation { + /** This field indicates whether the Charging Station was able to accept the request. */ + private GenericDeviceModelStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetMonitoringReportResponse class + * + * @param status This field indicates whether the Charging Station was able to accept the request. + */ + public GetMonitoringReportResponse(GenericDeviceModelStatusEnum status) { + setStatus(status); + } + + /** + * Gets this field indicates whether the Charging Station was able to accept the request. + * + * @return This field indicates whether the Charging Station was able to accept the request + */ + public GenericDeviceModelStatusEnum getStatus() { + return status; + } + + /** + * Sets this field indicates whether the Charging Station was able to accept the request. + * + * @param status This field indicates whether the Charging Station was able to accept the request + */ + public void setStatus(GenericDeviceModelStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericDeviceModelStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetMonitoringReportResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetMonitoringReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetMonitoringReportResponse that = (GetMonitoringReportResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetPeriodicEventStreamRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetPeriodicEventStreamRequest.java new file mode 100644 index 00000000..a8e03b57 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetPeriodicEventStreamRequest.java @@ -0,0 +1,124 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * This message is empty. It has no fields. + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetPeriodicEventStreamRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the GetPeriodicEventStreamRequest class */ + public GetPeriodicEventStreamRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetPeriodicEventStreamRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetPeriodicEventStreamRequest that = (GetPeriodicEventStreamRequest) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetPeriodicEventStreamResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetPeriodicEventStreamResponse.java new file mode 100644 index 00000000..912ec1c3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetPeriodicEventStreamResponse.java @@ -0,0 +1,172 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ConstantStreamData; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetPeriodicEventStreamResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetPeriodicEventStreamResponse extends Confirmation { + /** constantStreamData */ + @Nullable private ConstantStreamData[] constantStreamData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the GetPeriodicEventStreamResponse class */ + public GetPeriodicEventStreamResponse() {} + + /** + * Gets constantStreamData + * + * @return constantStreamData + */ + @Nullable + public ConstantStreamData[] getConstantStreamData() { + return constantStreamData; + } + + /** + * Sets constantStreamData + * + * @param constantStreamData constantStreamData + */ + public void setConstantStreamData(@Nullable ConstantStreamData[] constantStreamData) { + if (!isValidConstantStreamData(constantStreamData)) { + throw new PropertyConstraintException(constantStreamData, "constantStreamData is invalid"); + } + this.constantStreamData = constantStreamData; + } + + /** + * Returns whether the given constantStreamData is valid + * + * @param constantStreamData the constantStreamData to check the validity of + * @return {@code true} if constantStreamData is valid, {@code false} if not + */ + private boolean isValidConstantStreamData(@Nullable ConstantStreamData[] constantStreamData) { + return constantStreamData == null + || (constantStreamData.length >= 1 + && Arrays.stream(constantStreamData).allMatch(item -> item.validate())); + } + + /** + * Adds constantStreamData + * + * @param constantStreamData constantStreamData + * @return this + */ + public GetPeriodicEventStreamResponse withConstantStreamData( + @Nullable ConstantStreamData[] constantStreamData) { + setConstantStreamData(constantStreamData); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetPeriodicEventStreamResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidConstantStreamData(constantStreamData) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetPeriodicEventStreamResponse that = (GetPeriodicEventStreamResponse) o; + return Arrays.equals(constantStreamData, that.constantStreamData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(constantStreamData), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("constantStreamData", constantStreamData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetReportRequest.java new file mode 100644 index 00000000..d801dffb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetReportRequest.java @@ -0,0 +1,280 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ComponentCriterionEnum; +import eu.chargetime.ocpp.v21.model.types.ComponentVariable; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetReportRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetReportRequest extends RequestWithId { + /** Class to report components, variables and variable attributes and characteristics. */ + @Nullable private ComponentVariable[] componentVariable; + + /** The Id of the request. */ + private Integer requestId; + + /** This field contains criteria for components for which a report is requested */ + @Nullable private ComponentCriterionEnum[] componentCriteria; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetReportRequest class + * + * @param requestId The Id of the request. + */ + public GetReportRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets class to report components, variables and variable attributes and characteristics. + * + * @return Class to report components, variables and variable attributes and characteristics + */ + @Nullable + public ComponentVariable[] getComponentVariable() { + return componentVariable; + } + + /** + * Sets class to report components, variables and variable attributes and characteristics. + * + * @param componentVariable Class to report components, variables and variable attributes and + * characteristics + */ + public void setComponentVariable(@Nullable ComponentVariable[] componentVariable) { + if (!isValidComponentVariable(componentVariable)) { + throw new PropertyConstraintException(componentVariable, "componentVariable is invalid"); + } + this.componentVariable = componentVariable; + } + + /** + * Returns whether the given componentVariable is valid + * + * @param componentVariable the componentVariable to check the validity of + * @return {@code true} if componentVariable is valid, {@code false} if not + */ + private boolean isValidComponentVariable(@Nullable ComponentVariable[] componentVariable) { + return componentVariable == null + || (componentVariable.length >= 1 + && Arrays.stream(componentVariable).allMatch(item -> item.validate())); + } + + /** + * Adds class to report components, variables and variable attributes and characteristics. + * + * @param componentVariable Class to report components, variables and variable attributes and + * characteristics + * @return this + */ + public GetReportRequest withComponentVariable(@Nullable ComponentVariable[] componentVariable) { + setComponentVariable(componentVariable); + return this; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets this field contains criteria for components for which a report is requested + * + * @return This field contains criteria for components for which a report is requested + */ + @Nullable + public ComponentCriterionEnum[] getComponentCriteria() { + return componentCriteria; + } + + /** + * Sets this field contains criteria for components for which a report is requested + * + * @param componentCriteria This field contains criteria for components for which a report is + * requested + */ + public void setComponentCriteria(@Nullable ComponentCriterionEnum[] componentCriteria) { + if (!isValidComponentCriteria(componentCriteria)) { + throw new PropertyConstraintException(componentCriteria, "componentCriteria is invalid"); + } + this.componentCriteria = componentCriteria; + } + + /** + * Returns whether the given componentCriteria is valid + * + * @param componentCriteria the componentCriteria to check the validity of + * @return {@code true} if componentCriteria is valid, {@code false} if not + */ + private boolean isValidComponentCriteria(@Nullable ComponentCriterionEnum[] componentCriteria) { + return componentCriteria == null + || (componentCriteria.length >= 1 && componentCriteria.length <= 4); + } + + /** + * Adds this field contains criteria for components for which a report is requested + * + * @param componentCriteria This field contains criteria for components for which a report is + * requested + * @return this + */ + public GetReportRequest withComponentCriteria( + @Nullable ComponentCriterionEnum[] componentCriteria) { + setComponentCriteria(componentCriteria); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidComponentVariable(componentVariable) + && isValidRequestId(requestId) + && isValidComponentCriteria(componentCriteria) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetReportRequest that = (GetReportRequest) o; + return Arrays.equals(componentVariable, that.componentVariable) + && Objects.equals(requestId, that.requestId) + && Arrays.equals(componentCriteria, that.componentCriteria) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(componentVariable), + requestId, + Arrays.hashCode(componentCriteria), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("componentVariable", componentVariable) + .add("requestId", requestId) + .add("componentCriteria", componentCriteria) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetReportResponse.java new file mode 100644 index 00000000..64535acf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetReportResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetReportResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetReportResponse extends Confirmation { + /** This field indicates whether the Charging Station was able to accept the request. */ + private GenericDeviceModelStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetReportResponse class + * + * @param status This field indicates whether the Charging Station was able to accept the request. + */ + public GetReportResponse(GenericDeviceModelStatusEnum status) { + setStatus(status); + } + + /** + * Gets this field indicates whether the Charging Station was able to accept the request. + * + * @return This field indicates whether the Charging Station was able to accept the request + */ + public GenericDeviceModelStatusEnum getStatus() { + return status; + } + + /** + * Sets this field indicates whether the Charging Station was able to accept the request. + * + * @param status This field indicates whether the Charging Station was able to accept the request + */ + public void setStatus(GenericDeviceModelStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericDeviceModelStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetReportResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetReportResponse that = (GetReportResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTariffsRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTariffsRequest.java new file mode 100644 index 00000000..3482122c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTariffsRequest.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetTariffsRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetTariffsRequest extends RequestWithId { + /** EVSE id to get tariff from. When evseId = 0, this gets tariffs from all EVSEs. */ + private Integer evseId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetTariffsRequest class + * + * @param evseId EVSE id to get tariff from. When evseId = 0, this gets tariffs from all EVSEs. + */ + public GetTariffsRequest(Integer evseId) { + setEvseId(evseId); + } + + /** + * Gets EVSE id to get tariff from. When evseId = 0, this gets tariffs from all EVSEs. + * + * @return EVSE id to get tariff from + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets EVSE id to get tariff from. When evseId = 0, this gets tariffs from all EVSEs. + * + * @param evseId EVSE id to get tariff from + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetTariffsRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvseId(evseId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetTariffsRequest that = (GetTariffsRequest) o; + return Objects.equals(evseId, that.evseId) && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTariffsResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTariffsResponse.java new file mode 100644 index 00000000..0882b18c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTariffsResponse.java @@ -0,0 +1,266 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import eu.chargetime.ocpp.v21.model.types.TariffAssignment; +import eu.chargetime.ocpp.v21.model.types.TariffGetStatusEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetTariffsResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetTariffsResponse extends Confirmation { + /** Status of operation */ + private TariffGetStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Shows assignment of tariffs to EVSE or IdToken. */ + @Nullable private TariffAssignment[] tariffAssignments; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetTariffsResponse class + * + * @param status Status of operation + */ + public GetTariffsResponse(TariffGetStatusEnum status) { + setStatus(status); + } + + /** + * Gets status of operation + * + * @return Status of operation + */ + public TariffGetStatusEnum getStatus() { + return status; + } + + /** + * Sets status of operation + * + * @param status Status of operation + */ + public void setStatus(TariffGetStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(TariffGetStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetTariffsResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets shows assignment of tariffs to EVSE or IdToken. + * + * @return Shows assignment of tariffs to EVSE or IdToken + */ + @Nullable + public TariffAssignment[] getTariffAssignments() { + return tariffAssignments; + } + + /** + * Sets shows assignment of tariffs to EVSE or IdToken. + * + * @param tariffAssignments Shows assignment of tariffs to EVSE or IdToken + */ + public void setTariffAssignments(@Nullable TariffAssignment[] tariffAssignments) { + if (!isValidTariffAssignments(tariffAssignments)) { + throw new PropertyConstraintException(tariffAssignments, "tariffAssignments is invalid"); + } + this.tariffAssignments = tariffAssignments; + } + + /** + * Returns whether the given tariffAssignments is valid + * + * @param tariffAssignments the tariffAssignments to check the validity of + * @return {@code true} if tariffAssignments is valid, {@code false} if not + */ + private boolean isValidTariffAssignments(@Nullable TariffAssignment[] tariffAssignments) { + return tariffAssignments == null + || (tariffAssignments.length >= 1 + && Arrays.stream(tariffAssignments).allMatch(item -> item.validate())); + } + + /** + * Adds shows assignment of tariffs to EVSE or IdToken. + * + * @param tariffAssignments Shows assignment of tariffs to EVSE or IdToken + * @return this + */ + public GetTariffsResponse withTariffAssignments(@Nullable TariffAssignment[] tariffAssignments) { + setTariffAssignments(tariffAssignments); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetTariffsResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidTariffAssignments(tariffAssignments) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetTariffsResponse that = (GetTariffsResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Arrays.equals(tariffAssignments, that.tariffAssignments) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, Arrays.hashCode(tariffAssignments), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("tariffAssignments", tariffAssignments) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTransactionStatusRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTransactionStatusRequest.java new file mode 100644 index 00000000..34a84a90 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTransactionStatusRequest.java @@ -0,0 +1,172 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetTransactionStatusRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetTransactionStatusRequest extends RequestWithId { + /** The Id of the transaction for which the status is requested. */ + @Nullable private String transactionId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the GetTransactionStatusRequest class */ + public GetTransactionStatusRequest() {} + + /** + * Gets the Id of the transaction for which the status is requested. + * + * @return The Id of the transaction for which the status is requested + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the Id of the transaction for which the status is requested. + * + * @param transactionId The Id of the transaction for which the status is requested + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds the Id of the transaction for which the status is requested. + * + * @param transactionId The Id of the transaction for which the status is requested + * @return this + */ + public GetTransactionStatusRequest withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetTransactionStatusRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTransactionId(transactionId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetTransactionStatusRequest that = (GetTransactionStatusRequest) o; + return Objects.equals(transactionId, that.transactionId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(transactionId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("transactionId", transactionId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTransactionStatusResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTransactionStatusResponse.java new file mode 100644 index 00000000..0126ac92 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetTransactionStatusResponse.java @@ -0,0 +1,196 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetTransactionStatusResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetTransactionStatusResponse extends Confirmation { + /** Whether the transaction is still ongoing. */ + @Nullable private Boolean ongoingIndicator; + + /** Whether there are still message to be delivered. */ + private Boolean messagesInQueue; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetTransactionStatusResponse class + * + * @param messagesInQueue Whether there are still message to be delivered. + */ + public GetTransactionStatusResponse(Boolean messagesInQueue) { + setMessagesInQueue(messagesInQueue); + } + + /** + * Gets whether the transaction is still ongoing. + * + * @return Whether the transaction is still ongoing + */ + @Nullable + public Boolean getOngoingIndicator() { + return ongoingIndicator; + } + + /** + * Sets whether the transaction is still ongoing. + * + * @param ongoingIndicator Whether the transaction is still ongoing + */ + public void setOngoingIndicator(@Nullable Boolean ongoingIndicator) { + this.ongoingIndicator = ongoingIndicator; + } + + /** + * Adds whether the transaction is still ongoing. + * + * @param ongoingIndicator Whether the transaction is still ongoing + * @return this + */ + public GetTransactionStatusResponse withOngoingIndicator(@Nullable Boolean ongoingIndicator) { + setOngoingIndicator(ongoingIndicator); + return this; + } + + /** + * Gets whether there are still message to be delivered. + * + * @return Whether there are still message to be delivered + */ + public Boolean getMessagesInQueue() { + return messagesInQueue; + } + + /** + * Sets whether there are still message to be delivered. + * + * @param messagesInQueue Whether there are still message to be delivered + */ + public void setMessagesInQueue(Boolean messagesInQueue) { + if (!isValidMessagesInQueue(messagesInQueue)) { + throw new PropertyConstraintException(messagesInQueue, "messagesInQueue is invalid"); + } + this.messagesInQueue = messagesInQueue; + } + + /** + * Returns whether the given messagesInQueue is valid + * + * @param messagesInQueue the messagesInQueue to check the validity of + * @return {@code true} if messagesInQueue is valid, {@code false} if not + */ + private boolean isValidMessagesInQueue(Boolean messagesInQueue) { + return messagesInQueue != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetTransactionStatusResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidMessagesInQueue(messagesInQueue) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetTransactionStatusResponse that = (GetTransactionStatusResponse) o; + return Objects.equals(ongoingIndicator, that.ongoingIndicator) + && Objects.equals(messagesInQueue, that.messagesInQueue) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(ongoingIndicator, messagesInQueue, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("ongoingIndicator", ongoingIndicator) + .add("messagesInQueue", messagesInQueue) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetVariablesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetVariablesRequest.java new file mode 100644 index 00000000..d740ca53 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetVariablesRequest.java @@ -0,0 +1,170 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GetVariableData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetVariablesRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetVariablesRequest extends RequestWithId { + /** Class to hold parameters for GetVariables request. */ + private GetVariableData[] getVariableData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetVariablesRequest class + * + * @param getVariableData Class to hold parameters for GetVariables request. + */ + public GetVariablesRequest(GetVariableData[] getVariableData) { + setGetVariableData(getVariableData); + } + + /** + * Gets class to hold parameters for GetVariables request. + * + * @return Class to hold parameters for GetVariables request + */ + public GetVariableData[] getGetVariableData() { + return getVariableData; + } + + /** + * Sets class to hold parameters for GetVariables request. + * + * @param getVariableData Class to hold parameters for GetVariables request + */ + public void setGetVariableData(GetVariableData[] getVariableData) { + if (!isValidGetVariableData(getVariableData)) { + throw new PropertyConstraintException(getVariableData, "getVariableData is invalid"); + } + this.getVariableData = getVariableData; + } + + /** + * Returns whether the given getVariableData is valid + * + * @param getVariableData the getVariableData to check the validity of + * @return {@code true} if getVariableData is valid, {@code false} if not + */ + private boolean isValidGetVariableData(GetVariableData[] getVariableData) { + return getVariableData != null + && getVariableData.length >= 1 + && Arrays.stream(getVariableData).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetVariablesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidGetVariableData(getVariableData) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetVariablesRequest that = (GetVariablesRequest) o; + return Arrays.equals(getVariableData, that.getVariableData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(getVariableData), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("getVariableData", getVariableData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetVariablesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetVariablesResponse.java new file mode 100644 index 00000000..06d06a32 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/GetVariablesResponse.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GetVariableResult; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetVariablesResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class GetVariablesResponse extends Confirmation { + /** Class to hold results of GetVariables request. */ + private GetVariableResult[] getVariableResult; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetVariablesResponse class + * + * @param getVariableResult Class to hold results of GetVariables request. + */ + public GetVariablesResponse(GetVariableResult[] getVariableResult) { + setGetVariableResult(getVariableResult); + } + + /** + * Gets class to hold results of GetVariables request. + * + * @return Class to hold results of GetVariables request + */ + public GetVariableResult[] getGetVariableResult() { + return getVariableResult; + } + + /** + * Sets class to hold results of GetVariables request. + * + * @param getVariableResult Class to hold results of GetVariables request + */ + public void setGetVariableResult(GetVariableResult[] getVariableResult) { + if (!isValidGetVariableResult(getVariableResult)) { + throw new PropertyConstraintException(getVariableResult, "getVariableResult is invalid"); + } + this.getVariableResult = getVariableResult; + } + + /** + * Returns whether the given getVariableResult is valid + * + * @param getVariableResult the getVariableResult to check the validity of + * @return {@code true} if getVariableResult is valid, {@code false} if not + */ + private boolean isValidGetVariableResult(GetVariableResult[] getVariableResult) { + return getVariableResult != null + && getVariableResult.length >= 1 + && Arrays.stream(getVariableResult).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetVariablesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidGetVariableResult(getVariableResult) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetVariablesResponse that = (GetVariablesResponse) o; + return Arrays.equals(getVariableResult, that.getVariableResult) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(getVariableResult), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("getVariableResult", getVariableResult) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/HeartbeatRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/HeartbeatRequest.java new file mode 100644 index 00000000..9f9f5f76 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/HeartbeatRequest.java @@ -0,0 +1,124 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * HeartbeatRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class HeartbeatRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the HeartbeatRequest class */ + public HeartbeatRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public HeartbeatRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeartbeatRequest that = (HeartbeatRequest) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/HeartbeatResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/HeartbeatResponse.java new file mode 100644 index 00000000..86d3cea7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/HeartbeatResponse.java @@ -0,0 +1,162 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * HeartbeatResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class HeartbeatResponse extends Confirmation { + /** The current time of the CSMS. */ + private ZonedDateTime currentTime; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the HeartbeatResponse class + * + * @param currentTime The current time of the CSMS. + */ + public HeartbeatResponse(ZonedDateTime currentTime) { + setCurrentTime(currentTime); + } + + /** + * Gets the current time of the CSMS. + * + * @return The current time of the CSMS + */ + public ZonedDateTime getCurrentTime() { + return currentTime; + } + + /** + * Sets the current time of the CSMS. + * + * @param currentTime The current time of the CSMS + */ + public void setCurrentTime(ZonedDateTime currentTime) { + if (!isValidCurrentTime(currentTime)) { + throw new PropertyConstraintException(currentTime, "currentTime is invalid"); + } + this.currentTime = currentTime; + } + + /** + * Returns whether the given currentTime is valid + * + * @param currentTime the currentTime to check the validity of + * @return {@code true} if currentTime is valid, {@code false} if not + */ + private boolean isValidCurrentTime(ZonedDateTime currentTime) { + return currentTime != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public HeartbeatResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCurrentTime(currentTime) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeartbeatResponse that = (HeartbeatResponse) o; + return Objects.equals(currentTime, that.currentTime) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(currentTime, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("currentTime", currentTime) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/InstallCertificateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/InstallCertificateRequest.java new file mode 100644 index 00000000..18811cc5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/InstallCertificateRequest.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.InstallCertificateUseEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * InstallCertificateRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class InstallCertificateRequest extends RequestWithId { + /** The certificate type that is sent. */ + private InstallCertificateUseEnum certificateType; + + /** A PEM encoded X.509 certificate. */ + private String certificate; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the InstallCertificateRequest class + * + * @param certificateType The certificate type that is sent. + * @param certificate A PEM encoded X.509 certificate. + */ + public InstallCertificateRequest(InstallCertificateUseEnum certificateType, String certificate) { + setCertificateType(certificateType); + setCertificate(certificate); + } + + /** + * Gets the certificate type that is sent. + * + * @return The certificate type that is sent + */ + public InstallCertificateUseEnum getCertificateType() { + return certificateType; + } + + /** + * Sets the certificate type that is sent. + * + * @param certificateType The certificate type that is sent + */ + public void setCertificateType(InstallCertificateUseEnum certificateType) { + if (!isValidCertificateType(certificateType)) { + throw new PropertyConstraintException(certificateType, "certificateType is invalid"); + } + this.certificateType = certificateType; + } + + /** + * Returns whether the given certificateType is valid + * + * @param certificateType the certificateType to check the validity of + * @return {@code true} if certificateType is valid, {@code false} if not + */ + private boolean isValidCertificateType(InstallCertificateUseEnum certificateType) { + return certificateType != null; + } + + /** + * Gets a PEM encoded X.509 certificate. + * + * @return A PEM encoded X.509 certificate + */ + public String getCertificate() { + return certificate; + } + + /** + * Sets a PEM encoded X.509 certificate. + * + * @param certificate A PEM encoded X.509 certificate + */ + public void setCertificate(String certificate) { + if (!isValidCertificate(certificate)) { + throw new PropertyConstraintException(certificate, "certificate is invalid"); + } + this.certificate = certificate; + } + + /** + * Returns whether the given certificate is valid + * + * @param certificate the certificate to check the validity of + * @return {@code true} if certificate is valid, {@code false} if not + */ + private boolean isValidCertificate(String certificate) { + return certificate != null && certificate.length() <= 10000; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public InstallCertificateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCertificateType(certificateType) + && isValidCertificate(certificate) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InstallCertificateRequest that = (InstallCertificateRequest) o; + return Objects.equals(certificateType, that.certificateType) + && Objects.equals(certificate, that.certificate) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(certificateType, certificate, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateType", certificateType) + .add("certificate", certificate) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/InstallCertificateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/InstallCertificateResponse.java new file mode 100644 index 00000000..01d7b2eb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/InstallCertificateResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.InstallCertificateStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * InstallCertificateResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class InstallCertificateResponse extends Confirmation { + /** Charging Station indicates if installation was successful. */ + private InstallCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the InstallCertificateResponse class + * + * @param status Charging Station indicates if installation was successful. + */ + public InstallCertificateResponse(InstallCertificateStatusEnum status) { + setStatus(status); + } + + /** + * Gets charging Station indicates if installation was successful. + * + * @return Charging Station indicates if installation was successful + */ + public InstallCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets charging Station indicates if installation was successful. + * + * @param status Charging Station indicates if installation was successful + */ + public void setStatus(InstallCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(InstallCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public InstallCertificateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public InstallCertificateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InstallCertificateResponse that = (InstallCertificateResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/LogStatusNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/LogStatusNotificationRequest.java new file mode 100644 index 00000000..78e16c97 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/LogStatusNotificationRequest.java @@ -0,0 +1,261 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import eu.chargetime.ocpp.v21.model.types.UploadLogStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * LogStatusNotificationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class LogStatusNotificationRequest extends RequestWithId { + /** The status of the log upload. */ + private UploadLogStatusEnum status; + + /** + * The request id that was provided in GetLogRequest that started this log upload. This field is + * mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log + * upload ongoing. + */ + @Nullable private Integer requestId; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the LogStatusNotificationRequest class + * + * @param status The status of the log upload. + */ + public LogStatusNotificationRequest(UploadLogStatusEnum status) { + setStatus(status); + } + + /** + * Gets the status of the log upload. + * + * @return The status of the log upload + */ + public UploadLogStatusEnum getStatus() { + return status; + } + + /** + * Sets the status of the log upload. + * + * @param status The status of the log upload + */ + public void setStatus(UploadLogStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(UploadLogStatusEnum status) { + return status != null; + } + + /** + * Gets the request id that was provided in GetLogRequest that started this log upload. This field + * is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log + * upload ongoing. + * + * @return The request id that was provided in GetLogRequest that started this log upload + */ + @Nullable + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the request id that was provided in GetLogRequest that started this log upload. This field + * is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log + * upload ongoing. + * + * @param requestId The request id that was provided in GetLogRequest that started this log upload + */ + public void setRequestId(@Nullable Integer requestId) { + this.requestId = requestId; + } + + /** + * Adds the request id that was provided in GetLogRequest that started this log upload. This field + * is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log + * upload ongoing. + * + * @param requestId The request id that was provided in GetLogRequest that started this log upload + * @return this + */ + public LogStatusNotificationRequest withRequestId(@Nullable Integer requestId) { + setRequestId(requestId); + return this; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public LogStatusNotificationRequest withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LogStatusNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogStatusNotificationRequest that = (LogStatusNotificationRequest) o; + return Objects.equals(status, that.status) + && Objects.equals(requestId, that.requestId) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, requestId, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("requestId", requestId) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/LogStatusNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/LogStatusNotificationResponse.java new file mode 100644 index 00000000..9d63fbde --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/LogStatusNotificationResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * LogStatusNotificationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class LogStatusNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the LogStatusNotificationResponse class */ + public LogStatusNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LogStatusNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogStatusNotificationResponse that = (LogStatusNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/MeterValuesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/MeterValuesRequest.java new file mode 100644 index 00000000..807a58eb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/MeterValuesRequest.java @@ -0,0 +1,221 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.MeterValue; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * MeterValuesRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class MeterValuesRequest extends RequestWithId { + /** + * A number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) is used to + * designate the main power meter. + */ + private Integer evseId; + + /** + * Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + */ + private MeterValue[] meterValue; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the MeterValuesRequest class + * + * @param evseId A number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) + * is used to designate the main power meter. + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time. + */ + public MeterValuesRequest(Integer evseId, MeterValue[] meterValue) { + setEvseId(evseId); + setMeterValue(meterValue); + } + + /** + * Gets a number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) is used + * to designate the main power meter. + * + * @return A number (greater than 0) designating an EVSE of the Charging Station + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets a number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) is used + * to designate the main power meter. + * + * @param evseId A number (greater than 0) designating an EVSE of the Charging Station + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @return Collection of one or more sampled values in MeterValuesRequest and TransactionEvent + */ + public MeterValue[] getMeterValue() { + return meterValue; + } + + /** + * Sets collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent + */ + public void setMeterValue(MeterValue[] meterValue) { + if (!isValidMeterValue(meterValue)) { + throw new PropertyConstraintException(meterValue, "meterValue is invalid"); + } + this.meterValue = meterValue; + } + + /** + * Returns whether the given meterValue is valid + * + * @param meterValue the meterValue to check the validity of + * @return {@code true} if meterValue is valid, {@code false} if not + */ + private boolean isValidMeterValue(MeterValue[] meterValue) { + return meterValue != null + && meterValue.length >= 1 + && Arrays.stream(meterValue).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MeterValuesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvseId(evseId) && isValidMeterValue(meterValue) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MeterValuesRequest that = (MeterValuesRequest) o; + return Objects.equals(evseId, that.evseId) + && Arrays.equals(meterValue, that.meterValue) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, Arrays.hashCode(meterValue), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("meterValue", meterValue) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/MeterValuesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/MeterValuesResponse.java new file mode 100644 index 00000000..f9b13d0b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/MeterValuesResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * MeterValuesResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class MeterValuesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the MeterValuesResponse class */ + public MeterValuesResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MeterValuesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MeterValuesResponse that = (MeterValuesResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyAllowedEnergyTransferRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyAllowedEnergyTransferRequest.java new file mode 100644 index 00000000..4f8ec321 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyAllowedEnergyTransferRequest.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.EnergyTransferModeEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyAllowedEnergyTransferRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyAllowedEnergyTransferRequest extends RequestWithId { + /** The transaction for which the allowed energy transfer is allowed. */ + private String transactionId; + + /** Modes of energy transfer that are accepted by CSMS. */ + private EnergyTransferModeEnum[] allowedEnergyTransfer; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyAllowedEnergyTransferRequest class + * + * @param transactionId The transaction for which the allowed energy transfer is allowed. + * @param allowedEnergyTransfer Modes of energy transfer that are accepted by CSMS. + */ + public NotifyAllowedEnergyTransferRequest( + String transactionId, EnergyTransferModeEnum[] allowedEnergyTransfer) { + setTransactionId(transactionId); + setAllowedEnergyTransfer(allowedEnergyTransfer); + } + + /** + * Gets the transaction for which the allowed energy transfer is allowed. + * + * @return The transaction for which the allowed energy transfer is allowed + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the transaction for which the allowed energy transfer is allowed. + * + * @param transactionId The transaction for which the allowed energy transfer is allowed + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + /** + * Gets modes of energy transfer that are accepted by CSMS. + * + * @return Modes of energy transfer that are accepted by CSMS + */ + public EnergyTransferModeEnum[] getAllowedEnergyTransfer() { + return allowedEnergyTransfer; + } + + /** + * Sets modes of energy transfer that are accepted by CSMS. + * + * @param allowedEnergyTransfer Modes of energy transfer that are accepted by CSMS + */ + public void setAllowedEnergyTransfer(EnergyTransferModeEnum[] allowedEnergyTransfer) { + if (!isValidAllowedEnergyTransfer(allowedEnergyTransfer)) { + throw new PropertyConstraintException( + allowedEnergyTransfer, "allowedEnergyTransfer is invalid"); + } + this.allowedEnergyTransfer = allowedEnergyTransfer; + } + + /** + * Returns whether the given allowedEnergyTransfer is valid + * + * @param allowedEnergyTransfer the allowedEnergyTransfer to check the validity of + * @return {@code true} if allowedEnergyTransfer is valid, {@code false} if not + */ + private boolean isValidAllowedEnergyTransfer(EnergyTransferModeEnum[] allowedEnergyTransfer) { + return allowedEnergyTransfer != null && allowedEnergyTransfer.length >= 1; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyAllowedEnergyTransferRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTransactionId(transactionId) + && isValidAllowedEnergyTransfer(allowedEnergyTransfer) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyAllowedEnergyTransferRequest that = (NotifyAllowedEnergyTransferRequest) o; + return Objects.equals(transactionId, that.transactionId) + && Arrays.equals(allowedEnergyTransfer, that.allowedEnergyTransfer) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(transactionId, Arrays.hashCode(allowedEnergyTransfer), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("transactionId", transactionId) + .add("allowedEnergyTransfer", allowedEnergyTransfer) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyAllowedEnergyTransferResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyAllowedEnergyTransferResponse.java new file mode 100644 index 00000000..ecd2e68a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyAllowedEnergyTransferResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.NotifyAllowedEnergyTransferStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyAllowedEnergyTransferResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyAllowedEnergyTransferResponse extends Confirmation { + /** status */ + private NotifyAllowedEnergyTransferStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyAllowedEnergyTransferResponse class + * + * @param status status + */ + public NotifyAllowedEnergyTransferResponse(NotifyAllowedEnergyTransferStatusEnum status) { + setStatus(status); + } + + /** + * Gets status + * + * @return status + */ + public NotifyAllowedEnergyTransferStatusEnum getStatus() { + return status; + } + + /** + * Sets status + * + * @param status status + */ + public void setStatus(NotifyAllowedEnergyTransferStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(NotifyAllowedEnergyTransferStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public NotifyAllowedEnergyTransferResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyAllowedEnergyTransferResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyAllowedEnergyTransferResponse that = (NotifyAllowedEnergyTransferResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyChargingLimitRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyChargingLimitRequest.java new file mode 100644 index 00000000..8405f9ba --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyChargingLimitRequest.java @@ -0,0 +1,300 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingLimit; +import eu.chargetime.ocpp.v21.model.types.ChargingSchedule; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyChargingLimitRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyChargingLimitRequest extends RequestWithId { + /** + * Charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + *

An ISO 15118-20 session may provide either an absolutePriceSchedule or a priceLevelSchedule. + * An ISO 15118-2 session can only provide asalesTariff element. The field digestValue is used + * when price schedule or sales tariff are signed. + * + *

image::images/ChargingSchedule-Simple.png[] + */ + @Nullable private ChargingSchedule[] chargingSchedule; + + /** + * The EVSE to which the charging limit is set. If absent or when zero, it applies to the entire + * Charging Station. + */ + @Nullable private Integer evseId; + + /** chargingLimit */ + private ChargingLimit chargingLimit; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyChargingLimitRequest class + * + * @param chargingLimit chargingLimit + */ + public NotifyChargingLimitRequest(ChargingLimit chargingLimit) { + setChargingLimit(chargingLimit); + } + + /** + * Gets charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + * @return Charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType + */ + @Nullable + public ChargingSchedule[] getChargingSchedule() { + return chargingSchedule; + } + + /** + * Sets charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: NotifyEVChargingScheduleRequest and ChargingProfileType + */ + public void setChargingSchedule(@Nullable ChargingSchedule[] chargingSchedule) { + if (!isValidChargingSchedule(chargingSchedule)) { + throw new PropertyConstraintException(chargingSchedule, "chargingSchedule is invalid"); + } + this.chargingSchedule = chargingSchedule; + } + + /** + * Returns whether the given chargingSchedule is valid + * + * @param chargingSchedule the chargingSchedule to check the validity of + * @return {@code true} if chargingSchedule is valid, {@code false} if not + */ + private boolean isValidChargingSchedule(@Nullable ChargingSchedule[] chargingSchedule) { + return chargingSchedule == null + || (chargingSchedule.length >= 1 + && Arrays.stream(chargingSchedule).allMatch(item -> item.validate())); + } + + /** + * Adds charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: NotifyEVChargingScheduleRequest and ChargingProfileType + * @return this + */ + public NotifyChargingLimitRequest withChargingSchedule( + @Nullable ChargingSchedule[] chargingSchedule) { + setChargingSchedule(chargingSchedule); + return this; + } + + /** + * Gets the EVSE to which the charging limit is set. If absent or when zero, it applies to the + * entire Charging Station. + * + * @return The EVSE to which the charging limit is set + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the EVSE to which the charging limit is set. If absent or when zero, it applies to the + * entire Charging Station. + * + * @param evseId The EVSE to which the charging limit is set + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds the EVSE to which the charging limit is set. If absent or when zero, it applies to the + * entire Charging Station. + * + * @param evseId The EVSE to which the charging limit is set + * @return this + */ + public NotifyChargingLimitRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets chargingLimit + * + * @return chargingLimit + */ + public ChargingLimit getChargingLimit() { + return chargingLimit; + } + + /** + * Sets chargingLimit + * + * @param chargingLimit chargingLimit + */ + public void setChargingLimit(ChargingLimit chargingLimit) { + if (!isValidChargingLimit(chargingLimit)) { + throw new PropertyConstraintException(chargingLimit, "chargingLimit is invalid"); + } + this.chargingLimit = chargingLimit; + } + + /** + * Returns whether the given chargingLimit is valid + * + * @param chargingLimit the chargingLimit to check the validity of + * @return {@code true} if chargingLimit is valid, {@code false} if not + */ + private boolean isValidChargingLimit(ChargingLimit chargingLimit) { + return chargingLimit != null && chargingLimit.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyChargingLimitRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidChargingSchedule(chargingSchedule) + && isValidEvseId(evseId) + && isValidChargingLimit(chargingLimit) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyChargingLimitRequest that = (NotifyChargingLimitRequest) o; + return Arrays.equals(chargingSchedule, that.chargingSchedule) + && Objects.equals(evseId, that.evseId) + && Objects.equals(chargingLimit, that.chargingLimit) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(chargingSchedule), evseId, chargingLimit, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingSchedule", chargingSchedule) + .add("evseId", evseId) + .add("chargingLimit", chargingLimit) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyChargingLimitResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyChargingLimitResponse.java new file mode 100644 index 00000000..595b5184 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyChargingLimitResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyChargingLimitResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyChargingLimitResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyChargingLimitResponse class */ + public NotifyChargingLimitResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyChargingLimitResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyChargingLimitResponse that = (NotifyChargingLimitResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyCustomerInformationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyCustomerInformationRequest.java new file mode 100644 index 00000000..547d1df6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyCustomerInformationRequest.java @@ -0,0 +1,332 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyCustomerInformationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyCustomerInformationRequest extends RequestWithId { + /** + * (Part of) the requested data. No format specified in which the data is returned. Should be + * human readable. + */ + private String data; + + /** + * “to be continued” indicator. Indicates whether another part of the monitoringData follows in an + * upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Sequence number of this message. First message starts at 0. */ + private Integer seqNo; + + /** Timestamp of the moment this message was generated at the Charging Station. */ + private ZonedDateTime generatedAt; + + /** The Id of the request. */ + private Integer requestId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyCustomerInformationRequest class + * + * @param data (Part of) the requested data. No format specified in which the data is returned. + * Should be human readable. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param requestId The Id of the request. + */ + public NotifyCustomerInformationRequest( + String data, Integer seqNo, ZonedDateTime generatedAt, Integer requestId) { + setData(data); + setSeqNo(seqNo); + setGeneratedAt(generatedAt); + setRequestId(requestId); + } + + /** + * Gets (Part of) the requested data. No format specified in which the data is returned. Should be + * human readable. + * + * @return (Part of) the requested data + */ + public String getData() { + return data; + } + + /** + * Sets (Part of) the requested data. No format specified in which the data is returned. Should be + * human readable. + * + * @param data (Part of) the requested data + */ + public void setData(String data) { + if (!isValidData(data)) { + throw new PropertyConstraintException(data, "data is invalid"); + } + this.data = data; + } + + /** + * Returns whether the given data is valid + * + * @param data the data to check the validity of + * @return {@code true} if data is valid, {@code false} if not + */ + private boolean isValidData(String data) { + return data != null && data.length() <= 512; + } + + /** + * Gets “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @return “to be continued” indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + * @return this + */ + public NotifyCustomerInformationRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets sequence number of this message. First message starts at 0. + * + * @return Sequence number of this message + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets sequence number of this message. First message starts at 0. + * + * @param seqNo Sequence number of this message + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null && seqNo >= 0; + } + + /** + * Gets timestamp of the moment this message was generated at the Charging Station. + * + * @return Timestamp of the moment this message was generated at the Charging Station + */ + public ZonedDateTime getGeneratedAt() { + return generatedAt; + } + + /** + * Sets timestamp of the moment this message was generated at the Charging Station. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station + */ + public void setGeneratedAt(ZonedDateTime generatedAt) { + if (!isValidGeneratedAt(generatedAt)) { + throw new PropertyConstraintException(generatedAt, "generatedAt is invalid"); + } + this.generatedAt = generatedAt; + } + + /** + * Returns whether the given generatedAt is valid + * + * @param generatedAt the generatedAt to check the validity of + * @return {@code true} if generatedAt is valid, {@code false} if not + */ + private boolean isValidGeneratedAt(ZonedDateTime generatedAt) { + return generatedAt != null; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null && requestId >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyCustomerInformationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidData(data) + && isValidSeqNo(seqNo) + && isValidGeneratedAt(generatedAt) + && isValidRequestId(requestId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyCustomerInformationRequest that = (NotifyCustomerInformationRequest) o; + return Objects.equals(data, that.data) + && Objects.equals(tbc, that.tbc) + && Objects.equals(seqNo, that.seqNo) + && Objects.equals(generatedAt, that.generatedAt) + && Objects.equals(requestId, that.requestId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(data, tbc, seqNo, generatedAt, requestId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("data", data) + .add("tbc", tbc) + .add("seqNo", seqNo) + .add("generatedAt", generatedAt) + .add("requestId", requestId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyCustomerInformationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyCustomerInformationResponse.java new file mode 100644 index 00000000..af0f23f4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyCustomerInformationResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyCustomerInformationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyCustomerInformationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyCustomerInformationResponse class */ + public NotifyCustomerInformationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyCustomerInformationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyCustomerInformationResponse that = (NotifyCustomerInformationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERAlarmRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERAlarmRequest.java new file mode 100644 index 00000000..e98f34a4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERAlarmRequest.java @@ -0,0 +1,328 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DERControlEnum; +import eu.chargetime.ocpp.v21.model.types.GridEventFaultEnum; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyDERAlarmRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyDERAlarmRequest extends RequestWithId { + /** Name of DER control, e.g. LFMustTrip */ + private DERControlEnum controlType; + + /** Type of grid event that caused this */ + @Nullable private GridEventFaultEnum gridEventFault; + + /** True when error condition has ended. Absent or false when alarm has started. */ + @Nullable private Boolean alarmEnded; + + /** Time of start or end of alarm. */ + private ZonedDateTime timestamp; + + /** Optional info provided by EV. */ + @Nullable private String extraInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyDERAlarmRequest class + * + * @param controlType Name of DER control, e.g. LFMustTrip + * @param timestamp Time of start or end of alarm. + */ + public NotifyDERAlarmRequest(DERControlEnum controlType, ZonedDateTime timestamp) { + setControlType(controlType); + setTimestamp(timestamp); + } + + /** + * Gets name of DER control, e.g. LFMustTrip + * + * @return Name of DER control, e.g. LFMustTrip + */ + public DERControlEnum getControlType() { + return controlType; + } + + /** + * Sets name of DER control, e.g. LFMustTrip + * + * @param controlType Name of DER control, e.g. LFMustTrip + */ + public void setControlType(DERControlEnum controlType) { + if (!isValidControlType(controlType)) { + throw new PropertyConstraintException(controlType, "controlType is invalid"); + } + this.controlType = controlType; + } + + /** + * Returns whether the given controlType is valid + * + * @param controlType the controlType to check the validity of + * @return {@code true} if controlType is valid, {@code false} if not + */ + private boolean isValidControlType(DERControlEnum controlType) { + return controlType != null; + } + + /** + * Gets type of grid event that caused this + * + * @return Type of grid event that caused this + */ + @Nullable + public GridEventFaultEnum getGridEventFault() { + return gridEventFault; + } + + /** + * Sets type of grid event that caused this + * + * @param gridEventFault Type of grid event that caused this + */ + public void setGridEventFault(@Nullable GridEventFaultEnum gridEventFault) { + this.gridEventFault = gridEventFault; + } + + /** + * Adds type of grid event that caused this + * + * @param gridEventFault Type of grid event that caused this + * @return this + */ + public NotifyDERAlarmRequest withGridEventFault(@Nullable GridEventFaultEnum gridEventFault) { + setGridEventFault(gridEventFault); + return this; + } + + /** + * Gets true when error condition has ended. Absent or false when alarm has started. + * + * @return True when error condition has ended + */ + @Nullable + public Boolean getAlarmEnded() { + return alarmEnded; + } + + /** + * Sets true when error condition has ended. Absent or false when alarm has started. + * + * @param alarmEnded True when error condition has ended + */ + public void setAlarmEnded(@Nullable Boolean alarmEnded) { + this.alarmEnded = alarmEnded; + } + + /** + * Adds true when error condition has ended. Absent or false when alarm has started. + * + * @param alarmEnded True when error condition has ended + * @return this + */ + public NotifyDERAlarmRequest withAlarmEnded(@Nullable Boolean alarmEnded) { + setAlarmEnded(alarmEnded); + return this; + } + + /** + * Gets time of start or end of alarm. + * + * @return Time of start or end of alarm + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets time of start or end of alarm. + * + * @param timestamp Time of start or end of alarm + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets optional info provided by EV. + * + * @return Optional info provided by EV + */ + @Nullable + public String getExtraInfo() { + return extraInfo; + } + + /** + * Sets optional info provided by EV. + * + * @param extraInfo Optional info provided by EV + */ + public void setExtraInfo(@Nullable String extraInfo) { + if (!isValidExtraInfo(extraInfo)) { + throw new PropertyConstraintException(extraInfo, "extraInfo is invalid"); + } + this.extraInfo = extraInfo; + } + + /** + * Returns whether the given extraInfo is valid + * + * @param extraInfo the extraInfo to check the validity of + * @return {@code true} if extraInfo is valid, {@code false} if not + */ + private boolean isValidExtraInfo(@Nullable String extraInfo) { + return extraInfo == null || extraInfo.length() <= 200; + } + + /** + * Adds optional info provided by EV. + * + * @param extraInfo Optional info provided by EV + * @return this + */ + public NotifyDERAlarmRequest withExtraInfo(@Nullable String extraInfo) { + setExtraInfo(extraInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyDERAlarmRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidControlType(controlType) + && isValidTimestamp(timestamp) + && isValidExtraInfo(extraInfo) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyDERAlarmRequest that = (NotifyDERAlarmRequest) o; + return Objects.equals(controlType, that.controlType) + && Objects.equals(gridEventFault, that.gridEventFault) + && Objects.equals(alarmEnded, that.alarmEnded) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(extraInfo, that.extraInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(controlType, gridEventFault, alarmEnded, timestamp, extraInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("controlType", controlType) + .add("gridEventFault", gridEventFault) + .add("alarmEnded", alarmEnded) + .add("timestamp", timestamp) + .add("extraInfo", extraInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERAlarmResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERAlarmResponse.java new file mode 100644 index 00000000..8a61cff1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERAlarmResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyDERAlarmResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyDERAlarmResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyDERAlarmResponse class */ + public NotifyDERAlarmResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyDERAlarmResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyDERAlarmResponse that = (NotifyDERAlarmResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERStartStopRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERStartStopRequest.java new file mode 100644 index 00000000..abaf1c7c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERStartStopRequest.java @@ -0,0 +1,307 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyDERStartStopRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyDERStartStopRequest extends RequestWithId { + /** + * Id of the started or stopped DER control. Corresponds to the controlId of the + * SetDERControlRequest. + */ + private String controlId; + + /** True if DER control has started. False if it has ended. */ + private Boolean started; + + /** Time of start or end of event. */ + private ZonedDateTime timestamp; + + /** List of controlIds that are superseded as a result of this control starting. */ + @Nullable private String[] supersededIds; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyDERStartStopRequest class + * + * @param controlId Id of the started or stopped DER control. Corresponds to the controlId of the + * SetDERControlRequest. + * @param started True if DER control has started. False if it has ended. + * @param timestamp Time of start or end of event. + */ + public NotifyDERStartStopRequest(String controlId, Boolean started, ZonedDateTime timestamp) { + setControlId(controlId); + setStarted(started); + setTimestamp(timestamp); + } + + /** + * Gets id of the started or stopped DER control. Corresponds to the controlId of the + * SetDERControlRequest. + * + * @return Id of the started or stopped DER control + */ + public String getControlId() { + return controlId; + } + + /** + * Sets id of the started or stopped DER control. Corresponds to the controlId of the + * SetDERControlRequest. + * + * @param controlId Id of the started or stopped DER control + */ + public void setControlId(String controlId) { + if (!isValidControlId(controlId)) { + throw new PropertyConstraintException(controlId, "controlId is invalid"); + } + this.controlId = controlId; + } + + /** + * Returns whether the given controlId is valid + * + * @param controlId the controlId to check the validity of + * @return {@code true} if controlId is valid, {@code false} if not + */ + private boolean isValidControlId(String controlId) { + return controlId != null && controlId.length() <= 36; + } + + /** + * Gets true if DER control has started. False if it has ended. + * + * @return True if DER control has started + */ + public Boolean getStarted() { + return started; + } + + /** + * Sets true if DER control has started. False if it has ended. + * + * @param started True if DER control has started + */ + public void setStarted(Boolean started) { + if (!isValidStarted(started)) { + throw new PropertyConstraintException(started, "started is invalid"); + } + this.started = started; + } + + /** + * Returns whether the given started is valid + * + * @param started the started to check the validity of + * @return {@code true} if started is valid, {@code false} if not + */ + private boolean isValidStarted(Boolean started) { + return started != null; + } + + /** + * Gets time of start or end of event. + * + * @return Time of start or end of event + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets time of start or end of event. + * + * @param timestamp Time of start or end of event + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets list of controlIds that are superseded as a result of this control starting. + * + * @return List of controlIds that are superseded as a result of this control starting + */ + @Nullable + public String[] getSupersededIds() { + return supersededIds; + } + + /** + * Sets list of controlIds that are superseded as a result of this control starting. + * + * @param supersededIds List of controlIds that are superseded as a result of this control + * starting + */ + public void setSupersededIds(@Nullable String[] supersededIds) { + if (!isValidSupersededIds(supersededIds)) { + throw new PropertyConstraintException(supersededIds, "supersededIds is invalid"); + } + this.supersededIds = supersededIds; + } + + /** + * Returns whether the given supersededIds is valid + * + * @param supersededIds the supersededIds to check the validity of + * @return {@code true} if supersededIds is valid, {@code false} if not + */ + private boolean isValidSupersededIds(@Nullable String[] supersededIds) { + return supersededIds == null + || (supersededIds.length >= 1 + && supersededIds.length <= 24 + && Arrays.stream(supersededIds).allMatch(item -> item.length() <= 36)); + } + + /** + * Adds list of controlIds that are superseded as a result of this control starting. + * + * @param supersededIds List of controlIds that are superseded as a result of this control + * starting + * @return this + */ + public NotifyDERStartStopRequest withSupersededIds(@Nullable String[] supersededIds) { + setSupersededIds(supersededIds); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyDERStartStopRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidControlId(controlId) + && isValidStarted(started) + && isValidTimestamp(timestamp) + && isValidSupersededIds(supersededIds) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyDERStartStopRequest that = (NotifyDERStartStopRequest) o; + return Objects.equals(controlId, that.controlId) + && Objects.equals(started, that.started) + && Objects.equals(timestamp, that.timestamp) + && Arrays.equals(supersededIds, that.supersededIds) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(controlId, started, timestamp, Arrays.hashCode(supersededIds), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("controlId", controlId) + .add("started", started) + .add("timestamp", timestamp) + .add("supersededIds", supersededIds) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERStartStopResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERStartStopResponse.java new file mode 100644 index 00000000..c722f5ec --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDERStartStopResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyDERStartStopResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyDERStartStopResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyDERStartStopResponse class */ + public NotifyDERStartStopResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyDERStartStopResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyDERStartStopResponse that = (NotifyDERStartStopResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDisplayMessagesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDisplayMessagesRequest.java new file mode 100644 index 00000000..b9aab032 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDisplayMessagesRequest.java @@ -0,0 +1,260 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.MessageInfo; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyDisplayMessagesRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyDisplayMessagesRequest extends RequestWithId { + /** Message details, for a message to be displayed on a Charging Station. */ + @Nullable private MessageInfo[] messageInfo; + + /** The id of the GetDisplayMessagesRequest that requested this message. */ + private Integer requestId; + + /** + * "to be continued" indicator. Indicates whether another part of the report follows in an + * upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyDisplayMessagesRequest class + * + * @param requestId The id of the GetDisplayMessagesRequest that requested this message. + */ + public NotifyDisplayMessagesRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageInfo[] getMessageInfo() { + return messageInfo; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param messageInfo Message details, for a message to be displayed on a Charging Station + */ + public void setMessageInfo(@Nullable MessageInfo[] messageInfo) { + if (!isValidMessageInfo(messageInfo)) { + throw new PropertyConstraintException(messageInfo, "messageInfo is invalid"); + } + this.messageInfo = messageInfo; + } + + /** + * Returns whether the given messageInfo is valid + * + * @param messageInfo the messageInfo to check the validity of + * @return {@code true} if messageInfo is valid, {@code false} if not + */ + private boolean isValidMessageInfo(@Nullable MessageInfo[] messageInfo) { + return messageInfo == null + || (messageInfo.length >= 1 + && Arrays.stream(messageInfo).allMatch(item -> item.validate())); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param messageInfo Message details, for a message to be displayed on a Charging Station + * @return this + */ + public NotifyDisplayMessagesRequest withMessageInfo(@Nullable MessageInfo[] messageInfo) { + setMessageInfo(messageInfo); + return this; + } + + /** + * Gets the id of the GetDisplayMessagesRequest that requested this message. + * + * @return The id of the GetDisplayMessagesRequest that requested this message + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the id of the GetDisplayMessagesRequest that requested this message. + * + * @param requestId The id of the GetDisplayMessagesRequest that requested this message + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets "to be continued" indicator. Indicates whether another part of the report follows in an + * upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. + * + * @return "to be continued" indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets "to be continued" indicator. Indicates whether another part of the report follows in an + * upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. + * + * @param tbc "to be continued" indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds "to be continued" indicator. Indicates whether another part of the report follows in an + * upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. + * + * @param tbc "to be continued" indicator + * @return this + */ + public NotifyDisplayMessagesRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyDisplayMessagesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidMessageInfo(messageInfo) + && isValidRequestId(requestId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyDisplayMessagesRequest that = (NotifyDisplayMessagesRequest) o; + return Arrays.equals(messageInfo, that.messageInfo) + && Objects.equals(requestId, that.requestId) + && Objects.equals(tbc, that.tbc) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(messageInfo), requestId, tbc, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("messageInfo", messageInfo) + .add("requestId", requestId) + .add("tbc", tbc) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDisplayMessagesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDisplayMessagesResponse.java new file mode 100644 index 00000000..1c4cc4f7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyDisplayMessagesResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyDisplayMessagesResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyDisplayMessagesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyDisplayMessagesResponse class */ + public NotifyDisplayMessagesResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyDisplayMessagesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyDisplayMessagesResponse that = (NotifyDisplayMessagesResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingNeedsRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingNeedsRequest.java new file mode 100644 index 00000000..087aa252 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingNeedsRequest.java @@ -0,0 +1,303 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingNeeds; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEVChargingNeedsRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyEVChargingNeedsRequest extends RequestWithId { + /** The EVSE and connector to which the EV is connected. EvseId may not be 0. */ + private Integer evseId; + + /** + * The maximum elements the EV supports for: + * + *

+   * - ISO 15118-2: schedule tuples in SASchedule (both Pmax and Tariff).
+   * - ISO 15118-20: PowerScheduleEntry, PriceRule and PriceLevelScheduleEntries.
+   * 
+ */ + @Nullable private Integer maxScheduleTuples; + + /** chargingNeeds */ + private ChargingNeeds chargingNeeds; + + /** + * Time when EV charging needs were received. + * + *

Field can be added when charging station was offline when charging needs were received. + */ + @Nullable private ZonedDateTime timestamp; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyEVChargingNeedsRequest class + * + * @param evseId The EVSE and connector to which the EV is connected. EvseId may not be 0. + * @param chargingNeeds chargingNeeds + */ + public NotifyEVChargingNeedsRequest(Integer evseId, ChargingNeeds chargingNeeds) { + setEvseId(evseId); + setChargingNeeds(chargingNeeds); + } + + /** + * Gets the EVSE and connector to which the EV is connected. EvseId may not be 0. + * + * @return The EVSE and connector to which the EV is connected + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the EVSE and connector to which the EV is connected. EvseId may not be 0. + * + * @param evseId The EVSE and connector to which the EV is connected + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 1; + } + + /** + * Gets the maximum elements the EV supports for: + * + * @return The maximum elements the EV supports for: + */ + @Nullable + public Integer getMaxScheduleTuples() { + return maxScheduleTuples; + } + + /** + * Sets the maximum elements the EV supports for: + * + * @param maxScheduleTuples The maximum elements the EV supports for: + */ + public void setMaxScheduleTuples(@Nullable Integer maxScheduleTuples) { + if (!isValidMaxScheduleTuples(maxScheduleTuples)) { + throw new PropertyConstraintException(maxScheduleTuples, "maxScheduleTuples is invalid"); + } + this.maxScheduleTuples = maxScheduleTuples; + } + + /** + * Returns whether the given maxScheduleTuples is valid + * + * @param maxScheduleTuples the maxScheduleTuples to check the validity of + * @return {@code true} if maxScheduleTuples is valid, {@code false} if not + */ + private boolean isValidMaxScheduleTuples(@Nullable Integer maxScheduleTuples) { + return maxScheduleTuples == null || (maxScheduleTuples >= 0); + } + + /** + * Adds the maximum elements the EV supports for: + * + * @param maxScheduleTuples The maximum elements the EV supports for: + * @return this + */ + public NotifyEVChargingNeedsRequest withMaxScheduleTuples(@Nullable Integer maxScheduleTuples) { + setMaxScheduleTuples(maxScheduleTuples); + return this; + } + + /** + * Gets chargingNeeds + * + * @return chargingNeeds + */ + public ChargingNeeds getChargingNeeds() { + return chargingNeeds; + } + + /** + * Sets chargingNeeds + * + * @param chargingNeeds chargingNeeds + */ + public void setChargingNeeds(ChargingNeeds chargingNeeds) { + if (!isValidChargingNeeds(chargingNeeds)) { + throw new PropertyConstraintException(chargingNeeds, "chargingNeeds is invalid"); + } + this.chargingNeeds = chargingNeeds; + } + + /** + * Returns whether the given chargingNeeds is valid + * + * @param chargingNeeds the chargingNeeds to check the validity of + * @return {@code true} if chargingNeeds is valid, {@code false} if not + */ + private boolean isValidChargingNeeds(ChargingNeeds chargingNeeds) { + return chargingNeeds != null && chargingNeeds.validate(); + } + + /** + * Gets time when EV charging needs were received. + * + * @return Time when EV charging needs were received + */ + @Nullable + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets time when EV charging needs were received. + * + * @param timestamp Time when EV charging needs were received + */ + public void setTimestamp(@Nullable ZonedDateTime timestamp) { + this.timestamp = timestamp; + } + + /** + * Adds time when EV charging needs were received. + * + * @param timestamp Time when EV charging needs were received + * @return this + */ + public NotifyEVChargingNeedsRequest withTimestamp(@Nullable ZonedDateTime timestamp) { + setTimestamp(timestamp); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEVChargingNeedsRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvseId(evseId) + && isValidMaxScheduleTuples(maxScheduleTuples) + && isValidChargingNeeds(chargingNeeds) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEVChargingNeedsRequest that = (NotifyEVChargingNeedsRequest) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(maxScheduleTuples, that.maxScheduleTuples) + && Objects.equals(chargingNeeds, that.chargingNeeds) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, maxScheduleTuples, chargingNeeds, timestamp, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("maxScheduleTuples", maxScheduleTuples) + .add("chargingNeeds", chargingNeeds) + .add("timestamp", timestamp) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingNeedsResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingNeedsResponse.java new file mode 100644 index 00000000..851822e9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingNeedsResponse.java @@ -0,0 +1,217 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.NotifyEVChargingNeedsStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEVChargingNeedsResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyEVChargingNeedsResponse extends Confirmation { + /** + * Returns whether the CSMS has been able to process the message successfully. It does not imply + * that the evChargingNeeds can be met with the current charging profile. + */ + private NotifyEVChargingNeedsStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyEVChargingNeedsResponse class + * + * @param status Returns whether the CSMS has been able to process the message successfully. It + * does not imply that the evChargingNeeds can be met with the current charging profile. + */ + public NotifyEVChargingNeedsResponse(NotifyEVChargingNeedsStatusEnum status) { + setStatus(status); + } + + /** + * Gets returns whether the CSMS has been able to process the message successfully. It does not + * imply that the evChargingNeeds can be met with the current charging profile. + * + * @return Returns whether the CSMS has been able to process the message successfully + */ + public NotifyEVChargingNeedsStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether the CSMS has been able to process the message successfully. It does not + * imply that the evChargingNeeds can be met with the current charging profile. + * + * @param status Returns whether the CSMS has been able to process the message successfully + */ + public void setStatus(NotifyEVChargingNeedsStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(NotifyEVChargingNeedsStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public NotifyEVChargingNeedsResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEVChargingNeedsResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEVChargingNeedsResponse that = (NotifyEVChargingNeedsResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingScheduleRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingScheduleRequest.java new file mode 100644 index 00000000..4f747196 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingScheduleRequest.java @@ -0,0 +1,377 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingSchedule; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEVChargingScheduleRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyEVChargingScheduleRequest extends RequestWithId { + /** Periods contained in the charging profile are relative to this point in time. */ + private ZonedDateTime timeBase; + + /** + * Charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + *

An ISO 15118-20 session may provide either an absolutePriceSchedule or a priceLevelSchedule. + * An ISO 15118-2 session can only provide asalesTariff element. The field digestValue is used + * when price schedule or sales tariff are signed. + * + *

image::images/ChargingSchedule-Simple.png[] + */ + private ChargingSchedule chargingSchedule; + + /** + * The charging schedule contained in this notification applies to an EVSE. EvseId must be greater + * than 0. + */ + private Integer evseId; + + /** Id of the chargingSchedule that EV selected from the provided ChargingProfile. */ + @Nullable private Integer selectedChargingScheduleId; + + /** + * True when power tolerance is accepted by EV. This value is taken from + * EVPowerProfile.PowerToleranceAcceptance in the ISO 15118-20 PowerDeliverReq message.. + */ + @Nullable private Boolean powerToleranceAcceptance; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyEVChargingScheduleRequest class + * + * @param timeBase Periods contained in the charging profile are relative to this point in time. + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * @param evseId The charging schedule contained in this notification applies to an EVSE. EvseId + * must be greater than 0. + */ + public NotifyEVChargingScheduleRequest( + ZonedDateTime timeBase, ChargingSchedule chargingSchedule, Integer evseId) { + setTimeBase(timeBase); + setChargingSchedule(chargingSchedule); + setEvseId(evseId); + } + + /** + * Gets periods contained in the charging profile are relative to this point in time. + * + * @return Periods contained in the charging profile are relative to this point in time + */ + public ZonedDateTime getTimeBase() { + return timeBase; + } + + /** + * Sets periods contained in the charging profile are relative to this point in time. + * + * @param timeBase Periods contained in the charging profile are relative to this point in time + */ + public void setTimeBase(ZonedDateTime timeBase) { + if (!isValidTimeBase(timeBase)) { + throw new PropertyConstraintException(timeBase, "timeBase is invalid"); + } + this.timeBase = timeBase; + } + + /** + * Returns whether the given timeBase is valid + * + * @param timeBase the timeBase to check the validity of + * @return {@code true} if timeBase is valid, {@code false} if not + */ + private boolean isValidTimeBase(ZonedDateTime timeBase) { + return timeBase != null; + } + + /** + * Gets charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + * @return Charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType + */ + public ChargingSchedule getChargingSchedule() { + return chargingSchedule; + } + + /** + * Sets charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: NotifyEVChargingScheduleRequest and ChargingProfileType + */ + public void setChargingSchedule(ChargingSchedule chargingSchedule) { + if (!isValidChargingSchedule(chargingSchedule)) { + throw new PropertyConstraintException(chargingSchedule, "chargingSchedule is invalid"); + } + this.chargingSchedule = chargingSchedule; + } + + /** + * Returns whether the given chargingSchedule is valid + * + * @param chargingSchedule the chargingSchedule to check the validity of + * @return {@code true} if chargingSchedule is valid, {@code false} if not + */ + private boolean isValidChargingSchedule(ChargingSchedule chargingSchedule) { + return chargingSchedule != null && chargingSchedule.validate(); + } + + /** + * Gets the charging schedule contained in this notification applies to an EVSE. EvseId must be + * greater than 0. + * + * @return The charging schedule contained in this notification applies to an EVSE + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the charging schedule contained in this notification applies to an EVSE. EvseId must be + * greater than 0. + * + * @param evseId The charging schedule contained in this notification applies to an EVSE + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 1; + } + + /** + * Gets id of the chargingSchedule that EV selected from the provided ChargingProfile. + * + * @return Id of the chargingSchedule that EV selected from the provided ChargingProfile + */ + @Nullable + public Integer getSelectedChargingScheduleId() { + return selectedChargingScheduleId; + } + + /** + * Sets id of the chargingSchedule that EV selected from the provided ChargingProfile. + * + * @param selectedChargingScheduleId Id of the chargingSchedule that EV selected from the provided + * ChargingProfile + */ + public void setSelectedChargingScheduleId(@Nullable Integer selectedChargingScheduleId) { + if (!isValidSelectedChargingScheduleId(selectedChargingScheduleId)) { + throw new PropertyConstraintException( + selectedChargingScheduleId, "selectedChargingScheduleId is invalid"); + } + this.selectedChargingScheduleId = selectedChargingScheduleId; + } + + /** + * Returns whether the given selectedChargingScheduleId is valid + * + * @param selectedChargingScheduleId the selectedChargingScheduleId to check the validity of + * @return {@code true} if selectedChargingScheduleId is valid, {@code false} if not + */ + private boolean isValidSelectedChargingScheduleId(@Nullable Integer selectedChargingScheduleId) { + return selectedChargingScheduleId == null || (selectedChargingScheduleId >= 0); + } + + /** + * Adds id of the chargingSchedule that EV selected from the provided ChargingProfile. + * + * @param selectedChargingScheduleId Id of the chargingSchedule that EV selected from the provided + * ChargingProfile + * @return this + */ + public NotifyEVChargingScheduleRequest withSelectedChargingScheduleId( + @Nullable Integer selectedChargingScheduleId) { + setSelectedChargingScheduleId(selectedChargingScheduleId); + return this; + } + + /** + * Gets true when power tolerance is accepted by EV. This value is taken from + * EVPowerProfile.PowerToleranceAcceptance in the ISO 15118-20 PowerDeliverReq message.. + * + * @return True when power tolerance is accepted by EV + */ + @Nullable + public Boolean getPowerToleranceAcceptance() { + return powerToleranceAcceptance; + } + + /** + * Sets true when power tolerance is accepted by EV. This value is taken from + * EVPowerProfile.PowerToleranceAcceptance in the ISO 15118-20 PowerDeliverReq message.. + * + * @param powerToleranceAcceptance True when power tolerance is accepted by EV + */ + public void setPowerToleranceAcceptance(@Nullable Boolean powerToleranceAcceptance) { + this.powerToleranceAcceptance = powerToleranceAcceptance; + } + + /** + * Adds true when power tolerance is accepted by EV. This value is taken from + * EVPowerProfile.PowerToleranceAcceptance in the ISO 15118-20 PowerDeliverReq message.. + * + * @param powerToleranceAcceptance True when power tolerance is accepted by EV + * @return this + */ + public NotifyEVChargingScheduleRequest withPowerToleranceAcceptance( + @Nullable Boolean powerToleranceAcceptance) { + setPowerToleranceAcceptance(powerToleranceAcceptance); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEVChargingScheduleRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTimeBase(timeBase) + && isValidChargingSchedule(chargingSchedule) + && isValidEvseId(evseId) + && isValidSelectedChargingScheduleId(selectedChargingScheduleId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEVChargingScheduleRequest that = (NotifyEVChargingScheduleRequest) o; + return Objects.equals(timeBase, that.timeBase) + && Objects.equals(chargingSchedule, that.chargingSchedule) + && Objects.equals(evseId, that.evseId) + && Objects.equals(selectedChargingScheduleId, that.selectedChargingScheduleId) + && Objects.equals(powerToleranceAcceptance, that.powerToleranceAcceptance) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + timeBase, + chargingSchedule, + evseId, + selectedChargingScheduleId, + powerToleranceAcceptance, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("timeBase", timeBase) + .add("chargingSchedule", chargingSchedule) + .add("evseId", evseId) + .add("selectedChargingScheduleId", selectedChargingScheduleId) + .add("powerToleranceAcceptance", powerToleranceAcceptance) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingScheduleResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingScheduleResponse.java new file mode 100644 index 00000000..0eeee7f6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEVChargingScheduleResponse.java @@ -0,0 +1,217 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEVChargingScheduleResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyEVChargingScheduleResponse extends Confirmation { + /** + * Returns whether the CSMS has been able to process the message successfully. It does not imply + * any approval of the charging schedule. + */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyEVChargingScheduleResponse class + * + * @param status Returns whether the CSMS has been able to process the message successfully. It + * does not imply any approval of the charging schedule. + */ + public NotifyEVChargingScheduleResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets returns whether the CSMS has been able to process the message successfully. It does not + * imply any approval of the charging schedule. + * + * @return Returns whether the CSMS has been able to process the message successfully + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether the CSMS has been able to process the message successfully. It does not + * imply any approval of the charging schedule. + * + * @param status Returns whether the CSMS has been able to process the message successfully + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public NotifyEVChargingScheduleResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEVChargingScheduleResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEVChargingScheduleResponse that = (NotifyEVChargingScheduleResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEventRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEventRequest.java new file mode 100644 index 00000000..a243f1de --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEventRequest.java @@ -0,0 +1,290 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.EventData; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEventRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyEventRequest extends RequestWithId { + /** Timestamp of the moment this message was generated at the Charging Station. */ + private ZonedDateTime generatedAt; + + /** + * “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyEventRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Sequence number of this message. First message starts at 0. */ + private Integer seqNo; + + /** Class to report an event notification for a component-variable. */ + private EventData[] eventData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyEventRequest class + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param eventData Class to report an event notification for a component-variable. + */ + public NotifyEventRequest(ZonedDateTime generatedAt, Integer seqNo, EventData[] eventData) { + setGeneratedAt(generatedAt); + setSeqNo(seqNo); + setEventData(eventData); + } + + /** + * Gets timestamp of the moment this message was generated at the Charging Station. + * + * @return Timestamp of the moment this message was generated at the Charging Station + */ + public ZonedDateTime getGeneratedAt() { + return generatedAt; + } + + /** + * Sets timestamp of the moment this message was generated at the Charging Station. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station + */ + public void setGeneratedAt(ZonedDateTime generatedAt) { + if (!isValidGeneratedAt(generatedAt)) { + throw new PropertyConstraintException(generatedAt, "generatedAt is invalid"); + } + this.generatedAt = generatedAt; + } + + /** + * Returns whether the given generatedAt is valid + * + * @param generatedAt the generatedAt to check the validity of + * @return {@code true} if generatedAt is valid, {@code false} if not + */ + private boolean isValidGeneratedAt(ZonedDateTime generatedAt) { + return generatedAt != null; + } + + /** + * Gets “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyEventRequest message. Default value when omitted is false. + * + * @return “to be continued” indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyEventRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyEventRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + * @return this + */ + public NotifyEventRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets sequence number of this message. First message starts at 0. + * + * @return Sequence number of this message + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets sequence number of this message. First message starts at 0. + * + * @param seqNo Sequence number of this message + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null && seqNo >= 0; + } + + /** + * Gets class to report an event notification for a component-variable. + * + * @return Class to report an event notification for a component-variable + */ + public EventData[] getEventData() { + return eventData; + } + + /** + * Sets class to report an event notification for a component-variable. + * + * @param eventData Class to report an event notification for a component-variable + */ + public void setEventData(EventData[] eventData) { + if (!isValidEventData(eventData)) { + throw new PropertyConstraintException(eventData, "eventData is invalid"); + } + this.eventData = eventData; + } + + /** + * Returns whether the given eventData is valid + * + * @param eventData the eventData to check the validity of + * @return {@code true} if eventData is valid, {@code false} if not + */ + private boolean isValidEventData(EventData[] eventData) { + return eventData != null + && eventData.length >= 1 + && Arrays.stream(eventData).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEventRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidGeneratedAt(generatedAt) + && isValidSeqNo(seqNo) + && isValidEventData(eventData) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEventRequest that = (NotifyEventRequest) o; + return Objects.equals(generatedAt, that.generatedAt) + && Objects.equals(tbc, that.tbc) + && Objects.equals(seqNo, that.seqNo) + && Arrays.equals(eventData, that.eventData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(generatedAt, tbc, seqNo, Arrays.hashCode(eventData), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("generatedAt", generatedAt) + .add("tbc", tbc) + .add("seqNo", seqNo) + .add("eventData", eventData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEventResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEventResponse.java new file mode 100644 index 00000000..6fb6aa2c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyEventResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEventResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyEventResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyEventResponse class */ + public NotifyEventResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEventResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEventResponse that = (NotifyEventResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyMonitoringReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyMonitoringReportRequest.java new file mode 100644 index 00000000..b1842c6a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyMonitoringReportRequest.java @@ -0,0 +1,339 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.MonitoringData; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyMonitoringReportRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyMonitoringReportRequest extends RequestWithId { + /** Class to hold parameters of SetVariableMonitoring request. */ + @Nullable private MonitoringData[] monitor; + + /** The id of the GetMonitoringRequest that requested this report. */ + private Integer requestId; + + /** + * “to be continued” indicator. Indicates whether another part of the monitoringData follows in an + * upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Sequence number of this message. First message starts at 0. */ + private Integer seqNo; + + /** Timestamp of the moment this message was generated at the Charging Station. */ + private ZonedDateTime generatedAt; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyMonitoringReportRequest class + * + * @param requestId The id of the GetMonitoringRequest that requested this report. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + */ + public NotifyMonitoringReportRequest( + Integer requestId, Integer seqNo, ZonedDateTime generatedAt) { + setRequestId(requestId); + setSeqNo(seqNo); + setGeneratedAt(generatedAt); + } + + /** + * Gets class to hold parameters of SetVariableMonitoring request. + * + * @return Class to hold parameters of SetVariableMonitoring request + */ + @Nullable + public MonitoringData[] getMonitor() { + return monitor; + } + + /** + * Sets class to hold parameters of SetVariableMonitoring request. + * + * @param monitor Class to hold parameters of SetVariableMonitoring request + */ + public void setMonitor(@Nullable MonitoringData[] monitor) { + if (!isValidMonitor(monitor)) { + throw new PropertyConstraintException(monitor, "monitor is invalid"); + } + this.monitor = monitor; + } + + /** + * Returns whether the given monitor is valid + * + * @param monitor the monitor to check the validity of + * @return {@code true} if monitor is valid, {@code false} if not + */ + private boolean isValidMonitor(@Nullable MonitoringData[] monitor) { + return monitor == null + || (monitor.length >= 1 && Arrays.stream(monitor).allMatch(item -> item.validate())); + } + + /** + * Adds class to hold parameters of SetVariableMonitoring request. + * + * @param monitor Class to hold parameters of SetVariableMonitoring request + * @return this + */ + public NotifyMonitoringReportRequest withMonitor(@Nullable MonitoringData[] monitor) { + setMonitor(monitor); + return this; + } + + /** + * Gets the id of the GetMonitoringRequest that requested this report. + * + * @return The id of the GetMonitoringRequest that requested this report + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the id of the GetMonitoringRequest that requested this report. + * + * @param requestId The id of the GetMonitoringRequest that requested this report + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @return “to be continued” indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + * @return this + */ + public NotifyMonitoringReportRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets sequence number of this message. First message starts at 0. + * + * @return Sequence number of this message + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets sequence number of this message. First message starts at 0. + * + * @param seqNo Sequence number of this message + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null && seqNo >= 0; + } + + /** + * Gets timestamp of the moment this message was generated at the Charging Station. + * + * @return Timestamp of the moment this message was generated at the Charging Station + */ + public ZonedDateTime getGeneratedAt() { + return generatedAt; + } + + /** + * Sets timestamp of the moment this message was generated at the Charging Station. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station + */ + public void setGeneratedAt(ZonedDateTime generatedAt) { + if (!isValidGeneratedAt(generatedAt)) { + throw new PropertyConstraintException(generatedAt, "generatedAt is invalid"); + } + this.generatedAt = generatedAt; + } + + /** + * Returns whether the given generatedAt is valid + * + * @param generatedAt the generatedAt to check the validity of + * @return {@code true} if generatedAt is valid, {@code false} if not + */ + private boolean isValidGeneratedAt(ZonedDateTime generatedAt) { + return generatedAt != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyMonitoringReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidMonitor(monitor) + && isValidRequestId(requestId) + && isValidSeqNo(seqNo) + && isValidGeneratedAt(generatedAt) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyMonitoringReportRequest that = (NotifyMonitoringReportRequest) o; + return Arrays.equals(monitor, that.monitor) + && Objects.equals(requestId, that.requestId) + && Objects.equals(tbc, that.tbc) + && Objects.equals(seqNo, that.seqNo) + && Objects.equals(generatedAt, that.generatedAt) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(monitor), requestId, tbc, seqNo, generatedAt, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("monitor", monitor) + .add("requestId", requestId) + .add("tbc", tbc) + .add("seqNo", seqNo) + .add("generatedAt", generatedAt) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyMonitoringReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyMonitoringReportResponse.java new file mode 100644 index 00000000..d30c28e0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyMonitoringReportResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyMonitoringReportResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyMonitoringReportResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyMonitoringReportResponse class */ + public NotifyMonitoringReportResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyMonitoringReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyMonitoringReportResponse that = (NotifyMonitoringReportResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPeriodicEventStream.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPeriodicEventStream.java new file mode 100644 index 00000000..fa06a578 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPeriodicEventStream.java @@ -0,0 +1,283 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StreamDataElement; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyPeriodicEventStream + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyPeriodicEventStream { + /** data */ + private StreamDataElement[] data; + + /** Id of stream. */ + private Integer id; + + /** Number of data elements still pending to be sent. */ + private Integer pending; + + /** Base timestamp to add to time offset of values. */ + private ZonedDateTime basetime; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyPeriodicEventStream class + * + * @param data data + * @param id Id of stream. + * @param pending Number of data elements still pending to be sent. + * @param basetime Base timestamp to add to time offset of values. + */ + public NotifyPeriodicEventStream( + StreamDataElement[] data, Integer id, Integer pending, ZonedDateTime basetime) { + setData(data); + setId(id); + setPending(pending); + setBasetime(basetime); + } + + /** + * Gets data + * + * @return data + */ + public StreamDataElement[] getData() { + return data; + } + + /** + * Sets data + * + * @param data data + */ + public void setData(StreamDataElement[] data) { + if (!isValidData(data)) { + throw new PropertyConstraintException(data, "data is invalid"); + } + this.data = data; + } + + /** + * Returns whether the given data is valid + * + * @param data the data to check the validity of + * @return {@code true} if data is valid, {@code false} if not + */ + private boolean isValidData(StreamDataElement[] data) { + return data != null + && data.length >= 1 + && Arrays.stream(data).allMatch(item -> item.validate()); + } + + /** + * Gets id of stream. + * + * @return Id of stream + */ + public Integer getId() { + return id; + } + + /** + * Sets id of stream. + * + * @param id Id of stream + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets number of data elements still pending to be sent. + * + * @return Number of data elements still pending to be sent + */ + public Integer getPending() { + return pending; + } + + /** + * Sets number of data elements still pending to be sent. + * + * @param pending Number of data elements still pending to be sent + */ + public void setPending(Integer pending) { + if (!isValidPending(pending)) { + throw new PropertyConstraintException(pending, "pending is invalid"); + } + this.pending = pending; + } + + /** + * Returns whether the given pending is valid + * + * @param pending the pending to check the validity of + * @return {@code true} if pending is valid, {@code false} if not + */ + private boolean isValidPending(Integer pending) { + return pending != null && pending >= 0; + } + + /** + * Gets base timestamp to add to time offset of values. + * + * @return Base timestamp to add to time offset of values + */ + public ZonedDateTime getBasetime() { + return basetime; + } + + /** + * Sets base timestamp to add to time offset of values. + * + * @param basetime Base timestamp to add to time offset of values + */ + public void setBasetime(ZonedDateTime basetime) { + if (!isValidBasetime(basetime)) { + throw new PropertyConstraintException(basetime, "basetime is invalid"); + } + this.basetime = basetime; + } + + /** + * Returns whether the given basetime is valid + * + * @param basetime the basetime to check the validity of + * @return {@code true} if basetime is valid, {@code false} if not + */ + private boolean isValidBasetime(ZonedDateTime basetime) { + return basetime != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyPeriodicEventStream withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidData(data) + && isValidId(id) + && isValidPending(pending) + && isValidBasetime(basetime) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyPeriodicEventStream that = (NotifyPeriodicEventStream) o; + return Arrays.equals(data, that.data) + && Objects.equals(id, that.id) + && Objects.equals(pending, that.pending) + && Objects.equals(basetime, that.basetime) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(data), id, pending, basetime, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("data", data) + .add("id", id) + .add("pending", pending) + .add("basetime", basetime) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPriorityChargingRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPriorityChargingRequest.java new file mode 100644 index 00000000..e36889bd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPriorityChargingRequest.java @@ -0,0 +1,212 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyPriorityChargingRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyPriorityChargingRequest extends RequestWithId { + /** The transaction for which priority charging is requested. */ + private String transactionId; + + /** + * True if priority charging was activated. False if it has stopped using the priority charging + * profile. + */ + private Boolean activated; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyPriorityChargingRequest class + * + * @param transactionId The transaction for which priority charging is requested. + * @param activated True if priority charging was activated. False if it has stopped using the + * priority charging profile. + */ + public NotifyPriorityChargingRequest(String transactionId, Boolean activated) { + setTransactionId(transactionId); + setActivated(activated); + } + + /** + * Gets the transaction for which priority charging is requested. + * + * @return The transaction for which priority charging is requested + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the transaction for which priority charging is requested. + * + * @param transactionId The transaction for which priority charging is requested + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + /** + * Gets true if priority charging was activated. False if it has stopped using the priority + * charging profile. + * + * @return True if priority charging was activated + */ + public Boolean getActivated() { + return activated; + } + + /** + * Sets true if priority charging was activated. False if it has stopped using the priority + * charging profile. + * + * @param activated True if priority charging was activated + */ + public void setActivated(Boolean activated) { + if (!isValidActivated(activated)) { + throw new PropertyConstraintException(activated, "activated is invalid"); + } + this.activated = activated; + } + + /** + * Returns whether the given activated is valid + * + * @param activated the activated to check the validity of + * @return {@code true} if activated is valid, {@code false} if not + */ + private boolean isValidActivated(Boolean activated) { + return activated != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyPriorityChargingRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTransactionId(transactionId) + && isValidActivated(activated) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyPriorityChargingRequest that = (NotifyPriorityChargingRequest) o; + return Objects.equals(transactionId, that.transactionId) + && Objects.equals(activated, that.activated) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(transactionId, activated, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("transactionId", transactionId) + .add("activated", activated) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPriorityChargingResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPriorityChargingResponse.java new file mode 100644 index 00000000..46c380ec --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPriorityChargingResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * This response message has an empty body. + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyPriorityChargingResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyPriorityChargingResponse class */ + public NotifyPriorityChargingResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyPriorityChargingResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyPriorityChargingResponse that = (NotifyPriorityChargingResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyReportRequest.java new file mode 100644 index 00000000..1a42694d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyReportRequest.java @@ -0,0 +1,343 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.ReportData; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyReportRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyReportRequest extends RequestWithId { + /** The id of the GetReportRequest or GetBaseReportRequest that requested this report */ + private Integer requestId; + + /** Timestamp of the moment this message was generated at the Charging Station. */ + private ZonedDateTime generatedAt; + + /** Class to report components, variables and variable attributes and characteristics. */ + @Nullable private ReportData[] reportData; + + /** + * “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyReportRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Sequence number of this message. First message starts at 0. */ + private Integer seqNo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyReportRequest class + * + * @param requestId The id of the GetReportRequest or GetBaseReportRequest that requested this + * report + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param seqNo Sequence number of this message. First message starts at 0. + */ + public NotifyReportRequest(Integer requestId, ZonedDateTime generatedAt, Integer seqNo) { + setRequestId(requestId); + setGeneratedAt(generatedAt); + setSeqNo(seqNo); + } + + /** + * Gets the id of the GetReportRequest or GetBaseReportRequest that requested this report + * + * @return The id of the GetReportRequest or GetBaseReportRequest that requested this report + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the id of the GetReportRequest or GetBaseReportRequest that requested this report + * + * @param requestId The id of the GetReportRequest or GetBaseReportRequest that requested this + * report + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets timestamp of the moment this message was generated at the Charging Station. + * + * @return Timestamp of the moment this message was generated at the Charging Station + */ + public ZonedDateTime getGeneratedAt() { + return generatedAt; + } + + /** + * Sets timestamp of the moment this message was generated at the Charging Station. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station + */ + public void setGeneratedAt(ZonedDateTime generatedAt) { + if (!isValidGeneratedAt(generatedAt)) { + throw new PropertyConstraintException(generatedAt, "generatedAt is invalid"); + } + this.generatedAt = generatedAt; + } + + /** + * Returns whether the given generatedAt is valid + * + * @param generatedAt the generatedAt to check the validity of + * @return {@code true} if generatedAt is valid, {@code false} if not + */ + private boolean isValidGeneratedAt(ZonedDateTime generatedAt) { + return generatedAt != null; + } + + /** + * Gets class to report components, variables and variable attributes and characteristics. + * + * @return Class to report components, variables and variable attributes and characteristics + */ + @Nullable + public ReportData[] getReportData() { + return reportData; + } + + /** + * Sets class to report components, variables and variable attributes and characteristics. + * + * @param reportData Class to report components, variables and variable attributes and + * characteristics + */ + public void setReportData(@Nullable ReportData[] reportData) { + if (!isValidReportData(reportData)) { + throw new PropertyConstraintException(reportData, "reportData is invalid"); + } + this.reportData = reportData; + } + + /** + * Returns whether the given reportData is valid + * + * @param reportData the reportData to check the validity of + * @return {@code true} if reportData is valid, {@code false} if not + */ + private boolean isValidReportData(@Nullable ReportData[] reportData) { + return reportData == null + || (reportData.length >= 1 && Arrays.stream(reportData).allMatch(item -> item.validate())); + } + + /** + * Adds class to report components, variables and variable attributes and characteristics. + * + * @param reportData Class to report components, variables and variable attributes and + * characteristics + * @return this + */ + public NotifyReportRequest withReportData(@Nullable ReportData[] reportData) { + setReportData(reportData); + return this; + } + + /** + * Gets “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyReportRequest message. Default value when omitted is false. + * + * @return “to be continued” indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + * @return this + */ + public NotifyReportRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets sequence number of this message. First message starts at 0. + * + * @return Sequence number of this message + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets sequence number of this message. First message starts at 0. + * + * @param seqNo Sequence number of this message + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null && seqNo >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidRequestId(requestId) + && isValidGeneratedAt(generatedAt) + && isValidReportData(reportData) + && isValidSeqNo(seqNo) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyReportRequest that = (NotifyReportRequest) o; + return Objects.equals(requestId, that.requestId) + && Objects.equals(generatedAt, that.generatedAt) + && Arrays.equals(reportData, that.reportData) + && Objects.equals(tbc, that.tbc) + && Objects.equals(seqNo, that.seqNo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + requestId, generatedAt, Arrays.hashCode(reportData), tbc, seqNo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("requestId", requestId) + .add("generatedAt", generatedAt) + .add("reportData", reportData) + .add("tbc", tbc) + .add("seqNo", seqNo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyReportResponse.java new file mode 100644 index 00000000..89492586 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyReportResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyReportResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyReportResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyReportResponse class */ + public NotifyReportResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyReportResponse that = (NotifyReportResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifySettlementRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifySettlementRequest.java new file mode 100644 index 00000000..3ad347a4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifySettlementRequest.java @@ -0,0 +1,614 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.Address; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.PaymentStatusEnum; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifySettlementRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifySettlementRequest extends RequestWithId { + /** + * The transactionId that the settlement belongs to. Can be empty if the payment transaction is + * canceled prior to the start of the OCPP transaction. + */ + @Nullable private String transactionId; + + /** + * The payment reference received from the payment terminal and is used as the value for idToken. + */ + private String pspRef; + + /** The status of the settlement attempt. */ + private PaymentStatusEnum status; + + /** Additional information from payment terminal/payment process. */ + @Nullable private String statusInfo; + + /** The amount that was settled, or attempted to be settled (in case of failure). */ + private Double settlementAmount; + + /** The time when the settlement was done. */ + private ZonedDateTime settlementTime; + + /** receiptId */ + @Nullable private String receiptId; + + /** The receipt URL, to be used if the receipt is generated by the payment terminal or the CS. */ + @Nullable private String receiptUrl; + + /** A generic address format. */ + @Nullable private Address vatCompany; + + /** VAT number for a company receipt. */ + @Nullable private String vatNumber; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifySettlementRequest class + * + * @param pspRef The payment reference received from the payment terminal and is used as the value + * for idToken. + * @param status The status of the settlement attempt. + * @param settlementAmount The amount that was settled, or attempted to be settled (in case of + * failure). + * @param settlementTime The time when the settlement was done. + */ + public NotifySettlementRequest( + String pspRef, + PaymentStatusEnum status, + Double settlementAmount, + ZonedDateTime settlementTime) { + setPspRef(pspRef); + setStatus(status); + setSettlementAmount(settlementAmount); + setSettlementTime(settlementTime); + } + + /** + * Gets the transactionId that the settlement belongs to. Can be empty if the payment transaction + * is canceled prior to the start of the OCPP transaction. + * + * @return The transactionId that the settlement belongs to + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the transactionId that the settlement belongs to. Can be empty if the payment transaction + * is canceled prior to the start of the OCPP transaction. + * + * @param transactionId The transactionId that the settlement belongs to + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds the transactionId that the settlement belongs to. Can be empty if the payment transaction + * is canceled prior to the start of the OCPP transaction. + * + * @param transactionId The transactionId that the settlement belongs to + * @return this + */ + public NotifySettlementRequest withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + /** + * Gets the payment reference received from the payment terminal and is used as the value for + * idToken. + * + * @return The payment reference received from the payment terminal and is used as the value for + * idToken + */ + public String getPspRef() { + return pspRef; + } + + /** + * Sets the payment reference received from the payment terminal and is used as the value for + * idToken. + * + * @param pspRef The payment reference received from the payment terminal and is used as the value + * for idToken + */ + public void setPspRef(String pspRef) { + if (!isValidPspRef(pspRef)) { + throw new PropertyConstraintException(pspRef, "pspRef is invalid"); + } + this.pspRef = pspRef; + } + + /** + * Returns whether the given pspRef is valid + * + * @param pspRef the pspRef to check the validity of + * @return {@code true} if pspRef is valid, {@code false} if not + */ + private boolean isValidPspRef(String pspRef) { + return pspRef != null && pspRef.length() <= 255; + } + + /** + * Gets the status of the settlement attempt. + * + * @return The status of the settlement attempt + */ + public PaymentStatusEnum getStatus() { + return status; + } + + /** + * Sets the status of the settlement attempt. + * + * @param status The status of the settlement attempt + */ + public void setStatus(PaymentStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(PaymentStatusEnum status) { + return status != null; + } + + /** + * Gets additional information from payment terminal/payment process. + * + * @return Additional information from payment terminal/payment process + */ + @Nullable + public String getStatusInfo() { + return statusInfo; + } + + /** + * Sets additional information from payment terminal/payment process. + * + * @param statusInfo Additional information from payment terminal/payment process + */ + public void setStatusInfo(@Nullable String statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable String statusInfo) { + return statusInfo == null || statusInfo.length() <= 500; + } + + /** + * Adds additional information from payment terminal/payment process. + * + * @param statusInfo Additional information from payment terminal/payment process + * @return this + */ + public NotifySettlementRequest withStatusInfo(@Nullable String statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets the amount that was settled, or attempted to be settled (in case of failure). + * + * @return The amount that was settled, or attempted to be settled (in case of failure) + */ + public Double getSettlementAmount() { + return settlementAmount; + } + + /** + * Sets the amount that was settled, or attempted to be settled (in case of failure). + * + * @param settlementAmount The amount that was settled, or attempted to be settled (in case of + * failure) + */ + public void setSettlementAmount(Double settlementAmount) { + if (!isValidSettlementAmount(settlementAmount)) { + throw new PropertyConstraintException(settlementAmount, "settlementAmount is invalid"); + } + this.settlementAmount = settlementAmount; + } + + /** + * Returns whether the given settlementAmount is valid + * + * @param settlementAmount the settlementAmount to check the validity of + * @return {@code true} if settlementAmount is valid, {@code false} if not + */ + private boolean isValidSettlementAmount(Double settlementAmount) { + return settlementAmount != null; + } + + /** + * Gets the time when the settlement was done. + * + * @return The time when the settlement was done + */ + public ZonedDateTime getSettlementTime() { + return settlementTime; + } + + /** + * Sets the time when the settlement was done. + * + * @param settlementTime The time when the settlement was done + */ + public void setSettlementTime(ZonedDateTime settlementTime) { + if (!isValidSettlementTime(settlementTime)) { + throw new PropertyConstraintException(settlementTime, "settlementTime is invalid"); + } + this.settlementTime = settlementTime; + } + + /** + * Returns whether the given settlementTime is valid + * + * @param settlementTime the settlementTime to check the validity of + * @return {@code true} if settlementTime is valid, {@code false} if not + */ + private boolean isValidSettlementTime(ZonedDateTime settlementTime) { + return settlementTime != null; + } + + /** + * Gets receiptId + * + * @return receiptId + */ + @Nullable + public String getReceiptId() { + return receiptId; + } + + /** + * Sets receiptId + * + * @param receiptId receiptId + */ + public void setReceiptId(@Nullable String receiptId) { + if (!isValidReceiptId(receiptId)) { + throw new PropertyConstraintException(receiptId, "receiptId is invalid"); + } + this.receiptId = receiptId; + } + + /** + * Returns whether the given receiptId is valid + * + * @param receiptId the receiptId to check the validity of + * @return {@code true} if receiptId is valid, {@code false} if not + */ + private boolean isValidReceiptId(@Nullable String receiptId) { + return receiptId == null || receiptId.length() <= 50; + } + + /** + * Adds receiptId + * + * @param receiptId receiptId + * @return this + */ + public NotifySettlementRequest withReceiptId(@Nullable String receiptId) { + setReceiptId(receiptId); + return this; + } + + /** + * Gets the receipt URL, to be used if the receipt is generated by the payment terminal or the CS. + * + * @return The receipt URL, to be used if the receipt is generated by the payment terminal or the + * CS + */ + @Nullable + public String getReceiptUrl() { + return receiptUrl; + } + + /** + * Sets the receipt URL, to be used if the receipt is generated by the payment terminal or the CS. + * + * @param receiptUrl The receipt URL, to be used if the receipt is generated by the payment + * terminal or the CS + */ + public void setReceiptUrl(@Nullable String receiptUrl) { + if (!isValidReceiptUrl(receiptUrl)) { + throw new PropertyConstraintException(receiptUrl, "receiptUrl is invalid"); + } + this.receiptUrl = receiptUrl; + } + + /** + * Returns whether the given receiptUrl is valid + * + * @param receiptUrl the receiptUrl to check the validity of + * @return {@code true} if receiptUrl is valid, {@code false} if not + */ + private boolean isValidReceiptUrl(@Nullable String receiptUrl) { + return receiptUrl == null || receiptUrl.length() <= 2000; + } + + /** + * Adds the receipt URL, to be used if the receipt is generated by the payment terminal or the CS. + * + * @param receiptUrl The receipt URL, to be used if the receipt is generated by the payment + * terminal or the CS + * @return this + */ + public NotifySettlementRequest withReceiptUrl(@Nullable String receiptUrl) { + setReceiptUrl(receiptUrl); + return this; + } + + /** + * Gets a generic address format. + * + * @return A generic address format + */ + @Nullable + public Address getVatCompany() { + return vatCompany; + } + + /** + * Sets a generic address format. + * + * @param vatCompany A generic address format + */ + public void setVatCompany(@Nullable Address vatCompany) { + if (!isValidVatCompany(vatCompany)) { + throw new PropertyConstraintException(vatCompany, "vatCompany is invalid"); + } + this.vatCompany = vatCompany; + } + + /** + * Returns whether the given vatCompany is valid + * + * @param vatCompany the vatCompany to check the validity of + * @return {@code true} if vatCompany is valid, {@code false} if not + */ + private boolean isValidVatCompany(@Nullable Address vatCompany) { + return vatCompany == null || vatCompany.validate(); + } + + /** + * Adds a generic address format. + * + * @param vatCompany A generic address format + * @return this + */ + public NotifySettlementRequest withVatCompany(@Nullable Address vatCompany) { + setVatCompany(vatCompany); + return this; + } + + /** + * Gets VAT number for a company receipt. + * + * @return VAT number for a company receipt + */ + @Nullable + public String getVatNumber() { + return vatNumber; + } + + /** + * Sets VAT number for a company receipt. + * + * @param vatNumber VAT number for a company receipt + */ + public void setVatNumber(@Nullable String vatNumber) { + if (!isValidVatNumber(vatNumber)) { + throw new PropertyConstraintException(vatNumber, "vatNumber is invalid"); + } + this.vatNumber = vatNumber; + } + + /** + * Returns whether the given vatNumber is valid + * + * @param vatNumber the vatNumber to check the validity of + * @return {@code true} if vatNumber is valid, {@code false} if not + */ + private boolean isValidVatNumber(@Nullable String vatNumber) { + return vatNumber == null || vatNumber.length() <= 20; + } + + /** + * Adds VAT number for a company receipt. + * + * @param vatNumber VAT number for a company receipt + * @return this + */ + public NotifySettlementRequest withVatNumber(@Nullable String vatNumber) { + setVatNumber(vatNumber); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifySettlementRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTransactionId(transactionId) + && isValidPspRef(pspRef) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidSettlementAmount(settlementAmount) + && isValidSettlementTime(settlementTime) + && isValidReceiptId(receiptId) + && isValidReceiptUrl(receiptUrl) + && isValidVatCompany(vatCompany) + && isValidVatNumber(vatNumber) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifySettlementRequest that = (NotifySettlementRequest) o; + return Objects.equals(transactionId, that.transactionId) + && Objects.equals(pspRef, that.pspRef) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(settlementAmount, that.settlementAmount) + && Objects.equals(settlementTime, that.settlementTime) + && Objects.equals(receiptId, that.receiptId) + && Objects.equals(receiptUrl, that.receiptUrl) + && Objects.equals(vatCompany, that.vatCompany) + && Objects.equals(vatNumber, that.vatNumber) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + transactionId, + pspRef, + status, + statusInfo, + settlementAmount, + settlementTime, + receiptId, + receiptUrl, + vatCompany, + vatNumber, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("transactionId", transactionId) + .add("pspRef", pspRef) + .add("status", status) + .add("statusInfo", statusInfo) + .add("settlementAmount", settlementAmount) + .add("settlementTime", settlementTime) + .add("receiptId", receiptId) + .add("receiptUrl", receiptUrl) + .add("vatCompany", vatCompany) + .add("vatNumber", vatNumber) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifySettlementResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifySettlementResponse.java new file mode 100644 index 00000000..4322f896 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifySettlementResponse.java @@ -0,0 +1,223 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifySettlementResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifySettlementResponse extends Confirmation { + /** + * The receipt URL if receipt generated by CSMS. The Charging Station can QR encode it and show it + * to the EV Driver. + */ + @Nullable private String receiptUrl; + + /** The receipt id if the receipt is generated by CSMS. */ + @Nullable private String receiptId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifySettlementResponse class */ + public NotifySettlementResponse() {} + + /** + * Gets the receipt URL if receipt generated by CSMS. The Charging Station can QR encode it and + * show it to the EV Driver. + * + * @return The receipt URL if receipt generated by CSMS + */ + @Nullable + public String getReceiptUrl() { + return receiptUrl; + } + + /** + * Sets the receipt URL if receipt generated by CSMS. The Charging Station can QR encode it and + * show it to the EV Driver. + * + * @param receiptUrl The receipt URL if receipt generated by CSMS + */ + public void setReceiptUrl(@Nullable String receiptUrl) { + if (!isValidReceiptUrl(receiptUrl)) { + throw new PropertyConstraintException(receiptUrl, "receiptUrl is invalid"); + } + this.receiptUrl = receiptUrl; + } + + /** + * Returns whether the given receiptUrl is valid + * + * @param receiptUrl the receiptUrl to check the validity of + * @return {@code true} if receiptUrl is valid, {@code false} if not + */ + private boolean isValidReceiptUrl(@Nullable String receiptUrl) { + return receiptUrl == null || receiptUrl.length() <= 2000; + } + + /** + * Adds the receipt URL if receipt generated by CSMS. The Charging Station can QR encode it and + * show it to the EV Driver. + * + * @param receiptUrl The receipt URL if receipt generated by CSMS + * @return this + */ + public NotifySettlementResponse withReceiptUrl(@Nullable String receiptUrl) { + setReceiptUrl(receiptUrl); + return this; + } + + /** + * Gets the receipt id if the receipt is generated by CSMS. + * + * @return The receipt id if the receipt is generated by CSMS + */ + @Nullable + public String getReceiptId() { + return receiptId; + } + + /** + * Sets the receipt id if the receipt is generated by CSMS. + * + * @param receiptId The receipt id if the receipt is generated by CSMS + */ + public void setReceiptId(@Nullable String receiptId) { + if (!isValidReceiptId(receiptId)) { + throw new PropertyConstraintException(receiptId, "receiptId is invalid"); + } + this.receiptId = receiptId; + } + + /** + * Returns whether the given receiptId is valid + * + * @param receiptId the receiptId to check the validity of + * @return {@code true} if receiptId is valid, {@code false} if not + */ + private boolean isValidReceiptId(@Nullable String receiptId) { + return receiptId == null || receiptId.length() <= 50; + } + + /** + * Adds the receipt id if the receipt is generated by CSMS. + * + * @param receiptId The receipt id if the receipt is generated by CSMS + * @return this + */ + public NotifySettlementResponse withReceiptId(@Nullable String receiptId) { + setReceiptId(receiptId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifySettlementResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidReceiptUrl(receiptUrl) + && isValidReceiptId(receiptId) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifySettlementResponse that = (NotifySettlementResponse) o; + return Objects.equals(receiptUrl, that.receiptUrl) + && Objects.equals(receiptId, that.receiptId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(receiptUrl, receiptId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("receiptUrl", receiptUrl) + .add("receiptId", receiptId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyWebPaymentStartedRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyWebPaymentStartedRequest.java new file mode 100644 index 00000000..2be36781 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyWebPaymentStartedRequest.java @@ -0,0 +1,212 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyWebPaymentStartedRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyWebPaymentStartedRequest extends RequestWithId { + /** EVSE id for which transaction is requested. */ + private Integer evseId; + + /** + * Timeout value in seconds after which no result of web payment process (e.g. QR code scanning) + * is to be expected anymore. + */ + private Integer timeout; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NotifyWebPaymentStartedRequest class + * + * @param evseId EVSE id for which transaction is requested. + * @param timeout Timeout value in seconds after which no result of web payment process (e.g. QR + * code scanning) is to be expected anymore. + */ + public NotifyWebPaymentStartedRequest(Integer evseId, Integer timeout) { + setEvseId(evseId); + setTimeout(timeout); + } + + /** + * Gets EVSE id for which transaction is requested. + * + * @return EVSE id for which transaction is requested + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets EVSE id for which transaction is requested. + * + * @param evseId EVSE id for which transaction is requested + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets timeout value in seconds after which no result of web payment process (e.g. QR code + * scanning) is to be expected anymore. + * + * @return Timeout value in seconds after which no result of web payment process (e.g. QR code + * scanning) is to be expected anymore + */ + public Integer getTimeout() { + return timeout; + } + + /** + * Sets timeout value in seconds after which no result of web payment process (e.g. QR code + * scanning) is to be expected anymore. + * + * @param timeout Timeout value in seconds after which no result of web payment process (e.g. QR + * code scanning) is to be expected anymore + */ + public void setTimeout(Integer timeout) { + if (!isValidTimeout(timeout)) { + throw new PropertyConstraintException(timeout, "timeout is invalid"); + } + this.timeout = timeout; + } + + /** + * Returns whether the given timeout is valid + * + * @param timeout the timeout to check the validity of + * @return {@code true} if timeout is valid, {@code false} if not + */ + private boolean isValidTimeout(Integer timeout) { + return timeout != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyWebPaymentStartedRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvseId(evseId) && isValidTimeout(timeout) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyWebPaymentStartedRequest that = (NotifyWebPaymentStartedRequest) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(timeout, that.timeout) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, timeout, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("timeout", timeout) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyWebPaymentStartedResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyWebPaymentStartedResponse.java new file mode 100644 index 00000000..a264a934 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyWebPaymentStartedResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyWebPaymentStartedResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class NotifyWebPaymentStartedResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyWebPaymentStartedResponse class */ + public NotifyWebPaymentStartedResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyWebPaymentStartedResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyWebPaymentStartedResponse that = (NotifyWebPaymentStartedResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/OpenPeriodicEventStreamRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/OpenPeriodicEventStreamRequest.java new file mode 100644 index 00000000..c468b218 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/OpenPeriodicEventStreamRequest.java @@ -0,0 +1,167 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ConstantStreamData; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * OpenPeriodicEventStreamRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class OpenPeriodicEventStreamRequest extends RequestWithId { + /** constantStreamData */ + private ConstantStreamData constantStreamData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the OpenPeriodicEventStreamRequest class + * + * @param constantStreamData constantStreamData + */ + public OpenPeriodicEventStreamRequest(ConstantStreamData constantStreamData) { + setConstantStreamData(constantStreamData); + } + + /** + * Gets constantStreamData + * + * @return constantStreamData + */ + public ConstantStreamData getConstantStreamData() { + return constantStreamData; + } + + /** + * Sets constantStreamData + * + * @param constantStreamData constantStreamData + */ + public void setConstantStreamData(ConstantStreamData constantStreamData) { + if (!isValidConstantStreamData(constantStreamData)) { + throw new PropertyConstraintException(constantStreamData, "constantStreamData is invalid"); + } + this.constantStreamData = constantStreamData; + } + + /** + * Returns whether the given constantStreamData is valid + * + * @param constantStreamData the constantStreamData to check the validity of + * @return {@code true} if constantStreamData is valid, {@code false} if not + */ + private boolean isValidConstantStreamData(ConstantStreamData constantStreamData) { + return constantStreamData != null && constantStreamData.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public OpenPeriodicEventStreamRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidConstantStreamData(constantStreamData) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OpenPeriodicEventStreamRequest that = (OpenPeriodicEventStreamRequest) o; + return Objects.equals(constantStreamData, that.constantStreamData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(constantStreamData, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("constantStreamData", constantStreamData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/OpenPeriodicEventStreamResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/OpenPeriodicEventStreamResponse.java new file mode 100644 index 00000000..89d932a1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/OpenPeriodicEventStreamResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * OpenPeriodicEventStreamResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class OpenPeriodicEventStreamResponse extends Confirmation { + /** Result of request. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the OpenPeriodicEventStreamResponse class + * + * @param status Result of request. + */ + public OpenPeriodicEventStreamResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets result of request. + * + * @return Result of request + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets result of request. + * + * @param status Result of request + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public OpenPeriodicEventStreamResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public OpenPeriodicEventStreamResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OpenPeriodicEventStreamResponse that = (OpenPeriodicEventStreamResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareRequest.java new file mode 100644 index 00000000..f81b01db --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareRequest.java @@ -0,0 +1,365 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PublishFirmwareRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class PublishFirmwareRequest extends RequestWithId { + /** A string containing a URI pointing to a location from which to retrieve the firmware. */ + private String location; + + /** + * How many times Charging Station must retry to download the firmware before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + */ + @Nullable private Integer retries; + + /** The MD5 checksum over the entire firmware file as a hexadecimal string of length 32. */ + private String checksum; + + /** The Id of the request. */ + private Integer requestId; + + /** + * The interval in seconds after which a retry may be attempted. If this field is not present, it + * is left to Charging Station to decide how long to wait between attempts. + */ + @Nullable private Integer retryInterval; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PublishFirmwareRequest class + * + * @param location A string containing a URI pointing to a location from which to retrieve the + * firmware. + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32. + * @param requestId The Id of the request. + */ + public PublishFirmwareRequest(String location, String checksum, Integer requestId) { + setLocation(location); + setChecksum(checksum); + setRequestId(requestId); + } + + /** + * Gets a string containing a URI pointing to a location from which to retrieve the firmware. + * + * @return A string containing a URI pointing to a location from which to retrieve the firmware + */ + public String getLocation() { + return location; + } + + /** + * Sets a string containing a URI pointing to a location from which to retrieve the firmware. + * + * @param location A string containing a URI pointing to a location from which to retrieve the + * firmware + */ + public void setLocation(String location) { + if (!isValidLocation(location)) { + throw new PropertyConstraintException(location, "location is invalid"); + } + this.location = location; + } + + /** + * Returns whether the given location is valid + * + * @param location the location to check the validity of + * @return {@code true} if location is valid, {@code false} if not + */ + private boolean isValidLocation(String location) { + return location != null && location.length() <= 2000; + } + + /** + * Gets how many times Charging Station must retry to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @return How many times Charging Station must retry to download the firmware before giving up + */ + @Nullable + public Integer getRetries() { + return retries; + } + + /** + * Sets how many times Charging Station must retry to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @param retries How many times Charging Station must retry to download the firmware before + * giving up + */ + public void setRetries(@Nullable Integer retries) { + if (!isValidRetries(retries)) { + throw new PropertyConstraintException(retries, "retries is invalid"); + } + this.retries = retries; + } + + /** + * Returns whether the given retries is valid + * + * @param retries the retries to check the validity of + * @return {@code true} if retries is valid, {@code false} if not + */ + private boolean isValidRetries(@Nullable Integer retries) { + return retries == null || (retries >= 0); + } + + /** + * Adds how many times Charging Station must retry to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @param retries How many times Charging Station must retry to download the firmware before + * giving up + * @return this + */ + public PublishFirmwareRequest withRetries(@Nullable Integer retries) { + setRetries(retries); + return this; + } + + /** + * Gets the MD5 checksum over the entire firmware file as a hexadecimal string of length 32. + * + * @return The MD5 checksum over the entire firmware file as a hexadecimal string of length 32 + */ + public String getChecksum() { + return checksum; + } + + /** + * Sets the MD5 checksum over the entire firmware file as a hexadecimal string of length 32. + * + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32 + */ + public void setChecksum(String checksum) { + if (!isValidChecksum(checksum)) { + throw new PropertyConstraintException(checksum, "checksum is invalid"); + } + this.checksum = checksum; + } + + /** + * Returns whether the given checksum is valid + * + * @param checksum the checksum to check the validity of + * @return {@code true} if checksum is valid, {@code false} if not + */ + private boolean isValidChecksum(String checksum) { + return checksum != null && checksum.length() <= 32; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null && requestId >= 0; + } + + /** + * Gets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @return The interval in seconds after which a retry may be attempted + */ + @Nullable + public Integer getRetryInterval() { + return retryInterval; + } + + /** + * Sets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + */ + public void setRetryInterval(@Nullable Integer retryInterval) { + if (!isValidRetryInterval(retryInterval)) { + throw new PropertyConstraintException(retryInterval, "retryInterval is invalid"); + } + this.retryInterval = retryInterval; + } + + /** + * Returns whether the given retryInterval is valid + * + * @param retryInterval the retryInterval to check the validity of + * @return {@code true} if retryInterval is valid, {@code false} if not + */ + private boolean isValidRetryInterval(@Nullable Integer retryInterval) { + return retryInterval == null || (retryInterval >= 0); + } + + /** + * Adds the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + * @return this + */ + public PublishFirmwareRequest withRetryInterval(@Nullable Integer retryInterval) { + setRetryInterval(retryInterval); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PublishFirmwareRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidLocation(location) + && isValidRetries(retries) + && isValidChecksum(checksum) + && isValidRequestId(requestId) + && isValidRetryInterval(retryInterval) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PublishFirmwareRequest that = (PublishFirmwareRequest) o; + return Objects.equals(location, that.location) + && Objects.equals(retries, that.retries) + && Objects.equals(checksum, that.checksum) + && Objects.equals(requestId, that.requestId) + && Objects.equals(retryInterval, that.retryInterval) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(location, retries, checksum, requestId, retryInterval, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("location", location) + .add("retries", retries) + .add("checksum", checksum) + .add("requestId", requestId) + .add("retryInterval", retryInterval) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareResponse.java new file mode 100644 index 00000000..77f06bcc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PublishFirmwareResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class PublishFirmwareResponse extends Confirmation { + /** Whether the request was accepted. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PublishFirmwareResponse class + * + * @param status Whether the request was accepted. + */ + public PublishFirmwareResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the request was accepted. + * + * @return Whether the request was accepted + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the request was accepted. + * + * @param status Whether the request was accepted + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public PublishFirmwareResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PublishFirmwareResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PublishFirmwareResponse that = (PublishFirmwareResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareStatusNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareStatusNotificationRequest.java new file mode 100644 index 00000000..be642461 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareStatusNotificationRequest.java @@ -0,0 +1,331 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.PublishFirmwareStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PublishFirmwareStatusNotificationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class PublishFirmwareStatusNotificationRequest extends RequestWithId { + /** The progress status of the publishfirmware installation. */ + private PublishFirmwareStatusEnum status; + + /** + * Required if status is Published. Can be multiple URI’s, if the Local Controller supports e.g. + * HTTP, HTTPS, and FTP. + */ + @Nullable private String[] location; + + /** The request id that was provided in the PublishFirmwareRequest which triggered this action. */ + @Nullable private Integer requestId; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PublishFirmwareStatusNotificationRequest class + * + * @param status The progress status of the publishfirmware installation. + */ + public PublishFirmwareStatusNotificationRequest(PublishFirmwareStatusEnum status) { + setStatus(status); + } + + /** + * Gets the progress status of the publishfirmware installation. + * + * @return The progress status of the publishfirmware installation + */ + public PublishFirmwareStatusEnum getStatus() { + return status; + } + + /** + * Sets the progress status of the publishfirmware installation. + * + * @param status The progress status of the publishfirmware installation + */ + public void setStatus(PublishFirmwareStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(PublishFirmwareStatusEnum status) { + return status != null; + } + + /** + * Gets required if status is Published. Can be multiple URI’s, if the Local Controller supports + * e.g. HTTP, HTTPS, and FTP. + * + * @return Required if status is Published + */ + @Nullable + public String[] getLocation() { + return location; + } + + /** + * Sets required if status is Published. Can be multiple URI’s, if the Local Controller supports + * e.g. HTTP, HTTPS, and FTP. + * + * @param location Required if status is Published + */ + public void setLocation(@Nullable String[] location) { + if (!isValidLocation(location)) { + throw new PropertyConstraintException(location, "location is invalid"); + } + this.location = location; + } + + /** + * Returns whether the given location is valid + * + * @param location the location to check the validity of + * @return {@code true} if location is valid, {@code false} if not + */ + private boolean isValidLocation(@Nullable String[] location) { + return location == null + || (location.length >= 1 + && Arrays.stream(location).allMatch(item -> item.length() <= 2000)); + } + + /** + * Adds required if status is Published. Can be multiple URI’s, if the Local Controller supports + * e.g. HTTP, HTTPS, and FTP. + * + * @param location Required if status is Published + * @return this + */ + public PublishFirmwareStatusNotificationRequest withLocation(@Nullable String[] location) { + setLocation(location); + return this; + } + + /** + * Gets the request id that was provided in the PublishFirmwareRequest which triggered this + * action. + * + * @return The request id that was provided in the PublishFirmwareRequest which triggered this + * action + */ + @Nullable + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the request id that was provided in the PublishFirmwareRequest which triggered this + * action. + * + * @param requestId The request id that was provided in the PublishFirmwareRequest which triggered + * this action + */ + public void setRequestId(@Nullable Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(@Nullable Integer requestId) { + return requestId == null || (requestId >= 0); + } + + /** + * Adds the request id that was provided in the PublishFirmwareRequest which triggered this + * action. + * + * @param requestId The request id that was provided in the PublishFirmwareRequest which triggered + * this action + * @return this + */ + public PublishFirmwareStatusNotificationRequest withRequestId(@Nullable Integer requestId) { + setRequestId(requestId); + return this; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public PublishFirmwareStatusNotificationRequest withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PublishFirmwareStatusNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidLocation(location) + && isValidRequestId(requestId) + && isValidStatusInfo(statusInfo) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PublishFirmwareStatusNotificationRequest that = (PublishFirmwareStatusNotificationRequest) o; + return Objects.equals(status, that.status) + && Arrays.equals(location, that.location) + && Objects.equals(requestId, that.requestId) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, Arrays.hashCode(location), requestId, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("location", location) + .add("requestId", requestId) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareStatusNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareStatusNotificationResponse.java new file mode 100644 index 00000000..cb324079 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PublishFirmwareStatusNotificationResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PublishFirmwareStatusNotificationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class PublishFirmwareStatusNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the PublishFirmwareStatusNotificationResponse class */ + public PublishFirmwareStatusNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PublishFirmwareStatusNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PublishFirmwareStatusNotificationResponse that = (PublishFirmwareStatusNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PullDynamicScheduleUpdateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PullDynamicScheduleUpdateRequest.java new file mode 100644 index 00000000..28e2417c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PullDynamicScheduleUpdateRequest.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PullDynamicScheduleUpdateRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class PullDynamicScheduleUpdateRequest extends RequestWithId { + /** Id of charging profile to update. */ + private Integer chargingProfileId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PullDynamicScheduleUpdateRequest class + * + * @param chargingProfileId Id of charging profile to update. + */ + public PullDynamicScheduleUpdateRequest(Integer chargingProfileId) { + setChargingProfileId(chargingProfileId); + } + + /** + * Gets id of charging profile to update. + * + * @return Id of charging profile to update + */ + public Integer getChargingProfileId() { + return chargingProfileId; + } + + /** + * Sets id of charging profile to update. + * + * @param chargingProfileId Id of charging profile to update + */ + public void setChargingProfileId(Integer chargingProfileId) { + if (!isValidChargingProfileId(chargingProfileId)) { + throw new PropertyConstraintException(chargingProfileId, "chargingProfileId is invalid"); + } + this.chargingProfileId = chargingProfileId; + } + + /** + * Returns whether the given chargingProfileId is valid + * + * @param chargingProfileId the chargingProfileId to check the validity of + * @return {@code true} if chargingProfileId is valid, {@code false} if not + */ + private boolean isValidChargingProfileId(Integer chargingProfileId) { + return chargingProfileId != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PullDynamicScheduleUpdateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidChargingProfileId(chargingProfileId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PullDynamicScheduleUpdateRequest that = (PullDynamicScheduleUpdateRequest) o; + return Objects.equals(chargingProfileId, that.chargingProfileId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(chargingProfileId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingProfileId", chargingProfileId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PullDynamicScheduleUpdateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PullDynamicScheduleUpdateResponse.java new file mode 100644 index 00000000..b646fd52 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/PullDynamicScheduleUpdateResponse.java @@ -0,0 +1,264 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingProfileStatusEnum; +import eu.chargetime.ocpp.v21.model.types.ChargingScheduleUpdate; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PullDynamicScheduleUpdateResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class PullDynamicScheduleUpdateResponse extends Confirmation { + /** Updates to a ChargingSchedulePeriodType for dynamic charging profiles. */ + @Nullable private ChargingScheduleUpdate scheduleUpdate; + + /** Result of request. */ + private ChargingProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PullDynamicScheduleUpdateResponse class + * + * @param status Result of request. + */ + public PullDynamicScheduleUpdateResponse(ChargingProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets updates to a ChargingSchedulePeriodType for dynamic charging profiles. + * + * @return Updates to a ChargingSchedulePeriodType for dynamic charging profiles + */ + @Nullable + public ChargingScheduleUpdate getScheduleUpdate() { + return scheduleUpdate; + } + + /** + * Sets updates to a ChargingSchedulePeriodType for dynamic charging profiles. + * + * @param scheduleUpdate Updates to a ChargingSchedulePeriodType for dynamic charging profiles + */ + public void setScheduleUpdate(@Nullable ChargingScheduleUpdate scheduleUpdate) { + if (!isValidScheduleUpdate(scheduleUpdate)) { + throw new PropertyConstraintException(scheduleUpdate, "scheduleUpdate is invalid"); + } + this.scheduleUpdate = scheduleUpdate; + } + + /** + * Returns whether the given scheduleUpdate is valid + * + * @param scheduleUpdate the scheduleUpdate to check the validity of + * @return {@code true} if scheduleUpdate is valid, {@code false} if not + */ + private boolean isValidScheduleUpdate(@Nullable ChargingScheduleUpdate scheduleUpdate) { + return scheduleUpdate == null || scheduleUpdate.validate(); + } + + /** + * Adds updates to a ChargingSchedulePeriodType for dynamic charging profiles. + * + * @param scheduleUpdate Updates to a ChargingSchedulePeriodType for dynamic charging profiles + * @return this + */ + public PullDynamicScheduleUpdateResponse withScheduleUpdate( + @Nullable ChargingScheduleUpdate scheduleUpdate) { + setScheduleUpdate(scheduleUpdate); + return this; + } + + /** + * Gets result of request. + * + * @return Result of request + */ + public ChargingProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets result of request. + * + * @param status Result of request + */ + public void setStatus(ChargingProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ChargingProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public PullDynamicScheduleUpdateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PullDynamicScheduleUpdateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidScheduleUpdate(scheduleUpdate) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PullDynamicScheduleUpdateResponse that = (PullDynamicScheduleUpdateResponse) o; + return Objects.equals(scheduleUpdate, that.scheduleUpdate) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(scheduleUpdate, status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("scheduleUpdate", scheduleUpdate) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportChargingProfilesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportChargingProfilesRequest.java new file mode 100644 index 00000000..285f6e51 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportChargingProfilesRequest.java @@ -0,0 +1,372 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingProfile; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReportChargingProfilesRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ReportChargingProfilesRequest extends RequestWithId { + /** + * Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + */ + private Integer requestId; + + /** + * Source that has installed this charging profile. Values defined in Appendix as + * ChargingLimitSourceEnumStringType. + */ + private String chargingLimitSource; + + /** + * A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of ChargingSchedulePeriods, + * describing the amount of power or current that can be delivered per time interval. + * + *

image::images/ChargingProfile-Simple.png[] + */ + private ChargingProfile[] chargingProfile; + + /** + * To Be Continued. Default value when omitted: false. false indicates that there are no further + * messages as part of this report. + */ + @Nullable private Boolean tbc; + + /** + * The evse to which the charging profile applies. If evseId = 0, the message contains an overall + * limit for the Charging Station. + */ + private Integer evseId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ReportChargingProfilesRequest class + * + * @param requestId Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + * @param chargingLimitSource Source that has installed this charging profile. Values defined in + * Appendix as ChargingLimitSourceEnumStringType. + * @param chargingProfile A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval. + * @param evseId The evse to which the charging profile applies. If evseId = 0, the message + * contains an overall limit for the Charging Station. + */ + public ReportChargingProfilesRequest( + Integer requestId, + String chargingLimitSource, + ChargingProfile[] chargingProfile, + Integer evseId) { + setRequestId(requestId); + setChargingLimitSource(chargingLimitSource); + setChargingProfile(chargingProfile); + setEvseId(evseId); + } + + /** + * Gets id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + * + * @return Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + * + * @param requestId Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets source that has installed this charging profile. Values defined in Appendix as + * ChargingLimitSourceEnumStringType. + * + * @return Source that has installed this charging profile + */ + public String getChargingLimitSource() { + return chargingLimitSource; + } + + /** + * Sets source that has installed this charging profile. Values defined in Appendix as + * ChargingLimitSourceEnumStringType. + * + * @param chargingLimitSource Source that has installed this charging profile + */ + public void setChargingLimitSource(String chargingLimitSource) { + if (!isValidChargingLimitSource(chargingLimitSource)) { + throw new PropertyConstraintException(chargingLimitSource, "chargingLimitSource is invalid"); + } + this.chargingLimitSource = chargingLimitSource; + } + + /** + * Returns whether the given chargingLimitSource is valid + * + * @param chargingLimitSource the chargingLimitSource to check the validity of + * @return {@code true} if chargingLimitSource is valid, {@code false} if not + */ + private boolean isValidChargingLimitSource(String chargingLimitSource) { + return chargingLimitSource != null && chargingLimitSource.length() <= 20; + } + + /** + * Gets a ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered per + * time interval. + * + * @return A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval + */ + public ChargingProfile[] getChargingProfile() { + return chargingProfile; + } + + /** + * Sets a ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered per + * time interval. + * + * @param chargingProfile A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval + */ + public void setChargingProfile(ChargingProfile[] chargingProfile) { + if (!isValidChargingProfile(chargingProfile)) { + throw new PropertyConstraintException(chargingProfile, "chargingProfile is invalid"); + } + this.chargingProfile = chargingProfile; + } + + /** + * Returns whether the given chargingProfile is valid + * + * @param chargingProfile the chargingProfile to check the validity of + * @return {@code true} if chargingProfile is valid, {@code false} if not + */ + private boolean isValidChargingProfile(ChargingProfile[] chargingProfile) { + return chargingProfile != null + && chargingProfile.length >= 1 + && Arrays.stream(chargingProfile).allMatch(item -> item.validate()); + } + + /** + * Gets to Be Continued. Default value when omitted: false. false indicates that there are no + * further messages as part of this report. + * + * @return To Be Continued + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets to Be Continued. Default value when omitted: false. false indicates that there are no + * further messages as part of this report. + * + * @param tbc To Be Continued + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds to Be Continued. Default value when omitted: false. false indicates that there are no + * further messages as part of this report. + * + * @param tbc To Be Continued + * @return this + */ + public ReportChargingProfilesRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets the evse to which the charging profile applies. If evseId = 0, the message contains an + * overall limit for the Charging Station. + * + * @return The evse to which the charging profile applies + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the evse to which the charging profile applies. If evseId = 0, the message contains an + * overall limit for the Charging Station. + * + * @param evseId The evse to which the charging profile applies + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReportChargingProfilesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidRequestId(requestId) + && isValidChargingLimitSource(chargingLimitSource) + && isValidChargingProfile(chargingProfile) + && isValidEvseId(evseId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportChargingProfilesRequest that = (ReportChargingProfilesRequest) o; + return Objects.equals(requestId, that.requestId) + && Objects.equals(chargingLimitSource, that.chargingLimitSource) + && Arrays.equals(chargingProfile, that.chargingProfile) + && Objects.equals(tbc, that.tbc) + && Objects.equals(evseId, that.evseId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + requestId, chargingLimitSource, Arrays.hashCode(chargingProfile), tbc, evseId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("requestId", requestId) + .add("chargingLimitSource", chargingLimitSource) + .add("chargingProfile", chargingProfile) + .add("tbc", tbc) + .add("evseId", evseId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportChargingProfilesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportChargingProfilesResponse.java new file mode 100644 index 00000000..3787f977 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportChargingProfilesResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReportChargingProfilesResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ReportChargingProfilesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ReportChargingProfilesResponse class */ + public ReportChargingProfilesResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReportChargingProfilesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportChargingProfilesResponse that = (ReportChargingProfilesResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportDERControlRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportDERControlRequest.java new file mode 100644 index 00000000..620de62b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportDERControlRequest.java @@ -0,0 +1,642 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DERCurveGet; +import eu.chargetime.ocpp.v21.model.types.EnterServiceGet; +import eu.chargetime.ocpp.v21.model.types.FixedPFGet; +import eu.chargetime.ocpp.v21.model.types.FixedVarGet; +import eu.chargetime.ocpp.v21.model.types.FreqDroopGet; +import eu.chargetime.ocpp.v21.model.types.GradientGet; +import eu.chargetime.ocpp.v21.model.types.LimitMaxDischargeGet; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReportDERControlRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ReportDERControlRequest extends RequestWithId { + /** curve */ + @Nullable private DERCurveGet[] curve; + + /** enterService */ + @Nullable private EnterServiceGet[] enterService; + + /** fixedPFAbsorb */ + @Nullable private FixedPFGet[] fixedPFAbsorb; + + /** fixedPFInject */ + @Nullable private FixedPFGet[] fixedPFInject; + + /** fixedVar */ + @Nullable private FixedVarGet[] fixedVar; + + /** freqDroop */ + @Nullable private FreqDroopGet[] freqDroop; + + /** gradient */ + @Nullable private GradientGet[] gradient; + + /** limitMaxDischarge */ + @Nullable private LimitMaxDischargeGet[] limitMaxDischarge; + + /** RequestId from GetDERControlRequest. */ + private Integer requestId; + + /** + * To Be Continued. Default value when omitted: false. + * + *

False indicates that there are no further messages as part of this report. + */ + @Nullable private Boolean tbc; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ReportDERControlRequest class + * + * @param requestId RequestId from GetDERControlRequest. + */ + public ReportDERControlRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets curve + * + * @return curve + */ + @Nullable + public DERCurveGet[] getCurve() { + return curve; + } + + /** + * Sets curve + * + * @param curve curve + */ + public void setCurve(@Nullable DERCurveGet[] curve) { + if (!isValidCurve(curve)) { + throw new PropertyConstraintException(curve, "curve is invalid"); + } + this.curve = curve; + } + + /** + * Returns whether the given curve is valid + * + * @param curve the curve to check the validity of + * @return {@code true} if curve is valid, {@code false} if not + */ + private boolean isValidCurve(@Nullable DERCurveGet[] curve) { + return curve == null + || (curve.length >= 1 + && curve.length <= 24 + && Arrays.stream(curve).allMatch(item -> item.validate())); + } + + /** + * Adds curve + * + * @param curve curve + * @return this + */ + public ReportDERControlRequest withCurve(@Nullable DERCurveGet[] curve) { + setCurve(curve); + return this; + } + + /** + * Gets enterService + * + * @return enterService + */ + @Nullable + public EnterServiceGet[] getEnterService() { + return enterService; + } + + /** + * Sets enterService + * + * @param enterService enterService + */ + public void setEnterService(@Nullable EnterServiceGet[] enterService) { + if (!isValidEnterService(enterService)) { + throw new PropertyConstraintException(enterService, "enterService is invalid"); + } + this.enterService = enterService; + } + + /** + * Returns whether the given enterService is valid + * + * @param enterService the enterService to check the validity of + * @return {@code true} if enterService is valid, {@code false} if not + */ + private boolean isValidEnterService(@Nullable EnterServiceGet[] enterService) { + return enterService == null + || (enterService.length >= 1 + && enterService.length <= 24 + && Arrays.stream(enterService).allMatch(item -> item.validate())); + } + + /** + * Adds enterService + * + * @param enterService enterService + * @return this + */ + public ReportDERControlRequest withEnterService(@Nullable EnterServiceGet[] enterService) { + setEnterService(enterService); + return this; + } + + /** + * Gets fixedPFAbsorb + * + * @return fixedPFAbsorb + */ + @Nullable + public FixedPFGet[] getFixedPFAbsorb() { + return fixedPFAbsorb; + } + + /** + * Sets fixedPFAbsorb + * + * @param fixedPFAbsorb fixedPFAbsorb + */ + public void setFixedPFAbsorb(@Nullable FixedPFGet[] fixedPFAbsorb) { + if (!isValidFixedPFAbsorb(fixedPFAbsorb)) { + throw new PropertyConstraintException(fixedPFAbsorb, "fixedPFAbsorb is invalid"); + } + this.fixedPFAbsorb = fixedPFAbsorb; + } + + /** + * Returns whether the given fixedPFAbsorb is valid + * + * @param fixedPFAbsorb the fixedPFAbsorb to check the validity of + * @return {@code true} if fixedPFAbsorb is valid, {@code false} if not + */ + private boolean isValidFixedPFAbsorb(@Nullable FixedPFGet[] fixedPFAbsorb) { + return fixedPFAbsorb == null + || (fixedPFAbsorb.length >= 1 + && fixedPFAbsorb.length <= 24 + && Arrays.stream(fixedPFAbsorb).allMatch(item -> item.validate())); + } + + /** + * Adds fixedPFAbsorb + * + * @param fixedPFAbsorb fixedPFAbsorb + * @return this + */ + public ReportDERControlRequest withFixedPFAbsorb(@Nullable FixedPFGet[] fixedPFAbsorb) { + setFixedPFAbsorb(fixedPFAbsorb); + return this; + } + + /** + * Gets fixedPFInject + * + * @return fixedPFInject + */ + @Nullable + public FixedPFGet[] getFixedPFInject() { + return fixedPFInject; + } + + /** + * Sets fixedPFInject + * + * @param fixedPFInject fixedPFInject + */ + public void setFixedPFInject(@Nullable FixedPFGet[] fixedPFInject) { + if (!isValidFixedPFInject(fixedPFInject)) { + throw new PropertyConstraintException(fixedPFInject, "fixedPFInject is invalid"); + } + this.fixedPFInject = fixedPFInject; + } + + /** + * Returns whether the given fixedPFInject is valid + * + * @param fixedPFInject the fixedPFInject to check the validity of + * @return {@code true} if fixedPFInject is valid, {@code false} if not + */ + private boolean isValidFixedPFInject(@Nullable FixedPFGet[] fixedPFInject) { + return fixedPFInject == null + || (fixedPFInject.length >= 1 + && fixedPFInject.length <= 24 + && Arrays.stream(fixedPFInject).allMatch(item -> item.validate())); + } + + /** + * Adds fixedPFInject + * + * @param fixedPFInject fixedPFInject + * @return this + */ + public ReportDERControlRequest withFixedPFInject(@Nullable FixedPFGet[] fixedPFInject) { + setFixedPFInject(fixedPFInject); + return this; + } + + /** + * Gets fixedVar + * + * @return fixedVar + */ + @Nullable + public FixedVarGet[] getFixedVar() { + return fixedVar; + } + + /** + * Sets fixedVar + * + * @param fixedVar fixedVar + */ + public void setFixedVar(@Nullable FixedVarGet[] fixedVar) { + if (!isValidFixedVar(fixedVar)) { + throw new PropertyConstraintException(fixedVar, "fixedVar is invalid"); + } + this.fixedVar = fixedVar; + } + + /** + * Returns whether the given fixedVar is valid + * + * @param fixedVar the fixedVar to check the validity of + * @return {@code true} if fixedVar is valid, {@code false} if not + */ + private boolean isValidFixedVar(@Nullable FixedVarGet[] fixedVar) { + return fixedVar == null + || (fixedVar.length >= 1 + && fixedVar.length <= 24 + && Arrays.stream(fixedVar).allMatch(item -> item.validate())); + } + + /** + * Adds fixedVar + * + * @param fixedVar fixedVar + * @return this + */ + public ReportDERControlRequest withFixedVar(@Nullable FixedVarGet[] fixedVar) { + setFixedVar(fixedVar); + return this; + } + + /** + * Gets freqDroop + * + * @return freqDroop + */ + @Nullable + public FreqDroopGet[] getFreqDroop() { + return freqDroop; + } + + /** + * Sets freqDroop + * + * @param freqDroop freqDroop + */ + public void setFreqDroop(@Nullable FreqDroopGet[] freqDroop) { + if (!isValidFreqDroop(freqDroop)) { + throw new PropertyConstraintException(freqDroop, "freqDroop is invalid"); + } + this.freqDroop = freqDroop; + } + + /** + * Returns whether the given freqDroop is valid + * + * @param freqDroop the freqDroop to check the validity of + * @return {@code true} if freqDroop is valid, {@code false} if not + */ + private boolean isValidFreqDroop(@Nullable FreqDroopGet[] freqDroop) { + return freqDroop == null + || (freqDroop.length >= 1 + && freqDroop.length <= 24 + && Arrays.stream(freqDroop).allMatch(item -> item.validate())); + } + + /** + * Adds freqDroop + * + * @param freqDroop freqDroop + * @return this + */ + public ReportDERControlRequest withFreqDroop(@Nullable FreqDroopGet[] freqDroop) { + setFreqDroop(freqDroop); + return this; + } + + /** + * Gets gradient + * + * @return gradient + */ + @Nullable + public GradientGet[] getGradient() { + return gradient; + } + + /** + * Sets gradient + * + * @param gradient gradient + */ + public void setGradient(@Nullable GradientGet[] gradient) { + if (!isValidGradient(gradient)) { + throw new PropertyConstraintException(gradient, "gradient is invalid"); + } + this.gradient = gradient; + } + + /** + * Returns whether the given gradient is valid + * + * @param gradient the gradient to check the validity of + * @return {@code true} if gradient is valid, {@code false} if not + */ + private boolean isValidGradient(@Nullable GradientGet[] gradient) { + return gradient == null + || (gradient.length >= 1 + && gradient.length <= 24 + && Arrays.stream(gradient).allMatch(item -> item.validate())); + } + + /** + * Adds gradient + * + * @param gradient gradient + * @return this + */ + public ReportDERControlRequest withGradient(@Nullable GradientGet[] gradient) { + setGradient(gradient); + return this; + } + + /** + * Gets limitMaxDischarge + * + * @return limitMaxDischarge + */ + @Nullable + public LimitMaxDischargeGet[] getLimitMaxDischarge() { + return limitMaxDischarge; + } + + /** + * Sets limitMaxDischarge + * + * @param limitMaxDischarge limitMaxDischarge + */ + public void setLimitMaxDischarge(@Nullable LimitMaxDischargeGet[] limitMaxDischarge) { + if (!isValidLimitMaxDischarge(limitMaxDischarge)) { + throw new PropertyConstraintException(limitMaxDischarge, "limitMaxDischarge is invalid"); + } + this.limitMaxDischarge = limitMaxDischarge; + } + + /** + * Returns whether the given limitMaxDischarge is valid + * + * @param limitMaxDischarge the limitMaxDischarge to check the validity of + * @return {@code true} if limitMaxDischarge is valid, {@code false} if not + */ + private boolean isValidLimitMaxDischarge(@Nullable LimitMaxDischargeGet[] limitMaxDischarge) { + return limitMaxDischarge == null + || (limitMaxDischarge.length >= 1 + && limitMaxDischarge.length <= 24 + && Arrays.stream(limitMaxDischarge).allMatch(item -> item.validate())); + } + + /** + * Adds limitMaxDischarge + * + * @param limitMaxDischarge limitMaxDischarge + * @return this + */ + public ReportDERControlRequest withLimitMaxDischarge( + @Nullable LimitMaxDischargeGet[] limitMaxDischarge) { + setLimitMaxDischarge(limitMaxDischarge); + return this; + } + + /** + * Gets requestId from GetDERControlRequest. + * + * @return RequestId from GetDERControlRequest + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets requestId from GetDERControlRequest. + * + * @param requestId RequestId from GetDERControlRequest + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets to Be Continued. Default value when omitted: false. + * + * @return To Be Continued + */ + @Nullable + public Boolean getTbc() { + return tbc; + } + + /** + * Sets to Be Continued. Default value when omitted: false. + * + * @param tbc To Be Continued + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds to Be Continued. Default value when omitted: false. + * + * @param tbc To Be Continued + * @return this + */ + public ReportDERControlRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReportDERControlRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCurve(curve) + && isValidEnterService(enterService) + && isValidFixedPFAbsorb(fixedPFAbsorb) + && isValidFixedPFInject(fixedPFInject) + && isValidFixedVar(fixedVar) + && isValidFreqDroop(freqDroop) + && isValidGradient(gradient) + && isValidLimitMaxDischarge(limitMaxDischarge) + && isValidRequestId(requestId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportDERControlRequest that = (ReportDERControlRequest) o; + return Arrays.equals(curve, that.curve) + && Arrays.equals(enterService, that.enterService) + && Arrays.equals(fixedPFAbsorb, that.fixedPFAbsorb) + && Arrays.equals(fixedPFInject, that.fixedPFInject) + && Arrays.equals(fixedVar, that.fixedVar) + && Arrays.equals(freqDroop, that.freqDroop) + && Arrays.equals(gradient, that.gradient) + && Arrays.equals(limitMaxDischarge, that.limitMaxDischarge) + && Objects.equals(requestId, that.requestId) + && Objects.equals(tbc, that.tbc) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(curve), + Arrays.hashCode(enterService), + Arrays.hashCode(fixedPFAbsorb), + Arrays.hashCode(fixedPFInject), + Arrays.hashCode(fixedVar), + Arrays.hashCode(freqDroop), + Arrays.hashCode(gradient), + Arrays.hashCode(limitMaxDischarge), + requestId, + tbc, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("curve", curve) + .add("enterService", enterService) + .add("fixedPFAbsorb", fixedPFAbsorb) + .add("fixedPFInject", fixedPFInject) + .add("fixedVar", fixedVar) + .add("freqDroop", freqDroop) + .add("gradient", gradient) + .add("limitMaxDischarge", limitMaxDischarge) + .add("requestId", requestId) + .add("tbc", tbc) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportDERControlResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportDERControlResponse.java new file mode 100644 index 00000000..83d05fca --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReportDERControlResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * This message has no parameters. + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ReportDERControlResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ReportDERControlResponse class */ + public ReportDERControlResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReportDERControlResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportDERControlResponse that = (ReportDERControlResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestBatterySwapRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestBatterySwapRequest.java new file mode 100644 index 00000000..2e622d41 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestBatterySwapRequest.java @@ -0,0 +1,213 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.IdToken; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestBatterySwapRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class RequestBatterySwapRequest extends RequestWithId { + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** Request id to match with BatterySwapRequest. */ + private Integer requestId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the RequestBatterySwapRequest class + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @param requestId Request id to match with BatterySwapRequest. + */ + public RequestBatterySwapRequest(IdToken idToken, Integer requestId) { + setIdToken(idToken); + setRequestId(requestId); + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets request id to match with BatterySwapRequest. + * + * @return Request id to match with BatterySwapRequest + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets request id to match with BatterySwapRequest. + * + * @param requestId Request id to match with BatterySwapRequest + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestBatterySwapRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidIdToken(idToken) && isValidRequestId(requestId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestBatterySwapRequest that = (RequestBatterySwapRequest) o; + return Objects.equals(idToken, that.idToken) + && Objects.equals(requestId, that.requestId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(idToken, requestId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("idToken", idToken) + .add("requestId", requestId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestBatterySwapResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestBatterySwapResponse.java new file mode 100644 index 00000000..fc304992 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestBatterySwapResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestBatterySwapResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class RequestBatterySwapResponse extends Confirmation { + /** Accepted or rejected the request. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the RequestBatterySwapResponse class + * + * @param status Accepted or rejected the request. + */ + public RequestBatterySwapResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets accepted or rejected the request. + * + * @return Accepted or rejected the request + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets accepted or rejected the request. + * + * @param status Accepted or rejected the request + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public RequestBatterySwapResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestBatterySwapResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestBatterySwapResponse that = (RequestBatterySwapResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStartTransactionRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStartTransactionRequest.java new file mode 100644 index 00000000..d96beec5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStartTransactionRequest.java @@ -0,0 +1,400 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingProfile; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.IdToken; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestStartTransactionRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class RequestStartTransactionRequest extends RequestWithId { + /** Number of the EVSE on which to start the transaction. EvseId SHALL be greater than 0 */ + @Nullable private Integer evseId; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken groupIdToken; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** + * Id given by the server to this start request. The Charging Station will return this in the + * TransactionEventRequest, letting the server know which transaction was started for this + * request. Use to start a transaction. + */ + private Integer remoteStartId; + + /** + * A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of ChargingSchedulePeriods, + * describing the amount of power or current that can be delivered per time interval. + * + *

image::images/ChargingProfile-Simple.png[] + */ + @Nullable private ChargingProfile chargingProfile; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the RequestStartTransactionRequest class + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @param remoteStartId Id given by the server to this start request. The Charging Station will + * return this in the TransactionEventRequest, letting the server know which transaction was + * started for this request. Use to start a transaction. + */ + public RequestStartTransactionRequest(IdToken idToken, Integer remoteStartId) { + setIdToken(idToken); + setRemoteStartId(remoteStartId); + } + + /** + * Gets number of the EVSE on which to start the transaction. EvseId SHALL be greater than 0 + * + * @return Number of the EVSE on which to start the transaction + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets number of the EVSE on which to start the transaction. EvseId SHALL be greater than 0 + * + * @param evseId Number of the EVSE on which to start the transaction + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 1); + } + + /** + * Adds number of the EVSE on which to start the transaction. EvseId SHALL be greater than 0 + * + * @param evseId Number of the EVSE on which to start the transaction + * @return this + */ + public RequestStartTransactionRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getGroupIdToken() { + return groupIdToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setGroupIdToken(@Nullable IdToken groupIdToken) { + if (!isValidGroupIdToken(groupIdToken)) { + throw new PropertyConstraintException(groupIdToken, "groupIdToken is invalid"); + } + this.groupIdToken = groupIdToken; + } + + /** + * Returns whether the given groupIdToken is valid + * + * @param groupIdToken the groupIdToken to check the validity of + * @return {@code true} if groupIdToken is valid, {@code false} if not + */ + private boolean isValidGroupIdToken(@Nullable IdToken groupIdToken) { + return groupIdToken == null || groupIdToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public RequestStartTransactionRequest withGroupIdToken(@Nullable IdToken groupIdToken) { + setGroupIdToken(groupIdToken); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets id given by the server to this start request. The Charging Station will return this in the + * TransactionEventRequest, letting the server know which transaction was started for this + * request. Use to start a transaction. + * + * @return Id given by the server to this start request + */ + public Integer getRemoteStartId() { + return remoteStartId; + } + + /** + * Sets id given by the server to this start request. The Charging Station will return this in the + * TransactionEventRequest, letting the server know which transaction was started for this + * request. Use to start a transaction. + * + * @param remoteStartId Id given by the server to this start request + */ + public void setRemoteStartId(Integer remoteStartId) { + if (!isValidRemoteStartId(remoteStartId)) { + throw new PropertyConstraintException(remoteStartId, "remoteStartId is invalid"); + } + this.remoteStartId = remoteStartId; + } + + /** + * Returns whether the given remoteStartId is valid + * + * @param remoteStartId the remoteStartId to check the validity of + * @return {@code true} if remoteStartId is valid, {@code false} if not + */ + private boolean isValidRemoteStartId(Integer remoteStartId) { + return remoteStartId != null; + } + + /** + * Gets a ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered per + * time interval. + * + * @return A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval + */ + @Nullable + public ChargingProfile getChargingProfile() { + return chargingProfile; + } + + /** + * Sets a ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered per + * time interval. + * + * @param chargingProfile A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval + */ + public void setChargingProfile(@Nullable ChargingProfile chargingProfile) { + if (!isValidChargingProfile(chargingProfile)) { + throw new PropertyConstraintException(chargingProfile, "chargingProfile is invalid"); + } + this.chargingProfile = chargingProfile; + } + + /** + * Returns whether the given chargingProfile is valid + * + * @param chargingProfile the chargingProfile to check the validity of + * @return {@code true} if chargingProfile is valid, {@code false} if not + */ + private boolean isValidChargingProfile(@Nullable ChargingProfile chargingProfile) { + return chargingProfile == null || chargingProfile.validate(); + } + + /** + * Adds a ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered per + * time interval. + * + * @param chargingProfile A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval + * @return this + */ + public RequestStartTransactionRequest withChargingProfile( + @Nullable ChargingProfile chargingProfile) { + setChargingProfile(chargingProfile); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestStartTransactionRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvseId(evseId) + && isValidGroupIdToken(groupIdToken) + && isValidIdToken(idToken) + && isValidRemoteStartId(remoteStartId) + && isValidChargingProfile(chargingProfile) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestStartTransactionRequest that = (RequestStartTransactionRequest) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(groupIdToken, that.groupIdToken) + && Objects.equals(idToken, that.idToken) + && Objects.equals(remoteStartId, that.remoteStartId) + && Objects.equals(chargingProfile, that.chargingProfile) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, groupIdToken, idToken, remoteStartId, chargingProfile, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("groupIdToken", groupIdToken) + .add("idToken", idToken) + .add("remoteStartId", remoteStartId) + .add("chargingProfile", chargingProfile) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStartTransactionResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStartTransactionResponse.java new file mode 100644 index 00000000..87c6ebe4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStartTransactionResponse.java @@ -0,0 +1,278 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.RequestStartStopStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestStartTransactionResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class RequestStartTransactionResponse extends Confirmation { + /** Status indicating whether the Charging Station accepts the request to start a transaction. */ + private RequestStartStopStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * When the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first. This contains + * the transactionId of the already started transaction. + */ + @Nullable private String transactionId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the RequestStartTransactionResponse class + * + * @param status Status indicating whether the Charging Station accepts the request to start a + * transaction. + */ + public RequestStartTransactionResponse(RequestStartStopStatusEnum status) { + setStatus(status); + } + + /** + * Gets status indicating whether the Charging Station accepts the request to start a transaction. + * + * @return Status indicating whether the Charging Station accepts the request to start a + * transaction + */ + public RequestStartStopStatusEnum getStatus() { + return status; + } + + /** + * Sets status indicating whether the Charging Station accepts the request to start a transaction. + * + * @param status Status indicating whether the Charging Station accepts the request to start a + * transaction + */ + public void setStatus(RequestStartStopStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(RequestStartStopStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public RequestStartTransactionResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets when the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first. This contains + * the transactionId of the already started transaction. + * + * @return When the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets when the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first. This contains + * the transactionId of the already started transaction. + * + * @param transactionId When the transaction was already started by the Charging Station before + * the RequestStartTransactionRequest was received, for example: cable plugged in first + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds when the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first. This contains + * the transactionId of the already started transaction. + * + * @param transactionId When the transaction was already started by the Charging Station before + * the RequestStartTransactionRequest was received, for example: cable plugged in first + * @return this + */ + public RequestStartTransactionResponse withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestStartTransactionResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidTransactionId(transactionId) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestStartTransactionResponse that = (RequestStartTransactionResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, transactionId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("transactionId", transactionId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStopTransactionRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStopTransactionRequest.java new file mode 100644 index 00000000..ab2d6efe --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStopTransactionRequest.java @@ -0,0 +1,168 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestStopTransactionRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class RequestStopTransactionRequest extends RequestWithId { + /** The identifier of the transaction which the Charging Station is requested to stop. */ + private String transactionId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the RequestStopTransactionRequest class + * + * @param transactionId The identifier of the transaction which the Charging Station is requested + * to stop. + */ + public RequestStopTransactionRequest(String transactionId) { + setTransactionId(transactionId); + } + + /** + * Gets the identifier of the transaction which the Charging Station is requested to stop. + * + * @return The identifier of the transaction which the Charging Station is requested to stop + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the identifier of the transaction which the Charging Station is requested to stop. + * + * @param transactionId The identifier of the transaction which the Charging Station is requested + * to stop + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestStopTransactionRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTransactionId(transactionId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestStopTransactionRequest that = (RequestStopTransactionRequest) o; + return Objects.equals(transactionId, that.transactionId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(transactionId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("transactionId", transactionId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStopTransactionResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStopTransactionResponse.java new file mode 100644 index 00000000..7f0ddb30 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/RequestStopTransactionResponse.java @@ -0,0 +1,213 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.RequestStartStopStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestStopTransactionResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class RequestStopTransactionResponse extends Confirmation { + /** Status indicating whether Charging Station accepts the request to stop a transaction. */ + private RequestStartStopStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the RequestStopTransactionResponse class + * + * @param status Status indicating whether Charging Station accepts the request to stop a + * transaction. + */ + public RequestStopTransactionResponse(RequestStartStopStatusEnum status) { + setStatus(status); + } + + /** + * Gets status indicating whether Charging Station accepts the request to stop a transaction. + * + * @return Status indicating whether Charging Station accepts the request to stop a transaction + */ + public RequestStartStopStatusEnum getStatus() { + return status; + } + + /** + * Sets status indicating whether Charging Station accepts the request to stop a transaction. + * + * @param status Status indicating whether Charging Station accepts the request to stop a + * transaction + */ + public void setStatus(RequestStartStopStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(RequestStartStopStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public RequestStopTransactionResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestStopTransactionResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestStopTransactionResponse that = (RequestStopTransactionResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReservationStatusUpdateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReservationStatusUpdateRequest.java new file mode 100644 index 00000000..98a95ff0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReservationStatusUpdateRequest.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.ReservationUpdateStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReservationStatusUpdateRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ReservationStatusUpdateRequest extends RequestWithId { + /** The ID of the reservation. */ + private Integer reservationId; + + /** The updated reservation status. */ + private ReservationUpdateStatusEnum reservationUpdateStatus; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ReservationStatusUpdateRequest class + * + * @param reservationId The ID of the reservation. + * @param reservationUpdateStatus The updated reservation status. + */ + public ReservationStatusUpdateRequest( + Integer reservationId, ReservationUpdateStatusEnum reservationUpdateStatus) { + setReservationId(reservationId); + setReservationUpdateStatus(reservationUpdateStatus); + } + + /** + * Gets the ID of the reservation. + * + * @return The ID of the reservation + */ + public Integer getReservationId() { + return reservationId; + } + + /** + * Sets the ID of the reservation. + * + * @param reservationId The ID of the reservation + */ + public void setReservationId(Integer reservationId) { + if (!isValidReservationId(reservationId)) { + throw new PropertyConstraintException(reservationId, "reservationId is invalid"); + } + this.reservationId = reservationId; + } + + /** + * Returns whether the given reservationId is valid + * + * @param reservationId the reservationId to check the validity of + * @return {@code true} if reservationId is valid, {@code false} if not + */ + private boolean isValidReservationId(Integer reservationId) { + return reservationId != null && reservationId >= 0; + } + + /** + * Gets the updated reservation status. + * + * @return The updated reservation status + */ + public ReservationUpdateStatusEnum getReservationUpdateStatus() { + return reservationUpdateStatus; + } + + /** + * Sets the updated reservation status. + * + * @param reservationUpdateStatus The updated reservation status + */ + public void setReservationUpdateStatus(ReservationUpdateStatusEnum reservationUpdateStatus) { + if (!isValidReservationUpdateStatus(reservationUpdateStatus)) { + throw new PropertyConstraintException( + reservationUpdateStatus, "reservationUpdateStatus is invalid"); + } + this.reservationUpdateStatus = reservationUpdateStatus; + } + + /** + * Returns whether the given reservationUpdateStatus is valid + * + * @param reservationUpdateStatus the reservationUpdateStatus to check the validity of + * @return {@code true} if reservationUpdateStatus is valid, {@code false} if not + */ + private boolean isValidReservationUpdateStatus( + ReservationUpdateStatusEnum reservationUpdateStatus) { + return reservationUpdateStatus != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReservationStatusUpdateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidReservationId(reservationId) + && isValidReservationUpdateStatus(reservationUpdateStatus) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReservationStatusUpdateRequest that = (ReservationStatusUpdateRequest) o; + return Objects.equals(reservationId, that.reservationId) + && Objects.equals(reservationUpdateStatus, that.reservationUpdateStatus) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(reservationId, reservationUpdateStatus, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("reservationId", reservationId) + .add("reservationUpdateStatus", reservationUpdateStatus) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReservationStatusUpdateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReservationStatusUpdateResponse.java new file mode 100644 index 00000000..bf419311 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReservationStatusUpdateResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReservationStatusUpdateResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ReservationStatusUpdateResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ReservationStatusUpdateResponse class */ + public ReservationStatusUpdateResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReservationStatusUpdateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReservationStatusUpdateResponse that = (ReservationStatusUpdateResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReserveNowRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReserveNowRequest.java new file mode 100644 index 00000000..d5c45e04 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReserveNowRequest.java @@ -0,0 +1,412 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.IdToken; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReserveNowRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ReserveNowRequest extends RequestWithId { + /** Id of reservation. */ + private Integer id; + + /** Date and time at which the reservation expires. */ + private ZonedDateTime expiryDateTime; + + /** The connector type. Values defined in Appendix as ConnectorEnumStringType. */ + @Nullable private String connectorType; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** ID of the evse to be reserved. */ + @Nullable private Integer evseId; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken groupIdToken; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ReserveNowRequest class + * + * @param id Id of reservation. + * @param expiryDateTime Date and time at which the reservation expires. + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + */ + public ReserveNowRequest(Integer id, ZonedDateTime expiryDateTime, IdToken idToken) { + setId(id); + setExpiryDateTime(expiryDateTime); + setIdToken(idToken); + } + + /** + * Gets id of reservation. + * + * @return Id of reservation + */ + public Integer getId() { + return id; + } + + /** + * Sets id of reservation. + * + * @param id Id of reservation + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets date and time at which the reservation expires. + * + * @return Date and time at which the reservation expires + */ + public ZonedDateTime getExpiryDateTime() { + return expiryDateTime; + } + + /** + * Sets date and time at which the reservation expires. + * + * @param expiryDateTime Date and time at which the reservation expires + */ + public void setExpiryDateTime(ZonedDateTime expiryDateTime) { + if (!isValidExpiryDateTime(expiryDateTime)) { + throw new PropertyConstraintException(expiryDateTime, "expiryDateTime is invalid"); + } + this.expiryDateTime = expiryDateTime; + } + + /** + * Returns whether the given expiryDateTime is valid + * + * @param expiryDateTime the expiryDateTime to check the validity of + * @return {@code true} if expiryDateTime is valid, {@code false} if not + */ + private boolean isValidExpiryDateTime(ZonedDateTime expiryDateTime) { + return expiryDateTime != null; + } + + /** + * Gets the connector type. Values defined in Appendix as ConnectorEnumStringType. + * + * @return The connector type + */ + @Nullable + public String getConnectorType() { + return connectorType; + } + + /** + * Sets the connector type. Values defined in Appendix as ConnectorEnumStringType. + * + * @param connectorType The connector type + */ + public void setConnectorType(@Nullable String connectorType) { + if (!isValidConnectorType(connectorType)) { + throw new PropertyConstraintException(connectorType, "connectorType is invalid"); + } + this.connectorType = connectorType; + } + + /** + * Returns whether the given connectorType is valid + * + * @param connectorType the connectorType to check the validity of + * @return {@code true} if connectorType is valid, {@code false} if not + */ + private boolean isValidConnectorType(@Nullable String connectorType) { + return connectorType == null || connectorType.length() <= 20; + } + + /** + * Adds the connector type. Values defined in Appendix as ConnectorEnumStringType. + * + * @param connectorType The connector type + * @return this + */ + public ReserveNowRequest withConnectorType(@Nullable String connectorType) { + setConnectorType(connectorType); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets ID of the evse to be reserved. + * + * @return ID of the evse to be reserved + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets ID of the evse to be reserved. + * + * @param evseId ID of the evse to be reserved + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds ID of the evse to be reserved. + * + * @param evseId ID of the evse to be reserved + * @return this + */ + public ReserveNowRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getGroupIdToken() { + return groupIdToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setGroupIdToken(@Nullable IdToken groupIdToken) { + if (!isValidGroupIdToken(groupIdToken)) { + throw new PropertyConstraintException(groupIdToken, "groupIdToken is invalid"); + } + this.groupIdToken = groupIdToken; + } + + /** + * Returns whether the given groupIdToken is valid + * + * @param groupIdToken the groupIdToken to check the validity of + * @return {@code true} if groupIdToken is valid, {@code false} if not + */ + private boolean isValidGroupIdToken(@Nullable IdToken groupIdToken) { + return groupIdToken == null || groupIdToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public ReserveNowRequest withGroupIdToken(@Nullable IdToken groupIdToken) { + setGroupIdToken(groupIdToken); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReserveNowRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidId(id) + && isValidExpiryDateTime(expiryDateTime) + && isValidConnectorType(connectorType) + && isValidIdToken(idToken) + && isValidEvseId(evseId) + && isValidGroupIdToken(groupIdToken) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReserveNowRequest that = (ReserveNowRequest) o; + return Objects.equals(id, that.id) + && Objects.equals(expiryDateTime, that.expiryDateTime) + && Objects.equals(connectorType, that.connectorType) + && Objects.equals(idToken, that.idToken) + && Objects.equals(evseId, that.evseId) + && Objects.equals(groupIdToken, that.groupIdToken) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + id, expiryDateTime, connectorType, idToken, evseId, groupIdToken, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("expiryDateTime", expiryDateTime) + .add("connectorType", connectorType) + .add("idToken", idToken) + .add("evseId", evseId) + .add("groupIdToken", groupIdToken) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReserveNowResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReserveNowResponse.java new file mode 100644 index 00000000..3e4d4ea4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ReserveNowResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.ReserveNowStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReserveNowResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ReserveNowResponse extends Confirmation { + /** The success or failure of the reservation. */ + private ReserveNowStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ReserveNowResponse class + * + * @param status The success or failure of the reservation. + */ + public ReserveNowResponse(ReserveNowStatusEnum status) { + setStatus(status); + } + + /** + * Gets the success or failure of the reservation. + * + * @return The success or failure of the reservation + */ + public ReserveNowStatusEnum getStatus() { + return status; + } + + /** + * Sets the success or failure of the reservation. + * + * @param status The success or failure of the reservation + */ + public void setStatus(ReserveNowStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ReserveNowStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ReserveNowResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReserveNowResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReserveNowResponse that = (ReserveNowResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ResetRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ResetRequest.java new file mode 100644 index 00000000..1d305dc8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ResetRequest.java @@ -0,0 +1,218 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.ResetEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ResetRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ResetRequest extends RequestWithId { + /** The type of reset that the Charging Station or EVSE should perform. */ + private ResetEnum type; + + /** The ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. */ + @Nullable private Integer evseId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ResetRequest class + * + * @param type The type of reset that the Charging Station or EVSE should perform. + */ + public ResetRequest(ResetEnum type) { + setType(type); + } + + /** + * Gets the type of reset that the Charging Station or EVSE should perform. + * + * @return The type of reset that the Charging Station or EVSE should perform + */ + public ResetEnum getType() { + return type; + } + + /** + * Sets the type of reset that the Charging Station or EVSE should perform. + * + * @param type The type of reset that the Charging Station or EVSE should perform + */ + public void setType(ResetEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(ResetEnum type) { + return type != null; + } + + /** + * Gets the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. + * + * @return The ID of a specific EVSE that needs to be reset, instead of the entire Charging + * Station + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. + * + * @param evseId The ID of a specific EVSE that needs to be reset, instead of the entire Charging + * Station + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. + * + * @param evseId The ID of a specific EVSE that needs to be reset, instead of the entire Charging + * Station + * @return this + */ + public ResetRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ResetRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidType(type) && isValidEvseId(evseId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResetRequest that = (ResetRequest) o; + return Objects.equals(type, that.type) + && Objects.equals(evseId, that.evseId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(type, evseId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("type", type) + .add("evseId", evseId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ResetResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ResetResponse.java new file mode 100644 index 00000000..29ac9a9c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/ResetResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.ResetStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ResetResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class ResetResponse extends Confirmation { + /** Whether the Charging Station is able to perform the reset. */ + private ResetStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ResetResponse class + * + * @param status Whether the Charging Station is able to perform the reset. + */ + public ResetResponse(ResetStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station is able to perform the reset. + * + * @return Whether the Charging Station is able to perform the reset + */ + public ResetStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to perform the reset. + * + * @param status Whether the Charging Station is able to perform the reset + */ + public void setStatus(ResetStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ResetStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ResetResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ResetResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResetResponse that = (ResetResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SecurityEventNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SecurityEventNotificationRequest.java new file mode 100644 index 00000000..f9786a0d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SecurityEventNotificationRequest.java @@ -0,0 +1,257 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SecurityEventNotificationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SecurityEventNotificationRequest extends RequestWithId { + /** Type of the security event. This value should be taken from the Security events list. */ + private String type; + + /** Date and time at which the event occurred. */ + private ZonedDateTime timestamp; + + /** Additional information about the occurred security event. */ + @Nullable private String techInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SecurityEventNotificationRequest class + * + * @param type Type of the security event. This value should be taken from the Security events + * list. + * @param timestamp Date and time at which the event occurred. + */ + public SecurityEventNotificationRequest(String type, ZonedDateTime timestamp) { + setType(type); + setTimestamp(timestamp); + } + + /** + * Gets type of the security event. This value should be taken from the Security events list. + * + * @return Type of the security event + */ + public String getType() { + return type; + } + + /** + * Sets type of the security event. This value should be taken from the Security events list. + * + * @param type Type of the security event + */ + public void setType(String type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(String type) { + return type != null && type.length() <= 50; + } + + /** + * Gets date and time at which the event occurred. + * + * @return Date and time at which the event occurred + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets date and time at which the event occurred. + * + * @param timestamp Date and time at which the event occurred + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets additional information about the occurred security event. + * + * @return Additional information about the occurred security event + */ + @Nullable + public String getTechInfo() { + return techInfo; + } + + /** + * Sets additional information about the occurred security event. + * + * @param techInfo Additional information about the occurred security event + */ + public void setTechInfo(@Nullable String techInfo) { + if (!isValidTechInfo(techInfo)) { + throw new PropertyConstraintException(techInfo, "techInfo is invalid"); + } + this.techInfo = techInfo; + } + + /** + * Returns whether the given techInfo is valid + * + * @param techInfo the techInfo to check the validity of + * @return {@code true} if techInfo is valid, {@code false} if not + */ + private boolean isValidTechInfo(@Nullable String techInfo) { + return techInfo == null || techInfo.length() <= 255; + } + + /** + * Adds additional information about the occurred security event. + * + * @param techInfo Additional information about the occurred security event + * @return this + */ + public SecurityEventNotificationRequest withTechInfo(@Nullable String techInfo) { + setTechInfo(techInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SecurityEventNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidType(type) + && isValidTimestamp(timestamp) + && isValidTechInfo(techInfo) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityEventNotificationRequest that = (SecurityEventNotificationRequest) o; + return Objects.equals(type, that.type) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(techInfo, that.techInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(type, timestamp, techInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("type", type) + .add("timestamp", timestamp) + .add("techInfo", techInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SecurityEventNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SecurityEventNotificationResponse.java new file mode 100644 index 00000000..fc5850b5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SecurityEventNotificationResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SecurityEventNotificationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SecurityEventNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the SecurityEventNotificationResponse class */ + public SecurityEventNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SecurityEventNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityEventNotificationResponse that = (SecurityEventNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SendLocalListRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SendLocalListRequest.java new file mode 100644 index 00000000..6679cf64 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SendLocalListRequest.java @@ -0,0 +1,271 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.AuthorizationData; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.UpdateEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SendLocalListRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SendLocalListRequest extends RequestWithId { + /** The identifier to use for authorization. */ + @Nullable private AuthorizationData[] localAuthorizationList; + + /** + * In case of a full update this is the version number of the full list. In case of a differential + * update it is the version number of the list after the update has been applied. + */ + private Integer versionNumber; + + /** The type of update (full or differential) of this request. */ + private UpdateEnum updateType; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SendLocalListRequest class + * + * @param versionNumber In case of a full update this is the version number of the full list. In + * case of a differential update it is the version number of the list after the update has + * been applied. + * @param updateType The type of update (full or differential) of this request. + */ + public SendLocalListRequest(Integer versionNumber, UpdateEnum updateType) { + setVersionNumber(versionNumber); + setUpdateType(updateType); + } + + /** + * Gets the identifier to use for authorization. + * + * @return The identifier to use for authorization + */ + @Nullable + public AuthorizationData[] getLocalAuthorizationList() { + return localAuthorizationList; + } + + /** + * Sets the identifier to use for authorization. + * + * @param localAuthorizationList The identifier to use for authorization + */ + public void setLocalAuthorizationList(@Nullable AuthorizationData[] localAuthorizationList) { + if (!isValidLocalAuthorizationList(localAuthorizationList)) { + throw new PropertyConstraintException( + localAuthorizationList, "localAuthorizationList is invalid"); + } + this.localAuthorizationList = localAuthorizationList; + } + + /** + * Returns whether the given localAuthorizationList is valid + * + * @param localAuthorizationList the localAuthorizationList to check the validity of + * @return {@code true} if localAuthorizationList is valid, {@code false} if not + */ + private boolean isValidLocalAuthorizationList( + @Nullable AuthorizationData[] localAuthorizationList) { + return localAuthorizationList == null + || (localAuthorizationList.length >= 1 + && Arrays.stream(localAuthorizationList).allMatch(item -> item.validate())); + } + + /** + * Adds the identifier to use for authorization. + * + * @param localAuthorizationList The identifier to use for authorization + * @return this + */ + public SendLocalListRequest withLocalAuthorizationList( + @Nullable AuthorizationData[] localAuthorizationList) { + setLocalAuthorizationList(localAuthorizationList); + return this; + } + + /** + * Gets in case of a full update this is the version number of the full list. In case of a + * differential update it is the version number of the list after the update has been applied. + * + * @return In case of a full update this is the version number of the full list + */ + public Integer getVersionNumber() { + return versionNumber; + } + + /** + * Sets in case of a full update this is the version number of the full list. In case of a + * differential update it is the version number of the list after the update has been applied. + * + * @param versionNumber In case of a full update this is the version number of the full list + */ + public void setVersionNumber(Integer versionNumber) { + if (!isValidVersionNumber(versionNumber)) { + throw new PropertyConstraintException(versionNumber, "versionNumber is invalid"); + } + this.versionNumber = versionNumber; + } + + /** + * Returns whether the given versionNumber is valid + * + * @param versionNumber the versionNumber to check the validity of + * @return {@code true} if versionNumber is valid, {@code false} if not + */ + private boolean isValidVersionNumber(Integer versionNumber) { + return versionNumber != null; + } + + /** + * Gets the type of update (full or differential) of this request. + * + * @return The type of update (full or differential) of this request + */ + public UpdateEnum getUpdateType() { + return updateType; + } + + /** + * Sets the type of update (full or differential) of this request. + * + * @param updateType The type of update (full or differential) of this request + */ + public void setUpdateType(UpdateEnum updateType) { + if (!isValidUpdateType(updateType)) { + throw new PropertyConstraintException(updateType, "updateType is invalid"); + } + this.updateType = updateType; + } + + /** + * Returns whether the given updateType is valid + * + * @param updateType the updateType to check the validity of + * @return {@code true} if updateType is valid, {@code false} if not + */ + private boolean isValidUpdateType(UpdateEnum updateType) { + return updateType != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SendLocalListRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidLocalAuthorizationList(localAuthorizationList) + && isValidVersionNumber(versionNumber) + && isValidUpdateType(updateType) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SendLocalListRequest that = (SendLocalListRequest) o; + return Arrays.equals(localAuthorizationList, that.localAuthorizationList) + && Objects.equals(versionNumber, that.versionNumber) + && Objects.equals(updateType, that.updateType) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(localAuthorizationList), versionNumber, updateType, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("localAuthorizationList", localAuthorizationList) + .add("versionNumber", versionNumber) + .add("updateType", updateType) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SendLocalListResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SendLocalListResponse.java new file mode 100644 index 00000000..e383501f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SendLocalListResponse.java @@ -0,0 +1,219 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.SendLocalListStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SendLocalListResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SendLocalListResponse extends Confirmation { + /** + * Whether the Charging Station has successfully received and applied the update of the Local + * Authorization List. + */ + private SendLocalListStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SendLocalListResponse class + * + * @param status Whether the Charging Station has successfully received and applied the update of + * the Local Authorization List. + */ + public SendLocalListResponse(SendLocalListStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station has successfully received and applied the update of the Local + * Authorization List. + * + * @return Whether the Charging Station has successfully received and applied the update of the + * Local Authorization List + */ + public SendLocalListStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station has successfully received and applied the update of the Local + * Authorization List. + * + * @param status Whether the Charging Station has successfully received and applied the update of + * the Local Authorization List + */ + public void setStatus(SendLocalListStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(SendLocalListStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SendLocalListResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SendLocalListResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SendLocalListResponse that = (SendLocalListResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetChargingProfileRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetChargingProfileRequest.java new file mode 100644 index 00000000..8697d58c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetChargingProfileRequest.java @@ -0,0 +1,232 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingProfile; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetChargingProfileRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetChargingProfileRequest extends RequestWithId { + /** + * For TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an overal + * limit for the whole Charging Station. + */ + private Integer evseId; + + /** + * A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of ChargingSchedulePeriods, + * describing the amount of power or current that can be delivered per time interval. + * + *

image::images/ChargingProfile-Simple.png[] + */ + private ChargingProfile chargingProfile; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetChargingProfileRequest class + * + * @param evseId For TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an + * overal limit for the whole Charging Station. + * @param chargingProfile A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval. + */ + public SetChargingProfileRequest(Integer evseId, ChargingProfile chargingProfile) { + setEvseId(evseId); + setChargingProfile(chargingProfile); + } + + /** + * Gets for TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an overal + * limit for the whole Charging Station. + * + * @return For TxDefaultProfile an evseId=0 applies the profile to each individual evse + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets for TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an overal + * limit for the whole Charging Station. + * + * @param evseId For TxDefaultProfile an evseId=0 applies the profile to each individual evse + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets a ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered per + * time interval. + * + * @return A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval + */ + public ChargingProfile getChargingProfile() { + return chargingProfile; + } + + /** + * Sets a ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered per + * time interval. + * + * @param chargingProfile A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of + * ChargingSchedulePeriods, describing the amount of power or current that can be delivered + * per time interval + */ + public void setChargingProfile(ChargingProfile chargingProfile) { + if (!isValidChargingProfile(chargingProfile)) { + throw new PropertyConstraintException(chargingProfile, "chargingProfile is invalid"); + } + this.chargingProfile = chargingProfile; + } + + /** + * Returns whether the given chargingProfile is valid + * + * @param chargingProfile the chargingProfile to check the validity of + * @return {@code true} if chargingProfile is valid, {@code false} if not + */ + private boolean isValidChargingProfile(ChargingProfile chargingProfile) { + return chargingProfile != null && chargingProfile.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetChargingProfileRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvseId(evseId) + && isValidChargingProfile(chargingProfile) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetChargingProfileRequest that = (SetChargingProfileRequest) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(chargingProfile, that.chargingProfile) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, chargingProfile, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("chargingProfile", chargingProfile) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetChargingProfileResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetChargingProfileResponse.java new file mode 100644 index 00000000..64ac851c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetChargingProfileResponse.java @@ -0,0 +1,222 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingProfileStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetChargingProfileResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetChargingProfileResponse extends Confirmation { + /** + * Returns whether the Charging Station has been able to process the message successfully. This + * does not guarantee the schedule will be followed to the letter. There might be other + * constraints the Charging Station may need to take into account. + */ + private ChargingProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetChargingProfileResponse class + * + * @param status Returns whether the Charging Station has been able to process the message + * successfully. This does not guarantee the schedule will be followed to the letter. There + * might be other constraints the Charging Station may need to take into account. + */ + public SetChargingProfileResponse(ChargingProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets returns whether the Charging Station has been able to process the message successfully. + * This does not guarantee the schedule will be followed to the letter. There might be other + * constraints the Charging Station may need to take into account. + * + * @return Returns whether the Charging Station has been able to process the message successfully + */ + public ChargingProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether the Charging Station has been able to process the message successfully. + * This does not guarantee the schedule will be followed to the letter. There might be other + * constraints the Charging Station may need to take into account. + * + * @param status Returns whether the Charging Station has been able to process the message + * successfully + */ + public void setStatus(ChargingProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ChargingProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetChargingProfileResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetChargingProfileResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetChargingProfileResponse that = (SetChargingProfileResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDERControlRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDERControlRequest.java new file mode 100644 index 00000000..442d6825 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDERControlRequest.java @@ -0,0 +1,657 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DERControlEnum; +import eu.chargetime.ocpp.v21.model.types.DERCurve; +import eu.chargetime.ocpp.v21.model.types.EnterService; +import eu.chargetime.ocpp.v21.model.types.FixedPF; +import eu.chargetime.ocpp.v21.model.types.FixedVar; +import eu.chargetime.ocpp.v21.model.types.FreqDroop; +import eu.chargetime.ocpp.v21.model.types.Gradient; +import eu.chargetime.ocpp.v21.model.types.LimitMaxDischarge; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetDERControlRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetDERControlRequest extends RequestWithId { + /** True if this is a default DER control */ + private Boolean isDefault; + + /** Unique id of this control, e.g. UUID */ + private String controlId; + + /** Type of control. Determines which setting field below is used. */ + private DERControlEnum controlType; + + /** curve */ + @Nullable private DERCurve curve; + + /** enterService */ + @Nullable private EnterService enterService; + + /** fixedPFAbsorb */ + @Nullable private FixedPF fixedPFAbsorb; + + /** fixedPFInject */ + @Nullable private FixedPF fixedPFInject; + + /** fixedVar */ + @Nullable private FixedVar fixedVar; + + /** freqDroop */ + @Nullable private FreqDroop freqDroop; + + /** gradient */ + @Nullable private Gradient gradient; + + /** limitMaxDischarge */ + @Nullable private LimitMaxDischarge limitMaxDischarge; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetDERControlRequest class + * + * @param isDefault True if this is a default DER control + * @param controlId Unique id of this control, e.g. UUID + * @param controlType Type of control. Determines which setting field below is used. + */ + public SetDERControlRequest(Boolean isDefault, String controlId, DERControlEnum controlType) { + setIsDefault(isDefault); + setControlId(controlId); + setControlType(controlType); + } + + /** + * Gets true if this is a default DER control + * + * @return True if this is a default DER control + */ + public Boolean getIsDefault() { + return isDefault; + } + + /** + * Sets true if this is a default DER control + * + * @param isDefault True if this is a default DER control + */ + public void setIsDefault(Boolean isDefault) { + if (!isValidIsDefault(isDefault)) { + throw new PropertyConstraintException(isDefault, "isDefault is invalid"); + } + this.isDefault = isDefault; + } + + /** + * Returns whether the given isDefault is valid + * + * @param isDefault the isDefault to check the validity of + * @return {@code true} if isDefault is valid, {@code false} if not + */ + private boolean isValidIsDefault(Boolean isDefault) { + return isDefault != null; + } + + /** + * Gets unique id of this control, e.g. UUID + * + * @return Unique id of this control, e.g. UUID + */ + public String getControlId() { + return controlId; + } + + /** + * Sets unique id of this control, e.g. UUID + * + * @param controlId Unique id of this control, e.g. UUID + */ + public void setControlId(String controlId) { + if (!isValidControlId(controlId)) { + throw new PropertyConstraintException(controlId, "controlId is invalid"); + } + this.controlId = controlId; + } + + /** + * Returns whether the given controlId is valid + * + * @param controlId the controlId to check the validity of + * @return {@code true} if controlId is valid, {@code false} if not + */ + private boolean isValidControlId(String controlId) { + return controlId != null && controlId.length() <= 36; + } + + /** + * Gets type of control. Determines which setting field below is used. + * + * @return Type of control + */ + public DERControlEnum getControlType() { + return controlType; + } + + /** + * Sets type of control. Determines which setting field below is used. + * + * @param controlType Type of control + */ + public void setControlType(DERControlEnum controlType) { + if (!isValidControlType(controlType)) { + throw new PropertyConstraintException(controlType, "controlType is invalid"); + } + this.controlType = controlType; + } + + /** + * Returns whether the given controlType is valid + * + * @param controlType the controlType to check the validity of + * @return {@code true} if controlType is valid, {@code false} if not + */ + private boolean isValidControlType(DERControlEnum controlType) { + return controlType != null; + } + + /** + * Gets curve + * + * @return curve + */ + @Nullable + public DERCurve getCurve() { + return curve; + } + + /** + * Sets curve + * + * @param curve curve + */ + public void setCurve(@Nullable DERCurve curve) { + if (!isValidCurve(curve)) { + throw new PropertyConstraintException(curve, "curve is invalid"); + } + this.curve = curve; + } + + /** + * Returns whether the given curve is valid + * + * @param curve the curve to check the validity of + * @return {@code true} if curve is valid, {@code false} if not + */ + private boolean isValidCurve(@Nullable DERCurve curve) { + return curve == null || curve.validate(); + } + + /** + * Adds curve + * + * @param curve curve + * @return this + */ + public SetDERControlRequest withCurve(@Nullable DERCurve curve) { + setCurve(curve); + return this; + } + + /** + * Gets enterService + * + * @return enterService + */ + @Nullable + public EnterService getEnterService() { + return enterService; + } + + /** + * Sets enterService + * + * @param enterService enterService + */ + public void setEnterService(@Nullable EnterService enterService) { + if (!isValidEnterService(enterService)) { + throw new PropertyConstraintException(enterService, "enterService is invalid"); + } + this.enterService = enterService; + } + + /** + * Returns whether the given enterService is valid + * + * @param enterService the enterService to check the validity of + * @return {@code true} if enterService is valid, {@code false} if not + */ + private boolean isValidEnterService(@Nullable EnterService enterService) { + return enterService == null || enterService.validate(); + } + + /** + * Adds enterService + * + * @param enterService enterService + * @return this + */ + public SetDERControlRequest withEnterService(@Nullable EnterService enterService) { + setEnterService(enterService); + return this; + } + + /** + * Gets fixedPFAbsorb + * + * @return fixedPFAbsorb + */ + @Nullable + public FixedPF getFixedPFAbsorb() { + return fixedPFAbsorb; + } + + /** + * Sets fixedPFAbsorb + * + * @param fixedPFAbsorb fixedPFAbsorb + */ + public void setFixedPFAbsorb(@Nullable FixedPF fixedPFAbsorb) { + if (!isValidFixedPFAbsorb(fixedPFAbsorb)) { + throw new PropertyConstraintException(fixedPFAbsorb, "fixedPFAbsorb is invalid"); + } + this.fixedPFAbsorb = fixedPFAbsorb; + } + + /** + * Returns whether the given fixedPFAbsorb is valid + * + * @param fixedPFAbsorb the fixedPFAbsorb to check the validity of + * @return {@code true} if fixedPFAbsorb is valid, {@code false} if not + */ + private boolean isValidFixedPFAbsorb(@Nullable FixedPF fixedPFAbsorb) { + return fixedPFAbsorb == null || fixedPFAbsorb.validate(); + } + + /** + * Adds fixedPFAbsorb + * + * @param fixedPFAbsorb fixedPFAbsorb + * @return this + */ + public SetDERControlRequest withFixedPFAbsorb(@Nullable FixedPF fixedPFAbsorb) { + setFixedPFAbsorb(fixedPFAbsorb); + return this; + } + + /** + * Gets fixedPFInject + * + * @return fixedPFInject + */ + @Nullable + public FixedPF getFixedPFInject() { + return fixedPFInject; + } + + /** + * Sets fixedPFInject + * + * @param fixedPFInject fixedPFInject + */ + public void setFixedPFInject(@Nullable FixedPF fixedPFInject) { + if (!isValidFixedPFInject(fixedPFInject)) { + throw new PropertyConstraintException(fixedPFInject, "fixedPFInject is invalid"); + } + this.fixedPFInject = fixedPFInject; + } + + /** + * Returns whether the given fixedPFInject is valid + * + * @param fixedPFInject the fixedPFInject to check the validity of + * @return {@code true} if fixedPFInject is valid, {@code false} if not + */ + private boolean isValidFixedPFInject(@Nullable FixedPF fixedPFInject) { + return fixedPFInject == null || fixedPFInject.validate(); + } + + /** + * Adds fixedPFInject + * + * @param fixedPFInject fixedPFInject + * @return this + */ + public SetDERControlRequest withFixedPFInject(@Nullable FixedPF fixedPFInject) { + setFixedPFInject(fixedPFInject); + return this; + } + + /** + * Gets fixedVar + * + * @return fixedVar + */ + @Nullable + public FixedVar getFixedVar() { + return fixedVar; + } + + /** + * Sets fixedVar + * + * @param fixedVar fixedVar + */ + public void setFixedVar(@Nullable FixedVar fixedVar) { + if (!isValidFixedVar(fixedVar)) { + throw new PropertyConstraintException(fixedVar, "fixedVar is invalid"); + } + this.fixedVar = fixedVar; + } + + /** + * Returns whether the given fixedVar is valid + * + * @param fixedVar the fixedVar to check the validity of + * @return {@code true} if fixedVar is valid, {@code false} if not + */ + private boolean isValidFixedVar(@Nullable FixedVar fixedVar) { + return fixedVar == null || fixedVar.validate(); + } + + /** + * Adds fixedVar + * + * @param fixedVar fixedVar + * @return this + */ + public SetDERControlRequest withFixedVar(@Nullable FixedVar fixedVar) { + setFixedVar(fixedVar); + return this; + } + + /** + * Gets freqDroop + * + * @return freqDroop + */ + @Nullable + public FreqDroop getFreqDroop() { + return freqDroop; + } + + /** + * Sets freqDroop + * + * @param freqDroop freqDroop + */ + public void setFreqDroop(@Nullable FreqDroop freqDroop) { + if (!isValidFreqDroop(freqDroop)) { + throw new PropertyConstraintException(freqDroop, "freqDroop is invalid"); + } + this.freqDroop = freqDroop; + } + + /** + * Returns whether the given freqDroop is valid + * + * @param freqDroop the freqDroop to check the validity of + * @return {@code true} if freqDroop is valid, {@code false} if not + */ + private boolean isValidFreqDroop(@Nullable FreqDroop freqDroop) { + return freqDroop == null || freqDroop.validate(); + } + + /** + * Adds freqDroop + * + * @param freqDroop freqDroop + * @return this + */ + public SetDERControlRequest withFreqDroop(@Nullable FreqDroop freqDroop) { + setFreqDroop(freqDroop); + return this; + } + + /** + * Gets gradient + * + * @return gradient + */ + @Nullable + public Gradient getGradient() { + return gradient; + } + + /** + * Sets gradient + * + * @param gradient gradient + */ + public void setGradient(@Nullable Gradient gradient) { + if (!isValidGradient(gradient)) { + throw new PropertyConstraintException(gradient, "gradient is invalid"); + } + this.gradient = gradient; + } + + /** + * Returns whether the given gradient is valid + * + * @param gradient the gradient to check the validity of + * @return {@code true} if gradient is valid, {@code false} if not + */ + private boolean isValidGradient(@Nullable Gradient gradient) { + return gradient == null || gradient.validate(); + } + + /** + * Adds gradient + * + * @param gradient gradient + * @return this + */ + public SetDERControlRequest withGradient(@Nullable Gradient gradient) { + setGradient(gradient); + return this; + } + + /** + * Gets limitMaxDischarge + * + * @return limitMaxDischarge + */ + @Nullable + public LimitMaxDischarge getLimitMaxDischarge() { + return limitMaxDischarge; + } + + /** + * Sets limitMaxDischarge + * + * @param limitMaxDischarge limitMaxDischarge + */ + public void setLimitMaxDischarge(@Nullable LimitMaxDischarge limitMaxDischarge) { + if (!isValidLimitMaxDischarge(limitMaxDischarge)) { + throw new PropertyConstraintException(limitMaxDischarge, "limitMaxDischarge is invalid"); + } + this.limitMaxDischarge = limitMaxDischarge; + } + + /** + * Returns whether the given limitMaxDischarge is valid + * + * @param limitMaxDischarge the limitMaxDischarge to check the validity of + * @return {@code true} if limitMaxDischarge is valid, {@code false} if not + */ + private boolean isValidLimitMaxDischarge(@Nullable LimitMaxDischarge limitMaxDischarge) { + return limitMaxDischarge == null || limitMaxDischarge.validate(); + } + + /** + * Adds limitMaxDischarge + * + * @param limitMaxDischarge limitMaxDischarge + * @return this + */ + public SetDERControlRequest withLimitMaxDischarge(@Nullable LimitMaxDischarge limitMaxDischarge) { + setLimitMaxDischarge(limitMaxDischarge); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetDERControlRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidIsDefault(isDefault) + && isValidControlId(controlId) + && isValidControlType(controlType) + && isValidCurve(curve) + && isValidEnterService(enterService) + && isValidFixedPFAbsorb(fixedPFAbsorb) + && isValidFixedPFInject(fixedPFInject) + && isValidFixedVar(fixedVar) + && isValidFreqDroop(freqDroop) + && isValidGradient(gradient) + && isValidLimitMaxDischarge(limitMaxDischarge) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetDERControlRequest that = (SetDERControlRequest) o; + return Objects.equals(isDefault, that.isDefault) + && Objects.equals(controlId, that.controlId) + && Objects.equals(controlType, that.controlType) + && Objects.equals(curve, that.curve) + && Objects.equals(enterService, that.enterService) + && Objects.equals(fixedPFAbsorb, that.fixedPFAbsorb) + && Objects.equals(fixedPFInject, that.fixedPFInject) + && Objects.equals(fixedVar, that.fixedVar) + && Objects.equals(freqDroop, that.freqDroop) + && Objects.equals(gradient, that.gradient) + && Objects.equals(limitMaxDischarge, that.limitMaxDischarge) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + isDefault, + controlId, + controlType, + curve, + enterService, + fixedPFAbsorb, + fixedPFInject, + fixedVar, + freqDroop, + gradient, + limitMaxDischarge, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("isDefault", isDefault) + .add("controlId", controlId) + .add("controlType", controlType) + .add("curve", curve) + .add("enterService", enterService) + .add("fixedPFAbsorb", fixedPFAbsorb) + .add("fixedPFInject", fixedPFInject) + .add("fixedVar", fixedVar) + .add("freqDroop", freqDroop) + .add("gradient", gradient) + .add("limitMaxDischarge", limitMaxDischarge) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDERControlResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDERControlResponse.java new file mode 100644 index 00000000..f4711aa6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDERControlResponse.java @@ -0,0 +1,266 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DERControlStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetDERControlResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetDERControlResponse extends Confirmation { + /** Result of operation. */ + private DERControlStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** List of controlIds that are superseded as a result of setting this control. */ + @Nullable private String[] supersededIds; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetDERControlResponse class + * + * @param status Result of operation. + */ + public SetDERControlResponse(DERControlStatusEnum status) { + setStatus(status); + } + + /** + * Gets result of operation. + * + * @return Result of operation + */ + public DERControlStatusEnum getStatus() { + return status; + } + + /** + * Sets result of operation. + * + * @param status Result of operation + */ + public void setStatus(DERControlStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DERControlStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetDERControlResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets list of controlIds that are superseded as a result of setting this control. + * + * @return List of controlIds that are superseded as a result of setting this control + */ + @Nullable + public String[] getSupersededIds() { + return supersededIds; + } + + /** + * Sets list of controlIds that are superseded as a result of setting this control. + * + * @param supersededIds List of controlIds that are superseded as a result of setting this control + */ + public void setSupersededIds(@Nullable String[] supersededIds) { + if (!isValidSupersededIds(supersededIds)) { + throw new PropertyConstraintException(supersededIds, "supersededIds is invalid"); + } + this.supersededIds = supersededIds; + } + + /** + * Returns whether the given supersededIds is valid + * + * @param supersededIds the supersededIds to check the validity of + * @return {@code true} if supersededIds is valid, {@code false} if not + */ + private boolean isValidSupersededIds(@Nullable String[] supersededIds) { + return supersededIds == null + || (supersededIds.length >= 1 + && supersededIds.length <= 24 + && Arrays.stream(supersededIds).allMatch(item -> item.length() <= 36)); + } + + /** + * Adds list of controlIds that are superseded as a result of setting this control. + * + * @param supersededIds List of controlIds that are superseded as a result of setting this control + * @return this + */ + public SetDERControlResponse withSupersededIds(@Nullable String[] supersededIds) { + setSupersededIds(supersededIds); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetDERControlResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidSupersededIds(supersededIds) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetDERControlResponse that = (SetDERControlResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Arrays.equals(supersededIds, that.supersededIds) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, Arrays.hashCode(supersededIds), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("supersededIds", supersededIds) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDefaultTariffRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDefaultTariffRequest.java new file mode 100644 index 00000000..5062c23c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDefaultTariffRequest.java @@ -0,0 +1,221 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.Tariff; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetDefaultTariffRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetDefaultTariffRequest extends RequestWithId { + /** EVSE that tariff applies to. When evseId = 0, then tarriff applies to all EVSEs. */ + private Integer evseId; + + /** + * A tariff is described by fields with prices for: energy, charging time, idle time, fixed fee, + * reservation time, + * + *

+   * reservation fixed fee.
+   * Each of these fields may have (optional) conditions that specify when a price is applicable.
+   * The description contains a human-readable explanation of the tariff to be shown to the user.
+   * The other fields are parameters that define the tariff. These are used by the charging station
+   * to calculate the price.
+   * 
+ */ + private Tariff tariff; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetDefaultTariffRequest class + * + * @param evseId EVSE that tariff applies to. When evseId = 0, then tarriff applies to all EVSEs. + * @param tariff A tariff is described by fields with prices for: energy, charging time, idle + * time, fixed fee, reservation time, + */ + public SetDefaultTariffRequest(Integer evseId, Tariff tariff) { + setEvseId(evseId); + setTariff(tariff); + } + + /** + * Gets EVSE that tariff applies to. When evseId = 0, then tarriff applies to all EVSEs. + * + * @return EVSE that tariff applies to + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets EVSE that tariff applies to. When evseId = 0, then tarriff applies to all EVSEs. + * + * @param evseId EVSE that tariff applies to + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets a tariff is described by fields with prices for: energy, charging time, idle time, fixed + * fee, reservation time, + * + * @return A tariff is described by fields with prices for: energy, charging time, idle time, + * fixed fee, reservation time, + */ + public Tariff getTariff() { + return tariff; + } + + /** + * Sets a tariff is described by fields with prices for: energy, charging time, idle time, fixed + * fee, reservation time, + * + * @param tariff A tariff is described by fields with prices for: energy, charging time, idle + * time, fixed fee, reservation time, + */ + public void setTariff(Tariff tariff) { + if (!isValidTariff(tariff)) { + throw new PropertyConstraintException(tariff, "tariff is invalid"); + } + this.tariff = tariff; + } + + /** + * Returns whether the given tariff is valid + * + * @param tariff the tariff to check the validity of + * @return {@code true} if tariff is valid, {@code false} if not + */ + private boolean isValidTariff(Tariff tariff) { + return tariff != null && tariff.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetDefaultTariffRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvseId(evseId) && isValidTariff(tariff) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetDefaultTariffRequest that = (SetDefaultTariffRequest) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(tariff, that.tariff) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, tariff, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("tariff", tariff) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDefaultTariffResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDefaultTariffResponse.java new file mode 100644 index 00000000..7eab3e81 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDefaultTariffResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import eu.chargetime.ocpp.v21.model.types.TariffSetStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetDefaultTariffResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetDefaultTariffResponse extends Confirmation { + /** status */ + private TariffSetStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetDefaultTariffResponse class + * + * @param status status + */ + public SetDefaultTariffResponse(TariffSetStatusEnum status) { + setStatus(status); + } + + /** + * Gets status + * + * @return status + */ + public TariffSetStatusEnum getStatus() { + return status; + } + + /** + * Sets status + * + * @param status status + */ + public void setStatus(TariffSetStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(TariffSetStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetDefaultTariffResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetDefaultTariffResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetDefaultTariffResponse that = (SetDefaultTariffResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDisplayMessageRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDisplayMessageRequest.java new file mode 100644 index 00000000..e8540467 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDisplayMessageRequest.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.MessageInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetDisplayMessageRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetDisplayMessageRequest extends RequestWithId { + /** Message details, for a message to be displayed on a Charging Station. */ + private MessageInfo message; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetDisplayMessageRequest class + * + * @param message Message details, for a message to be displayed on a Charging Station. + */ + public SetDisplayMessageRequest(MessageInfo message) { + setMessage(message); + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + public MessageInfo getMessage() { + return message; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param message Message details, for a message to be displayed on a Charging Station + */ + public void setMessage(MessageInfo message) { + if (!isValidMessage(message)) { + throw new PropertyConstraintException(message, "message is invalid"); + } + this.message = message; + } + + /** + * Returns whether the given message is valid + * + * @param message the message to check the validity of + * @return {@code true} if message is valid, {@code false} if not + */ + private boolean isValidMessage(MessageInfo message) { + return message != null && message.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetDisplayMessageRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidMessage(message) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetDisplayMessageRequest that = (SetDisplayMessageRequest) o; + return Objects.equals(message, that.message) && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(message, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("message", message) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDisplayMessageResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDisplayMessageResponse.java new file mode 100644 index 00000000..43b82e3b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetDisplayMessageResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.DisplayMessageStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetDisplayMessageResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetDisplayMessageResponse extends Confirmation { + /** Whether the Charging Station is able to display the message. */ + private DisplayMessageStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetDisplayMessageResponse class + * + * @param status Whether the Charging Station is able to display the message. + */ + public SetDisplayMessageResponse(DisplayMessageStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station is able to display the message. + * + * @return Whether the Charging Station is able to display the message + */ + public DisplayMessageStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to display the message. + * + * @param status Whether the Charging Station is able to display the message + */ + public void setStatus(DisplayMessageStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DisplayMessageStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetDisplayMessageResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetDisplayMessageResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetDisplayMessageResponse that = (SetDisplayMessageResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringBaseRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringBaseRequest.java new file mode 100644 index 00000000..db857aba --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringBaseRequest.java @@ -0,0 +1,167 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.MonitoringBaseEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetMonitoringBaseRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetMonitoringBaseRequest extends RequestWithId { + /** Specify which monitoring base will be set */ + private MonitoringBaseEnum monitoringBase; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetMonitoringBaseRequest class + * + * @param monitoringBase Specify which monitoring base will be set + */ + public SetMonitoringBaseRequest(MonitoringBaseEnum monitoringBase) { + setMonitoringBase(monitoringBase); + } + + /** + * Gets specify which monitoring base will be set + * + * @return Specify which monitoring base will be set + */ + public MonitoringBaseEnum getMonitoringBase() { + return monitoringBase; + } + + /** + * Sets specify which monitoring base will be set + * + * @param monitoringBase Specify which monitoring base will be set + */ + public void setMonitoringBase(MonitoringBaseEnum monitoringBase) { + if (!isValidMonitoringBase(monitoringBase)) { + throw new PropertyConstraintException(monitoringBase, "monitoringBase is invalid"); + } + this.monitoringBase = monitoringBase; + } + + /** + * Returns whether the given monitoringBase is valid + * + * @param monitoringBase the monitoringBase to check the validity of + * @return {@code true} if monitoringBase is valid, {@code false} if not + */ + private boolean isValidMonitoringBase(MonitoringBaseEnum monitoringBase) { + return monitoringBase != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringBaseRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidMonitoringBase(monitoringBase) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringBaseRequest that = (SetMonitoringBaseRequest) o; + return Objects.equals(monitoringBase, that.monitoringBase) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(monitoringBase, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("monitoringBase", monitoringBase) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringBaseResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringBaseResponse.java new file mode 100644 index 00000000..ede327ff --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringBaseResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetMonitoringBaseResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetMonitoringBaseResponse extends Confirmation { + /** Whether the Charging Station was able to accept the request. */ + private GenericDeviceModelStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetMonitoringBaseResponse class + * + * @param status Whether the Charging Station was able to accept the request. + */ + public SetMonitoringBaseResponse(GenericDeviceModelStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station was able to accept the request. + * + * @return Whether the Charging Station was able to accept the request + */ + public GenericDeviceModelStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station was able to accept the request. + * + * @param status Whether the Charging Station was able to accept the request + */ + public void setStatus(GenericDeviceModelStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericDeviceModelStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetMonitoringBaseResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringBaseResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringBaseResponse that = (SetMonitoringBaseResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringLevelRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringLevelRequest.java new file mode 100644 index 00000000..d1c40ddf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringLevelRequest.java @@ -0,0 +1,205 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetMonitoringLevelRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetMonitoringLevelRequest extends RequestWithId { + /** + * The Charging Station SHALL only report events with a severity number lower than or equal to + * this severity. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * + *

+   * The severity levels have the following meaning:
+   * *0-Danger*
+   * Lives are potentially in danger. Urgent attention is needed and action should be taken
+   * immediately.
+   * *1-Hardware Failure*
+   * That the Charging Station is unable to continue regular operations due to Hardware issues.
+   * Action is required.
+   * *2-System Failure*
+   * That the Charging Station is unable to continue regular operations due to software or minor
+   * hardware issues. Action is required.
+   * *3-Critical*
+   * A critical error. Action is required.
+   * *4-Error*
+   * A non-urgent error. Action is required.
+   * *5-Alert*
+   * An alert event. Default severity for any type of monitoring event.
+   * *6-Warning*
+   * A warning event. Action may be required.
+   * *7-Notice*
+   * An unusual event. No immediate action is required.
+   * *8-Informational*
+   * A regular operational event. May be used for reporting, measuring throughput, etc. No action is
+   * required.
+   * *9-Debug*
+   * Information useful to developers for debugging, not useful during operations.
+   * 
+ */ + private Integer severity; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetMonitoringLevelRequest class + * + * @param severity The Charging Station SHALL only report events with a severity number lower than + * or equal to this severity. The severity range is 0-9, with 0 as the highest and 9 as the + * lowest severity level. + */ + public SetMonitoringLevelRequest(Integer severity) { + setSeverity(severity); + } + + /** + * Gets the Charging Station SHALL only report events with a severity number lower than or equal + * to this severity. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * + * @return The Charging Station SHALL only report events with a severity number lower than or + * equal to this severity + */ + public Integer getSeverity() { + return severity; + } + + /** + * Sets the Charging Station SHALL only report events with a severity number lower than or equal + * to this severity. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * + * @param severity The Charging Station SHALL only report events with a severity number lower than + * or equal to this severity + */ + public void setSeverity(Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(Integer severity) { + return severity != null && severity >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringLevelRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidSeverity(severity) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringLevelRequest that = (SetMonitoringLevelRequest) o; + return Objects.equals(severity, that.severity) && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(severity, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("severity", severity) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringLevelResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringLevelResponse.java new file mode 100644 index 00000000..63a51447 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetMonitoringLevelResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetMonitoringLevelResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetMonitoringLevelResponse extends Confirmation { + /** Whether the Charging Station was able to accept the request. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetMonitoringLevelResponse class + * + * @param status Whether the Charging Station was able to accept the request. + */ + public SetMonitoringLevelResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station was able to accept the request. + * + * @return Whether the Charging Station was able to accept the request + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station was able to accept the request. + * + * @param status Whether the Charging Station was able to accept the request + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetMonitoringLevelResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringLevelResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringLevelResponse that = (SetMonitoringLevelResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetNetworkProfileRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetNetworkProfileRequest.java new file mode 100644 index 00000000..ce547f05 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetNetworkProfileRequest.java @@ -0,0 +1,216 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.NetworkConnectionProfile; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetNetworkProfileRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetNetworkProfileRequest extends RequestWithId { + /** Slot in which the configuration should be stored. */ + private Integer configurationSlot; + + /** + * The NetworkConnectionProfile defines the functional and technical parameters of a communication + * link. + */ + private NetworkConnectionProfile connectionData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetNetworkProfileRequest class + * + * @param configurationSlot Slot in which the configuration should be stored. + * @param connectionData The NetworkConnectionProfile defines the functional and technical + * parameters of a communication link. + */ + public SetNetworkProfileRequest( + Integer configurationSlot, NetworkConnectionProfile connectionData) { + setConfigurationSlot(configurationSlot); + setConnectionData(connectionData); + } + + /** + * Gets slot in which the configuration should be stored. + * + * @return Slot in which the configuration should be stored + */ + public Integer getConfigurationSlot() { + return configurationSlot; + } + + /** + * Sets slot in which the configuration should be stored. + * + * @param configurationSlot Slot in which the configuration should be stored + */ + public void setConfigurationSlot(Integer configurationSlot) { + if (!isValidConfigurationSlot(configurationSlot)) { + throw new PropertyConstraintException(configurationSlot, "configurationSlot is invalid"); + } + this.configurationSlot = configurationSlot; + } + + /** + * Returns whether the given configurationSlot is valid + * + * @param configurationSlot the configurationSlot to check the validity of + * @return {@code true} if configurationSlot is valid, {@code false} if not + */ + private boolean isValidConfigurationSlot(Integer configurationSlot) { + return configurationSlot != null; + } + + /** + * Gets the NetworkConnectionProfile defines the functional and technical parameters of a + * communication link. + * + * @return The NetworkConnectionProfile defines the functional and technical parameters of a + * communication link + */ + public NetworkConnectionProfile getConnectionData() { + return connectionData; + } + + /** + * Sets the NetworkConnectionProfile defines the functional and technical parameters of a + * communication link. + * + * @param connectionData The NetworkConnectionProfile defines the functional and technical + * parameters of a communication link + */ + public void setConnectionData(NetworkConnectionProfile connectionData) { + if (!isValidConnectionData(connectionData)) { + throw new PropertyConstraintException(connectionData, "connectionData is invalid"); + } + this.connectionData = connectionData; + } + + /** + * Returns whether the given connectionData is valid + * + * @param connectionData the connectionData to check the validity of + * @return {@code true} if connectionData is valid, {@code false} if not + */ + private boolean isValidConnectionData(NetworkConnectionProfile connectionData) { + return connectionData != null && connectionData.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetNetworkProfileRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidConfigurationSlot(configurationSlot) + && isValidConnectionData(connectionData) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetNetworkProfileRequest that = (SetNetworkProfileRequest) o; + return Objects.equals(configurationSlot, that.configurationSlot) + && Objects.equals(connectionData, that.connectionData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(configurationSlot, connectionData, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("configurationSlot", configurationSlot) + .add("connectionData", connectionData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetNetworkProfileResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetNetworkProfileResponse.java new file mode 100644 index 00000000..2be76585 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetNetworkProfileResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.SetNetworkProfileStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetNetworkProfileResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetNetworkProfileResponse extends Confirmation { + /** Result of operation. */ + private SetNetworkProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetNetworkProfileResponse class + * + * @param status Result of operation. + */ + public SetNetworkProfileResponse(SetNetworkProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets result of operation. + * + * @return Result of operation + */ + public SetNetworkProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets result of operation. + * + * @param status Result of operation + */ + public void setStatus(SetNetworkProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(SetNetworkProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetNetworkProfileResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetNetworkProfileResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetNetworkProfileResponse that = (SetNetworkProfileResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariableMonitoringRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariableMonitoringRequest.java new file mode 100644 index 00000000..75878d4a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariableMonitoringRequest.java @@ -0,0 +1,170 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.SetMonitoringData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetVariableMonitoringRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetVariableMonitoringRequest extends RequestWithId { + /** Class to hold parameters of SetVariableMonitoring request. */ + private SetMonitoringData[] setMonitoringData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetVariableMonitoringRequest class + * + * @param setMonitoringData Class to hold parameters of SetVariableMonitoring request. + */ + public SetVariableMonitoringRequest(SetMonitoringData[] setMonitoringData) { + setSetMonitoringData(setMonitoringData); + } + + /** + * Gets class to hold parameters of SetVariableMonitoring request. + * + * @return Class to hold parameters of SetVariableMonitoring request + */ + public SetMonitoringData[] getSetMonitoringData() { + return setMonitoringData; + } + + /** + * Sets class to hold parameters of SetVariableMonitoring request. + * + * @param setMonitoringData Class to hold parameters of SetVariableMonitoring request + */ + public void setSetMonitoringData(SetMonitoringData[] setMonitoringData) { + if (!isValidSetMonitoringData(setMonitoringData)) { + throw new PropertyConstraintException(setMonitoringData, "setMonitoringData is invalid"); + } + this.setMonitoringData = setMonitoringData; + } + + /** + * Returns whether the given setMonitoringData is valid + * + * @param setMonitoringData the setMonitoringData to check the validity of + * @return {@code true} if setMonitoringData is valid, {@code false} if not + */ + private boolean isValidSetMonitoringData(SetMonitoringData[] setMonitoringData) { + return setMonitoringData != null + && setMonitoringData.length >= 1 + && Arrays.stream(setMonitoringData).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariableMonitoringRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidSetMonitoringData(setMonitoringData) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariableMonitoringRequest that = (SetVariableMonitoringRequest) o; + return Arrays.equals(setMonitoringData, that.setMonitoringData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(setMonitoringData), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("setMonitoringData", setMonitoringData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariableMonitoringResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariableMonitoringResponse.java new file mode 100644 index 00000000..81be4272 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariableMonitoringResponse.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.SetMonitoringResult; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetVariableMonitoringResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetVariableMonitoringResponse extends Confirmation { + /** Class to hold result of SetVariableMonitoring request. */ + private SetMonitoringResult[] setMonitoringResult; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetVariableMonitoringResponse class + * + * @param setMonitoringResult Class to hold result of SetVariableMonitoring request. + */ + public SetVariableMonitoringResponse(SetMonitoringResult[] setMonitoringResult) { + setSetMonitoringResult(setMonitoringResult); + } + + /** + * Gets class to hold result of SetVariableMonitoring request. + * + * @return Class to hold result of SetVariableMonitoring request + */ + public SetMonitoringResult[] getSetMonitoringResult() { + return setMonitoringResult; + } + + /** + * Sets class to hold result of SetVariableMonitoring request. + * + * @param setMonitoringResult Class to hold result of SetVariableMonitoring request + */ + public void setSetMonitoringResult(SetMonitoringResult[] setMonitoringResult) { + if (!isValidSetMonitoringResult(setMonitoringResult)) { + throw new PropertyConstraintException(setMonitoringResult, "setMonitoringResult is invalid"); + } + this.setMonitoringResult = setMonitoringResult; + } + + /** + * Returns whether the given setMonitoringResult is valid + * + * @param setMonitoringResult the setMonitoringResult to check the validity of + * @return {@code true} if setMonitoringResult is valid, {@code false} if not + */ + private boolean isValidSetMonitoringResult(SetMonitoringResult[] setMonitoringResult) { + return setMonitoringResult != null + && setMonitoringResult.length >= 1 + && Arrays.stream(setMonitoringResult).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariableMonitoringResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidSetMonitoringResult(setMonitoringResult) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariableMonitoringResponse that = (SetVariableMonitoringResponse) o; + return Arrays.equals(setMonitoringResult, that.setMonitoringResult) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(setMonitoringResult), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("setMonitoringResult", setMonitoringResult) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariablesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariablesRequest.java new file mode 100644 index 00000000..0c5f072f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariablesRequest.java @@ -0,0 +1,170 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.SetVariableData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetVariablesRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetVariablesRequest extends RequestWithId { + /** setVariableData */ + private SetVariableData[] setVariableData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetVariablesRequest class + * + * @param setVariableData setVariableData + */ + public SetVariablesRequest(SetVariableData[] setVariableData) { + setSetVariableData(setVariableData); + } + + /** + * Gets setVariableData + * + * @return setVariableData + */ + public SetVariableData[] getSetVariableData() { + return setVariableData; + } + + /** + * Sets setVariableData + * + * @param setVariableData setVariableData + */ + public void setSetVariableData(SetVariableData[] setVariableData) { + if (!isValidSetVariableData(setVariableData)) { + throw new PropertyConstraintException(setVariableData, "setVariableData is invalid"); + } + this.setVariableData = setVariableData; + } + + /** + * Returns whether the given setVariableData is valid + * + * @param setVariableData the setVariableData to check the validity of + * @return {@code true} if setVariableData is valid, {@code false} if not + */ + private boolean isValidSetVariableData(SetVariableData[] setVariableData) { + return setVariableData != null + && setVariableData.length >= 1 + && Arrays.stream(setVariableData).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariablesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidSetVariableData(setVariableData) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariablesRequest that = (SetVariablesRequest) o; + return Arrays.equals(setVariableData, that.setVariableData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(setVariableData), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("setVariableData", setVariableData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariablesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariablesResponse.java new file mode 100644 index 00000000..ec96993d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SetVariablesResponse.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.SetVariableResult; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetVariablesResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SetVariablesResponse extends Confirmation { + /** setVariableResult */ + private SetVariableResult[] setVariableResult; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetVariablesResponse class + * + * @param setVariableResult setVariableResult + */ + public SetVariablesResponse(SetVariableResult[] setVariableResult) { + setSetVariableResult(setVariableResult); + } + + /** + * Gets setVariableResult + * + * @return setVariableResult + */ + public SetVariableResult[] getSetVariableResult() { + return setVariableResult; + } + + /** + * Sets setVariableResult + * + * @param setVariableResult setVariableResult + */ + public void setSetVariableResult(SetVariableResult[] setVariableResult) { + if (!isValidSetVariableResult(setVariableResult)) { + throw new PropertyConstraintException(setVariableResult, "setVariableResult is invalid"); + } + this.setVariableResult = setVariableResult; + } + + /** + * Returns whether the given setVariableResult is valid + * + * @param setVariableResult the setVariableResult to check the validity of + * @return {@code true} if setVariableResult is valid, {@code false} if not + */ + private boolean isValidSetVariableResult(SetVariableResult[] setVariableResult) { + return setVariableResult != null + && setVariableResult.length >= 1 + && Arrays.stream(setVariableResult).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariablesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidSetVariableResult(setVariableResult) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariablesResponse that = (SetVariablesResponse) o; + return Arrays.equals(setVariableResult, that.setVariableResult) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(setVariableResult), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("setVariableResult", setVariableResult) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SignCertificateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SignCertificateRequest.java new file mode 100644 index 00000000..b3579494 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SignCertificateRequest.java @@ -0,0 +1,309 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CertificateHashData; +import eu.chargetime.ocpp.v21.model.types.CertificateSigningUseEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SignCertificateRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SignCertificateRequest extends RequestWithId { + /** + * The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) + * as described in RFC 2986 [22] and then PEM encoded, using the SignCertificateRequest message. + */ + private String csr; + + /** + * The type of certificate that is to be signed. When omitted the certificate is to be used for + * both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + */ + @Nullable private CertificateSigningUseEnum certificateType; + + /** hashRootCertificate */ + @Nullable private CertificateHashData hashRootCertificate; + + /** RequestId to match this message with the CertificateSignedRequest. */ + @Nullable private Integer requestId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SignCertificateRequest class + * + * @param csr The Charging Station SHALL send the public key in form of a Certificate Signing + * Request (CSR) as described in RFC 2986 [22] and then PEM encoded, using the + * SignCertificateRequest message. + */ + public SignCertificateRequest(String csr) { + setCsr(csr); + } + + /** + * Gets the Charging Station SHALL send the public key in form of a Certificate Signing Request + * (CSR) as described in RFC 2986 [22] and then PEM encoded, using the SignCertificateRequest + * message. + * + * @return The Charging Station SHALL send the public key in form of a Certificate Signing Request + * (CSR) as described in RFC 2986 [22] and then PEM encoded, using the SignCertificateRequest + * message + */ + public String getCsr() { + return csr; + } + + /** + * Sets the Charging Station SHALL send the public key in form of a Certificate Signing Request + * (CSR) as described in RFC 2986 [22] and then PEM encoded, using the SignCertificateRequest + * message. + * + * @param csr The Charging Station SHALL send the public key in form of a Certificate Signing + * Request (CSR) as described in RFC 2986 [22] and then PEM encoded, using the + * SignCertificateRequest message + */ + public void setCsr(String csr) { + if (!isValidCsr(csr)) { + throw new PropertyConstraintException(csr, "csr is invalid"); + } + this.csr = csr; + } + + /** + * Returns whether the given csr is valid + * + * @param csr the csr to check the validity of + * @return {@code true} if csr is valid, {@code false} if not + */ + private boolean isValidCsr(String csr) { + return csr != null && csr.length() <= 5500; + } + + /** + * Gets the type of certificate that is to be signed. When omitted the certificate is to be used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * + * @return The type of certificate that is to be signed + */ + @Nullable + public CertificateSigningUseEnum getCertificateType() { + return certificateType; + } + + /** + * Sets the type of certificate that is to be signed. When omitted the certificate is to be used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * + * @param certificateType The type of certificate that is to be signed + */ + public void setCertificateType(@Nullable CertificateSigningUseEnum certificateType) { + this.certificateType = certificateType; + } + + /** + * Adds the type of certificate that is to be signed. When omitted the certificate is to be used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * + * @param certificateType The type of certificate that is to be signed + * @return this + */ + public SignCertificateRequest withCertificateType( + @Nullable CertificateSigningUseEnum certificateType) { + setCertificateType(certificateType); + return this; + } + + /** + * Gets hashRootCertificate + * + * @return hashRootCertificate + */ + @Nullable + public CertificateHashData getHashRootCertificate() { + return hashRootCertificate; + } + + /** + * Sets hashRootCertificate + * + * @param hashRootCertificate hashRootCertificate + */ + public void setHashRootCertificate(@Nullable CertificateHashData hashRootCertificate) { + if (!isValidHashRootCertificate(hashRootCertificate)) { + throw new PropertyConstraintException(hashRootCertificate, "hashRootCertificate is invalid"); + } + this.hashRootCertificate = hashRootCertificate; + } + + /** + * Returns whether the given hashRootCertificate is valid + * + * @param hashRootCertificate the hashRootCertificate to check the validity of + * @return {@code true} if hashRootCertificate is valid, {@code false} if not + */ + private boolean isValidHashRootCertificate(@Nullable CertificateHashData hashRootCertificate) { + return hashRootCertificate == null || hashRootCertificate.validate(); + } + + /** + * Adds hashRootCertificate + * + * @param hashRootCertificate hashRootCertificate + * @return this + */ + public SignCertificateRequest withHashRootCertificate( + @Nullable CertificateHashData hashRootCertificate) { + setHashRootCertificate(hashRootCertificate); + return this; + } + + /** + * Gets requestId to match this message with the CertificateSignedRequest. + * + * @return RequestId to match this message with the CertificateSignedRequest + */ + @Nullable + public Integer getRequestId() { + return requestId; + } + + /** + * Sets requestId to match this message with the CertificateSignedRequest. + * + * @param requestId RequestId to match this message with the CertificateSignedRequest + */ + public void setRequestId(@Nullable Integer requestId) { + this.requestId = requestId; + } + + /** + * Adds requestId to match this message with the CertificateSignedRequest. + * + * @param requestId RequestId to match this message with the CertificateSignedRequest + * @return this + */ + public SignCertificateRequest withRequestId(@Nullable Integer requestId) { + setRequestId(requestId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SignCertificateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCsr(csr) + && isValidHashRootCertificate(hashRootCertificate) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SignCertificateRequest that = (SignCertificateRequest) o; + return Objects.equals(csr, that.csr) + && Objects.equals(certificateType, that.certificateType) + && Objects.equals(hashRootCertificate, that.hashRootCertificate) + && Objects.equals(requestId, that.requestId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(csr, certificateType, hashRootCertificate, requestId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("csr", csr) + .add("certificateType", certificateType) + .add("hashRootCertificate", hashRootCertificate) + .add("requestId", requestId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SignCertificateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SignCertificateResponse.java new file mode 100644 index 00000000..1b89bc17 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/SignCertificateResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SignCertificateResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class SignCertificateResponse extends Confirmation { + /** Specifies whether the CSMS can process the request. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SignCertificateResponse class + * + * @param status Specifies whether the CSMS can process the request. + */ + public SignCertificateResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets specifies whether the CSMS can process the request. + * + * @return Specifies whether the CSMS can process the request + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets specifies whether the CSMS can process the request. + * + * @param status Specifies whether the CSMS can process the request + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SignCertificateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SignCertificateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SignCertificateResponse that = (SignCertificateResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/StatusNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/StatusNotificationRequest.java new file mode 100644 index 00000000..efd11d89 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/StatusNotificationRequest.java @@ -0,0 +1,292 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ConnectorStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * StatusNotificationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class StatusNotificationRequest extends RequestWithId { + /** The time for which the status is reported. */ + private ZonedDateTime timestamp; + + /** The current status of the Connector. */ + private ConnectorStatusEnum connectorStatus; + + /** The id of the EVSE to which the connector belongs for which the the status is reported. */ + private Integer evseId; + + /** The id of the connector within the EVSE for which the status is reported. */ + private Integer connectorId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the StatusNotificationRequest class + * + * @param timestamp The time for which the status is reported. + * @param connectorStatus The current status of the Connector. + * @param evseId The id of the EVSE to which the connector belongs for which the the status is + * reported. + * @param connectorId The id of the connector within the EVSE for which the status is reported. + */ + public StatusNotificationRequest( + ZonedDateTime timestamp, + ConnectorStatusEnum connectorStatus, + Integer evseId, + Integer connectorId) { + setTimestamp(timestamp); + setConnectorStatus(connectorStatus); + setEvseId(evseId); + setConnectorId(connectorId); + } + + /** + * Gets the time for which the status is reported. + * + * @return The time for which the status is reported + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets the time for which the status is reported. + * + * @param timestamp The time for which the status is reported + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets the current status of the Connector. + * + * @return The current status of the Connector + */ + public ConnectorStatusEnum getConnectorStatus() { + return connectorStatus; + } + + /** + * Sets the current status of the Connector. + * + * @param connectorStatus The current status of the Connector + */ + public void setConnectorStatus(ConnectorStatusEnum connectorStatus) { + if (!isValidConnectorStatus(connectorStatus)) { + throw new PropertyConstraintException(connectorStatus, "connectorStatus is invalid"); + } + this.connectorStatus = connectorStatus; + } + + /** + * Returns whether the given connectorStatus is valid + * + * @param connectorStatus the connectorStatus to check the validity of + * @return {@code true} if connectorStatus is valid, {@code false} if not + */ + private boolean isValidConnectorStatus(ConnectorStatusEnum connectorStatus) { + return connectorStatus != null; + } + + /** + * Gets the id of the EVSE to which the connector belongs for which the the status is reported. + * + * @return The id of the EVSE to which the connector belongs for which the the status is reported + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the id of the EVSE to which the connector belongs for which the the status is reported. + * + * @param evseId The id of the EVSE to which the connector belongs for which the the status is + * reported + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets the id of the connector within the EVSE for which the status is reported. + * + * @return The id of the connector within the EVSE for which the status is reported + */ + public Integer getConnectorId() { + return connectorId; + } + + /** + * Sets the id of the connector within the EVSE for which the status is reported. + * + * @param connectorId The id of the connector within the EVSE for which the status is reported + */ + public void setConnectorId(Integer connectorId) { + if (!isValidConnectorId(connectorId)) { + throw new PropertyConstraintException(connectorId, "connectorId is invalid"); + } + this.connectorId = connectorId; + } + + /** + * Returns whether the given connectorId is valid + * + * @param connectorId the connectorId to check the validity of + * @return {@code true} if connectorId is valid, {@code false} if not + */ + private boolean isValidConnectorId(Integer connectorId) { + return connectorId != null && connectorId >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public StatusNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTimestamp(timestamp) + && isValidConnectorStatus(connectorStatus) + && isValidEvseId(evseId) + && isValidConnectorId(connectorId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StatusNotificationRequest that = (StatusNotificationRequest) o; + return Objects.equals(timestamp, that.timestamp) + && Objects.equals(connectorStatus, that.connectorStatus) + && Objects.equals(evseId, that.evseId) + && Objects.equals(connectorId, that.connectorId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, connectorStatus, evseId, connectorId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("timestamp", timestamp) + .add("connectorStatus", connectorStatus) + .add("evseId", evseId) + .add("connectorId", connectorId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/StatusNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/StatusNotificationResponse.java new file mode 100644 index 00000000..d570ad2f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/StatusNotificationResponse.java @@ -0,0 +1,119 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * StatusNotificationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class StatusNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the StatusNotificationResponse class */ + public StatusNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public StatusNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StatusNotificationResponse that = (StatusNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TransactionEventRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TransactionEventRequest.java new file mode 100644 index 00000000..81ef19f0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TransactionEventRequest.java @@ -0,0 +1,864 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CostDetails; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.EVSE; +import eu.chargetime.ocpp.v21.model.types.IdToken; +import eu.chargetime.ocpp.v21.model.types.MeterValue; +import eu.chargetime.ocpp.v21.model.types.PreconditioningStatusEnum; +import eu.chargetime.ocpp.v21.model.types.Transaction; +import eu.chargetime.ocpp.v21.model.types.TransactionEventEnum; +import eu.chargetime.ocpp.v21.model.types.TriggerReasonEnum; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * TransactionEventRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class TransactionEventRequest extends RequestWithId { + /** + * CostDetailsType contains the cost as calculated by Charging Station based on provided + * TariffType. + * + *

NOTE: Reservation is not shown as a chargingPeriod, because it took place outside of the + * transaction. + */ + @Nullable private CostDetails costDetails; + + /** + * The type of this event. The first TransactionEvent of a transaction SHALL contain: "Started" + * The last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL contain: + * "Updated" + */ + private TransactionEventEnum eventType; + + /** + * Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + */ + @Nullable private MeterValue[] meterValue; + + /** The date and time at which this transaction event occurred. */ + private ZonedDateTime timestamp; + + /** Reason the Charging Station sends this message to the CSMS */ + private TriggerReasonEnum triggerReason; + + /** + * Incremental sequence number, helps with determining if all messages of a transaction have been + * received. + */ + private Integer seqNo; + + /** + * Indication that this transaction event happened when the Charging Station was offline. Default + * = false, meaning: the event occurred when the Charging Station was online. + */ + @Nullable private Boolean offline; + + /** + * If the Charging Station is able to report the number of phases used, then it SHALL provide it. + * + *

+   * When omitted the CSMS may be able to determine the number of phases used as follows:
+   * 1: The numberPhases in the currently used ChargingSchedule.
+   * 2: The number of phases provided via device management.
+   * 
+ */ + @Nullable private Integer numberOfPhasesUsed; + + /** The maximum current of the connected cable in Ampere (A). */ + @Nullable private Integer cableMaxCurrent; + + /** The Id of the reservation that terminates as a result of this transaction. */ + @Nullable private Integer reservationId; + + /** The current preconditioning status of the BMS in the EV. Default value is Unknown. */ + @Nullable private PreconditioningStatusEnum preconditioningStatus; + + /** + * True when EVSE electronics are in sleep mode for this transaction. Default value (when absent) + * is false. + */ + @Nullable private Boolean evseSleep; + + /** transactionInfo */ + private Transaction transactionInfo; + + /** Electric Vehicle Supply Equipment */ + @Nullable private EVSE evse; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken idToken; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TransactionEventRequest class + * + * @param eventType The type of this event. The first TransactionEvent of a transaction SHALL + * contain: "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All + * others SHALL contain: "Updated" + * @param timestamp The date and time at which this transaction event occurred. + * @param triggerReason Reason the Charging Station sends this message to the CSMS + * @param seqNo Incremental sequence number, helps with determining if all messages of a + * transaction have been received. + * @param transactionInfo transactionInfo + */ + public TransactionEventRequest( + TransactionEventEnum eventType, + ZonedDateTime timestamp, + TriggerReasonEnum triggerReason, + Integer seqNo, + Transaction transactionInfo) { + setEventType(eventType); + setTimestamp(timestamp); + setTriggerReason(triggerReason); + setSeqNo(seqNo); + setTransactionInfo(transactionInfo); + } + + /** + * Gets costDetailsType contains the cost as calculated by Charging Station based on provided + * TariffType. + * + * @return CostDetailsType contains the cost as calculated by Charging Station based on provided + * TariffType + */ + @Nullable + public CostDetails getCostDetails() { + return costDetails; + } + + /** + * Sets costDetailsType contains the cost as calculated by Charging Station based on provided + * TariffType. + * + * @param costDetails CostDetailsType contains the cost as calculated by Charging Station based on + * provided TariffType + */ + public void setCostDetails(@Nullable CostDetails costDetails) { + if (!isValidCostDetails(costDetails)) { + throw new PropertyConstraintException(costDetails, "costDetails is invalid"); + } + this.costDetails = costDetails; + } + + /** + * Returns whether the given costDetails is valid + * + * @param costDetails the costDetails to check the validity of + * @return {@code true} if costDetails is valid, {@code false} if not + */ + private boolean isValidCostDetails(@Nullable CostDetails costDetails) { + return costDetails == null || costDetails.validate(); + } + + /** + * Adds costDetailsType contains the cost as calculated by Charging Station based on provided + * TariffType. + * + * @param costDetails CostDetailsType contains the cost as calculated by Charging Station based on + * provided TariffType + * @return this + */ + public TransactionEventRequest withCostDetails(@Nullable CostDetails costDetails) { + setCostDetails(costDetails); + return this; + } + + /** + * Gets the type of this event. The first TransactionEvent of a transaction SHALL contain: + * "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL + * contain: "Updated" + * + * @return The type of this event + */ + public TransactionEventEnum getEventType() { + return eventType; + } + + /** + * Sets the type of this event. The first TransactionEvent of a transaction SHALL contain: + * "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL + * contain: "Updated" + * + * @param eventType The type of this event + */ + public void setEventType(TransactionEventEnum eventType) { + if (!isValidEventType(eventType)) { + throw new PropertyConstraintException(eventType, "eventType is invalid"); + } + this.eventType = eventType; + } + + /** + * Returns whether the given eventType is valid + * + * @param eventType the eventType to check the validity of + * @return {@code true} if eventType is valid, {@code false} if not + */ + private boolean isValidEventType(TransactionEventEnum eventType) { + return eventType != null; + } + + /** + * Gets collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @return Collection of one or more sampled values in MeterValuesRequest and TransactionEvent + */ + @Nullable + public MeterValue[] getMeterValue() { + return meterValue; + } + + /** + * Sets collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent + */ + public void setMeterValue(@Nullable MeterValue[] meterValue) { + if (!isValidMeterValue(meterValue)) { + throw new PropertyConstraintException(meterValue, "meterValue is invalid"); + } + this.meterValue = meterValue; + } + + /** + * Returns whether the given meterValue is valid + * + * @param meterValue the meterValue to check the validity of + * @return {@code true} if meterValue is valid, {@code false} if not + */ + private boolean isValidMeterValue(@Nullable MeterValue[] meterValue) { + return meterValue == null + || (meterValue.length >= 1 && Arrays.stream(meterValue).allMatch(item -> item.validate())); + } + + /** + * Adds collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent + * @return this + */ + public TransactionEventRequest withMeterValue(@Nullable MeterValue[] meterValue) { + setMeterValue(meterValue); + return this; + } + + /** + * Gets the date and time at which this transaction event occurred. + * + * @return The date and time at which this transaction event occurred + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets the date and time at which this transaction event occurred. + * + * @param timestamp The date and time at which this transaction event occurred + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets reason the Charging Station sends this message to the CSMS + * + * @return Reason the Charging Station sends this message to the CSMS + */ + public TriggerReasonEnum getTriggerReason() { + return triggerReason; + } + + /** + * Sets reason the Charging Station sends this message to the CSMS + * + * @param triggerReason Reason the Charging Station sends this message to the CSMS + */ + public void setTriggerReason(TriggerReasonEnum triggerReason) { + if (!isValidTriggerReason(triggerReason)) { + throw new PropertyConstraintException(triggerReason, "triggerReason is invalid"); + } + this.triggerReason = triggerReason; + } + + /** + * Returns whether the given triggerReason is valid + * + * @param triggerReason the triggerReason to check the validity of + * @return {@code true} if triggerReason is valid, {@code false} if not + */ + private boolean isValidTriggerReason(TriggerReasonEnum triggerReason) { + return triggerReason != null; + } + + /** + * Gets incremental sequence number, helps with determining if all messages of a transaction have + * been received. + * + * @return Incremental sequence number, helps with determining if all messages of a transaction + * have been received + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets incremental sequence number, helps with determining if all messages of a transaction have + * been received. + * + * @param seqNo Incremental sequence number, helps with determining if all messages of a + * transaction have been received + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null && seqNo >= 0; + } + + /** + * Gets indication that this transaction event happened when the Charging Station was offline. + * Default = false, meaning: the event occurred when the Charging Station was online. + * + * @return Indication that this transaction event happened when the Charging Station was offline + */ + public Boolean getOffline() { + return offline != null ? offline : false; + } + + /** + * Sets indication that this transaction event happened when the Charging Station was offline. + * Default = false, meaning: the event occurred when the Charging Station was online. + * + * @param offline Indication that this transaction event happened when the Charging Station was + * offline + */ + public void setOffline(@Nullable Boolean offline) { + this.offline = offline; + } + + /** + * Adds indication that this transaction event happened when the Charging Station was offline. + * Default = false, meaning: the event occurred when the Charging Station was online. + * + * @param offline Indication that this transaction event happened when the Charging Station was + * offline + * @return this + */ + public TransactionEventRequest withOffline(@Nullable Boolean offline) { + setOffline(offline); + return this; + } + + /** + * Gets if the Charging Station is able to report the number of phases used, then it SHALL provide + * it. + * + * @return If the Charging Station is able to report the number of phases used, then it SHALL + * provide it + */ + @Nullable + public Integer getNumberOfPhasesUsed() { + return numberOfPhasesUsed; + } + + /** + * Sets if the Charging Station is able to report the number of phases used, then it SHALL provide + * it. + * + * @param numberOfPhasesUsed If the Charging Station is able to report the number of phases used, + * then it SHALL provide it + */ + public void setNumberOfPhasesUsed(@Nullable Integer numberOfPhasesUsed) { + if (!isValidNumberOfPhasesUsed(numberOfPhasesUsed)) { + throw new PropertyConstraintException(numberOfPhasesUsed, "numberOfPhasesUsed is invalid"); + } + this.numberOfPhasesUsed = numberOfPhasesUsed; + } + + /** + * Returns whether the given numberOfPhasesUsed is valid + * + * @param numberOfPhasesUsed the numberOfPhasesUsed to check the validity of + * @return {@code true} if numberOfPhasesUsed is valid, {@code false} if not + */ + private boolean isValidNumberOfPhasesUsed(@Nullable Integer numberOfPhasesUsed) { + return numberOfPhasesUsed == null || (numberOfPhasesUsed >= 0 && numberOfPhasesUsed <= 3); + } + + /** + * Adds if the Charging Station is able to report the number of phases used, then it SHALL provide + * it. + * + * @param numberOfPhasesUsed If the Charging Station is able to report the number of phases used, + * then it SHALL provide it + * @return this + */ + public TransactionEventRequest withNumberOfPhasesUsed(@Nullable Integer numberOfPhasesUsed) { + setNumberOfPhasesUsed(numberOfPhasesUsed); + return this; + } + + /** + * Gets the maximum current of the connected cable in Ampere (A). + * + * @return The maximum current of the connected cable in Ampere (A) + */ + @Nullable + public Integer getCableMaxCurrent() { + return cableMaxCurrent; + } + + /** + * Sets the maximum current of the connected cable in Ampere (A). + * + * @param cableMaxCurrent The maximum current of the connected cable in Ampere (A) + */ + public void setCableMaxCurrent(@Nullable Integer cableMaxCurrent) { + this.cableMaxCurrent = cableMaxCurrent; + } + + /** + * Adds the maximum current of the connected cable in Ampere (A). + * + * @param cableMaxCurrent The maximum current of the connected cable in Ampere (A) + * @return this + */ + public TransactionEventRequest withCableMaxCurrent(@Nullable Integer cableMaxCurrent) { + setCableMaxCurrent(cableMaxCurrent); + return this; + } + + /** + * Gets the Id of the reservation that terminates as a result of this transaction. + * + * @return The Id of the reservation that terminates as a result of this transaction + */ + @Nullable + public Integer getReservationId() { + return reservationId; + } + + /** + * Sets the Id of the reservation that terminates as a result of this transaction. + * + * @param reservationId The Id of the reservation that terminates as a result of this transaction + */ + public void setReservationId(@Nullable Integer reservationId) { + if (!isValidReservationId(reservationId)) { + throw new PropertyConstraintException(reservationId, "reservationId is invalid"); + } + this.reservationId = reservationId; + } + + /** + * Returns whether the given reservationId is valid + * + * @param reservationId the reservationId to check the validity of + * @return {@code true} if reservationId is valid, {@code false} if not + */ + private boolean isValidReservationId(@Nullable Integer reservationId) { + return reservationId == null || (reservationId >= 0); + } + + /** + * Adds the Id of the reservation that terminates as a result of this transaction. + * + * @param reservationId The Id of the reservation that terminates as a result of this transaction + * @return this + */ + public TransactionEventRequest withReservationId(@Nullable Integer reservationId) { + setReservationId(reservationId); + return this; + } + + /** + * Gets the current preconditioning status of the BMS in the EV. Default value is Unknown. + * + * @return The current preconditioning status of the BMS in the EV + */ + @Nullable + public PreconditioningStatusEnum getPreconditioningStatus() { + return preconditioningStatus; + } + + /** + * Sets the current preconditioning status of the BMS in the EV. Default value is Unknown. + * + * @param preconditioningStatus The current preconditioning status of the BMS in the EV + */ + public void setPreconditioningStatus(@Nullable PreconditioningStatusEnum preconditioningStatus) { + this.preconditioningStatus = preconditioningStatus; + } + + /** + * Adds the current preconditioning status of the BMS in the EV. Default value is Unknown. + * + * @param preconditioningStatus The current preconditioning status of the BMS in the EV + * @return this + */ + public TransactionEventRequest withPreconditioningStatus( + @Nullable PreconditioningStatusEnum preconditioningStatus) { + setPreconditioningStatus(preconditioningStatus); + return this; + } + + /** + * Gets true when EVSE electronics are in sleep mode for this transaction. Default value (when + * absent) is false. + * + * @return True when EVSE electronics are in sleep mode for this transaction + */ + @Nullable + public Boolean getEvseSleep() { + return evseSleep; + } + + /** + * Sets true when EVSE electronics are in sleep mode for this transaction. Default value (when + * absent) is false. + * + * @param evseSleep True when EVSE electronics are in sleep mode for this transaction + */ + public void setEvseSleep(@Nullable Boolean evseSleep) { + this.evseSleep = evseSleep; + } + + /** + * Adds true when EVSE electronics are in sleep mode for this transaction. Default value (when + * absent) is false. + * + * @param evseSleep True when EVSE electronics are in sleep mode for this transaction + * @return this + */ + public TransactionEventRequest withEvseSleep(@Nullable Boolean evseSleep) { + setEvseSleep(evseSleep); + return this; + } + + /** + * Gets transactionInfo + * + * @return transactionInfo + */ + public Transaction getTransactionInfo() { + return transactionInfo; + } + + /** + * Sets transactionInfo + * + * @param transactionInfo transactionInfo + */ + public void setTransactionInfo(Transaction transactionInfo) { + if (!isValidTransactionInfo(transactionInfo)) { + throw new PropertyConstraintException(transactionInfo, "transactionInfo is invalid"); + } + this.transactionInfo = transactionInfo; + } + + /** + * Returns whether the given transactionInfo is valid + * + * @param transactionInfo the transactionInfo to check the validity of + * @return {@code true} if transactionInfo is valid, {@code false} if not + */ + private boolean isValidTransactionInfo(Transaction transactionInfo) { + return transactionInfo != null && transactionInfo.validate(); + } + + /** + * Gets electric Vehicle Supply Equipment + * + * @return Electric Vehicle Supply Equipment + */ + @Nullable + public EVSE getEvse() { + return evse; + } + + /** + * Sets electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + */ + public void setEvse(@Nullable EVSE evse) { + if (!isValidEvse(evse)) { + throw new PropertyConstraintException(evse, "evse is invalid"); + } + this.evse = evse; + } + + /** + * Returns whether the given evse is valid + * + * @param evse the evse to check the validity of + * @return {@code true} if evse is valid, {@code false} if not + */ + private boolean isValidEvse(@Nullable EVSE evse) { + return evse == null || evse.validate(); + } + + /** + * Adds electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + * @return this + */ + public TransactionEventRequest withEvse(@Nullable EVSE evse) { + setEvse(evse); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(@Nullable IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(@Nullable IdToken idToken) { + return idToken == null || idToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public TransactionEventRequest withIdToken(@Nullable IdToken idToken) { + setIdToken(idToken); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TransactionEventRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCostDetails(costDetails) + && isValidEventType(eventType) + && isValidMeterValue(meterValue) + && isValidTimestamp(timestamp) + && isValidTriggerReason(triggerReason) + && isValidSeqNo(seqNo) + && isValidNumberOfPhasesUsed(numberOfPhasesUsed) + && isValidReservationId(reservationId) + && isValidTransactionInfo(transactionInfo) + && isValidEvse(evse) + && isValidIdToken(idToken) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return true; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransactionEventRequest that = (TransactionEventRequest) o; + return Objects.equals(costDetails, that.costDetails) + && Objects.equals(eventType, that.eventType) + && Arrays.equals(meterValue, that.meterValue) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(triggerReason, that.triggerReason) + && Objects.equals(seqNo, that.seqNo) + && Objects.equals(offline, that.offline) + && Objects.equals(numberOfPhasesUsed, that.numberOfPhasesUsed) + && Objects.equals(cableMaxCurrent, that.cableMaxCurrent) + && Objects.equals(reservationId, that.reservationId) + && Objects.equals(preconditioningStatus, that.preconditioningStatus) + && Objects.equals(evseSleep, that.evseSleep) + && Objects.equals(transactionInfo, that.transactionInfo) + && Objects.equals(evse, that.evse) + && Objects.equals(idToken, that.idToken) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + costDetails, + eventType, + Arrays.hashCode(meterValue), + timestamp, + triggerReason, + seqNo, + offline, + numberOfPhasesUsed, + cableMaxCurrent, + reservationId, + preconditioningStatus, + evseSleep, + transactionInfo, + evse, + idToken, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("costDetails", costDetails) + .add("eventType", eventType) + .add("meterValue", meterValue) + .add("timestamp", timestamp) + .add("triggerReason", triggerReason) + .add("seqNo", seqNo) + .add("offline", offline) + .add("numberOfPhasesUsed", numberOfPhasesUsed) + .add("cableMaxCurrent", cableMaxCurrent) + .add("reservationId", reservationId) + .add("preconditioningStatus", preconditioningStatus) + .add("evseSleep", evseSleep) + .add("transactionInfo", transactionInfo) + .add("evse", evse) + .add("idToken", idToken) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TransactionEventResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TransactionEventResponse.java new file mode 100644 index 00000000..3ef3d326 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TransactionEventResponse.java @@ -0,0 +1,455 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.IdTokenInfo; +import eu.chargetime.ocpp.v21.model.types.MessageContent; +import eu.chargetime.ocpp.v21.model.types.TransactionLimit; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * TransactionEventResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class TransactionEventResponse extends Confirmation { + /** + * When eventType of TransactionEventRequest is Updated, then this value contains the running + * cost. When eventType of TransactionEventRequest is Ended, then this contains the final total + * cost of this transaction, including taxes, in the currency configured with the Configuration + * Variable: Currency. Absence of this value does not imply that the transaction was free. To + * indicate a free transaction, the CSMS SHALL send a value of 0.00. + */ + @Nullable private Double totalCost; + + /** + * Priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse is + * temporarily, so it may not be set in the IdTokenInfoType afterwards. Also the chargingPriority + * in TransactionEventResponse has a higher priority than the one in IdTokenInfoType. + */ + @Nullable private Integer chargingPriority; + + /** + * Status information about an identifier. It is advised to not stop charging for a token that + * expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not + * given, the status has no end date. + */ + @Nullable private IdTokenInfo idTokenInfo; + + /** Cost, energy, time or SoC limit for a transaction. */ + @Nullable private TransactionLimit transactionLimit; + + /** Message details, for a message to be displayed on a Charging Station. */ + @Nullable private MessageContent updatedPersonalMessage; + + /** Message details, for a message to be displayed on a Charging Station. */ + @Nullable private MessageContent[] updatedPersonalMessageExtra; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the TransactionEventResponse class */ + public TransactionEventResponse() {} + + /** + * Gets when eventType of TransactionEventRequest is Updated, then this value contains the running + * cost. When eventType of TransactionEventRequest is Ended, then this contains the final total + * cost of this transaction, including taxes, in the currency configured with the Configuration + * Variable: Currency. Absence of this value does not imply that the transaction was free. To + * indicate a free transaction, the CSMS SHALL send a value of 0.00. + * + * @return When eventType of TransactionEventRequest is Updated, then this value contains the + * running cost + */ + @Nullable + public Double getTotalCost() { + return totalCost; + } + + /** + * Sets when eventType of TransactionEventRequest is Updated, then this value contains the running + * cost. When eventType of TransactionEventRequest is Ended, then this contains the final total + * cost of this transaction, including taxes, in the currency configured with the Configuration + * Variable: Currency. Absence of this value does not imply that the transaction was free. To + * indicate a free transaction, the CSMS SHALL send a value of 0.00. + * + * @param totalCost When eventType of TransactionEventRequest is Updated, then this value contains + * the running cost + */ + public void setTotalCost(@Nullable Double totalCost) { + this.totalCost = totalCost; + } + + /** + * Adds when eventType of TransactionEventRequest is Updated, then this value contains the running + * cost. When eventType of TransactionEventRequest is Ended, then this contains the final total + * cost of this transaction, including taxes, in the currency configured with the Configuration + * Variable: Currency. Absence of this value does not imply that the transaction was free. To + * indicate a free transaction, the CSMS SHALL send a value of 0.00. + * + * @param totalCost When eventType of TransactionEventRequest is Updated, then this value contains + * the running cost + * @return this + */ + public TransactionEventResponse withTotalCost(@Nullable Double totalCost) { + setTotalCost(totalCost); + return this; + } + + /** + * Gets priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse is + * temporarily, so it may not be set in the IdTokenInfoType afterwards. Also the chargingPriority + * in TransactionEventResponse has a higher priority than the one in IdTokenInfoType. + * + * @return Priority from a business point of view + */ + @Nullable + public Integer getChargingPriority() { + return chargingPriority; + } + + /** + * Sets priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse is + * temporarily, so it may not be set in the IdTokenInfoType afterwards. Also the chargingPriority + * in TransactionEventResponse has a higher priority than the one in IdTokenInfoType. + * + * @param chargingPriority Priority from a business point of view + */ + public void setChargingPriority(@Nullable Integer chargingPriority) { + this.chargingPriority = chargingPriority; + } + + /** + * Adds priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse is + * temporarily, so it may not be set in the IdTokenInfoType afterwards. Also the chargingPriority + * in TransactionEventResponse has a higher priority than the one in IdTokenInfoType. + * + * @param chargingPriority Priority from a business point of view + * @return this + */ + public TransactionEventResponse withChargingPriority(@Nullable Integer chargingPriority) { + setChargingPriority(chargingPriority); + return this; + } + + /** + * Gets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @return Status information about an identifier + */ + @Nullable + public IdTokenInfo getIdTokenInfo() { + return idTokenInfo; + } + + /** + * Sets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + */ + public void setIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + if (!isValidIdTokenInfo(idTokenInfo)) { + throw new PropertyConstraintException(idTokenInfo, "idTokenInfo is invalid"); + } + this.idTokenInfo = idTokenInfo; + } + + /** + * Returns whether the given idTokenInfo is valid + * + * @param idTokenInfo the idTokenInfo to check the validity of + * @return {@code true} if idTokenInfo is valid, {@code false} if not + */ + private boolean isValidIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + return idTokenInfo == null || idTokenInfo.validate(); + } + + /** + * Adds status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + * @return this + */ + public TransactionEventResponse withIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + setIdTokenInfo(idTokenInfo); + return this; + } + + /** + * Gets cost, energy, time or SoC limit for a transaction. + * + * @return Cost, energy, time or SoC limit for a transaction + */ + @Nullable + public TransactionLimit getTransactionLimit() { + return transactionLimit; + } + + /** + * Sets cost, energy, time or SoC limit for a transaction. + * + * @param transactionLimit Cost, energy, time or SoC limit for a transaction + */ + public void setTransactionLimit(@Nullable TransactionLimit transactionLimit) { + if (!isValidTransactionLimit(transactionLimit)) { + throw new PropertyConstraintException(transactionLimit, "transactionLimit is invalid"); + } + this.transactionLimit = transactionLimit; + } + + /** + * Returns whether the given transactionLimit is valid + * + * @param transactionLimit the transactionLimit to check the validity of + * @return {@code true} if transactionLimit is valid, {@code false} if not + */ + private boolean isValidTransactionLimit(@Nullable TransactionLimit transactionLimit) { + return transactionLimit == null || transactionLimit.validate(); + } + + /** + * Adds cost, energy, time or SoC limit for a transaction. + * + * @param transactionLimit Cost, energy, time or SoC limit for a transaction + * @return this + */ + public TransactionEventResponse withTransactionLimit( + @Nullable TransactionLimit transactionLimit) { + setTransactionLimit(transactionLimit); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageContent getUpdatedPersonalMessage() { + return updatedPersonalMessage; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param updatedPersonalMessage Message details, for a message to be displayed on a Charging + * Station + */ + public void setUpdatedPersonalMessage(@Nullable MessageContent updatedPersonalMessage) { + if (!isValidUpdatedPersonalMessage(updatedPersonalMessage)) { + throw new PropertyConstraintException( + updatedPersonalMessage, "updatedPersonalMessage is invalid"); + } + this.updatedPersonalMessage = updatedPersonalMessage; + } + + /** + * Returns whether the given updatedPersonalMessage is valid + * + * @param updatedPersonalMessage the updatedPersonalMessage to check the validity of + * @return {@code true} if updatedPersonalMessage is valid, {@code false} if not + */ + private boolean isValidUpdatedPersonalMessage(@Nullable MessageContent updatedPersonalMessage) { + return updatedPersonalMessage == null || updatedPersonalMessage.validate(); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param updatedPersonalMessage Message details, for a message to be displayed on a Charging + * Station + * @return this + */ + public TransactionEventResponse withUpdatedPersonalMessage( + @Nullable MessageContent updatedPersonalMessage) { + setUpdatedPersonalMessage(updatedPersonalMessage); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageContent[] getUpdatedPersonalMessageExtra() { + return updatedPersonalMessageExtra; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param updatedPersonalMessageExtra Message details, for a message to be displayed on a Charging + * Station + */ + public void setUpdatedPersonalMessageExtra( + @Nullable MessageContent[] updatedPersonalMessageExtra) { + if (!isValidUpdatedPersonalMessageExtra(updatedPersonalMessageExtra)) { + throw new PropertyConstraintException( + updatedPersonalMessageExtra, "updatedPersonalMessageExtra is invalid"); + } + this.updatedPersonalMessageExtra = updatedPersonalMessageExtra; + } + + /** + * Returns whether the given updatedPersonalMessageExtra is valid + * + * @param updatedPersonalMessageExtra the updatedPersonalMessageExtra to check the validity of + * @return {@code true} if updatedPersonalMessageExtra is valid, {@code false} if not + */ + private boolean isValidUpdatedPersonalMessageExtra( + @Nullable MessageContent[] updatedPersonalMessageExtra) { + return updatedPersonalMessageExtra == null + || (updatedPersonalMessageExtra.length >= 1 + && updatedPersonalMessageExtra.length <= 4 + && Arrays.stream(updatedPersonalMessageExtra).allMatch(item -> item.validate())); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param updatedPersonalMessageExtra Message details, for a message to be displayed on a Charging + * Station + * @return this + */ + public TransactionEventResponse withUpdatedPersonalMessageExtra( + @Nullable MessageContent[] updatedPersonalMessageExtra) { + setUpdatedPersonalMessageExtra(updatedPersonalMessageExtra); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TransactionEventResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidIdTokenInfo(idTokenInfo) + && isValidTransactionLimit(transactionLimit) + && isValidUpdatedPersonalMessage(updatedPersonalMessage) + && isValidUpdatedPersonalMessageExtra(updatedPersonalMessageExtra) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransactionEventResponse that = (TransactionEventResponse) o; + return Objects.equals(totalCost, that.totalCost) + && Objects.equals(chargingPriority, that.chargingPriority) + && Objects.equals(idTokenInfo, that.idTokenInfo) + && Objects.equals(transactionLimit, that.transactionLimit) + && Objects.equals(updatedPersonalMessage, that.updatedPersonalMessage) + && Arrays.equals(updatedPersonalMessageExtra, that.updatedPersonalMessageExtra) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + totalCost, + chargingPriority, + idTokenInfo, + transactionLimit, + updatedPersonalMessage, + Arrays.hashCode(updatedPersonalMessageExtra), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("totalCost", totalCost) + .add("chargingPriority", chargingPriority) + .add("idTokenInfo", idTokenInfo) + .add("transactionLimit", transactionLimit) + .add("updatedPersonalMessage", updatedPersonalMessage) + .add("updatedPersonalMessageExtra", updatedPersonalMessageExtra) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TriggerMessageRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TriggerMessageRequest.java new file mode 100644 index 00000000..ada27bee --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TriggerMessageRequest.java @@ -0,0 +1,276 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.EVSE; +import eu.chargetime.ocpp.v21.model.types.MessageTriggerEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * TriggerMessageRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class TriggerMessageRequest extends RequestWithId { + /** Electric Vehicle Supply Equipment */ + @Nullable private EVSE evse; + + /** Type of message to be triggered. */ + private MessageTriggerEnum requestedMessage; + + /** + * When requestedMessage = `CustomTrigger` this will trigger sending the corresponding message in + * field customTrigger, if supported by Charging Station. + */ + @Nullable private String customTrigger; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TriggerMessageRequest class + * + * @param requestedMessage Type of message to be triggered. + */ + public TriggerMessageRequest(MessageTriggerEnum requestedMessage) { + setRequestedMessage(requestedMessage); + } + + /** + * Gets electric Vehicle Supply Equipment + * + * @return Electric Vehicle Supply Equipment + */ + @Nullable + public EVSE getEvse() { + return evse; + } + + /** + * Sets electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + */ + public void setEvse(@Nullable EVSE evse) { + if (!isValidEvse(evse)) { + throw new PropertyConstraintException(evse, "evse is invalid"); + } + this.evse = evse; + } + + /** + * Returns whether the given evse is valid + * + * @param evse the evse to check the validity of + * @return {@code true} if evse is valid, {@code false} if not + */ + private boolean isValidEvse(@Nullable EVSE evse) { + return evse == null || evse.validate(); + } + + /** + * Adds electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + * @return this + */ + public TriggerMessageRequest withEvse(@Nullable EVSE evse) { + setEvse(evse); + return this; + } + + /** + * Gets type of message to be triggered. + * + * @return Type of message to be triggered + */ + public MessageTriggerEnum getRequestedMessage() { + return requestedMessage; + } + + /** + * Sets type of message to be triggered. + * + * @param requestedMessage Type of message to be triggered + */ + public void setRequestedMessage(MessageTriggerEnum requestedMessage) { + if (!isValidRequestedMessage(requestedMessage)) { + throw new PropertyConstraintException(requestedMessage, "requestedMessage is invalid"); + } + this.requestedMessage = requestedMessage; + } + + /** + * Returns whether the given requestedMessage is valid + * + * @param requestedMessage the requestedMessage to check the validity of + * @return {@code true} if requestedMessage is valid, {@code false} if not + */ + private boolean isValidRequestedMessage(MessageTriggerEnum requestedMessage) { + return requestedMessage != null; + } + + /** + * Gets when requestedMessage = `CustomTrigger` this will trigger sending the corresponding + * message in field customTrigger, if supported by Charging Station. + * + * @return When requestedMessage = `CustomTrigger` this will trigger sending the corresponding + * message in field customTrigger, if supported by Charging Station + */ + @Nullable + public String getCustomTrigger() { + return customTrigger; + } + + /** + * Sets when requestedMessage = `CustomTrigger` this will trigger sending the corresponding + * message in field customTrigger, if supported by Charging Station. + * + * @param customTrigger When requestedMessage = `CustomTrigger` this will trigger sending the + * corresponding message in field customTrigger, if supported by Charging Station + */ + public void setCustomTrigger(@Nullable String customTrigger) { + if (!isValidCustomTrigger(customTrigger)) { + throw new PropertyConstraintException(customTrigger, "customTrigger is invalid"); + } + this.customTrigger = customTrigger; + } + + /** + * Returns whether the given customTrigger is valid + * + * @param customTrigger the customTrigger to check the validity of + * @return {@code true} if customTrigger is valid, {@code false} if not + */ + private boolean isValidCustomTrigger(@Nullable String customTrigger) { + return customTrigger == null || customTrigger.length() <= 50; + } + + /** + * Adds when requestedMessage = `CustomTrigger` this will trigger sending the corresponding + * message in field customTrigger, if supported by Charging Station. + * + * @param customTrigger When requestedMessage = `CustomTrigger` this will trigger sending the + * corresponding message in field customTrigger, if supported by Charging Station + * @return this + */ + public TriggerMessageRequest withCustomTrigger(@Nullable String customTrigger) { + setCustomTrigger(customTrigger); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TriggerMessageRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvse(evse) + && isValidRequestedMessage(requestedMessage) + && isValidCustomTrigger(customTrigger) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerMessageRequest that = (TriggerMessageRequest) o; + return Objects.equals(evse, that.evse) + && Objects.equals(requestedMessage, that.requestedMessage) + && Objects.equals(customTrigger, that.customTrigger) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evse, requestedMessage, customTrigger, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evse", evse) + .add("requestedMessage", requestedMessage) + .add("customTrigger", customTrigger) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TriggerMessageResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TriggerMessageResponse.java new file mode 100644 index 00000000..6b0f41ce --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/TriggerMessageResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import eu.chargetime.ocpp.v21.model.types.TriggerMessageStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * TriggerMessageResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class TriggerMessageResponse extends Confirmation { + /** Whether the Charging Station will send the requested notification or not. */ + private TriggerMessageStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TriggerMessageResponse class + * + * @param status Whether the Charging Station will send the requested notification or not. + */ + public TriggerMessageResponse(TriggerMessageStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station will send the requested notification or not. + * + * @return Whether the Charging Station will send the requested notification or not + */ + public TriggerMessageStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station will send the requested notification or not. + * + * @param status Whether the Charging Station will send the requested notification or not + */ + public void setStatus(TriggerMessageStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(TriggerMessageStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public TriggerMessageResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TriggerMessageResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerMessageResponse that = (TriggerMessageResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnlockConnectorRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnlockConnectorRequest.java new file mode 100644 index 00000000..361c62aa --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnlockConnectorRequest.java @@ -0,0 +1,206 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UnlockConnectorRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UnlockConnectorRequest extends RequestWithId { + /** The identifier of the EVSE for which a connector needs to be unlocked. */ + private Integer evseId; + + /** The identifier of the connector that needs to be unlocked. */ + private Integer connectorId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UnlockConnectorRequest class + * + * @param evseId The identifier of the EVSE for which a connector needs to be unlocked. + * @param connectorId The identifier of the connector that needs to be unlocked. + */ + public UnlockConnectorRequest(Integer evseId, Integer connectorId) { + setEvseId(evseId); + setConnectorId(connectorId); + } + + /** + * Gets the identifier of the EVSE for which a connector needs to be unlocked. + * + * @return The identifier of the EVSE for which a connector needs to be unlocked + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the identifier of the EVSE for which a connector needs to be unlocked. + * + * @param evseId The identifier of the EVSE for which a connector needs to be unlocked + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets the identifier of the connector that needs to be unlocked. + * + * @return The identifier of the connector that needs to be unlocked + */ + public Integer getConnectorId() { + return connectorId; + } + + /** + * Sets the identifier of the connector that needs to be unlocked. + * + * @param connectorId The identifier of the connector that needs to be unlocked + */ + public void setConnectorId(Integer connectorId) { + if (!isValidConnectorId(connectorId)) { + throw new PropertyConstraintException(connectorId, "connectorId is invalid"); + } + this.connectorId = connectorId; + } + + /** + * Returns whether the given connectorId is valid + * + * @param connectorId the connectorId to check the validity of + * @return {@code true} if connectorId is valid, {@code false} if not + */ + private boolean isValidConnectorId(Integer connectorId) { + return connectorId != null && connectorId >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnlockConnectorRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidEvseId(evseId) + && isValidConnectorId(connectorId) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnlockConnectorRequest that = (UnlockConnectorRequest) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(connectorId, that.connectorId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, connectorId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("connectorId", connectorId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnlockConnectorResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnlockConnectorResponse.java new file mode 100644 index 00000000..e1d753b1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnlockConnectorResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import eu.chargetime.ocpp.v21.model.types.UnlockStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UnlockConnectorResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UnlockConnectorResponse extends Confirmation { + /** Whether the Charging Station has unlocked the connector. */ + private UnlockStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UnlockConnectorResponse class + * + * @param status Whether the Charging Station has unlocked the connector. + */ + public UnlockConnectorResponse(UnlockStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Charging Station has unlocked the connector. + * + * @return Whether the Charging Station has unlocked the connector + */ + public UnlockStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station has unlocked the connector. + * + * @param status Whether the Charging Station has unlocked the connector + */ + public void setStatus(UnlockStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(UnlockStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public UnlockConnectorResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnlockConnectorResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnlockConnectorResponse that = (UnlockConnectorResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnpublishFirmwareRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnpublishFirmwareRequest.java new file mode 100644 index 00000000..bb476797 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnpublishFirmwareRequest.java @@ -0,0 +1,167 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UnpublishFirmwareRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UnpublishFirmwareRequest extends RequestWithId { + /** The MD5 checksum over the entire firmware file as a hexadecimal string of length 32. */ + private String checksum; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UnpublishFirmwareRequest class + * + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32. + */ + public UnpublishFirmwareRequest(String checksum) { + setChecksum(checksum); + } + + /** + * Gets the MD5 checksum over the entire firmware file as a hexadecimal string of length 32. + * + * @return The MD5 checksum over the entire firmware file as a hexadecimal string of length 32 + */ + public String getChecksum() { + return checksum; + } + + /** + * Sets the MD5 checksum over the entire firmware file as a hexadecimal string of length 32. + * + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32 + */ + public void setChecksum(String checksum) { + if (!isValidChecksum(checksum)) { + throw new PropertyConstraintException(checksum, "checksum is invalid"); + } + this.checksum = checksum; + } + + /** + * Returns whether the given checksum is valid + * + * @param checksum the checksum to check the validity of + * @return {@code true} if checksum is valid, {@code false} if not + */ + private boolean isValidChecksum(String checksum) { + return checksum != null && checksum.length() <= 32; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnpublishFirmwareRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidChecksum(checksum) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnpublishFirmwareRequest that = (UnpublishFirmwareRequest) o; + return Objects.equals(checksum, that.checksum) && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(checksum, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("checksum", checksum) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnpublishFirmwareResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnpublishFirmwareResponse.java new file mode 100644 index 00000000..44702840 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UnpublishFirmwareResponse.java @@ -0,0 +1,161 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.UnpublishFirmwareStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UnpublishFirmwareResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UnpublishFirmwareResponse extends Confirmation { + /** Whether the Local Controller succeeded in unpublishing the firmware. */ + private UnpublishFirmwareStatusEnum status; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UnpublishFirmwareResponse class + * + * @param status Whether the Local Controller succeeded in unpublishing the firmware. + */ + public UnpublishFirmwareResponse(UnpublishFirmwareStatusEnum status) { + setStatus(status); + } + + /** + * Gets whether the Local Controller succeeded in unpublishing the firmware. + * + * @return Whether the Local Controller succeeded in unpublishing the firmware + */ + public UnpublishFirmwareStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Local Controller succeeded in unpublishing the firmware. + * + * @param status Whether the Local Controller succeeded in unpublishing the firmware + */ + public void setStatus(UnpublishFirmwareStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(UnpublishFirmwareStatusEnum status) { + return status != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnpublishFirmwareResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnpublishFirmwareResponse that = (UnpublishFirmwareResponse) o; + return Objects.equals(status, that.status) && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateDynamicScheduleRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateDynamicScheduleRequest.java new file mode 100644 index 00000000..eaa52d00 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateDynamicScheduleRequest.java @@ -0,0 +1,208 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingScheduleUpdate; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Id of dynamic charging profile to update. + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UpdateDynamicScheduleRequest extends RequestWithId { + /** Id of charging profile to update. */ + private Integer chargingProfileId; + + /** Updates to a ChargingSchedulePeriodType for dynamic charging profiles. */ + private ChargingScheduleUpdate scheduleUpdate; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UpdateDynamicScheduleRequest class + * + * @param chargingProfileId Id of charging profile to update. + * @param scheduleUpdate Updates to a ChargingSchedulePeriodType for dynamic charging profiles. + */ + public UpdateDynamicScheduleRequest( + Integer chargingProfileId, ChargingScheduleUpdate scheduleUpdate) { + setChargingProfileId(chargingProfileId); + setScheduleUpdate(scheduleUpdate); + } + + /** + * Gets id of charging profile to update. + * + * @return Id of charging profile to update + */ + public Integer getChargingProfileId() { + return chargingProfileId; + } + + /** + * Sets id of charging profile to update. + * + * @param chargingProfileId Id of charging profile to update + */ + public void setChargingProfileId(Integer chargingProfileId) { + if (!isValidChargingProfileId(chargingProfileId)) { + throw new PropertyConstraintException(chargingProfileId, "chargingProfileId is invalid"); + } + this.chargingProfileId = chargingProfileId; + } + + /** + * Returns whether the given chargingProfileId is valid + * + * @param chargingProfileId the chargingProfileId to check the validity of + * @return {@code true} if chargingProfileId is valid, {@code false} if not + */ + private boolean isValidChargingProfileId(Integer chargingProfileId) { + return chargingProfileId != null; + } + + /** + * Gets updates to a ChargingSchedulePeriodType for dynamic charging profiles. + * + * @return Updates to a ChargingSchedulePeriodType for dynamic charging profiles + */ + public ChargingScheduleUpdate getScheduleUpdate() { + return scheduleUpdate; + } + + /** + * Sets updates to a ChargingSchedulePeriodType for dynamic charging profiles. + * + * @param scheduleUpdate Updates to a ChargingSchedulePeriodType for dynamic charging profiles + */ + public void setScheduleUpdate(ChargingScheduleUpdate scheduleUpdate) { + if (!isValidScheduleUpdate(scheduleUpdate)) { + throw new PropertyConstraintException(scheduleUpdate, "scheduleUpdate is invalid"); + } + this.scheduleUpdate = scheduleUpdate; + } + + /** + * Returns whether the given scheduleUpdate is valid + * + * @param scheduleUpdate the scheduleUpdate to check the validity of + * @return {@code true} if scheduleUpdate is valid, {@code false} if not + */ + private boolean isValidScheduleUpdate(ChargingScheduleUpdate scheduleUpdate) { + return scheduleUpdate != null && scheduleUpdate.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UpdateDynamicScheduleRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidChargingProfileId(chargingProfileId) + && isValidScheduleUpdate(scheduleUpdate) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateDynamicScheduleRequest that = (UpdateDynamicScheduleRequest) o; + return Objects.equals(chargingProfileId, that.chargingProfileId) + && Objects.equals(scheduleUpdate, that.scheduleUpdate) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(chargingProfileId, scheduleUpdate, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingProfileId", chargingProfileId) + .add("scheduleUpdate", scheduleUpdate) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateDynamicScheduleResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateDynamicScheduleResponse.java new file mode 100644 index 00000000..913ec9bb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateDynamicScheduleResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.ChargingProfileStatusEnum; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UpdateDynamicScheduleResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UpdateDynamicScheduleResponse extends Confirmation { + /** Returns whether message was processed successfully. */ + private ChargingProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UpdateDynamicScheduleResponse class + * + * @param status Returns whether message was processed successfully. + */ + public UpdateDynamicScheduleResponse(ChargingProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets returns whether message was processed successfully. + * + * @return Returns whether message was processed successfully + */ + public ChargingProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether message was processed successfully. + * + * @param status Returns whether message was processed successfully + */ + public void setStatus(ChargingProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ChargingProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public UpdateDynamicScheduleResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UpdateDynamicScheduleResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateDynamicScheduleResponse that = (UpdateDynamicScheduleResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateFirmwareRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateFirmwareRequest.java new file mode 100644 index 00000000..8b300225 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateFirmwareRequest.java @@ -0,0 +1,309 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.Firmware; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UpdateFirmwareRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UpdateFirmwareRequest extends RequestWithId { + /** + * How many times Charging Station must retry to download the firmware before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + */ + @Nullable private Integer retries; + + /** + * The interval in seconds after which a retry may be attempted. If this field is not present, it + * is left to Charging Station to decide how long to wait between attempts. + */ + @Nullable private Integer retryInterval; + + /** The Id of this request */ + private Integer requestId; + + /** A copy of the firmware that can be loaded/updated on the Charging Station. */ + private Firmware firmware; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UpdateFirmwareRequest class + * + * @param requestId The Id of this request + * @param firmware A copy of the firmware that can be loaded/updated on the Charging Station. + */ + public UpdateFirmwareRequest(Integer requestId, Firmware firmware) { + setRequestId(requestId); + setFirmware(firmware); + } + + /** + * Gets how many times Charging Station must retry to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @return How many times Charging Station must retry to download the firmware before giving up + */ + @Nullable + public Integer getRetries() { + return retries; + } + + /** + * Sets how many times Charging Station must retry to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @param retries How many times Charging Station must retry to download the firmware before + * giving up + */ + public void setRetries(@Nullable Integer retries) { + if (!isValidRetries(retries)) { + throw new PropertyConstraintException(retries, "retries is invalid"); + } + this.retries = retries; + } + + /** + * Returns whether the given retries is valid + * + * @param retries the retries to check the validity of + * @return {@code true} if retries is valid, {@code false} if not + */ + private boolean isValidRetries(@Nullable Integer retries) { + return retries == null || (retries >= 0); + } + + /** + * Adds how many times Charging Station must retry to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. If the value is 0, it means: no retries. + * + * @param retries How many times Charging Station must retry to download the firmware before + * giving up + * @return this + */ + public UpdateFirmwareRequest withRetries(@Nullable Integer retries) { + setRetries(retries); + return this; + } + + /** + * Gets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @return The interval in seconds after which a retry may be attempted + */ + @Nullable + public Integer getRetryInterval() { + return retryInterval; + } + + /** + * Sets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + */ + public void setRetryInterval(@Nullable Integer retryInterval) { + this.retryInterval = retryInterval; + } + + /** + * Adds the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + * @return this + */ + public UpdateFirmwareRequest withRetryInterval(@Nullable Integer retryInterval) { + setRetryInterval(retryInterval); + return this; + } + + /** + * Gets the Id of this request + * + * @return The Id of this request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of this request + * + * @param requestId The Id of this request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets a copy of the firmware that can be loaded/updated on the Charging Station. + * + * @return A copy of the firmware that can be loaded/updated on the Charging Station + */ + public Firmware getFirmware() { + return firmware; + } + + /** + * Sets a copy of the firmware that can be loaded/updated on the Charging Station. + * + * @param firmware A copy of the firmware that can be loaded/updated on the Charging Station + */ + public void setFirmware(Firmware firmware) { + if (!isValidFirmware(firmware)) { + throw new PropertyConstraintException(firmware, "firmware is invalid"); + } + this.firmware = firmware; + } + + /** + * Returns whether the given firmware is valid + * + * @param firmware the firmware to check the validity of + * @return {@code true} if firmware is valid, {@code false} if not + */ + private boolean isValidFirmware(Firmware firmware) { + return firmware != null && firmware.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UpdateFirmwareRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidRetries(retries) + && isValidRequestId(requestId) + && isValidFirmware(firmware) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateFirmwareRequest that = (UpdateFirmwareRequest) o; + return Objects.equals(retries, that.retries) + && Objects.equals(retryInterval, that.retryInterval) + && Objects.equals(requestId, that.requestId) + && Objects.equals(firmware, that.firmware) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(retries, retryInterval, requestId, firmware, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("retries", retries) + .add("retryInterval", retryInterval) + .add("requestId", requestId) + .add("firmware", firmware) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateFirmwareResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateFirmwareResponse.java new file mode 100644 index 00000000..19ca20fa --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UpdateFirmwareResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import eu.chargetime.ocpp.v21.model.types.UpdateFirmwareStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UpdateFirmwareResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UpdateFirmwareResponse extends Confirmation { + /** This field indicates whether the Charging Station was able to accept the request. */ + private UpdateFirmwareStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UpdateFirmwareResponse class + * + * @param status This field indicates whether the Charging Station was able to accept the request. + */ + public UpdateFirmwareResponse(UpdateFirmwareStatusEnum status) { + setStatus(status); + } + + /** + * Gets this field indicates whether the Charging Station was able to accept the request. + * + * @return This field indicates whether the Charging Station was able to accept the request + */ + public UpdateFirmwareStatusEnum getStatus() { + return status; + } + + /** + * Sets this field indicates whether the Charging Station was able to accept the request. + * + * @param status This field indicates whether the Charging Station was able to accept the request + */ + public void setStatus(UpdateFirmwareStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(UpdateFirmwareStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public UpdateFirmwareResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UpdateFirmwareResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateFirmwareResponse that = (UpdateFirmwareResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UsePriorityChargingRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UsePriorityChargingRequest.java new file mode 100644 index 00000000..54766681 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UsePriorityChargingRequest.java @@ -0,0 +1,206 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UsePriorityChargingRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UsePriorityChargingRequest extends RequestWithId { + /** The transaction for which priority charging is requested. */ + private String transactionId; + + /** True to request priority charging. False to request stopping priority charging. */ + private Boolean activate; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UsePriorityChargingRequest class + * + * @param transactionId The transaction for which priority charging is requested. + * @param activate True to request priority charging. False to request stopping priority charging. + */ + public UsePriorityChargingRequest(String transactionId, Boolean activate) { + setTransactionId(transactionId); + setActivate(activate); + } + + /** + * Gets the transaction for which priority charging is requested. + * + * @return The transaction for which priority charging is requested + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the transaction for which priority charging is requested. + * + * @param transactionId The transaction for which priority charging is requested + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + /** + * Gets true to request priority charging. False to request stopping priority charging. + * + * @return True to request priority charging + */ + public Boolean getActivate() { + return activate; + } + + /** + * Sets true to request priority charging. False to request stopping priority charging. + * + * @param activate True to request priority charging + */ + public void setActivate(Boolean activate) { + if (!isValidActivate(activate)) { + throw new PropertyConstraintException(activate, "activate is invalid"); + } + this.activate = activate; + } + + /** + * Returns whether the given activate is valid + * + * @param activate the activate to check the validity of + * @return {@code true} if activate is valid, {@code false} if not + */ + private boolean isValidActivate(Boolean activate) { + return activate != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UsePriorityChargingRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidTransactionId(transactionId) + && isValidActivate(activate) + && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsePriorityChargingRequest that = (UsePriorityChargingRequest) o; + return Objects.equals(transactionId, that.transactionId) + && Objects.equals(activate, that.activate) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(transactionId, activate, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("transactionId", transactionId) + .add("activate", activate) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UsePriorityChargingResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UsePriorityChargingResponse.java new file mode 100644 index 00000000..93578473 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/UsePriorityChargingResponse.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.PriorityChargingStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UsePriorityChargingResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class UsePriorityChargingResponse extends Confirmation { + /** Result of the request. */ + private PriorityChargingStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the UsePriorityChargingResponse class + * + * @param status Result of the request. + */ + public UsePriorityChargingResponse(PriorityChargingStatusEnum status) { + setStatus(status); + } + + /** + * Gets result of the request. + * + * @return Result of the request + */ + public PriorityChargingStatusEnum getStatus() { + return status; + } + + /** + * Sets result of the request. + * + * @param status Result of the request + */ + public void setStatus(PriorityChargingStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(PriorityChargingStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public UsePriorityChargingResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UsePriorityChargingResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidStatus(status) && isValidStatusInfo(statusInfo) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsePriorityChargingResponse that = (UsePriorityChargingResponse) o; + return Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/VatNumberValidationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/VatNumberValidationRequest.java new file mode 100644 index 00000000..27393d55 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/VatNumberValidationRequest.java @@ -0,0 +1,214 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * VatNumberValidationRequest + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class VatNumberValidationRequest extends RequestWithId { + /** VAT number to check. */ + private String vatNumber; + + /** EVSE id for which check is done */ + @Nullable private Integer evseId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the VatNumberValidationRequest class + * + * @param vatNumber VAT number to check. + */ + public VatNumberValidationRequest(String vatNumber) { + setVatNumber(vatNumber); + } + + /** + * Gets VAT number to check. + * + * @return VAT number to check + */ + public String getVatNumber() { + return vatNumber; + } + + /** + * Sets VAT number to check. + * + * @param vatNumber VAT number to check + */ + public void setVatNumber(String vatNumber) { + if (!isValidVatNumber(vatNumber)) { + throw new PropertyConstraintException(vatNumber, "vatNumber is invalid"); + } + this.vatNumber = vatNumber; + } + + /** + * Returns whether the given vatNumber is valid + * + * @param vatNumber the vatNumber to check the validity of + * @return {@code true} if vatNumber is valid, {@code false} if not + */ + private boolean isValidVatNumber(String vatNumber) { + return vatNumber != null && vatNumber.length() <= 20; + } + + /** + * Gets EVSE id for which check is done + * + * @return EVSE id for which check is done + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets EVSE id for which check is done + * + * @param evseId EVSE id for which check is done + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds EVSE id for which check is done + * + * @param evseId EVSE id for which check is done + * @return this + */ + public VatNumberValidationRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VatNumberValidationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidVatNumber(vatNumber) && isValidEvseId(evseId) && isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VatNumberValidationRequest that = (VatNumberValidationRequest) o; + return Objects.equals(vatNumber, that.vatNumber) + && Objects.equals(evseId, that.evseId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(vatNumber, evseId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("vatNumber", vatNumber) + .add("evseId", evseId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/VatNumberValidationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/VatNumberValidationResponse.java new file mode 100644 index 00000000..eb04f39e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/VatNumberValidationResponse.java @@ -0,0 +1,351 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v21.model.types.Address; +import eu.chargetime.ocpp.v21.model.types.CustomData; +import eu.chargetime.ocpp.v21.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v21.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * VatNumberValidationResponse + * + *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International + * Public License + */ +public final class VatNumberValidationResponse extends Confirmation { + /** A generic address format. */ + @Nullable private Address company; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** VAT number that was requested. */ + private String vatNumber; + + /** EVSE id for which check was requested. */ + @Nullable private Integer evseId; + + /** Result of operation. */ + private GenericStatusEnum status; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the VatNumberValidationResponse class + * + * @param vatNumber VAT number that was requested. + * @param status Result of operation. + */ + public VatNumberValidationResponse(String vatNumber, GenericStatusEnum status) { + setVatNumber(vatNumber); + setStatus(status); + } + + /** + * Gets a generic address format. + * + * @return A generic address format + */ + @Nullable + public Address getCompany() { + return company; + } + + /** + * Sets a generic address format. + * + * @param company A generic address format + */ + public void setCompany(@Nullable Address company) { + if (!isValidCompany(company)) { + throw new PropertyConstraintException(company, "company is invalid"); + } + this.company = company; + } + + /** + * Returns whether the given company is valid + * + * @param company the company to check the validity of + * @return {@code true} if company is valid, {@code false} if not + */ + private boolean isValidCompany(@Nullable Address company) { + return company == null || company.validate(); + } + + /** + * Adds a generic address format. + * + * @param company A generic address format + * @return this + */ + public VatNumberValidationResponse withCompany(@Nullable Address company) { + setCompany(company); + return this; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public VatNumberValidationResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets VAT number that was requested. + * + * @return VAT number that was requested + */ + public String getVatNumber() { + return vatNumber; + } + + /** + * Sets VAT number that was requested. + * + * @param vatNumber VAT number that was requested + */ + public void setVatNumber(String vatNumber) { + if (!isValidVatNumber(vatNumber)) { + throw new PropertyConstraintException(vatNumber, "vatNumber is invalid"); + } + this.vatNumber = vatNumber; + } + + /** + * Returns whether the given vatNumber is valid + * + * @param vatNumber the vatNumber to check the validity of + * @return {@code true} if vatNumber is valid, {@code false} if not + */ + private boolean isValidVatNumber(String vatNumber) { + return vatNumber != null && vatNumber.length() <= 20; + } + + /** + * Gets EVSE id for which check was requested. + * + * @return EVSE id for which check was requested + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets EVSE id for which check was requested. + * + * @param evseId EVSE id for which check was requested + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds EVSE id for which check was requested. + * + * @param evseId EVSE id for which check was requested + * @return this + */ + public VatNumberValidationResponse withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets result of operation. + * + * @return Result of operation + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets result of operation. + * + * @param status Result of operation + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VatNumberValidationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCompany(company) + && isValidStatusInfo(statusInfo) + && isValidVatNumber(vatNumber) + && isValidEvseId(evseId) + && isValidStatus(status) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VatNumberValidationResponse that = (VatNumberValidationResponse) o; + return Objects.equals(company, that.company) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(vatNumber, that.vatNumber) + && Objects.equals(evseId, that.evseId) + && Objects.equals(status, that.status) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(company, statusInfo, vatNumber, evseId, status, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("company", company) + .add("statusInfo", statusInfo) + .add("vatNumber", vatNumber) + .add("evseId", evseId) + .add("status", status) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ACChargingParameters.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ACChargingParameters.java new file mode 100644 index 00000000..7da4e7bd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ACChargingParameters.java @@ -0,0 +1,305 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** EV AC charging parameters for ISO 15118-2 */ +public final class ACChargingParameters { + /** + * Amount of energy requested (in Wh). This includes energy required for preconditioning. + * + *

+   * Relates to:
+   * *ISO 15118-2*: ACEVChargeParameterType: EAmount
+   * *ISO 15118-20*: Dynamic/ScheduledSEReqControlModeType: EVTargetEnergyRequest
+   * 
+ */ + private Double energyAmount; + + /** + * Minimum current (amps) supported by the electric vehicle (per phase). + * + *
+   * Relates to:
+   * *ISO 15118-2*: ACEVChargeParameterType: EVMinCurrent
+   * 
+ */ + private Double evMinCurrent; + + /** + * Maximum current (amps) supported by the electric vehicle (per phase). Includes cable capacity. + * + *
+   * Relates to:
+   * *ISO 15118-2*: ACEVChargeParameterType: EVMaxCurrent
+   * 
+ */ + private Double evMaxCurrent; + + /** + * Maximum voltage supported by the electric vehicle. + * + *
+   * Relates to:
+   * *ISO 15118-2*: ACEVChargeParameterType: EVMaxVoltage
+   * 
+ */ + private Double evMaxVoltage; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ACChargingParameters class + * + * @param energyAmount Amount of energy requested (in Wh). This includes energy required for + * preconditioning. + * @param evMinCurrent Minimum current (amps) supported by the electric vehicle (per phase). + * @param evMaxCurrent Maximum current (amps) supported by the electric vehicle (per phase). + * Includes cable capacity. + * @param evMaxVoltage Maximum voltage supported by the electric vehicle. + */ + public ACChargingParameters( + Double energyAmount, Double evMinCurrent, Double evMaxCurrent, Double evMaxVoltage) { + setEnergyAmount(energyAmount); + setEvMinCurrent(evMinCurrent); + setEvMaxCurrent(evMaxCurrent); + setEvMaxVoltage(evMaxVoltage); + } + + /** + * Gets amount of energy requested (in Wh). This includes energy required for preconditioning. + * + * @return Amount of energy requested (in Wh) + */ + public Double getEnergyAmount() { + return energyAmount; + } + + /** + * Sets amount of energy requested (in Wh). This includes energy required for preconditioning. + * + * @param energyAmount Amount of energy requested (in Wh) + */ + public void setEnergyAmount(Double energyAmount) { + if (!isValidEnergyAmount(energyAmount)) { + throw new PropertyConstraintException(energyAmount, "energyAmount is invalid"); + } + this.energyAmount = energyAmount; + } + + /** + * Returns whether the given energyAmount is valid + * + * @param energyAmount the energyAmount to check the validity of + * @return {@code true} if energyAmount is valid, {@code false} if not + */ + private boolean isValidEnergyAmount(Double energyAmount) { + return energyAmount != null; + } + + /** + * Gets minimum current (amps) supported by the electric vehicle (per phase). + * + * @return Minimum current (amps) supported by the electric vehicle (per phase) + */ + public Double getEvMinCurrent() { + return evMinCurrent; + } + + /** + * Sets minimum current (amps) supported by the electric vehicle (per phase). + * + * @param evMinCurrent Minimum current (amps) supported by the electric vehicle (per phase) + */ + public void setEvMinCurrent(Double evMinCurrent) { + if (!isValidEvMinCurrent(evMinCurrent)) { + throw new PropertyConstraintException(evMinCurrent, "evMinCurrent is invalid"); + } + this.evMinCurrent = evMinCurrent; + } + + /** + * Returns whether the given evMinCurrent is valid + * + * @param evMinCurrent the evMinCurrent to check the validity of + * @return {@code true} if evMinCurrent is valid, {@code false} if not + */ + private boolean isValidEvMinCurrent(Double evMinCurrent) { + return evMinCurrent != null; + } + + /** + * Gets maximum current (amps) supported by the electric vehicle (per phase). Includes cable + * capacity. + * + * @return Maximum current (amps) supported by the electric vehicle (per phase) + */ + public Double getEvMaxCurrent() { + return evMaxCurrent; + } + + /** + * Sets maximum current (amps) supported by the electric vehicle (per phase). Includes cable + * capacity. + * + * @param evMaxCurrent Maximum current (amps) supported by the electric vehicle (per phase) + */ + public void setEvMaxCurrent(Double evMaxCurrent) { + if (!isValidEvMaxCurrent(evMaxCurrent)) { + throw new PropertyConstraintException(evMaxCurrent, "evMaxCurrent is invalid"); + } + this.evMaxCurrent = evMaxCurrent; + } + + /** + * Returns whether the given evMaxCurrent is valid + * + * @param evMaxCurrent the evMaxCurrent to check the validity of + * @return {@code true} if evMaxCurrent is valid, {@code false} if not + */ + private boolean isValidEvMaxCurrent(Double evMaxCurrent) { + return evMaxCurrent != null; + } + + /** + * Gets maximum voltage supported by the electric vehicle. + * + * @return Maximum voltage supported by the electric vehicle + */ + public Double getEvMaxVoltage() { + return evMaxVoltage; + } + + /** + * Sets maximum voltage supported by the electric vehicle. + * + * @param evMaxVoltage Maximum voltage supported by the electric vehicle + */ + public void setEvMaxVoltage(Double evMaxVoltage) { + if (!isValidEvMaxVoltage(evMaxVoltage)) { + throw new PropertyConstraintException(evMaxVoltage, "evMaxVoltage is invalid"); + } + this.evMaxVoltage = evMaxVoltage; + } + + /** + * Returns whether the given evMaxVoltage is valid + * + * @param evMaxVoltage the evMaxVoltage to check the validity of + * @return {@code true} if evMaxVoltage is valid, {@code false} if not + */ + private boolean isValidEvMaxVoltage(Double evMaxVoltage) { + return evMaxVoltage != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ACChargingParameters withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEnergyAmount(energyAmount) + && isValidEvMinCurrent(evMinCurrent) + && isValidEvMaxCurrent(evMaxCurrent) + && isValidEvMaxVoltage(evMaxVoltage) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ACChargingParameters that = (ACChargingParameters) o; + return Objects.equals(energyAmount, that.energyAmount) + && Objects.equals(evMinCurrent, that.evMinCurrent) + && Objects.equals(evMaxCurrent, that.evMaxCurrent) + && Objects.equals(evMaxVoltage, that.evMaxVoltage) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(energyAmount, evMinCurrent, evMaxCurrent, evMaxVoltage, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("energyAmount", energyAmount) + .add("evMinCurrent", evMinCurrent) + .add("evMaxCurrent", evMaxCurrent) + .add("evMaxVoltage", evMaxVoltage) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/APN.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/APN.java new file mode 100644 index 00000000..c9408131 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/APN.java @@ -0,0 +1,431 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Collection of configuration data needed to make a data-connection over a cellular network. + * + *

NOTE: When asking a GSM modem to dial in, it is possible to specify which mobile operator + * should be used. This can be done with the mobile country code (MCC) in combination with a mobile + * network code (MNC). Example: If your preferred network is Vodafone Netherlands, the MCC=204 and + * the MNC=04 which means the key PreferredNetwork = 20404 Some modems allows to specify a preferred + * network, which means, if this network is not available, a different network is used. If you + * specify UseOnlyPreferredNetwork and this network is not available, the modem will not dial in. + */ +public final class APN { + /** The Access Point Name as an URL. */ + private String apn; + + /** APN username. */ + @Nullable private String apnUserName; + + /** APN Password. */ + @Nullable private String apnPassword; + + /** SIM card pin code. */ + @Nullable private Integer simPin; + + /** Preferred network, written as MCC and MNC concatenated. See note. */ + @Nullable private String preferredNetwork; + + /** + * Default: false. Use only the preferred Network, do not dial in when not available. See Note. + */ + @Nullable private Boolean useOnlyPreferredNetwork; + + /** Authentication method. */ + private APNAuthenticationEnum apnAuthentication; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the APN class + * + * @param apn The Access Point Name as an URL. + * @param apnAuthentication Authentication method. + */ + public APN(String apn, APNAuthenticationEnum apnAuthentication) { + setApn(apn); + setApnAuthentication(apnAuthentication); + } + + /** + * Gets the Access Point Name as an URL. + * + * @return The Access Point Name as an URL + */ + public String getApn() { + return apn; + } + + /** + * Sets the Access Point Name as an URL. + * + * @param apn The Access Point Name as an URL + */ + public void setApn(String apn) { + if (!isValidApn(apn)) { + throw new PropertyConstraintException(apn, "apn is invalid"); + } + this.apn = apn; + } + + /** + * Returns whether the given apn is valid + * + * @param apn the apn to check the validity of + * @return {@code true} if apn is valid, {@code false} if not + */ + private boolean isValidApn(String apn) { + return apn != null && apn.length() <= 2000; + } + + /** + * Gets APN username. + * + * @return APN username + */ + @Nullable + public String getApnUserName() { + return apnUserName; + } + + /** + * Sets APN username. + * + * @param apnUserName APN username + */ + public void setApnUserName(@Nullable String apnUserName) { + if (!isValidApnUserName(apnUserName)) { + throw new PropertyConstraintException(apnUserName, "apnUserName is invalid"); + } + this.apnUserName = apnUserName; + } + + /** + * Returns whether the given apnUserName is valid + * + * @param apnUserName the apnUserName to check the validity of + * @return {@code true} if apnUserName is valid, {@code false} if not + */ + private boolean isValidApnUserName(@Nullable String apnUserName) { + return apnUserName == null || apnUserName.length() <= 50; + } + + /** + * Adds APN username. + * + * @param apnUserName APN username + * @return this + */ + public APN withApnUserName(@Nullable String apnUserName) { + setApnUserName(apnUserName); + return this; + } + + /** + * Gets APN Password. + * + * @return APN Password + */ + @Nullable + public String getApnPassword() { + return apnPassword; + } + + /** + * Sets APN Password. + * + * @param apnPassword APN Password + */ + public void setApnPassword(@Nullable String apnPassword) { + if (!isValidApnPassword(apnPassword)) { + throw new PropertyConstraintException(apnPassword, "apnPassword is invalid"); + } + this.apnPassword = apnPassword; + } + + /** + * Returns whether the given apnPassword is valid + * + * @param apnPassword the apnPassword to check the validity of + * @return {@code true} if apnPassword is valid, {@code false} if not + */ + private boolean isValidApnPassword(@Nullable String apnPassword) { + return apnPassword == null || apnPassword.length() <= 64; + } + + /** + * Adds APN Password. + * + * @param apnPassword APN Password + * @return this + */ + public APN withApnPassword(@Nullable String apnPassword) { + setApnPassword(apnPassword); + return this; + } + + /** + * Gets SIM card pin code. + * + * @return SIM card pin code + */ + @Nullable + public Integer getSimPin() { + return simPin; + } + + /** + * Sets SIM card pin code. + * + * @param simPin SIM card pin code + */ + public void setSimPin(@Nullable Integer simPin) { + this.simPin = simPin; + } + + /** + * Adds SIM card pin code. + * + * @param simPin SIM card pin code + * @return this + */ + public APN withSimPin(@Nullable Integer simPin) { + setSimPin(simPin); + return this; + } + + /** + * Gets preferred network, written as MCC and MNC concatenated. See note. + * + * @return Preferred network, written as MCC and MNC concatenated + */ + @Nullable + public String getPreferredNetwork() { + return preferredNetwork; + } + + /** + * Sets preferred network, written as MCC and MNC concatenated. See note. + * + * @param preferredNetwork Preferred network, written as MCC and MNC concatenated + */ + public void setPreferredNetwork(@Nullable String preferredNetwork) { + if (!isValidPreferredNetwork(preferredNetwork)) { + throw new PropertyConstraintException(preferredNetwork, "preferredNetwork is invalid"); + } + this.preferredNetwork = preferredNetwork; + } + + /** + * Returns whether the given preferredNetwork is valid + * + * @param preferredNetwork the preferredNetwork to check the validity of + * @return {@code true} if preferredNetwork is valid, {@code false} if not + */ + private boolean isValidPreferredNetwork(@Nullable String preferredNetwork) { + return preferredNetwork == null || preferredNetwork.length() <= 6; + } + + /** + * Adds preferred network, written as MCC and MNC concatenated. See note. + * + * @param preferredNetwork Preferred network, written as MCC and MNC concatenated + * @return this + */ + public APN withPreferredNetwork(@Nullable String preferredNetwork) { + setPreferredNetwork(preferredNetwork); + return this; + } + + /** + * Gets default: false. Use only the preferred Network, do not dial in when not available. See + * Note. + * + * @return Default: false + */ + public Boolean getUseOnlyPreferredNetwork() { + return useOnlyPreferredNetwork != null ? useOnlyPreferredNetwork : false; + } + + /** + * Sets default: false. Use only the preferred Network, do not dial in when not available. See + * Note. + * + * @param useOnlyPreferredNetwork Default: false + */ + public void setUseOnlyPreferredNetwork(@Nullable Boolean useOnlyPreferredNetwork) { + this.useOnlyPreferredNetwork = useOnlyPreferredNetwork; + } + + /** + * Adds default: false. Use only the preferred Network, do not dial in when not available. See + * Note. + * + * @param useOnlyPreferredNetwork Default: false + * @return this + */ + public APN withUseOnlyPreferredNetwork(@Nullable Boolean useOnlyPreferredNetwork) { + setUseOnlyPreferredNetwork(useOnlyPreferredNetwork); + return this; + } + + /** + * Gets authentication method. + * + * @return Authentication method + */ + public APNAuthenticationEnum getApnAuthentication() { + return apnAuthentication; + } + + /** + * Sets authentication method. + * + * @param apnAuthentication Authentication method + */ + public void setApnAuthentication(APNAuthenticationEnum apnAuthentication) { + if (!isValidApnAuthentication(apnAuthentication)) { + throw new PropertyConstraintException(apnAuthentication, "apnAuthentication is invalid"); + } + this.apnAuthentication = apnAuthentication; + } + + /** + * Returns whether the given apnAuthentication is valid + * + * @param apnAuthentication the apnAuthentication to check the validity of + * @return {@code true} if apnAuthentication is valid, {@code false} if not + */ + private boolean isValidApnAuthentication(APNAuthenticationEnum apnAuthentication) { + return apnAuthentication != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public APN withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidApn(apn) + && isValidApnUserName(apnUserName) + && isValidApnPassword(apnPassword) + && isValidPreferredNetwork(preferredNetwork) + && isValidApnAuthentication(apnAuthentication) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APN that = (APN) o; + return Objects.equals(apn, that.apn) + && Objects.equals(apnUserName, that.apnUserName) + && Objects.equals(apnPassword, that.apnPassword) + && Objects.equals(simPin, that.simPin) + && Objects.equals(preferredNetwork, that.preferredNetwork) + && Objects.equals(useOnlyPreferredNetwork, that.useOnlyPreferredNetwork) + && Objects.equals(apnAuthentication, that.apnAuthentication) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + apn, + apnUserName, + apnPassword, + simPin, + preferredNetwork, + useOnlyPreferredNetwork, + apnAuthentication, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("apn", apn) + .add("apnUserName", apnUserName) + .add("apnPassword", apnPassword) + .add("simPin", simPin) + .add("preferredNetwork", preferredNetwork) + .add("useOnlyPreferredNetwork", useOnlyPreferredNetwork) + .add("apnAuthentication", apnAuthentication) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/APNAuthenticationEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/APNAuthenticationEnum.java new file mode 100644 index 00000000..59a71b1c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/APNAuthenticationEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Authentication method. */ +public enum APNAuthenticationEnum { + PAP, + CHAP, + NONE, + AUTO +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AbsolutePriceSchedule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AbsolutePriceSchedule.java new file mode 100644 index 00000000..c4630d1c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AbsolutePriceSchedule.java @@ -0,0 +1,708 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * The AbsolutePriceScheduleType is modeled after the same type that is defined in ISO 15118-20, + * such that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON + * (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not + * invalidate the signature. + * + *

image::images/AbsolutePriceSchedule-Simple.png[] + */ +public final class AbsolutePriceSchedule { + /** Starting point of price schedule. */ + private ZonedDateTime timeAnchor; + + /** Unique ID of price schedule */ + private Integer priceScheduleID; + + /** Description of the price schedule. */ + @Nullable private String priceScheduleDescription; + + /** Currency according to ISO 4217. */ + private String currency; + + /** + * String that indicates what language is used for the human readable strings in the price + * schedule. Based on ISO 639. + */ + private String language; + + /** + * A string in URN notation which shall uniquely identify an algorithm that defines how to compute + * an energy fee sum for a specific power profile based on the EnergyFee information from the + * PriceRule elements. + */ + private String priceAlgorithm; + + /** Part of ISO 15118-20 price schedule. */ + @Nullable private RationalNumber minimumCost; + + /** Part of ISO 15118-20 price schedule. */ + @Nullable private RationalNumber maximumCost; + + /** Part of ISO 15118-20 price schedule. */ + private PriceRuleStack[] priceRuleStacks; + + /** Part of ISO 15118-20 price schedule. */ + @Nullable private TaxRule[] taxRules; + + /** Part of ISO 15118-20 price schedule. */ + @Nullable private OverstayRuleList overstayRuleList; + + /** Part of ISO 15118-20 price schedule. */ + @Nullable private AdditionalSelectedServices[] additionalSelectedServices; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AbsolutePriceSchedule class + * + * @param timeAnchor Starting point of price schedule. + * @param priceScheduleID Unique ID of price schedule + * @param currency Currency according to ISO 4217. + * @param language String that indicates what language is used for the human readable strings in + * the price schedule. Based on ISO 639. + * @param priceAlgorithm A string in URN notation which shall uniquely identify an algorithm that + * defines how to compute an energy fee sum for a specific power profile based on the + * EnergyFee information from the PriceRule elements. + * @param priceRuleStacks Part of ISO 15118-20 price schedule. + */ + public AbsolutePriceSchedule( + ZonedDateTime timeAnchor, + Integer priceScheduleID, + String currency, + String language, + String priceAlgorithm, + PriceRuleStack[] priceRuleStacks) { + setTimeAnchor(timeAnchor); + setPriceScheduleID(priceScheduleID); + setCurrency(currency); + setLanguage(language); + setPriceAlgorithm(priceAlgorithm); + setPriceRuleStacks(priceRuleStacks); + } + + /** + * Gets starting point of price schedule. + * + * @return Starting point of price schedule + */ + public ZonedDateTime getTimeAnchor() { + return timeAnchor; + } + + /** + * Sets starting point of price schedule. + * + * @param timeAnchor Starting point of price schedule + */ + public void setTimeAnchor(ZonedDateTime timeAnchor) { + if (!isValidTimeAnchor(timeAnchor)) { + throw new PropertyConstraintException(timeAnchor, "timeAnchor is invalid"); + } + this.timeAnchor = timeAnchor; + } + + /** + * Returns whether the given timeAnchor is valid + * + * @param timeAnchor the timeAnchor to check the validity of + * @return {@code true} if timeAnchor is valid, {@code false} if not + */ + private boolean isValidTimeAnchor(ZonedDateTime timeAnchor) { + return timeAnchor != null; + } + + /** + * Gets unique ID of price schedule + * + * @return Unique ID of price schedule + */ + public Integer getPriceScheduleID() { + return priceScheduleID; + } + + /** + * Sets unique ID of price schedule + * + * @param priceScheduleID Unique ID of price schedule + */ + public void setPriceScheduleID(Integer priceScheduleID) { + if (!isValidPriceScheduleID(priceScheduleID)) { + throw new PropertyConstraintException(priceScheduleID, "priceScheduleID is invalid"); + } + this.priceScheduleID = priceScheduleID; + } + + /** + * Returns whether the given priceScheduleID is valid + * + * @param priceScheduleID the priceScheduleID to check the validity of + * @return {@code true} if priceScheduleID is valid, {@code false} if not + */ + private boolean isValidPriceScheduleID(Integer priceScheduleID) { + return priceScheduleID != null && priceScheduleID >= 0; + } + + /** + * Gets description of the price schedule. + * + * @return Description of the price schedule + */ + @Nullable + public String getPriceScheduleDescription() { + return priceScheduleDescription; + } + + /** + * Sets description of the price schedule. + * + * @param priceScheduleDescription Description of the price schedule + */ + public void setPriceScheduleDescription(@Nullable String priceScheduleDescription) { + if (!isValidPriceScheduleDescription(priceScheduleDescription)) { + throw new PropertyConstraintException( + priceScheduleDescription, "priceScheduleDescription is invalid"); + } + this.priceScheduleDescription = priceScheduleDescription; + } + + /** + * Returns whether the given priceScheduleDescription is valid + * + * @param priceScheduleDescription the priceScheduleDescription to check the validity of + * @return {@code true} if priceScheduleDescription is valid, {@code false} if not + */ + private boolean isValidPriceScheduleDescription(@Nullable String priceScheduleDescription) { + return priceScheduleDescription == null || priceScheduleDescription.length() <= 160; + } + + /** + * Adds description of the price schedule. + * + * @param priceScheduleDescription Description of the price schedule + * @return this + */ + public AbsolutePriceSchedule withPriceScheduleDescription( + @Nullable String priceScheduleDescription) { + setPriceScheduleDescription(priceScheduleDescription); + return this; + } + + /** + * Gets currency according to ISO 4217. + * + * @return Currency according to ISO 4217 + */ + public String getCurrency() { + return currency; + } + + /** + * Sets currency according to ISO 4217. + * + * @param currency Currency according to ISO 4217 + */ + public void setCurrency(String currency) { + if (!isValidCurrency(currency)) { + throw new PropertyConstraintException(currency, "currency is invalid"); + } + this.currency = currency; + } + + /** + * Returns whether the given currency is valid + * + * @param currency the currency to check the validity of + * @return {@code true} if currency is valid, {@code false} if not + */ + private boolean isValidCurrency(String currency) { + return currency != null && currency.length() <= 3; + } + + /** + * Gets string that indicates what language is used for the human readable strings in the price + * schedule. Based on ISO 639. + * + * @return String that indicates what language is used for the human readable strings in the price + * schedule + */ + public String getLanguage() { + return language; + } + + /** + * Sets string that indicates what language is used for the human readable strings in the price + * schedule. Based on ISO 639. + * + * @param language String that indicates what language is used for the human readable strings in + * the price schedule + */ + public void setLanguage(String language) { + if (!isValidLanguage(language)) { + throw new PropertyConstraintException(language, "language is invalid"); + } + this.language = language; + } + + /** + * Returns whether the given language is valid + * + * @param language the language to check the validity of + * @return {@code true} if language is valid, {@code false} if not + */ + private boolean isValidLanguage(String language) { + return language != null && language.length() <= 8; + } + + /** + * Gets a string in URN notation which shall uniquely identify an algorithm that defines how to + * compute an energy fee sum for a specific power profile based on the EnergyFee information from + * the PriceRule elements. + * + * @return A string in URN notation which shall uniquely identify an algorithm that defines how to + * compute an energy fee sum for a specific power profile based on the EnergyFee information + * from the PriceRule elements + */ + public String getPriceAlgorithm() { + return priceAlgorithm; + } + + /** + * Sets a string in URN notation which shall uniquely identify an algorithm that defines how to + * compute an energy fee sum for a specific power profile based on the EnergyFee information from + * the PriceRule elements. + * + * @param priceAlgorithm A string in URN notation which shall uniquely identify an algorithm that + * defines how to compute an energy fee sum for a specific power profile based on the + * EnergyFee information from the PriceRule elements + */ + public void setPriceAlgorithm(String priceAlgorithm) { + if (!isValidPriceAlgorithm(priceAlgorithm)) { + throw new PropertyConstraintException(priceAlgorithm, "priceAlgorithm is invalid"); + } + this.priceAlgorithm = priceAlgorithm; + } + + /** + * Returns whether the given priceAlgorithm is valid + * + * @param priceAlgorithm the priceAlgorithm to check the validity of + * @return {@code true} if priceAlgorithm is valid, {@code false} if not + */ + private boolean isValidPriceAlgorithm(String priceAlgorithm) { + return priceAlgorithm != null && priceAlgorithm.length() <= 2000; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + @Nullable + public RationalNumber getMinimumCost() { + return minimumCost; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param minimumCost Part of ISO 15118-20 price schedule + */ + public void setMinimumCost(@Nullable RationalNumber minimumCost) { + if (!isValidMinimumCost(minimumCost)) { + throw new PropertyConstraintException(minimumCost, "minimumCost is invalid"); + } + this.minimumCost = minimumCost; + } + + /** + * Returns whether the given minimumCost is valid + * + * @param minimumCost the minimumCost to check the validity of + * @return {@code true} if minimumCost is valid, {@code false} if not + */ + private boolean isValidMinimumCost(@Nullable RationalNumber minimumCost) { + return minimumCost == null || minimumCost.validate(); + } + + /** + * Adds part of ISO 15118-20 price schedule. + * + * @param minimumCost Part of ISO 15118-20 price schedule + * @return this + */ + public AbsolutePriceSchedule withMinimumCost(@Nullable RationalNumber minimumCost) { + setMinimumCost(minimumCost); + return this; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + @Nullable + public RationalNumber getMaximumCost() { + return maximumCost; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param maximumCost Part of ISO 15118-20 price schedule + */ + public void setMaximumCost(@Nullable RationalNumber maximumCost) { + if (!isValidMaximumCost(maximumCost)) { + throw new PropertyConstraintException(maximumCost, "maximumCost is invalid"); + } + this.maximumCost = maximumCost; + } + + /** + * Returns whether the given maximumCost is valid + * + * @param maximumCost the maximumCost to check the validity of + * @return {@code true} if maximumCost is valid, {@code false} if not + */ + private boolean isValidMaximumCost(@Nullable RationalNumber maximumCost) { + return maximumCost == null || maximumCost.validate(); + } + + /** + * Adds part of ISO 15118-20 price schedule. + * + * @param maximumCost Part of ISO 15118-20 price schedule + * @return this + */ + public AbsolutePriceSchedule withMaximumCost(@Nullable RationalNumber maximumCost) { + setMaximumCost(maximumCost); + return this; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public PriceRuleStack[] getPriceRuleStacks() { + return priceRuleStacks; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param priceRuleStacks Part of ISO 15118-20 price schedule + */ + public void setPriceRuleStacks(PriceRuleStack[] priceRuleStacks) { + if (!isValidPriceRuleStacks(priceRuleStacks)) { + throw new PropertyConstraintException(priceRuleStacks, "priceRuleStacks is invalid"); + } + this.priceRuleStacks = priceRuleStacks; + } + + /** + * Returns whether the given priceRuleStacks is valid + * + * @param priceRuleStacks the priceRuleStacks to check the validity of + * @return {@code true} if priceRuleStacks is valid, {@code false} if not + */ + private boolean isValidPriceRuleStacks(PriceRuleStack[] priceRuleStacks) { + return priceRuleStacks != null + && priceRuleStacks.length >= 1 + && priceRuleStacks.length <= 1024 + && Arrays.stream(priceRuleStacks).allMatch(item -> item.validate()); + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + @Nullable + public TaxRule[] getTaxRules() { + return taxRules; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param taxRules Part of ISO 15118-20 price schedule + */ + public void setTaxRules(@Nullable TaxRule[] taxRules) { + if (!isValidTaxRules(taxRules)) { + throw new PropertyConstraintException(taxRules, "taxRules is invalid"); + } + this.taxRules = taxRules; + } + + /** + * Returns whether the given taxRules is valid + * + * @param taxRules the taxRules to check the validity of + * @return {@code true} if taxRules is valid, {@code false} if not + */ + private boolean isValidTaxRules(@Nullable TaxRule[] taxRules) { + return taxRules == null + || (taxRules.length >= 1 + && taxRules.length <= 10 + && Arrays.stream(taxRules).allMatch(item -> item.validate())); + } + + /** + * Adds part of ISO 15118-20 price schedule. + * + * @param taxRules Part of ISO 15118-20 price schedule + * @return this + */ + public AbsolutePriceSchedule withTaxRules(@Nullable TaxRule[] taxRules) { + setTaxRules(taxRules); + return this; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + @Nullable + public OverstayRuleList getOverstayRuleList() { + return overstayRuleList; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param overstayRuleList Part of ISO 15118-20 price schedule + */ + public void setOverstayRuleList(@Nullable OverstayRuleList overstayRuleList) { + if (!isValidOverstayRuleList(overstayRuleList)) { + throw new PropertyConstraintException(overstayRuleList, "overstayRuleList is invalid"); + } + this.overstayRuleList = overstayRuleList; + } + + /** + * Returns whether the given overstayRuleList is valid + * + * @param overstayRuleList the overstayRuleList to check the validity of + * @return {@code true} if overstayRuleList is valid, {@code false} if not + */ + private boolean isValidOverstayRuleList(@Nullable OverstayRuleList overstayRuleList) { + return overstayRuleList == null || overstayRuleList.validate(); + } + + /** + * Adds part of ISO 15118-20 price schedule. + * + * @param overstayRuleList Part of ISO 15118-20 price schedule + * @return this + */ + public AbsolutePriceSchedule withOverstayRuleList(@Nullable OverstayRuleList overstayRuleList) { + setOverstayRuleList(overstayRuleList); + return this; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + @Nullable + public AdditionalSelectedServices[] getAdditionalSelectedServices() { + return additionalSelectedServices; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param additionalSelectedServices Part of ISO 15118-20 price schedule + */ + public void setAdditionalSelectedServices( + @Nullable AdditionalSelectedServices[] additionalSelectedServices) { + if (!isValidAdditionalSelectedServices(additionalSelectedServices)) { + throw new PropertyConstraintException( + additionalSelectedServices, "additionalSelectedServices is invalid"); + } + this.additionalSelectedServices = additionalSelectedServices; + } + + /** + * Returns whether the given additionalSelectedServices is valid + * + * @param additionalSelectedServices the additionalSelectedServices to check the validity of + * @return {@code true} if additionalSelectedServices is valid, {@code false} if not + */ + private boolean isValidAdditionalSelectedServices( + @Nullable AdditionalSelectedServices[] additionalSelectedServices) { + return additionalSelectedServices == null + || (additionalSelectedServices.length >= 1 + && additionalSelectedServices.length <= 5 + && Arrays.stream(additionalSelectedServices).allMatch(item -> item.validate())); + } + + /** + * Adds part of ISO 15118-20 price schedule. + * + * @param additionalSelectedServices Part of ISO 15118-20 price schedule + * @return this + */ + public AbsolutePriceSchedule withAdditionalSelectedServices( + @Nullable AdditionalSelectedServices[] additionalSelectedServices) { + setAdditionalSelectedServices(additionalSelectedServices); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AbsolutePriceSchedule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidTimeAnchor(timeAnchor) + && isValidPriceScheduleID(priceScheduleID) + && isValidPriceScheduleDescription(priceScheduleDescription) + && isValidCurrency(currency) + && isValidLanguage(language) + && isValidPriceAlgorithm(priceAlgorithm) + && isValidMinimumCost(minimumCost) + && isValidMaximumCost(maximumCost) + && isValidPriceRuleStacks(priceRuleStacks) + && isValidTaxRules(taxRules) + && isValidOverstayRuleList(overstayRuleList) + && isValidAdditionalSelectedServices(additionalSelectedServices) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbsolutePriceSchedule that = (AbsolutePriceSchedule) o; + return Objects.equals(timeAnchor, that.timeAnchor) + && Objects.equals(priceScheduleID, that.priceScheduleID) + && Objects.equals(priceScheduleDescription, that.priceScheduleDescription) + && Objects.equals(currency, that.currency) + && Objects.equals(language, that.language) + && Objects.equals(priceAlgorithm, that.priceAlgorithm) + && Objects.equals(minimumCost, that.minimumCost) + && Objects.equals(maximumCost, that.maximumCost) + && Arrays.equals(priceRuleStacks, that.priceRuleStacks) + && Arrays.equals(taxRules, that.taxRules) + && Objects.equals(overstayRuleList, that.overstayRuleList) + && Arrays.equals(additionalSelectedServices, that.additionalSelectedServices) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + timeAnchor, + priceScheduleID, + priceScheduleDescription, + currency, + language, + priceAlgorithm, + minimumCost, + maximumCost, + Arrays.hashCode(priceRuleStacks), + Arrays.hashCode(taxRules), + overstayRuleList, + Arrays.hashCode(additionalSelectedServices), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("timeAnchor", timeAnchor) + .add("priceScheduleID", priceScheduleID) + .add("priceScheduleDescription", priceScheduleDescription) + .add("currency", currency) + .add("language", language) + .add("priceAlgorithm", priceAlgorithm) + .add("minimumCost", minimumCost) + .add("maximumCost", maximumCost) + .add("priceRuleStacks", priceRuleStacks) + .add("taxRules", taxRules) + .add("overstayRuleList", overstayRuleList) + .add("additionalSelectedServices", additionalSelectedServices) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AdditionalInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AdditionalInfo.java new file mode 100644 index 00000000..03bfe984 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AdditionalInfo.java @@ -0,0 +1,212 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ +public final class AdditionalInfo { + /** The additional IdToken. */ + private String additionalIdToken; + + /** + * additionalInfo can be used to send extra information to CSMS in addition to the regular + * authorization with IdToken. AdditionalInfo contains one or more custom types, which need to be + * agreed upon by all parties involved. When the type is not supported, the CSMS/Charging Station + * MAY ignore the additionalInfo. + */ + private String type; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AdditionalInfo class + * + * @param additionalIdToken The additional IdToken. + * @param type additionalInfo can be used to send extra information to CSMS in addition to the + * regular authorization with IdToken. AdditionalInfo contains one or more custom types, which + * need to be agreed upon by all parties involved. When the type is not supported, the + * CSMS/Charging Station MAY ignore the additionalInfo. + */ + public AdditionalInfo(String additionalIdToken, String type) { + setAdditionalIdToken(additionalIdToken); + setType(type); + } + + /** + * Gets the additional IdToken. + * + * @return The additional IdToken + */ + public String getAdditionalIdToken() { + return additionalIdToken; + } + + /** + * Sets the additional IdToken. + * + * @param additionalIdToken The additional IdToken + */ + public void setAdditionalIdToken(String additionalIdToken) { + if (!isValidAdditionalIdToken(additionalIdToken)) { + throw new PropertyConstraintException(additionalIdToken, "additionalIdToken is invalid"); + } + this.additionalIdToken = additionalIdToken; + } + + /** + * Returns whether the given additionalIdToken is valid + * + * @param additionalIdToken the additionalIdToken to check the validity of + * @return {@code true} if additionalIdToken is valid, {@code false} if not + */ + private boolean isValidAdditionalIdToken(String additionalIdToken) { + return additionalIdToken != null && additionalIdToken.length() <= 255; + } + + /** + * Gets additionalInfo can be used to send extra information to CSMS in addition to the regular + * authorization with IdToken. AdditionalInfo contains one or more custom types, which need to be + * agreed upon by all parties involved. When the type is not supported, the CSMS/Charging Station + * MAY ignore the additionalInfo. + * + * @return additionalInfo can be used to send extra information to CSMS in addition to the regular + * authorization with IdToken + */ + public String getType() { + return type; + } + + /** + * Sets additionalInfo can be used to send extra information to CSMS in addition to the regular + * authorization with IdToken. AdditionalInfo contains one or more custom types, which need to be + * agreed upon by all parties involved. When the type is not supported, the CSMS/Charging Station + * MAY ignore the additionalInfo. + * + * @param type additionalInfo can be used to send extra information to CSMS in addition to the + * regular authorization with IdToken + */ + public void setType(String type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(String type) { + return type != null && type.length() <= 50; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AdditionalInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidAdditionalIdToken(additionalIdToken) + && isValidType(type) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalInfo that = (AdditionalInfo) o; + return Objects.equals(additionalIdToken, that.additionalIdToken) + && Objects.equals(type, that.type) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(additionalIdToken, type, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("additionalIdToken", additionalIdToken) + .add("type", type) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AdditionalSelectedServices.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AdditionalSelectedServices.java new file mode 100644 index 00000000..d57dc7b7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AdditionalSelectedServices.java @@ -0,0 +1,193 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Part of ISO 15118-20 price schedule. */ +public final class AdditionalSelectedServices { + /** Part of ISO 15118-20 price schedule. */ + private RationalNumber serviceFee; + + /** Human readable string to identify this service. */ + private String serviceName; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AdditionalSelectedServices class + * + * @param serviceFee Part of ISO 15118-20 price schedule. + * @param serviceName Human readable string to identify this service. + */ + public AdditionalSelectedServices(RationalNumber serviceFee, String serviceName) { + setServiceFee(serviceFee); + setServiceName(serviceName); + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public RationalNumber getServiceFee() { + return serviceFee; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param serviceFee Part of ISO 15118-20 price schedule + */ + public void setServiceFee(RationalNumber serviceFee) { + if (!isValidServiceFee(serviceFee)) { + throw new PropertyConstraintException(serviceFee, "serviceFee is invalid"); + } + this.serviceFee = serviceFee; + } + + /** + * Returns whether the given serviceFee is valid + * + * @param serviceFee the serviceFee to check the validity of + * @return {@code true} if serviceFee is valid, {@code false} if not + */ + private boolean isValidServiceFee(RationalNumber serviceFee) { + return serviceFee != null && serviceFee.validate(); + } + + /** + * Gets human readable string to identify this service. + * + * @return Human readable string to identify this service + */ + public String getServiceName() { + return serviceName; + } + + /** + * Sets human readable string to identify this service. + * + * @param serviceName Human readable string to identify this service + */ + public void setServiceName(String serviceName) { + if (!isValidServiceName(serviceName)) { + throw new PropertyConstraintException(serviceName, "serviceName is invalid"); + } + this.serviceName = serviceName; + } + + /** + * Returns whether the given serviceName is valid + * + * @param serviceName the serviceName to check the validity of + * @return {@code true} if serviceName is valid, {@code false} if not + */ + private boolean isValidServiceName(String serviceName) { + return serviceName != null && serviceName.length() <= 80; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AdditionalSelectedServices withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidServiceFee(serviceFee) + && isValidServiceName(serviceName) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalSelectedServices that = (AdditionalSelectedServices) o; + return Objects.equals(serviceFee, that.serviceFee) + && Objects.equals(serviceName, that.serviceName) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(serviceFee, serviceName, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("serviceFee", serviceFee) + .add("serviceName", serviceName) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Address.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Address.java new file mode 100644 index 00000000..60fd54b0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Address.java @@ -0,0 +1,369 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A generic address format. */ +public final class Address { + /** Name of person/company */ + private String name; + + /** Address line 1 */ + private String address1; + + /** Address line 2 */ + @Nullable private String address2; + + /** City */ + private String city; + + /** Postal code */ + @Nullable private String postalCode; + + /** Country name */ + private String country; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Address class + * + * @param name Name of person/company + * @param address1 Address line 1 + * @param city City + * @param country Country name + */ + public Address(String name, String address1, String city, String country) { + setName(name); + setAddress1(address1); + setCity(city); + setCountry(country); + } + + /** + * Gets name of person/company + * + * @return Name of person/company + */ + public String getName() { + return name; + } + + /** + * Sets name of person/company + * + * @param name Name of person/company + */ + public void setName(String name) { + if (!isValidName(name)) { + throw new PropertyConstraintException(name, "name is invalid"); + } + this.name = name; + } + + /** + * Returns whether the given name is valid + * + * @param name the name to check the validity of + * @return {@code true} if name is valid, {@code false} if not + */ + private boolean isValidName(String name) { + return name != null && name.length() <= 50; + } + + /** + * Gets address line 1 + * + * @return Address line 1 + */ + public String getAddress1() { + return address1; + } + + /** + * Sets address line 1 + * + * @param address1 Address line 1 + */ + public void setAddress1(String address1) { + if (!isValidAddress1(address1)) { + throw new PropertyConstraintException(address1, "address1 is invalid"); + } + this.address1 = address1; + } + + /** + * Returns whether the given address1 is valid + * + * @param address1 the address1 to check the validity of + * @return {@code true} if address1 is valid, {@code false} if not + */ + private boolean isValidAddress1(String address1) { + return address1 != null && address1.length() <= 100; + } + + /** + * Gets address line 2 + * + * @return Address line 2 + */ + @Nullable + public String getAddress2() { + return address2; + } + + /** + * Sets address line 2 + * + * @param address2 Address line 2 + */ + public void setAddress2(@Nullable String address2) { + if (!isValidAddress2(address2)) { + throw new PropertyConstraintException(address2, "address2 is invalid"); + } + this.address2 = address2; + } + + /** + * Returns whether the given address2 is valid + * + * @param address2 the address2 to check the validity of + * @return {@code true} if address2 is valid, {@code false} if not + */ + private boolean isValidAddress2(@Nullable String address2) { + return address2 == null || address2.length() <= 100; + } + + /** + * Adds address line 2 + * + * @param address2 Address line 2 + * @return this + */ + public Address withAddress2(@Nullable String address2) { + setAddress2(address2); + return this; + } + + /** + * Gets city + * + * @return City + */ + public String getCity() { + return city; + } + + /** + * Sets city + * + * @param city City + */ + public void setCity(String city) { + if (!isValidCity(city)) { + throw new PropertyConstraintException(city, "city is invalid"); + } + this.city = city; + } + + /** + * Returns whether the given city is valid + * + * @param city the city to check the validity of + * @return {@code true} if city is valid, {@code false} if not + */ + private boolean isValidCity(String city) { + return city != null && city.length() <= 100; + } + + /** + * Gets postal code + * + * @return Postal code + */ + @Nullable + public String getPostalCode() { + return postalCode; + } + + /** + * Sets postal code + * + * @param postalCode Postal code + */ + public void setPostalCode(@Nullable String postalCode) { + if (!isValidPostalCode(postalCode)) { + throw new PropertyConstraintException(postalCode, "postalCode is invalid"); + } + this.postalCode = postalCode; + } + + /** + * Returns whether the given postalCode is valid + * + * @param postalCode the postalCode to check the validity of + * @return {@code true} if postalCode is valid, {@code false} if not + */ + private boolean isValidPostalCode(@Nullable String postalCode) { + return postalCode == null || postalCode.length() <= 20; + } + + /** + * Adds postal code + * + * @param postalCode Postal code + * @return this + */ + public Address withPostalCode(@Nullable String postalCode) { + setPostalCode(postalCode); + return this; + } + + /** + * Gets country name + * + * @return Country name + */ + public String getCountry() { + return country; + } + + /** + * Sets country name + * + * @param country Country name + */ + public void setCountry(String country) { + if (!isValidCountry(country)) { + throw new PropertyConstraintException(country, "country is invalid"); + } + this.country = country; + } + + /** + * Returns whether the given country is valid + * + * @param country the country to check the validity of + * @return {@code true} if country is valid, {@code false} if not + */ + private boolean isValidCountry(String country) { + return country != null && country.length() <= 50; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Address withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidName(name) + && isValidAddress1(address1) + && isValidAddress2(address2) + && isValidCity(city) + && isValidPostalCode(postalCode) + && isValidCountry(country) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Address that = (Address) o; + return Objects.equals(name, that.name) + && Objects.equals(address1, that.address1) + && Objects.equals(address2, that.address2) + && Objects.equals(city, that.city) + && Objects.equals(postalCode, that.postalCode) + && Objects.equals(country, that.country) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(name, address1, address2, city, postalCode, country, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("name", name) + .add("address1", address1) + .add("address2", address2) + .add("city", city) + .add("postalCode", postalCode) + .add("country", country) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AttributeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AttributeEnum.java new file mode 100644 index 00000000..b7645068 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AttributeEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. */ +public enum AttributeEnum { + Actual, + Target, + MinSet, + MaxSet +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizationData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizationData.java new file mode 100644 index 00000000..414d7eb3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizationData.java @@ -0,0 +1,221 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** The identifier to use for authorization. */ +public final class AuthorizationData { + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** + * Status information about an identifier. It is advised to not stop charging for a token that + * expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not + * given, the status has no end date. + */ + @Nullable private IdTokenInfo idTokenInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the AuthorizationData class + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + */ + public AuthorizationData(IdToken idToken) { + setIdToken(idToken); + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @return Status information about an identifier + */ + @Nullable + public IdTokenInfo getIdTokenInfo() { + return idTokenInfo; + } + + /** + * Sets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + */ + public void setIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + if (!isValidIdTokenInfo(idTokenInfo)) { + throw new PropertyConstraintException(idTokenInfo, "idTokenInfo is invalid"); + } + this.idTokenInfo = idTokenInfo; + } + + /** + * Returns whether the given idTokenInfo is valid + * + * @param idTokenInfo the idTokenInfo to check the validity of + * @return {@code true} if idTokenInfo is valid, {@code false} if not + */ + private boolean isValidIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + return idTokenInfo == null || idTokenInfo.validate(); + } + + /** + * Adds status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + * @return this + */ + public AuthorizationData withIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + setIdTokenInfo(idTokenInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AuthorizationData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidIdToken(idToken) + && isValidIdTokenInfo(idTokenInfo) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthorizationData that = (AuthorizationData) o; + return Objects.equals(idToken, that.idToken) + && Objects.equals(idTokenInfo, that.idTokenInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(idToken, idTokenInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("idToken", idToken) + .add("idTokenInfo", idTokenInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizationStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizationStatusEnum.java new file mode 100644 index 00000000..ce0b7355 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizationStatusEnum.java @@ -0,0 +1,39 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Current status of the ID Token. */ +public enum AuthorizationStatusEnum { + Accepted, + Blocked, + ConcurrentTx, + Expired, + Invalid, + NoCredit, + NotAllowedTypeEVSE, + NotAtThisLocation, + NotAtThisTime, + Unknown +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizeCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizeCertificateStatusEnum.java new file mode 100644 index 00000000..e5676aff --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/AuthorizeCertificateStatusEnum.java @@ -0,0 +1,43 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Certificate status information. + * + *

+ * - if all certificates are valid: return 'Accepted'.
+ * - if one of the certificates was revoked, return 'CertificateRevoked'.
+ * 
+ */ +public enum AuthorizeCertificateStatusEnum { + Accepted, + SignatureError, + CertificateExpired, + CertificateRevoked, + NoCertificateAvailable, + CertChainError, + ContractCancelled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BatteryData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BatteryData.java new file mode 100644 index 00000000..32e4974f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BatteryData.java @@ -0,0 +1,356 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** BatteryDataType */ +public final class BatteryData { + /** Slot number where battery is inserted or removed. */ + private Integer evseId; + + /** Serial number of battery. */ + private String serialNumber; + + /** State of charge */ + private Double soC; + + /** State of health */ + private Double soH; + + /** Production date of battery. */ + @Nullable private ZonedDateTime productionDate; + + /** Vendor-specific info from battery in undefined format. */ + @Nullable private String vendorInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the BatteryData class + * + * @param evseId Slot number where battery is inserted or removed. + * @param serialNumber Serial number of battery. + * @param soC State of charge + * @param soH State of health + */ + public BatteryData(Integer evseId, String serialNumber, Double soC, Double soH) { + setEvseId(evseId); + setSerialNumber(serialNumber); + setSoC(soC); + setSoH(soH); + } + + /** + * Gets slot number where battery is inserted or removed. + * + * @return Slot number where battery is inserted or removed + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets slot number where battery is inserted or removed. + * + * @param evseId Slot number where battery is inserted or removed + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets serial number of battery. + * + * @return Serial number of battery + */ + public String getSerialNumber() { + return serialNumber; + } + + /** + * Sets serial number of battery. + * + * @param serialNumber Serial number of battery + */ + public void setSerialNumber(String serialNumber) { + if (!isValidSerialNumber(serialNumber)) { + throw new PropertyConstraintException(serialNumber, "serialNumber is invalid"); + } + this.serialNumber = serialNumber; + } + + /** + * Returns whether the given serialNumber is valid + * + * @param serialNumber the serialNumber to check the validity of + * @return {@code true} if serialNumber is valid, {@code false} if not + */ + private boolean isValidSerialNumber(String serialNumber) { + return serialNumber != null && serialNumber.length() <= 50; + } + + /** + * Gets state of charge + * + * @return State of charge + */ + public Double getSoC() { + return soC; + } + + /** + * Sets state of charge + * + * @param soC State of charge + */ + public void setSoC(Double soC) { + if (!isValidSoC(soC)) { + throw new PropertyConstraintException(soC, "soC is invalid"); + } + this.soC = soC; + } + + /** + * Returns whether the given soC is valid + * + * @param soC the soC to check the validity of + * @return {@code true} if soC is valid, {@code false} if not + */ + private boolean isValidSoC(Double soC) { + return soC != null && soC >= 0.0d && soC <= 100.0d; + } + + /** + * Gets state of health + * + * @return State of health + */ + public Double getSoH() { + return soH; + } + + /** + * Sets state of health + * + * @param soH State of health + */ + public void setSoH(Double soH) { + if (!isValidSoH(soH)) { + throw new PropertyConstraintException(soH, "soH is invalid"); + } + this.soH = soH; + } + + /** + * Returns whether the given soH is valid + * + * @param soH the soH to check the validity of + * @return {@code true} if soH is valid, {@code false} if not + */ + private boolean isValidSoH(Double soH) { + return soH != null && soH >= 0.0d && soH <= 100.0d; + } + + /** + * Gets production date of battery. + * + * @return Production date of battery + */ + @Nullable + public ZonedDateTime getProductionDate() { + return productionDate; + } + + /** + * Sets production date of battery. + * + * @param productionDate Production date of battery + */ + public void setProductionDate(@Nullable ZonedDateTime productionDate) { + this.productionDate = productionDate; + } + + /** + * Adds production date of battery. + * + * @param productionDate Production date of battery + * @return this + */ + public BatteryData withProductionDate(@Nullable ZonedDateTime productionDate) { + setProductionDate(productionDate); + return this; + } + + /** + * Gets vendor-specific info from battery in undefined format. + * + * @return Vendor-specific info from battery in undefined format + */ + @Nullable + public String getVendorInfo() { + return vendorInfo; + } + + /** + * Sets vendor-specific info from battery in undefined format. + * + * @param vendorInfo Vendor-specific info from battery in undefined format + */ + public void setVendorInfo(@Nullable String vendorInfo) { + if (!isValidVendorInfo(vendorInfo)) { + throw new PropertyConstraintException(vendorInfo, "vendorInfo is invalid"); + } + this.vendorInfo = vendorInfo; + } + + /** + * Returns whether the given vendorInfo is valid + * + * @param vendorInfo the vendorInfo to check the validity of + * @return {@code true} if vendorInfo is valid, {@code false} if not + */ + private boolean isValidVendorInfo(@Nullable String vendorInfo) { + return vendorInfo == null || vendorInfo.length() <= 500; + } + + /** + * Adds vendor-specific info from battery in undefined format. + * + * @param vendorInfo Vendor-specific info from battery in undefined format + * @return this + */ + public BatteryData withVendorInfo(@Nullable String vendorInfo) { + setVendorInfo(vendorInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public BatteryData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEvseId(evseId) + && isValidSerialNumber(serialNumber) + && isValidSoC(soC) + && isValidSoH(soH) + && isValidVendorInfo(vendorInfo) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatteryData that = (BatteryData) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(serialNumber, that.serialNumber) + && Objects.equals(soC, that.soC) + && Objects.equals(soH, that.soH) + && Objects.equals(productionDate, that.productionDate) + && Objects.equals(vendorInfo, that.vendorInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, serialNumber, soC, soH, productionDate, vendorInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("serialNumber", serialNumber) + .add("soC", soC) + .add("soH", soH) + .add("productionDate", productionDate) + .add("vendorInfo", vendorInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BatterySwapEventEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BatterySwapEventEnum.java new file mode 100644 index 00000000..186f60b7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BatterySwapEventEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Battery in/out */ +public enum BatterySwapEventEnum { + BatteryIn, + BatteryOut, + BatteryOutTimeout +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BootReasonEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BootReasonEnum.java new file mode 100644 index 00000000..28d56f5f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/BootReasonEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The reason for sending this message to the CSMS. */ +public enum BootReasonEnum { + ApplicationReset, + FirmwareUpdate, + LocalReset, + PowerUp, + RemoteReset, + ScheduledReset, + Triggered, + Unknown, + Watchdog +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CancelReservationStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CancelReservationStatusEnum.java new file mode 100644 index 00000000..270e64ca --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CancelReservationStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The success or failure of the canceling of a reservation by CSMS. */ +public enum CancelReservationStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateActionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateActionEnum.java new file mode 100644 index 00000000..1c9e505e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateActionEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether certificate needs to be installed or updated. */ +public enum CertificateActionEnum { + Install, + Update +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateHashData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateHashData.java new file mode 100644 index 00000000..b7e60135 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateHashData.java @@ -0,0 +1,299 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** CertificateHashDataType */ +public final class CertificateHashData { + /** Used algorithms for the hashes provided. */ + private HashAlgorithmEnum hashAlgorithm; + + /** + * The hash of the issuer’s distinguished name (DN), that must be calculated over the DER encoding + * of the issuer’s name field in the certificate being checked. + */ + private String issuerNameHash; + + /** + * The hash of the DER encoded public key: the value (excluding tag and length) of the subject + * public key field in the issuer’s certificate. + */ + private String issuerKeyHash; + + /** + * The string representation of the hexadecimal value of the serial number without the prefix "0x" + * and without leading zeroes. + */ + private String serialNumber; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CertificateHashData class + * + * @param hashAlgorithm Used algorithms for the hashes provided. + * @param issuerNameHash The hash of the issuer’s distinguished name (DN), that must be calculated + * over the DER encoding of the issuer’s name field in the certificate being checked. + * @param issuerKeyHash The hash of the DER encoded public key: the value (excluding tag and + * length) of the subject public key field in the issuer’s certificate. + * @param serialNumber The string representation of the hexadecimal value of the serial number + * without the prefix "0x" and without leading zeroes. + */ + public CertificateHashData( + HashAlgorithmEnum hashAlgorithm, + String issuerNameHash, + String issuerKeyHash, + String serialNumber) { + setHashAlgorithm(hashAlgorithm); + setIssuerNameHash(issuerNameHash); + setIssuerKeyHash(issuerKeyHash); + setSerialNumber(serialNumber); + } + + /** + * Gets used algorithms for the hashes provided. + * + * @return Used algorithms for the hashes provided + */ + public HashAlgorithmEnum getHashAlgorithm() { + return hashAlgorithm; + } + + /** + * Sets used algorithms for the hashes provided. + * + * @param hashAlgorithm Used algorithms for the hashes provided + */ + public void setHashAlgorithm(HashAlgorithmEnum hashAlgorithm) { + if (!isValidHashAlgorithm(hashAlgorithm)) { + throw new PropertyConstraintException(hashAlgorithm, "hashAlgorithm is invalid"); + } + this.hashAlgorithm = hashAlgorithm; + } + + /** + * Returns whether the given hashAlgorithm is valid + * + * @param hashAlgorithm the hashAlgorithm to check the validity of + * @return {@code true} if hashAlgorithm is valid, {@code false} if not + */ + private boolean isValidHashAlgorithm(HashAlgorithmEnum hashAlgorithm) { + return hashAlgorithm != null; + } + + /** + * Gets the hash of the issuer’s distinguished name (DN), that must be calculated over the DER + * encoding of the issuer’s name field in the certificate being checked. + * + * @return The hash of the issuer’s distinguished name (DN), that must be calculated over the DER + * encoding of the issuer’s name field in the certificate being checked + */ + public String getIssuerNameHash() { + return issuerNameHash; + } + + /** + * Sets the hash of the issuer’s distinguished name (DN), that must be calculated over the DER + * encoding of the issuer’s name field in the certificate being checked. + * + * @param issuerNameHash The hash of the issuer’s distinguished name (DN), that must be calculated + * over the DER encoding of the issuer’s name field in the certificate being checked + */ + public void setIssuerNameHash(String issuerNameHash) { + if (!isValidIssuerNameHash(issuerNameHash)) { + throw new PropertyConstraintException(issuerNameHash, "issuerNameHash is invalid"); + } + this.issuerNameHash = issuerNameHash; + } + + /** + * Returns whether the given issuerNameHash is valid + * + * @param issuerNameHash the issuerNameHash to check the validity of + * @return {@code true} if issuerNameHash is valid, {@code false} if not + */ + private boolean isValidIssuerNameHash(String issuerNameHash) { + return issuerNameHash != null && issuerNameHash.length() <= 128; + } + + /** + * Gets the hash of the DER encoded public key: the value (excluding tag and length) of the + * subject public key field in the issuer’s certificate. + * + * @return The hash of the DER encoded public key: the value (excluding tag and length) of the + * subject public key field in the issuer’s certificate + */ + public String getIssuerKeyHash() { + return issuerKeyHash; + } + + /** + * Sets the hash of the DER encoded public key: the value (excluding tag and length) of the + * subject public key field in the issuer’s certificate. + * + * @param issuerKeyHash The hash of the DER encoded public key: the value (excluding tag and + * length) of the subject public key field in the issuer’s certificate + */ + public void setIssuerKeyHash(String issuerKeyHash) { + if (!isValidIssuerKeyHash(issuerKeyHash)) { + throw new PropertyConstraintException(issuerKeyHash, "issuerKeyHash is invalid"); + } + this.issuerKeyHash = issuerKeyHash; + } + + /** + * Returns whether the given issuerKeyHash is valid + * + * @param issuerKeyHash the issuerKeyHash to check the validity of + * @return {@code true} if issuerKeyHash is valid, {@code false} if not + */ + private boolean isValidIssuerKeyHash(String issuerKeyHash) { + return issuerKeyHash != null && issuerKeyHash.length() <= 128; + } + + /** + * Gets the string representation of the hexadecimal value of the serial number without the prefix + * "0x" and without leading zeroes. + * + * @return The string representation of the hexadecimal value of the serial number without the + * prefix "0x" and without leading zeroes + */ + public String getSerialNumber() { + return serialNumber; + } + + /** + * Sets the string representation of the hexadecimal value of the serial number without the prefix + * "0x" and without leading zeroes. + * + * @param serialNumber The string representation of the hexadecimal value of the serial number + * without the prefix "0x" and without leading zeroes + */ + public void setSerialNumber(String serialNumber) { + if (!isValidSerialNumber(serialNumber)) { + throw new PropertyConstraintException(serialNumber, "serialNumber is invalid"); + } + this.serialNumber = serialNumber; + } + + /** + * Returns whether the given serialNumber is valid + * + * @param serialNumber the serialNumber to check the validity of + * @return {@code true} if serialNumber is valid, {@code false} if not + */ + private boolean isValidSerialNumber(String serialNumber) { + return serialNumber != null && serialNumber.length() <= 40; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateHashData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidHashAlgorithm(hashAlgorithm) + && isValidIssuerNameHash(issuerNameHash) + && isValidIssuerKeyHash(issuerKeyHash) + && isValidSerialNumber(serialNumber) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateHashData that = (CertificateHashData) o; + return Objects.equals(hashAlgorithm, that.hashAlgorithm) + && Objects.equals(issuerNameHash, that.issuerNameHash) + && Objects.equals(issuerKeyHash, that.issuerKeyHash) + && Objects.equals(serialNumber, that.serialNumber) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(hashAlgorithm, issuerNameHash, issuerKeyHash, serialNumber, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("hashAlgorithm", hashAlgorithm) + .add("issuerNameHash", issuerNameHash) + .add("issuerKeyHash", issuerKeyHash) + .add("serialNumber", serialNumber) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateHashDataChain.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateHashDataChain.java new file mode 100644 index 00000000..8f2024f9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateHashDataChain.java @@ -0,0 +1,255 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** CertificateHashDataChainType */ +public final class CertificateHashDataChain { + /** certificateHashData */ + private CertificateHashData certificateHashData; + + /** The type of the requested certificate(s). */ + private GetCertificateIdUseEnum certificateType; + + /** childCertificateHashData */ + @Nullable private CertificateHashData[] childCertificateHashData; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CertificateHashDataChain class + * + * @param certificateHashData certificateHashData + * @param certificateType The type of the requested certificate(s). + */ + public CertificateHashDataChain( + CertificateHashData certificateHashData, GetCertificateIdUseEnum certificateType) { + setCertificateHashData(certificateHashData); + setCertificateType(certificateType); + } + + /** + * Gets certificateHashData + * + * @return certificateHashData + */ + public CertificateHashData getCertificateHashData() { + return certificateHashData; + } + + /** + * Sets certificateHashData + * + * @param certificateHashData certificateHashData + */ + public void setCertificateHashData(CertificateHashData certificateHashData) { + if (!isValidCertificateHashData(certificateHashData)) { + throw new PropertyConstraintException(certificateHashData, "certificateHashData is invalid"); + } + this.certificateHashData = certificateHashData; + } + + /** + * Returns whether the given certificateHashData is valid + * + * @param certificateHashData the certificateHashData to check the validity of + * @return {@code true} if certificateHashData is valid, {@code false} if not + */ + private boolean isValidCertificateHashData(CertificateHashData certificateHashData) { + return certificateHashData != null && certificateHashData.validate(); + } + + /** + * Gets the type of the requested certificate(s). + * + * @return The type of the requested certificate(s) + */ + public GetCertificateIdUseEnum getCertificateType() { + return certificateType; + } + + /** + * Sets the type of the requested certificate(s). + * + * @param certificateType The type of the requested certificate(s) + */ + public void setCertificateType(GetCertificateIdUseEnum certificateType) { + if (!isValidCertificateType(certificateType)) { + throw new PropertyConstraintException(certificateType, "certificateType is invalid"); + } + this.certificateType = certificateType; + } + + /** + * Returns whether the given certificateType is valid + * + * @param certificateType the certificateType to check the validity of + * @return {@code true} if certificateType is valid, {@code false} if not + */ + private boolean isValidCertificateType(GetCertificateIdUseEnum certificateType) { + return certificateType != null; + } + + /** + * Gets childCertificateHashData + * + * @return childCertificateHashData + */ + @Nullable + public CertificateHashData[] getChildCertificateHashData() { + return childCertificateHashData; + } + + /** + * Sets childCertificateHashData + * + * @param childCertificateHashData childCertificateHashData + */ + public void setChildCertificateHashData( + @Nullable CertificateHashData[] childCertificateHashData) { + if (!isValidChildCertificateHashData(childCertificateHashData)) { + throw new PropertyConstraintException( + childCertificateHashData, "childCertificateHashData is invalid"); + } + this.childCertificateHashData = childCertificateHashData; + } + + /** + * Returns whether the given childCertificateHashData is valid + * + * @param childCertificateHashData the childCertificateHashData to check the validity of + * @return {@code true} if childCertificateHashData is valid, {@code false} if not + */ + private boolean isValidChildCertificateHashData( + @Nullable CertificateHashData[] childCertificateHashData) { + return childCertificateHashData == null + || (childCertificateHashData.length >= 1 + && childCertificateHashData.length <= 4 + && Arrays.stream(childCertificateHashData).allMatch(item -> item.validate())); + } + + /** + * Adds childCertificateHashData + * + * @param childCertificateHashData childCertificateHashData + * @return this + */ + public CertificateHashDataChain withChildCertificateHashData( + @Nullable CertificateHashData[] childCertificateHashData) { + setChildCertificateHashData(childCertificateHashData); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateHashDataChain withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCertificateHashData(certificateHashData) + && isValidCertificateType(certificateType) + && isValidChildCertificateHashData(childCertificateHashData) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateHashDataChain that = (CertificateHashDataChain) o; + return Objects.equals(certificateHashData, that.certificateHashData) + && Objects.equals(certificateType, that.certificateType) + && Arrays.equals(childCertificateHashData, that.childCertificateHashData) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + certificateHashData, + certificateType, + Arrays.hashCode(childCertificateHashData), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateHashData", certificateHashData) + .add("certificateType", certificateType) + .add("childCertificateHashData", childCertificateHashData) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateSignedStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateSignedStatusEnum.java new file mode 100644 index 00000000..0e1ab767 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateSignedStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Returns whether certificate signing has been accepted, otherwise rejected. */ +public enum CertificateSignedStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateSigningUseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateSigningUseEnum.java new file mode 100644 index 00000000..4db93fd8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateSigningUseEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * The type of certificate that is to be signed. When omitted the certificate is to be used for both + * the 15118 connection (if implemented) and the Charging Station to CSMS connection. + */ +public enum CertificateSigningUseEnum { + ChargingStationCertificate, + V2GCertificate, + V2G20Certificate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatus.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatus.java new file mode 100644 index 00000000..1a96c3eb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatus.java @@ -0,0 +1,276 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Revocation status of certificate */ +public final class CertificateStatus { + /** certificateHashData */ + private CertificateHashData certificateHashData; + + /** Source of status: OCSP, CRL */ + private CertificateStatusSourceEnum source; + + /** Status of certificate: good, revoked or unknown. */ + private CertificateStatusEnum status; + + /** nextUpdate */ + private ZonedDateTime nextUpdate; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CertificateStatus class + * + * @param certificateHashData certificateHashData + * @param source Source of status: OCSP, CRL + * @param status Status of certificate: good, revoked or unknown. + * @param nextUpdate nextUpdate + */ + public CertificateStatus( + CertificateHashData certificateHashData, + CertificateStatusSourceEnum source, + CertificateStatusEnum status, + ZonedDateTime nextUpdate) { + setCertificateHashData(certificateHashData); + setSource(source); + setStatus(status); + setNextUpdate(nextUpdate); + } + + /** + * Gets certificateHashData + * + * @return certificateHashData + */ + public CertificateHashData getCertificateHashData() { + return certificateHashData; + } + + /** + * Sets certificateHashData + * + * @param certificateHashData certificateHashData + */ + public void setCertificateHashData(CertificateHashData certificateHashData) { + if (!isValidCertificateHashData(certificateHashData)) { + throw new PropertyConstraintException(certificateHashData, "certificateHashData is invalid"); + } + this.certificateHashData = certificateHashData; + } + + /** + * Returns whether the given certificateHashData is valid + * + * @param certificateHashData the certificateHashData to check the validity of + * @return {@code true} if certificateHashData is valid, {@code false} if not + */ + private boolean isValidCertificateHashData(CertificateHashData certificateHashData) { + return certificateHashData != null && certificateHashData.validate(); + } + + /** + * Gets source of status: OCSP, CRL + * + * @return Source of status: OCSP, CRL + */ + public CertificateStatusSourceEnum getSource() { + return source; + } + + /** + * Sets source of status: OCSP, CRL + * + * @param source Source of status: OCSP, CRL + */ + public void setSource(CertificateStatusSourceEnum source) { + if (!isValidSource(source)) { + throw new PropertyConstraintException(source, "source is invalid"); + } + this.source = source; + } + + /** + * Returns whether the given source is valid + * + * @param source the source to check the validity of + * @return {@code true} if source is valid, {@code false} if not + */ + private boolean isValidSource(CertificateStatusSourceEnum source) { + return source != null; + } + + /** + * Gets status of certificate: good, revoked or unknown. + * + * @return Status of certificate: good, revoked or unknown + */ + public CertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets status of certificate: good, revoked or unknown. + * + * @param status Status of certificate: good, revoked or unknown + */ + public void setStatus(CertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(CertificateStatusEnum status) { + return status != null; + } + + /** + * Gets nextUpdate + * + * @return nextUpdate + */ + public ZonedDateTime getNextUpdate() { + return nextUpdate; + } + + /** + * Sets nextUpdate + * + * @param nextUpdate nextUpdate + */ + public void setNextUpdate(ZonedDateTime nextUpdate) { + if (!isValidNextUpdate(nextUpdate)) { + throw new PropertyConstraintException(nextUpdate, "nextUpdate is invalid"); + } + this.nextUpdate = nextUpdate; + } + + /** + * Returns whether the given nextUpdate is valid + * + * @param nextUpdate the nextUpdate to check the validity of + * @return {@code true} if nextUpdate is valid, {@code false} if not + */ + private boolean isValidNextUpdate(ZonedDateTime nextUpdate) { + return nextUpdate != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateStatus withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCertificateHashData(certificateHashData) + && isValidSource(source) + && isValidStatus(status) + && isValidNextUpdate(nextUpdate) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateStatus that = (CertificateStatus) o; + return Objects.equals(certificateHashData, that.certificateHashData) + && Objects.equals(source, that.source) + && Objects.equals(status, that.status) + && Objects.equals(nextUpdate, that.nextUpdate) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(certificateHashData, source, status, nextUpdate, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateHashData", certificateHashData) + .add("source", source) + .add("status", status) + .add("nextUpdate", nextUpdate) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusEnum.java new file mode 100644 index 00000000..a276f9a2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Status of certificate: good, revoked or unknown. */ +public enum CertificateStatusEnum { + Good, + Revoked, + Unknown, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusRequestInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusRequestInfo.java new file mode 100644 index 00000000..69a9527b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusRequestInfo.java @@ -0,0 +1,237 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Data necessary to request the revocation status of a certificate. */ +public final class CertificateStatusRequestInfo { + /** certificateHashData */ + private CertificateHashData certificateHashData; + + /** Source of status: OCSP, CRL */ + private CertificateStatusSourceEnum source; + + /** URL(s) of source. */ + private String[] urls; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CertificateStatusRequestInfo class + * + * @param certificateHashData certificateHashData + * @param source Source of status: OCSP, CRL + * @param urls URL(s) of source. + */ + public CertificateStatusRequestInfo( + CertificateHashData certificateHashData, CertificateStatusSourceEnum source, String[] urls) { + setCertificateHashData(certificateHashData); + setSource(source); + setUrls(urls); + } + + /** + * Gets certificateHashData + * + * @return certificateHashData + */ + public CertificateHashData getCertificateHashData() { + return certificateHashData; + } + + /** + * Sets certificateHashData + * + * @param certificateHashData certificateHashData + */ + public void setCertificateHashData(CertificateHashData certificateHashData) { + if (!isValidCertificateHashData(certificateHashData)) { + throw new PropertyConstraintException(certificateHashData, "certificateHashData is invalid"); + } + this.certificateHashData = certificateHashData; + } + + /** + * Returns whether the given certificateHashData is valid + * + * @param certificateHashData the certificateHashData to check the validity of + * @return {@code true} if certificateHashData is valid, {@code false} if not + */ + private boolean isValidCertificateHashData(CertificateHashData certificateHashData) { + return certificateHashData != null && certificateHashData.validate(); + } + + /** + * Gets source of status: OCSP, CRL + * + * @return Source of status: OCSP, CRL + */ + public CertificateStatusSourceEnum getSource() { + return source; + } + + /** + * Sets source of status: OCSP, CRL + * + * @param source Source of status: OCSP, CRL + */ + public void setSource(CertificateStatusSourceEnum source) { + if (!isValidSource(source)) { + throw new PropertyConstraintException(source, "source is invalid"); + } + this.source = source; + } + + /** + * Returns whether the given source is valid + * + * @param source the source to check the validity of + * @return {@code true} if source is valid, {@code false} if not + */ + private boolean isValidSource(CertificateStatusSourceEnum source) { + return source != null; + } + + /** + * Gets URL(s) of source. + * + * @return URL(s) of source + */ + public String[] getUrls() { + return urls; + } + + /** + * Sets URL(s) of source. + * + * @param urls URL(s) of source + */ + public void setUrls(String[] urls) { + if (!isValidUrls(urls)) { + throw new PropertyConstraintException(urls, "urls is invalid"); + } + this.urls = urls; + } + + /** + * Returns whether the given urls is valid + * + * @param urls the urls to check the validity of + * @return {@code true} if urls is valid, {@code false} if not + */ + private boolean isValidUrls(String[] urls) { + return urls != null + && urls.length >= 1 + && urls.length <= 5 + && Arrays.stream(urls).allMatch(item -> item.length() <= 2000); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateStatusRequestInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCertificateHashData(certificateHashData) + && isValidSource(source) + && isValidUrls(urls) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateStatusRequestInfo that = (CertificateStatusRequestInfo) o; + return Objects.equals(certificateHashData, that.certificateHashData) + && Objects.equals(source, that.source) + && Arrays.equals(urls, that.urls) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(certificateHashData, source, Arrays.hashCode(urls), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("certificateHashData", certificateHashData) + .add("source", source) + .add("urls", urls) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusSourceEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusSourceEnum.java new file mode 100644 index 00000000..cc14aabc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CertificateStatusSourceEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Source of status: OCSP, CRL */ +public enum CertificateStatusSourceEnum { + CRL, + OCSP +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChangeAvailabilityStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChangeAvailabilityStatusEnum.java new file mode 100644 index 00000000..01713077 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChangeAvailabilityStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Charging Station is able to perform the availability change. */ +public enum ChangeAvailabilityStatusEnum { + Accepted, + Rejected, + Scheduled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingLimit.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingLimit.java new file mode 100644 index 00000000..2f2f1def --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingLimit.java @@ -0,0 +1,238 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** ChargingLimitType */ +public final class ChargingLimit { + /** + * The source of the charging limit. Values defined in appendix as + * ChargingLimitSourceEnumStringType. + */ + private String chargingLimitSource; + + /** + * True when the reported limit concerns local generation that is providing extra capacity, + * instead of a limitation. + */ + @Nullable private Boolean isLocalGeneration; + + /** Whether the charging limit is critical for the grid. */ + @Nullable private Boolean isGridCritical; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChargingLimit class + * + * @param chargingLimitSource The source of the charging limit. Values defined in appendix as + * ChargingLimitSourceEnumStringType. + */ + public ChargingLimit(String chargingLimitSource) { + setChargingLimitSource(chargingLimitSource); + } + + /** + * Gets the source of the charging limit. Values defined in appendix as + * ChargingLimitSourceEnumStringType. + * + * @return The source of the charging limit + */ + public String getChargingLimitSource() { + return chargingLimitSource; + } + + /** + * Sets the source of the charging limit. Values defined in appendix as + * ChargingLimitSourceEnumStringType. + * + * @param chargingLimitSource The source of the charging limit + */ + public void setChargingLimitSource(String chargingLimitSource) { + if (!isValidChargingLimitSource(chargingLimitSource)) { + throw new PropertyConstraintException(chargingLimitSource, "chargingLimitSource is invalid"); + } + this.chargingLimitSource = chargingLimitSource; + } + + /** + * Returns whether the given chargingLimitSource is valid + * + * @param chargingLimitSource the chargingLimitSource to check the validity of + * @return {@code true} if chargingLimitSource is valid, {@code false} if not + */ + private boolean isValidChargingLimitSource(String chargingLimitSource) { + return chargingLimitSource != null && chargingLimitSource.length() <= 20; + } + + /** + * Gets true when the reported limit concerns local generation that is providing extra capacity, + * instead of a limitation. + * + * @return True when the reported limit concerns local generation that is providing extra + * capacity, instead of a limitation + */ + @Nullable + public Boolean getIsLocalGeneration() { + return isLocalGeneration; + } + + /** + * Sets true when the reported limit concerns local generation that is providing extra capacity, + * instead of a limitation. + * + * @param isLocalGeneration True when the reported limit concerns local generation that is + * providing extra capacity, instead of a limitation + */ + public void setIsLocalGeneration(@Nullable Boolean isLocalGeneration) { + this.isLocalGeneration = isLocalGeneration; + } + + /** + * Adds true when the reported limit concerns local generation that is providing extra capacity, + * instead of a limitation. + * + * @param isLocalGeneration True when the reported limit concerns local generation that is + * providing extra capacity, instead of a limitation + * @return this + */ + public ChargingLimit withIsLocalGeneration(@Nullable Boolean isLocalGeneration) { + setIsLocalGeneration(isLocalGeneration); + return this; + } + + /** + * Gets whether the charging limit is critical for the grid. + * + * @return Whether the charging limit is critical for the grid + */ + @Nullable + public Boolean getIsGridCritical() { + return isGridCritical; + } + + /** + * Sets whether the charging limit is critical for the grid. + * + * @param isGridCritical Whether the charging limit is critical for the grid + */ + public void setIsGridCritical(@Nullable Boolean isGridCritical) { + this.isGridCritical = isGridCritical; + } + + /** + * Adds whether the charging limit is critical for the grid. + * + * @param isGridCritical Whether the charging limit is critical for the grid + * @return this + */ + public ChargingLimit withIsGridCritical(@Nullable Boolean isGridCritical) { + setIsGridCritical(isGridCritical); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingLimit withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidChargingLimitSource(chargingLimitSource) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingLimit that = (ChargingLimit) o; + return Objects.equals(chargingLimitSource, that.chargingLimitSource) + && Objects.equals(isLocalGeneration, that.isLocalGeneration) + && Objects.equals(isGridCritical, that.isGridCritical) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(chargingLimitSource, isLocalGeneration, isGridCritical, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingLimitSource", chargingLimitSource) + .add("isLocalGeneration", isLocalGeneration) + .add("isGridCritical", isGridCritical) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingNeeds.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingNeeds.java new file mode 100644 index 00000000..77107032 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingNeeds.java @@ -0,0 +1,662 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** ChargingNeedsType */ +public final class ChargingNeeds { + /** EV AC charging parameters for ISO 15118-2 */ + @Nullable private ACChargingParameters acChargingParameters; + + /** + * DERChargingParametersType is used in ChargingNeedsType during an ISO 15118-20 session for + * ACBPTDER to report the inverter settings related to DER control that were agreed between EVSE + * and EV. + * + *

Fields starting with "ev" contain values from the EV. Other fields contain a value that is + * supported by both EV and EVSE. + * + *

DERChargingParametersType type is only relevant in case of an ISO 15118-20 ACBPTDER/ACDER + * charging session. + * + *

NOTE: All these fields have values greater or equal to zero (i.e. are non-negative) + */ + @Nullable private DERChargingParameters derChargingParameters; + + /** + * A schedule of the energy amount over time that EV is willing to discharge. A negative value + * indicates the willingness to discharge under specific conditions, a positive value indicates + * that the EV currently is not able to offer energy to discharge. + */ + @Nullable private EVEnergyOffer evEnergyOffer; + + /** Mode of energy transfer requested by the EV. */ + private EnergyTransferModeEnum requestedEnergyTransfer; + + /** EV DC charging parameters for ISO 15118-2 */ + @Nullable private DCChargingParameters dcChargingParameters; + + /** + * Charging parameters for ISO 15118-20, also supporting V2X charging/discharging.+ All values are + * greater or equal to zero, with the exception of EVMinEnergyRequest, EVMaxEnergyRequest, + * EVTargetEnergyRequest, EVMinV2XEnergyRequest and EVMaxV2XEnergyRequest. + */ + @Nullable private V2XChargingParameters v2xChargingParameters; + + /** Modes of energy transfer that are marked as available by EV. */ + @Nullable private EnergyTransferModeEnum[] availableEnergyTransfer; + + /** + * Whether EV wants to operate in Dynamic or Scheduled mode. When absent, Scheduled mode is + * assumed for backwards compatibility. + * + *

+   * *ISO 15118-20:*
+   * ServiceSelectionReq(SelectedEnergyTransferService)
+   * 
+ */ + @Nullable private ControlModeEnum controlMode; + + /** + * Value of EVCC indicates that EV determines min/target SOC and departure time. + * + *
+   * A value of EVCCSECC indicates that charging station or CSMS may also update min/target SOC and
+   * departure time.
+   * *ISO 15118-20:*
+   * ServiceSelectionReq(SelectedEnergyTransferService)
+   * 
+ */ + @Nullable private MobilityNeedsModeEnum mobilityNeedsMode; + + /** + * Estimated departure time of the EV. + * + *
+   * *ISO 15118-2:* AC/DCEVChargeParameterType: DepartureTime
+   * *ISO 15118-20:* Dynamic/ScheduledSEReqControlModeType: DepartureTIme
+   * 
+ */ + @Nullable private ZonedDateTime departureTime; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChargingNeeds class + * + * @param requestedEnergyTransfer Mode of energy transfer requested by the EV. + */ + public ChargingNeeds(EnergyTransferModeEnum requestedEnergyTransfer) { + setRequestedEnergyTransfer(requestedEnergyTransfer); + } + + /** + * Gets EV AC charging parameters for ISO 15118-2 + * + * @return EV AC charging parameters for ISO 15118-2 + */ + @Nullable + public ACChargingParameters getAcChargingParameters() { + return acChargingParameters; + } + + /** + * Sets EV AC charging parameters for ISO 15118-2 + * + * @param acChargingParameters EV AC charging parameters for ISO 15118-2 + */ + public void setAcChargingParameters(@Nullable ACChargingParameters acChargingParameters) { + if (!isValidAcChargingParameters(acChargingParameters)) { + throw new PropertyConstraintException( + acChargingParameters, "acChargingParameters is invalid"); + } + this.acChargingParameters = acChargingParameters; + } + + /** + * Returns whether the given acChargingParameters is valid + * + * @param acChargingParameters the acChargingParameters to check the validity of + * @return {@code true} if acChargingParameters is valid, {@code false} if not + */ + private boolean isValidAcChargingParameters(@Nullable ACChargingParameters acChargingParameters) { + return acChargingParameters == null || acChargingParameters.validate(); + } + + /** + * Adds EV AC charging parameters for ISO 15118-2 + * + * @param acChargingParameters EV AC charging parameters for ISO 15118-2 + * @return this + */ + public ChargingNeeds withAcChargingParameters( + @Nullable ACChargingParameters acChargingParameters) { + setAcChargingParameters(acChargingParameters); + return this; + } + + /** + * Gets DERChargingParametersType is used in ChargingNeedsType during an ISO 15118-20 session for + * ACBPTDER to report the inverter settings related to DER control that were agreed between EVSE + * and EV. + * + * @return DERChargingParametersType is used in ChargingNeedsType during an ISO 15118-20 session + * for ACBPTDER to report the inverter settings related to DER control that were agreed + * between EVSE and EV + */ + @Nullable + public DERChargingParameters getDerChargingParameters() { + return derChargingParameters; + } + + /** + * Sets DERChargingParametersType is used in ChargingNeedsType during an ISO 15118-20 session for + * ACBPTDER to report the inverter settings related to DER control that were agreed between EVSE + * and EV. + * + * @param derChargingParameters DERChargingParametersType is used in ChargingNeedsType during an + * ISO 15118-20 session for ACBPTDER to report the inverter settings related to DER control + * that were agreed between EVSE and EV + */ + public void setDerChargingParameters(@Nullable DERChargingParameters derChargingParameters) { + if (!isValidDerChargingParameters(derChargingParameters)) { + throw new PropertyConstraintException( + derChargingParameters, "derChargingParameters is invalid"); + } + this.derChargingParameters = derChargingParameters; + } + + /** + * Returns whether the given derChargingParameters is valid + * + * @param derChargingParameters the derChargingParameters to check the validity of + * @return {@code true} if derChargingParameters is valid, {@code false} if not + */ + private boolean isValidDerChargingParameters( + @Nullable DERChargingParameters derChargingParameters) { + return derChargingParameters == null || derChargingParameters.validate(); + } + + /** + * Adds DERChargingParametersType is used in ChargingNeedsType during an ISO 15118-20 session for + * ACBPTDER to report the inverter settings related to DER control that were agreed between EVSE + * and EV. + * + * @param derChargingParameters DERChargingParametersType is used in ChargingNeedsType during an + * ISO 15118-20 session for ACBPTDER to report the inverter settings related to DER control + * that were agreed between EVSE and EV + * @return this + */ + public ChargingNeeds withDerChargingParameters( + @Nullable DERChargingParameters derChargingParameters) { + setDerChargingParameters(derChargingParameters); + return this; + } + + /** + * Gets a schedule of the energy amount over time that EV is willing to discharge. A negative + * value indicates the willingness to discharge under specific conditions, a positive value + * indicates that the EV currently is not able to offer energy to discharge. + * + * @return A schedule of the energy amount over time that EV is willing to discharge + */ + @Nullable + public EVEnergyOffer getEvEnergyOffer() { + return evEnergyOffer; + } + + /** + * Sets a schedule of the energy amount over time that EV is willing to discharge. A negative + * value indicates the willingness to discharge under specific conditions, a positive value + * indicates that the EV currently is not able to offer energy to discharge. + * + * @param evEnergyOffer A schedule of the energy amount over time that EV is willing to discharge + */ + public void setEvEnergyOffer(@Nullable EVEnergyOffer evEnergyOffer) { + if (!isValidEvEnergyOffer(evEnergyOffer)) { + throw new PropertyConstraintException(evEnergyOffer, "evEnergyOffer is invalid"); + } + this.evEnergyOffer = evEnergyOffer; + } + + /** + * Returns whether the given evEnergyOffer is valid + * + * @param evEnergyOffer the evEnergyOffer to check the validity of + * @return {@code true} if evEnergyOffer is valid, {@code false} if not + */ + private boolean isValidEvEnergyOffer(@Nullable EVEnergyOffer evEnergyOffer) { + return evEnergyOffer == null || evEnergyOffer.validate(); + } + + /** + * Adds a schedule of the energy amount over time that EV is willing to discharge. A negative + * value indicates the willingness to discharge under specific conditions, a positive value + * indicates that the EV currently is not able to offer energy to discharge. + * + * @param evEnergyOffer A schedule of the energy amount over time that EV is willing to discharge + * @return this + */ + public ChargingNeeds withEvEnergyOffer(@Nullable EVEnergyOffer evEnergyOffer) { + setEvEnergyOffer(evEnergyOffer); + return this; + } + + /** + * Gets mode of energy transfer requested by the EV. + * + * @return Mode of energy transfer requested by the EV + */ + public EnergyTransferModeEnum getRequestedEnergyTransfer() { + return requestedEnergyTransfer; + } + + /** + * Sets mode of energy transfer requested by the EV. + * + * @param requestedEnergyTransfer Mode of energy transfer requested by the EV + */ + public void setRequestedEnergyTransfer(EnergyTransferModeEnum requestedEnergyTransfer) { + if (!isValidRequestedEnergyTransfer(requestedEnergyTransfer)) { + throw new PropertyConstraintException( + requestedEnergyTransfer, "requestedEnergyTransfer is invalid"); + } + this.requestedEnergyTransfer = requestedEnergyTransfer; + } + + /** + * Returns whether the given requestedEnergyTransfer is valid + * + * @param requestedEnergyTransfer the requestedEnergyTransfer to check the validity of + * @return {@code true} if requestedEnergyTransfer is valid, {@code false} if not + */ + private boolean isValidRequestedEnergyTransfer(EnergyTransferModeEnum requestedEnergyTransfer) { + return requestedEnergyTransfer != null; + } + + /** + * Gets EV DC charging parameters for ISO 15118-2 + * + * @return EV DC charging parameters for ISO 15118-2 + */ + @Nullable + public DCChargingParameters getDcChargingParameters() { + return dcChargingParameters; + } + + /** + * Sets EV DC charging parameters for ISO 15118-2 + * + * @param dcChargingParameters EV DC charging parameters for ISO 15118-2 + */ + public void setDcChargingParameters(@Nullable DCChargingParameters dcChargingParameters) { + if (!isValidDcChargingParameters(dcChargingParameters)) { + throw new PropertyConstraintException( + dcChargingParameters, "dcChargingParameters is invalid"); + } + this.dcChargingParameters = dcChargingParameters; + } + + /** + * Returns whether the given dcChargingParameters is valid + * + * @param dcChargingParameters the dcChargingParameters to check the validity of + * @return {@code true} if dcChargingParameters is valid, {@code false} if not + */ + private boolean isValidDcChargingParameters(@Nullable DCChargingParameters dcChargingParameters) { + return dcChargingParameters == null || dcChargingParameters.validate(); + } + + /** + * Adds EV DC charging parameters for ISO 15118-2 + * + * @param dcChargingParameters EV DC charging parameters for ISO 15118-2 + * @return this + */ + public ChargingNeeds withDcChargingParameters( + @Nullable DCChargingParameters dcChargingParameters) { + setDcChargingParameters(dcChargingParameters); + return this; + } + + /** + * Gets charging parameters for ISO 15118-20, also supporting V2X charging/discharging.+ All + * values are greater or equal to zero, with the exception of EVMinEnergyRequest, + * EVMaxEnergyRequest, EVTargetEnergyRequest, EVMinV2XEnergyRequest and EVMaxV2XEnergyRequest. + * + * @return Charging parameters for ISO 15118-20, also supporting V2X charging/discharging.+ All + * values are greater or equal to zero, with the exception of EVMinEnergyRequest, + * EVMaxEnergyRequest, EVTargetEnergyRequest, EVMinV2XEnergyRequest and EVMaxV2XEnergyRequest + */ + @Nullable + public V2XChargingParameters getV2xChargingParameters() { + return v2xChargingParameters; + } + + /** + * Sets charging parameters for ISO 15118-20, also supporting V2X charging/discharging.+ All + * values are greater or equal to zero, with the exception of EVMinEnergyRequest, + * EVMaxEnergyRequest, EVTargetEnergyRequest, EVMinV2XEnergyRequest and EVMaxV2XEnergyRequest. + * + * @param v2xChargingParameters Charging parameters for ISO 15118-20, also supporting V2X + * charging/discharging.+ All values are greater or equal to zero, with the exception of + * EVMinEnergyRequest, EVMaxEnergyRequest, EVTargetEnergyRequest, EVMinV2XEnergyRequest and + * EVMaxV2XEnergyRequest + */ + public void setV2xChargingParameters(@Nullable V2XChargingParameters v2xChargingParameters) { + if (!isValidV2xChargingParameters(v2xChargingParameters)) { + throw new PropertyConstraintException( + v2xChargingParameters, "v2xChargingParameters is invalid"); + } + this.v2xChargingParameters = v2xChargingParameters; + } + + /** + * Returns whether the given v2xChargingParameters is valid + * + * @param v2xChargingParameters the v2xChargingParameters to check the validity of + * @return {@code true} if v2xChargingParameters is valid, {@code false} if not + */ + private boolean isValidV2xChargingParameters( + @Nullable V2XChargingParameters v2xChargingParameters) { + return v2xChargingParameters == null || v2xChargingParameters.validate(); + } + + /** + * Adds charging parameters for ISO 15118-20, also supporting V2X charging/discharging.+ All + * values are greater or equal to zero, with the exception of EVMinEnergyRequest, + * EVMaxEnergyRequest, EVTargetEnergyRequest, EVMinV2XEnergyRequest and EVMaxV2XEnergyRequest. + * + * @param v2xChargingParameters Charging parameters for ISO 15118-20, also supporting V2X + * charging/discharging.+ All values are greater or equal to zero, with the exception of + * EVMinEnergyRequest, EVMaxEnergyRequest, EVTargetEnergyRequest, EVMinV2XEnergyRequest and + * EVMaxV2XEnergyRequest + * @return this + */ + public ChargingNeeds withV2xChargingParameters( + @Nullable V2XChargingParameters v2xChargingParameters) { + setV2xChargingParameters(v2xChargingParameters); + return this; + } + + /** + * Gets modes of energy transfer that are marked as available by EV. + * + * @return Modes of energy transfer that are marked as available by EV + */ + @Nullable + public EnergyTransferModeEnum[] getAvailableEnergyTransfer() { + return availableEnergyTransfer; + } + + /** + * Sets modes of energy transfer that are marked as available by EV. + * + * @param availableEnergyTransfer Modes of energy transfer that are marked as available by EV + */ + public void setAvailableEnergyTransfer( + @Nullable EnergyTransferModeEnum[] availableEnergyTransfer) { + if (!isValidAvailableEnergyTransfer(availableEnergyTransfer)) { + throw new PropertyConstraintException( + availableEnergyTransfer, "availableEnergyTransfer is invalid"); + } + this.availableEnergyTransfer = availableEnergyTransfer; + } + + /** + * Returns whether the given availableEnergyTransfer is valid + * + * @param availableEnergyTransfer the availableEnergyTransfer to check the validity of + * @return {@code true} if availableEnergyTransfer is valid, {@code false} if not + */ + private boolean isValidAvailableEnergyTransfer( + @Nullable EnergyTransferModeEnum[] availableEnergyTransfer) { + return availableEnergyTransfer == null || (availableEnergyTransfer.length >= 1); + } + + /** + * Adds modes of energy transfer that are marked as available by EV. + * + * @param availableEnergyTransfer Modes of energy transfer that are marked as available by EV + * @return this + */ + public ChargingNeeds withAvailableEnergyTransfer( + @Nullable EnergyTransferModeEnum[] availableEnergyTransfer) { + setAvailableEnergyTransfer(availableEnergyTransfer); + return this; + } + + /** + * Gets whether EV wants to operate in Dynamic or Scheduled mode. When absent, Scheduled mode is + * assumed for backwards compatibility. + * + * @return Whether EV wants to operate in Dynamic or Scheduled mode + */ + @Nullable + public ControlModeEnum getControlMode() { + return controlMode; + } + + /** + * Sets whether EV wants to operate in Dynamic or Scheduled mode. When absent, Scheduled mode is + * assumed for backwards compatibility. + * + * @param controlMode Whether EV wants to operate in Dynamic or Scheduled mode + */ + public void setControlMode(@Nullable ControlModeEnum controlMode) { + this.controlMode = controlMode; + } + + /** + * Adds whether EV wants to operate in Dynamic or Scheduled mode. When absent, Scheduled mode is + * assumed for backwards compatibility. + * + * @param controlMode Whether EV wants to operate in Dynamic or Scheduled mode + * @return this + */ + public ChargingNeeds withControlMode(@Nullable ControlModeEnum controlMode) { + setControlMode(controlMode); + return this; + } + + /** + * Gets value of EVCC indicates that EV determines min/target SOC and departure time. + * + * @return Value of EVCC indicates that EV determines min/target SOC and departure time + */ + @Nullable + public MobilityNeedsModeEnum getMobilityNeedsMode() { + return mobilityNeedsMode; + } + + /** + * Sets value of EVCC indicates that EV determines min/target SOC and departure time. + * + * @param mobilityNeedsMode Value of EVCC indicates that EV determines min/target SOC and + * departure time + */ + public void setMobilityNeedsMode(@Nullable MobilityNeedsModeEnum mobilityNeedsMode) { + this.mobilityNeedsMode = mobilityNeedsMode; + } + + /** + * Adds value of EVCC indicates that EV determines min/target SOC and departure time. + * + * @param mobilityNeedsMode Value of EVCC indicates that EV determines min/target SOC and + * departure time + * @return this + */ + public ChargingNeeds withMobilityNeedsMode(@Nullable MobilityNeedsModeEnum mobilityNeedsMode) { + setMobilityNeedsMode(mobilityNeedsMode); + return this; + } + + /** + * Gets estimated departure time of the EV. + * + * @return Estimated departure time of the EV + */ + @Nullable + public ZonedDateTime getDepartureTime() { + return departureTime; + } + + /** + * Sets estimated departure time of the EV. + * + * @param departureTime Estimated departure time of the EV + */ + public void setDepartureTime(@Nullable ZonedDateTime departureTime) { + this.departureTime = departureTime; + } + + /** + * Adds estimated departure time of the EV. + * + * @param departureTime Estimated departure time of the EV + * @return this + */ + public ChargingNeeds withDepartureTime(@Nullable ZonedDateTime departureTime) { + setDepartureTime(departureTime); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingNeeds withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidAcChargingParameters(acChargingParameters) + && isValidDerChargingParameters(derChargingParameters) + && isValidEvEnergyOffer(evEnergyOffer) + && isValidRequestedEnergyTransfer(requestedEnergyTransfer) + && isValidDcChargingParameters(dcChargingParameters) + && isValidV2xChargingParameters(v2xChargingParameters) + && isValidAvailableEnergyTransfer(availableEnergyTransfer) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingNeeds that = (ChargingNeeds) o; + return Objects.equals(acChargingParameters, that.acChargingParameters) + && Objects.equals(derChargingParameters, that.derChargingParameters) + && Objects.equals(evEnergyOffer, that.evEnergyOffer) + && Objects.equals(requestedEnergyTransfer, that.requestedEnergyTransfer) + && Objects.equals(dcChargingParameters, that.dcChargingParameters) + && Objects.equals(v2xChargingParameters, that.v2xChargingParameters) + && Arrays.equals(availableEnergyTransfer, that.availableEnergyTransfer) + && Objects.equals(controlMode, that.controlMode) + && Objects.equals(mobilityNeedsMode, that.mobilityNeedsMode) + && Objects.equals(departureTime, that.departureTime) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + acChargingParameters, + derChargingParameters, + evEnergyOffer, + requestedEnergyTransfer, + dcChargingParameters, + v2xChargingParameters, + Arrays.hashCode(availableEnergyTransfer), + controlMode, + mobilityNeedsMode, + departureTime, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("acChargingParameters", acChargingParameters) + .add("derChargingParameters", derChargingParameters) + .add("evEnergyOffer", evEnergyOffer) + .add("requestedEnergyTransfer", requestedEnergyTransfer) + .add("dcChargingParameters", dcChargingParameters) + .add("v2xChargingParameters", v2xChargingParameters) + .add("availableEnergyTransfer", availableEnergyTransfer) + .add("controlMode", controlMode) + .add("mobilityNeedsMode", mobilityNeedsMode) + .add("departureTime", departureTime) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingPeriod.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingPeriod.java new file mode 100644 index 00000000..2b386f8f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingPeriod.java @@ -0,0 +1,271 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A ChargingPeriodType consists of a start time, and a list of possible values that influence this + * period, for example: amount of energy charged this period, maximum current during this period + * etc. + */ +public final class ChargingPeriod { + /** Volume consumed of cost dimension. */ + @Nullable private CostDimension[] dimensions; + + /** + * Unique identifier of the Tariff that was used to calculate cost. If not provided, then cost was + * calculated by some other means. + */ + @Nullable private String tariffId; + + /** + * Start timestamp of charging period. A period ends when the next period starts. The last period + * ends when the session ends. + */ + private ZonedDateTime startPeriod; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChargingPeriod class + * + * @param startPeriod Start timestamp of charging period. A period ends when the next period + * starts. The last period ends when the session ends. + */ + public ChargingPeriod(ZonedDateTime startPeriod) { + setStartPeriod(startPeriod); + } + + /** + * Gets volume consumed of cost dimension. + * + * @return Volume consumed of cost dimension + */ + @Nullable + public CostDimension[] getDimensions() { + return dimensions; + } + + /** + * Sets volume consumed of cost dimension. + * + * @param dimensions Volume consumed of cost dimension + */ + public void setDimensions(@Nullable CostDimension[] dimensions) { + if (!isValidDimensions(dimensions)) { + throw new PropertyConstraintException(dimensions, "dimensions is invalid"); + } + this.dimensions = dimensions; + } + + /** + * Returns whether the given dimensions is valid + * + * @param dimensions the dimensions to check the validity of + * @return {@code true} if dimensions is valid, {@code false} if not + */ + private boolean isValidDimensions(@Nullable CostDimension[] dimensions) { + return dimensions == null + || (dimensions.length >= 1 && Arrays.stream(dimensions).allMatch(item -> item.validate())); + } + + /** + * Adds volume consumed of cost dimension. + * + * @param dimensions Volume consumed of cost dimension + * @return this + */ + public ChargingPeriod withDimensions(@Nullable CostDimension[] dimensions) { + setDimensions(dimensions); + return this; + } + + /** + * Gets unique identifier of the Tariff that was used to calculate cost. If not provided, then + * cost was calculated by some other means. + * + * @return Unique identifier of the Tariff that was used to calculate cost + */ + @Nullable + public String getTariffId() { + return tariffId; + } + + /** + * Sets unique identifier of the Tariff that was used to calculate cost. If not provided, then + * cost was calculated by some other means. + * + * @param tariffId Unique identifier of the Tariff that was used to calculate cost + */ + public void setTariffId(@Nullable String tariffId) { + if (!isValidTariffId(tariffId)) { + throw new PropertyConstraintException(tariffId, "tariffId is invalid"); + } + this.tariffId = tariffId; + } + + /** + * Returns whether the given tariffId is valid + * + * @param tariffId the tariffId to check the validity of + * @return {@code true} if tariffId is valid, {@code false} if not + */ + private boolean isValidTariffId(@Nullable String tariffId) { + return tariffId == null || tariffId.length() <= 60; + } + + /** + * Adds unique identifier of the Tariff that was used to calculate cost. If not provided, then + * cost was calculated by some other means. + * + * @param tariffId Unique identifier of the Tariff that was used to calculate cost + * @return this + */ + public ChargingPeriod withTariffId(@Nullable String tariffId) { + setTariffId(tariffId); + return this; + } + + /** + * Gets start timestamp of charging period. A period ends when the next period starts. The last + * period ends when the session ends. + * + * @return Start timestamp of charging period + */ + public ZonedDateTime getStartPeriod() { + return startPeriod; + } + + /** + * Sets start timestamp of charging period. A period ends when the next period starts. The last + * period ends when the session ends. + * + * @param startPeriod Start timestamp of charging period + */ + public void setStartPeriod(ZonedDateTime startPeriod) { + if (!isValidStartPeriod(startPeriod)) { + throw new PropertyConstraintException(startPeriod, "startPeriod is invalid"); + } + this.startPeriod = startPeriod; + } + + /** + * Returns whether the given startPeriod is valid + * + * @param startPeriod the startPeriod to check the validity of + * @return {@code true} if startPeriod is valid, {@code false} if not + */ + private boolean isValidStartPeriod(ZonedDateTime startPeriod) { + return startPeriod != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingPeriod withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDimensions(dimensions) + && isValidTariffId(tariffId) + && isValidStartPeriod(startPeriod) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingPeriod that = (ChargingPeriod) o; + return Arrays.equals(dimensions, that.dimensions) + && Objects.equals(tariffId, that.tariffId) + && Objects.equals(startPeriod, that.startPeriod) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(dimensions), tariffId, startPeriod, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("dimensions", dimensions) + .add("tariffId", tariffId) + .add("startPeriod", startPeriod) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfile.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfile.java new file mode 100644 index 00000000..f8e84e80 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfile.java @@ -0,0 +1,824 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of ChargingSchedulePeriods, + * describing the amount of power or current that can be delivered per time interval. + * + *

image::images/ChargingProfile-Simple.png[] + */ +public final class ChargingProfile { + /** + * Id of ChargingProfile. Unique within charging station. Id can have a negative value. This is + * useful to distinguish charging profiles from an external actor (external constraints) from + * charging profiles received from CSMS. + */ + private Integer id; + + /** + * Value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + */ + private Integer stackLevel; + + /** The purpose of the schedule transferred by this profile */ + private ChargingProfilePurposeEnum chargingProfilePurpose; + + /** The kind of schedule. */ + private ChargingProfileKindEnum chargingProfileKind; + + /** The start point of a recurrence. */ + @Nullable private RecurrencyKindEnum recurrencyKind; + + /** + * Point in time at which the profile starts to be valid. If absent, the profile is valid as soon + * as it is received by the Charging Station. + */ + @Nullable private ZonedDateTime validFrom; + + /** + * Point in time at which the profile stops to be valid. If absent, the profile is valid until it + * is replaced by another profile. + */ + @Nullable private ZonedDateTime validTo; + + /** + * SHALL only be included if ChargingProfilePurpose is set to TxProfile in a + * SetChargingProfileRequest. The transactionId is used to match the profile to a specific + * transaction. + */ + @Nullable private String transactionId; + + /** + * Period in seconds that this charging profile remains valid after the Charging Station has gone + * offline. After this period the charging profile becomes invalid for as long as it is offline + * and the Charging Station reverts back to a valid profile with a lower stack level. If + * invalidAfterOfflineDuration is true, then this charging profile will become permanently + * invalid. A value of 0 means that the charging profile is immediately invalid while offline. + * When the field is absent, then no timeout applies and the charging profile remains valid when + * offline. + */ + @Nullable private Integer maxOfflineDuration; + + /** + * Charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + *

An ISO 15118-20 session may provide either an absolutePriceSchedule or a priceLevelSchedule. + * An ISO 15118-2 session can only provide asalesTariff element. The field digestValue is used + * when price schedule or sales tariff are signed. + * + *

image::images/ChargingSchedule-Simple.png[] + */ + private ChargingSchedule[] chargingSchedule; + + /** + * When set to true this charging profile will not be valid anymore after being offline for more + * than maxOfflineDuration. + * + *

When absent defaults to false. + */ + @Nullable private Boolean invalidAfterOfflineDuration; + + /** + * Interval in seconds after receipt of last update, when to request a profile update by sending a + * PullDynamicScheduleUpdateRequest message. + * + *

+   * A value of 0 or no value means that no update interval applies.
+   * Only relevant in a dynamic charging profile.
+   * 
+ */ + @Nullable private Integer dynUpdateInterval; + + /** + * Time at which limits or setpoints in this charging profile were last updated by a + * PullDynamicScheduleUpdateRequest or UpdateDynamicScheduleRequest or by an external actor. + * + *

Only relevant in a dynamic charging profile. + */ + @Nullable private ZonedDateTime dynUpdateTime; + + /** + * ISO 15118-20 signature for all price schedules in chargingSchedules. + * + *

Note: for 256-bit elliptic curves (like secp256k1) the ECDSA signature is 512 bits (64 + * bytes) and for 521-bit curves (like secp521r1) the signature is 1042 bits. This equals 131 + * bytes, which can be encoded as base64 in 176 bytes. + */ + @Nullable private String priceScheduleSignature; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChargingProfile class + * + * @param id Id of ChargingProfile. Unique within charging station. Id can have a negative value. + * This is useful to distinguish charging profiles from an external actor (external + * constraints) from charging profiles received from CSMS. + * @param stackLevel Value determining level in hierarchy stack of profiles. Higher values have + * precedence over lower values. Lowest level is 0. + * @param chargingProfilePurpose The purpose of the schedule transferred by this profile + * @param chargingProfileKind The kind of schedule. + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + */ + public ChargingProfile( + Integer id, + Integer stackLevel, + ChargingProfilePurposeEnum chargingProfilePurpose, + ChargingProfileKindEnum chargingProfileKind, + ChargingSchedule[] chargingSchedule) { + setId(id); + setStackLevel(stackLevel); + setChargingProfilePurpose(chargingProfilePurpose); + setChargingProfileKind(chargingProfileKind); + setChargingSchedule(chargingSchedule); + } + + /** + * Gets id of ChargingProfile. Unique within charging station. Id can have a negative value. This + * is useful to distinguish charging profiles from an external actor (external constraints) from + * charging profiles received from CSMS. + * + * @return Id of ChargingProfile + */ + public Integer getId() { + return id; + } + + /** + * Sets id of ChargingProfile. Unique within charging station. Id can have a negative value. This + * is useful to distinguish charging profiles from an external actor (external constraints) from + * charging profiles received from CSMS. + * + * @param id Id of ChargingProfile + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @return Value determining level in hierarchy stack of profiles + */ + public Integer getStackLevel() { + return stackLevel; + } + + /** + * Sets value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @param stackLevel Value determining level in hierarchy stack of profiles + */ + public void setStackLevel(Integer stackLevel) { + if (!isValidStackLevel(stackLevel)) { + throw new PropertyConstraintException(stackLevel, "stackLevel is invalid"); + } + this.stackLevel = stackLevel; + } + + /** + * Returns whether the given stackLevel is valid + * + * @param stackLevel the stackLevel to check the validity of + * @return {@code true} if stackLevel is valid, {@code false} if not + */ + private boolean isValidStackLevel(Integer stackLevel) { + return stackLevel != null && stackLevel >= 0; + } + + /** + * Gets the purpose of the schedule transferred by this profile + * + * @return The purpose of the schedule transferred by this profile + */ + public ChargingProfilePurposeEnum getChargingProfilePurpose() { + return chargingProfilePurpose; + } + + /** + * Sets the purpose of the schedule transferred by this profile + * + * @param chargingProfilePurpose The purpose of the schedule transferred by this profile + */ + public void setChargingProfilePurpose(ChargingProfilePurposeEnum chargingProfilePurpose) { + if (!isValidChargingProfilePurpose(chargingProfilePurpose)) { + throw new PropertyConstraintException( + chargingProfilePurpose, "chargingProfilePurpose is invalid"); + } + this.chargingProfilePurpose = chargingProfilePurpose; + } + + /** + * Returns whether the given chargingProfilePurpose is valid + * + * @param chargingProfilePurpose the chargingProfilePurpose to check the validity of + * @return {@code true} if chargingProfilePurpose is valid, {@code false} if not + */ + private boolean isValidChargingProfilePurpose(ChargingProfilePurposeEnum chargingProfilePurpose) { + return chargingProfilePurpose != null; + } + + /** + * Gets the kind of schedule. + * + * @return The kind of schedule + */ + public ChargingProfileKindEnum getChargingProfileKind() { + return chargingProfileKind; + } + + /** + * Sets the kind of schedule. + * + * @param chargingProfileKind The kind of schedule + */ + public void setChargingProfileKind(ChargingProfileKindEnum chargingProfileKind) { + if (!isValidChargingProfileKind(chargingProfileKind)) { + throw new PropertyConstraintException(chargingProfileKind, "chargingProfileKind is invalid"); + } + this.chargingProfileKind = chargingProfileKind; + } + + /** + * Returns whether the given chargingProfileKind is valid + * + * @param chargingProfileKind the chargingProfileKind to check the validity of + * @return {@code true} if chargingProfileKind is valid, {@code false} if not + */ + private boolean isValidChargingProfileKind(ChargingProfileKindEnum chargingProfileKind) { + return chargingProfileKind != null; + } + + /** + * Gets the start point of a recurrence. + * + * @return The start point of a recurrence + */ + @Nullable + public RecurrencyKindEnum getRecurrencyKind() { + return recurrencyKind; + } + + /** + * Sets the start point of a recurrence. + * + * @param recurrencyKind The start point of a recurrence + */ + public void setRecurrencyKind(@Nullable RecurrencyKindEnum recurrencyKind) { + this.recurrencyKind = recurrencyKind; + } + + /** + * Adds the start point of a recurrence. + * + * @param recurrencyKind The start point of a recurrence + * @return this + */ + public ChargingProfile withRecurrencyKind(@Nullable RecurrencyKindEnum recurrencyKind) { + setRecurrencyKind(recurrencyKind); + return this; + } + + /** + * Gets point in time at which the profile starts to be valid. If absent, the profile is valid as + * soon as it is received by the Charging Station. + * + * @return Point in time at which the profile starts to be valid + */ + @Nullable + public ZonedDateTime getValidFrom() { + return validFrom; + } + + /** + * Sets point in time at which the profile starts to be valid. If absent, the profile is valid as + * soon as it is received by the Charging Station. + * + * @param validFrom Point in time at which the profile starts to be valid + */ + public void setValidFrom(@Nullable ZonedDateTime validFrom) { + this.validFrom = validFrom; + } + + /** + * Adds point in time at which the profile starts to be valid. If absent, the profile is valid as + * soon as it is received by the Charging Station. + * + * @param validFrom Point in time at which the profile starts to be valid + * @return this + */ + public ChargingProfile withValidFrom(@Nullable ZonedDateTime validFrom) { + setValidFrom(validFrom); + return this; + } + + /** + * Gets point in time at which the profile stops to be valid. If absent, the profile is valid + * until it is replaced by another profile. + * + * @return Point in time at which the profile stops to be valid + */ + @Nullable + public ZonedDateTime getValidTo() { + return validTo; + } + + /** + * Sets point in time at which the profile stops to be valid. If absent, the profile is valid + * until it is replaced by another profile. + * + * @param validTo Point in time at which the profile stops to be valid + */ + public void setValidTo(@Nullable ZonedDateTime validTo) { + this.validTo = validTo; + } + + /** + * Adds point in time at which the profile stops to be valid. If absent, the profile is valid + * until it is replaced by another profile. + * + * @param validTo Point in time at which the profile stops to be valid + * @return this + */ + public ChargingProfile withValidTo(@Nullable ZonedDateTime validTo) { + setValidTo(validTo); + return this; + } + + /** + * Gets SHALL only be included if ChargingProfilePurpose is set to TxProfile in a + * SetChargingProfileRequest. The transactionId is used to match the profile to a specific + * transaction. + * + * @return SHALL only be included if ChargingProfilePurpose is set to TxProfile in a + * SetChargingProfileRequest + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets SHALL only be included if ChargingProfilePurpose is set to TxProfile in a + * SetChargingProfileRequest. The transactionId is used to match the profile to a specific + * transaction. + * + * @param transactionId SHALL only be included if ChargingProfilePurpose is set to TxProfile in a + * SetChargingProfileRequest + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds SHALL only be included if ChargingProfilePurpose is set to TxProfile in a + * SetChargingProfileRequest. The transactionId is used to match the profile to a specific + * transaction. + * + * @param transactionId SHALL only be included if ChargingProfilePurpose is set to TxProfile in a + * SetChargingProfileRequest + * @return this + */ + public ChargingProfile withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + /** + * Gets period in seconds that this charging profile remains valid after the Charging Station has + * gone offline. After this period the charging profile becomes invalid for as long as it is + * offline and the Charging Station reverts back to a valid profile with a lower stack level. If + * invalidAfterOfflineDuration is true, then this charging profile will become permanently + * invalid. A value of 0 means that the charging profile is immediately invalid while offline. + * When the field is absent, then no timeout applies and the charging profile remains valid when + * offline. + * + * @return Period in seconds that this charging profile remains valid after the Charging Station + * has gone offline + */ + @Nullable + public Integer getMaxOfflineDuration() { + return maxOfflineDuration; + } + + /** + * Sets period in seconds that this charging profile remains valid after the Charging Station has + * gone offline. After this period the charging profile becomes invalid for as long as it is + * offline and the Charging Station reverts back to a valid profile with a lower stack level. If + * invalidAfterOfflineDuration is true, then this charging profile will become permanently + * invalid. A value of 0 means that the charging profile is immediately invalid while offline. + * When the field is absent, then no timeout applies and the charging profile remains valid when + * offline. + * + * @param maxOfflineDuration Period in seconds that this charging profile remains valid after the + * Charging Station has gone offline + */ + public void setMaxOfflineDuration(@Nullable Integer maxOfflineDuration) { + this.maxOfflineDuration = maxOfflineDuration; + } + + /** + * Adds period in seconds that this charging profile remains valid after the Charging Station has + * gone offline. After this period the charging profile becomes invalid for as long as it is + * offline and the Charging Station reverts back to a valid profile with a lower stack level. If + * invalidAfterOfflineDuration is true, then this charging profile will become permanently + * invalid. A value of 0 means that the charging profile is immediately invalid while offline. + * When the field is absent, then no timeout applies and the charging profile remains valid when + * offline. + * + * @param maxOfflineDuration Period in seconds that this charging profile remains valid after the + * Charging Station has gone offline + * @return this + */ + public ChargingProfile withMaxOfflineDuration(@Nullable Integer maxOfflineDuration) { + setMaxOfflineDuration(maxOfflineDuration); + return this; + } + + /** + * Gets charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + * @return Charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType + */ + public ChargingSchedule[] getChargingSchedule() { + return chargingSchedule; + } + + /** + * Sets charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: NotifyEVChargingScheduleRequest and ChargingProfileType + */ + public void setChargingSchedule(ChargingSchedule[] chargingSchedule) { + if (!isValidChargingSchedule(chargingSchedule)) { + throw new PropertyConstraintException(chargingSchedule, "chargingSchedule is invalid"); + } + this.chargingSchedule = chargingSchedule; + } + + /** + * Returns whether the given chargingSchedule is valid + * + * @param chargingSchedule the chargingSchedule to check the validity of + * @return {@code true} if chargingSchedule is valid, {@code false} if not + */ + private boolean isValidChargingSchedule(ChargingSchedule[] chargingSchedule) { + return chargingSchedule != null + && chargingSchedule.length >= 1 + && chargingSchedule.length <= 3 + && Arrays.stream(chargingSchedule).allMatch(item -> item.validate()); + } + + /** + * Gets when set to true this charging profile will not be valid anymore after being offline for + * more than maxOfflineDuration. + * + * @return When set to true this charging profile will not be valid anymore after being offline + * for more than maxOfflineDuration + */ + @Nullable + public Boolean getInvalidAfterOfflineDuration() { + return invalidAfterOfflineDuration; + } + + /** + * Sets when set to true this charging profile will not be valid anymore after being offline for + * more than maxOfflineDuration. + * + * @param invalidAfterOfflineDuration When set to true this charging profile will not be valid + * anymore after being offline for more than maxOfflineDuration + */ + public void setInvalidAfterOfflineDuration(@Nullable Boolean invalidAfterOfflineDuration) { + this.invalidAfterOfflineDuration = invalidAfterOfflineDuration; + } + + /** + * Adds when set to true this charging profile will not be valid anymore after being offline for + * more than maxOfflineDuration. + * + * @param invalidAfterOfflineDuration When set to true this charging profile will not be valid + * anymore after being offline for more than maxOfflineDuration + * @return this + */ + public ChargingProfile withInvalidAfterOfflineDuration( + @Nullable Boolean invalidAfterOfflineDuration) { + setInvalidAfterOfflineDuration(invalidAfterOfflineDuration); + return this; + } + + /** + * Gets interval in seconds after receipt of last update, when to request a profile update by + * sending a PullDynamicScheduleUpdateRequest message. + * + * @return Interval in seconds after receipt of last update, when to request a profile update by + * sending a PullDynamicScheduleUpdateRequest message + */ + @Nullable + public Integer getDynUpdateInterval() { + return dynUpdateInterval; + } + + /** + * Sets interval in seconds after receipt of last update, when to request a profile update by + * sending a PullDynamicScheduleUpdateRequest message. + * + * @param dynUpdateInterval Interval in seconds after receipt of last update, when to request a + * profile update by sending a PullDynamicScheduleUpdateRequest message + */ + public void setDynUpdateInterval(@Nullable Integer dynUpdateInterval) { + this.dynUpdateInterval = dynUpdateInterval; + } + + /** + * Adds interval in seconds after receipt of last update, when to request a profile update by + * sending a PullDynamicScheduleUpdateRequest message. + * + * @param dynUpdateInterval Interval in seconds after receipt of last update, when to request a + * profile update by sending a PullDynamicScheduleUpdateRequest message + * @return this + */ + public ChargingProfile withDynUpdateInterval(@Nullable Integer dynUpdateInterval) { + setDynUpdateInterval(dynUpdateInterval); + return this; + } + + /** + * Gets time at which limits or setpoints in this charging profile were last updated by a + * PullDynamicScheduleUpdateRequest or UpdateDynamicScheduleRequest or by an external actor. + * + * @return Time at which limits or setpoints in this charging profile were last updated by a + * PullDynamicScheduleUpdateRequest or UpdateDynamicScheduleRequest or by an external actor + */ + @Nullable + public ZonedDateTime getDynUpdateTime() { + return dynUpdateTime; + } + + /** + * Sets time at which limits or setpoints in this charging profile were last updated by a + * PullDynamicScheduleUpdateRequest or UpdateDynamicScheduleRequest or by an external actor. + * + * @param dynUpdateTime Time at which limits or setpoints in this charging profile were last + * updated by a PullDynamicScheduleUpdateRequest or UpdateDynamicScheduleRequest or by an + * external actor + */ + public void setDynUpdateTime(@Nullable ZonedDateTime dynUpdateTime) { + this.dynUpdateTime = dynUpdateTime; + } + + /** + * Adds time at which limits or setpoints in this charging profile were last updated by a + * PullDynamicScheduleUpdateRequest or UpdateDynamicScheduleRequest or by an external actor. + * + * @param dynUpdateTime Time at which limits or setpoints in this charging profile were last + * updated by a PullDynamicScheduleUpdateRequest or UpdateDynamicScheduleRequest or by an + * external actor + * @return this + */ + public ChargingProfile withDynUpdateTime(@Nullable ZonedDateTime dynUpdateTime) { + setDynUpdateTime(dynUpdateTime); + return this; + } + + /** + * Gets ISO 15118-20 signature for all price schedules in chargingSchedules. + * + * @return ISO 15118-20 signature for all price schedules in chargingSchedules + */ + @Nullable + public String getPriceScheduleSignature() { + return priceScheduleSignature; + } + + /** + * Sets ISO 15118-20 signature for all price schedules in chargingSchedules. + * + * @param priceScheduleSignature ISO 15118-20 signature for all price schedules in + * chargingSchedules + */ + public void setPriceScheduleSignature(@Nullable String priceScheduleSignature) { + if (!isValidPriceScheduleSignature(priceScheduleSignature)) { + throw new PropertyConstraintException( + priceScheduleSignature, "priceScheduleSignature is invalid"); + } + this.priceScheduleSignature = priceScheduleSignature; + } + + /** + * Returns whether the given priceScheduleSignature is valid + * + * @param priceScheduleSignature the priceScheduleSignature to check the validity of + * @return {@code true} if priceScheduleSignature is valid, {@code false} if not + */ + private boolean isValidPriceScheduleSignature(@Nullable String priceScheduleSignature) { + return priceScheduleSignature == null || priceScheduleSignature.length() <= 256; + } + + /** + * Adds ISO 15118-20 signature for all price schedules in chargingSchedules. + * + * @param priceScheduleSignature ISO 15118-20 signature for all price schedules in + * chargingSchedules + * @return this + */ + public ChargingProfile withPriceScheduleSignature(@Nullable String priceScheduleSignature) { + setPriceScheduleSignature(priceScheduleSignature); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingProfile withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) + && isValidStackLevel(stackLevel) + && isValidChargingProfilePurpose(chargingProfilePurpose) + && isValidChargingProfileKind(chargingProfileKind) + && isValidTransactionId(transactionId) + && isValidChargingSchedule(chargingSchedule) + && isValidPriceScheduleSignature(priceScheduleSignature) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingProfile that = (ChargingProfile) o; + return Objects.equals(id, that.id) + && Objects.equals(stackLevel, that.stackLevel) + && Objects.equals(chargingProfilePurpose, that.chargingProfilePurpose) + && Objects.equals(chargingProfileKind, that.chargingProfileKind) + && Objects.equals(recurrencyKind, that.recurrencyKind) + && Objects.equals(validFrom, that.validFrom) + && Objects.equals(validTo, that.validTo) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(maxOfflineDuration, that.maxOfflineDuration) + && Arrays.equals(chargingSchedule, that.chargingSchedule) + && Objects.equals(invalidAfterOfflineDuration, that.invalidAfterOfflineDuration) + && Objects.equals(dynUpdateInterval, that.dynUpdateInterval) + && Objects.equals(dynUpdateTime, that.dynUpdateTime) + && Objects.equals(priceScheduleSignature, that.priceScheduleSignature) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + stackLevel, + chargingProfilePurpose, + chargingProfileKind, + recurrencyKind, + validFrom, + validTo, + transactionId, + maxOfflineDuration, + Arrays.hashCode(chargingSchedule), + invalidAfterOfflineDuration, + dynUpdateInterval, + dynUpdateTime, + priceScheduleSignature, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("stackLevel", stackLevel) + .add("chargingProfilePurpose", chargingProfilePurpose) + .add("chargingProfileKind", chargingProfileKind) + .add("recurrencyKind", recurrencyKind) + .add("validFrom", validFrom) + .add("validTo", validTo) + .add("transactionId", transactionId) + .add("maxOfflineDuration", maxOfflineDuration) + .add("chargingSchedule", chargingSchedule) + .add("invalidAfterOfflineDuration", invalidAfterOfflineDuration) + .add("dynUpdateInterval", dynUpdateInterval) + .add("dynUpdateTime", dynUpdateTime) + .add("priceScheduleSignature", priceScheduleSignature) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileCriterion.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileCriterion.java new file mode 100644 index 00000000..b36de1e8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileCriterion.java @@ -0,0 +1,339 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A ChargingProfileCriterionType is a filter for charging profiles to be selected by a + * GetChargingProfilesRequest. + */ +public final class ChargingProfileCriterion { + /** The purpose of the schedule transferred by this profile */ + @Nullable private ChargingProfilePurposeEnum chargingProfilePurpose; + + /** + * Value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + */ + @Nullable private Integer stackLevel; + + /** + * List of all the chargingProfileIds requested. Any ChargingProfile that matches one of these + * profiles will be reported. If omitted, the Charging Station SHALL not filter on + * chargingProfileId. This field SHALL NOT contain more ids than set in + * ChargingProfileEntries.maxLimit + */ + @Nullable private Integer[] chargingProfileId; + + /** + * For which charging limit sources, charging profiles SHALL be reported. If omitted, the Charging + * Station SHALL not filter on chargingLimitSource. Values defined in Appendix as + * ChargingLimitSourceEnumStringType. + */ + @Nullable private String[] chargingLimitSource; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ChargingProfileCriterion class */ + public ChargingProfileCriterion() {} + + /** + * Gets the purpose of the schedule transferred by this profile + * + * @return The purpose of the schedule transferred by this profile + */ + @Nullable + public ChargingProfilePurposeEnum getChargingProfilePurpose() { + return chargingProfilePurpose; + } + + /** + * Sets the purpose of the schedule transferred by this profile + * + * @param chargingProfilePurpose The purpose of the schedule transferred by this profile + */ + public void setChargingProfilePurpose( + @Nullable ChargingProfilePurposeEnum chargingProfilePurpose) { + this.chargingProfilePurpose = chargingProfilePurpose; + } + + /** + * Adds the purpose of the schedule transferred by this profile + * + * @param chargingProfilePurpose The purpose of the schedule transferred by this profile + * @return this + */ + public ChargingProfileCriterion withChargingProfilePurpose( + @Nullable ChargingProfilePurposeEnum chargingProfilePurpose) { + setChargingProfilePurpose(chargingProfilePurpose); + return this; + } + + /** + * Gets value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @return Value determining level in hierarchy stack of profiles + */ + @Nullable + public Integer getStackLevel() { + return stackLevel; + } + + /** + * Sets value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @param stackLevel Value determining level in hierarchy stack of profiles + */ + public void setStackLevel(@Nullable Integer stackLevel) { + if (!isValidStackLevel(stackLevel)) { + throw new PropertyConstraintException(stackLevel, "stackLevel is invalid"); + } + this.stackLevel = stackLevel; + } + + /** + * Returns whether the given stackLevel is valid + * + * @param stackLevel the stackLevel to check the validity of + * @return {@code true} if stackLevel is valid, {@code false} if not + */ + private boolean isValidStackLevel(@Nullable Integer stackLevel) { + return stackLevel == null || (stackLevel >= 0); + } + + /** + * Adds value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @param stackLevel Value determining level in hierarchy stack of profiles + * @return this + */ + public ChargingProfileCriterion withStackLevel(@Nullable Integer stackLevel) { + setStackLevel(stackLevel); + return this; + } + + /** + * Gets list of all the chargingProfileIds requested. Any ChargingProfile that matches one of + * these profiles will be reported. If omitted, the Charging Station SHALL not filter on + * chargingProfileId. This field SHALL NOT contain more ids than set in + * ChargingProfileEntries.maxLimit + * + * @return List of all the chargingProfileIds requested + */ + @Nullable + public Integer[] getChargingProfileId() { + return chargingProfileId; + } + + /** + * Sets list of all the chargingProfileIds requested. Any ChargingProfile that matches one of + * these profiles will be reported. If omitted, the Charging Station SHALL not filter on + * chargingProfileId. This field SHALL NOT contain more ids than set in + * ChargingProfileEntries.maxLimit + * + * @param chargingProfileId List of all the chargingProfileIds requested + */ + public void setChargingProfileId(@Nullable Integer[] chargingProfileId) { + if (!isValidChargingProfileId(chargingProfileId)) { + throw new PropertyConstraintException(chargingProfileId, "chargingProfileId is invalid"); + } + this.chargingProfileId = chargingProfileId; + } + + /** + * Returns whether the given chargingProfileId is valid + * + * @param chargingProfileId the chargingProfileId to check the validity of + * @return {@code true} if chargingProfileId is valid, {@code false} if not + */ + private boolean isValidChargingProfileId(@Nullable Integer[] chargingProfileId) { + return chargingProfileId == null || (chargingProfileId.length >= 1); + } + + /** + * Adds list of all the chargingProfileIds requested. Any ChargingProfile that matches one of + * these profiles will be reported. If omitted, the Charging Station SHALL not filter on + * chargingProfileId. This field SHALL NOT contain more ids than set in + * ChargingProfileEntries.maxLimit + * + * @param chargingProfileId List of all the chargingProfileIds requested + * @return this + */ + public ChargingProfileCriterion withChargingProfileId(@Nullable Integer[] chargingProfileId) { + setChargingProfileId(chargingProfileId); + return this; + } + + /** + * Gets for which charging limit sources, charging profiles SHALL be reported. If omitted, the + * Charging Station SHALL not filter on chargingLimitSource. Values defined in Appendix as + * ChargingLimitSourceEnumStringType. + * + * @return For which charging limit sources, charging profiles SHALL be reported + */ + @Nullable + public String[] getChargingLimitSource() { + return chargingLimitSource; + } + + /** + * Sets for which charging limit sources, charging profiles SHALL be reported. If omitted, the + * Charging Station SHALL not filter on chargingLimitSource. Values defined in Appendix as + * ChargingLimitSourceEnumStringType. + * + * @param chargingLimitSource For which charging limit sources, charging profiles SHALL be + * reported + */ + public void setChargingLimitSource(@Nullable String[] chargingLimitSource) { + if (!isValidChargingLimitSource(chargingLimitSource)) { + throw new PropertyConstraintException(chargingLimitSource, "chargingLimitSource is invalid"); + } + this.chargingLimitSource = chargingLimitSource; + } + + /** + * Returns whether the given chargingLimitSource is valid + * + * @param chargingLimitSource the chargingLimitSource to check the validity of + * @return {@code true} if chargingLimitSource is valid, {@code false} if not + */ + private boolean isValidChargingLimitSource(@Nullable String[] chargingLimitSource) { + return chargingLimitSource == null + || (chargingLimitSource.length >= 1 + && chargingLimitSource.length <= 4 + && Arrays.stream(chargingLimitSource).allMatch(item -> item.length() <= 20)); + } + + /** + * Adds for which charging limit sources, charging profiles SHALL be reported. If omitted, the + * Charging Station SHALL not filter on chargingLimitSource. Values defined in Appendix as + * ChargingLimitSourceEnumStringType. + * + * @param chargingLimitSource For which charging limit sources, charging profiles SHALL be + * reported + * @return this + */ + public ChargingProfileCriterion withChargingLimitSource(@Nullable String[] chargingLimitSource) { + setChargingLimitSource(chargingLimitSource); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingProfileCriterion withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidStackLevel(stackLevel) + && isValidChargingProfileId(chargingProfileId) + && isValidChargingLimitSource(chargingLimitSource) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingProfileCriterion that = (ChargingProfileCriterion) o; + return Objects.equals(chargingProfilePurpose, that.chargingProfilePurpose) + && Objects.equals(stackLevel, that.stackLevel) + && Arrays.equals(chargingProfileId, that.chargingProfileId) + && Arrays.equals(chargingLimitSource, that.chargingLimitSource) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + chargingProfilePurpose, + stackLevel, + Arrays.hashCode(chargingProfileId), + Arrays.hashCode(chargingLimitSource), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingProfilePurpose", chargingProfilePurpose) + .add("stackLevel", stackLevel) + .add("chargingProfileId", chargingProfileId) + .add("chargingLimitSource", chargingLimitSource) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileKindEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileKindEnum.java new file mode 100644 index 00000000..c4e91335 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileKindEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The kind of schedule. */ +public enum ChargingProfileKindEnum { + Absolute, + Recurring, + Relative, + Dynamic +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfilePurposeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfilePurposeEnum.java new file mode 100644 index 00000000..544c081c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfilePurposeEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The purpose of the schedule transferred by this profile */ +public enum ChargingProfilePurposeEnum { + ChargingStationExternalConstraints, + ChargingStationMaxProfile, + TxDefaultProfile, + TxProfile, + PriorityCharging, + LocalGeneration +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileStatusEnum.java new file mode 100644 index 00000000..2e7ed910 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingProfileStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Returns whether message was processed successfully. */ +public enum ChargingProfileStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingRateUnitEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingRateUnitEnum.java new file mode 100644 index 00000000..ed409b29 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingRateUnitEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The unit of measure in which limits and setpoints are expressed. */ +public enum ChargingRateUnitEnum { + W, + A +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingSchedule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingSchedule.java new file mode 100644 index 00000000..17c790da --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingSchedule.java @@ -0,0 +1,907 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charging schedule structure defines a list of charging periods, as used in: + * NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a + * NotifyEVChargingScheduleRequest only duration and chargingSchedulePeriod are relevant and + * chargingRateUnit must be 'W'. + * + *

An ISO 15118-20 session may provide either an absolutePriceSchedule or a priceLevelSchedule. + * An ISO 15118-2 session can only provide asalesTariff element. The field digestValue is used when + * price schedule or sales tariff are signed. + * + *

image::images/ChargingSchedule-Simple.png[] + */ +public final class ChargingSchedule { + /** id */ + private Integer id; + + /** limitAtSoC */ + @Nullable private LimitAtSoC limitAtSoC; + + /** Starting point of an absolute schedule or recurring schedule. */ + @Nullable private ZonedDateTime startSchedule; + + /** + * Duration of the charging schedule in seconds. If the duration is left empty, the last period + * will continue indefinitely or until end of the transaction in case startSchedule is absent. + */ + @Nullable private Integer duration; + + /** The unit of measure in which limits and setpoints are expressed. */ + private ChargingRateUnitEnum chargingRateUnit; + + /** + * Minimum charging rate supported by the EV. The unit of measure is defined by the + * chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to + * optimize the power allocation for in the case a charging process is inefficient at lower + * charging rates. + */ + @Nullable private Double minChargingRate; + + /** Power tolerance when following EVPowerProfile. */ + @Nullable private Double powerTolerance; + + /** Id of this element for referencing in a signature. */ + @Nullable private Integer signatureId; + + /** + * Base64 encoded hash (SHA256 for ISO 15118-2, SHA512 for ISO 15118-20) of the EXI price schedule + * element. Used in signature. + */ + @Nullable private String digestValue; + + /** + * Defaults to false. When true, disregard time zone offset in dateTime fields of + * ChargingScheduleType and use unqualified local time at Charging Station instead. This allows + * the same `Absolute` or `Recurring` charging profile to be used in both summer and winter time. + */ + @Nullable private Boolean useLocalTime; + + /** + * Charging schedule period structure defines a time period in a charging schedule. It is used in: + * CompositeScheduleType and in ChargingScheduleType. When used in a + * NotifyEVChargingScheduleRequest only startPeriod, limit, limitL2, limitL3 are relevant. + */ + private ChargingSchedulePeriod[] chargingSchedulePeriod; + + /** + * Defaults to 0. When randomizedDelay not equals zero, then the start of each + * ChargingSchedulePeriodType is delayed by a randomly chosen number of seconds between 0 and + * randomizedDelay. Only allowed for TxProfile and TxDefaultProfile. + */ + @Nullable private Integer randomizedDelay; + + /** + * A SalesTariff provided by a Mobility Operator (EMSP) . NOTE: This dataType is based on + * dataTypes from ISO 15118-2. + */ + @Nullable private SalesTariff salesTariff; + + /** + * The AbsolutePriceScheduleType is modeled after the same type that is defined in ISO 15118-20, + * such that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON + * (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not + * invalidate the signature. + * + *

image::images/AbsolutePriceSchedule-Simple.png[] + */ + @Nullable private AbsolutePriceSchedule absolutePriceSchedule; + + /** + * The PriceLevelScheduleType is modeled after the same type that is defined in ISO 15118-20, such + * that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON (in + * OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not + * invalidate the signature. + */ + @Nullable private PriceLevelSchedule priceLevelSchedule; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChargingSchedule class + * + * @param id id + * @param chargingRateUnit The unit of measure in which limits and setpoints are expressed. + * @param chargingSchedulePeriod Charging schedule period structure defines a time period in a + * charging schedule. It is used in: CompositeScheduleType and in ChargingScheduleType. When + * used in a NotifyEVChargingScheduleRequest only startPeriod, limit, limitL2, limitL3 are + * relevant. + */ + public ChargingSchedule( + Integer id, + ChargingRateUnitEnum chargingRateUnit, + ChargingSchedulePeriod[] chargingSchedulePeriod) { + setId(id); + setChargingRateUnit(chargingRateUnit); + setChargingSchedulePeriod(chargingSchedulePeriod); + } + + /** + * Gets id + * + * @return id + */ + public Integer getId() { + return id; + } + + /** + * Sets id + * + * @param id id + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets limitAtSoC + * + * @return limitAtSoC + */ + @Nullable + public LimitAtSoC getLimitAtSoC() { + return limitAtSoC; + } + + /** + * Sets limitAtSoC + * + * @param limitAtSoC limitAtSoC + */ + public void setLimitAtSoC(@Nullable LimitAtSoC limitAtSoC) { + if (!isValidLimitAtSoC(limitAtSoC)) { + throw new PropertyConstraintException(limitAtSoC, "limitAtSoC is invalid"); + } + this.limitAtSoC = limitAtSoC; + } + + /** + * Returns whether the given limitAtSoC is valid + * + * @param limitAtSoC the limitAtSoC to check the validity of + * @return {@code true} if limitAtSoC is valid, {@code false} if not + */ + private boolean isValidLimitAtSoC(@Nullable LimitAtSoC limitAtSoC) { + return limitAtSoC == null || limitAtSoC.validate(); + } + + /** + * Adds limitAtSoC + * + * @param limitAtSoC limitAtSoC + * @return this + */ + public ChargingSchedule withLimitAtSoC(@Nullable LimitAtSoC limitAtSoC) { + setLimitAtSoC(limitAtSoC); + return this; + } + + /** + * Gets starting point of an absolute schedule or recurring schedule. + * + * @return Starting point of an absolute schedule or recurring schedule + */ + @Nullable + public ZonedDateTime getStartSchedule() { + return startSchedule; + } + + /** + * Sets starting point of an absolute schedule or recurring schedule. + * + * @param startSchedule Starting point of an absolute schedule or recurring schedule + */ + public void setStartSchedule(@Nullable ZonedDateTime startSchedule) { + this.startSchedule = startSchedule; + } + + /** + * Adds starting point of an absolute schedule or recurring schedule. + * + * @param startSchedule Starting point of an absolute schedule or recurring schedule + * @return this + */ + public ChargingSchedule withStartSchedule(@Nullable ZonedDateTime startSchedule) { + setStartSchedule(startSchedule); + return this; + } + + /** + * Gets duration of the charging schedule in seconds. If the duration is left empty, the last + * period will continue indefinitely or until end of the transaction in case startSchedule is + * absent. + * + * @return Duration of the charging schedule in seconds + */ + @Nullable + public Integer getDuration() { + return duration; + } + + /** + * Sets duration of the charging schedule in seconds. If the duration is left empty, the last + * period will continue indefinitely or until end of the transaction in case startSchedule is + * absent. + * + * @param duration Duration of the charging schedule in seconds + */ + public void setDuration(@Nullable Integer duration) { + this.duration = duration; + } + + /** + * Adds duration of the charging schedule in seconds. If the duration is left empty, the last + * period will continue indefinitely or until end of the transaction in case startSchedule is + * absent. + * + * @param duration Duration of the charging schedule in seconds + * @return this + */ + public ChargingSchedule withDuration(@Nullable Integer duration) { + setDuration(duration); + return this; + } + + /** + * Gets the unit of measure in which limits and setpoints are expressed. + * + * @return The unit of measure in which limits and setpoints are expressed + */ + public ChargingRateUnitEnum getChargingRateUnit() { + return chargingRateUnit; + } + + /** + * Sets the unit of measure in which limits and setpoints are expressed. + * + * @param chargingRateUnit The unit of measure in which limits and setpoints are expressed + */ + public void setChargingRateUnit(ChargingRateUnitEnum chargingRateUnit) { + if (!isValidChargingRateUnit(chargingRateUnit)) { + throw new PropertyConstraintException(chargingRateUnit, "chargingRateUnit is invalid"); + } + this.chargingRateUnit = chargingRateUnit; + } + + /** + * Returns whether the given chargingRateUnit is valid + * + * @param chargingRateUnit the chargingRateUnit to check the validity of + * @return {@code true} if chargingRateUnit is valid, {@code false} if not + */ + private boolean isValidChargingRateUnit(ChargingRateUnitEnum chargingRateUnit) { + return chargingRateUnit != null; + } + + /** + * Gets minimum charging rate supported by the EV. The unit of measure is defined by the + * chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to + * optimize the power allocation for in the case a charging process is inefficient at lower + * charging rates. + * + * @return Minimum charging rate supported by the EV + */ + @Nullable + public Double getMinChargingRate() { + return minChargingRate; + } + + /** + * Sets minimum charging rate supported by the EV. The unit of measure is defined by the + * chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to + * optimize the power allocation for in the case a charging process is inefficient at lower + * charging rates. + * + * @param minChargingRate Minimum charging rate supported by the EV + */ + public void setMinChargingRate(@Nullable Double minChargingRate) { + this.minChargingRate = minChargingRate; + } + + /** + * Adds minimum charging rate supported by the EV. The unit of measure is defined by the + * chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to + * optimize the power allocation for in the case a charging process is inefficient at lower + * charging rates. + * + * @param minChargingRate Minimum charging rate supported by the EV + * @return this + */ + public ChargingSchedule withMinChargingRate(@Nullable Double minChargingRate) { + setMinChargingRate(minChargingRate); + return this; + } + + /** + * Gets power tolerance when following EVPowerProfile. + * + * @return Power tolerance when following EVPowerProfile + */ + @Nullable + public Double getPowerTolerance() { + return powerTolerance; + } + + /** + * Sets power tolerance when following EVPowerProfile. + * + * @param powerTolerance Power tolerance when following EVPowerProfile + */ + public void setPowerTolerance(@Nullable Double powerTolerance) { + this.powerTolerance = powerTolerance; + } + + /** + * Adds power tolerance when following EVPowerProfile. + * + * @param powerTolerance Power tolerance when following EVPowerProfile + * @return this + */ + public ChargingSchedule withPowerTolerance(@Nullable Double powerTolerance) { + setPowerTolerance(powerTolerance); + return this; + } + + /** + * Gets id of this element for referencing in a signature. + * + * @return Id of this element for referencing in a signature + */ + @Nullable + public Integer getSignatureId() { + return signatureId; + } + + /** + * Sets id of this element for referencing in a signature. + * + * @param signatureId Id of this element for referencing in a signature + */ + public void setSignatureId(@Nullable Integer signatureId) { + if (!isValidSignatureId(signatureId)) { + throw new PropertyConstraintException(signatureId, "signatureId is invalid"); + } + this.signatureId = signatureId; + } + + /** + * Returns whether the given signatureId is valid + * + * @param signatureId the signatureId to check the validity of + * @return {@code true} if signatureId is valid, {@code false} if not + */ + private boolean isValidSignatureId(@Nullable Integer signatureId) { + return signatureId == null || (signatureId >= 0); + } + + /** + * Adds id of this element for referencing in a signature. + * + * @param signatureId Id of this element for referencing in a signature + * @return this + */ + public ChargingSchedule withSignatureId(@Nullable Integer signatureId) { + setSignatureId(signatureId); + return this; + } + + /** + * Gets base64 encoded hash (SHA256 for ISO 15118-2, SHA512 for ISO 15118-20) of the EXI price + * schedule element. Used in signature. + * + * @return Base64 encoded hash (SHA256 for ISO 15118-2, SHA512 for ISO 15118-20) of the EXI price + * schedule element + */ + @Nullable + public String getDigestValue() { + return digestValue; + } + + /** + * Sets base64 encoded hash (SHA256 for ISO 15118-2, SHA512 for ISO 15118-20) of the EXI price + * schedule element. Used in signature. + * + * @param digestValue Base64 encoded hash (SHA256 for ISO 15118-2, SHA512 for ISO 15118-20) of the + * EXI price schedule element + */ + public void setDigestValue(@Nullable String digestValue) { + if (!isValidDigestValue(digestValue)) { + throw new PropertyConstraintException(digestValue, "digestValue is invalid"); + } + this.digestValue = digestValue; + } + + /** + * Returns whether the given digestValue is valid + * + * @param digestValue the digestValue to check the validity of + * @return {@code true} if digestValue is valid, {@code false} if not + */ + private boolean isValidDigestValue(@Nullable String digestValue) { + return digestValue == null || digestValue.length() <= 88; + } + + /** + * Adds base64 encoded hash (SHA256 for ISO 15118-2, SHA512 for ISO 15118-20) of the EXI price + * schedule element. Used in signature. + * + * @param digestValue Base64 encoded hash (SHA256 for ISO 15118-2, SHA512 for ISO 15118-20) of the + * EXI price schedule element + * @return this + */ + public ChargingSchedule withDigestValue(@Nullable String digestValue) { + setDigestValue(digestValue); + return this; + } + + /** + * Gets defaults to false. When true, disregard time zone offset in dateTime fields of + * ChargingScheduleType and use unqualified local time at Charging Station instead. This allows + * the same `Absolute` or `Recurring` charging profile to be used in both summer and winter time. + * + * @return Defaults to false + */ + @Nullable + public Boolean getUseLocalTime() { + return useLocalTime; + } + + /** + * Sets defaults to false. When true, disregard time zone offset in dateTime fields of + * ChargingScheduleType and use unqualified local time at Charging Station instead. This allows + * the same `Absolute` or `Recurring` charging profile to be used in both summer and winter time. + * + * @param useLocalTime Defaults to false + */ + public void setUseLocalTime(@Nullable Boolean useLocalTime) { + this.useLocalTime = useLocalTime; + } + + /** + * Adds defaults to false. When true, disregard time zone offset in dateTime fields of + * ChargingScheduleType and use unqualified local time at Charging Station instead. This allows + * the same `Absolute` or `Recurring` charging profile to be used in both summer and winter time. + * + * @param useLocalTime Defaults to false + * @return this + */ + public ChargingSchedule withUseLocalTime(@Nullable Boolean useLocalTime) { + setUseLocalTime(useLocalTime); + return this; + } + + /** + * Gets charging schedule period structure defines a time period in a charging schedule. It is + * used in: CompositeScheduleType and in ChargingScheduleType. When used in a + * NotifyEVChargingScheduleRequest only startPeriod, limit, limitL2, limitL3 are relevant. + * + * @return Charging schedule period structure defines a time period in a charging schedule + */ + public ChargingSchedulePeriod[] getChargingSchedulePeriod() { + return chargingSchedulePeriod; + } + + /** + * Sets charging schedule period structure defines a time period in a charging schedule. It is + * used in: CompositeScheduleType and in ChargingScheduleType. When used in a + * NotifyEVChargingScheduleRequest only startPeriod, limit, limitL2, limitL3 are relevant. + * + * @param chargingSchedulePeriod Charging schedule period structure defines a time period in a + * charging schedule + */ + public void setChargingSchedulePeriod(ChargingSchedulePeriod[] chargingSchedulePeriod) { + if (!isValidChargingSchedulePeriod(chargingSchedulePeriod)) { + throw new PropertyConstraintException( + chargingSchedulePeriod, "chargingSchedulePeriod is invalid"); + } + this.chargingSchedulePeriod = chargingSchedulePeriod; + } + + /** + * Returns whether the given chargingSchedulePeriod is valid + * + * @param chargingSchedulePeriod the chargingSchedulePeriod to check the validity of + * @return {@code true} if chargingSchedulePeriod is valid, {@code false} if not + */ + private boolean isValidChargingSchedulePeriod(ChargingSchedulePeriod[] chargingSchedulePeriod) { + return chargingSchedulePeriod != null + && chargingSchedulePeriod.length >= 1 + && chargingSchedulePeriod.length <= 1024 + && Arrays.stream(chargingSchedulePeriod).allMatch(item -> item.validate()); + } + + /** + * Gets defaults to 0. When randomizedDelay not equals zero, then the start of each + * ChargingSchedulePeriodType is delayed by a randomly chosen number of seconds between 0 and + * randomizedDelay. Only allowed for TxProfile and TxDefaultProfile. + * + * @return Defaults to 0 + */ + @Nullable + public Integer getRandomizedDelay() { + return randomizedDelay; + } + + /** + * Sets defaults to 0. When randomizedDelay not equals zero, then the start of each + * ChargingSchedulePeriodType is delayed by a randomly chosen number of seconds between 0 and + * randomizedDelay. Only allowed for TxProfile and TxDefaultProfile. + * + * @param randomizedDelay Defaults to 0 + */ + public void setRandomizedDelay(@Nullable Integer randomizedDelay) { + if (!isValidRandomizedDelay(randomizedDelay)) { + throw new PropertyConstraintException(randomizedDelay, "randomizedDelay is invalid"); + } + this.randomizedDelay = randomizedDelay; + } + + /** + * Returns whether the given randomizedDelay is valid + * + * @param randomizedDelay the randomizedDelay to check the validity of + * @return {@code true} if randomizedDelay is valid, {@code false} if not + */ + private boolean isValidRandomizedDelay(@Nullable Integer randomizedDelay) { + return randomizedDelay == null || (randomizedDelay >= 0); + } + + /** + * Adds defaults to 0. When randomizedDelay not equals zero, then the start of each + * ChargingSchedulePeriodType is delayed by a randomly chosen number of seconds between 0 and + * randomizedDelay. Only allowed for TxProfile and TxDefaultProfile. + * + * @param randomizedDelay Defaults to 0 + * @return this + */ + public ChargingSchedule withRandomizedDelay(@Nullable Integer randomizedDelay) { + setRandomizedDelay(randomizedDelay); + return this; + } + + /** + * Gets a SalesTariff provided by a Mobility Operator (EMSP) . NOTE: This dataType is based on + * dataTypes from ISO 15118-2. + * + * @return A SalesTariff provided by a Mobility Operator (EMSP) + */ + @Nullable + public SalesTariff getSalesTariff() { + return salesTariff; + } + + /** + * Sets a SalesTariff provided by a Mobility Operator (EMSP) . NOTE: This dataType is based on + * dataTypes from ISO 15118-2. + * + * @param salesTariff A SalesTariff provided by a Mobility Operator (EMSP) + */ + public void setSalesTariff(@Nullable SalesTariff salesTariff) { + if (!isValidSalesTariff(salesTariff)) { + throw new PropertyConstraintException(salesTariff, "salesTariff is invalid"); + } + this.salesTariff = salesTariff; + } + + /** + * Returns whether the given salesTariff is valid + * + * @param salesTariff the salesTariff to check the validity of + * @return {@code true} if salesTariff is valid, {@code false} if not + */ + private boolean isValidSalesTariff(@Nullable SalesTariff salesTariff) { + return salesTariff == null || salesTariff.validate(); + } + + /** + * Adds a SalesTariff provided by a Mobility Operator (EMSP) . NOTE: This dataType is based on + * dataTypes from ISO 15118-2. + * + * @param salesTariff A SalesTariff provided by a Mobility Operator (EMSP) + * @return this + */ + public ChargingSchedule withSalesTariff(@Nullable SalesTariff salesTariff) { + setSalesTariff(salesTariff); + return this; + } + + /** + * Gets the AbsolutePriceScheduleType is modeled after the same type that is defined in ISO + * 15118-20, such that if it is supplied by an EMSP as a signed EXI message, the conversion from + * EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and + * therefore does not invalidate the signature. + * + * @return The AbsolutePriceScheduleType is modeled after the same type that is defined in ISO + * 15118-20, such that if it is supplied by an EMSP as a signed EXI message, the conversion + * from EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest + * and therefore does not invalidate the signature + */ + @Nullable + public AbsolutePriceSchedule getAbsolutePriceSchedule() { + return absolutePriceSchedule; + } + + /** + * Sets the AbsolutePriceScheduleType is modeled after the same type that is defined in ISO + * 15118-20, such that if it is supplied by an EMSP as a signed EXI message, the conversion from + * EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and + * therefore does not invalidate the signature. + * + * @param absolutePriceSchedule The AbsolutePriceScheduleType is modeled after the same type that + * is defined in ISO 15118-20, such that if it is supplied by an EMSP as a signed EXI message, + * the conversion from EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not + * change the digest and therefore does not invalidate the signature + */ + public void setAbsolutePriceSchedule(@Nullable AbsolutePriceSchedule absolutePriceSchedule) { + if (!isValidAbsolutePriceSchedule(absolutePriceSchedule)) { + throw new PropertyConstraintException( + absolutePriceSchedule, "absolutePriceSchedule is invalid"); + } + this.absolutePriceSchedule = absolutePriceSchedule; + } + + /** + * Returns whether the given absolutePriceSchedule is valid + * + * @param absolutePriceSchedule the absolutePriceSchedule to check the validity of + * @return {@code true} if absolutePriceSchedule is valid, {@code false} if not + */ + private boolean isValidAbsolutePriceSchedule( + @Nullable AbsolutePriceSchedule absolutePriceSchedule) { + return absolutePriceSchedule == null || absolutePriceSchedule.validate(); + } + + /** + * Adds the AbsolutePriceScheduleType is modeled after the same type that is defined in ISO + * 15118-20, such that if it is supplied by an EMSP as a signed EXI message, the conversion from + * EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and + * therefore does not invalidate the signature. + * + * @param absolutePriceSchedule The AbsolutePriceScheduleType is modeled after the same type that + * is defined in ISO 15118-20, such that if it is supplied by an EMSP as a signed EXI message, + * the conversion from EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not + * change the digest and therefore does not invalidate the signature + * @return this + */ + public ChargingSchedule withAbsolutePriceSchedule( + @Nullable AbsolutePriceSchedule absolutePriceSchedule) { + setAbsolutePriceSchedule(absolutePriceSchedule); + return this; + } + + /** + * Gets the PriceLevelScheduleType is modeled after the same type that is defined in ISO 15118-20, + * such that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON + * (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not + * invalidate the signature. + * + * @return The PriceLevelScheduleType is modeled after the same type that is defined in ISO + * 15118-20, such that if it is supplied by an EMSP as a signed EXI message, the conversion + * from EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest + * and therefore does not invalidate the signature + */ + @Nullable + public PriceLevelSchedule getPriceLevelSchedule() { + return priceLevelSchedule; + } + + /** + * Sets the PriceLevelScheduleType is modeled after the same type that is defined in ISO 15118-20, + * such that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON + * (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not + * invalidate the signature. + * + * @param priceLevelSchedule The PriceLevelScheduleType is modeled after the same type that is + * defined in ISO 15118-20, such that if it is supplied by an EMSP as a signed EXI message, + * the conversion from EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not + * change the digest and therefore does not invalidate the signature + */ + public void setPriceLevelSchedule(@Nullable PriceLevelSchedule priceLevelSchedule) { + if (!isValidPriceLevelSchedule(priceLevelSchedule)) { + throw new PropertyConstraintException(priceLevelSchedule, "priceLevelSchedule is invalid"); + } + this.priceLevelSchedule = priceLevelSchedule; + } + + /** + * Returns whether the given priceLevelSchedule is valid + * + * @param priceLevelSchedule the priceLevelSchedule to check the validity of + * @return {@code true} if priceLevelSchedule is valid, {@code false} if not + */ + private boolean isValidPriceLevelSchedule(@Nullable PriceLevelSchedule priceLevelSchedule) { + return priceLevelSchedule == null || priceLevelSchedule.validate(); + } + + /** + * Adds the PriceLevelScheduleType is modeled after the same type that is defined in ISO 15118-20, + * such that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON + * (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not + * invalidate the signature. + * + * @param priceLevelSchedule The PriceLevelScheduleType is modeled after the same type that is + * defined in ISO 15118-20, such that if it is supplied by an EMSP as a signed EXI message, + * the conversion from EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not + * change the digest and therefore does not invalidate the signature + * @return this + */ + public ChargingSchedule withPriceLevelSchedule(@Nullable PriceLevelSchedule priceLevelSchedule) { + setPriceLevelSchedule(priceLevelSchedule); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingSchedule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) + && isValidLimitAtSoC(limitAtSoC) + && isValidChargingRateUnit(chargingRateUnit) + && isValidSignatureId(signatureId) + && isValidDigestValue(digestValue) + && isValidChargingSchedulePeriod(chargingSchedulePeriod) + && isValidRandomizedDelay(randomizedDelay) + && isValidSalesTariff(salesTariff) + && isValidAbsolutePriceSchedule(absolutePriceSchedule) + && isValidPriceLevelSchedule(priceLevelSchedule) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingSchedule that = (ChargingSchedule) o; + return Objects.equals(id, that.id) + && Objects.equals(limitAtSoC, that.limitAtSoC) + && Objects.equals(startSchedule, that.startSchedule) + && Objects.equals(duration, that.duration) + && Objects.equals(chargingRateUnit, that.chargingRateUnit) + && Objects.equals(minChargingRate, that.minChargingRate) + && Objects.equals(powerTolerance, that.powerTolerance) + && Objects.equals(signatureId, that.signatureId) + && Objects.equals(digestValue, that.digestValue) + && Objects.equals(useLocalTime, that.useLocalTime) + && Arrays.equals(chargingSchedulePeriod, that.chargingSchedulePeriod) + && Objects.equals(randomizedDelay, that.randomizedDelay) + && Objects.equals(salesTariff, that.salesTariff) + && Objects.equals(absolutePriceSchedule, that.absolutePriceSchedule) + && Objects.equals(priceLevelSchedule, that.priceLevelSchedule) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + limitAtSoC, + startSchedule, + duration, + chargingRateUnit, + minChargingRate, + powerTolerance, + signatureId, + digestValue, + useLocalTime, + Arrays.hashCode(chargingSchedulePeriod), + randomizedDelay, + salesTariff, + absolutePriceSchedule, + priceLevelSchedule, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("limitAtSoC", limitAtSoC) + .add("startSchedule", startSchedule) + .add("duration", duration) + .add("chargingRateUnit", chargingRateUnit) + .add("minChargingRate", minChargingRate) + .add("powerTolerance", powerTolerance) + .add("signatureId", signatureId) + .add("digestValue", digestValue) + .add("useLocalTime", useLocalTime) + .add("chargingSchedulePeriod", chargingSchedulePeriod) + .add("randomizedDelay", randomizedDelay) + .add("salesTariff", salesTariff) + .add("absolutePriceSchedule", absolutePriceSchedule) + .add("priceLevelSchedule", priceLevelSchedule) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingSchedulePeriod.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingSchedulePeriod.java new file mode 100644 index 00000000..0aadf80a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingSchedulePeriod.java @@ -0,0 +1,1120 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charging schedule period structure defines a time period in a charging schedule. It is used in: + * CompositeScheduleType and in ChargingScheduleType. When used in a NotifyEVChargingScheduleRequest + * only startPeriod, limit, limitL2, limitL3 are relevant. + */ +public final class ChargingSchedulePeriod { + /** + * Start of the period, in seconds from the start of schedule. The value of StartPeriod also + * defines the stop time of the previous period. + */ + private Integer startPeriod; + + /** + * Optional only when not required by the operationMode, as in CentralSetpoint, ExternalSetpoint, + * ExternalLimits, LocalFrequency, LocalLoadBalancing. + * + *

Charging rate limit during the schedule period, in the applicable chargingRateUnit. This + * SHOULD be a non-negative value; a negative value is only supported for backwards compatibility + * with older systems that use a negative value to specify a discharging limit. When using + * chargingRateUnit = `W`, this field represents the sum of the power of all phases, unless values + * are provided for L2 and L3, in which case this field represents phase L1. + */ + @Nullable private Double limit; + + /** Charging rate limit on phase L2 in the applicable chargingRateUnit. */ + @Nullable private Double limit_L2; + + /** Charging rate limit on phase L3 in the applicable chargingRateUnit. */ + @Nullable private Double limit_L3; + + /** + * The number of phases that can be used for charging. + * + *

+   * For a DC EVSE this field should be omitted.
+   * For an AC EVSE a default value of numberPhases = 3 will be assumed if the field is absent.
+   * 
+ */ + @Nullable private Integer numberPhases; + + /** + * Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed + * unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, + * the Charging Station / EVSE will make the selection on its own. + */ + @Nullable private Integer phaseToUse; + + /** + * Limit in chargingRateUnit that the EV is allowed to discharge with. Note, these are negative + * values in order to be consistent with setpoint, which can be positive and negative. + * + *

For AC this field represents the sum of all phases, unless values are provided for L2 and + * L3, in which case this field represents phase L1. + */ + @Nullable private Double dischargeLimit; + + /** Limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with. */ + @Nullable private Double dischargeLimit_L2; + + /** Limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with. */ + @Nullable private Double dischargeLimit_L3; + + /** + * Setpoint in chargingRateUnit that the EV should follow as close as possible. Use negative + * values for discharging. + * + *

When a limit and/or dischargeLimit are given the overshoot when following setpoint must + * remain within these values. This field represents the sum of all phases, unless values are + * provided for L2 and L3, in which case this field represents phase L1. + */ + @Nullable private Double setpoint; + + /** Setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible. */ + @Nullable private Double setpoint_L2; + + /** Setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible. */ + @Nullable private Double setpoint_L3; + + /** + * Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow as + * closely as possible. Positive values for inductive, negative for capacitive reactive power or + * current. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, in + * which case this field represents phase L1. + */ + @Nullable private Double setpointReactive; + + /** + * Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on phase + * L2 as closely as possible. + */ + @Nullable private Double setpointReactive_L2; + + /** + * Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on phase + * L3 as closely as possible. + */ + @Nullable private Double setpointReactive_L3; + + /** If true, the EV should attempt to keep the BMS preconditioned for this time interval. */ + @Nullable private Boolean preconditioningRequest; + + /** + * Whether the EVSE must turn off power electronics/modules associated with this transaction. + * Default value when absent is false. + */ + @Nullable private Boolean evseSleep; + + /** + * Power value that, when present, is used as a baseline on top of which values from + * v2xFreqWattCurve and v2xSignalWattCurve are added. + */ + @Nullable private Double v2xBaseline; + + /** + * Charging operation mode to use during this time interval. When absent defaults to + * `ChargingOnly`. + */ + @Nullable private OperationModeEnum operationMode; + + /** A point of a frequency-watt curve. */ + @Nullable private V2XFreqWattPoint[] v2xFreqWattCurve; + + /** A point of a signal-watt curve. */ + @Nullable private V2XSignalWattPoint[] v2xSignalWattCurve; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChargingSchedulePeriod class + * + * @param startPeriod Start of the period, in seconds from the start of schedule. The value of + * StartPeriod also defines the stop time of the previous period. + */ + public ChargingSchedulePeriod(Integer startPeriod) { + setStartPeriod(startPeriod); + } + + /** + * Gets start of the period, in seconds from the start of schedule. The value of StartPeriod also + * defines the stop time of the previous period. + * + * @return Start of the period, in seconds from the start of schedule + */ + public Integer getStartPeriod() { + return startPeriod; + } + + /** + * Sets start of the period, in seconds from the start of schedule. The value of StartPeriod also + * defines the stop time of the previous period. + * + * @param startPeriod Start of the period, in seconds from the start of schedule + */ + public void setStartPeriod(Integer startPeriod) { + if (!isValidStartPeriod(startPeriod)) { + throw new PropertyConstraintException(startPeriod, "startPeriod is invalid"); + } + this.startPeriod = startPeriod; + } + + /** + * Returns whether the given startPeriod is valid + * + * @param startPeriod the startPeriod to check the validity of + * @return {@code true} if startPeriod is valid, {@code false} if not + */ + private boolean isValidStartPeriod(Integer startPeriod) { + return startPeriod != null; + } + + /** + * Gets optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing. + * + * @return Optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing + */ + @Nullable + public Double getLimit() { + return limit; + } + + /** + * Sets optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing. + * + * @param limit Optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing + */ + public void setLimit(@Nullable Double limit) { + this.limit = limit; + } + + /** + * Adds optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing. + * + * @param limit Optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing + * @return this + */ + public ChargingSchedulePeriod withLimit(@Nullable Double limit) { + setLimit(limit); + return this; + } + + /** + * Gets charging rate limit on phase L2 in the applicable chargingRateUnit. + * + * @return Charging rate limit on phase L2 in the applicable chargingRateUnit + */ + @Nullable + public Double getLimit_L2() { + return limit_L2; + } + + /** + * Sets charging rate limit on phase L2 in the applicable chargingRateUnit. + * + * @param limit_L2 Charging rate limit on phase L2 in the applicable chargingRateUnit + */ + public void setLimit_L2(@Nullable Double limit_L2) { + this.limit_L2 = limit_L2; + } + + /** + * Adds charging rate limit on phase L2 in the applicable chargingRateUnit. + * + * @param limit_L2 Charging rate limit on phase L2 in the applicable chargingRateUnit + * @return this + */ + public ChargingSchedulePeriod withLimit_L2(@Nullable Double limit_L2) { + setLimit_L2(limit_L2); + return this; + } + + /** + * Gets charging rate limit on phase L3 in the applicable chargingRateUnit. + * + * @return Charging rate limit on phase L3 in the applicable chargingRateUnit + */ + @Nullable + public Double getLimit_L3() { + return limit_L3; + } + + /** + * Sets charging rate limit on phase L3 in the applicable chargingRateUnit. + * + * @param limit_L3 Charging rate limit on phase L3 in the applicable chargingRateUnit + */ + public void setLimit_L3(@Nullable Double limit_L3) { + this.limit_L3 = limit_L3; + } + + /** + * Adds charging rate limit on phase L3 in the applicable chargingRateUnit. + * + * @param limit_L3 Charging rate limit on phase L3 in the applicable chargingRateUnit + * @return this + */ + public ChargingSchedulePeriod withLimit_L3(@Nullable Double limit_L3) { + setLimit_L3(limit_L3); + return this; + } + + /** + * Gets the number of phases that can be used for charging. + * + * @return The number of phases that can be used for charging + */ + @Nullable + public Integer getNumberPhases() { + return numberPhases; + } + + /** + * Sets the number of phases that can be used for charging. + * + * @param numberPhases The number of phases that can be used for charging + */ + public void setNumberPhases(@Nullable Integer numberPhases) { + if (!isValidNumberPhases(numberPhases)) { + throw new PropertyConstraintException(numberPhases, "numberPhases is invalid"); + } + this.numberPhases = numberPhases; + } + + /** + * Returns whether the given numberPhases is valid + * + * @param numberPhases the numberPhases to check the validity of + * @return {@code true} if numberPhases is valid, {@code false} if not + */ + private boolean isValidNumberPhases(@Nullable Integer numberPhases) { + return numberPhases == null || (numberPhases >= 0 && numberPhases <= 3); + } + + /** + * Adds the number of phases that can be used for charging. + * + * @param numberPhases The number of phases that can be used for charging + * @return this + */ + public ChargingSchedulePeriod withNumberPhases(@Nullable Integer numberPhases) { + setNumberPhases(numberPhases); + return this; + } + + /** + * Gets values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed + * unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, + * the Charging Station / EVSE will make the selection on its own. + * + * @return Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true + */ + @Nullable + public Integer getPhaseToUse() { + return phaseToUse; + } + + /** + * Sets values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed + * unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, + * the Charging Station / EVSE will make the selection on its own. + * + * @param phaseToUse Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching + * the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true + */ + public void setPhaseToUse(@Nullable Integer phaseToUse) { + if (!isValidPhaseToUse(phaseToUse)) { + throw new PropertyConstraintException(phaseToUse, "phaseToUse is invalid"); + } + this.phaseToUse = phaseToUse; + } + + /** + * Returns whether the given phaseToUse is valid + * + * @param phaseToUse the phaseToUse to check the validity of + * @return {@code true} if phaseToUse is valid, {@code false} if not + */ + private boolean isValidPhaseToUse(@Nullable Integer phaseToUse) { + return phaseToUse == null || (phaseToUse >= 0 && phaseToUse <= 3); + } + + /** + * Adds values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed + * unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, + * the Charging Station / EVSE will make the selection on its own. + * + * @param phaseToUse Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching + * the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true + * @return this + */ + public ChargingSchedulePeriod withPhaseToUse(@Nullable Integer phaseToUse) { + setPhaseToUse(phaseToUse); + return this; + } + + /** + * Gets limit in chargingRateUnit that the EV is allowed to discharge with. Note, these are + * negative values in order to be consistent with setpoint, which can be positive and negative. + * + * @return Limit in chargingRateUnit that the EV is allowed to discharge with + */ + @Nullable + public Double getDischargeLimit() { + return dischargeLimit; + } + + /** + * Sets limit in chargingRateUnit that the EV is allowed to discharge with. Note, these are + * negative values in order to be consistent with setpoint, which can be positive and negative. + * + * @param dischargeLimit Limit in chargingRateUnit that the EV is allowed to discharge with + */ + public void setDischargeLimit(@Nullable Double dischargeLimit) { + if (!isValidDischargeLimit(dischargeLimit)) { + throw new PropertyConstraintException(dischargeLimit, "dischargeLimit is invalid"); + } + this.dischargeLimit = dischargeLimit; + } + + /** + * Returns whether the given dischargeLimit is valid + * + * @param dischargeLimit the dischargeLimit to check the validity of + * @return {@code true} if dischargeLimit is valid, {@code false} if not + */ + private boolean isValidDischargeLimit(@Nullable Double dischargeLimit) { + return dischargeLimit == null || (dischargeLimit <= 0.0d); + } + + /** + * Adds limit in chargingRateUnit that the EV is allowed to discharge with. Note, these are + * negative values in order to be consistent with setpoint, which can be positive and negative. + * + * @param dischargeLimit Limit in chargingRateUnit that the EV is allowed to discharge with + * @return this + */ + public ChargingSchedulePeriod withDischargeLimit(@Nullable Double dischargeLimit) { + setDischargeLimit(dischargeLimit); + return this; + } + + /** + * Gets limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with. + * + * @return Limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with + */ + @Nullable + public Double getDischargeLimit_L2() { + return dischargeLimit_L2; + } + + /** + * Sets limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with. + * + * @param dischargeLimit_L2 Limit in chargingRateUnit on phase L2 that the EV is allowed to + * discharge with + */ + public void setDischargeLimit_L2(@Nullable Double dischargeLimit_L2) { + if (!isValidDischargeLimit_L2(dischargeLimit_L2)) { + throw new PropertyConstraintException(dischargeLimit_L2, "dischargeLimit_L2 is invalid"); + } + this.dischargeLimit_L2 = dischargeLimit_L2; + } + + /** + * Returns whether the given dischargeLimit_L2 is valid + * + * @param dischargeLimit_L2 the dischargeLimit_L2 to check the validity of + * @return {@code true} if dischargeLimit_L2 is valid, {@code false} if not + */ + private boolean isValidDischargeLimit_L2(@Nullable Double dischargeLimit_L2) { + return dischargeLimit_L2 == null || (dischargeLimit_L2 <= 0.0d); + } + + /** + * Adds limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with. + * + * @param dischargeLimit_L2 Limit in chargingRateUnit on phase L2 that the EV is allowed to + * discharge with + * @return this + */ + public ChargingSchedulePeriod withDischargeLimit_L2(@Nullable Double dischargeLimit_L2) { + setDischargeLimit_L2(dischargeLimit_L2); + return this; + } + + /** + * Gets limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with. + * + * @return Limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with + */ + @Nullable + public Double getDischargeLimit_L3() { + return dischargeLimit_L3; + } + + /** + * Sets limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with. + * + * @param dischargeLimit_L3 Limit in chargingRateUnit on phase L3 that the EV is allowed to + * discharge with + */ + public void setDischargeLimit_L3(@Nullable Double dischargeLimit_L3) { + if (!isValidDischargeLimit_L3(dischargeLimit_L3)) { + throw new PropertyConstraintException(dischargeLimit_L3, "dischargeLimit_L3 is invalid"); + } + this.dischargeLimit_L3 = dischargeLimit_L3; + } + + /** + * Returns whether the given dischargeLimit_L3 is valid + * + * @param dischargeLimit_L3 the dischargeLimit_L3 to check the validity of + * @return {@code true} if dischargeLimit_L3 is valid, {@code false} if not + */ + private boolean isValidDischargeLimit_L3(@Nullable Double dischargeLimit_L3) { + return dischargeLimit_L3 == null || (dischargeLimit_L3 <= 0.0d); + } + + /** + * Adds limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with. + * + * @param dischargeLimit_L3 Limit in chargingRateUnit on phase L3 that the EV is allowed to + * discharge with + * @return this + */ + public ChargingSchedulePeriod withDischargeLimit_L3(@Nullable Double dischargeLimit_L3) { + setDischargeLimit_L3(dischargeLimit_L3); + return this; + } + + /** + * Gets setpoint in chargingRateUnit that the EV should follow as close as possible. Use negative + * values for discharging. + * + * @return Setpoint in chargingRateUnit that the EV should follow as close as possible + */ + @Nullable + public Double getSetpoint() { + return setpoint; + } + + /** + * Sets setpoint in chargingRateUnit that the EV should follow as close as possible. Use negative + * values for discharging. + * + * @param setpoint Setpoint in chargingRateUnit that the EV should follow as close as possible + */ + public void setSetpoint(@Nullable Double setpoint) { + this.setpoint = setpoint; + } + + /** + * Adds setpoint in chargingRateUnit that the EV should follow as close as possible. Use negative + * values for discharging. + * + * @param setpoint Setpoint in chargingRateUnit that the EV should follow as close as possible + * @return this + */ + public ChargingSchedulePeriod withSetpoint(@Nullable Double setpoint) { + setSetpoint(setpoint); + return this; + } + + /** + * Gets setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible. + * + * @return Setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible + */ + @Nullable + public Double getSetpoint_L2() { + return setpoint_L2; + } + + /** + * Sets setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible. + * + * @param setpoint_L2 Setpoint in chargingRateUnit that the EV should follow on phase L2 as close + * as possible + */ + public void setSetpoint_L2(@Nullable Double setpoint_L2) { + this.setpoint_L2 = setpoint_L2; + } + + /** + * Adds setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible. + * + * @param setpoint_L2 Setpoint in chargingRateUnit that the EV should follow on phase L2 as close + * as possible + * @return this + */ + public ChargingSchedulePeriod withSetpoint_L2(@Nullable Double setpoint_L2) { + setSetpoint_L2(setpoint_L2); + return this; + } + + /** + * Gets setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible. + * + * @return Setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible + */ + @Nullable + public Double getSetpoint_L3() { + return setpoint_L3; + } + + /** + * Sets setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible. + * + * @param setpoint_L3 Setpoint in chargingRateUnit that the EV should follow on phase L3 as close + * as possible + */ + public void setSetpoint_L3(@Nullable Double setpoint_L3) { + this.setpoint_L3 = setpoint_L3; + } + + /** + * Adds setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible. + * + * @param setpoint_L3 Setpoint in chargingRateUnit that the EV should follow on phase L3 as close + * as possible + * @return this + */ + public ChargingSchedulePeriod withSetpoint_L3(@Nullable Double setpoint_L3) { + setSetpoint_L3(setpoint_L3); + return this; + } + + /** + * Gets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow as + * closely as possible. Positive values for inductive, negative for capacitive reactive power or + * current. + * + * @return Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow + * as closely as possible + */ + @Nullable + public Double getSetpointReactive() { + return setpointReactive; + } + + /** + * Sets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow as + * closely as possible. Positive values for inductive, negative for capacitive reactive power or + * current. + * + * @param setpointReactive Setpoint for reactive power (or current) in chargingRateUnit that the + * EV should follow as closely as possible + */ + public void setSetpointReactive(@Nullable Double setpointReactive) { + this.setpointReactive = setpointReactive; + } + + /** + * Adds setpoint for reactive power (or current) in chargingRateUnit that the EV should follow as + * closely as possible. Positive values for inductive, negative for capacitive reactive power or + * current. + * + * @param setpointReactive Setpoint for reactive power (or current) in chargingRateUnit that the + * EV should follow as closely as possible + * @return this + */ + public ChargingSchedulePeriod withSetpointReactive(@Nullable Double setpointReactive) { + setSetpointReactive(setpointReactive); + return this; + } + + /** + * Gets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L2 as closely as possible. + * + * @return Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow + * on phase L2 as closely as possible + */ + @Nullable + public Double getSetpointReactive_L2() { + return setpointReactive_L2; + } + + /** + * Sets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L2 as closely as possible. + * + * @param setpointReactive_L2 Setpoint for reactive power (or current) in chargingRateUnit that + * the EV should follow on phase L2 as closely as possible + */ + public void setSetpointReactive_L2(@Nullable Double setpointReactive_L2) { + this.setpointReactive_L2 = setpointReactive_L2; + } + + /** + * Adds setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L2 as closely as possible. + * + * @param setpointReactive_L2 Setpoint for reactive power (or current) in chargingRateUnit that + * the EV should follow on phase L2 as closely as possible + * @return this + */ + public ChargingSchedulePeriod withSetpointReactive_L2(@Nullable Double setpointReactive_L2) { + setSetpointReactive_L2(setpointReactive_L2); + return this; + } + + /** + * Gets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L3 as closely as possible. + * + * @return Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow + * on phase L3 as closely as possible + */ + @Nullable + public Double getSetpointReactive_L3() { + return setpointReactive_L3; + } + + /** + * Sets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L3 as closely as possible. + * + * @param setpointReactive_L3 Setpoint for reactive power (or current) in chargingRateUnit that + * the EV should follow on phase L3 as closely as possible + */ + public void setSetpointReactive_L3(@Nullable Double setpointReactive_L3) { + this.setpointReactive_L3 = setpointReactive_L3; + } + + /** + * Adds setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L3 as closely as possible. + * + * @param setpointReactive_L3 Setpoint for reactive power (or current) in chargingRateUnit that + * the EV should follow on phase L3 as closely as possible + * @return this + */ + public ChargingSchedulePeriod withSetpointReactive_L3(@Nullable Double setpointReactive_L3) { + setSetpointReactive_L3(setpointReactive_L3); + return this; + } + + /** + * Gets if true, the EV should attempt to keep the BMS preconditioned for this time interval. + * + * @return If true, the EV should attempt to keep the BMS preconditioned for this time interval + */ + @Nullable + public Boolean getPreconditioningRequest() { + return preconditioningRequest; + } + + /** + * Sets if true, the EV should attempt to keep the BMS preconditioned for this time interval. + * + * @param preconditioningRequest If true, the EV should attempt to keep the BMS preconditioned for + * this time interval + */ + public void setPreconditioningRequest(@Nullable Boolean preconditioningRequest) { + this.preconditioningRequest = preconditioningRequest; + } + + /** + * Adds if true, the EV should attempt to keep the BMS preconditioned for this time interval. + * + * @param preconditioningRequest If true, the EV should attempt to keep the BMS preconditioned for + * this time interval + * @return this + */ + public ChargingSchedulePeriod withPreconditioningRequest( + @Nullable Boolean preconditioningRequest) { + setPreconditioningRequest(preconditioningRequest); + return this; + } + + /** + * Gets whether the EVSE must turn off power electronics/modules associated with this transaction. + * Default value when absent is false. + * + * @return Whether the EVSE must turn off power electronics/modules associated with this + * transaction + */ + @Nullable + public Boolean getEvseSleep() { + return evseSleep; + } + + /** + * Sets whether the EVSE must turn off power electronics/modules associated with this transaction. + * Default value when absent is false. + * + * @param evseSleep Whether the EVSE must turn off power electronics/modules associated with this + * transaction + */ + public void setEvseSleep(@Nullable Boolean evseSleep) { + this.evseSleep = evseSleep; + } + + /** + * Adds whether the EVSE must turn off power electronics/modules associated with this transaction. + * Default value when absent is false. + * + * @param evseSleep Whether the EVSE must turn off power electronics/modules associated with this + * transaction + * @return this + */ + public ChargingSchedulePeriod withEvseSleep(@Nullable Boolean evseSleep) { + setEvseSleep(evseSleep); + return this; + } + + /** + * Gets power value that, when present, is used as a baseline on top of which values from + * v2xFreqWattCurve and v2xSignalWattCurve are added. + * + * @return Power value that, when present, is used as a baseline on top of which values from + * v2xFreqWattCurve and v2xSignalWattCurve are added + */ + @Nullable + public Double getV2xBaseline() { + return v2xBaseline; + } + + /** + * Sets power value that, when present, is used as a baseline on top of which values from + * v2xFreqWattCurve and v2xSignalWattCurve are added. + * + * @param v2xBaseline Power value that, when present, is used as a baseline on top of which values + * from v2xFreqWattCurve and v2xSignalWattCurve are added + */ + public void setV2xBaseline(@Nullable Double v2xBaseline) { + this.v2xBaseline = v2xBaseline; + } + + /** + * Adds power value that, when present, is used as a baseline on top of which values from + * v2xFreqWattCurve and v2xSignalWattCurve are added. + * + * @param v2xBaseline Power value that, when present, is used as a baseline on top of which values + * from v2xFreqWattCurve and v2xSignalWattCurve are added + * @return this + */ + public ChargingSchedulePeriod withV2xBaseline(@Nullable Double v2xBaseline) { + setV2xBaseline(v2xBaseline); + return this; + } + + /** + * Gets charging operation mode to use during this time interval. When absent defaults to + * `ChargingOnly`. + * + * @return Charging operation mode to use during this time interval + */ + @Nullable + public OperationModeEnum getOperationMode() { + return operationMode; + } + + /** + * Sets charging operation mode to use during this time interval. When absent defaults to + * `ChargingOnly`. + * + * @param operationMode Charging operation mode to use during this time interval + */ + public void setOperationMode(@Nullable OperationModeEnum operationMode) { + this.operationMode = operationMode; + } + + /** + * Adds charging operation mode to use during this time interval. When absent defaults to + * `ChargingOnly`. + * + * @param operationMode Charging operation mode to use during this time interval + * @return this + */ + public ChargingSchedulePeriod withOperationMode(@Nullable OperationModeEnum operationMode) { + setOperationMode(operationMode); + return this; + } + + /** + * Gets a point of a frequency-watt curve. + * + * @return A point of a frequency-watt curve + */ + @Nullable + public V2XFreqWattPoint[] getV2xFreqWattCurve() { + return v2xFreqWattCurve; + } + + /** + * Sets a point of a frequency-watt curve. + * + * @param v2xFreqWattCurve A point of a frequency-watt curve + */ + public void setV2xFreqWattCurve(@Nullable V2XFreqWattPoint[] v2xFreqWattCurve) { + if (!isValidV2xFreqWattCurve(v2xFreqWattCurve)) { + throw new PropertyConstraintException(v2xFreqWattCurve, "v2xFreqWattCurve is invalid"); + } + this.v2xFreqWattCurve = v2xFreqWattCurve; + } + + /** + * Returns whether the given v2xFreqWattCurve is valid + * + * @param v2xFreqWattCurve the v2xFreqWattCurve to check the validity of + * @return {@code true} if v2xFreqWattCurve is valid, {@code false} if not + */ + private boolean isValidV2xFreqWattCurve(@Nullable V2XFreqWattPoint[] v2xFreqWattCurve) { + return v2xFreqWattCurve == null + || (v2xFreqWattCurve.length >= 1 + && v2xFreqWattCurve.length <= 20 + && Arrays.stream(v2xFreqWattCurve).allMatch(item -> item.validate())); + } + + /** + * Adds a point of a frequency-watt curve. + * + * @param v2xFreqWattCurve A point of a frequency-watt curve + * @return this + */ + public ChargingSchedulePeriod withV2xFreqWattCurve( + @Nullable V2XFreqWattPoint[] v2xFreqWattCurve) { + setV2xFreqWattCurve(v2xFreqWattCurve); + return this; + } + + /** + * Gets a point of a signal-watt curve. + * + * @return A point of a signal-watt curve + */ + @Nullable + public V2XSignalWattPoint[] getV2xSignalWattCurve() { + return v2xSignalWattCurve; + } + + /** + * Sets a point of a signal-watt curve. + * + * @param v2xSignalWattCurve A point of a signal-watt curve + */ + public void setV2xSignalWattCurve(@Nullable V2XSignalWattPoint[] v2xSignalWattCurve) { + if (!isValidV2xSignalWattCurve(v2xSignalWattCurve)) { + throw new PropertyConstraintException(v2xSignalWattCurve, "v2xSignalWattCurve is invalid"); + } + this.v2xSignalWattCurve = v2xSignalWattCurve; + } + + /** + * Returns whether the given v2xSignalWattCurve is valid + * + * @param v2xSignalWattCurve the v2xSignalWattCurve to check the validity of + * @return {@code true} if v2xSignalWattCurve is valid, {@code false} if not + */ + private boolean isValidV2xSignalWattCurve(@Nullable V2XSignalWattPoint[] v2xSignalWattCurve) { + return v2xSignalWattCurve == null + || (v2xSignalWattCurve.length >= 1 + && v2xSignalWattCurve.length <= 20 + && Arrays.stream(v2xSignalWattCurve).allMatch(item -> item.validate())); + } + + /** + * Adds a point of a signal-watt curve. + * + * @param v2xSignalWattCurve A point of a signal-watt curve + * @return this + */ + public ChargingSchedulePeriod withV2xSignalWattCurve( + @Nullable V2XSignalWattPoint[] v2xSignalWattCurve) { + setV2xSignalWattCurve(v2xSignalWattCurve); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingSchedulePeriod withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidStartPeriod(startPeriod) + && isValidNumberPhases(numberPhases) + && isValidPhaseToUse(phaseToUse) + && isValidDischargeLimit(dischargeLimit) + && isValidDischargeLimit_L2(dischargeLimit_L2) + && isValidDischargeLimit_L3(dischargeLimit_L3) + && isValidV2xFreqWattCurve(v2xFreqWattCurve) + && isValidV2xSignalWattCurve(v2xSignalWattCurve) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingSchedulePeriod that = (ChargingSchedulePeriod) o; + return Objects.equals(startPeriod, that.startPeriod) + && Objects.equals(limit, that.limit) + && Objects.equals(limit_L2, that.limit_L2) + && Objects.equals(limit_L3, that.limit_L3) + && Objects.equals(numberPhases, that.numberPhases) + && Objects.equals(phaseToUse, that.phaseToUse) + && Objects.equals(dischargeLimit, that.dischargeLimit) + && Objects.equals(dischargeLimit_L2, that.dischargeLimit_L2) + && Objects.equals(dischargeLimit_L3, that.dischargeLimit_L3) + && Objects.equals(setpoint, that.setpoint) + && Objects.equals(setpoint_L2, that.setpoint_L2) + && Objects.equals(setpoint_L3, that.setpoint_L3) + && Objects.equals(setpointReactive, that.setpointReactive) + && Objects.equals(setpointReactive_L2, that.setpointReactive_L2) + && Objects.equals(setpointReactive_L3, that.setpointReactive_L3) + && Objects.equals(preconditioningRequest, that.preconditioningRequest) + && Objects.equals(evseSleep, that.evseSleep) + && Objects.equals(v2xBaseline, that.v2xBaseline) + && Objects.equals(operationMode, that.operationMode) + && Arrays.equals(v2xFreqWattCurve, that.v2xFreqWattCurve) + && Arrays.equals(v2xSignalWattCurve, that.v2xSignalWattCurve) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + startPeriod, + limit, + limit_L2, + limit_L3, + numberPhases, + phaseToUse, + dischargeLimit, + dischargeLimit_L2, + dischargeLimit_L3, + setpoint, + setpoint_L2, + setpoint_L3, + setpointReactive, + setpointReactive_L2, + setpointReactive_L3, + preconditioningRequest, + evseSleep, + v2xBaseline, + operationMode, + Arrays.hashCode(v2xFreqWattCurve), + Arrays.hashCode(v2xSignalWattCurve), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("startPeriod", startPeriod) + .add("limit", limit) + .add("limit_L2", limit_L2) + .add("limit_L3", limit_L3) + .add("numberPhases", numberPhases) + .add("phaseToUse", phaseToUse) + .add("dischargeLimit", dischargeLimit) + .add("dischargeLimit_L2", dischargeLimit_L2) + .add("dischargeLimit_L3", dischargeLimit_L3) + .add("setpoint", setpoint) + .add("setpoint_L2", setpoint_L2) + .add("setpoint_L3", setpoint_L3) + .add("setpointReactive", setpointReactive) + .add("setpointReactive_L2", setpointReactive_L2) + .add("setpointReactive_L3", setpointReactive_L3) + .add("preconditioningRequest", preconditioningRequest) + .add("evseSleep", evseSleep) + .add("v2xBaseline", v2xBaseline) + .add("operationMode", operationMode) + .add("v2xFreqWattCurve", v2xFreqWattCurve) + .add("v2xSignalWattCurve", v2xSignalWattCurve) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingScheduleUpdate.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingScheduleUpdate.java new file mode 100644 index 00000000..c98260a0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingScheduleUpdate.java @@ -0,0 +1,662 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Updates to a ChargingSchedulePeriodType for dynamic charging profiles. */ +public final class ChargingScheduleUpdate { + /** + * Optional only when not required by the operationMode, as in CentralSetpoint, ExternalSetpoint, + * ExternalLimits, LocalFrequency, LocalLoadBalancing. + * + *

Charging rate limit during the schedule period, in the applicable chargingRateUnit. This + * SHOULD be a non-negative value; a negative value is only supported for backwards compatibility + * with older systems that use a negative value to specify a discharging limit. For AC this field + * represents the sum of all phases, unless values are provided for L2 and L3, in which case this + * field represents phase L1. + */ + @Nullable private Double limit; + + /** Charging rate limit on phase L2 in the applicable chargingRateUnit. */ + @Nullable private Double limit_L2; + + /** Charging rate limit on phase L3 in the applicable chargingRateUnit. */ + @Nullable private Double limit_L3; + + /** + * Limit in chargingRateUnit that the EV is allowed to discharge with. Note, these are negative + * values in order to be consistent with setpoint, which can be positive and negative. + * + *

For AC this field represents the sum of all phases, unless values are provided for L2 and + * L3, in which case this field represents phase L1. + */ + @Nullable private Double dischargeLimit; + + /** Limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with. */ + @Nullable private Double dischargeLimit_L2; + + /** Limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with. */ + @Nullable private Double dischargeLimit_L3; + + /** + * Setpoint in chargingRateUnit that the EV should follow as close as possible. Use negative + * values for discharging. + * + *

When a limit and/or dischargeLimit are given the overshoot when following setpoint must + * remain within these values. This field represents the sum of all phases, unless values are + * provided for L2 and L3, in which case this field represents phase L1. + */ + @Nullable private Double setpoint; + + /** Setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible. */ + @Nullable private Double setpoint_L2; + + /** Setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible. */ + @Nullable private Double setpoint_L3; + + /** + * Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow as + * closely as possible. Positive values for inductive, negative for capacitive reactive power or + * current. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, in + * which case this field represents phase L1. + */ + @Nullable private Double setpointReactive; + + /** + * Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on phase + * L2 as closely as possible. + */ + @Nullable private Double setpointReactive_L2; + + /** + * Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on phase + * L3 as closely as possible. + */ + @Nullable private Double setpointReactive_L3; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ChargingScheduleUpdate class */ + public ChargingScheduleUpdate() {} + + /** + * Gets optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing. + * + * @return Optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing + */ + @Nullable + public Double getLimit() { + return limit; + } + + /** + * Sets optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing. + * + * @param limit Optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing + */ + public void setLimit(@Nullable Double limit) { + this.limit = limit; + } + + /** + * Adds optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing. + * + * @param limit Optional only when not required by the operationMode, as in CentralSetpoint, + * ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing + * @return this + */ + public ChargingScheduleUpdate withLimit(@Nullable Double limit) { + setLimit(limit); + return this; + } + + /** + * Gets charging rate limit on phase L2 in the applicable chargingRateUnit. + * + * @return Charging rate limit on phase L2 in the applicable chargingRateUnit + */ + @Nullable + public Double getLimit_L2() { + return limit_L2; + } + + /** + * Sets charging rate limit on phase L2 in the applicable chargingRateUnit. + * + * @param limit_L2 Charging rate limit on phase L2 in the applicable chargingRateUnit + */ + public void setLimit_L2(@Nullable Double limit_L2) { + this.limit_L2 = limit_L2; + } + + /** + * Adds charging rate limit on phase L2 in the applicable chargingRateUnit. + * + * @param limit_L2 Charging rate limit on phase L2 in the applicable chargingRateUnit + * @return this + */ + public ChargingScheduleUpdate withLimit_L2(@Nullable Double limit_L2) { + setLimit_L2(limit_L2); + return this; + } + + /** + * Gets charging rate limit on phase L3 in the applicable chargingRateUnit. + * + * @return Charging rate limit on phase L3 in the applicable chargingRateUnit + */ + @Nullable + public Double getLimit_L3() { + return limit_L3; + } + + /** + * Sets charging rate limit on phase L3 in the applicable chargingRateUnit. + * + * @param limit_L3 Charging rate limit on phase L3 in the applicable chargingRateUnit + */ + public void setLimit_L3(@Nullable Double limit_L3) { + this.limit_L3 = limit_L3; + } + + /** + * Adds charging rate limit on phase L3 in the applicable chargingRateUnit. + * + * @param limit_L3 Charging rate limit on phase L3 in the applicable chargingRateUnit + * @return this + */ + public ChargingScheduleUpdate withLimit_L3(@Nullable Double limit_L3) { + setLimit_L3(limit_L3); + return this; + } + + /** + * Gets limit in chargingRateUnit that the EV is allowed to discharge with. Note, these are + * negative values in order to be consistent with setpoint, which can be positive and negative. + * + * @return Limit in chargingRateUnit that the EV is allowed to discharge with + */ + @Nullable + public Double getDischargeLimit() { + return dischargeLimit; + } + + /** + * Sets limit in chargingRateUnit that the EV is allowed to discharge with. Note, these are + * negative values in order to be consistent with setpoint, which can be positive and negative. + * + * @param dischargeLimit Limit in chargingRateUnit that the EV is allowed to discharge with + */ + public void setDischargeLimit(@Nullable Double dischargeLimit) { + if (!isValidDischargeLimit(dischargeLimit)) { + throw new PropertyConstraintException(dischargeLimit, "dischargeLimit is invalid"); + } + this.dischargeLimit = dischargeLimit; + } + + /** + * Returns whether the given dischargeLimit is valid + * + * @param dischargeLimit the dischargeLimit to check the validity of + * @return {@code true} if dischargeLimit is valid, {@code false} if not + */ + private boolean isValidDischargeLimit(@Nullable Double dischargeLimit) { + return dischargeLimit == null || (dischargeLimit <= 0.0d); + } + + /** + * Adds limit in chargingRateUnit that the EV is allowed to discharge with. Note, these are + * negative values in order to be consistent with setpoint, which can be positive and negative. + * + * @param dischargeLimit Limit in chargingRateUnit that the EV is allowed to discharge with + * @return this + */ + public ChargingScheduleUpdate withDischargeLimit(@Nullable Double dischargeLimit) { + setDischargeLimit(dischargeLimit); + return this; + } + + /** + * Gets limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with. + * + * @return Limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with + */ + @Nullable + public Double getDischargeLimit_L2() { + return dischargeLimit_L2; + } + + /** + * Sets limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with. + * + * @param dischargeLimit_L2 Limit in chargingRateUnit on phase L2 that the EV is allowed to + * discharge with + */ + public void setDischargeLimit_L2(@Nullable Double dischargeLimit_L2) { + if (!isValidDischargeLimit_L2(dischargeLimit_L2)) { + throw new PropertyConstraintException(dischargeLimit_L2, "dischargeLimit_L2 is invalid"); + } + this.dischargeLimit_L2 = dischargeLimit_L2; + } + + /** + * Returns whether the given dischargeLimit_L2 is valid + * + * @param dischargeLimit_L2 the dischargeLimit_L2 to check the validity of + * @return {@code true} if dischargeLimit_L2 is valid, {@code false} if not + */ + private boolean isValidDischargeLimit_L2(@Nullable Double dischargeLimit_L2) { + return dischargeLimit_L2 == null || (dischargeLimit_L2 <= 0.0d); + } + + /** + * Adds limit in chargingRateUnit on phase L2 that the EV is allowed to discharge with. + * + * @param dischargeLimit_L2 Limit in chargingRateUnit on phase L2 that the EV is allowed to + * discharge with + * @return this + */ + public ChargingScheduleUpdate withDischargeLimit_L2(@Nullable Double dischargeLimit_L2) { + setDischargeLimit_L2(dischargeLimit_L2); + return this; + } + + /** + * Gets limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with. + * + * @return Limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with + */ + @Nullable + public Double getDischargeLimit_L3() { + return dischargeLimit_L3; + } + + /** + * Sets limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with. + * + * @param dischargeLimit_L3 Limit in chargingRateUnit on phase L3 that the EV is allowed to + * discharge with + */ + public void setDischargeLimit_L3(@Nullable Double dischargeLimit_L3) { + if (!isValidDischargeLimit_L3(dischargeLimit_L3)) { + throw new PropertyConstraintException(dischargeLimit_L3, "dischargeLimit_L3 is invalid"); + } + this.dischargeLimit_L3 = dischargeLimit_L3; + } + + /** + * Returns whether the given dischargeLimit_L3 is valid + * + * @param dischargeLimit_L3 the dischargeLimit_L3 to check the validity of + * @return {@code true} if dischargeLimit_L3 is valid, {@code false} if not + */ + private boolean isValidDischargeLimit_L3(@Nullable Double dischargeLimit_L3) { + return dischargeLimit_L3 == null || (dischargeLimit_L3 <= 0.0d); + } + + /** + * Adds limit in chargingRateUnit on phase L3 that the EV is allowed to discharge with. + * + * @param dischargeLimit_L3 Limit in chargingRateUnit on phase L3 that the EV is allowed to + * discharge with + * @return this + */ + public ChargingScheduleUpdate withDischargeLimit_L3(@Nullable Double dischargeLimit_L3) { + setDischargeLimit_L3(dischargeLimit_L3); + return this; + } + + /** + * Gets setpoint in chargingRateUnit that the EV should follow as close as possible. Use negative + * values for discharging. + * + * @return Setpoint in chargingRateUnit that the EV should follow as close as possible + */ + @Nullable + public Double getSetpoint() { + return setpoint; + } + + /** + * Sets setpoint in chargingRateUnit that the EV should follow as close as possible. Use negative + * values for discharging. + * + * @param setpoint Setpoint in chargingRateUnit that the EV should follow as close as possible + */ + public void setSetpoint(@Nullable Double setpoint) { + this.setpoint = setpoint; + } + + /** + * Adds setpoint in chargingRateUnit that the EV should follow as close as possible. Use negative + * values for discharging. + * + * @param setpoint Setpoint in chargingRateUnit that the EV should follow as close as possible + * @return this + */ + public ChargingScheduleUpdate withSetpoint(@Nullable Double setpoint) { + setSetpoint(setpoint); + return this; + } + + /** + * Gets setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible. + * + * @return Setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible + */ + @Nullable + public Double getSetpoint_L2() { + return setpoint_L2; + } + + /** + * Sets setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible. + * + * @param setpoint_L2 Setpoint in chargingRateUnit that the EV should follow on phase L2 as close + * as possible + */ + public void setSetpoint_L2(@Nullable Double setpoint_L2) { + this.setpoint_L2 = setpoint_L2; + } + + /** + * Adds setpoint in chargingRateUnit that the EV should follow on phase L2 as close as possible. + * + * @param setpoint_L2 Setpoint in chargingRateUnit that the EV should follow on phase L2 as close + * as possible + * @return this + */ + public ChargingScheduleUpdate withSetpoint_L2(@Nullable Double setpoint_L2) { + setSetpoint_L2(setpoint_L2); + return this; + } + + /** + * Gets setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible. + * + * @return Setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible + */ + @Nullable + public Double getSetpoint_L3() { + return setpoint_L3; + } + + /** + * Sets setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible. + * + * @param setpoint_L3 Setpoint in chargingRateUnit that the EV should follow on phase L3 as close + * as possible + */ + public void setSetpoint_L3(@Nullable Double setpoint_L3) { + this.setpoint_L3 = setpoint_L3; + } + + /** + * Adds setpoint in chargingRateUnit that the EV should follow on phase L3 as close as possible. + * + * @param setpoint_L3 Setpoint in chargingRateUnit that the EV should follow on phase L3 as close + * as possible + * @return this + */ + public ChargingScheduleUpdate withSetpoint_L3(@Nullable Double setpoint_L3) { + setSetpoint_L3(setpoint_L3); + return this; + } + + /** + * Gets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow as + * closely as possible. Positive values for inductive, negative for capacitive reactive power or + * current. + * + * @return Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow + * as closely as possible + */ + @Nullable + public Double getSetpointReactive() { + return setpointReactive; + } + + /** + * Sets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow as + * closely as possible. Positive values for inductive, negative for capacitive reactive power or + * current. + * + * @param setpointReactive Setpoint for reactive power (or current) in chargingRateUnit that the + * EV should follow as closely as possible + */ + public void setSetpointReactive(@Nullable Double setpointReactive) { + this.setpointReactive = setpointReactive; + } + + /** + * Adds setpoint for reactive power (or current) in chargingRateUnit that the EV should follow as + * closely as possible. Positive values for inductive, negative for capacitive reactive power or + * current. + * + * @param setpointReactive Setpoint for reactive power (or current) in chargingRateUnit that the + * EV should follow as closely as possible + * @return this + */ + public ChargingScheduleUpdate withSetpointReactive(@Nullable Double setpointReactive) { + setSetpointReactive(setpointReactive); + return this; + } + + /** + * Gets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L2 as closely as possible. + * + * @return Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow + * on phase L2 as closely as possible + */ + @Nullable + public Double getSetpointReactive_L2() { + return setpointReactive_L2; + } + + /** + * Sets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L2 as closely as possible. + * + * @param setpointReactive_L2 Setpoint for reactive power (or current) in chargingRateUnit that + * the EV should follow on phase L2 as closely as possible + */ + public void setSetpointReactive_L2(@Nullable Double setpointReactive_L2) { + this.setpointReactive_L2 = setpointReactive_L2; + } + + /** + * Adds setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L2 as closely as possible. + * + * @param setpointReactive_L2 Setpoint for reactive power (or current) in chargingRateUnit that + * the EV should follow on phase L2 as closely as possible + * @return this + */ + public ChargingScheduleUpdate withSetpointReactive_L2(@Nullable Double setpointReactive_L2) { + setSetpointReactive_L2(setpointReactive_L2); + return this; + } + + /** + * Gets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L3 as closely as possible. + * + * @return Setpoint for reactive power (or current) in chargingRateUnit that the EV should follow + * on phase L3 as closely as possible + */ + @Nullable + public Double getSetpointReactive_L3() { + return setpointReactive_L3; + } + + /** + * Sets setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L3 as closely as possible. + * + * @param setpointReactive_L3 Setpoint for reactive power (or current) in chargingRateUnit that + * the EV should follow on phase L3 as closely as possible + */ + public void setSetpointReactive_L3(@Nullable Double setpointReactive_L3) { + this.setpointReactive_L3 = setpointReactive_L3; + } + + /** + * Adds setpoint for reactive power (or current) in chargingRateUnit that the EV should follow on + * phase L3 as closely as possible. + * + * @param setpointReactive_L3 Setpoint for reactive power (or current) in chargingRateUnit that + * the EV should follow on phase L3 as closely as possible + * @return this + */ + public ChargingScheduleUpdate withSetpointReactive_L3(@Nullable Double setpointReactive_L3) { + setSetpointReactive_L3(setpointReactive_L3); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingScheduleUpdate withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDischargeLimit(dischargeLimit) + && isValidDischargeLimit_L2(dischargeLimit_L2) + && isValidDischargeLimit_L3(dischargeLimit_L3) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingScheduleUpdate that = (ChargingScheduleUpdate) o; + return Objects.equals(limit, that.limit) + && Objects.equals(limit_L2, that.limit_L2) + && Objects.equals(limit_L3, that.limit_L3) + && Objects.equals(dischargeLimit, that.dischargeLimit) + && Objects.equals(dischargeLimit_L2, that.dischargeLimit_L2) + && Objects.equals(dischargeLimit_L3, that.dischargeLimit_L3) + && Objects.equals(setpoint, that.setpoint) + && Objects.equals(setpoint_L2, that.setpoint_L2) + && Objects.equals(setpoint_L3, that.setpoint_L3) + && Objects.equals(setpointReactive, that.setpointReactive) + && Objects.equals(setpointReactive_L2, that.setpointReactive_L2) + && Objects.equals(setpointReactive_L3, that.setpointReactive_L3) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + limit, + limit_L2, + limit_L3, + dischargeLimit, + dischargeLimit_L2, + dischargeLimit_L3, + setpoint, + setpoint_L2, + setpoint_L3, + setpointReactive, + setpointReactive_L2, + setpointReactive_L3, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("limit", limit) + .add("limit_L2", limit_L2) + .add("limit_L3", limit_L3) + .add("dischargeLimit", dischargeLimit) + .add("dischargeLimit_L2", dischargeLimit_L2) + .add("dischargeLimit_L3", dischargeLimit_L3) + .add("setpoint", setpoint) + .add("setpoint_L2", setpoint_L2) + .add("setpoint_L3", setpoint_L3) + .add("setpointReactive", setpointReactive) + .add("setpointReactive_L2", setpointReactive_L2) + .add("setpointReactive_L3", setpointReactive_L3) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingStateEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingStateEnum.java new file mode 100644 index 00000000..c07cc83f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingStateEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Current charging state, is required when state has changed. Omitted when there is no + * communication between EVSE and EV, because no cable is plugged in. + */ +public enum ChargingStateEnum { + EVConnected, + Charging, + SuspendedEV, + SuspendedEVSE, + Idle +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingStation.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingStation.java new file mode 100644 index 00000000..d7e17641 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ChargingStation.java @@ -0,0 +1,348 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** The physical system where an Electrical Vehicle (EV) can be charged. */ +public final class ChargingStation { + /** Vendor-specific device identifier. */ + @Nullable private String serialNumber; + + /** The model of the device. */ + private String model; + + /** + * Parameters required for initiating and maintaining wireless communication with other devices. + */ + @Nullable private Modem modem; + + /** The identifier of the vendor (not necessarily in a unique manner). */ + private String vendorName; + + /** The firmware version of the Charging Station. */ + @Nullable private String firmwareVersion; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ChargingStation class + * + * @param model The model of the device. + * @param vendorName The identifier of the vendor (not necessarily in a unique manner). + */ + public ChargingStation(String model, String vendorName) { + setModel(model); + setVendorName(vendorName); + } + + /** + * Gets vendor-specific device identifier. + * + * @return Vendor-specific device identifier + */ + @Nullable + public String getSerialNumber() { + return serialNumber; + } + + /** + * Sets vendor-specific device identifier. + * + * @param serialNumber Vendor-specific device identifier + */ + public void setSerialNumber(@Nullable String serialNumber) { + if (!isValidSerialNumber(serialNumber)) { + throw new PropertyConstraintException(serialNumber, "serialNumber is invalid"); + } + this.serialNumber = serialNumber; + } + + /** + * Returns whether the given serialNumber is valid + * + * @param serialNumber the serialNumber to check the validity of + * @return {@code true} if serialNumber is valid, {@code false} if not + */ + private boolean isValidSerialNumber(@Nullable String serialNumber) { + return serialNumber == null || serialNumber.length() <= 25; + } + + /** + * Adds vendor-specific device identifier. + * + * @param serialNumber Vendor-specific device identifier + * @return this + */ + public ChargingStation withSerialNumber(@Nullable String serialNumber) { + setSerialNumber(serialNumber); + return this; + } + + /** + * Gets the model of the device. + * + * @return The model of the device + */ + public String getModel() { + return model; + } + + /** + * Sets the model of the device. + * + * @param model The model of the device + */ + public void setModel(String model) { + if (!isValidModel(model)) { + throw new PropertyConstraintException(model, "model is invalid"); + } + this.model = model; + } + + /** + * Returns whether the given model is valid + * + * @param model the model to check the validity of + * @return {@code true} if model is valid, {@code false} if not + */ + private boolean isValidModel(String model) { + return model != null && model.length() <= 20; + } + + /** + * Gets parameters required for initiating and maintaining wireless communication with other + * devices. + * + * @return Parameters required for initiating and maintaining wireless communication with other + * devices + */ + @Nullable + public Modem getModem() { + return modem; + } + + /** + * Sets parameters required for initiating and maintaining wireless communication with other + * devices. + * + * @param modem Parameters required for initiating and maintaining wireless communication with + * other devices + */ + public void setModem(@Nullable Modem modem) { + if (!isValidModem(modem)) { + throw new PropertyConstraintException(modem, "modem is invalid"); + } + this.modem = modem; + } + + /** + * Returns whether the given modem is valid + * + * @param modem the modem to check the validity of + * @return {@code true} if modem is valid, {@code false} if not + */ + private boolean isValidModem(@Nullable Modem modem) { + return modem == null || modem.validate(); + } + + /** + * Adds parameters required for initiating and maintaining wireless communication with other + * devices. + * + * @param modem Parameters required for initiating and maintaining wireless communication with + * other devices + * @return this + */ + public ChargingStation withModem(@Nullable Modem modem) { + setModem(modem); + return this; + } + + /** + * Gets the identifier of the vendor (not necessarily in a unique manner). + * + * @return The identifier of the vendor (not necessarily in a unique manner) + */ + public String getVendorName() { + return vendorName; + } + + /** + * Sets the identifier of the vendor (not necessarily in a unique manner). + * + * @param vendorName The identifier of the vendor (not necessarily in a unique manner) + */ + public void setVendorName(String vendorName) { + if (!isValidVendorName(vendorName)) { + throw new PropertyConstraintException(vendorName, "vendorName is invalid"); + } + this.vendorName = vendorName; + } + + /** + * Returns whether the given vendorName is valid + * + * @param vendorName the vendorName to check the validity of + * @return {@code true} if vendorName is valid, {@code false} if not + */ + private boolean isValidVendorName(String vendorName) { + return vendorName != null && vendorName.length() <= 50; + } + + /** + * Gets the firmware version of the Charging Station. + * + * @return The firmware version of the Charging Station + */ + @Nullable + public String getFirmwareVersion() { + return firmwareVersion; + } + + /** + * Sets the firmware version of the Charging Station. + * + * @param firmwareVersion The firmware version of the Charging Station + */ + public void setFirmwareVersion(@Nullable String firmwareVersion) { + if (!isValidFirmwareVersion(firmwareVersion)) { + throw new PropertyConstraintException(firmwareVersion, "firmwareVersion is invalid"); + } + this.firmwareVersion = firmwareVersion; + } + + /** + * Returns whether the given firmwareVersion is valid + * + * @param firmwareVersion the firmwareVersion to check the validity of + * @return {@code true} if firmwareVersion is valid, {@code false} if not + */ + private boolean isValidFirmwareVersion(@Nullable String firmwareVersion) { + return firmwareVersion == null || firmwareVersion.length() <= 50; + } + + /** + * Adds the firmware version of the Charging Station. + * + * @param firmwareVersion The firmware version of the Charging Station + * @return this + */ + public ChargingStation withFirmwareVersion(@Nullable String firmwareVersion) { + setFirmwareVersion(firmwareVersion); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingStation withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidSerialNumber(serialNumber) + && isValidModel(model) + && isValidModem(modem) + && isValidVendorName(vendorName) + && isValidFirmwareVersion(firmwareVersion) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingStation that = (ChargingStation) o; + return Objects.equals(serialNumber, that.serialNumber) + && Objects.equals(model, that.model) + && Objects.equals(modem, that.modem) + && Objects.equals(vendorName, that.vendorName) + && Objects.equals(firmwareVersion, that.firmwareVersion) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(serialNumber, model, modem, vendorName, firmwareVersion, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("serialNumber", serialNumber) + .add("model", model) + .add("modem", modem) + .add("vendorName", vendorName) + .add("firmwareVersion", firmwareVersion) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearCacheStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearCacheStatusEnum.java new file mode 100644 index 00000000..1d88997e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearCacheStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Accepted if the Charging Station has executed the request, otherwise rejected. */ +public enum ClearCacheStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearChargingProfile.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearChargingProfile.java new file mode 100644 index 00000000..814bb5dd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearChargingProfile.java @@ -0,0 +1,279 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A ClearChargingProfileType is a filter for charging profiles to be cleared by + * ClearChargingProfileRequest. + */ +public final class ClearChargingProfile { + /** + * Specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) + * specifies the charging profile for the overall Charging Station. Absence of this parameter + * means the clearing applies to all charging profiles that match the other criteria in the + * request. + */ + @Nullable private Integer evseId; + + /** + * Specifies to purpose of the charging profiles that will be cleared, if they meet the other + * criteria in the request. + */ + @Nullable private ChargingProfilePurposeEnum chargingProfilePurpose; + + /** + * Specifies the stackLevel for which charging profiles will be cleared, if they meet the other + * criteria in the request. + */ + @Nullable private Integer stackLevel; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ClearChargingProfile class */ + public ClearChargingProfile() {} + + /** + * Gets specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) + * specifies the charging profile for the overall Charging Station. Absence of this parameter + * means the clearing applies to all charging profiles that match the other criteria in the + * request. + * + * @return Specifies the id of the EVSE for which to clear charging profiles + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) + * specifies the charging profile for the overall Charging Station. Absence of this parameter + * means the clearing applies to all charging profiles that match the other criteria in the + * request. + * + * @param evseId Specifies the id of the EVSE for which to clear charging profiles + */ + public void setEvseId(@Nullable Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer evseId) { + return evseId == null || (evseId >= 0); + } + + /** + * Adds specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) + * specifies the charging profile for the overall Charging Station. Absence of this parameter + * means the clearing applies to all charging profiles that match the other criteria in the + * request. + * + * @param evseId Specifies the id of the EVSE for which to clear charging profiles + * @return this + */ + public ClearChargingProfile withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets specifies to purpose of the charging profiles that will be cleared, if they meet the other + * criteria in the request. + * + * @return Specifies to purpose of the charging profiles that will be cleared, if they meet the + * other criteria in the request + */ + @Nullable + public ChargingProfilePurposeEnum getChargingProfilePurpose() { + return chargingProfilePurpose; + } + + /** + * Sets specifies to purpose of the charging profiles that will be cleared, if they meet the other + * criteria in the request. + * + * @param chargingProfilePurpose Specifies to purpose of the charging profiles that will be + * cleared, if they meet the other criteria in the request + */ + public void setChargingProfilePurpose( + @Nullable ChargingProfilePurposeEnum chargingProfilePurpose) { + this.chargingProfilePurpose = chargingProfilePurpose; + } + + /** + * Adds specifies to purpose of the charging profiles that will be cleared, if they meet the other + * criteria in the request. + * + * @param chargingProfilePurpose Specifies to purpose of the charging profiles that will be + * cleared, if they meet the other criteria in the request + * @return this + */ + public ClearChargingProfile withChargingProfilePurpose( + @Nullable ChargingProfilePurposeEnum chargingProfilePurpose) { + setChargingProfilePurpose(chargingProfilePurpose); + return this; + } + + /** + * Gets specifies the stackLevel for which charging profiles will be cleared, if they meet the + * other criteria in the request. + * + * @return Specifies the stackLevel for which charging profiles will be cleared, if they meet the + * other criteria in the request + */ + @Nullable + public Integer getStackLevel() { + return stackLevel; + } + + /** + * Sets specifies the stackLevel for which charging profiles will be cleared, if they meet the + * other criteria in the request. + * + * @param stackLevel Specifies the stackLevel for which charging profiles will be cleared, if they + * meet the other criteria in the request + */ + public void setStackLevel(@Nullable Integer stackLevel) { + if (!isValidStackLevel(stackLevel)) { + throw new PropertyConstraintException(stackLevel, "stackLevel is invalid"); + } + this.stackLevel = stackLevel; + } + + /** + * Returns whether the given stackLevel is valid + * + * @param stackLevel the stackLevel to check the validity of + * @return {@code true} if stackLevel is valid, {@code false} if not + */ + private boolean isValidStackLevel(@Nullable Integer stackLevel) { + return stackLevel == null || (stackLevel >= 0); + } + + /** + * Adds specifies the stackLevel for which charging profiles will be cleared, if they meet the + * other criteria in the request. + * + * @param stackLevel Specifies the stackLevel for which charging profiles will be cleared, if they + * meet the other criteria in the request + * @return this + */ + public ClearChargingProfile withStackLevel(@Nullable Integer stackLevel) { + setStackLevel(stackLevel); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearChargingProfile withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEvseId(evseId) && isValidStackLevel(stackLevel) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearChargingProfile that = (ClearChargingProfile) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(chargingProfilePurpose, that.chargingProfilePurpose) + && Objects.equals(stackLevel, that.stackLevel) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evseId, chargingProfilePurpose, stackLevel, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("chargingProfilePurpose", chargingProfilePurpose) + .add("stackLevel", stackLevel) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearChargingProfileStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearChargingProfileStatusEnum.java new file mode 100644 index 00000000..dabca070 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearChargingProfileStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Charging Station was able to execute the request. */ +public enum ClearChargingProfileStatusEnum { + Accepted, + Unknown +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMessageStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMessageStatusEnum.java new file mode 100644 index 00000000..d5d8efaf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMessageStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Returns whether the Charging Station has been able to remove the message. */ +public enum ClearMessageStatusEnum { + Accepted, + Unknown, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMonitoringResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMonitoringResult.java new file mode 100644 index 00000000..d88af7af --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMonitoringResult.java @@ -0,0 +1,242 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** ClearMonitoringResultType */ +public final class ClearMonitoringResult { + /** Result of the clear request for this monitor, identified by its Id. */ + private ClearMonitoringStatusEnum status; + + /** Id of the monitor of which a clear was requested. */ + private Integer id; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearMonitoringResult class + * + * @param status Result of the clear request for this monitor, identified by its Id. + * @param id Id of the monitor of which a clear was requested. + */ + public ClearMonitoringResult(ClearMonitoringStatusEnum status, Integer id) { + setStatus(status); + setId(id); + } + + /** + * Gets result of the clear request for this monitor, identified by its Id. + * + * @return Result of the clear request for this monitor, identified by its Id + */ + public ClearMonitoringStatusEnum getStatus() { + return status; + } + + /** + * Sets result of the clear request for this monitor, identified by its Id. + * + * @param status Result of the clear request for this monitor, identified by its Id + */ + public void setStatus(ClearMonitoringStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ClearMonitoringStatusEnum status) { + return status != null; + } + + /** + * Gets id of the monitor of which a clear was requested. + * + * @return Id of the monitor of which a clear was requested + */ + public Integer getId() { + return id; + } + + /** + * Sets id of the monitor of which a clear was requested. + * + * @param id Id of the monitor of which a clear was requested + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearMonitoringResult withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearMonitoringResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidStatus(status) + && isValidId(id) + && isValidStatusInfo(statusInfo) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearMonitoringResult that = (ClearMonitoringResult) o; + return Objects.equals(status, that.status) + && Objects.equals(id, that.id) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(status, id, statusInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("id", id) + .add("statusInfo", statusInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMonitoringStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMonitoringStatusEnum.java new file mode 100644 index 00000000..ca057b86 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearMonitoringStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Result of the clear request for this monitor, identified by its Id. */ +public enum ClearMonitoringStatusEnum { + Accepted, + Rejected, + NotFound +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearTariffsResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearTariffsResult.java new file mode 100644 index 00000000..6e67c681 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ClearTariffsResult.java @@ -0,0 +1,258 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** ClearTariffsResultType */ +public final class ClearTariffsResult { + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Id of tariff for which status is reported. If no tariffs were found, then this field is absent, + * and status will be `NoTariff`. + */ + @Nullable private String tariffId; + + /** status */ + private TariffClearStatusEnum status; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ClearTariffsResult class + * + * @param status status + */ + public ClearTariffsResult(TariffClearStatusEnum status) { + setStatus(status); + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearTariffsResult withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets id of tariff for which status is reported. If no tariffs were found, then this field is + * absent, and status will be `NoTariff`. + * + * @return Id of tariff for which status is reported + */ + @Nullable + public String getTariffId() { + return tariffId; + } + + /** + * Sets id of tariff for which status is reported. If no tariffs were found, then this field is + * absent, and status will be `NoTariff`. + * + * @param tariffId Id of tariff for which status is reported + */ + public void setTariffId(@Nullable String tariffId) { + if (!isValidTariffId(tariffId)) { + throw new PropertyConstraintException(tariffId, "tariffId is invalid"); + } + this.tariffId = tariffId; + } + + /** + * Returns whether the given tariffId is valid + * + * @param tariffId the tariffId to check the validity of + * @return {@code true} if tariffId is valid, {@code false} if not + */ + private boolean isValidTariffId(@Nullable String tariffId) { + return tariffId == null || tariffId.length() <= 60; + } + + /** + * Adds id of tariff for which status is reported. If no tariffs were found, then this field is + * absent, and status will be `NoTariff`. + * + * @param tariffId Id of tariff for which status is reported + * @return this + */ + public ClearTariffsResult withTariffId(@Nullable String tariffId) { + setTariffId(tariffId); + return this; + } + + /** + * Gets status + * + * @return status + */ + public TariffClearStatusEnum getStatus() { + return status; + } + + /** + * Sets status + * + * @param status status + */ + public void setStatus(TariffClearStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(TariffClearStatusEnum status) { + return status != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearTariffsResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidStatusInfo(statusInfo) + && isValidTariffId(tariffId) + && isValidStatus(status) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearTariffsResult that = (ClearTariffsResult) o; + return Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(tariffId, that.tariffId) + && Objects.equals(status, that.status) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(statusInfo, tariffId, status, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("statusInfo", statusInfo) + .add("tariffId", tariffId) + .add("status", status) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Component.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Component.java new file mode 100644 index 00000000..21e265e6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Component.java @@ -0,0 +1,264 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A physical or logical component */ +public final class Component { + /** Electric Vehicle Supply Equipment */ + @Nullable private EVSE evse; + + /** + * Name of the component. Name should be taken from the list of standardized component names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + */ + private String name; + + /** + * Name of instance in case the component exists as multiple instances. Case Insensitive. strongly + * advised to use Camel Case. + */ + @Nullable private String instance; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Component class + * + * @param name Name of the component. Name should be taken from the list of standardized component + * names whenever possible. Case Insensitive. strongly advised to use Camel Case. + */ + public Component(String name) { + setName(name); + } + + /** + * Gets electric Vehicle Supply Equipment + * + * @return Electric Vehicle Supply Equipment + */ + @Nullable + public EVSE getEvse() { + return evse; + } + + /** + * Sets electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + */ + public void setEvse(@Nullable EVSE evse) { + if (!isValidEvse(evse)) { + throw new PropertyConstraintException(evse, "evse is invalid"); + } + this.evse = evse; + } + + /** + * Returns whether the given evse is valid + * + * @param evse the evse to check the validity of + * @return {@code true} if evse is valid, {@code false} if not + */ + private boolean isValidEvse(@Nullable EVSE evse) { + return evse == null || evse.validate(); + } + + /** + * Adds electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + * @return this + */ + public Component withEvse(@Nullable EVSE evse) { + setEvse(evse); + return this; + } + + /** + * Gets name of the component. Name should be taken from the list of standardized component names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + * + * @return Name of the component + */ + public String getName() { + return name; + } + + /** + * Sets name of the component. Name should be taken from the list of standardized component names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + * + * @param name Name of the component + */ + public void setName(String name) { + if (!isValidName(name)) { + throw new PropertyConstraintException(name, "name is invalid"); + } + this.name = name; + } + + /** + * Returns whether the given name is valid + * + * @param name the name to check the validity of + * @return {@code true} if name is valid, {@code false} if not + */ + private boolean isValidName(String name) { + return name != null && name.length() <= 50; + } + + /** + * Gets name of instance in case the component exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @return Name of instance in case the component exists as multiple instances + */ + @Nullable + public String getInstance() { + return instance; + } + + /** + * Sets name of instance in case the component exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @param instance Name of instance in case the component exists as multiple instances + */ + public void setInstance(@Nullable String instance) { + if (!isValidInstance(instance)) { + throw new PropertyConstraintException(instance, "instance is invalid"); + } + this.instance = instance; + } + + /** + * Returns whether the given instance is valid + * + * @param instance the instance to check the validity of + * @return {@code true} if instance is valid, {@code false} if not + */ + private boolean isValidInstance(@Nullable String instance) { + return instance == null || instance.length() <= 50; + } + + /** + * Adds name of instance in case the component exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @param instance Name of instance in case the component exists as multiple instances + * @return this + */ + public Component withInstance(@Nullable String instance) { + setInstance(instance); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Component withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEvse(evse) + && isValidName(name) + && isValidInstance(instance) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Component that = (Component) o; + return Objects.equals(evse, that.evse) + && Objects.equals(name, that.name) + && Objects.equals(instance, that.instance) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evse, name, instance, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evse", evse) + .add("name", name) + .add("instance", instance) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ComponentCriterionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ComponentCriterionEnum.java new file mode 100644 index 00000000..e5716e1d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ComponentCriterionEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** ComponentCriterionEnumType */ +public enum ComponentCriterionEnum { + Active, + Available, + Enabled, + Problem +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ComponentVariable.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ComponentVariable.java new file mode 100644 index 00000000..63f225d8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ComponentVariable.java @@ -0,0 +1,203 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to report components, variables and variable attributes and characteristics. */ +public final class ComponentVariable { + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + @Nullable private Variable variable; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ComponentVariable class + * + * @param component A physical or logical component + */ + public ComponentVariable(Component component) { + setComponent(component); + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + @Nullable + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(@Nullable Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(@Nullable Variable variable) { + return variable == null || variable.validate(); + } + + /** + * Adds reference key to a component-variable. + * + * @param variable Reference key to a component-variable + * @return this + */ + public ComponentVariable withVariable(@Nullable Variable variable) { + setVariable(variable); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ComponentVariable withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidComponent(component) + && isValidVariable(variable) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ComponentVariable that = (ComponentVariable) o; + return Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(component, variable, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("component", component) + .add("variable", variable) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CompositeSchedule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CompositeSchedule.java new file mode 100644 index 00000000..1da05bbe --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CompositeSchedule.java @@ -0,0 +1,338 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** CompositeScheduleType */ +public final class CompositeSchedule { + /** evseId */ + private Integer evseId; + + /** duration */ + private Integer duration; + + /** scheduleStart */ + private ZonedDateTime scheduleStart; + + /** chargingRateUnit */ + private ChargingRateUnitEnum chargingRateUnit; + + /** + * Charging schedule period structure defines a time period in a charging schedule. It is used in: + * CompositeScheduleType and in ChargingScheduleType. When used in a + * NotifyEVChargingScheduleRequest only startPeriod, limit, limitL2, limitL3 are relevant. + */ + private ChargingSchedulePeriod[] chargingSchedulePeriod; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CompositeSchedule class + * + * @param evseId evseId + * @param duration duration + * @param scheduleStart scheduleStart + * @param chargingRateUnit chargingRateUnit + * @param chargingSchedulePeriod Charging schedule period structure defines a time period in a + * charging schedule. It is used in: CompositeScheduleType and in ChargingScheduleType. When + * used in a NotifyEVChargingScheduleRequest only startPeriod, limit, limitL2, limitL3 are + * relevant. + */ + public CompositeSchedule( + Integer evseId, + Integer duration, + ZonedDateTime scheduleStart, + ChargingRateUnitEnum chargingRateUnit, + ChargingSchedulePeriod[] chargingSchedulePeriod) { + setEvseId(evseId); + setDuration(duration); + setScheduleStart(scheduleStart); + setChargingRateUnit(chargingRateUnit); + setChargingSchedulePeriod(chargingSchedulePeriod); + } + + /** + * Gets evseId + * + * @return evseId + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets evseId + * + * @param evseId evseId + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null && evseId >= 0; + } + + /** + * Gets duration + * + * @return duration + */ + public Integer getDuration() { + return duration; + } + + /** + * Sets duration + * + * @param duration duration + */ + public void setDuration(Integer duration) { + if (!isValidDuration(duration)) { + throw new PropertyConstraintException(duration, "duration is invalid"); + } + this.duration = duration; + } + + /** + * Returns whether the given duration is valid + * + * @param duration the duration to check the validity of + * @return {@code true} if duration is valid, {@code false} if not + */ + private boolean isValidDuration(Integer duration) { + return duration != null; + } + + /** + * Gets scheduleStart + * + * @return scheduleStart + */ + public ZonedDateTime getScheduleStart() { + return scheduleStart; + } + + /** + * Sets scheduleStart + * + * @param scheduleStart scheduleStart + */ + public void setScheduleStart(ZonedDateTime scheduleStart) { + if (!isValidScheduleStart(scheduleStart)) { + throw new PropertyConstraintException(scheduleStart, "scheduleStart is invalid"); + } + this.scheduleStart = scheduleStart; + } + + /** + * Returns whether the given scheduleStart is valid + * + * @param scheduleStart the scheduleStart to check the validity of + * @return {@code true} if scheduleStart is valid, {@code false} if not + */ + private boolean isValidScheduleStart(ZonedDateTime scheduleStart) { + return scheduleStart != null; + } + + /** + * Gets chargingRateUnit + * + * @return chargingRateUnit + */ + public ChargingRateUnitEnum getChargingRateUnit() { + return chargingRateUnit; + } + + /** + * Sets chargingRateUnit + * + * @param chargingRateUnit chargingRateUnit + */ + public void setChargingRateUnit(ChargingRateUnitEnum chargingRateUnit) { + if (!isValidChargingRateUnit(chargingRateUnit)) { + throw new PropertyConstraintException(chargingRateUnit, "chargingRateUnit is invalid"); + } + this.chargingRateUnit = chargingRateUnit; + } + + /** + * Returns whether the given chargingRateUnit is valid + * + * @param chargingRateUnit the chargingRateUnit to check the validity of + * @return {@code true} if chargingRateUnit is valid, {@code false} if not + */ + private boolean isValidChargingRateUnit(ChargingRateUnitEnum chargingRateUnit) { + return chargingRateUnit != null; + } + + /** + * Gets charging schedule period structure defines a time period in a charging schedule. It is + * used in: CompositeScheduleType and in ChargingScheduleType. When used in a + * NotifyEVChargingScheduleRequest only startPeriod, limit, limitL2, limitL3 are relevant. + * + * @return Charging schedule period structure defines a time period in a charging schedule + */ + public ChargingSchedulePeriod[] getChargingSchedulePeriod() { + return chargingSchedulePeriod; + } + + /** + * Sets charging schedule period structure defines a time period in a charging schedule. It is + * used in: CompositeScheduleType and in ChargingScheduleType. When used in a + * NotifyEVChargingScheduleRequest only startPeriod, limit, limitL2, limitL3 are relevant. + * + * @param chargingSchedulePeriod Charging schedule period structure defines a time period in a + * charging schedule + */ + public void setChargingSchedulePeriod(ChargingSchedulePeriod[] chargingSchedulePeriod) { + if (!isValidChargingSchedulePeriod(chargingSchedulePeriod)) { + throw new PropertyConstraintException( + chargingSchedulePeriod, "chargingSchedulePeriod is invalid"); + } + this.chargingSchedulePeriod = chargingSchedulePeriod; + } + + /** + * Returns whether the given chargingSchedulePeriod is valid + * + * @param chargingSchedulePeriod the chargingSchedulePeriod to check the validity of + * @return {@code true} if chargingSchedulePeriod is valid, {@code false} if not + */ + private boolean isValidChargingSchedulePeriod(ChargingSchedulePeriod[] chargingSchedulePeriod) { + return chargingSchedulePeriod != null + && chargingSchedulePeriod.length >= 1 + && Arrays.stream(chargingSchedulePeriod).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CompositeSchedule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEvseId(evseId) + && isValidDuration(duration) + && isValidScheduleStart(scheduleStart) + && isValidChargingRateUnit(chargingRateUnit) + && isValidChargingSchedulePeriod(chargingSchedulePeriod) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CompositeSchedule that = (CompositeSchedule) o; + return Objects.equals(evseId, that.evseId) + && Objects.equals(duration, that.duration) + && Objects.equals(scheduleStart, that.scheduleStart) + && Objects.equals(chargingRateUnit, that.chargingRateUnit) + && Arrays.equals(chargingSchedulePeriod, that.chargingSchedulePeriod) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + evseId, + duration, + scheduleStart, + chargingRateUnit, + Arrays.hashCode(chargingSchedulePeriod), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evseId", evseId) + .add("duration", duration) + .add("scheduleStart", scheduleStart) + .add("chargingRateUnit", chargingRateUnit) + .add("chargingSchedulePeriod", chargingSchedulePeriod) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConnectorStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConnectorStatusEnum.java new file mode 100644 index 00000000..bc6b7fea --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConnectorStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The current status of the Connector. */ +public enum ConnectorStatusEnum { + Available, + Occupied, + Reserved, + Unavailable, + Faulted +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConstantStreamData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConstantStreamData.java new file mode 100644 index 00000000..b1e1ca40 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConstantStreamData.java @@ -0,0 +1,235 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** ConstantStreamDataType */ +public final class ConstantStreamData { + /** Uniquely identifies the stream */ + private Integer id; + + /** params */ + private PeriodicEventStreamParams params; + + /** Id of monitor used to report his event. It can be a preconfigured or hardwired monitor. */ + private Integer variableMonitoringId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ConstantStreamData class + * + * @param id Uniquely identifies the stream + * @param params params + * @param variableMonitoringId Id of monitor used to report his event. It can be a preconfigured + * or hardwired monitor. + */ + public ConstantStreamData( + Integer id, PeriodicEventStreamParams params, Integer variableMonitoringId) { + setId(id); + setParams(params); + setVariableMonitoringId(variableMonitoringId); + } + + /** + * Gets uniquely identifies the stream + * + * @return Uniquely identifies the stream + */ + public Integer getId() { + return id; + } + + /** + * Sets uniquely identifies the stream + * + * @param id Uniquely identifies the stream + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets params + * + * @return params + */ + public PeriodicEventStreamParams getParams() { + return params; + } + + /** + * Sets params + * + * @param params params + */ + public void setParams(PeriodicEventStreamParams params) { + if (!isValidParams(params)) { + throw new PropertyConstraintException(params, "params is invalid"); + } + this.params = params; + } + + /** + * Returns whether the given params is valid + * + * @param params the params to check the validity of + * @return {@code true} if params is valid, {@code false} if not + */ + private boolean isValidParams(PeriodicEventStreamParams params) { + return params != null && params.validate(); + } + + /** + * Gets id of monitor used to report his event. It can be a preconfigured or hardwired monitor. + * + * @return Id of monitor used to report his event + */ + public Integer getVariableMonitoringId() { + return variableMonitoringId; + } + + /** + * Sets id of monitor used to report his event. It can be a preconfigured or hardwired monitor. + * + * @param variableMonitoringId Id of monitor used to report his event + */ + public void setVariableMonitoringId(Integer variableMonitoringId) { + if (!isValidVariableMonitoringId(variableMonitoringId)) { + throw new PropertyConstraintException( + variableMonitoringId, "variableMonitoringId is invalid"); + } + this.variableMonitoringId = variableMonitoringId; + } + + /** + * Returns whether the given variableMonitoringId is valid + * + * @param variableMonitoringId the variableMonitoringId to check the validity of + * @return {@code true} if variableMonitoringId is valid, {@code false} if not + */ + private boolean isValidVariableMonitoringId(Integer variableMonitoringId) { + return variableMonitoringId != null && variableMonitoringId >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ConstantStreamData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) + && isValidParams(params) + && isValidVariableMonitoringId(variableMonitoringId) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConstantStreamData that = (ConstantStreamData) o; + return Objects.equals(id, that.id) + && Objects.equals(params, that.params) + && Objects.equals(variableMonitoringId, that.variableMonitoringId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(id, params, variableMonitoringId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("params", params) + .add("variableMonitoringId", variableMonitoringId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConsumptionCost.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConsumptionCost.java new file mode 100644 index 00000000..0daa0ea6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ConsumptionCost.java @@ -0,0 +1,203 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** ConsumptionCostType */ +public final class ConsumptionCost { + /** + * The lowest level of consumption that defines the starting point of this consumption block. The + * block interval extends to the start of the next interval. + */ + private Double startValue; + + /** cost */ + private Cost[] cost; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ConsumptionCost class + * + * @param startValue The lowest level of consumption that defines the starting point of this + * consumption block. The block interval extends to the start of the next interval. + * @param cost cost + */ + public ConsumptionCost(Double startValue, Cost[] cost) { + setStartValue(startValue); + setCost(cost); + } + + /** + * Gets the lowest level of consumption that defines the starting point of this consumption block. + * The block interval extends to the start of the next interval. + * + * @return The lowest level of consumption that defines the starting point of this consumption + * block + */ + public Double getStartValue() { + return startValue; + } + + /** + * Sets the lowest level of consumption that defines the starting point of this consumption block. + * The block interval extends to the start of the next interval. + * + * @param startValue The lowest level of consumption that defines the starting point of this + * consumption block + */ + public void setStartValue(Double startValue) { + if (!isValidStartValue(startValue)) { + throw new PropertyConstraintException(startValue, "startValue is invalid"); + } + this.startValue = startValue; + } + + /** + * Returns whether the given startValue is valid + * + * @param startValue the startValue to check the validity of + * @return {@code true} if startValue is valid, {@code false} if not + */ + private boolean isValidStartValue(Double startValue) { + return startValue != null; + } + + /** + * Gets cost + * + * @return cost + */ + public Cost[] getCost() { + return cost; + } + + /** + * Sets cost + * + * @param cost cost + */ + public void setCost(Cost[] cost) { + if (!isValidCost(cost)) { + throw new PropertyConstraintException(cost, "cost is invalid"); + } + this.cost = cost; + } + + /** + * Returns whether the given cost is valid + * + * @param cost the cost to check the validity of + * @return {@code true} if cost is valid, {@code false} if not + */ + private boolean isValidCost(Cost[] cost) { + return cost != null + && cost.length >= 1 + && cost.length <= 3 + && Arrays.stream(cost).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ConsumptionCost withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidStartValue(startValue) && isValidCost(cost) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConsumptionCost that = (ConsumptionCost) o; + return Objects.equals(startValue, that.startValue) + && Arrays.equals(cost, that.cost) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(startValue, Arrays.hashCode(cost), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("startValue", startValue) + .add("cost", cost) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ControlModeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ControlModeEnum.java new file mode 100644 index 00000000..36545b63 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ControlModeEnum.java @@ -0,0 +1,39 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Whether EV wants to operate in Dynamic or Scheduled mode. When absent, Scheduled mode is assumed + * for backwards compatibility. + * + *

+ * *ISO 15118-20:*
+ * ServiceSelectionReq(SelectedEnergyTransferService)
+ * 
+ */ +public enum ControlModeEnum { + ScheduledControl, + DynamicControl +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Cost.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Cost.java new file mode 100644 index 00000000..bf00e8a1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Cost.java @@ -0,0 +1,234 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** CostType */ +public final class Cost { + /** The kind of cost referred to in the message element amount */ + private CostKindEnum costKind; + + /** The estimated or actual cost per kWh */ + private Integer amount; + + /** + * Values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is + * determined by: amount * 10 ^ amountMultiplier + */ + @Nullable private Integer amountMultiplier; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Cost class + * + * @param costKind The kind of cost referred to in the message element amount + * @param amount The estimated or actual cost per kWh + */ + public Cost(CostKindEnum costKind, Integer amount) { + setCostKind(costKind); + setAmount(amount); + } + + /** + * Gets the kind of cost referred to in the message element amount + * + * @return The kind of cost referred to in the message element amount + */ + public CostKindEnum getCostKind() { + return costKind; + } + + /** + * Sets the kind of cost referred to in the message element amount + * + * @param costKind The kind of cost referred to in the message element amount + */ + public void setCostKind(CostKindEnum costKind) { + if (!isValidCostKind(costKind)) { + throw new PropertyConstraintException(costKind, "costKind is invalid"); + } + this.costKind = costKind; + } + + /** + * Returns whether the given costKind is valid + * + * @param costKind the costKind to check the validity of + * @return {@code true} if costKind is valid, {@code false} if not + */ + private boolean isValidCostKind(CostKindEnum costKind) { + return costKind != null; + } + + /** + * Gets the estimated or actual cost per kWh + * + * @return The estimated or actual cost per kWh + */ + public Integer getAmount() { + return amount; + } + + /** + * Sets the estimated or actual cost per kWh + * + * @param amount The estimated or actual cost per kWh + */ + public void setAmount(Integer amount) { + if (!isValidAmount(amount)) { + throw new PropertyConstraintException(amount, "amount is invalid"); + } + this.amount = amount; + } + + /** + * Returns whether the given amount is valid + * + * @param amount the amount to check the validity of + * @return {@code true} if amount is valid, {@code false} if not + */ + private boolean isValidAmount(Integer amount) { + return amount != null; + } + + /** + * Gets values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value + * is determined by: amount * 10 ^ amountMultiplier + * + * @return Values: -3..3, The amountMultiplier defines the exponent to base 10 (dec) + */ + @Nullable + public Integer getAmountMultiplier() { + return amountMultiplier; + } + + /** + * Sets values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value + * is determined by: amount * 10 ^ amountMultiplier + * + * @param amountMultiplier Values: -3..3, The amountMultiplier defines the exponent to base 10 + * (dec) + */ + public void setAmountMultiplier(@Nullable Integer amountMultiplier) { + this.amountMultiplier = amountMultiplier; + } + + /** + * Adds values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value + * is determined by: amount * 10 ^ amountMultiplier + * + * @param amountMultiplier Values: -3..3, The amountMultiplier defines the exponent to base 10 + * (dec) + * @return this + */ + public Cost withAmountMultiplier(@Nullable Integer amountMultiplier) { + setAmountMultiplier(amountMultiplier); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Cost withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCostKind(costKind) && isValidAmount(amount) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cost that = (Cost) o; + return Objects.equals(costKind, that.costKind) + && Objects.equals(amount, that.amount) + && Objects.equals(amountMultiplier, that.amountMultiplier) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(costKind, amount, amountMultiplier, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("costKind", costKind) + .add("amount", amount) + .add("amountMultiplier", amountMultiplier) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDetails.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDetails.java new file mode 100644 index 00000000..39f556e7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDetails.java @@ -0,0 +1,366 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CostDetailsType contains the cost as calculated by Charging Station based on provided TariffType. + * + *

NOTE: Reservation is not shown as a chargingPeriod, because it took place outside of the + * transaction. + */ +public final class CostDetails { + /** + * A ChargingPeriodType consists of a start time, and a list of possible values that influence + * this period, for example: amount of energy charged this period, maximum current during this + * period etc. + */ + @Nullable private ChargingPeriod[] chargingPeriods; + + /** + * The cost calculated during a transaction. It is used both for running cost and final cost of + * the transaction. + */ + private TotalCost totalCost; + + /** The calculated usage of energy, charging time and idle time during a transaction. */ + private TotalUsage totalUsage; + + /** If set to true, then Charging Station has failed to calculate the cost. */ + @Nullable private Boolean failureToCalculate; + + /** Optional human-readable reason text in case of failure to calculate. */ + @Nullable private String failureReason; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CostDetails class + * + * @param totalCost The cost calculated during a transaction. It is used both for running cost and + * final cost of the transaction. + * @param totalUsage The calculated usage of energy, charging time and idle time during a + * transaction. + */ + public CostDetails(TotalCost totalCost, TotalUsage totalUsage) { + setTotalCost(totalCost); + setTotalUsage(totalUsage); + } + + /** + * Gets a ChargingPeriodType consists of a start time, and a list of possible values that + * influence this period, for example: amount of energy charged this period, maximum current + * during this period etc. + * + * @return A ChargingPeriodType consists of a start time, and a list of possible values that + * influence this period, for example: amount of energy charged this period, maximum current + * during this period etc + */ + @Nullable + public ChargingPeriod[] getChargingPeriods() { + return chargingPeriods; + } + + /** + * Sets a ChargingPeriodType consists of a start time, and a list of possible values that + * influence this period, for example: amount of energy charged this period, maximum current + * during this period etc. + * + * @param chargingPeriods A ChargingPeriodType consists of a start time, and a list of possible + * values that influence this period, for example: amount of energy charged this period, + * maximum current during this period etc + */ + public void setChargingPeriods(@Nullable ChargingPeriod[] chargingPeriods) { + if (!isValidChargingPeriods(chargingPeriods)) { + throw new PropertyConstraintException(chargingPeriods, "chargingPeriods is invalid"); + } + this.chargingPeriods = chargingPeriods; + } + + /** + * Returns whether the given chargingPeriods is valid + * + * @param chargingPeriods the chargingPeriods to check the validity of + * @return {@code true} if chargingPeriods is valid, {@code false} if not + */ + private boolean isValidChargingPeriods(@Nullable ChargingPeriod[] chargingPeriods) { + return chargingPeriods == null + || (chargingPeriods.length >= 1 + && Arrays.stream(chargingPeriods).allMatch(item -> item.validate())); + } + + /** + * Adds a ChargingPeriodType consists of a start time, and a list of possible values that + * influence this period, for example: amount of energy charged this period, maximum current + * during this period etc. + * + * @param chargingPeriods A ChargingPeriodType consists of a start time, and a list of possible + * values that influence this period, for example: amount of energy charged this period, + * maximum current during this period etc + * @return this + */ + public CostDetails withChargingPeriods(@Nullable ChargingPeriod[] chargingPeriods) { + setChargingPeriods(chargingPeriods); + return this; + } + + /** + * Gets the cost calculated during a transaction. It is used both for running cost and final cost + * of the transaction. + * + * @return The cost calculated during a transaction + */ + public TotalCost getTotalCost() { + return totalCost; + } + + /** + * Sets the cost calculated during a transaction. It is used both for running cost and final cost + * of the transaction. + * + * @param totalCost The cost calculated during a transaction + */ + public void setTotalCost(TotalCost totalCost) { + if (!isValidTotalCost(totalCost)) { + throw new PropertyConstraintException(totalCost, "totalCost is invalid"); + } + this.totalCost = totalCost; + } + + /** + * Returns whether the given totalCost is valid + * + * @param totalCost the totalCost to check the validity of + * @return {@code true} if totalCost is valid, {@code false} if not + */ + private boolean isValidTotalCost(TotalCost totalCost) { + return totalCost != null && totalCost.validate(); + } + + /** + * Gets the calculated usage of energy, charging time and idle time during a transaction. + * + * @return The calculated usage of energy, charging time and idle time during a transaction + */ + public TotalUsage getTotalUsage() { + return totalUsage; + } + + /** + * Sets the calculated usage of energy, charging time and idle time during a transaction. + * + * @param totalUsage The calculated usage of energy, charging time and idle time during a + * transaction + */ + public void setTotalUsage(TotalUsage totalUsage) { + if (!isValidTotalUsage(totalUsage)) { + throw new PropertyConstraintException(totalUsage, "totalUsage is invalid"); + } + this.totalUsage = totalUsage; + } + + /** + * Returns whether the given totalUsage is valid + * + * @param totalUsage the totalUsage to check the validity of + * @return {@code true} if totalUsage is valid, {@code false} if not + */ + private boolean isValidTotalUsage(TotalUsage totalUsage) { + return totalUsage != null && totalUsage.validate(); + } + + /** + * Gets if set to true, then Charging Station has failed to calculate the cost. + * + * @return If set to true, then Charging Station has failed to calculate the cost + */ + @Nullable + public Boolean getFailureToCalculate() { + return failureToCalculate; + } + + /** + * Sets if set to true, then Charging Station has failed to calculate the cost. + * + * @param failureToCalculate If set to true, then Charging Station has failed to calculate the + * cost + */ + public void setFailureToCalculate(@Nullable Boolean failureToCalculate) { + this.failureToCalculate = failureToCalculate; + } + + /** + * Adds if set to true, then Charging Station has failed to calculate the cost. + * + * @param failureToCalculate If set to true, then Charging Station has failed to calculate the + * cost + * @return this + */ + public CostDetails withFailureToCalculate(@Nullable Boolean failureToCalculate) { + setFailureToCalculate(failureToCalculate); + return this; + } + + /** + * Gets optional human-readable reason text in case of failure to calculate. + * + * @return Optional human-readable reason text in case of failure to calculate + */ + @Nullable + public String getFailureReason() { + return failureReason; + } + + /** + * Sets optional human-readable reason text in case of failure to calculate. + * + * @param failureReason Optional human-readable reason text in case of failure to calculate + */ + public void setFailureReason(@Nullable String failureReason) { + if (!isValidFailureReason(failureReason)) { + throw new PropertyConstraintException(failureReason, "failureReason is invalid"); + } + this.failureReason = failureReason; + } + + /** + * Returns whether the given failureReason is valid + * + * @param failureReason the failureReason to check the validity of + * @return {@code true} if failureReason is valid, {@code false} if not + */ + private boolean isValidFailureReason(@Nullable String failureReason) { + return failureReason == null || failureReason.length() <= 500; + } + + /** + * Adds optional human-readable reason text in case of failure to calculate. + * + * @param failureReason Optional human-readable reason text in case of failure to calculate + * @return this + */ + public CostDetails withFailureReason(@Nullable String failureReason) { + setFailureReason(failureReason); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CostDetails withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidChargingPeriods(chargingPeriods) + && isValidTotalCost(totalCost) + && isValidTotalUsage(totalUsage) + && isValidFailureReason(failureReason) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostDetails that = (CostDetails) o; + return Arrays.equals(chargingPeriods, that.chargingPeriods) + && Objects.equals(totalCost, that.totalCost) + && Objects.equals(totalUsage, that.totalUsage) + && Objects.equals(failureToCalculate, that.failureToCalculate) + && Objects.equals(failureReason, that.failureReason) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(chargingPeriods), + totalCost, + totalUsage, + failureToCalculate, + failureReason, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("chargingPeriods", chargingPeriods) + .add("totalCost", totalCost) + .add("totalUsage", totalUsage) + .add("failureToCalculate", failureToCalculate) + .add("failureReason", failureReason) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDimension.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDimension.java new file mode 100644 index 00000000..b7d8d5f5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDimension.java @@ -0,0 +1,191 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Volume consumed of cost dimension. */ +public final class CostDimension { + /** Type of cost dimension: energy, power, time, etc. */ + private CostDimensionEnum type; + + /** Volume of the dimension consumed, measured according to the dimension type. */ + private Double volume; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the CostDimension class + * + * @param type Type of cost dimension: energy, power, time, etc. + * @param volume Volume of the dimension consumed, measured according to the dimension type. + */ + public CostDimension(CostDimensionEnum type, Double volume) { + setType(type); + setVolume(volume); + } + + /** + * Gets type of cost dimension: energy, power, time, etc. + * + * @return Type of cost dimension: energy, power, time, etc + */ + public CostDimensionEnum getType() { + return type; + } + + /** + * Sets type of cost dimension: energy, power, time, etc. + * + * @param type Type of cost dimension: energy, power, time, etc + */ + public void setType(CostDimensionEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(CostDimensionEnum type) { + return type != null; + } + + /** + * Gets volume of the dimension consumed, measured according to the dimension type. + * + * @return Volume of the dimension consumed, measured according to the dimension type + */ + public Double getVolume() { + return volume; + } + + /** + * Sets volume of the dimension consumed, measured according to the dimension type. + * + * @param volume Volume of the dimension consumed, measured according to the dimension type + */ + public void setVolume(Double volume) { + if (!isValidVolume(volume)) { + throw new PropertyConstraintException(volume, "volume is invalid"); + } + this.volume = volume; + } + + /** + * Returns whether the given volume is valid + * + * @param volume the volume to check the validity of + * @return {@code true} if volume is valid, {@code false} if not + */ + private boolean isValidVolume(Double volume) { + return volume != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CostDimension withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidType(type) && isValidVolume(volume) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostDimension that = (CostDimension) o; + return Objects.equals(type, that.type) + && Objects.equals(volume, that.volume) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(type, volume, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("type", type) + .add("volume", volume) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDimensionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDimensionEnum.java new file mode 100644 index 00000000..adde4f63 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostDimensionEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of cost dimension: energy, power, time, etc. */ +public enum CostDimensionEnum { + Energy, + MaxCurrent, + MinCurrent, + MaxPower, + MinPower, + IdleTIme, + ChargingTime +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostKindEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostKindEnum.java new file mode 100644 index 00000000..ba630b36 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CostKindEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The kind of cost referred to in the message element amount */ +public enum CostKindEnum { + CarbonDioxideEmission, + RelativePricePercentage, + RenewableGenerationPercentage +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CustomData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CustomData.java new file mode 100644 index 00000000..f3813c25 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CustomData.java @@ -0,0 +1,104 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; + +/** Custom data */ +public class CustomData { + /** vendorId */ + private String vendorId; + + /** + * Constructor for the CustomData class + * + * @param vendorId vendorId + */ + public CustomData(String vendorId) { + setVendorId(vendorId); + } + + /** + * Gets vendorId + * + * @return vendorId + */ + public String getVendorId() { + return vendorId; + } + + /** + * Sets vendorId + * + * @param vendorId vendorId + */ + public void setVendorId(String vendorId) { + if (!isValidVendorId(vendorId)) { + throw new PropertyConstraintException(vendorId, "vendorId is invalid"); + } + this.vendorId = vendorId; + } + + /** + * Returns whether the given vendorId is valid + * + * @param vendorId the vendorId to check the validity of + * @return {@code true} if vendorId is valid, {@code false} if not + */ + private boolean isValidVendorId(String vendorId) { + return vendorId != null && vendorId.length() <= 255; + } + + public boolean validate() { + return isValidVendorId(vendorId); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomData that = (CustomData) o; + return Objects.equals(vendorId, that.vendorId); + } + + @Override + public int hashCode() { + return Objects.hash(vendorId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("vendorId", vendorId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CustomerInformationStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CustomerInformationStatusEnum.java new file mode 100644 index 00000000..2aa4334f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/CustomerInformationStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the request was accepted. */ +public enum CustomerInformationStatusEnum { + Accepted, + Rejected, + Invalid +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DCChargingParameters.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DCChargingParameters.java new file mode 100644 index 00000000..dc303498 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DCChargingParameters.java @@ -0,0 +1,519 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** EV DC charging parameters for ISO 15118-2 */ +public final class DCChargingParameters { + /** + * Maximum current (in A) supported by the electric vehicle. Includes cable capacity. + * + *

+   * Relates to:
+   * *ISO 15118-2*: DCEVChargeParameterType:EVMaximumCurrentLimit
+   * 
+ */ + private Double evMaxCurrent; + + /** + * Maximum voltage supported by the electric vehicle. + * + *
+   * Relates to:
+   * *ISO 15118-2*: DCEVChargeParameterType: EVMaximumVoltageLimit
+   * 
+ */ + private Double evMaxVoltage; + + /** + * Maximum power (in W) supported by the electric vehicle. Required for DC charging. + * + *
+   * Relates to:
+   * *ISO 15118-2*: DCEVChargeParameterType: EVMaximumPowerLimit
+   * 
+ */ + @Nullable private Double evMaxPower; + + /** + * Capacity of the electric vehicle battery (in Wh). + * + *
+   * Relates to:
+   * *ISO 15118-2*: DCEVChargeParameterType: EVEnergyCapacity
+   * 
+ */ + @Nullable private Double evEnergyCapacity; + + /** + * Amount of energy requested (in Wh). This inludes energy required for preconditioning. + * + *
+   * Relates to:
+   * *ISO 15118-2*: DCEVChargeParameterType: EVEnergyRequest
+   * 
+ */ + @Nullable private Double energyAmount; + + /** + * Energy available in the battery (in percent of the battery capacity) + * + *
+   * Relates to:
+   * *ISO 15118-2*: DCEVChargeParameterType: DCEVStatus: EVRESSSOC
+   * 
+ */ + @Nullable private Integer stateOfCharge; + + /** + * Percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 - + * 100) + * + *
+   * Relates to:
+   * *ISO 15118-2*: DCEVChargeParameterType: FullSOC
+   * 
+ */ + @Nullable private Integer fullSoC; + + /** + * Percentage of SoC at which the EV considers a fast charging process to end. (possible values: 0 + * - 100) + * + *
+   * Relates to:
+   * *ISO 15118-2*: DCEVChargeParameterType: BulkSOC
+   * 
+ */ + @Nullable private Integer bulkSoC; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the DCChargingParameters class + * + * @param evMaxCurrent Maximum current (in A) supported by the electric vehicle. Includes cable + * capacity. + * @param evMaxVoltage Maximum voltage supported by the electric vehicle. + */ + public DCChargingParameters(Double evMaxCurrent, Double evMaxVoltage) { + setEvMaxCurrent(evMaxCurrent); + setEvMaxVoltage(evMaxVoltage); + } + + /** + * Gets maximum current (in A) supported by the electric vehicle. Includes cable capacity. + * + * @return Maximum current (in A) supported by the electric vehicle + */ + public Double getEvMaxCurrent() { + return evMaxCurrent; + } + + /** + * Sets maximum current (in A) supported by the electric vehicle. Includes cable capacity. + * + * @param evMaxCurrent Maximum current (in A) supported by the electric vehicle + */ + public void setEvMaxCurrent(Double evMaxCurrent) { + if (!isValidEvMaxCurrent(evMaxCurrent)) { + throw new PropertyConstraintException(evMaxCurrent, "evMaxCurrent is invalid"); + } + this.evMaxCurrent = evMaxCurrent; + } + + /** + * Returns whether the given evMaxCurrent is valid + * + * @param evMaxCurrent the evMaxCurrent to check the validity of + * @return {@code true} if evMaxCurrent is valid, {@code false} if not + */ + private boolean isValidEvMaxCurrent(Double evMaxCurrent) { + return evMaxCurrent != null; + } + + /** + * Gets maximum voltage supported by the electric vehicle. + * + * @return Maximum voltage supported by the electric vehicle + */ + public Double getEvMaxVoltage() { + return evMaxVoltage; + } + + /** + * Sets maximum voltage supported by the electric vehicle. + * + * @param evMaxVoltage Maximum voltage supported by the electric vehicle + */ + public void setEvMaxVoltage(Double evMaxVoltage) { + if (!isValidEvMaxVoltage(evMaxVoltage)) { + throw new PropertyConstraintException(evMaxVoltage, "evMaxVoltage is invalid"); + } + this.evMaxVoltage = evMaxVoltage; + } + + /** + * Returns whether the given evMaxVoltage is valid + * + * @param evMaxVoltage the evMaxVoltage to check the validity of + * @return {@code true} if evMaxVoltage is valid, {@code false} if not + */ + private boolean isValidEvMaxVoltage(Double evMaxVoltage) { + return evMaxVoltage != null; + } + + /** + * Gets maximum power (in W) supported by the electric vehicle. Required for DC charging. + * + * @return Maximum power (in W) supported by the electric vehicle + */ + @Nullable + public Double getEvMaxPower() { + return evMaxPower; + } + + /** + * Sets maximum power (in W) supported by the electric vehicle. Required for DC charging. + * + * @param evMaxPower Maximum power (in W) supported by the electric vehicle + */ + public void setEvMaxPower(@Nullable Double evMaxPower) { + this.evMaxPower = evMaxPower; + } + + /** + * Adds maximum power (in W) supported by the electric vehicle. Required for DC charging. + * + * @param evMaxPower Maximum power (in W) supported by the electric vehicle + * @return this + */ + public DCChargingParameters withEvMaxPower(@Nullable Double evMaxPower) { + setEvMaxPower(evMaxPower); + return this; + } + + /** + * Gets capacity of the electric vehicle battery (in Wh). + * + * @return Capacity of the electric vehicle battery (in Wh) + */ + @Nullable + public Double getEvEnergyCapacity() { + return evEnergyCapacity; + } + + /** + * Sets capacity of the electric vehicle battery (in Wh). + * + * @param evEnergyCapacity Capacity of the electric vehicle battery (in Wh) + */ + public void setEvEnergyCapacity(@Nullable Double evEnergyCapacity) { + this.evEnergyCapacity = evEnergyCapacity; + } + + /** + * Adds capacity of the electric vehicle battery (in Wh). + * + * @param evEnergyCapacity Capacity of the electric vehicle battery (in Wh) + * @return this + */ + public DCChargingParameters withEvEnergyCapacity(@Nullable Double evEnergyCapacity) { + setEvEnergyCapacity(evEnergyCapacity); + return this; + } + + /** + * Gets amount of energy requested (in Wh). This inludes energy required for preconditioning. + * + * @return Amount of energy requested (in Wh) + */ + @Nullable + public Double getEnergyAmount() { + return energyAmount; + } + + /** + * Sets amount of energy requested (in Wh). This inludes energy required for preconditioning. + * + * @param energyAmount Amount of energy requested (in Wh) + */ + public void setEnergyAmount(@Nullable Double energyAmount) { + this.energyAmount = energyAmount; + } + + /** + * Adds amount of energy requested (in Wh). This inludes energy required for preconditioning. + * + * @param energyAmount Amount of energy requested (in Wh) + * @return this + */ + public DCChargingParameters withEnergyAmount(@Nullable Double energyAmount) { + setEnergyAmount(energyAmount); + return this; + } + + /** + * Gets energy available in the battery (in percent of the battery capacity) + * + * @return Energy available in the battery (in percent of the battery capacity) + */ + @Nullable + public Integer getStateOfCharge() { + return stateOfCharge; + } + + /** + * Sets energy available in the battery (in percent of the battery capacity) + * + * @param stateOfCharge Energy available in the battery (in percent of the battery capacity) + */ + public void setStateOfCharge(@Nullable Integer stateOfCharge) { + if (!isValidStateOfCharge(stateOfCharge)) { + throw new PropertyConstraintException(stateOfCharge, "stateOfCharge is invalid"); + } + this.stateOfCharge = stateOfCharge; + } + + /** + * Returns whether the given stateOfCharge is valid + * + * @param stateOfCharge the stateOfCharge to check the validity of + * @return {@code true} if stateOfCharge is valid, {@code false} if not + */ + private boolean isValidStateOfCharge(@Nullable Integer stateOfCharge) { + return stateOfCharge == null || (stateOfCharge >= 0 && stateOfCharge <= 100); + } + + /** + * Adds energy available in the battery (in percent of the battery capacity) + * + * @param stateOfCharge Energy available in the battery (in percent of the battery capacity) + * @return this + */ + public DCChargingParameters withStateOfCharge(@Nullable Integer stateOfCharge) { + setStateOfCharge(stateOfCharge); + return this; + } + + /** + * Gets percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 + * - 100) + * + * @return Percentage of SoC at which the EV considers the battery fully charged + */ + @Nullable + public Integer getFullSoC() { + return fullSoC; + } + + /** + * Sets percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 + * - 100) + * + * @param fullSoC Percentage of SoC at which the EV considers the battery fully charged + */ + public void setFullSoC(@Nullable Integer fullSoC) { + if (!isValidFullSoC(fullSoC)) { + throw new PropertyConstraintException(fullSoC, "fullSoC is invalid"); + } + this.fullSoC = fullSoC; + } + + /** + * Returns whether the given fullSoC is valid + * + * @param fullSoC the fullSoC to check the validity of + * @return {@code true} if fullSoC is valid, {@code false} if not + */ + private boolean isValidFullSoC(@Nullable Integer fullSoC) { + return fullSoC == null || (fullSoC >= 0 && fullSoC <= 100); + } + + /** + * Adds percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 + * - 100) + * + * @param fullSoC Percentage of SoC at which the EV considers the battery fully charged + * @return this + */ + public DCChargingParameters withFullSoC(@Nullable Integer fullSoC) { + setFullSoC(fullSoC); + return this; + } + + /** + * Gets percentage of SoC at which the EV considers a fast charging process to end. (possible + * values: 0 - 100) + * + * @return Percentage of SoC at which the EV considers a fast charging process to end + */ + @Nullable + public Integer getBulkSoC() { + return bulkSoC; + } + + /** + * Sets percentage of SoC at which the EV considers a fast charging process to end. (possible + * values: 0 - 100) + * + * @param bulkSoC Percentage of SoC at which the EV considers a fast charging process to end + */ + public void setBulkSoC(@Nullable Integer bulkSoC) { + if (!isValidBulkSoC(bulkSoC)) { + throw new PropertyConstraintException(bulkSoC, "bulkSoC is invalid"); + } + this.bulkSoC = bulkSoC; + } + + /** + * Returns whether the given bulkSoC is valid + * + * @param bulkSoC the bulkSoC to check the validity of + * @return {@code true} if bulkSoC is valid, {@code false} if not + */ + private boolean isValidBulkSoC(@Nullable Integer bulkSoC) { + return bulkSoC == null || (bulkSoC >= 0 && bulkSoC <= 100); + } + + /** + * Adds percentage of SoC at which the EV considers a fast charging process to end. (possible + * values: 0 - 100) + * + * @param bulkSoC Percentage of SoC at which the EV considers a fast charging process to end + * @return this + */ + public DCChargingParameters withBulkSoC(@Nullable Integer bulkSoC) { + setBulkSoC(bulkSoC); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DCChargingParameters withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEvMaxCurrent(evMaxCurrent) + && isValidEvMaxVoltage(evMaxVoltage) + && isValidStateOfCharge(stateOfCharge) + && isValidFullSoC(fullSoC) + && isValidBulkSoC(bulkSoC) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DCChargingParameters that = (DCChargingParameters) o; + return Objects.equals(evMaxCurrent, that.evMaxCurrent) + && Objects.equals(evMaxVoltage, that.evMaxVoltage) + && Objects.equals(evMaxPower, that.evMaxPower) + && Objects.equals(evEnergyCapacity, that.evEnergyCapacity) + && Objects.equals(energyAmount, that.energyAmount) + && Objects.equals(stateOfCharge, that.stateOfCharge) + && Objects.equals(fullSoC, that.fullSoC) + && Objects.equals(bulkSoC, that.bulkSoC) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + evMaxCurrent, + evMaxVoltage, + evMaxPower, + evEnergyCapacity, + energyAmount, + stateOfCharge, + fullSoC, + bulkSoC, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evMaxCurrent", evMaxCurrent) + .add("evMaxVoltage", evMaxVoltage) + .add("evMaxPower", evMaxPower) + .add("evEnergyCapacity", evEnergyCapacity) + .add("energyAmount", energyAmount) + .add("stateOfCharge", stateOfCharge) + .add("fullSoC", fullSoC) + .add("bulkSoC", bulkSoC) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERChargingParameters.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERChargingParameters.java new file mode 100644 index 00000000..fdc0c387 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERChargingParameters.java @@ -0,0 +1,2062 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DERChargingParametersType is used in ChargingNeedsType during an ISO 15118-20 session for + * ACBPTDER to report the inverter settings related to DER control that were agreed between EVSE and + * EV. + * + *

Fields starting with "ev" contain values from the EV. Other fields contain a value that is + * supported by both EV and EVSE. + * + *

DERChargingParametersType type is only relevant in case of an ISO 15118-20 ACBPTDER/ACDER + * charging session. + * + *

NOTE: All these fields have values greater or equal to zero (i.e. are non-negative) + */ +public final class DERChargingParameters { + /** + * DER control functions supported by EV. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType:DERControlFunctions (bitmap) + */ + @Nullable private DERControlEnum[] evSupportedDERControl; + + /** + * Rated maximum injected active power by EV, at specified over-excited power factor + * (overExcitedPowerFactor). + * + *

+   * It can also be defined as the rated maximum discharge power at the rated minimum injected
+   * reactive power value. This means that if the EV is providing reactive power support, and it is
+   * requested to discharge at max power (e.g. to satisfy an EMS request), the EV may override the
+   * request and discharge up to overExcitedMaximumDischargePower to meet the minimum reactive power
+   * requirements.
+   * Corresponds to the WOvPF attribute in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVOverExcitedMaximumDischargePower
+   * 
+ */ + @Nullable private Double evOverExcitedMaxDischargePower; + + /** + * EV power factor when injecting (over excited) the minimum reactive power. + * + *
+   * Corresponds to the OvPF attribute in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVOverExcitedPowerFactor
+   * 
+ */ + @Nullable private Double evOverExcitedPowerFactor; + + /** + * Rated maximum injected active power by EV supported at specified under-excited power factor + * (EVUnderExcitedPowerFactor). + * + *

It can also be defined as the rated maximum dischargePower at the rated minimum absorbed + * reactive power value. + * + *

+   * This means that if the EV is providing reactive power support, and it is requested to discharge
+   * at max power (e.g. to satisfy an EMS request), the EV may override the request and discharge up
+   * to underExcitedMaximumDischargePower to meet the minimum reactive power requirements.
+   * This corresponds to the WUnPF attribute in the IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVUnderExcitedMaximumDischargePower
+   * 
+ */ + @Nullable private Double evUnderExcitedMaxDischargePower; + + /** + * EV power factor when injecting (under excited) the minimum reactive power. + * + *
+   * Corresponds to the OvPF attribute in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVUnderExcitedPowerFactor
+   * 
+ */ + @Nullable private Double evUnderExcitedPowerFactor; + + /** + * Rated maximum total apparent power, defined by min(EV, EVSE) in va. + * + *
+   * Corresponds to the VAMaxRtg in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumApparentPower
+   * 
+ */ + @Nullable private Double maxApparentPower; + + /** + * Rated maximum absorbed apparent power, defined by min(EV, EVSE) in va. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, + * + *

+   * in which case this field represents phase L1.
+   * Corresponds to the ChaVAMaxRtg in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumChargeApparentPower
+   * 
+ */ + @Nullable private Double maxChargeApparentPower; + + /** + * Rated maximum absorbed apparent power on phase L2, defined by min(EV, EVSE) in va. + * + *
+   * Corresponds to the ChaVAMaxRtg in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumChargeApparentPowerL2
+   * 
+ */ + @Nullable private Double maxChargeApparentPower_L2; + + /** + * Rated maximum absorbed apparent power on phase L3, defined by min(EV, EVSE) in va. + * + *
+   * Corresponds to the ChaVAMaxRtg in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumChargeApparentPowerL3
+   * 
+ */ + @Nullable private Double maxChargeApparentPower_L3; + + /** + * Rated maximum injected apparent power, defined by min(EV, EVSE) in va. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, + * + *

+   * in which case this field represents phase L1.
+   * Corresponds to the DisVAMaxRtg in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumDischargeApparentPower
+   * 
+ */ + @Nullable private Double maxDischargeApparentPower; + + /** + * Rated maximum injected apparent power on phase L2, defined by min(EV, EVSE) in va. + * + *
+   * Corresponds to the DisVAMaxRtg in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumDischargeApparentPowerL2
+   * 
+ */ + @Nullable private Double maxDischargeApparentPower_L2; + + /** + * Rated maximum injected apparent power on phase L3, defined by min(EV, EVSE) in va. + * + *
+   * Corresponds to the DisVAMaxRtg in IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumDischargeApparentPowerL3
+   * 
+ */ + @Nullable private Double maxDischargeApparentPower_L3; + + /** + * Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, + * + *

+   * in which case this field represents phase L1.
+   * Corresponds to the AvarMax attribute in the IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumChargeReactivePower
+   * 
+ */ + @Nullable private Double maxChargeReactivePower; + + /** + * Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L2. + * + *
+   * Corresponds to the AvarMax attribute in the IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumChargeReactivePowerL2
+   * 
+ */ + @Nullable private Double maxChargeReactivePower_L2; + + /** + * Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L3. + * + *
+   * Corresponds to the AvarMax attribute in the IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumChargeReactivePowerL3
+   * 
+ */ + @Nullable private Double maxChargeReactivePower_L3; + + /** + * Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, + * + *

+   * in which case this field represents phase L1.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMinimumChargeReactivePower
+   * 
+ */ + @Nullable private Double minChargeReactivePower; + + /** + * Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L2. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMinimumChargeReactivePowerL2 + */ + @Nullable private Double minChargeReactivePower_L2; + + /** + * Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L3. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMinimumChargeReactivePowerL3 + */ + @Nullable private Double minChargeReactivePower_L3; + + /** + * Rated maximum injected reactive power, defined by min(EV, EVSE), in vars. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, + * + *

+   * in which case this field represents phase L1.
+   * Corresponds to the IvarMax attribute in the IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumDischargeReactivePower
+   * 
+ */ + @Nullable private Double maxDischargeReactivePower; + + /** + * Rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L2. + * + *
+   * Corresponds to the IvarMax attribute in the IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumDischargeReactivePowerL2
+   * 
+ */ + @Nullable private Double maxDischargeReactivePower_L2; + + /** + * Rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L3. + * + *
+   * Corresponds to the IvarMax attribute in the IEC 61850.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumDischargeReactivePowerL3
+   * 
+ */ + @Nullable private Double maxDischargeReactivePower_L3; + + /** + * Rated minimum injected reactive power, defined by max(EV, EVSE), in vars. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, + * + *

+   * in which case this field represents phase L1.
+   * *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMinimumDischargeReactivePower
+   * 
+ */ + @Nullable private Double minDischargeReactivePower; + + /** + * Rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L2. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMinimumDischargeReactivePowerL2 + */ + @Nullable private Double minDischargeReactivePower_L2; + + /** + * Rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L3. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMinimumDischargeReactivePowerL3 + */ + @Nullable private Double minDischargeReactivePower_L3; + + /** + * Line voltage supported by EVSE and EV. *ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: + * EVNominalVoltage + */ + @Nullable private Double nominalVoltage; + + /** + * The nominal AC voltage (rms) offset between the Charging Station's electrical connection point + * and the utility’s point of common coupling. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVNominalVoltageOffset + */ + @Nullable private Double nominalVoltageOffset; + + /** + * Maximum AC rms voltage, as defined by min(EV, EVSE) to operate with. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumNominalVoltage + */ + @Nullable private Double maxNominalVoltage; + + /** + * Minimum AC rms voltage, as defined by max(EV, EVSE) to operate with. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMinimumNominalVoltage + */ + @Nullable private Double minNominalVoltage; + + /** + * Manufacturer of the EV inverter. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVInverterManufacturer + */ + @Nullable private String evInverterManufacturer; + + /** + * Model name of the EV inverter. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVInverterModel + */ + @Nullable private String evInverterModel; + + /** + * Serial number of the EV inverter. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVInverterSerialNumber + */ + @Nullable private String evInverterSerialNumber; + + /** + * Software version of EV inverter. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVInverterSwVersion + */ + @Nullable private String evInverterSwVersion; + + /** + * Hardware version of EV inverter. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVInverterHwVersion + */ + @Nullable private String evInverterHwVersion; + + /** + * Type of islanding detection method. Only mandatory when islanding detection is required at the + * site, as set in the ISO 15118 Service Details configuration. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVIslandingDetectionMethod + */ + @Nullable private IslandingDetectionEnum[] evIslandingDetectionMethod; + + /** + * Time after which EV will trip if an island has been detected. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVIslandingTripTime + */ + @Nullable private Double evIslandingTripTime; + + /** + * Maximum injected DC current allowed at level 1 charging. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumLevel1DCInjection + */ + @Nullable private Double evMaximumLevel1DCInjection; + + /** + * Maximum allowed duration of DC injection at level 1 charging. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVDurationLevel1DCInjection + */ + @Nullable private Double evDurationLevel1DCInjection; + + /** + * Maximum injected DC current allowed at level 2 charging. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVMaximumLevel2DCInjection + */ + @Nullable private Double evMaximumLevel2DCInjection; + + /** + * Maximum allowed duration of DC injection at level 2 charging. + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVDurationLevel2DCInjection + */ + @Nullable private Double evDurationLevel2DCInjection; + + /** + * Measure of the susceptibility of the circuit to reactance, in Siemens (S). + * + *

*ISO 15118-20*: DERBPTACCPDReqEnergyTransferModeType: EVReactiveSusceptance + */ + @Nullable private Double evReactiveSusceptance; + + /** + * Total energy value, in Wh, that EV is allowed to provide during the entire V2G session. The + * value is independent of the V2X Cycling area. Once this value reaches the value of 0, the EV + * may block any attempt to discharge in order to protect the battery health. *ISO 15118-20*: + * DERBPTACCPDReqEnergyTransferModeType: EVSessionTotalDischargeEnergyAvailable + */ + @Nullable private Double evSessionTotalDischargeEnergyAvailable; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the DERChargingParameters class */ + public DERChargingParameters() {} + + /** + * Gets DER control functions supported by EV. + * + * @return DER control functions supported by EV + */ + @Nullable + public DERControlEnum[] getEvSupportedDERControl() { + return evSupportedDERControl; + } + + /** + * Sets DER control functions supported by EV. + * + * @param evSupportedDERControl DER control functions supported by EV + */ + public void setEvSupportedDERControl(@Nullable DERControlEnum[] evSupportedDERControl) { + if (!isValidEvSupportedDERControl(evSupportedDERControl)) { + throw new PropertyConstraintException( + evSupportedDERControl, "evSupportedDERControl is invalid"); + } + this.evSupportedDERControl = evSupportedDERControl; + } + + /** + * Returns whether the given evSupportedDERControl is valid + * + * @param evSupportedDERControl the evSupportedDERControl to check the validity of + * @return {@code true} if evSupportedDERControl is valid, {@code false} if not + */ + private boolean isValidEvSupportedDERControl(@Nullable DERControlEnum[] evSupportedDERControl) { + return evSupportedDERControl == null || (evSupportedDERControl.length >= 1); + } + + /** + * Adds DER control functions supported by EV. + * + * @param evSupportedDERControl DER control functions supported by EV + * @return this + */ + public DERChargingParameters withEvSupportedDERControl( + @Nullable DERControlEnum[] evSupportedDERControl) { + setEvSupportedDERControl(evSupportedDERControl); + return this; + } + + /** + * Gets rated maximum injected active power by EV, at specified over-excited power factor + * (overExcitedPowerFactor). + * + * @return Rated maximum injected active power by EV, at specified over-excited power factor + * (overExcitedPowerFactor) + */ + @Nullable + public Double getEvOverExcitedMaxDischargePower() { + return evOverExcitedMaxDischargePower; + } + + /** + * Sets rated maximum injected active power by EV, at specified over-excited power factor + * (overExcitedPowerFactor). + * + * @param evOverExcitedMaxDischargePower Rated maximum injected active power by EV, at specified + * over-excited power factor (overExcitedPowerFactor) + */ + public void setEvOverExcitedMaxDischargePower(@Nullable Double evOverExcitedMaxDischargePower) { + this.evOverExcitedMaxDischargePower = evOverExcitedMaxDischargePower; + } + + /** + * Adds rated maximum injected active power by EV, at specified over-excited power factor + * (overExcitedPowerFactor). + * + * @param evOverExcitedMaxDischargePower Rated maximum injected active power by EV, at specified + * over-excited power factor (overExcitedPowerFactor) + * @return this + */ + public DERChargingParameters withEvOverExcitedMaxDischargePower( + @Nullable Double evOverExcitedMaxDischargePower) { + setEvOverExcitedMaxDischargePower(evOverExcitedMaxDischargePower); + return this; + } + + /** + * Gets EV power factor when injecting (over excited) the minimum reactive power. + * + * @return EV power factor when injecting (over excited) the minimum reactive power + */ + @Nullable + public Double getEvOverExcitedPowerFactor() { + return evOverExcitedPowerFactor; + } + + /** + * Sets EV power factor when injecting (over excited) the minimum reactive power. + * + * @param evOverExcitedPowerFactor EV power factor when injecting (over excited) the minimum + * reactive power + */ + public void setEvOverExcitedPowerFactor(@Nullable Double evOverExcitedPowerFactor) { + this.evOverExcitedPowerFactor = evOverExcitedPowerFactor; + } + + /** + * Adds EV power factor when injecting (over excited) the minimum reactive power. + * + * @param evOverExcitedPowerFactor EV power factor when injecting (over excited) the minimum + * reactive power + * @return this + */ + public DERChargingParameters withEvOverExcitedPowerFactor( + @Nullable Double evOverExcitedPowerFactor) { + setEvOverExcitedPowerFactor(evOverExcitedPowerFactor); + return this; + } + + /** + * Gets rated maximum injected active power by EV supported at specified under-excited power + * factor (EVUnderExcitedPowerFactor). + * + * @return Rated maximum injected active power by EV supported at specified under-excited power + * factor (EVUnderExcitedPowerFactor) + */ + @Nullable + public Double getEvUnderExcitedMaxDischargePower() { + return evUnderExcitedMaxDischargePower; + } + + /** + * Sets rated maximum injected active power by EV supported at specified under-excited power + * factor (EVUnderExcitedPowerFactor). + * + * @param evUnderExcitedMaxDischargePower Rated maximum injected active power by EV supported at + * specified under-excited power factor (EVUnderExcitedPowerFactor) + */ + public void setEvUnderExcitedMaxDischargePower(@Nullable Double evUnderExcitedMaxDischargePower) { + this.evUnderExcitedMaxDischargePower = evUnderExcitedMaxDischargePower; + } + + /** + * Adds rated maximum injected active power by EV supported at specified under-excited power + * factor (EVUnderExcitedPowerFactor). + * + * @param evUnderExcitedMaxDischargePower Rated maximum injected active power by EV supported at + * specified under-excited power factor (EVUnderExcitedPowerFactor) + * @return this + */ + public DERChargingParameters withEvUnderExcitedMaxDischargePower( + @Nullable Double evUnderExcitedMaxDischargePower) { + setEvUnderExcitedMaxDischargePower(evUnderExcitedMaxDischargePower); + return this; + } + + /** + * Gets EV power factor when injecting (under excited) the minimum reactive power. + * + * @return EV power factor when injecting (under excited) the minimum reactive power + */ + @Nullable + public Double getEvUnderExcitedPowerFactor() { + return evUnderExcitedPowerFactor; + } + + /** + * Sets EV power factor when injecting (under excited) the minimum reactive power. + * + * @param evUnderExcitedPowerFactor EV power factor when injecting (under excited) the minimum + * reactive power + */ + public void setEvUnderExcitedPowerFactor(@Nullable Double evUnderExcitedPowerFactor) { + this.evUnderExcitedPowerFactor = evUnderExcitedPowerFactor; + } + + /** + * Adds EV power factor when injecting (under excited) the minimum reactive power. + * + * @param evUnderExcitedPowerFactor EV power factor when injecting (under excited) the minimum + * reactive power + * @return this + */ + public DERChargingParameters withEvUnderExcitedPowerFactor( + @Nullable Double evUnderExcitedPowerFactor) { + setEvUnderExcitedPowerFactor(evUnderExcitedPowerFactor); + return this; + } + + /** + * Gets rated maximum total apparent power, defined by min(EV, EVSE) in va. + * + * @return Rated maximum total apparent power, defined by min(EV, EVSE) in va + */ + @Nullable + public Double getMaxApparentPower() { + return maxApparentPower; + } + + /** + * Sets rated maximum total apparent power, defined by min(EV, EVSE) in va. + * + * @param maxApparentPower Rated maximum total apparent power, defined by min(EV, EVSE) in va + */ + public void setMaxApparentPower(@Nullable Double maxApparentPower) { + this.maxApparentPower = maxApparentPower; + } + + /** + * Adds rated maximum total apparent power, defined by min(EV, EVSE) in va. + * + * @param maxApparentPower Rated maximum total apparent power, defined by min(EV, EVSE) in va + * @return this + */ + public DERChargingParameters withMaxApparentPower(@Nullable Double maxApparentPower) { + setMaxApparentPower(maxApparentPower); + return this; + } + + /** + * Gets rated maximum absorbed apparent power, defined by min(EV, EVSE) in va. + * + * @return Rated maximum absorbed apparent power, defined by min(EV, EVSE) in va + */ + @Nullable + public Double getMaxChargeApparentPower() { + return maxChargeApparentPower; + } + + /** + * Sets rated maximum absorbed apparent power, defined by min(EV, EVSE) in va. + * + * @param maxChargeApparentPower Rated maximum absorbed apparent power, defined by min(EV, EVSE) + * in va + */ + public void setMaxChargeApparentPower(@Nullable Double maxChargeApparentPower) { + this.maxChargeApparentPower = maxChargeApparentPower; + } + + /** + * Adds rated maximum absorbed apparent power, defined by min(EV, EVSE) in va. + * + * @param maxChargeApparentPower Rated maximum absorbed apparent power, defined by min(EV, EVSE) + * in va + * @return this + */ + public DERChargingParameters withMaxChargeApparentPower(@Nullable Double maxChargeApparentPower) { + setMaxChargeApparentPower(maxChargeApparentPower); + return this; + } + + /** + * Gets rated maximum absorbed apparent power on phase L2, defined by min(EV, EVSE) in va. + * + * @return Rated maximum absorbed apparent power on phase L2, defined by min(EV, EVSE) in va + */ + @Nullable + public Double getMaxChargeApparentPower_L2() { + return maxChargeApparentPower_L2; + } + + /** + * Sets rated maximum absorbed apparent power on phase L2, defined by min(EV, EVSE) in va. + * + * @param maxChargeApparentPower_L2 Rated maximum absorbed apparent power on phase L2, defined by + * min(EV, EVSE) in va + */ + public void setMaxChargeApparentPower_L2(@Nullable Double maxChargeApparentPower_L2) { + this.maxChargeApparentPower_L2 = maxChargeApparentPower_L2; + } + + /** + * Adds rated maximum absorbed apparent power on phase L2, defined by min(EV, EVSE) in va. + * + * @param maxChargeApparentPower_L2 Rated maximum absorbed apparent power on phase L2, defined by + * min(EV, EVSE) in va + * @return this + */ + public DERChargingParameters withMaxChargeApparentPower_L2( + @Nullable Double maxChargeApparentPower_L2) { + setMaxChargeApparentPower_L2(maxChargeApparentPower_L2); + return this; + } + + /** + * Gets rated maximum absorbed apparent power on phase L3, defined by min(EV, EVSE) in va. + * + * @return Rated maximum absorbed apparent power on phase L3, defined by min(EV, EVSE) in va + */ + @Nullable + public Double getMaxChargeApparentPower_L3() { + return maxChargeApparentPower_L3; + } + + /** + * Sets rated maximum absorbed apparent power on phase L3, defined by min(EV, EVSE) in va. + * + * @param maxChargeApparentPower_L3 Rated maximum absorbed apparent power on phase L3, defined by + * min(EV, EVSE) in va + */ + public void setMaxChargeApparentPower_L3(@Nullable Double maxChargeApparentPower_L3) { + this.maxChargeApparentPower_L3 = maxChargeApparentPower_L3; + } + + /** + * Adds rated maximum absorbed apparent power on phase L3, defined by min(EV, EVSE) in va. + * + * @param maxChargeApparentPower_L3 Rated maximum absorbed apparent power on phase L3, defined by + * min(EV, EVSE) in va + * @return this + */ + public DERChargingParameters withMaxChargeApparentPower_L3( + @Nullable Double maxChargeApparentPower_L3) { + setMaxChargeApparentPower_L3(maxChargeApparentPower_L3); + return this; + } + + /** + * Gets rated maximum injected apparent power, defined by min(EV, EVSE) in va. + * + * @return Rated maximum injected apparent power, defined by min(EV, EVSE) in va + */ + @Nullable + public Double getMaxDischargeApparentPower() { + return maxDischargeApparentPower; + } + + /** + * Sets rated maximum injected apparent power, defined by min(EV, EVSE) in va. + * + * @param maxDischargeApparentPower Rated maximum injected apparent power, defined by min(EV, + * EVSE) in va + */ + public void setMaxDischargeApparentPower(@Nullable Double maxDischargeApparentPower) { + this.maxDischargeApparentPower = maxDischargeApparentPower; + } + + /** + * Adds rated maximum injected apparent power, defined by min(EV, EVSE) in va. + * + * @param maxDischargeApparentPower Rated maximum injected apparent power, defined by min(EV, + * EVSE) in va + * @return this + */ + public DERChargingParameters withMaxDischargeApparentPower( + @Nullable Double maxDischargeApparentPower) { + setMaxDischargeApparentPower(maxDischargeApparentPower); + return this; + } + + /** + * Gets rated maximum injected apparent power on phase L2, defined by min(EV, EVSE) in va. + * + * @return Rated maximum injected apparent power on phase L2, defined by min(EV, EVSE) in va + */ + @Nullable + public Double getMaxDischargeApparentPower_L2() { + return maxDischargeApparentPower_L2; + } + + /** + * Sets rated maximum injected apparent power on phase L2, defined by min(EV, EVSE) in va. + * + * @param maxDischargeApparentPower_L2 Rated maximum injected apparent power on phase L2, defined + * by min(EV, EVSE) in va + */ + public void setMaxDischargeApparentPower_L2(@Nullable Double maxDischargeApparentPower_L2) { + this.maxDischargeApparentPower_L2 = maxDischargeApparentPower_L2; + } + + /** + * Adds rated maximum injected apparent power on phase L2, defined by min(EV, EVSE) in va. + * + * @param maxDischargeApparentPower_L2 Rated maximum injected apparent power on phase L2, defined + * by min(EV, EVSE) in va + * @return this + */ + public DERChargingParameters withMaxDischargeApparentPower_L2( + @Nullable Double maxDischargeApparentPower_L2) { + setMaxDischargeApparentPower_L2(maxDischargeApparentPower_L2); + return this; + } + + /** + * Gets rated maximum injected apparent power on phase L3, defined by min(EV, EVSE) in va. + * + * @return Rated maximum injected apparent power on phase L3, defined by min(EV, EVSE) in va + */ + @Nullable + public Double getMaxDischargeApparentPower_L3() { + return maxDischargeApparentPower_L3; + } + + /** + * Sets rated maximum injected apparent power on phase L3, defined by min(EV, EVSE) in va. + * + * @param maxDischargeApparentPower_L3 Rated maximum injected apparent power on phase L3, defined + * by min(EV, EVSE) in va + */ + public void setMaxDischargeApparentPower_L3(@Nullable Double maxDischargeApparentPower_L3) { + this.maxDischargeApparentPower_L3 = maxDischargeApparentPower_L3; + } + + /** + * Adds rated maximum injected apparent power on phase L3, defined by min(EV, EVSE) in va. + * + * @param maxDischargeApparentPower_L3 Rated maximum injected apparent power on phase L3, defined + * by min(EV, EVSE) in va + * @return this + */ + public DERChargingParameters withMaxDischargeApparentPower_L3( + @Nullable Double maxDischargeApparentPower_L3) { + setMaxDischargeApparentPower_L3(maxDischargeApparentPower_L3); + return this; + } + + /** + * Gets rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars. + * + * @return Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars + */ + @Nullable + public Double getMaxChargeReactivePower() { + return maxChargeReactivePower; + } + + /** + * Sets rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars. + * + * @param maxChargeReactivePower Rated maximum absorbed reactive power, defined by min(EV, EVSE), + * in vars + */ + public void setMaxChargeReactivePower(@Nullable Double maxChargeReactivePower) { + this.maxChargeReactivePower = maxChargeReactivePower; + } + + /** + * Adds rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars. + * + * @param maxChargeReactivePower Rated maximum absorbed reactive power, defined by min(EV, EVSE), + * in vars + * @return this + */ + public DERChargingParameters withMaxChargeReactivePower(@Nullable Double maxChargeReactivePower) { + setMaxChargeReactivePower(maxChargeReactivePower); + return this; + } + + /** + * Gets rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L2. + * + * @return Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L2 + */ + @Nullable + public Double getMaxChargeReactivePower_L2() { + return maxChargeReactivePower_L2; + } + + /** + * Sets rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L2. + * + * @param maxChargeReactivePower_L2 Rated maximum absorbed reactive power, defined by min(EV, + * EVSE), in vars on phase L2 + */ + public void setMaxChargeReactivePower_L2(@Nullable Double maxChargeReactivePower_L2) { + this.maxChargeReactivePower_L2 = maxChargeReactivePower_L2; + } + + /** + * Adds rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L2. + * + * @param maxChargeReactivePower_L2 Rated maximum absorbed reactive power, defined by min(EV, + * EVSE), in vars on phase L2 + * @return this + */ + public DERChargingParameters withMaxChargeReactivePower_L2( + @Nullable Double maxChargeReactivePower_L2) { + setMaxChargeReactivePower_L2(maxChargeReactivePower_L2); + return this; + } + + /** + * Gets rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L3. + * + * @return Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L3 + */ + @Nullable + public Double getMaxChargeReactivePower_L3() { + return maxChargeReactivePower_L3; + } + + /** + * Sets rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L3. + * + * @param maxChargeReactivePower_L3 Rated maximum absorbed reactive power, defined by min(EV, + * EVSE), in vars on phase L3 + */ + public void setMaxChargeReactivePower_L3(@Nullable Double maxChargeReactivePower_L3) { + this.maxChargeReactivePower_L3 = maxChargeReactivePower_L3; + } + + /** + * Adds rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L3. + * + * @param maxChargeReactivePower_L3 Rated maximum absorbed reactive power, defined by min(EV, + * EVSE), in vars on phase L3 + * @return this + */ + public DERChargingParameters withMaxChargeReactivePower_L3( + @Nullable Double maxChargeReactivePower_L3) { + setMaxChargeReactivePower_L3(maxChargeReactivePower_L3); + return this; + } + + /** + * Gets rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars. + * + * @return Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars + */ + @Nullable + public Double getMinChargeReactivePower() { + return minChargeReactivePower; + } + + /** + * Sets rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars. + * + * @param minChargeReactivePower Rated minimum absorbed reactive power, defined by max(EV, EVSE), + * in vars + */ + public void setMinChargeReactivePower(@Nullable Double minChargeReactivePower) { + this.minChargeReactivePower = minChargeReactivePower; + } + + /** + * Adds rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars. + * + * @param minChargeReactivePower Rated minimum absorbed reactive power, defined by max(EV, EVSE), + * in vars + * @return this + */ + public DERChargingParameters withMinChargeReactivePower(@Nullable Double minChargeReactivePower) { + setMinChargeReactivePower(minChargeReactivePower); + return this; + } + + /** + * Gets rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L2. + * + * @return Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L2 + */ + @Nullable + public Double getMinChargeReactivePower_L2() { + return minChargeReactivePower_L2; + } + + /** + * Sets rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L2. + * + * @param minChargeReactivePower_L2 Rated minimum absorbed reactive power, defined by max(EV, + * EVSE), in vars on phase L2 + */ + public void setMinChargeReactivePower_L2(@Nullable Double minChargeReactivePower_L2) { + this.minChargeReactivePower_L2 = minChargeReactivePower_L2; + } + + /** + * Adds rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L2. + * + * @param minChargeReactivePower_L2 Rated minimum absorbed reactive power, defined by max(EV, + * EVSE), in vars on phase L2 + * @return this + */ + public DERChargingParameters withMinChargeReactivePower_L2( + @Nullable Double minChargeReactivePower_L2) { + setMinChargeReactivePower_L2(minChargeReactivePower_L2); + return this; + } + + /** + * Gets rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L3. + * + * @return Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L3 + */ + @Nullable + public Double getMinChargeReactivePower_L3() { + return minChargeReactivePower_L3; + } + + /** + * Sets rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L3. + * + * @param minChargeReactivePower_L3 Rated minimum absorbed reactive power, defined by max(EV, + * EVSE), in vars on phase L3 + */ + public void setMinChargeReactivePower_L3(@Nullable Double minChargeReactivePower_L3) { + this.minChargeReactivePower_L3 = minChargeReactivePower_L3; + } + + /** + * Adds rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L3. + * + * @param minChargeReactivePower_L3 Rated minimum absorbed reactive power, defined by max(EV, + * EVSE), in vars on phase L3 + * @return this + */ + public DERChargingParameters withMinChargeReactivePower_L3( + @Nullable Double minChargeReactivePower_L3) { + setMinChargeReactivePower_L3(minChargeReactivePower_L3); + return this; + } + + /** + * Gets rated maximum injected reactive power, defined by min(EV, EVSE), in vars. + * + * @return Rated maximum injected reactive power, defined by min(EV, EVSE), in vars + */ + @Nullable + public Double getMaxDischargeReactivePower() { + return maxDischargeReactivePower; + } + + /** + * Sets rated maximum injected reactive power, defined by min(EV, EVSE), in vars. + * + * @param maxDischargeReactivePower Rated maximum injected reactive power, defined by min(EV, + * EVSE), in vars + */ + public void setMaxDischargeReactivePower(@Nullable Double maxDischargeReactivePower) { + this.maxDischargeReactivePower = maxDischargeReactivePower; + } + + /** + * Adds rated maximum injected reactive power, defined by min(EV, EVSE), in vars. + * + * @param maxDischargeReactivePower Rated maximum injected reactive power, defined by min(EV, + * EVSE), in vars + * @return this + */ + public DERChargingParameters withMaxDischargeReactivePower( + @Nullable Double maxDischargeReactivePower) { + setMaxDischargeReactivePower(maxDischargeReactivePower); + return this; + } + + /** + * Gets rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L2. + * + * @return Rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L2 + */ + @Nullable + public Double getMaxDischargeReactivePower_L2() { + return maxDischargeReactivePower_L2; + } + + /** + * Sets rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L2. + * + * @param maxDischargeReactivePower_L2 Rated maximum injected reactive power, defined by min(EV, + * EVSE), in vars on phase L2 + */ + public void setMaxDischargeReactivePower_L2(@Nullable Double maxDischargeReactivePower_L2) { + this.maxDischargeReactivePower_L2 = maxDischargeReactivePower_L2; + } + + /** + * Adds rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L2. + * + * @param maxDischargeReactivePower_L2 Rated maximum injected reactive power, defined by min(EV, + * EVSE), in vars on phase L2 + * @return this + */ + public DERChargingParameters withMaxDischargeReactivePower_L2( + @Nullable Double maxDischargeReactivePower_L2) { + setMaxDischargeReactivePower_L2(maxDischargeReactivePower_L2); + return this; + } + + /** + * Gets rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L3. + * + * @return Rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L3 + */ + @Nullable + public Double getMaxDischargeReactivePower_L3() { + return maxDischargeReactivePower_L3; + } + + /** + * Sets rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L3. + * + * @param maxDischargeReactivePower_L3 Rated maximum injected reactive power, defined by min(EV, + * EVSE), in vars on phase L3 + */ + public void setMaxDischargeReactivePower_L3(@Nullable Double maxDischargeReactivePower_L3) { + this.maxDischargeReactivePower_L3 = maxDischargeReactivePower_L3; + } + + /** + * Adds rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L3. + * + * @param maxDischargeReactivePower_L3 Rated maximum injected reactive power, defined by min(EV, + * EVSE), in vars on phase L3 + * @return this + */ + public DERChargingParameters withMaxDischargeReactivePower_L3( + @Nullable Double maxDischargeReactivePower_L3) { + setMaxDischargeReactivePower_L3(maxDischargeReactivePower_L3); + return this; + } + + /** + * Gets rated minimum injected reactive power, defined by max(EV, EVSE), in vars. + * + * @return Rated minimum injected reactive power, defined by max(EV, EVSE), in vars + */ + @Nullable + public Double getMinDischargeReactivePower() { + return minDischargeReactivePower; + } + + /** + * Sets rated minimum injected reactive power, defined by max(EV, EVSE), in vars. + * + * @param minDischargeReactivePower Rated minimum injected reactive power, defined by max(EV, + * EVSE), in vars + */ + public void setMinDischargeReactivePower(@Nullable Double minDischargeReactivePower) { + this.minDischargeReactivePower = minDischargeReactivePower; + } + + /** + * Adds rated minimum injected reactive power, defined by max(EV, EVSE), in vars. + * + * @param minDischargeReactivePower Rated minimum injected reactive power, defined by max(EV, + * EVSE), in vars + * @return this + */ + public DERChargingParameters withMinDischargeReactivePower( + @Nullable Double minDischargeReactivePower) { + setMinDischargeReactivePower(minDischargeReactivePower); + return this; + } + + /** + * Gets rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L2. + * + * @return Rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L2 + */ + @Nullable + public Double getMinDischargeReactivePower_L2() { + return minDischargeReactivePower_L2; + } + + /** + * Sets rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L2. + * + * @param minDischargeReactivePower_L2 Rated minimum injected reactive power, defined by max(EV, + * EVSE), in var on phase L2 + */ + public void setMinDischargeReactivePower_L2(@Nullable Double minDischargeReactivePower_L2) { + this.minDischargeReactivePower_L2 = minDischargeReactivePower_L2; + } + + /** + * Adds rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L2. + * + * @param minDischargeReactivePower_L2 Rated minimum injected reactive power, defined by max(EV, + * EVSE), in var on phase L2 + * @return this + */ + public DERChargingParameters withMinDischargeReactivePower_L2( + @Nullable Double minDischargeReactivePower_L2) { + setMinDischargeReactivePower_L2(minDischargeReactivePower_L2); + return this; + } + + /** + * Gets rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L3. + * + * @return Rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L3 + */ + @Nullable + public Double getMinDischargeReactivePower_L3() { + return minDischargeReactivePower_L3; + } + + /** + * Sets rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L3. + * + * @param minDischargeReactivePower_L3 Rated minimum injected reactive power, defined by max(EV, + * EVSE), in var on phase L3 + */ + public void setMinDischargeReactivePower_L3(@Nullable Double minDischargeReactivePower_L3) { + this.minDischargeReactivePower_L3 = minDischargeReactivePower_L3; + } + + /** + * Adds rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L3. + * + * @param minDischargeReactivePower_L3 Rated minimum injected reactive power, defined by max(EV, + * EVSE), in var on phase L3 + * @return this + */ + public DERChargingParameters withMinDischargeReactivePower_L3( + @Nullable Double minDischargeReactivePower_L3) { + setMinDischargeReactivePower_L3(minDischargeReactivePower_L3); + return this; + } + + /** + * Gets line voltage supported by EVSE and EV. *ISO 15118-20*: + * DERBPTACCPDReqEnergyTransferModeType: EVNominalVoltage + * + * @return Line voltage supported by EVSE and EV + */ + @Nullable + public Double getNominalVoltage() { + return nominalVoltage; + } + + /** + * Sets line voltage supported by EVSE and EV. *ISO 15118-20*: + * DERBPTACCPDReqEnergyTransferModeType: EVNominalVoltage + * + * @param nominalVoltage Line voltage supported by EVSE and EV + */ + public void setNominalVoltage(@Nullable Double nominalVoltage) { + this.nominalVoltage = nominalVoltage; + } + + /** + * Adds line voltage supported by EVSE and EV. *ISO 15118-20*: + * DERBPTACCPDReqEnergyTransferModeType: EVNominalVoltage + * + * @param nominalVoltage Line voltage supported by EVSE and EV + * @return this + */ + public DERChargingParameters withNominalVoltage(@Nullable Double nominalVoltage) { + setNominalVoltage(nominalVoltage); + return this; + } + + /** + * Gets the nominal AC voltage (rms) offset between the Charging Station's electrical connection + * point and the utility’s point of common coupling. + * + * @return The nominal AC voltage (rms) offset between the Charging Station's electrical + * connection point and the utility’s point of common coupling + */ + @Nullable + public Double getNominalVoltageOffset() { + return nominalVoltageOffset; + } + + /** + * Sets the nominal AC voltage (rms) offset between the Charging Station's electrical connection + * point and the utility’s point of common coupling. + * + * @param nominalVoltageOffset The nominal AC voltage (rms) offset between the Charging Station's + * electrical connection point and the utility’s point of common coupling + */ + public void setNominalVoltageOffset(@Nullable Double nominalVoltageOffset) { + this.nominalVoltageOffset = nominalVoltageOffset; + } + + /** + * Adds the nominal AC voltage (rms) offset between the Charging Station's electrical connection + * point and the utility’s point of common coupling. + * + * @param nominalVoltageOffset The nominal AC voltage (rms) offset between the Charging Station's + * electrical connection point and the utility’s point of common coupling + * @return this + */ + public DERChargingParameters withNominalVoltageOffset(@Nullable Double nominalVoltageOffset) { + setNominalVoltageOffset(nominalVoltageOffset); + return this; + } + + /** + * Gets maximum AC rms voltage, as defined by min(EV, EVSE) to operate with. + * + * @return Maximum AC rms voltage, as defined by min(EV, EVSE) to operate with + */ + @Nullable + public Double getMaxNominalVoltage() { + return maxNominalVoltage; + } + + /** + * Sets maximum AC rms voltage, as defined by min(EV, EVSE) to operate with. + * + * @param maxNominalVoltage Maximum AC rms voltage, as defined by min(EV, EVSE) to operate with + */ + public void setMaxNominalVoltage(@Nullable Double maxNominalVoltage) { + this.maxNominalVoltage = maxNominalVoltage; + } + + /** + * Adds maximum AC rms voltage, as defined by min(EV, EVSE) to operate with. + * + * @param maxNominalVoltage Maximum AC rms voltage, as defined by min(EV, EVSE) to operate with + * @return this + */ + public DERChargingParameters withMaxNominalVoltage(@Nullable Double maxNominalVoltage) { + setMaxNominalVoltage(maxNominalVoltage); + return this; + } + + /** + * Gets minimum AC rms voltage, as defined by max(EV, EVSE) to operate with. + * + * @return Minimum AC rms voltage, as defined by max(EV, EVSE) to operate with + */ + @Nullable + public Double getMinNominalVoltage() { + return minNominalVoltage; + } + + /** + * Sets minimum AC rms voltage, as defined by max(EV, EVSE) to operate with. + * + * @param minNominalVoltage Minimum AC rms voltage, as defined by max(EV, EVSE) to operate with + */ + public void setMinNominalVoltage(@Nullable Double minNominalVoltage) { + this.minNominalVoltage = minNominalVoltage; + } + + /** + * Adds minimum AC rms voltage, as defined by max(EV, EVSE) to operate with. + * + * @param minNominalVoltage Minimum AC rms voltage, as defined by max(EV, EVSE) to operate with + * @return this + */ + public DERChargingParameters withMinNominalVoltage(@Nullable Double minNominalVoltage) { + setMinNominalVoltage(minNominalVoltage); + return this; + } + + /** + * Gets manufacturer of the EV inverter. + * + * @return Manufacturer of the EV inverter + */ + @Nullable + public String getEvInverterManufacturer() { + return evInverterManufacturer; + } + + /** + * Sets manufacturer of the EV inverter. + * + * @param evInverterManufacturer Manufacturer of the EV inverter + */ + public void setEvInverterManufacturer(@Nullable String evInverterManufacturer) { + if (!isValidEvInverterManufacturer(evInverterManufacturer)) { + throw new PropertyConstraintException( + evInverterManufacturer, "evInverterManufacturer is invalid"); + } + this.evInverterManufacturer = evInverterManufacturer; + } + + /** + * Returns whether the given evInverterManufacturer is valid + * + * @param evInverterManufacturer the evInverterManufacturer to check the validity of + * @return {@code true} if evInverterManufacturer is valid, {@code false} if not + */ + private boolean isValidEvInverterManufacturer(@Nullable String evInverterManufacturer) { + return evInverterManufacturer == null || evInverterManufacturer.length() <= 50; + } + + /** + * Adds manufacturer of the EV inverter. + * + * @param evInverterManufacturer Manufacturer of the EV inverter + * @return this + */ + public DERChargingParameters withEvInverterManufacturer(@Nullable String evInverterManufacturer) { + setEvInverterManufacturer(evInverterManufacturer); + return this; + } + + /** + * Gets model name of the EV inverter. + * + * @return Model name of the EV inverter + */ + @Nullable + public String getEvInverterModel() { + return evInverterModel; + } + + /** + * Sets model name of the EV inverter. + * + * @param evInverterModel Model name of the EV inverter + */ + public void setEvInverterModel(@Nullable String evInverterModel) { + if (!isValidEvInverterModel(evInverterModel)) { + throw new PropertyConstraintException(evInverterModel, "evInverterModel is invalid"); + } + this.evInverterModel = evInverterModel; + } + + /** + * Returns whether the given evInverterModel is valid + * + * @param evInverterModel the evInverterModel to check the validity of + * @return {@code true} if evInverterModel is valid, {@code false} if not + */ + private boolean isValidEvInverterModel(@Nullable String evInverterModel) { + return evInverterModel == null || evInverterModel.length() <= 50; + } + + /** + * Adds model name of the EV inverter. + * + * @param evInverterModel Model name of the EV inverter + * @return this + */ + public DERChargingParameters withEvInverterModel(@Nullable String evInverterModel) { + setEvInverterModel(evInverterModel); + return this; + } + + /** + * Gets serial number of the EV inverter. + * + * @return Serial number of the EV inverter + */ + @Nullable + public String getEvInverterSerialNumber() { + return evInverterSerialNumber; + } + + /** + * Sets serial number of the EV inverter. + * + * @param evInverterSerialNumber Serial number of the EV inverter + */ + public void setEvInverterSerialNumber(@Nullable String evInverterSerialNumber) { + if (!isValidEvInverterSerialNumber(evInverterSerialNumber)) { + throw new PropertyConstraintException( + evInverterSerialNumber, "evInverterSerialNumber is invalid"); + } + this.evInverterSerialNumber = evInverterSerialNumber; + } + + /** + * Returns whether the given evInverterSerialNumber is valid + * + * @param evInverterSerialNumber the evInverterSerialNumber to check the validity of + * @return {@code true} if evInverterSerialNumber is valid, {@code false} if not + */ + private boolean isValidEvInverterSerialNumber(@Nullable String evInverterSerialNumber) { + return evInverterSerialNumber == null || evInverterSerialNumber.length() <= 50; + } + + /** + * Adds serial number of the EV inverter. + * + * @param evInverterSerialNumber Serial number of the EV inverter + * @return this + */ + public DERChargingParameters withEvInverterSerialNumber(@Nullable String evInverterSerialNumber) { + setEvInverterSerialNumber(evInverterSerialNumber); + return this; + } + + /** + * Gets software version of EV inverter. + * + * @return Software version of EV inverter + */ + @Nullable + public String getEvInverterSwVersion() { + return evInverterSwVersion; + } + + /** + * Sets software version of EV inverter. + * + * @param evInverterSwVersion Software version of EV inverter + */ + public void setEvInverterSwVersion(@Nullable String evInverterSwVersion) { + if (!isValidEvInverterSwVersion(evInverterSwVersion)) { + throw new PropertyConstraintException(evInverterSwVersion, "evInverterSwVersion is invalid"); + } + this.evInverterSwVersion = evInverterSwVersion; + } + + /** + * Returns whether the given evInverterSwVersion is valid + * + * @param evInverterSwVersion the evInverterSwVersion to check the validity of + * @return {@code true} if evInverterSwVersion is valid, {@code false} if not + */ + private boolean isValidEvInverterSwVersion(@Nullable String evInverterSwVersion) { + return evInverterSwVersion == null || evInverterSwVersion.length() <= 50; + } + + /** + * Adds software version of EV inverter. + * + * @param evInverterSwVersion Software version of EV inverter + * @return this + */ + public DERChargingParameters withEvInverterSwVersion(@Nullable String evInverterSwVersion) { + setEvInverterSwVersion(evInverterSwVersion); + return this; + } + + /** + * Gets hardware version of EV inverter. + * + * @return Hardware version of EV inverter + */ + @Nullable + public String getEvInverterHwVersion() { + return evInverterHwVersion; + } + + /** + * Sets hardware version of EV inverter. + * + * @param evInverterHwVersion Hardware version of EV inverter + */ + public void setEvInverterHwVersion(@Nullable String evInverterHwVersion) { + if (!isValidEvInverterHwVersion(evInverterHwVersion)) { + throw new PropertyConstraintException(evInverterHwVersion, "evInverterHwVersion is invalid"); + } + this.evInverterHwVersion = evInverterHwVersion; + } + + /** + * Returns whether the given evInverterHwVersion is valid + * + * @param evInverterHwVersion the evInverterHwVersion to check the validity of + * @return {@code true} if evInverterHwVersion is valid, {@code false} if not + */ + private boolean isValidEvInverterHwVersion(@Nullable String evInverterHwVersion) { + return evInverterHwVersion == null || evInverterHwVersion.length() <= 50; + } + + /** + * Adds hardware version of EV inverter. + * + * @param evInverterHwVersion Hardware version of EV inverter + * @return this + */ + public DERChargingParameters withEvInverterHwVersion(@Nullable String evInverterHwVersion) { + setEvInverterHwVersion(evInverterHwVersion); + return this; + } + + /** + * Gets type of islanding detection method. Only mandatory when islanding detection is required at + * the site, as set in the ISO 15118 Service Details configuration. + * + * @return Type of islanding detection method + */ + @Nullable + public IslandingDetectionEnum[] getEvIslandingDetectionMethod() { + return evIslandingDetectionMethod; + } + + /** + * Sets type of islanding detection method. Only mandatory when islanding detection is required at + * the site, as set in the ISO 15118 Service Details configuration. + * + * @param evIslandingDetectionMethod Type of islanding detection method + */ + public void setEvIslandingDetectionMethod( + @Nullable IslandingDetectionEnum[] evIslandingDetectionMethod) { + if (!isValidEvIslandingDetectionMethod(evIslandingDetectionMethod)) { + throw new PropertyConstraintException( + evIslandingDetectionMethod, "evIslandingDetectionMethod is invalid"); + } + this.evIslandingDetectionMethod = evIslandingDetectionMethod; + } + + /** + * Returns whether the given evIslandingDetectionMethod is valid + * + * @param evIslandingDetectionMethod the evIslandingDetectionMethod to check the validity of + * @return {@code true} if evIslandingDetectionMethod is valid, {@code false} if not + */ + private boolean isValidEvIslandingDetectionMethod( + @Nullable IslandingDetectionEnum[] evIslandingDetectionMethod) { + return evIslandingDetectionMethod == null || (evIslandingDetectionMethod.length >= 1); + } + + /** + * Adds type of islanding detection method. Only mandatory when islanding detection is required at + * the site, as set in the ISO 15118 Service Details configuration. + * + * @param evIslandingDetectionMethod Type of islanding detection method + * @return this + */ + public DERChargingParameters withEvIslandingDetectionMethod( + @Nullable IslandingDetectionEnum[] evIslandingDetectionMethod) { + setEvIslandingDetectionMethod(evIslandingDetectionMethod); + return this; + } + + /** + * Gets time after which EV will trip if an island has been detected. + * + * @return Time after which EV will trip if an island has been detected + */ + @Nullable + public Double getEvIslandingTripTime() { + return evIslandingTripTime; + } + + /** + * Sets time after which EV will trip if an island has been detected. + * + * @param evIslandingTripTime Time after which EV will trip if an island has been detected + */ + public void setEvIslandingTripTime(@Nullable Double evIslandingTripTime) { + this.evIslandingTripTime = evIslandingTripTime; + } + + /** + * Adds time after which EV will trip if an island has been detected. + * + * @param evIslandingTripTime Time after which EV will trip if an island has been detected + * @return this + */ + public DERChargingParameters withEvIslandingTripTime(@Nullable Double evIslandingTripTime) { + setEvIslandingTripTime(evIslandingTripTime); + return this; + } + + /** + * Gets maximum injected DC current allowed at level 1 charging. + * + * @return Maximum injected DC current allowed at level 1 charging + */ + @Nullable + public Double getEvMaximumLevel1DCInjection() { + return evMaximumLevel1DCInjection; + } + + /** + * Sets maximum injected DC current allowed at level 1 charging. + * + * @param evMaximumLevel1DCInjection Maximum injected DC current allowed at level 1 charging + */ + public void setEvMaximumLevel1DCInjection(@Nullable Double evMaximumLevel1DCInjection) { + this.evMaximumLevel1DCInjection = evMaximumLevel1DCInjection; + } + + /** + * Adds maximum injected DC current allowed at level 1 charging. + * + * @param evMaximumLevel1DCInjection Maximum injected DC current allowed at level 1 charging + * @return this + */ + public DERChargingParameters withEvMaximumLevel1DCInjection( + @Nullable Double evMaximumLevel1DCInjection) { + setEvMaximumLevel1DCInjection(evMaximumLevel1DCInjection); + return this; + } + + /** + * Gets maximum allowed duration of DC injection at level 1 charging. + * + * @return Maximum allowed duration of DC injection at level 1 charging + */ + @Nullable + public Double getEvDurationLevel1DCInjection() { + return evDurationLevel1DCInjection; + } + + /** + * Sets maximum allowed duration of DC injection at level 1 charging. + * + * @param evDurationLevel1DCInjection Maximum allowed duration of DC injection at level 1 charging + */ + public void setEvDurationLevel1DCInjection(@Nullable Double evDurationLevel1DCInjection) { + this.evDurationLevel1DCInjection = evDurationLevel1DCInjection; + } + + /** + * Adds maximum allowed duration of DC injection at level 1 charging. + * + * @param evDurationLevel1DCInjection Maximum allowed duration of DC injection at level 1 charging + * @return this + */ + public DERChargingParameters withEvDurationLevel1DCInjection( + @Nullable Double evDurationLevel1DCInjection) { + setEvDurationLevel1DCInjection(evDurationLevel1DCInjection); + return this; + } + + /** + * Gets maximum injected DC current allowed at level 2 charging. + * + * @return Maximum injected DC current allowed at level 2 charging + */ + @Nullable + public Double getEvMaximumLevel2DCInjection() { + return evMaximumLevel2DCInjection; + } + + /** + * Sets maximum injected DC current allowed at level 2 charging. + * + * @param evMaximumLevel2DCInjection Maximum injected DC current allowed at level 2 charging + */ + public void setEvMaximumLevel2DCInjection(@Nullable Double evMaximumLevel2DCInjection) { + this.evMaximumLevel2DCInjection = evMaximumLevel2DCInjection; + } + + /** + * Adds maximum injected DC current allowed at level 2 charging. + * + * @param evMaximumLevel2DCInjection Maximum injected DC current allowed at level 2 charging + * @return this + */ + public DERChargingParameters withEvMaximumLevel2DCInjection( + @Nullable Double evMaximumLevel2DCInjection) { + setEvMaximumLevel2DCInjection(evMaximumLevel2DCInjection); + return this; + } + + /** + * Gets maximum allowed duration of DC injection at level 2 charging. + * + * @return Maximum allowed duration of DC injection at level 2 charging + */ + @Nullable + public Double getEvDurationLevel2DCInjection() { + return evDurationLevel2DCInjection; + } + + /** + * Sets maximum allowed duration of DC injection at level 2 charging. + * + * @param evDurationLevel2DCInjection Maximum allowed duration of DC injection at level 2 charging + */ + public void setEvDurationLevel2DCInjection(@Nullable Double evDurationLevel2DCInjection) { + this.evDurationLevel2DCInjection = evDurationLevel2DCInjection; + } + + /** + * Adds maximum allowed duration of DC injection at level 2 charging. + * + * @param evDurationLevel2DCInjection Maximum allowed duration of DC injection at level 2 charging + * @return this + */ + public DERChargingParameters withEvDurationLevel2DCInjection( + @Nullable Double evDurationLevel2DCInjection) { + setEvDurationLevel2DCInjection(evDurationLevel2DCInjection); + return this; + } + + /** + * Gets measure of the susceptibility of the circuit to reactance, in Siemens (S). + * + * @return Measure of the susceptibility of the circuit to reactance, in Siemens (S) + */ + @Nullable + public Double getEvReactiveSusceptance() { + return evReactiveSusceptance; + } + + /** + * Sets measure of the susceptibility of the circuit to reactance, in Siemens (S). + * + * @param evReactiveSusceptance Measure of the susceptibility of the circuit to reactance, in + * Siemens (S) + */ + public void setEvReactiveSusceptance(@Nullable Double evReactiveSusceptance) { + this.evReactiveSusceptance = evReactiveSusceptance; + } + + /** + * Adds measure of the susceptibility of the circuit to reactance, in Siemens (S). + * + * @param evReactiveSusceptance Measure of the susceptibility of the circuit to reactance, in + * Siemens (S) + * @return this + */ + public DERChargingParameters withEvReactiveSusceptance(@Nullable Double evReactiveSusceptance) { + setEvReactiveSusceptance(evReactiveSusceptance); + return this; + } + + /** + * Gets total energy value, in Wh, that EV is allowed to provide during the entire V2G session. + * The value is independent of the V2X Cycling area. Once this value reaches the value of 0, the + * EV may block any attempt to discharge in order to protect the battery health. *ISO 15118-20*: + * DERBPTACCPDReqEnergyTransferModeType: EVSessionTotalDischargeEnergyAvailable + * + * @return Total energy value, in Wh, that EV is allowed to provide during the entire V2G session + */ + @Nullable + public Double getEvSessionTotalDischargeEnergyAvailable() { + return evSessionTotalDischargeEnergyAvailable; + } + + /** + * Sets total energy value, in Wh, that EV is allowed to provide during the entire V2G session. + * The value is independent of the V2X Cycling area. Once this value reaches the value of 0, the + * EV may block any attempt to discharge in order to protect the battery health. *ISO 15118-20*: + * DERBPTACCPDReqEnergyTransferModeType: EVSessionTotalDischargeEnergyAvailable + * + * @param evSessionTotalDischargeEnergyAvailable Total energy value, in Wh, that EV is allowed to + * provide during the entire V2G session + */ + public void setEvSessionTotalDischargeEnergyAvailable( + @Nullable Double evSessionTotalDischargeEnergyAvailable) { + this.evSessionTotalDischargeEnergyAvailable = evSessionTotalDischargeEnergyAvailable; + } + + /** + * Adds total energy value, in Wh, that EV is allowed to provide during the entire V2G session. + * The value is independent of the V2X Cycling area. Once this value reaches the value of 0, the + * EV may block any attempt to discharge in order to protect the battery health. *ISO 15118-20*: + * DERBPTACCPDReqEnergyTransferModeType: EVSessionTotalDischargeEnergyAvailable + * + * @param evSessionTotalDischargeEnergyAvailable Total energy value, in Wh, that EV is allowed to + * provide during the entire V2G session + * @return this + */ + public DERChargingParameters withEvSessionTotalDischargeEnergyAvailable( + @Nullable Double evSessionTotalDischargeEnergyAvailable) { + setEvSessionTotalDischargeEnergyAvailable(evSessionTotalDischargeEnergyAvailable); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DERChargingParameters withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEvSupportedDERControl(evSupportedDERControl) + && isValidEvInverterManufacturer(evInverterManufacturer) + && isValidEvInverterModel(evInverterModel) + && isValidEvInverterSerialNumber(evInverterSerialNumber) + && isValidEvInverterSwVersion(evInverterSwVersion) + && isValidEvInverterHwVersion(evInverterHwVersion) + && isValidEvIslandingDetectionMethod(evIslandingDetectionMethod) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DERChargingParameters that = (DERChargingParameters) o; + return Arrays.equals(evSupportedDERControl, that.evSupportedDERControl) + && Objects.equals(evOverExcitedMaxDischargePower, that.evOverExcitedMaxDischargePower) + && Objects.equals(evOverExcitedPowerFactor, that.evOverExcitedPowerFactor) + && Objects.equals(evUnderExcitedMaxDischargePower, that.evUnderExcitedMaxDischargePower) + && Objects.equals(evUnderExcitedPowerFactor, that.evUnderExcitedPowerFactor) + && Objects.equals(maxApparentPower, that.maxApparentPower) + && Objects.equals(maxChargeApparentPower, that.maxChargeApparentPower) + && Objects.equals(maxChargeApparentPower_L2, that.maxChargeApparentPower_L2) + && Objects.equals(maxChargeApparentPower_L3, that.maxChargeApparentPower_L3) + && Objects.equals(maxDischargeApparentPower, that.maxDischargeApparentPower) + && Objects.equals(maxDischargeApparentPower_L2, that.maxDischargeApparentPower_L2) + && Objects.equals(maxDischargeApparentPower_L3, that.maxDischargeApparentPower_L3) + && Objects.equals(maxChargeReactivePower, that.maxChargeReactivePower) + && Objects.equals(maxChargeReactivePower_L2, that.maxChargeReactivePower_L2) + && Objects.equals(maxChargeReactivePower_L3, that.maxChargeReactivePower_L3) + && Objects.equals(minChargeReactivePower, that.minChargeReactivePower) + && Objects.equals(minChargeReactivePower_L2, that.minChargeReactivePower_L2) + && Objects.equals(minChargeReactivePower_L3, that.minChargeReactivePower_L3) + && Objects.equals(maxDischargeReactivePower, that.maxDischargeReactivePower) + && Objects.equals(maxDischargeReactivePower_L2, that.maxDischargeReactivePower_L2) + && Objects.equals(maxDischargeReactivePower_L3, that.maxDischargeReactivePower_L3) + && Objects.equals(minDischargeReactivePower, that.minDischargeReactivePower) + && Objects.equals(minDischargeReactivePower_L2, that.minDischargeReactivePower_L2) + && Objects.equals(minDischargeReactivePower_L3, that.minDischargeReactivePower_L3) + && Objects.equals(nominalVoltage, that.nominalVoltage) + && Objects.equals(nominalVoltageOffset, that.nominalVoltageOffset) + && Objects.equals(maxNominalVoltage, that.maxNominalVoltage) + && Objects.equals(minNominalVoltage, that.minNominalVoltage) + && Objects.equals(evInverterManufacturer, that.evInverterManufacturer) + && Objects.equals(evInverterModel, that.evInverterModel) + && Objects.equals(evInverterSerialNumber, that.evInverterSerialNumber) + && Objects.equals(evInverterSwVersion, that.evInverterSwVersion) + && Objects.equals(evInverterHwVersion, that.evInverterHwVersion) + && Arrays.equals(evIslandingDetectionMethod, that.evIslandingDetectionMethod) + && Objects.equals(evIslandingTripTime, that.evIslandingTripTime) + && Objects.equals(evMaximumLevel1DCInjection, that.evMaximumLevel1DCInjection) + && Objects.equals(evDurationLevel1DCInjection, that.evDurationLevel1DCInjection) + && Objects.equals(evMaximumLevel2DCInjection, that.evMaximumLevel2DCInjection) + && Objects.equals(evDurationLevel2DCInjection, that.evDurationLevel2DCInjection) + && Objects.equals(evReactiveSusceptance, that.evReactiveSusceptance) + && Objects.equals( + evSessionTotalDischargeEnergyAvailable, that.evSessionTotalDischargeEnergyAvailable) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(evSupportedDERControl), + evOverExcitedMaxDischargePower, + evOverExcitedPowerFactor, + evUnderExcitedMaxDischargePower, + evUnderExcitedPowerFactor, + maxApparentPower, + maxChargeApparentPower, + maxChargeApparentPower_L2, + maxChargeApparentPower_L3, + maxDischargeApparentPower, + maxDischargeApparentPower_L2, + maxDischargeApparentPower_L3, + maxChargeReactivePower, + maxChargeReactivePower_L2, + maxChargeReactivePower_L3, + minChargeReactivePower, + minChargeReactivePower_L2, + minChargeReactivePower_L3, + maxDischargeReactivePower, + maxDischargeReactivePower_L2, + maxDischargeReactivePower_L3, + minDischargeReactivePower, + minDischargeReactivePower_L2, + minDischargeReactivePower_L3, + nominalVoltage, + nominalVoltageOffset, + maxNominalVoltage, + minNominalVoltage, + evInverterManufacturer, + evInverterModel, + evInverterSerialNumber, + evInverterSwVersion, + evInverterHwVersion, + Arrays.hashCode(evIslandingDetectionMethod), + evIslandingTripTime, + evMaximumLevel1DCInjection, + evDurationLevel1DCInjection, + evMaximumLevel2DCInjection, + evDurationLevel2DCInjection, + evReactiveSusceptance, + evSessionTotalDischargeEnergyAvailable, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evSupportedDERControl", evSupportedDERControl) + .add("evOverExcitedMaxDischargePower", evOverExcitedMaxDischargePower) + .add("evOverExcitedPowerFactor", evOverExcitedPowerFactor) + .add("evUnderExcitedMaxDischargePower", evUnderExcitedMaxDischargePower) + .add("evUnderExcitedPowerFactor", evUnderExcitedPowerFactor) + .add("maxApparentPower", maxApparentPower) + .add("maxChargeApparentPower", maxChargeApparentPower) + .add("maxChargeApparentPower_L2", maxChargeApparentPower_L2) + .add("maxChargeApparentPower_L3", maxChargeApparentPower_L3) + .add("maxDischargeApparentPower", maxDischargeApparentPower) + .add("maxDischargeApparentPower_L2", maxDischargeApparentPower_L2) + .add("maxDischargeApparentPower_L3", maxDischargeApparentPower_L3) + .add("maxChargeReactivePower", maxChargeReactivePower) + .add("maxChargeReactivePower_L2", maxChargeReactivePower_L2) + .add("maxChargeReactivePower_L3", maxChargeReactivePower_L3) + .add("minChargeReactivePower", minChargeReactivePower) + .add("minChargeReactivePower_L2", minChargeReactivePower_L2) + .add("minChargeReactivePower_L3", minChargeReactivePower_L3) + .add("maxDischargeReactivePower", maxDischargeReactivePower) + .add("maxDischargeReactivePower_L2", maxDischargeReactivePower_L2) + .add("maxDischargeReactivePower_L3", maxDischargeReactivePower_L3) + .add("minDischargeReactivePower", minDischargeReactivePower) + .add("minDischargeReactivePower_L2", minDischargeReactivePower_L2) + .add("minDischargeReactivePower_L3", minDischargeReactivePower_L3) + .add("nominalVoltage", nominalVoltage) + .add("nominalVoltageOffset", nominalVoltageOffset) + .add("maxNominalVoltage", maxNominalVoltage) + .add("minNominalVoltage", minNominalVoltage) + .add("evInverterManufacturer", evInverterManufacturer) + .add("evInverterModel", evInverterModel) + .add("evInverterSerialNumber", evInverterSerialNumber) + .add("evInverterSwVersion", evInverterSwVersion) + .add("evInverterHwVersion", evInverterHwVersion) + .add("evIslandingDetectionMethod", evIslandingDetectionMethod) + .add("evIslandingTripTime", evIslandingTripTime) + .add("evMaximumLevel1DCInjection", evMaximumLevel1DCInjection) + .add("evDurationLevel1DCInjection", evDurationLevel1DCInjection) + .add("evMaximumLevel2DCInjection", evMaximumLevel2DCInjection) + .add("evDurationLevel2DCInjection", evDurationLevel2DCInjection) + .add("evReactiveSusceptance", evReactiveSusceptance) + .add("evSessionTotalDischargeEnergyAvailable", evSessionTotalDischargeEnergyAvailable) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERControlEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERControlEnum.java new file mode 100644 index 00000000..0d25dc04 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERControlEnum.java @@ -0,0 +1,51 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of control. Determines which setting field below is used. */ +public enum DERControlEnum { + EnterService, + FreqDroop, + FreqWatt, + FixedPFAbsorb, + FixedPFInject, + FixedVar, + Gradients, + HFMustTrip, + HFMayTrip, + HVMustTrip, + HVMomCess, + HVMayTrip, + LimitMaxDischarge, + LFMustTrip, + LVMustTrip, + LVMomCess, + LVMayTrip, + PowerMonitoringMustTrip, + VoltVar, + VoltWatt, + WattPF, + WattVar +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERControlStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERControlStatusEnum.java new file mode 100644 index 00000000..3675e48b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERControlStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Result of operation. */ +public enum DERControlStatusEnum { + Accepted, + Rejected, + NotSupported, + NotFound +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurve.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurve.java new file mode 100644 index 00000000..8f5b6ae0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurve.java @@ -0,0 +1,512 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** DERCurveType */ +public final class DERCurve { + /** curveData */ + private DERCurvePoints[] curveData; + + /** hysteresis */ + @Nullable private Hysteresis hysteresis; + + /** Priority of curve (0=highest) */ + private Integer priority; + + /** reactivePowerParams */ + @Nullable private ReactivePowerParams reactivePowerParams; + + /** voltageParams */ + @Nullable private VoltageParams voltageParams; + + /** Unit of the Y-axis of DER curve */ + private DERUnitEnum yUnit; + + /** + * Open loop response time, the time to ramp up to 90% of the new target in response to the change + * in voltage, in seconds. A value of 0 is used to mean no limit. When not present, the device + * should follow its default behavior. + */ + @Nullable private Double responseTime; + + /** Point in time when this curve will become activated. Only absent when default is true. */ + @Nullable private ZonedDateTime startTime; + + /** Duration in seconds that this curve will be active. Only absent when default is true. */ + @Nullable private Double duration; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the DERCurve class + * + * @param curveData curveData + * @param priority Priority of curve (0=highest) + * @param yUnit Unit of the Y-axis of DER curve + */ + public DERCurve(DERCurvePoints[] curveData, Integer priority, DERUnitEnum yUnit) { + setCurveData(curveData); + setPriority(priority); + setYUnit(yUnit); + } + + /** + * Gets curveData + * + * @return curveData + */ + public DERCurvePoints[] getCurveData() { + return curveData; + } + + /** + * Sets curveData + * + * @param curveData curveData + */ + public void setCurveData(DERCurvePoints[] curveData) { + if (!isValidCurveData(curveData)) { + throw new PropertyConstraintException(curveData, "curveData is invalid"); + } + this.curveData = curveData; + } + + /** + * Returns whether the given curveData is valid + * + * @param curveData the curveData to check the validity of + * @return {@code true} if curveData is valid, {@code false} if not + */ + private boolean isValidCurveData(DERCurvePoints[] curveData) { + return curveData != null + && curveData.length >= 1 + && curveData.length <= 10 + && Arrays.stream(curveData).allMatch(item -> item.validate()); + } + + /** + * Gets hysteresis + * + * @return hysteresis + */ + @Nullable + public Hysteresis getHysteresis() { + return hysteresis; + } + + /** + * Sets hysteresis + * + * @param hysteresis hysteresis + */ + public void setHysteresis(@Nullable Hysteresis hysteresis) { + if (!isValidHysteresis(hysteresis)) { + throw new PropertyConstraintException(hysteresis, "hysteresis is invalid"); + } + this.hysteresis = hysteresis; + } + + /** + * Returns whether the given hysteresis is valid + * + * @param hysteresis the hysteresis to check the validity of + * @return {@code true} if hysteresis is valid, {@code false} if not + */ + private boolean isValidHysteresis(@Nullable Hysteresis hysteresis) { + return hysteresis == null || hysteresis.validate(); + } + + /** + * Adds hysteresis + * + * @param hysteresis hysteresis + * @return this + */ + public DERCurve withHysteresis(@Nullable Hysteresis hysteresis) { + setHysteresis(hysteresis); + return this; + } + + /** + * Gets priority of curve (0=highest) + * + * @return Priority of curve (0=highest) + */ + public Integer getPriority() { + return priority; + } + + /** + * Sets priority of curve (0=highest) + * + * @param priority Priority of curve (0=highest) + */ + public void setPriority(Integer priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(Integer priority) { + return priority != null && priority >= 0; + } + + /** + * Gets reactivePowerParams + * + * @return reactivePowerParams + */ + @Nullable + public ReactivePowerParams getReactivePowerParams() { + return reactivePowerParams; + } + + /** + * Sets reactivePowerParams + * + * @param reactivePowerParams reactivePowerParams + */ + public void setReactivePowerParams(@Nullable ReactivePowerParams reactivePowerParams) { + if (!isValidReactivePowerParams(reactivePowerParams)) { + throw new PropertyConstraintException(reactivePowerParams, "reactivePowerParams is invalid"); + } + this.reactivePowerParams = reactivePowerParams; + } + + /** + * Returns whether the given reactivePowerParams is valid + * + * @param reactivePowerParams the reactivePowerParams to check the validity of + * @return {@code true} if reactivePowerParams is valid, {@code false} if not + */ + private boolean isValidReactivePowerParams(@Nullable ReactivePowerParams reactivePowerParams) { + return reactivePowerParams == null || reactivePowerParams.validate(); + } + + /** + * Adds reactivePowerParams + * + * @param reactivePowerParams reactivePowerParams + * @return this + */ + public DERCurve withReactivePowerParams(@Nullable ReactivePowerParams reactivePowerParams) { + setReactivePowerParams(reactivePowerParams); + return this; + } + + /** + * Gets voltageParams + * + * @return voltageParams + */ + @Nullable + public VoltageParams getVoltageParams() { + return voltageParams; + } + + /** + * Sets voltageParams + * + * @param voltageParams voltageParams + */ + public void setVoltageParams(@Nullable VoltageParams voltageParams) { + if (!isValidVoltageParams(voltageParams)) { + throw new PropertyConstraintException(voltageParams, "voltageParams is invalid"); + } + this.voltageParams = voltageParams; + } + + /** + * Returns whether the given voltageParams is valid + * + * @param voltageParams the voltageParams to check the validity of + * @return {@code true} if voltageParams is valid, {@code false} if not + */ + private boolean isValidVoltageParams(@Nullable VoltageParams voltageParams) { + return voltageParams == null || voltageParams.validate(); + } + + /** + * Adds voltageParams + * + * @param voltageParams voltageParams + * @return this + */ + public DERCurve withVoltageParams(@Nullable VoltageParams voltageParams) { + setVoltageParams(voltageParams); + return this; + } + + /** + * Gets unit of the Y-axis of DER curve + * + * @return Unit of the Y-axis of DER curve + */ + public DERUnitEnum getYUnit() { + return yUnit; + } + + /** + * Sets unit of the Y-axis of DER curve + * + * @param yUnit Unit of the Y-axis of DER curve + */ + public void setYUnit(DERUnitEnum yUnit) { + if (!isValidYUnit(yUnit)) { + throw new PropertyConstraintException(yUnit, "yUnit is invalid"); + } + this.yUnit = yUnit; + } + + /** + * Returns whether the given yUnit is valid + * + * @param yUnit the yUnit to check the validity of + * @return {@code true} if yUnit is valid, {@code false} if not + */ + private boolean isValidYUnit(DERUnitEnum yUnit) { + return yUnit != null; + } + + /** + * Gets open loop response time, the time to ramp up to 90% of the new target in response to the + * change in voltage, in seconds. A value of 0 is used to mean no limit. When not present, the + * device should follow its default behavior. + * + * @return Open loop response time, the time to ramp up to 90% of the new target in response to + * the change in voltage, in seconds + */ + @Nullable + public Double getResponseTime() { + return responseTime; + } + + /** + * Sets open loop response time, the time to ramp up to 90% of the new target in response to the + * change in voltage, in seconds. A value of 0 is used to mean no limit. When not present, the + * device should follow its default behavior. + * + * @param responseTime Open loop response time, the time to ramp up to 90% of the new target in + * response to the change in voltage, in seconds + */ + public void setResponseTime(@Nullable Double responseTime) { + this.responseTime = responseTime; + } + + /** + * Adds open loop response time, the time to ramp up to 90% of the new target in response to the + * change in voltage, in seconds. A value of 0 is used to mean no limit. When not present, the + * device should follow its default behavior. + * + * @param responseTime Open loop response time, the time to ramp up to 90% of the new target in + * response to the change in voltage, in seconds + * @return this + */ + public DERCurve withResponseTime(@Nullable Double responseTime) { + setResponseTime(responseTime); + return this; + } + + /** + * Gets point in time when this curve will become activated. Only absent when default is true. + * + * @return Point in time when this curve will become activated + */ + @Nullable + public ZonedDateTime getStartTime() { + return startTime; + } + + /** + * Sets point in time when this curve will become activated. Only absent when default is true. + * + * @param startTime Point in time when this curve will become activated + */ + public void setStartTime(@Nullable ZonedDateTime startTime) { + this.startTime = startTime; + } + + /** + * Adds point in time when this curve will become activated. Only absent when default is true. + * + * @param startTime Point in time when this curve will become activated + * @return this + */ + public DERCurve withStartTime(@Nullable ZonedDateTime startTime) { + setStartTime(startTime); + return this; + } + + /** + * Gets duration in seconds that this curve will be active. Only absent when default is true. + * + * @return Duration in seconds that this curve will be active + */ + @Nullable + public Double getDuration() { + return duration; + } + + /** + * Sets duration in seconds that this curve will be active. Only absent when default is true. + * + * @param duration Duration in seconds that this curve will be active + */ + public void setDuration(@Nullable Double duration) { + this.duration = duration; + } + + /** + * Adds duration in seconds that this curve will be active. Only absent when default is true. + * + * @param duration Duration in seconds that this curve will be active + * @return this + */ + public DERCurve withDuration(@Nullable Double duration) { + setDuration(duration); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DERCurve withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCurveData(curveData) + && isValidHysteresis(hysteresis) + && isValidPriority(priority) + && isValidReactivePowerParams(reactivePowerParams) + && isValidVoltageParams(voltageParams) + && isValidYUnit(yUnit) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DERCurve that = (DERCurve) o; + return Arrays.equals(curveData, that.curveData) + && Objects.equals(hysteresis, that.hysteresis) + && Objects.equals(priority, that.priority) + && Objects.equals(reactivePowerParams, that.reactivePowerParams) + && Objects.equals(voltageParams, that.voltageParams) + && Objects.equals(yUnit, that.yUnit) + && Objects.equals(responseTime, that.responseTime) + && Objects.equals(startTime, that.startTime) + && Objects.equals(duration, that.duration) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(curveData), + hysteresis, + priority, + reactivePowerParams, + voltageParams, + yUnit, + responseTime, + startTime, + duration, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("curveData", curveData) + .add("hysteresis", hysteresis) + .add("priority", priority) + .add("reactivePowerParams", reactivePowerParams) + .add("voltageParams", voltageParams) + .add("yUnit", yUnit) + .add("responseTime", responseTime) + .add("startTime", startTime) + .add("duration", duration) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurveGet.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurveGet.java new file mode 100644 index 00000000..9096f34d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurveGet.java @@ -0,0 +1,322 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** DERCurveGetType */ +public final class DERCurveGet { + /** curve */ + private DERCurve curve; + + /** Id of DER curve */ + private String id; + + /** Type of DER curve */ + private DERControlEnum curveType; + + /** True if this is a default curve */ + private Boolean isDefault; + + /** + * True if this setting is superseded by a higher priority setting (i.e. lower value of priority) + */ + private Boolean isSuperseded; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the DERCurveGet class + * + * @param curve curve + * @param id Id of DER curve + * @param curveType Type of DER curve + * @param isDefault True if this is a default curve + * @param isSuperseded True if this setting is superseded by a higher priority setting (i.e. lower + * value of priority) + */ + public DERCurveGet( + DERCurve curve, + String id, + DERControlEnum curveType, + Boolean isDefault, + Boolean isSuperseded) { + setCurve(curve); + setId(id); + setCurveType(curveType); + setIsDefault(isDefault); + setIsSuperseded(isSuperseded); + } + + /** + * Gets curve + * + * @return curve + */ + public DERCurve getCurve() { + return curve; + } + + /** + * Sets curve + * + * @param curve curve + */ + public void setCurve(DERCurve curve) { + if (!isValidCurve(curve)) { + throw new PropertyConstraintException(curve, "curve is invalid"); + } + this.curve = curve; + } + + /** + * Returns whether the given curve is valid + * + * @param curve the curve to check the validity of + * @return {@code true} if curve is valid, {@code false} if not + */ + private boolean isValidCurve(DERCurve curve) { + return curve != null && curve.validate(); + } + + /** + * Gets id of DER curve + * + * @return Id of DER curve + */ + public String getId() { + return id; + } + + /** + * Sets id of DER curve + * + * @param id Id of DER curve + */ + public void setId(String id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(String id) { + return id != null && id.length() <= 36; + } + + /** + * Gets type of DER curve + * + * @return Type of DER curve + */ + public DERControlEnum getCurveType() { + return curveType; + } + + /** + * Sets type of DER curve + * + * @param curveType Type of DER curve + */ + public void setCurveType(DERControlEnum curveType) { + if (!isValidCurveType(curveType)) { + throw new PropertyConstraintException(curveType, "curveType is invalid"); + } + this.curveType = curveType; + } + + /** + * Returns whether the given curveType is valid + * + * @param curveType the curveType to check the validity of + * @return {@code true} if curveType is valid, {@code false} if not + */ + private boolean isValidCurveType(DERControlEnum curveType) { + return curveType != null; + } + + /** + * Gets true if this is a default curve + * + * @return True if this is a default curve + */ + public Boolean getIsDefault() { + return isDefault; + } + + /** + * Sets true if this is a default curve + * + * @param isDefault True if this is a default curve + */ + public void setIsDefault(Boolean isDefault) { + if (!isValidIsDefault(isDefault)) { + throw new PropertyConstraintException(isDefault, "isDefault is invalid"); + } + this.isDefault = isDefault; + } + + /** + * Returns whether the given isDefault is valid + * + * @param isDefault the isDefault to check the validity of + * @return {@code true} if isDefault is valid, {@code false} if not + */ + private boolean isValidIsDefault(Boolean isDefault) { + return isDefault != null; + } + + /** + * Gets true if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + * + * @return True if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + */ + public Boolean getIsSuperseded() { + return isSuperseded; + } + + /** + * Sets true if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + * + * @param isSuperseded True if this setting is superseded by a higher priority setting (i.e. lower + * value of priority) + */ + public void setIsSuperseded(Boolean isSuperseded) { + if (!isValidIsSuperseded(isSuperseded)) { + throw new PropertyConstraintException(isSuperseded, "isSuperseded is invalid"); + } + this.isSuperseded = isSuperseded; + } + + /** + * Returns whether the given isSuperseded is valid + * + * @param isSuperseded the isSuperseded to check the validity of + * @return {@code true} if isSuperseded is valid, {@code false} if not + */ + private boolean isValidIsSuperseded(Boolean isSuperseded) { + return isSuperseded != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DERCurveGet withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCurve(curve) + && isValidId(id) + && isValidCurveType(curveType) + && isValidIsDefault(isDefault) + && isValidIsSuperseded(isSuperseded) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DERCurveGet that = (DERCurveGet) o; + return Objects.equals(curve, that.curve) + && Objects.equals(id, that.id) + && Objects.equals(curveType, that.curveType) + && Objects.equals(isDefault, that.isDefault) + && Objects.equals(isSuperseded, that.isSuperseded) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(curve, id, curveType, isDefault, isSuperseded, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("curve", curve) + .add("id", id) + .add("curveType", curveType) + .add("isDefault", isDefault) + .add("isSuperseded", isSuperseded) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurvePoints.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurvePoints.java new file mode 100644 index 00000000..e113e00d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERCurvePoints.java @@ -0,0 +1,204 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** DERCurvePointsType */ +public final class DERCurvePoints { + /** The data value of the X-axis (independent) variable, depending on the curve type. */ + private Double x; + + /** + * The data value of the Y-axis (dependent) variable, depending on the DERUnitEnumType of the + * curve. If y is power factor, then a positive value means DER is absorbing reactive power + * (under-excited), a negative value when DER is injecting reactive power (over-excited). + */ + private Double y; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the DERCurvePoints class + * + * @param x The data value of the X-axis (independent) variable, depending on the curve type. + * @param y The data value of the Y-axis (dependent) variable, depending on the DERUnitEnumType of + * the curve. If y is power factor, then a positive value means DER is absorbing reactive + * power (under-excited), a negative value when DER is injecting reactive power + * (over-excited). + */ + public DERCurvePoints(Double x, Double y) { + setX(x); + setY(y); + } + + /** + * Gets the data value of the X-axis (independent) variable, depending on the curve type. + * + * @return The data value of the X-axis (independent) variable, depending on the curve type + */ + public Double getX() { + return x; + } + + /** + * Sets the data value of the X-axis (independent) variable, depending on the curve type. + * + * @param x The data value of the X-axis (independent) variable, depending on the curve type + */ + public void setX(Double x) { + if (!isValidX(x)) { + throw new PropertyConstraintException(x, "x is invalid"); + } + this.x = x; + } + + /** + * Returns whether the given x is valid + * + * @param x the x to check the validity of + * @return {@code true} if x is valid, {@code false} if not + */ + private boolean isValidX(Double x) { + return x != null; + } + + /** + * Gets the data value of the Y-axis (dependent) variable, depending on the DERUnitEnumType of the + * curve. If y is power factor, then a positive value means DER is absorbing reactive power + * (under-excited), a negative value when DER is injecting reactive power (over-excited). + * + * @return The data value of the Y-axis (dependent) variable, depending on the DERUnitEnumType of + * the curve + */ + public Double getY() { + return y; + } + + /** + * Sets the data value of the Y-axis (dependent) variable, depending on the DERUnitEnumType of the + * curve. If y is power factor, then a positive value means DER is absorbing reactive power + * (under-excited), a negative value when DER is injecting reactive power (over-excited). + * + * @param y The data value of the Y-axis (dependent) variable, depending on the DERUnitEnumType of + * the curve + */ + public void setY(Double y) { + if (!isValidY(y)) { + throw new PropertyConstraintException(y, "y is invalid"); + } + this.y = y; + } + + /** + * Returns whether the given y is valid + * + * @param y the y to check the validity of + * @return {@code true} if y is valid, {@code false} if not + */ + private boolean isValidY(Double y) { + return y != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DERCurvePoints withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidX(x) && isValidY(y) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DERCurvePoints that = (DERCurvePoints) o; + return Objects.equals(x, that.x) + && Objects.equals(y, that.y) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(x, y, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("x", x) + .add("y", y) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERUnitEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERUnitEnum.java new file mode 100644 index 00000000..1dfae2c7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DERUnitEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Unit of the setpoint or the Y-axis of DER curve */ +public enum DERUnitEnum { + Not_Applicable, + PctMaxW, + PctMaxVar, + PctWAvail, + PctVarAvail, + PctEffectiveV +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DataEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DataEnum.java new file mode 100644 index 00000000..cc5d1721 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DataEnum.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import com.google.gson.annotations.SerializedName; + +/** Data type of this variable. */ +public enum DataEnum { + string, + decimal, + integer, + dateTime, + @SerializedName("boolean") + booleanType, + OptionList, + SequenceList, + MemberList +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DataTransferStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DataTransferStatusEnum.java new file mode 100644 index 00000000..7f5c0613 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DataTransferStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The success or failure of the data transfer. */ +public enum DataTransferStatusEnum { + Accepted, + Rejected, + UnknownMessageId, + UnknownVendorId +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DayOfWeekEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DayOfWeekEnum.java new file mode 100644 index 00000000..c61c10a3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DayOfWeekEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** DayOfWeekEnumType */ +public enum DayOfWeekEnum { + Monday, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday, + Sunday +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DeleteCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DeleteCertificateStatusEnum.java new file mode 100644 index 00000000..7538fb5c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DeleteCertificateStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Charging Station indicates if it can process the request. */ +public enum DeleteCertificateStatusEnum { + Accepted, + Failed, + NotFound +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DisplayMessageStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DisplayMessageStatusEnum.java new file mode 100644 index 00000000..3354e548 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/DisplayMessageStatusEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Charging Station is able to display the message. */ +public enum DisplayMessageStatusEnum { + Accepted, + NotSupportedMessageFormat, + Rejected, + NotSupportedPriority, + NotSupportedState, + UnknownTransaction, + LanguageNotSupported +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVAbsolutePriceSchedule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVAbsolutePriceSchedule.java new file mode 100644 index 00000000..676773b5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVAbsolutePriceSchedule.java @@ -0,0 +1,291 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Price schedule of EV energy offer. */ +public final class EVAbsolutePriceSchedule { + /** Starting point in time of the EVEnergyOffer. */ + private ZonedDateTime timeAnchor; + + /** Currency code according to ISO 4217. */ + private String currency; + + /** An entry in price schedule over time for which EV is willing to discharge. */ + private EVAbsolutePriceScheduleEntry[] evAbsolutePriceScheduleEntries; + + /** ISO 15118-20 URN of price algorithm: Power, PeakPower, StackedEnergy. */ + private String priceAlgorithm; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EVAbsolutePriceSchedule class + * + * @param timeAnchor Starting point in time of the EVEnergyOffer. + * @param currency Currency code according to ISO 4217. + * @param evAbsolutePriceScheduleEntries An entry in price schedule over time for which EV is + * willing to discharge. + * @param priceAlgorithm ISO 15118-20 URN of price algorithm: Power, PeakPower, StackedEnergy. + */ + public EVAbsolutePriceSchedule( + ZonedDateTime timeAnchor, + String currency, + EVAbsolutePriceScheduleEntry[] evAbsolutePriceScheduleEntries, + String priceAlgorithm) { + setTimeAnchor(timeAnchor); + setCurrency(currency); + setEvAbsolutePriceScheduleEntries(evAbsolutePriceScheduleEntries); + setPriceAlgorithm(priceAlgorithm); + } + + /** + * Gets starting point in time of the EVEnergyOffer. + * + * @return Starting point in time of the EVEnergyOffer + */ + public ZonedDateTime getTimeAnchor() { + return timeAnchor; + } + + /** + * Sets starting point in time of the EVEnergyOffer. + * + * @param timeAnchor Starting point in time of the EVEnergyOffer + */ + public void setTimeAnchor(ZonedDateTime timeAnchor) { + if (!isValidTimeAnchor(timeAnchor)) { + throw new PropertyConstraintException(timeAnchor, "timeAnchor is invalid"); + } + this.timeAnchor = timeAnchor; + } + + /** + * Returns whether the given timeAnchor is valid + * + * @param timeAnchor the timeAnchor to check the validity of + * @return {@code true} if timeAnchor is valid, {@code false} if not + */ + private boolean isValidTimeAnchor(ZonedDateTime timeAnchor) { + return timeAnchor != null; + } + + /** + * Gets currency code according to ISO 4217. + * + * @return Currency code according to ISO 4217 + */ + public String getCurrency() { + return currency; + } + + /** + * Sets currency code according to ISO 4217. + * + * @param currency Currency code according to ISO 4217 + */ + public void setCurrency(String currency) { + if (!isValidCurrency(currency)) { + throw new PropertyConstraintException(currency, "currency is invalid"); + } + this.currency = currency; + } + + /** + * Returns whether the given currency is valid + * + * @param currency the currency to check the validity of + * @return {@code true} if currency is valid, {@code false} if not + */ + private boolean isValidCurrency(String currency) { + return currency != null && currency.length() <= 3; + } + + /** + * Gets an entry in price schedule over time for which EV is willing to discharge. + * + * @return An entry in price schedule over time for which EV is willing to discharge + */ + public EVAbsolutePriceScheduleEntry[] getEvAbsolutePriceScheduleEntries() { + return evAbsolutePriceScheduleEntries; + } + + /** + * Sets an entry in price schedule over time for which EV is willing to discharge. + * + * @param evAbsolutePriceScheduleEntries An entry in price schedule over time for which EV is + * willing to discharge + */ + public void setEvAbsolutePriceScheduleEntries( + EVAbsolutePriceScheduleEntry[] evAbsolutePriceScheduleEntries) { + if (!isValidEvAbsolutePriceScheduleEntries(evAbsolutePriceScheduleEntries)) { + throw new PropertyConstraintException( + evAbsolutePriceScheduleEntries, "evAbsolutePriceScheduleEntries is invalid"); + } + this.evAbsolutePriceScheduleEntries = evAbsolutePriceScheduleEntries; + } + + /** + * Returns whether the given evAbsolutePriceScheduleEntries is valid + * + * @param evAbsolutePriceScheduleEntries the evAbsolutePriceScheduleEntries to check the validity + * of + * @return {@code true} if evAbsolutePriceScheduleEntries is valid, {@code false} if not + */ + private boolean isValidEvAbsolutePriceScheduleEntries( + EVAbsolutePriceScheduleEntry[] evAbsolutePriceScheduleEntries) { + return evAbsolutePriceScheduleEntries != null + && evAbsolutePriceScheduleEntries.length >= 1 + && evAbsolutePriceScheduleEntries.length <= 1024 + && Arrays.stream(evAbsolutePriceScheduleEntries).allMatch(item -> item.validate()); + } + + /** + * Gets ISO 15118-20 URN of price algorithm: Power, PeakPower, StackedEnergy. + * + * @return ISO 15118-20 URN of price algorithm: Power, PeakPower, StackedEnergy + */ + public String getPriceAlgorithm() { + return priceAlgorithm; + } + + /** + * Sets ISO 15118-20 URN of price algorithm: Power, PeakPower, StackedEnergy. + * + * @param priceAlgorithm ISO 15118-20 URN of price algorithm: Power, PeakPower, StackedEnergy + */ + public void setPriceAlgorithm(String priceAlgorithm) { + if (!isValidPriceAlgorithm(priceAlgorithm)) { + throw new PropertyConstraintException(priceAlgorithm, "priceAlgorithm is invalid"); + } + this.priceAlgorithm = priceAlgorithm; + } + + /** + * Returns whether the given priceAlgorithm is valid + * + * @param priceAlgorithm the priceAlgorithm to check the validity of + * @return {@code true} if priceAlgorithm is valid, {@code false} if not + */ + private boolean isValidPriceAlgorithm(String priceAlgorithm) { + return priceAlgorithm != null && priceAlgorithm.length() <= 2000; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EVAbsolutePriceSchedule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidTimeAnchor(timeAnchor) + && isValidCurrency(currency) + && isValidEvAbsolutePriceScheduleEntries(evAbsolutePriceScheduleEntries) + && isValidPriceAlgorithm(priceAlgorithm) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EVAbsolutePriceSchedule that = (EVAbsolutePriceSchedule) o; + return Objects.equals(timeAnchor, that.timeAnchor) + && Objects.equals(currency, that.currency) + && Arrays.equals(evAbsolutePriceScheduleEntries, that.evAbsolutePriceScheduleEntries) + && Objects.equals(priceAlgorithm, that.priceAlgorithm) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + timeAnchor, + currency, + Arrays.hashCode(evAbsolutePriceScheduleEntries), + priceAlgorithm, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("timeAnchor", timeAnchor) + .add("currency", currency) + .add("evAbsolutePriceScheduleEntries", evAbsolutePriceScheduleEntries) + .add("priceAlgorithm", priceAlgorithm) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVAbsolutePriceScheduleEntry.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVAbsolutePriceScheduleEntry.java new file mode 100644 index 00000000..5b5d7559 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVAbsolutePriceScheduleEntry.java @@ -0,0 +1,197 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** An entry in price schedule over time for which EV is willing to discharge. */ +public final class EVAbsolutePriceScheduleEntry { + /** The amount of seconds of this entry. */ + private Integer duration; + + /** An entry in price schedule over time for which EV is willing to discharge. */ + private EVPriceRule[] evPriceRule; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EVAbsolutePriceScheduleEntry class + * + * @param duration The amount of seconds of this entry. + * @param evPriceRule An entry in price schedule over time for which EV is willing to discharge. + */ + public EVAbsolutePriceScheduleEntry(Integer duration, EVPriceRule[] evPriceRule) { + setDuration(duration); + setEvPriceRule(evPriceRule); + } + + /** + * Gets the amount of seconds of this entry. + * + * @return The amount of seconds of this entry + */ + public Integer getDuration() { + return duration; + } + + /** + * Sets the amount of seconds of this entry. + * + * @param duration The amount of seconds of this entry + */ + public void setDuration(Integer duration) { + if (!isValidDuration(duration)) { + throw new PropertyConstraintException(duration, "duration is invalid"); + } + this.duration = duration; + } + + /** + * Returns whether the given duration is valid + * + * @param duration the duration to check the validity of + * @return {@code true} if duration is valid, {@code false} if not + */ + private boolean isValidDuration(Integer duration) { + return duration != null; + } + + /** + * Gets an entry in price schedule over time for which EV is willing to discharge. + * + * @return An entry in price schedule over time for which EV is willing to discharge + */ + public EVPriceRule[] getEvPriceRule() { + return evPriceRule; + } + + /** + * Sets an entry in price schedule over time for which EV is willing to discharge. + * + * @param evPriceRule An entry in price schedule over time for which EV is willing to discharge + */ + public void setEvPriceRule(EVPriceRule[] evPriceRule) { + if (!isValidEvPriceRule(evPriceRule)) { + throw new PropertyConstraintException(evPriceRule, "evPriceRule is invalid"); + } + this.evPriceRule = evPriceRule; + } + + /** + * Returns whether the given evPriceRule is valid + * + * @param evPriceRule the evPriceRule to check the validity of + * @return {@code true} if evPriceRule is valid, {@code false} if not + */ + private boolean isValidEvPriceRule(EVPriceRule[] evPriceRule) { + return evPriceRule != null + && evPriceRule.length >= 1 + && evPriceRule.length <= 8 + && Arrays.stream(evPriceRule).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EVAbsolutePriceScheduleEntry withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDuration(duration) + && isValidEvPriceRule(evPriceRule) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EVAbsolutePriceScheduleEntry that = (EVAbsolutePriceScheduleEntry) o; + return Objects.equals(duration, that.duration) + && Arrays.equals(evPriceRule, that.evPriceRule) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(duration, Arrays.hashCode(evPriceRule), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("duration", duration) + .add("evPriceRule", evPriceRule) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVEnergyOffer.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVEnergyOffer.java new file mode 100644 index 00000000..f99b9d5e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVEnergyOffer.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A schedule of the energy amount over time that EV is willing to discharge. A negative value + * indicates the willingness to discharge under specific conditions, a positive value indicates that + * the EV currently is not able to offer energy to discharge. + */ +public final class EVEnergyOffer { + /** Price schedule of EV energy offer. */ + @Nullable private EVAbsolutePriceSchedule evAbsolutePriceSchedule; + + /** Schedule of EV energy offer. */ + private EVPowerSchedule evPowerSchedule; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EVEnergyOffer class + * + * @param evPowerSchedule Schedule of EV energy offer. + */ + public EVEnergyOffer(EVPowerSchedule evPowerSchedule) { + setEvPowerSchedule(evPowerSchedule); + } + + /** + * Gets price schedule of EV energy offer. + * + * @return Price schedule of EV energy offer + */ + @Nullable + public EVAbsolutePriceSchedule getEvAbsolutePriceSchedule() { + return evAbsolutePriceSchedule; + } + + /** + * Sets price schedule of EV energy offer. + * + * @param evAbsolutePriceSchedule Price schedule of EV energy offer + */ + public void setEvAbsolutePriceSchedule( + @Nullable EVAbsolutePriceSchedule evAbsolutePriceSchedule) { + if (!isValidEvAbsolutePriceSchedule(evAbsolutePriceSchedule)) { + throw new PropertyConstraintException( + evAbsolutePriceSchedule, "evAbsolutePriceSchedule is invalid"); + } + this.evAbsolutePriceSchedule = evAbsolutePriceSchedule; + } + + /** + * Returns whether the given evAbsolutePriceSchedule is valid + * + * @param evAbsolutePriceSchedule the evAbsolutePriceSchedule to check the validity of + * @return {@code true} if evAbsolutePriceSchedule is valid, {@code false} if not + */ + private boolean isValidEvAbsolutePriceSchedule( + @Nullable EVAbsolutePriceSchedule evAbsolutePriceSchedule) { + return evAbsolutePriceSchedule == null || evAbsolutePriceSchedule.validate(); + } + + /** + * Adds price schedule of EV energy offer. + * + * @param evAbsolutePriceSchedule Price schedule of EV energy offer + * @return this + */ + public EVEnergyOffer withEvAbsolutePriceSchedule( + @Nullable EVAbsolutePriceSchedule evAbsolutePriceSchedule) { + setEvAbsolutePriceSchedule(evAbsolutePriceSchedule); + return this; + } + + /** + * Gets schedule of EV energy offer. + * + * @return Schedule of EV energy offer + */ + public EVPowerSchedule getEvPowerSchedule() { + return evPowerSchedule; + } + + /** + * Sets schedule of EV energy offer. + * + * @param evPowerSchedule Schedule of EV energy offer + */ + public void setEvPowerSchedule(EVPowerSchedule evPowerSchedule) { + if (!isValidEvPowerSchedule(evPowerSchedule)) { + throw new PropertyConstraintException(evPowerSchedule, "evPowerSchedule is invalid"); + } + this.evPowerSchedule = evPowerSchedule; + } + + /** + * Returns whether the given evPowerSchedule is valid + * + * @param evPowerSchedule the evPowerSchedule to check the validity of + * @return {@code true} if evPowerSchedule is valid, {@code false} if not + */ + private boolean isValidEvPowerSchedule(EVPowerSchedule evPowerSchedule) { + return evPowerSchedule != null && evPowerSchedule.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EVEnergyOffer withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEvAbsolutePriceSchedule(evAbsolutePriceSchedule) + && isValidEvPowerSchedule(evPowerSchedule) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EVEnergyOffer that = (EVEnergyOffer) o; + return Objects.equals(evAbsolutePriceSchedule, that.evAbsolutePriceSchedule) + && Objects.equals(evPowerSchedule, that.evPowerSchedule) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(evAbsolutePriceSchedule, evPowerSchedule, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evAbsolutePriceSchedule", evAbsolutePriceSchedule) + .add("evPowerSchedule", evPowerSchedule) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPowerSchedule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPowerSchedule.java new file mode 100644 index 00000000..c3573a4c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPowerSchedule.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Schedule of EV energy offer. */ +public final class EVPowerSchedule { + /** + * An entry in schedule of the energy amount over time that EV is willing to discharge. A negative + * value indicates the willingness to discharge under specific conditions, a positive value + * indicates that the EV currently is not able to offer energy to discharge. + */ + private EVPowerScheduleEntry[] evPowerScheduleEntries; + + /** The time that defines the starting point for the EVEnergyOffer. */ + private ZonedDateTime timeAnchor; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EVPowerSchedule class + * + * @param evPowerScheduleEntries An entry in schedule of the energy amount over time that EV is + * willing to discharge. A negative value indicates the willingness to discharge under + * specific conditions, a positive value indicates that the EV currently is not able to offer + * energy to discharge. + * @param timeAnchor The time that defines the starting point for the EVEnergyOffer. + */ + public EVPowerSchedule(EVPowerScheduleEntry[] evPowerScheduleEntries, ZonedDateTime timeAnchor) { + setEvPowerScheduleEntries(evPowerScheduleEntries); + setTimeAnchor(timeAnchor); + } + + /** + * Gets an entry in schedule of the energy amount over time that EV is willing to discharge. A + * negative value indicates the willingness to discharge under specific conditions, a positive + * value indicates that the EV currently is not able to offer energy to discharge. + * + * @return An entry in schedule of the energy amount over time that EV is willing to discharge + */ + public EVPowerScheduleEntry[] getEvPowerScheduleEntries() { + return evPowerScheduleEntries; + } + + /** + * Sets an entry in schedule of the energy amount over time that EV is willing to discharge. A + * negative value indicates the willingness to discharge under specific conditions, a positive + * value indicates that the EV currently is not able to offer energy to discharge. + * + * @param evPowerScheduleEntries An entry in schedule of the energy amount over time that EV is + * willing to discharge + */ + public void setEvPowerScheduleEntries(EVPowerScheduleEntry[] evPowerScheduleEntries) { + if (!isValidEvPowerScheduleEntries(evPowerScheduleEntries)) { + throw new PropertyConstraintException( + evPowerScheduleEntries, "evPowerScheduleEntries is invalid"); + } + this.evPowerScheduleEntries = evPowerScheduleEntries; + } + + /** + * Returns whether the given evPowerScheduleEntries is valid + * + * @param evPowerScheduleEntries the evPowerScheduleEntries to check the validity of + * @return {@code true} if evPowerScheduleEntries is valid, {@code false} if not + */ + private boolean isValidEvPowerScheduleEntries(EVPowerScheduleEntry[] evPowerScheduleEntries) { + return evPowerScheduleEntries != null + && evPowerScheduleEntries.length >= 1 + && evPowerScheduleEntries.length <= 1024 + && Arrays.stream(evPowerScheduleEntries).allMatch(item -> item.validate()); + } + + /** + * Gets the time that defines the starting point for the EVEnergyOffer. + * + * @return The time that defines the starting point for the EVEnergyOffer + */ + public ZonedDateTime getTimeAnchor() { + return timeAnchor; + } + + /** + * Sets the time that defines the starting point for the EVEnergyOffer. + * + * @param timeAnchor The time that defines the starting point for the EVEnergyOffer + */ + public void setTimeAnchor(ZonedDateTime timeAnchor) { + if (!isValidTimeAnchor(timeAnchor)) { + throw new PropertyConstraintException(timeAnchor, "timeAnchor is invalid"); + } + this.timeAnchor = timeAnchor; + } + + /** + * Returns whether the given timeAnchor is valid + * + * @param timeAnchor the timeAnchor to check the validity of + * @return {@code true} if timeAnchor is valid, {@code false} if not + */ + private boolean isValidTimeAnchor(ZonedDateTime timeAnchor) { + return timeAnchor != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EVPowerSchedule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEvPowerScheduleEntries(evPowerScheduleEntries) + && isValidTimeAnchor(timeAnchor) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EVPowerSchedule that = (EVPowerSchedule) o; + return Arrays.equals(evPowerScheduleEntries, that.evPowerScheduleEntries) + && Objects.equals(timeAnchor, that.timeAnchor) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(evPowerScheduleEntries), timeAnchor, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("evPowerScheduleEntries", evPowerScheduleEntries) + .add("timeAnchor", timeAnchor) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPowerScheduleEntry.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPowerScheduleEntry.java new file mode 100644 index 00000000..40c763f4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPowerScheduleEntry.java @@ -0,0 +1,204 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * An entry in schedule of the energy amount over time that EV is willing to discharge. A negative + * value indicates the willingness to discharge under specific conditions, a positive value + * indicates that the EV currently is not able to offer energy to discharge. + */ +public final class EVPowerScheduleEntry { + /** The duration of this entry. */ + private Integer duration; + + /** + * Maximum amount of power for the duration of this EVPowerScheduleEntry to be discharged from the + * EV battery through EVSE power outlet. Negative values are used for discharging. + */ + private Double power; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EVPowerScheduleEntry class + * + * @param duration The duration of this entry. + * @param power Maximum amount of power for the duration of this EVPowerScheduleEntry to be + * discharged from the EV battery through EVSE power outlet. Negative values are used for + * discharging. + */ + public EVPowerScheduleEntry(Integer duration, Double power) { + setDuration(duration); + setPower(power); + } + + /** + * Gets the duration of this entry. + * + * @return The duration of this entry + */ + public Integer getDuration() { + return duration; + } + + /** + * Sets the duration of this entry. + * + * @param duration The duration of this entry + */ + public void setDuration(Integer duration) { + if (!isValidDuration(duration)) { + throw new PropertyConstraintException(duration, "duration is invalid"); + } + this.duration = duration; + } + + /** + * Returns whether the given duration is valid + * + * @param duration the duration to check the validity of + * @return {@code true} if duration is valid, {@code false} if not + */ + private boolean isValidDuration(Integer duration) { + return duration != null; + } + + /** + * Gets maximum amount of power for the duration of this EVPowerScheduleEntry to be discharged + * from the EV battery through EVSE power outlet. Negative values are used for discharging. + * + * @return Maximum amount of power for the duration of this EVPowerScheduleEntry to be discharged + * from the EV battery through EVSE power outlet + */ + public Double getPower() { + return power; + } + + /** + * Sets maximum amount of power for the duration of this EVPowerScheduleEntry to be discharged + * from the EV battery through EVSE power outlet. Negative values are used for discharging. + * + * @param power Maximum amount of power for the duration of this EVPowerScheduleEntry to be + * discharged from the EV battery through EVSE power outlet + */ + public void setPower(Double power) { + if (!isValidPower(power)) { + throw new PropertyConstraintException(power, "power is invalid"); + } + this.power = power; + } + + /** + * Returns whether the given power is valid + * + * @param power the power to check the validity of + * @return {@code true} if power is valid, {@code false} if not + */ + private boolean isValidPower(Double power) { + return power != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EVPowerScheduleEntry withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDuration(duration) && isValidPower(power) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EVPowerScheduleEntry that = (EVPowerScheduleEntry) o; + return Objects.equals(duration, that.duration) + && Objects.equals(power, that.power) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(duration, power, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("duration", duration) + .add("power", power) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPriceRule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPriceRule.java new file mode 100644 index 00000000..788fee28 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVPriceRule.java @@ -0,0 +1,205 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** An entry in price schedule over time for which EV is willing to discharge. */ +public final class EVPriceRule { + /** Cost per kWh. */ + private Double energyFee; + + /** + * The EnergyFee applies between this value and the value of the PowerRangeStart of the subsequent + * EVPriceRule. If the power is below this value, the EnergyFee of the previous EVPriceRule + * applies. Negative values are used for discharging. + */ + private Double powerRangeStart; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EVPriceRule class + * + * @param energyFee Cost per kWh. + * @param powerRangeStart The EnergyFee applies between this value and the value of the + * PowerRangeStart of the subsequent EVPriceRule. If the power is below this value, the + * EnergyFee of the previous EVPriceRule applies. Negative values are used for discharging. + */ + public EVPriceRule(Double energyFee, Double powerRangeStart) { + setEnergyFee(energyFee); + setPowerRangeStart(powerRangeStart); + } + + /** + * Gets cost per kWh. + * + * @return Cost per kWh + */ + public Double getEnergyFee() { + return energyFee; + } + + /** + * Sets cost per kWh. + * + * @param energyFee Cost per kWh + */ + public void setEnergyFee(Double energyFee) { + if (!isValidEnergyFee(energyFee)) { + throw new PropertyConstraintException(energyFee, "energyFee is invalid"); + } + this.energyFee = energyFee; + } + + /** + * Returns whether the given energyFee is valid + * + * @param energyFee the energyFee to check the validity of + * @return {@code true} if energyFee is valid, {@code false} if not + */ + private boolean isValidEnergyFee(Double energyFee) { + return energyFee != null; + } + + /** + * Gets the EnergyFee applies between this value and the value of the PowerRangeStart of the + * subsequent EVPriceRule. If the power is below this value, the EnergyFee of the previous + * EVPriceRule applies. Negative values are used for discharging. + * + * @return The EnergyFee applies between this value and the value of the PowerRangeStart of the + * subsequent EVPriceRule + */ + public Double getPowerRangeStart() { + return powerRangeStart; + } + + /** + * Sets the EnergyFee applies between this value and the value of the PowerRangeStart of the + * subsequent EVPriceRule. If the power is below this value, the EnergyFee of the previous + * EVPriceRule applies. Negative values are used for discharging. + * + * @param powerRangeStart The EnergyFee applies between this value and the value of the + * PowerRangeStart of the subsequent EVPriceRule + */ + public void setPowerRangeStart(Double powerRangeStart) { + if (!isValidPowerRangeStart(powerRangeStart)) { + throw new PropertyConstraintException(powerRangeStart, "powerRangeStart is invalid"); + } + this.powerRangeStart = powerRangeStart; + } + + /** + * Returns whether the given powerRangeStart is valid + * + * @param powerRangeStart the powerRangeStart to check the validity of + * @return {@code true} if powerRangeStart is valid, {@code false} if not + */ + private boolean isValidPowerRangeStart(Double powerRangeStart) { + return powerRangeStart != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EVPriceRule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEnergyFee(energyFee) + && isValidPowerRangeStart(powerRangeStart) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EVPriceRule that = (EVPriceRule) o; + return Objects.equals(energyFee, that.energyFee) + && Objects.equals(powerRangeStart, that.powerRangeStart) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(energyFee, powerRangeStart, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("energyFee", energyFee) + .add("powerRangeStart", powerRangeStart) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVSE.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVSE.java new file mode 100644 index 00000000..093423fe --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EVSE.java @@ -0,0 +1,209 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Electric Vehicle Supply Equipment */ +public final class EVSE { + /** + * EVSE Identifier. This contains a number (greater than 0) designating an EVSE of the Charging + * Station. + */ + private Integer id; + + /** An id to designate a specific connector (on an EVSE) by connector index number. */ + @Nullable private Integer connectorId; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EVSE class + * + * @param id EVSE Identifier. This contains a number (greater than 0) designating an EVSE of the + * Charging Station. + */ + public EVSE(Integer id) { + setId(id); + } + + /** + * Gets EVSE Identifier. This contains a number (greater than 0) designating an EVSE of the + * Charging Station. + * + * @return EVSE Identifier + */ + public Integer getId() { + return id; + } + + /** + * Sets EVSE Identifier. This contains a number (greater than 0) designating an EVSE of the + * Charging Station. + * + * @param id EVSE Identifier + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets an id to designate a specific connector (on an EVSE) by connector index number. + * + * @return An id to designate a specific connector (on an EVSE) by connector index number + */ + @Nullable + public Integer getConnectorId() { + return connectorId; + } + + /** + * Sets an id to designate a specific connector (on an EVSE) by connector index number. + * + * @param connectorId An id to designate a specific connector (on an EVSE) by connector index + * number + */ + public void setConnectorId(@Nullable Integer connectorId) { + if (!isValidConnectorId(connectorId)) { + throw new PropertyConstraintException(connectorId, "connectorId is invalid"); + } + this.connectorId = connectorId; + } + + /** + * Returns whether the given connectorId is valid + * + * @param connectorId the connectorId to check the validity of + * @return {@code true} if connectorId is valid, {@code false} if not + */ + private boolean isValidConnectorId(@Nullable Integer connectorId) { + return connectorId == null || (connectorId >= 0); + } + + /** + * Adds an id to designate a specific connector (on an EVSE) by connector index number. + * + * @param connectorId An id to designate a specific connector (on an EVSE) by connector index + * number + * @return this + */ + public EVSE withConnectorId(@Nullable Integer connectorId) { + setConnectorId(connectorId); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EVSE withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) && isValidConnectorId(connectorId) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EVSE that = (EVSE) o; + return Objects.equals(id, that.id) + && Objects.equals(connectorId, that.connectorId) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(id, connectorId, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("connectorId", connectorId) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnergyTransferModeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnergyTransferModeEnum.java new file mode 100644 index 00000000..f2a23f08 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnergyTransferModeEnum.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Mode of energy transfer requested by the EV. */ +public enum EnergyTransferModeEnum { + AC_single_phase, + AC_two_phase, + AC_three_phase, + DC, + AC_BPT, + AC_BPT_DER, + AC_DER, + DC_BPT, + DC_ACDP, + DC_ACDP_BPT, + WPT +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnterService.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnterService.java new file mode 100644 index 00000000..50079e84 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnterService.java @@ -0,0 +1,425 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** EnterServiceType */ +public final class EnterService { + /** Priority of setting (0=highest) */ + private Integer priority; + + /** Enter service voltage high */ + private Double highVoltage; + + /** Enter service voltage low */ + private Double lowVoltage; + + /** Enter service frequency high */ + private Double highFreq; + + /** Enter service frequency low */ + private Double lowFreq; + + /** Enter service delay */ + @Nullable private Double delay; + + /** Enter service randomized delay */ + @Nullable private Double randomDelay; + + /** Enter service ramp rate in seconds */ + @Nullable private Double rampRate; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EnterService class + * + * @param priority Priority of setting (0=highest) + * @param highVoltage Enter service voltage high + * @param lowVoltage Enter service voltage low + * @param highFreq Enter service frequency high + * @param lowFreq Enter service frequency low + */ + public EnterService( + Integer priority, Double highVoltage, Double lowVoltage, Double highFreq, Double lowFreq) { + setPriority(priority); + setHighVoltage(highVoltage); + setLowVoltage(lowVoltage); + setHighFreq(highFreq); + setLowFreq(lowFreq); + } + + /** + * Gets priority of setting (0=highest) + * + * @return Priority of setting (0=highest) + */ + public Integer getPriority() { + return priority; + } + + /** + * Sets priority of setting (0=highest) + * + * @param priority Priority of setting (0=highest) + */ + public void setPriority(Integer priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(Integer priority) { + return priority != null && priority >= 0; + } + + /** + * Gets enter service voltage high + * + * @return Enter service voltage high + */ + public Double getHighVoltage() { + return highVoltage; + } + + /** + * Sets enter service voltage high + * + * @param highVoltage Enter service voltage high + */ + public void setHighVoltage(Double highVoltage) { + if (!isValidHighVoltage(highVoltage)) { + throw new PropertyConstraintException(highVoltage, "highVoltage is invalid"); + } + this.highVoltage = highVoltage; + } + + /** + * Returns whether the given highVoltage is valid + * + * @param highVoltage the highVoltage to check the validity of + * @return {@code true} if highVoltage is valid, {@code false} if not + */ + private boolean isValidHighVoltage(Double highVoltage) { + return highVoltage != null; + } + + /** + * Gets enter service voltage low + * + * @return Enter service voltage low + */ + public Double getLowVoltage() { + return lowVoltage; + } + + /** + * Sets enter service voltage low + * + * @param lowVoltage Enter service voltage low + */ + public void setLowVoltage(Double lowVoltage) { + if (!isValidLowVoltage(lowVoltage)) { + throw new PropertyConstraintException(lowVoltage, "lowVoltage is invalid"); + } + this.lowVoltage = lowVoltage; + } + + /** + * Returns whether the given lowVoltage is valid + * + * @param lowVoltage the lowVoltage to check the validity of + * @return {@code true} if lowVoltage is valid, {@code false} if not + */ + private boolean isValidLowVoltage(Double lowVoltage) { + return lowVoltage != null; + } + + /** + * Gets enter service frequency high + * + * @return Enter service frequency high + */ + public Double getHighFreq() { + return highFreq; + } + + /** + * Sets enter service frequency high + * + * @param highFreq Enter service frequency high + */ + public void setHighFreq(Double highFreq) { + if (!isValidHighFreq(highFreq)) { + throw new PropertyConstraintException(highFreq, "highFreq is invalid"); + } + this.highFreq = highFreq; + } + + /** + * Returns whether the given highFreq is valid + * + * @param highFreq the highFreq to check the validity of + * @return {@code true} if highFreq is valid, {@code false} if not + */ + private boolean isValidHighFreq(Double highFreq) { + return highFreq != null; + } + + /** + * Gets enter service frequency low + * + * @return Enter service frequency low + */ + public Double getLowFreq() { + return lowFreq; + } + + /** + * Sets enter service frequency low + * + * @param lowFreq Enter service frequency low + */ + public void setLowFreq(Double lowFreq) { + if (!isValidLowFreq(lowFreq)) { + throw new PropertyConstraintException(lowFreq, "lowFreq is invalid"); + } + this.lowFreq = lowFreq; + } + + /** + * Returns whether the given lowFreq is valid + * + * @param lowFreq the lowFreq to check the validity of + * @return {@code true} if lowFreq is valid, {@code false} if not + */ + private boolean isValidLowFreq(Double lowFreq) { + return lowFreq != null; + } + + /** + * Gets enter service delay + * + * @return Enter service delay + */ + @Nullable + public Double getDelay() { + return delay; + } + + /** + * Sets enter service delay + * + * @param delay Enter service delay + */ + public void setDelay(@Nullable Double delay) { + this.delay = delay; + } + + /** + * Adds enter service delay + * + * @param delay Enter service delay + * @return this + */ + public EnterService withDelay(@Nullable Double delay) { + setDelay(delay); + return this; + } + + /** + * Gets enter service randomized delay + * + * @return Enter service randomized delay + */ + @Nullable + public Double getRandomDelay() { + return randomDelay; + } + + /** + * Sets enter service randomized delay + * + * @param randomDelay Enter service randomized delay + */ + public void setRandomDelay(@Nullable Double randomDelay) { + this.randomDelay = randomDelay; + } + + /** + * Adds enter service randomized delay + * + * @param randomDelay Enter service randomized delay + * @return this + */ + public EnterService withRandomDelay(@Nullable Double randomDelay) { + setRandomDelay(randomDelay); + return this; + } + + /** + * Gets enter service ramp rate in seconds + * + * @return Enter service ramp rate in seconds + */ + @Nullable + public Double getRampRate() { + return rampRate; + } + + /** + * Sets enter service ramp rate in seconds + * + * @param rampRate Enter service ramp rate in seconds + */ + public void setRampRate(@Nullable Double rampRate) { + this.rampRate = rampRate; + } + + /** + * Adds enter service ramp rate in seconds + * + * @param rampRate Enter service ramp rate in seconds + * @return this + */ + public EnterService withRampRate(@Nullable Double rampRate) { + setRampRate(rampRate); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EnterService withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriority(priority) + && isValidHighVoltage(highVoltage) + && isValidLowVoltage(lowVoltage) + && isValidHighFreq(highFreq) + && isValidLowFreq(lowFreq) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnterService that = (EnterService) o; + return Objects.equals(priority, that.priority) + && Objects.equals(highVoltage, that.highVoltage) + && Objects.equals(lowVoltage, that.lowVoltage) + && Objects.equals(highFreq, that.highFreq) + && Objects.equals(lowFreq, that.lowFreq) + && Objects.equals(delay, that.delay) + && Objects.equals(randomDelay, that.randomDelay) + && Objects.equals(rampRate, that.rampRate) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + priority, + highVoltage, + lowVoltage, + highFreq, + lowFreq, + delay, + randomDelay, + rampRate, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priority", priority) + .add("highVoltage", highVoltage) + .add("lowVoltage", lowVoltage) + .add("highFreq", highFreq) + .add("lowFreq", lowFreq) + .add("delay", delay) + .add("randomDelay", randomDelay) + .add("rampRate", rampRate) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnterServiceGet.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnterServiceGet.java new file mode 100644 index 00000000..95314b48 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EnterServiceGet.java @@ -0,0 +1,191 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** EnterServiceGetType */ +public final class EnterServiceGet { + /** enterService */ + private EnterService enterService; + + /** Id of setting */ + private String id; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EnterServiceGet class + * + * @param enterService enterService + * @param id Id of setting + */ + public EnterServiceGet(EnterService enterService, String id) { + setEnterService(enterService); + setId(id); + } + + /** + * Gets enterService + * + * @return enterService + */ + public EnterService getEnterService() { + return enterService; + } + + /** + * Sets enterService + * + * @param enterService enterService + */ + public void setEnterService(EnterService enterService) { + if (!isValidEnterService(enterService)) { + throw new PropertyConstraintException(enterService, "enterService is invalid"); + } + this.enterService = enterService; + } + + /** + * Returns whether the given enterService is valid + * + * @param enterService the enterService to check the validity of + * @return {@code true} if enterService is valid, {@code false} if not + */ + private boolean isValidEnterService(EnterService enterService) { + return enterService != null && enterService.validate(); + } + + /** + * Gets id of setting + * + * @return Id of setting + */ + public String getId() { + return id; + } + + /** + * Sets id of setting + * + * @param id Id of setting + */ + public void setId(String id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(String id) { + return id != null && id.length() <= 36; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EnterServiceGet withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEnterService(enterService) && isValidId(id) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnterServiceGet that = (EnterServiceGet) o; + return Objects.equals(enterService, that.enterService) + && Objects.equals(id, that.id) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(enterService, id, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("enterService", enterService) + .add("id", id) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventData.java new file mode 100644 index 00000000..0cefd70c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventData.java @@ -0,0 +1,776 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to report an event notification for a component-variable. */ +public final class EventData { + /** The identifier of the event. This field can be referred to as a cause by other events. */ + private Integer eventId; + + /** Timestamp of the moment the report was generated. */ + private ZonedDateTime timestamp; + + /** Type of trigger for this event, e.g. exceeding a threshold value. */ + private EventTriggerEnum trigger; + + /** Refers to the Id of an event that is considered to be the cause for this event. */ + @Nullable private Integer cause; + + /** + * Actual value (attributeType Actual) of the variable. + * + *

The Configuration Variable ReportingValueSize can be used to limit + * GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max + * size of these values will always remain equal. + */ + private String actualValue; + + /** Technical (error) code as reported by component. */ + @Nullable private String techCode; + + /** Technical detail information as reported by component. */ + @Nullable private String techInfo; + + /** + * Cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to + * normal'. + */ + @Nullable private Boolean cleared; + + /** + * If an event notification is linked to a specific transaction, this field can be used to specify + * its transactionId. + */ + @Nullable private String transactionId; + + /** A physical or logical component */ + private Component component; + + /** The identifier of the VariableMonitoring which triggered the event. */ + @Nullable private Integer variableMonitoringId; + + /** Specifies the event notification type of the message. */ + private EventNotificationEnum eventNotificationType; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * Severity associated with the monitor in variableMonitoringId or with the hardwired + * notification. + */ + @Nullable private Integer severity; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the EventData class + * + * @param eventId The identifier of the event. This field can be referred to as a cause by other + * events. + * @param timestamp Timestamp of the moment the report was generated. + * @param trigger Type of trigger for this event, e.g. exceeding a threshold value. + * @param actualValue Actual value (attributeType Actual) of the variable. + * @param component A physical or logical component + * @param eventNotificationType Specifies the event notification type of the message. + * @param variable Reference key to a component-variable. + */ + public EventData( + Integer eventId, + ZonedDateTime timestamp, + EventTriggerEnum trigger, + String actualValue, + Component component, + EventNotificationEnum eventNotificationType, + Variable variable) { + setEventId(eventId); + setTimestamp(timestamp); + setTrigger(trigger); + setActualValue(actualValue); + setComponent(component); + setEventNotificationType(eventNotificationType); + setVariable(variable); + } + + /** + * Gets the identifier of the event. This field can be referred to as a cause by other events. + * + * @return The identifier of the event + */ + public Integer getEventId() { + return eventId; + } + + /** + * Sets the identifier of the event. This field can be referred to as a cause by other events. + * + * @param eventId The identifier of the event + */ + public void setEventId(Integer eventId) { + if (!isValidEventId(eventId)) { + throw new PropertyConstraintException(eventId, "eventId is invalid"); + } + this.eventId = eventId; + } + + /** + * Returns whether the given eventId is valid + * + * @param eventId the eventId to check the validity of + * @return {@code true} if eventId is valid, {@code false} if not + */ + private boolean isValidEventId(Integer eventId) { + return eventId != null && eventId >= 0; + } + + /** + * Gets timestamp of the moment the report was generated. + * + * @return Timestamp of the moment the report was generated + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets timestamp of the moment the report was generated. + * + * @param timestamp Timestamp of the moment the report was generated + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets type of trigger for this event, e.g. exceeding a threshold value. + * + * @return Type of trigger for this event, e.g. exceeding a threshold value + */ + public EventTriggerEnum getTrigger() { + return trigger; + } + + /** + * Sets type of trigger for this event, e.g. exceeding a threshold value. + * + * @param trigger Type of trigger for this event, e.g. exceeding a threshold value + */ + public void setTrigger(EventTriggerEnum trigger) { + if (!isValidTrigger(trigger)) { + throw new PropertyConstraintException(trigger, "trigger is invalid"); + } + this.trigger = trigger; + } + + /** + * Returns whether the given trigger is valid + * + * @param trigger the trigger to check the validity of + * @return {@code true} if trigger is valid, {@code false} if not + */ + private boolean isValidTrigger(EventTriggerEnum trigger) { + return trigger != null; + } + + /** + * Gets refers to the Id of an event that is considered to be the cause for this event. + * + * @return Refers to the Id of an event that is considered to be the cause for this event + */ + @Nullable + public Integer getCause() { + return cause; + } + + /** + * Sets refers to the Id of an event that is considered to be the cause for this event. + * + * @param cause Refers to the Id of an event that is considered to be the cause for this event + */ + public void setCause(@Nullable Integer cause) { + if (!isValidCause(cause)) { + throw new PropertyConstraintException(cause, "cause is invalid"); + } + this.cause = cause; + } + + /** + * Returns whether the given cause is valid + * + * @param cause the cause to check the validity of + * @return {@code true} if cause is valid, {@code false} if not + */ + private boolean isValidCause(@Nullable Integer cause) { + return cause == null || (cause >= 0); + } + + /** + * Adds refers to the Id of an event that is considered to be the cause for this event. + * + * @param cause Refers to the Id of an event that is considered to be the cause for this event + * @return this + */ + public EventData withCause(@Nullable Integer cause) { + setCause(cause); + return this; + } + + /** + * Gets actual value (attributeType Actual) of the variable. + * + * @return Actual value (attributeType Actual) of the variable + */ + public String getActualValue() { + return actualValue; + } + + /** + * Sets actual value (attributeType Actual) of the variable. + * + * @param actualValue Actual value (attributeType Actual) of the variable + */ + public void setActualValue(String actualValue) { + if (!isValidActualValue(actualValue)) { + throw new PropertyConstraintException(actualValue, "actualValue is invalid"); + } + this.actualValue = actualValue; + } + + /** + * Returns whether the given actualValue is valid + * + * @param actualValue the actualValue to check the validity of + * @return {@code true} if actualValue is valid, {@code false} if not + */ + private boolean isValidActualValue(String actualValue) { + return actualValue != null && actualValue.length() <= 2500; + } + + /** + * Gets technical (error) code as reported by component. + * + * @return Technical (error) code as reported by component + */ + @Nullable + public String getTechCode() { + return techCode; + } + + /** + * Sets technical (error) code as reported by component. + * + * @param techCode Technical (error) code as reported by component + */ + public void setTechCode(@Nullable String techCode) { + if (!isValidTechCode(techCode)) { + throw new PropertyConstraintException(techCode, "techCode is invalid"); + } + this.techCode = techCode; + } + + /** + * Returns whether the given techCode is valid + * + * @param techCode the techCode to check the validity of + * @return {@code true} if techCode is valid, {@code false} if not + */ + private boolean isValidTechCode(@Nullable String techCode) { + return techCode == null || techCode.length() <= 50; + } + + /** + * Adds technical (error) code as reported by component. + * + * @param techCode Technical (error) code as reported by component + * @return this + */ + public EventData withTechCode(@Nullable String techCode) { + setTechCode(techCode); + return this; + } + + /** + * Gets technical detail information as reported by component. + * + * @return Technical detail information as reported by component + */ + @Nullable + public String getTechInfo() { + return techInfo; + } + + /** + * Sets technical detail information as reported by component. + * + * @param techInfo Technical detail information as reported by component + */ + public void setTechInfo(@Nullable String techInfo) { + if (!isValidTechInfo(techInfo)) { + throw new PropertyConstraintException(techInfo, "techInfo is invalid"); + } + this.techInfo = techInfo; + } + + /** + * Returns whether the given techInfo is valid + * + * @param techInfo the techInfo to check the validity of + * @return {@code true} if techInfo is valid, {@code false} if not + */ + private boolean isValidTechInfo(@Nullable String techInfo) { + return techInfo == null || techInfo.length() <= 500; + } + + /** + * Adds technical detail information as reported by component. + * + * @param techInfo Technical detail information as reported by component + * @return this + */ + public EventData withTechInfo(@Nullable String techInfo) { + setTechInfo(techInfo); + return this; + } + + /** + * Gets cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to + * normal'. + * + * @return Cleared is set to true to report the clearing of a monitored situation, i.e. a 'return + * to normal' + */ + @Nullable + public Boolean getCleared() { + return cleared; + } + + /** + * Sets cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to + * normal'. + * + * @param cleared Cleared is set to true to report the clearing of a monitored situation, i.e. a + * 'return to normal' + */ + public void setCleared(@Nullable Boolean cleared) { + this.cleared = cleared; + } + + /** + * Adds cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to + * normal'. + * + * @param cleared Cleared is set to true to report the clearing of a monitored situation, i.e. a + * 'return to normal' + * @return this + */ + public EventData withCleared(@Nullable Boolean cleared) { + setCleared(cleared); + return this; + } + + /** + * Gets if an event notification is linked to a specific transaction, this field can be used to + * specify its transactionId. + * + * @return If an event notification is linked to a specific transaction, this field can be used to + * specify its transactionId + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets if an event notification is linked to a specific transaction, this field can be used to + * specify its transactionId. + * + * @param transactionId If an event notification is linked to a specific transaction, this field + * can be used to specify its transactionId + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds if an event notification is linked to a specific transaction, this field can be used to + * specify its transactionId. + * + * @param transactionId If an event notification is linked to a specific transaction, this field + * can be used to specify its transactionId + * @return this + */ + public EventData withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets the identifier of the VariableMonitoring which triggered the event. + * + * @return The identifier of the VariableMonitoring which triggered the event + */ + @Nullable + public Integer getVariableMonitoringId() { + return variableMonitoringId; + } + + /** + * Sets the identifier of the VariableMonitoring which triggered the event. + * + * @param variableMonitoringId The identifier of the VariableMonitoring which triggered the event + */ + public void setVariableMonitoringId(@Nullable Integer variableMonitoringId) { + if (!isValidVariableMonitoringId(variableMonitoringId)) { + throw new PropertyConstraintException( + variableMonitoringId, "variableMonitoringId is invalid"); + } + this.variableMonitoringId = variableMonitoringId; + } + + /** + * Returns whether the given variableMonitoringId is valid + * + * @param variableMonitoringId the variableMonitoringId to check the validity of + * @return {@code true} if variableMonitoringId is valid, {@code false} if not + */ + private boolean isValidVariableMonitoringId(@Nullable Integer variableMonitoringId) { + return variableMonitoringId == null || (variableMonitoringId >= 0); + } + + /** + * Adds the identifier of the VariableMonitoring which triggered the event. + * + * @param variableMonitoringId The identifier of the VariableMonitoring which triggered the event + * @return this + */ + public EventData withVariableMonitoringId(@Nullable Integer variableMonitoringId) { + setVariableMonitoringId(variableMonitoringId); + return this; + } + + /** + * Gets specifies the event notification type of the message. + * + * @return Specifies the event notification type of the message + */ + public EventNotificationEnum getEventNotificationType() { + return eventNotificationType; + } + + /** + * Sets specifies the event notification type of the message. + * + * @param eventNotificationType Specifies the event notification type of the message + */ + public void setEventNotificationType(EventNotificationEnum eventNotificationType) { + if (!isValidEventNotificationType(eventNotificationType)) { + throw new PropertyConstraintException( + eventNotificationType, "eventNotificationType is invalid"); + } + this.eventNotificationType = eventNotificationType; + } + + /** + * Returns whether the given eventNotificationType is valid + * + * @param eventNotificationType the eventNotificationType to check the validity of + * @return {@code true} if eventNotificationType is valid, {@code false} if not + */ + private boolean isValidEventNotificationType(EventNotificationEnum eventNotificationType) { + return eventNotificationType != null; + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets severity associated with the monitor in variableMonitoringId or with the hardwired + * notification. + * + * @return Severity associated with the monitor in variableMonitoringId or with the hardwired + * notification + */ + @Nullable + public Integer getSeverity() { + return severity; + } + + /** + * Sets severity associated with the monitor in variableMonitoringId or with the hardwired + * notification. + * + * @param severity Severity associated with the monitor in variableMonitoringId or with the + * hardwired notification + */ + public void setSeverity(@Nullable Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(@Nullable Integer severity) { + return severity == null || (severity >= 0); + } + + /** + * Adds severity associated with the monitor in variableMonitoringId or with the hardwired + * notification. + * + * @param severity Severity associated with the monitor in variableMonitoringId or with the + * hardwired notification + * @return this + */ + public EventData withSeverity(@Nullable Integer severity) { + setSeverity(severity); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EventData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEventId(eventId) + && isValidTimestamp(timestamp) + && isValidTrigger(trigger) + && isValidCause(cause) + && isValidActualValue(actualValue) + && isValidTechCode(techCode) + && isValidTechInfo(techInfo) + && isValidTransactionId(transactionId) + && isValidComponent(component) + && isValidVariableMonitoringId(variableMonitoringId) + && isValidEventNotificationType(eventNotificationType) + && isValidVariable(variable) + && isValidSeverity(severity) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventData that = (EventData) o; + return Objects.equals(eventId, that.eventId) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(trigger, that.trigger) + && Objects.equals(cause, that.cause) + && Objects.equals(actualValue, that.actualValue) + && Objects.equals(techCode, that.techCode) + && Objects.equals(techInfo, that.techInfo) + && Objects.equals(cleared, that.cleared) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(component, that.component) + && Objects.equals(variableMonitoringId, that.variableMonitoringId) + && Objects.equals(eventNotificationType, that.eventNotificationType) + && Objects.equals(variable, that.variable) + && Objects.equals(severity, that.severity) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + eventId, + timestamp, + trigger, + cause, + actualValue, + techCode, + techInfo, + cleared, + transactionId, + component, + variableMonitoringId, + eventNotificationType, + variable, + severity, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("eventId", eventId) + .add("timestamp", timestamp) + .add("trigger", trigger) + .add("cause", cause) + .add("actualValue", actualValue) + .add("techCode", techCode) + .add("techInfo", techInfo) + .add("cleared", cleared) + .add("transactionId", transactionId) + .add("component", component) + .add("variableMonitoringId", variableMonitoringId) + .add("eventNotificationType", eventNotificationType) + .add("variable", variable) + .add("severity", severity) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventNotificationEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventNotificationEnum.java new file mode 100644 index 00000000..a372daeb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventNotificationEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of monitor. */ +public enum EventNotificationEnum { + HardWiredNotification, + HardWiredMonitor, + PreconfiguredMonitor, + CustomMonitor +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventTriggerEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventTriggerEnum.java new file mode 100644 index 00000000..bea6edeb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EventTriggerEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of trigger for this event, e.g. exceeding a threshold value. */ +public enum EventTriggerEnum { + Alerting, + Delta, + Periodic +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EvseKindEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EvseKindEnum.java new file mode 100644 index 00000000..c5a017d7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/EvseKindEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of EVSE (AC, DC) this tariff applies to. */ +public enum EvseKindEnum { + AC, + DC +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Firmware.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Firmware.java new file mode 100644 index 00000000..2bea3144 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Firmware.java @@ -0,0 +1,328 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A copy of the firmware that can be loaded/updated on the Charging Station. */ +public final class Firmware { + /** URI defining the origin of the firmware. */ + private String location; + + /** Date and time at which the firmware shall be retrieved. */ + private ZonedDateTime retrieveDateTime; + + /** Date and time at which the firmware shall be installed. */ + @Nullable private ZonedDateTime installDateTime; + + /** Certificate with which the firmware was signed. PEM encoded X.509 certificate. */ + @Nullable private String signingCertificate; + + /** Base64 encoded firmware signature. */ + @Nullable private String signature; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Firmware class + * + * @param location URI defining the origin of the firmware. + * @param retrieveDateTime Date and time at which the firmware shall be retrieved. + */ + public Firmware(String location, ZonedDateTime retrieveDateTime) { + setLocation(location); + setRetrieveDateTime(retrieveDateTime); + } + + /** + * Gets URI defining the origin of the firmware. + * + * @return URI defining the origin of the firmware + */ + public String getLocation() { + return location; + } + + /** + * Sets URI defining the origin of the firmware. + * + * @param location URI defining the origin of the firmware + */ + public void setLocation(String location) { + if (!isValidLocation(location)) { + throw new PropertyConstraintException(location, "location is invalid"); + } + this.location = location; + } + + /** + * Returns whether the given location is valid + * + * @param location the location to check the validity of + * @return {@code true} if location is valid, {@code false} if not + */ + private boolean isValidLocation(String location) { + return location != null && location.length() <= 2000; + } + + /** + * Gets date and time at which the firmware shall be retrieved. + * + * @return Date and time at which the firmware shall be retrieved + */ + public ZonedDateTime getRetrieveDateTime() { + return retrieveDateTime; + } + + /** + * Sets date and time at which the firmware shall be retrieved. + * + * @param retrieveDateTime Date and time at which the firmware shall be retrieved + */ + public void setRetrieveDateTime(ZonedDateTime retrieveDateTime) { + if (!isValidRetrieveDateTime(retrieveDateTime)) { + throw new PropertyConstraintException(retrieveDateTime, "retrieveDateTime is invalid"); + } + this.retrieveDateTime = retrieveDateTime; + } + + /** + * Returns whether the given retrieveDateTime is valid + * + * @param retrieveDateTime the retrieveDateTime to check the validity of + * @return {@code true} if retrieveDateTime is valid, {@code false} if not + */ + private boolean isValidRetrieveDateTime(ZonedDateTime retrieveDateTime) { + return retrieveDateTime != null; + } + + /** + * Gets date and time at which the firmware shall be installed. + * + * @return Date and time at which the firmware shall be installed + */ + @Nullable + public ZonedDateTime getInstallDateTime() { + return installDateTime; + } + + /** + * Sets date and time at which the firmware shall be installed. + * + * @param installDateTime Date and time at which the firmware shall be installed + */ + public void setInstallDateTime(@Nullable ZonedDateTime installDateTime) { + this.installDateTime = installDateTime; + } + + /** + * Adds date and time at which the firmware shall be installed. + * + * @param installDateTime Date and time at which the firmware shall be installed + * @return this + */ + public Firmware withInstallDateTime(@Nullable ZonedDateTime installDateTime) { + setInstallDateTime(installDateTime); + return this; + } + + /** + * Gets certificate with which the firmware was signed. PEM encoded X.509 certificate. + * + * @return Certificate with which the firmware was signed + */ + @Nullable + public String getSigningCertificate() { + return signingCertificate; + } + + /** + * Sets certificate with which the firmware was signed. PEM encoded X.509 certificate. + * + * @param signingCertificate Certificate with which the firmware was signed + */ + public void setSigningCertificate(@Nullable String signingCertificate) { + if (!isValidSigningCertificate(signingCertificate)) { + throw new PropertyConstraintException(signingCertificate, "signingCertificate is invalid"); + } + this.signingCertificate = signingCertificate; + } + + /** + * Returns whether the given signingCertificate is valid + * + * @param signingCertificate the signingCertificate to check the validity of + * @return {@code true} if signingCertificate is valid, {@code false} if not + */ + private boolean isValidSigningCertificate(@Nullable String signingCertificate) { + return signingCertificate == null || signingCertificate.length() <= 5500; + } + + /** + * Adds certificate with which the firmware was signed. PEM encoded X.509 certificate. + * + * @param signingCertificate Certificate with which the firmware was signed + * @return this + */ + public Firmware withSigningCertificate(@Nullable String signingCertificate) { + setSigningCertificate(signingCertificate); + return this; + } + + /** + * Gets base64 encoded firmware signature. + * + * @return Base64 encoded firmware signature + */ + @Nullable + public String getSignature() { + return signature; + } + + /** + * Sets base64 encoded firmware signature. + * + * @param signature Base64 encoded firmware signature + */ + public void setSignature(@Nullable String signature) { + if (!isValidSignature(signature)) { + throw new PropertyConstraintException(signature, "signature is invalid"); + } + this.signature = signature; + } + + /** + * Returns whether the given signature is valid + * + * @param signature the signature to check the validity of + * @return {@code true} if signature is valid, {@code false} if not + */ + private boolean isValidSignature(@Nullable String signature) { + return signature == null || signature.length() <= 800; + } + + /** + * Adds base64 encoded firmware signature. + * + * @param signature Base64 encoded firmware signature + * @return this + */ + public Firmware withSignature(@Nullable String signature) { + setSignature(signature); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Firmware withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidLocation(location) + && isValidRetrieveDateTime(retrieveDateTime) + && isValidSigningCertificate(signingCertificate) + && isValidSignature(signature) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Firmware that = (Firmware) o; + return Objects.equals(location, that.location) + && Objects.equals(retrieveDateTime, that.retrieveDateTime) + && Objects.equals(installDateTime, that.installDateTime) + && Objects.equals(signingCertificate, that.signingCertificate) + && Objects.equals(signature, that.signature) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + location, retrieveDateTime, installDateTime, signingCertificate, signature, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("location", location) + .add("retrieveDateTime", retrieveDateTime) + .add("installDateTime", installDateTime) + .add("signingCertificate", signingCertificate) + .add("signature", signature) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FirmwareStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FirmwareStatusEnum.java new file mode 100644 index 00000000..4fca6e99 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FirmwareStatusEnum.java @@ -0,0 +1,43 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The progress status of the firmware installation. */ +public enum FirmwareStatusEnum { + Downloaded, + DownloadFailed, + Downloading, + DownloadScheduled, + DownloadPaused, + Idle, + InstallationFailed, + Installing, + Installed, + InstallRebooting, + InstallScheduled, + InstallVerificationFailed, + InvalidSignature, + SignatureVerified +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedPF.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedPF.java new file mode 100644 index 00000000..074bf23d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedPF.java @@ -0,0 +1,311 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** FixedPFType */ +public final class FixedPF { + /** Priority of setting (0=highest) */ + private Integer priority; + + /** Power factor, cos(phi), as value between 0..1. */ + private Double displacement; + + /** + * True when absorbing reactive power (under-excited), false when injecting reactive power + * (over-excited). + */ + private Boolean excitation; + + /** Time when this setting becomes active */ + @Nullable private ZonedDateTime startTime; + + /** Duration in seconds that this setting is active. */ + @Nullable private Double duration; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the FixedPF class + * + * @param priority Priority of setting (0=highest) + * @param displacement Power factor, cos(phi), as value between 0..1. + * @param excitation True when absorbing reactive power (under-excited), false when injecting + * reactive power (over-excited). + */ + public FixedPF(Integer priority, Double displacement, Boolean excitation) { + setPriority(priority); + setDisplacement(displacement); + setExcitation(excitation); + } + + /** + * Gets priority of setting (0=highest) + * + * @return Priority of setting (0=highest) + */ + public Integer getPriority() { + return priority; + } + + /** + * Sets priority of setting (0=highest) + * + * @param priority Priority of setting (0=highest) + */ + public void setPriority(Integer priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(Integer priority) { + return priority != null && priority >= 0; + } + + /** + * Gets power factor, cos(phi), as value between 0..1. + * + * @return Power factor, cos(phi), as value between 0..1 + */ + public Double getDisplacement() { + return displacement; + } + + /** + * Sets power factor, cos(phi), as value between 0..1. + * + * @param displacement Power factor, cos(phi), as value between 0..1 + */ + public void setDisplacement(Double displacement) { + if (!isValidDisplacement(displacement)) { + throw new PropertyConstraintException(displacement, "displacement is invalid"); + } + this.displacement = displacement; + } + + /** + * Returns whether the given displacement is valid + * + * @param displacement the displacement to check the validity of + * @return {@code true} if displacement is valid, {@code false} if not + */ + private boolean isValidDisplacement(Double displacement) { + return displacement != null; + } + + /** + * Gets true when absorbing reactive power (under-excited), false when injecting reactive power + * (over-excited). + * + * @return True when absorbing reactive power (under-excited), false when injecting reactive power + * (over-excited) + */ + public Boolean getExcitation() { + return excitation; + } + + /** + * Sets true when absorbing reactive power (under-excited), false when injecting reactive power + * (over-excited). + * + * @param excitation True when absorbing reactive power (under-excited), false when injecting + * reactive power (over-excited) + */ + public void setExcitation(Boolean excitation) { + if (!isValidExcitation(excitation)) { + throw new PropertyConstraintException(excitation, "excitation is invalid"); + } + this.excitation = excitation; + } + + /** + * Returns whether the given excitation is valid + * + * @param excitation the excitation to check the validity of + * @return {@code true} if excitation is valid, {@code false} if not + */ + private boolean isValidExcitation(Boolean excitation) { + return excitation != null; + } + + /** + * Gets time when this setting becomes active + * + * @return Time when this setting becomes active + */ + @Nullable + public ZonedDateTime getStartTime() { + return startTime; + } + + /** + * Sets time when this setting becomes active + * + * @param startTime Time when this setting becomes active + */ + public void setStartTime(@Nullable ZonedDateTime startTime) { + this.startTime = startTime; + } + + /** + * Adds time when this setting becomes active + * + * @param startTime Time when this setting becomes active + * @return this + */ + public FixedPF withStartTime(@Nullable ZonedDateTime startTime) { + setStartTime(startTime); + return this; + } + + /** + * Gets duration in seconds that this setting is active. + * + * @return Duration in seconds that this setting is active + */ + @Nullable + public Double getDuration() { + return duration; + } + + /** + * Sets duration in seconds that this setting is active. + * + * @param duration Duration in seconds that this setting is active + */ + public void setDuration(@Nullable Double duration) { + this.duration = duration; + } + + /** + * Adds duration in seconds that this setting is active. + * + * @param duration Duration in seconds that this setting is active + * @return this + */ + public FixedPF withDuration(@Nullable Double duration) { + setDuration(duration); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FixedPF withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriority(priority) + && isValidDisplacement(displacement) + && isValidExcitation(excitation) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FixedPF that = (FixedPF) o; + return Objects.equals(priority, that.priority) + && Objects.equals(displacement, that.displacement) + && Objects.equals(excitation, that.excitation) + && Objects.equals(startTime, that.startTime) + && Objects.equals(duration, that.duration) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(priority, displacement, excitation, startTime, duration, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priority", priority) + .add("displacement", displacement) + .add("excitation", excitation) + .add("startTime", startTime) + .add("duration", duration) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedPFGet.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedPFGet.java new file mode 100644 index 00000000..07fbf70b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedPFGet.java @@ -0,0 +1,271 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** FixedPFGetType */ +public final class FixedPFGet { + /** fixedPF */ + private FixedPF fixedPF; + + /** Id of setting. */ + private String id; + + /** True if setting is a default control. */ + private Boolean isDefault; + + /** True if this setting is superseded by a lower priority setting. */ + private Boolean isSuperseded; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the FixedPFGet class + * + * @param fixedPF fixedPF + * @param id Id of setting. + * @param isDefault True if setting is a default control. + * @param isSuperseded True if this setting is superseded by a lower priority setting. + */ + public FixedPFGet(FixedPF fixedPF, String id, Boolean isDefault, Boolean isSuperseded) { + setFixedPF(fixedPF); + setId(id); + setIsDefault(isDefault); + setIsSuperseded(isSuperseded); + } + + /** + * Gets fixedPF + * + * @return fixedPF + */ + public FixedPF getFixedPF() { + return fixedPF; + } + + /** + * Sets fixedPF + * + * @param fixedPF fixedPF + */ + public void setFixedPF(FixedPF fixedPF) { + if (!isValidFixedPF(fixedPF)) { + throw new PropertyConstraintException(fixedPF, "fixedPF is invalid"); + } + this.fixedPF = fixedPF; + } + + /** + * Returns whether the given fixedPF is valid + * + * @param fixedPF the fixedPF to check the validity of + * @return {@code true} if fixedPF is valid, {@code false} if not + */ + private boolean isValidFixedPF(FixedPF fixedPF) { + return fixedPF != null && fixedPF.validate(); + } + + /** + * Gets id of setting. + * + * @return Id of setting + */ + public String getId() { + return id; + } + + /** + * Sets id of setting. + * + * @param id Id of setting + */ + public void setId(String id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(String id) { + return id != null && id.length() <= 36; + } + + /** + * Gets true if setting is a default control. + * + * @return True if setting is a default control + */ + public Boolean getIsDefault() { + return isDefault; + } + + /** + * Sets true if setting is a default control. + * + * @param isDefault True if setting is a default control + */ + public void setIsDefault(Boolean isDefault) { + if (!isValidIsDefault(isDefault)) { + throw new PropertyConstraintException(isDefault, "isDefault is invalid"); + } + this.isDefault = isDefault; + } + + /** + * Returns whether the given isDefault is valid + * + * @param isDefault the isDefault to check the validity of + * @return {@code true} if isDefault is valid, {@code false} if not + */ + private boolean isValidIsDefault(Boolean isDefault) { + return isDefault != null; + } + + /** + * Gets true if this setting is superseded by a lower priority setting. + * + * @return True if this setting is superseded by a lower priority setting + */ + public Boolean getIsSuperseded() { + return isSuperseded; + } + + /** + * Sets true if this setting is superseded by a lower priority setting. + * + * @param isSuperseded True if this setting is superseded by a lower priority setting + */ + public void setIsSuperseded(Boolean isSuperseded) { + if (!isValidIsSuperseded(isSuperseded)) { + throw new PropertyConstraintException(isSuperseded, "isSuperseded is invalid"); + } + this.isSuperseded = isSuperseded; + } + + /** + * Returns whether the given isSuperseded is valid + * + * @param isSuperseded the isSuperseded to check the validity of + * @return {@code true} if isSuperseded is valid, {@code false} if not + */ + private boolean isValidIsSuperseded(Boolean isSuperseded) { + return isSuperseded != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FixedPFGet withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidFixedPF(fixedPF) + && isValidId(id) + && isValidIsDefault(isDefault) + && isValidIsSuperseded(isSuperseded) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FixedPFGet that = (FixedPFGet) o; + return Objects.equals(fixedPF, that.fixedPF) + && Objects.equals(id, that.id) + && Objects.equals(isDefault, that.isDefault) + && Objects.equals(isSuperseded, that.isSuperseded) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(fixedPF, id, isDefault, isSuperseded, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("fixedPF", fixedPF) + .add("id", id) + .add("isDefault", isDefault) + .add("isSuperseded", isSuperseded) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedVar.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedVar.java new file mode 100644 index 00000000..685ca599 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedVar.java @@ -0,0 +1,315 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** FixedVarType */ +public final class FixedVar { + /** Priority of setting (0=highest) */ + private Integer priority; + + /** + * The value specifies a target var output interpreted as a signed percentage (-100 to 100). A + * negative value refers to charging, whereas a positive one refers to discharging. The value type + * is determined by the unit field. + */ + private Double setpoint; + + /** Unit of the setpoint. */ + private DERUnitEnum unit; + + /** Time when this setting becomes active. */ + @Nullable private ZonedDateTime startTime; + + /** Duration in seconds that this setting is active. */ + @Nullable private Double duration; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the FixedVar class + * + * @param priority Priority of setting (0=highest) + * @param setpoint The value specifies a target var output interpreted as a signed percentage + * (-100 to 100). A negative value refers to charging, whereas a positive one refers to + * discharging. The value type is determined by the unit field. + * @param unit Unit of the setpoint. + */ + public FixedVar(Integer priority, Double setpoint, DERUnitEnum unit) { + setPriority(priority); + setSetpoint(setpoint); + setUnit(unit); + } + + /** + * Gets priority of setting (0=highest) + * + * @return Priority of setting (0=highest) + */ + public Integer getPriority() { + return priority; + } + + /** + * Sets priority of setting (0=highest) + * + * @param priority Priority of setting (0=highest) + */ + public void setPriority(Integer priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(Integer priority) { + return priority != null && priority >= 0; + } + + /** + * Gets the value specifies a target var output interpreted as a signed percentage (-100 to 100). + * A negative value refers to charging, whereas a positive one refers to discharging. The value + * type is determined by the unit field. + * + * @return The value specifies a target var output interpreted as a signed percentage (-100 to + * 100) + */ + public Double getSetpoint() { + return setpoint; + } + + /** + * Sets the value specifies a target var output interpreted as a signed percentage (-100 to 100). + * A negative value refers to charging, whereas a positive one refers to discharging. The value + * type is determined by the unit field. + * + * @param setpoint The value specifies a target var output interpreted as a signed percentage + * (-100 to 100) + */ + public void setSetpoint(Double setpoint) { + if (!isValidSetpoint(setpoint)) { + throw new PropertyConstraintException(setpoint, "setpoint is invalid"); + } + this.setpoint = setpoint; + } + + /** + * Returns whether the given setpoint is valid + * + * @param setpoint the setpoint to check the validity of + * @return {@code true} if setpoint is valid, {@code false} if not + */ + private boolean isValidSetpoint(Double setpoint) { + return setpoint != null; + } + + /** + * Gets unit of the setpoint. + * + * @return Unit of the setpoint + */ + public DERUnitEnum getUnit() { + return unit; + } + + /** + * Sets unit of the setpoint. + * + * @param unit Unit of the setpoint + */ + public void setUnit(DERUnitEnum unit) { + if (!isValidUnit(unit)) { + throw new PropertyConstraintException(unit, "unit is invalid"); + } + this.unit = unit; + } + + /** + * Returns whether the given unit is valid + * + * @param unit the unit to check the validity of + * @return {@code true} if unit is valid, {@code false} if not + */ + private boolean isValidUnit(DERUnitEnum unit) { + return unit != null; + } + + /** + * Gets time when this setting becomes active. + * + * @return Time when this setting becomes active + */ + @Nullable + public ZonedDateTime getStartTime() { + return startTime; + } + + /** + * Sets time when this setting becomes active. + * + * @param startTime Time when this setting becomes active + */ + public void setStartTime(@Nullable ZonedDateTime startTime) { + this.startTime = startTime; + } + + /** + * Adds time when this setting becomes active. + * + * @param startTime Time when this setting becomes active + * @return this + */ + public FixedVar withStartTime(@Nullable ZonedDateTime startTime) { + setStartTime(startTime); + return this; + } + + /** + * Gets duration in seconds that this setting is active. + * + * @return Duration in seconds that this setting is active + */ + @Nullable + public Double getDuration() { + return duration; + } + + /** + * Sets duration in seconds that this setting is active. + * + * @param duration Duration in seconds that this setting is active + */ + public void setDuration(@Nullable Double duration) { + this.duration = duration; + } + + /** + * Adds duration in seconds that this setting is active. + * + * @param duration Duration in seconds that this setting is active + * @return this + */ + public FixedVar withDuration(@Nullable Double duration) { + setDuration(duration); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FixedVar withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriority(priority) + && isValidSetpoint(setpoint) + && isValidUnit(unit) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FixedVar that = (FixedVar) o; + return Objects.equals(priority, that.priority) + && Objects.equals(setpoint, that.setpoint) + && Objects.equals(unit, that.unit) + && Objects.equals(startTime, that.startTime) + && Objects.equals(duration, that.duration) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(priority, setpoint, unit, startTime, duration, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priority", priority) + .add("setpoint", setpoint) + .add("unit", unit) + .add("startTime", startTime) + .add("duration", duration) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedVarGet.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedVarGet.java new file mode 100644 index 00000000..454378f2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FixedVarGet.java @@ -0,0 +1,271 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** FixedVarGetType */ +public final class FixedVarGet { + /** fixedVar */ + private FixedVar fixedVar; + + /** Id of setting */ + private String id; + + /** True if setting is a default control. */ + private Boolean isDefault; + + /** True if this setting is superseded by a lower priority setting */ + private Boolean isSuperseded; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the FixedVarGet class + * + * @param fixedVar fixedVar + * @param id Id of setting + * @param isDefault True if setting is a default control. + * @param isSuperseded True if this setting is superseded by a lower priority setting + */ + public FixedVarGet(FixedVar fixedVar, String id, Boolean isDefault, Boolean isSuperseded) { + setFixedVar(fixedVar); + setId(id); + setIsDefault(isDefault); + setIsSuperseded(isSuperseded); + } + + /** + * Gets fixedVar + * + * @return fixedVar + */ + public FixedVar getFixedVar() { + return fixedVar; + } + + /** + * Sets fixedVar + * + * @param fixedVar fixedVar + */ + public void setFixedVar(FixedVar fixedVar) { + if (!isValidFixedVar(fixedVar)) { + throw new PropertyConstraintException(fixedVar, "fixedVar is invalid"); + } + this.fixedVar = fixedVar; + } + + /** + * Returns whether the given fixedVar is valid + * + * @param fixedVar the fixedVar to check the validity of + * @return {@code true} if fixedVar is valid, {@code false} if not + */ + private boolean isValidFixedVar(FixedVar fixedVar) { + return fixedVar != null && fixedVar.validate(); + } + + /** + * Gets id of setting + * + * @return Id of setting + */ + public String getId() { + return id; + } + + /** + * Sets id of setting + * + * @param id Id of setting + */ + public void setId(String id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(String id) { + return id != null && id.length() <= 36; + } + + /** + * Gets true if setting is a default control. + * + * @return True if setting is a default control + */ + public Boolean getIsDefault() { + return isDefault; + } + + /** + * Sets true if setting is a default control. + * + * @param isDefault True if setting is a default control + */ + public void setIsDefault(Boolean isDefault) { + if (!isValidIsDefault(isDefault)) { + throw new PropertyConstraintException(isDefault, "isDefault is invalid"); + } + this.isDefault = isDefault; + } + + /** + * Returns whether the given isDefault is valid + * + * @param isDefault the isDefault to check the validity of + * @return {@code true} if isDefault is valid, {@code false} if not + */ + private boolean isValidIsDefault(Boolean isDefault) { + return isDefault != null; + } + + /** + * Gets true if this setting is superseded by a lower priority setting + * + * @return True if this setting is superseded by a lower priority setting + */ + public Boolean getIsSuperseded() { + return isSuperseded; + } + + /** + * Sets true if this setting is superseded by a lower priority setting + * + * @param isSuperseded True if this setting is superseded by a lower priority setting + */ + public void setIsSuperseded(Boolean isSuperseded) { + if (!isValidIsSuperseded(isSuperseded)) { + throw new PropertyConstraintException(isSuperseded, "isSuperseded is invalid"); + } + this.isSuperseded = isSuperseded; + } + + /** + * Returns whether the given isSuperseded is valid + * + * @param isSuperseded the isSuperseded to check the validity of + * @return {@code true} if isSuperseded is valid, {@code false} if not + */ + private boolean isValidIsSuperseded(Boolean isSuperseded) { + return isSuperseded != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FixedVarGet withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidFixedVar(fixedVar) + && isValidId(id) + && isValidIsDefault(isDefault) + && isValidIsSuperseded(isSuperseded) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FixedVarGet that = (FixedVarGet) o; + return Objects.equals(fixedVar, that.fixedVar) + && Objects.equals(id, that.id) + && Objects.equals(isDefault, that.isDefault) + && Objects.equals(isSuperseded, that.isSuperseded) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(fixedVar, id, isDefault, isSuperseded, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("fixedVar", fixedVar) + .add("id", id) + .add("isDefault", isDefault) + .add("isSuperseded", isSuperseded) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FreqDroop.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FreqDroop.java new file mode 100644 index 00000000..569e3463 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FreqDroop.java @@ -0,0 +1,435 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** FreqDroopType */ +public final class FreqDroop { + /** Priority of setting (0=highest) */ + private Integer priority; + + /** Over-frequency start of droop */ + private Double overFreq; + + /** Under-frequency start of droop */ + private Double underFreq; + + /** Over-frequency droop per unit, oFDroop */ + private Double overDroop; + + /** Under-frequency droop per unit, uFDroop */ + private Double underDroop; + + /** Open loop response time in seconds */ + private Double responseTime; + + /** Time when this setting becomes active */ + @Nullable private ZonedDateTime startTime; + + /** Duration in seconds that this setting is active */ + @Nullable private Double duration; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the FreqDroop class + * + * @param priority Priority of setting (0=highest) + * @param overFreq Over-frequency start of droop + * @param underFreq Under-frequency start of droop + * @param overDroop Over-frequency droop per unit, oFDroop + * @param underDroop Under-frequency droop per unit, uFDroop + * @param responseTime Open loop response time in seconds + */ + public FreqDroop( + Integer priority, + Double overFreq, + Double underFreq, + Double overDroop, + Double underDroop, + Double responseTime) { + setPriority(priority); + setOverFreq(overFreq); + setUnderFreq(underFreq); + setOverDroop(overDroop); + setUnderDroop(underDroop); + setResponseTime(responseTime); + } + + /** + * Gets priority of setting (0=highest) + * + * @return Priority of setting (0=highest) + */ + public Integer getPriority() { + return priority; + } + + /** + * Sets priority of setting (0=highest) + * + * @param priority Priority of setting (0=highest) + */ + public void setPriority(Integer priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(Integer priority) { + return priority != null && priority >= 0; + } + + /** + * Gets over-frequency start of droop + * + * @return Over-frequency start of droop + */ + public Double getOverFreq() { + return overFreq; + } + + /** + * Sets over-frequency start of droop + * + * @param overFreq Over-frequency start of droop + */ + public void setOverFreq(Double overFreq) { + if (!isValidOverFreq(overFreq)) { + throw new PropertyConstraintException(overFreq, "overFreq is invalid"); + } + this.overFreq = overFreq; + } + + /** + * Returns whether the given overFreq is valid + * + * @param overFreq the overFreq to check the validity of + * @return {@code true} if overFreq is valid, {@code false} if not + */ + private boolean isValidOverFreq(Double overFreq) { + return overFreq != null; + } + + /** + * Gets under-frequency start of droop + * + * @return Under-frequency start of droop + */ + public Double getUnderFreq() { + return underFreq; + } + + /** + * Sets under-frequency start of droop + * + * @param underFreq Under-frequency start of droop + */ + public void setUnderFreq(Double underFreq) { + if (!isValidUnderFreq(underFreq)) { + throw new PropertyConstraintException(underFreq, "underFreq is invalid"); + } + this.underFreq = underFreq; + } + + /** + * Returns whether the given underFreq is valid + * + * @param underFreq the underFreq to check the validity of + * @return {@code true} if underFreq is valid, {@code false} if not + */ + private boolean isValidUnderFreq(Double underFreq) { + return underFreq != null; + } + + /** + * Gets over-frequency droop per unit, oFDroop + * + * @return Over-frequency droop per unit, oFDroop + */ + public Double getOverDroop() { + return overDroop; + } + + /** + * Sets over-frequency droop per unit, oFDroop + * + * @param overDroop Over-frequency droop per unit, oFDroop + */ + public void setOverDroop(Double overDroop) { + if (!isValidOverDroop(overDroop)) { + throw new PropertyConstraintException(overDroop, "overDroop is invalid"); + } + this.overDroop = overDroop; + } + + /** + * Returns whether the given overDroop is valid + * + * @param overDroop the overDroop to check the validity of + * @return {@code true} if overDroop is valid, {@code false} if not + */ + private boolean isValidOverDroop(Double overDroop) { + return overDroop != null; + } + + /** + * Gets under-frequency droop per unit, uFDroop + * + * @return Under-frequency droop per unit, uFDroop + */ + public Double getUnderDroop() { + return underDroop; + } + + /** + * Sets under-frequency droop per unit, uFDroop + * + * @param underDroop Under-frequency droop per unit, uFDroop + */ + public void setUnderDroop(Double underDroop) { + if (!isValidUnderDroop(underDroop)) { + throw new PropertyConstraintException(underDroop, "underDroop is invalid"); + } + this.underDroop = underDroop; + } + + /** + * Returns whether the given underDroop is valid + * + * @param underDroop the underDroop to check the validity of + * @return {@code true} if underDroop is valid, {@code false} if not + */ + private boolean isValidUnderDroop(Double underDroop) { + return underDroop != null; + } + + /** + * Gets open loop response time in seconds + * + * @return Open loop response time in seconds + */ + public Double getResponseTime() { + return responseTime; + } + + /** + * Sets open loop response time in seconds + * + * @param responseTime Open loop response time in seconds + */ + public void setResponseTime(Double responseTime) { + if (!isValidResponseTime(responseTime)) { + throw new PropertyConstraintException(responseTime, "responseTime is invalid"); + } + this.responseTime = responseTime; + } + + /** + * Returns whether the given responseTime is valid + * + * @param responseTime the responseTime to check the validity of + * @return {@code true} if responseTime is valid, {@code false} if not + */ + private boolean isValidResponseTime(Double responseTime) { + return responseTime != null; + } + + /** + * Gets time when this setting becomes active + * + * @return Time when this setting becomes active + */ + @Nullable + public ZonedDateTime getStartTime() { + return startTime; + } + + /** + * Sets time when this setting becomes active + * + * @param startTime Time when this setting becomes active + */ + public void setStartTime(@Nullable ZonedDateTime startTime) { + this.startTime = startTime; + } + + /** + * Adds time when this setting becomes active + * + * @param startTime Time when this setting becomes active + * @return this + */ + public FreqDroop withStartTime(@Nullable ZonedDateTime startTime) { + setStartTime(startTime); + return this; + } + + /** + * Gets duration in seconds that this setting is active + * + * @return Duration in seconds that this setting is active + */ + @Nullable + public Double getDuration() { + return duration; + } + + /** + * Sets duration in seconds that this setting is active + * + * @param duration Duration in seconds that this setting is active + */ + public void setDuration(@Nullable Double duration) { + this.duration = duration; + } + + /** + * Adds duration in seconds that this setting is active + * + * @param duration Duration in seconds that this setting is active + * @return this + */ + public FreqDroop withDuration(@Nullable Double duration) { + setDuration(duration); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FreqDroop withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriority(priority) + && isValidOverFreq(overFreq) + && isValidUnderFreq(underFreq) + && isValidOverDroop(overDroop) + && isValidUnderDroop(underDroop) + && isValidResponseTime(responseTime) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FreqDroop that = (FreqDroop) o; + return Objects.equals(priority, that.priority) + && Objects.equals(overFreq, that.overFreq) + && Objects.equals(underFreq, that.underFreq) + && Objects.equals(overDroop, that.overDroop) + && Objects.equals(underDroop, that.underDroop) + && Objects.equals(responseTime, that.responseTime) + && Objects.equals(startTime, that.startTime) + && Objects.equals(duration, that.duration) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + priority, + overFreq, + underFreq, + overDroop, + underDroop, + responseTime, + startTime, + duration, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priority", priority) + .add("overFreq", overFreq) + .add("underFreq", underFreq) + .add("overDroop", overDroop) + .add("underDroop", underDroop) + .add("responseTime", responseTime) + .add("startTime", startTime) + .add("duration", duration) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FreqDroopGet.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FreqDroopGet.java new file mode 100644 index 00000000..cb632491 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/FreqDroopGet.java @@ -0,0 +1,278 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** FreqDroopGetType */ +public final class FreqDroopGet { + /** freqDroop */ + private FreqDroop freqDroop; + + /** Id of setting */ + private String id; + + /** True if setting is a default control. */ + private Boolean isDefault; + + /** + * True if this setting is superseded by a higher priority setting (i.e. lower value of priority) + */ + private Boolean isSuperseded; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the FreqDroopGet class + * + * @param freqDroop freqDroop + * @param id Id of setting + * @param isDefault True if setting is a default control. + * @param isSuperseded True if this setting is superseded by a higher priority setting (i.e. lower + * value of priority) + */ + public FreqDroopGet(FreqDroop freqDroop, String id, Boolean isDefault, Boolean isSuperseded) { + setFreqDroop(freqDroop); + setId(id); + setIsDefault(isDefault); + setIsSuperseded(isSuperseded); + } + + /** + * Gets freqDroop + * + * @return freqDroop + */ + public FreqDroop getFreqDroop() { + return freqDroop; + } + + /** + * Sets freqDroop + * + * @param freqDroop freqDroop + */ + public void setFreqDroop(FreqDroop freqDroop) { + if (!isValidFreqDroop(freqDroop)) { + throw new PropertyConstraintException(freqDroop, "freqDroop is invalid"); + } + this.freqDroop = freqDroop; + } + + /** + * Returns whether the given freqDroop is valid + * + * @param freqDroop the freqDroop to check the validity of + * @return {@code true} if freqDroop is valid, {@code false} if not + */ + private boolean isValidFreqDroop(FreqDroop freqDroop) { + return freqDroop != null && freqDroop.validate(); + } + + /** + * Gets id of setting + * + * @return Id of setting + */ + public String getId() { + return id; + } + + /** + * Sets id of setting + * + * @param id Id of setting + */ + public void setId(String id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(String id) { + return id != null && id.length() <= 36; + } + + /** + * Gets true if setting is a default control. + * + * @return True if setting is a default control + */ + public Boolean getIsDefault() { + return isDefault; + } + + /** + * Sets true if setting is a default control. + * + * @param isDefault True if setting is a default control + */ + public void setIsDefault(Boolean isDefault) { + if (!isValidIsDefault(isDefault)) { + throw new PropertyConstraintException(isDefault, "isDefault is invalid"); + } + this.isDefault = isDefault; + } + + /** + * Returns whether the given isDefault is valid + * + * @param isDefault the isDefault to check the validity of + * @return {@code true} if isDefault is valid, {@code false} if not + */ + private boolean isValidIsDefault(Boolean isDefault) { + return isDefault != null; + } + + /** + * Gets true if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + * + * @return True if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + */ + public Boolean getIsSuperseded() { + return isSuperseded; + } + + /** + * Sets true if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + * + * @param isSuperseded True if this setting is superseded by a higher priority setting (i.e. lower + * value of priority) + */ + public void setIsSuperseded(Boolean isSuperseded) { + if (!isValidIsSuperseded(isSuperseded)) { + throw new PropertyConstraintException(isSuperseded, "isSuperseded is invalid"); + } + this.isSuperseded = isSuperseded; + } + + /** + * Returns whether the given isSuperseded is valid + * + * @param isSuperseded the isSuperseded to check the validity of + * @return {@code true} if isSuperseded is valid, {@code false} if not + */ + private boolean isValidIsSuperseded(Boolean isSuperseded) { + return isSuperseded != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FreqDroopGet withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidFreqDroop(freqDroop) + && isValidId(id) + && isValidIsDefault(isDefault) + && isValidIsSuperseded(isSuperseded) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FreqDroopGet that = (FreqDroopGet) o; + return Objects.equals(freqDroop, that.freqDroop) + && Objects.equals(id, that.id) + && Objects.equals(isDefault, that.isDefault) + && Objects.equals(isSuperseded, that.isSuperseded) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(freqDroop, id, isDefault, isSuperseded, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("freqDroop", freqDroop) + .add("id", id) + .add("isDefault", isDefault) + .add("isSuperseded", isSuperseded) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GenericDeviceModelStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GenericDeviceModelStatusEnum.java new file mode 100644 index 00000000..363a7d2c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GenericDeviceModelStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Charging Station was able to accept the request. */ +public enum GenericDeviceModelStatusEnum { + Accepted, + Rejected, + NotSupported, + EmptyResultSet +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GenericStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GenericStatusEnum.java new file mode 100644 index 00000000..da5f5aa4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GenericStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Result of operation. */ +public enum GenericStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetCertificateIdUseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetCertificateIdUseEnum.java new file mode 100644 index 00000000..9d346536 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetCertificateIdUseEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The type of the requested certificate(s). */ +public enum GetCertificateIdUseEnum { + V2GRootCertificate, + MORootCertificate, + CSMSRootCertificate, + V2GCertificateChain, + ManufacturerRootCertificate, + OEMRootCertificate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetCertificateStatusEnum.java new file mode 100644 index 00000000..496692b3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetCertificateStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the charging station was able to retrieve the OCSP certificate status. */ +public enum GetCertificateStatusEnum { + Accepted, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetChargingProfileStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetChargingProfileStatusEnum.java new file mode 100644 index 00000000..2a48d96b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetChargingProfileStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + */ +public enum GetChargingProfileStatusEnum { + Accepted, + NoProfiles +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetDisplayMessagesStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetDisplayMessagesStatusEnum.java new file mode 100644 index 00000000..6d3828d8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetDisplayMessagesStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Whether the Charging Station has Display Messages that match the request criteria in the + * GetDisplayMessagesRequest + */ +public enum GetDisplayMessagesStatusEnum { + Accepted, + Unknown +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetInstalledCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetInstalledCertificateStatusEnum.java new file mode 100644 index 00000000..23ef87d8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetInstalledCertificateStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Charging Station indicates if it can process the request. */ +public enum GetInstalledCertificateStatusEnum { + Accepted, + NotFound +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableData.java new file mode 100644 index 00000000..1aaf76fe --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableData.java @@ -0,0 +1,227 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold parameters for GetVariables request. */ +public final class GetVariableData { + /** Attribute type for which value is requested. When absent, default Actual is assumed. */ + @Nullable private AttributeEnum attributeType; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetVariableData class + * + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public GetVariableData(Component component, Variable variable) { + setComponent(component); + setVariable(variable); + } + + /** + * Gets attribute type for which value is requested. When absent, default Actual is assumed. + * + * @return Attribute type for which value is requested + */ + public AttributeEnum getAttributeType() { + return attributeType != null ? attributeType : AttributeEnum.Actual; + } + + /** + * Sets attribute type for which value is requested. When absent, default Actual is assumed. + * + * @param attributeType Attribute type for which value is requested + */ + public void setAttributeType(@Nullable AttributeEnum attributeType) { + this.attributeType = attributeType; + } + + /** + * Adds attribute type for which value is requested. When absent, default Actual is assumed. + * + * @param attributeType Attribute type for which value is requested + * @return this + */ + public GetVariableData withAttributeType(@Nullable AttributeEnum attributeType) { + setAttributeType(attributeType); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetVariableData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidComponent(component) + && isValidVariable(variable) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetVariableData that = (GetVariableData) o; + return Objects.equals(attributeType, that.attributeType) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(attributeType, component, variable, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("attributeType", attributeType) + .add("component", component) + .add("variable", variable) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableResult.java new file mode 100644 index 00000000..a5b909d7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableResult.java @@ -0,0 +1,386 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold results of GetVariables request. */ +public final class GetVariableResult { + /** attributeStatus */ + private GetVariableStatusEnum attributeStatus; + + /** More information about the status. */ + @Nullable private StatusInfo attributeStatusInfo; + + /** attributeType */ + @Nullable private AttributeEnum attributeType; + + /** + * Value of requested attribute type of component-variable. This field can only be empty when the + * given status is NOT accepted. + * + *

The Configuration Variable ReportingValueSize can be used to limit + * GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max + * size of these values will always remain equal. + */ + @Nullable private String attributeValue; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GetVariableResult class + * + * @param attributeStatus attributeStatus + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public GetVariableResult( + GetVariableStatusEnum attributeStatus, Component component, Variable variable) { + setAttributeStatus(attributeStatus); + setComponent(component); + setVariable(variable); + } + + /** + * Gets attributeStatus + * + * @return attributeStatus + */ + public GetVariableStatusEnum getAttributeStatus() { + return attributeStatus; + } + + /** + * Sets attributeStatus + * + * @param attributeStatus attributeStatus + */ + public void setAttributeStatus(GetVariableStatusEnum attributeStatus) { + if (!isValidAttributeStatus(attributeStatus)) { + throw new PropertyConstraintException(attributeStatus, "attributeStatus is invalid"); + } + this.attributeStatus = attributeStatus; + } + + /** + * Returns whether the given attributeStatus is valid + * + * @param attributeStatus the attributeStatus to check the validity of + * @return {@code true} if attributeStatus is valid, {@code false} if not + */ + private boolean isValidAttributeStatus(GetVariableStatusEnum attributeStatus) { + return attributeStatus != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getAttributeStatusInfo() { + return attributeStatusInfo; + } + + /** + * Sets more information about the status. + * + * @param attributeStatusInfo More information about the status + */ + public void setAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + if (!isValidAttributeStatusInfo(attributeStatusInfo)) { + throw new PropertyConstraintException(attributeStatusInfo, "attributeStatusInfo is invalid"); + } + this.attributeStatusInfo = attributeStatusInfo; + } + + /** + * Returns whether the given attributeStatusInfo is valid + * + * @param attributeStatusInfo the attributeStatusInfo to check the validity of + * @return {@code true} if attributeStatusInfo is valid, {@code false} if not + */ + private boolean isValidAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + return attributeStatusInfo == null || attributeStatusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param attributeStatusInfo More information about the status + * @return this + */ + public GetVariableResult withAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + setAttributeStatusInfo(attributeStatusInfo); + return this; + } + + /** + * Gets attributeType + * + * @return attributeType + */ + public AttributeEnum getAttributeType() { + return attributeType != null ? attributeType : AttributeEnum.Actual; + } + + /** + * Sets attributeType + * + * @param attributeType attributeType + */ + public void setAttributeType(@Nullable AttributeEnum attributeType) { + this.attributeType = attributeType; + } + + /** + * Adds attributeType + * + * @param attributeType attributeType + * @return this + */ + public GetVariableResult withAttributeType(@Nullable AttributeEnum attributeType) { + setAttributeType(attributeType); + return this; + } + + /** + * Gets value of requested attribute type of component-variable. This field can only be empty when + * the given status is NOT accepted. + * + * @return Value of requested attribute type of component-variable + */ + @Nullable + public String getAttributeValue() { + return attributeValue; + } + + /** + * Sets value of requested attribute type of component-variable. This field can only be empty when + * the given status is NOT accepted. + * + * @param attributeValue Value of requested attribute type of component-variable + */ + public void setAttributeValue(@Nullable String attributeValue) { + if (!isValidAttributeValue(attributeValue)) { + throw new PropertyConstraintException(attributeValue, "attributeValue is invalid"); + } + this.attributeValue = attributeValue; + } + + /** + * Returns whether the given attributeValue is valid + * + * @param attributeValue the attributeValue to check the validity of + * @return {@code true} if attributeValue is valid, {@code false} if not + */ + private boolean isValidAttributeValue(@Nullable String attributeValue) { + if (attributeStatus != GetVariableStatusEnum.Accepted) { + return attributeValue == null || attributeValue.length() <= 2500; + } else { + return attributeValue != null && attributeValue.length() <= 2500; + } + } + + /** + * Adds value of requested attribute type of component-variable. This field can only be empty when + * the given status is NOT accepted. + * + * @param attributeValue Value of requested attribute type of component-variable + * @return this + */ + public GetVariableResult withAttributeValue(@Nullable String attributeValue) { + setAttributeValue(attributeValue); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetVariableResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidAttributeStatus(attributeStatus) + && isValidAttributeStatusInfo(attributeStatusInfo) + && isValidAttributeValue(attributeValue) + && isValidComponent(component) + && isValidVariable(variable) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetVariableResult that = (GetVariableResult) o; + return Objects.equals(attributeStatus, that.attributeStatus) + && Objects.equals(attributeStatusInfo, that.attributeStatusInfo) + && Objects.equals(attributeType, that.attributeType) + && Objects.equals(attributeValue, that.attributeValue) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + attributeStatus, + attributeStatusInfo, + attributeType, + attributeValue, + component, + variable, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("attributeStatus", attributeStatus) + .add("attributeStatusInfo", attributeStatusInfo) + .add("attributeType", attributeType) + .add("attributeValue", attributeValue) + .add("component", component) + .add("variable", variable) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableStatusEnum.java new file mode 100644 index 00000000..b2998bea --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GetVariableStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** GetVariableStatusEnumType */ +public enum GetVariableStatusEnum { + Accepted, + Rejected, + UnknownComponent, + UnknownVariable, + NotSupportedAttributeType +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Gradient.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Gradient.java new file mode 100644 index 00000000..370b4da5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Gradient.java @@ -0,0 +1,232 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** GradientType */ +public final class Gradient { + /** Id of setting */ + private Integer priority; + + /** Default ramp rate in seconds (0 if not applicable) */ + private Double gradient; + + /** Soft-start ramp rate in seconds (0 if not applicable) */ + private Double softGradient; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Gradient class + * + * @param priority Id of setting + * @param gradient Default ramp rate in seconds (0 if not applicable) + * @param softGradient Soft-start ramp rate in seconds (0 if not applicable) + */ + public Gradient(Integer priority, Double gradient, Double softGradient) { + setPriority(priority); + setGradient(gradient); + setSoftGradient(softGradient); + } + + /** + * Gets id of setting + * + * @return Id of setting + */ + public Integer getPriority() { + return priority; + } + + /** + * Sets id of setting + * + * @param priority Id of setting + */ + public void setPriority(Integer priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(Integer priority) { + return priority != null && priority >= 0; + } + + /** + * Gets default ramp rate in seconds (0 if not applicable) + * + * @return Default ramp rate in seconds (0 if not applicable) + */ + public Double getGradient() { + return gradient; + } + + /** + * Sets default ramp rate in seconds (0 if not applicable) + * + * @param gradient Default ramp rate in seconds (0 if not applicable) + */ + public void setGradient(Double gradient) { + if (!isValidGradient(gradient)) { + throw new PropertyConstraintException(gradient, "gradient is invalid"); + } + this.gradient = gradient; + } + + /** + * Returns whether the given gradient is valid + * + * @param gradient the gradient to check the validity of + * @return {@code true} if gradient is valid, {@code false} if not + */ + private boolean isValidGradient(Double gradient) { + return gradient != null; + } + + /** + * Gets soft-start ramp rate in seconds (0 if not applicable) + * + * @return Soft-start ramp rate in seconds (0 if not applicable) + */ + public Double getSoftGradient() { + return softGradient; + } + + /** + * Sets soft-start ramp rate in seconds (0 if not applicable) + * + * @param softGradient Soft-start ramp rate in seconds (0 if not applicable) + */ + public void setSoftGradient(Double softGradient) { + if (!isValidSoftGradient(softGradient)) { + throw new PropertyConstraintException(softGradient, "softGradient is invalid"); + } + this.softGradient = softGradient; + } + + /** + * Returns whether the given softGradient is valid + * + * @param softGradient the softGradient to check the validity of + * @return {@code true} if softGradient is valid, {@code false} if not + */ + private boolean isValidSoftGradient(Double softGradient) { + return softGradient != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Gradient withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriority(priority) + && isValidGradient(gradient) + && isValidSoftGradient(softGradient) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Gradient that = (Gradient) o; + return Objects.equals(priority, that.priority) + && Objects.equals(gradient, that.gradient) + && Objects.equals(softGradient, that.softGradient) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(priority, gradient, softGradient, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priority", priority) + .add("gradient", gradient) + .add("softGradient", softGradient) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GradientGet.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GradientGet.java new file mode 100644 index 00000000..a002c804 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GradientGet.java @@ -0,0 +1,191 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** GradientGetType */ +public final class GradientGet { + /** gradient */ + private Gradient gradient; + + /** Id of setting */ + private String id; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the GradientGet class + * + * @param gradient gradient + * @param id Id of setting + */ + public GradientGet(Gradient gradient, String id) { + setGradient(gradient); + setId(id); + } + + /** + * Gets gradient + * + * @return gradient + */ + public Gradient getGradient() { + return gradient; + } + + /** + * Sets gradient + * + * @param gradient gradient + */ + public void setGradient(Gradient gradient) { + if (!isValidGradient(gradient)) { + throw new PropertyConstraintException(gradient, "gradient is invalid"); + } + this.gradient = gradient; + } + + /** + * Returns whether the given gradient is valid + * + * @param gradient the gradient to check the validity of + * @return {@code true} if gradient is valid, {@code false} if not + */ + private boolean isValidGradient(Gradient gradient) { + return gradient != null && gradient.validate(); + } + + /** + * Gets id of setting + * + * @return Id of setting + */ + public String getId() { + return id; + } + + /** + * Sets id of setting + * + * @param id Id of setting + */ + public void setId(String id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(String id) { + return id != null && id.length() <= 36; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GradientGet withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidGradient(gradient) && isValidId(id) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GradientGet that = (GradientGet) o; + return Objects.equals(gradient, that.gradient) + && Objects.equals(id, that.id) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(gradient, id, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("gradient", gradient) + .add("id", id) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GridEventFaultEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GridEventFaultEnum.java new file mode 100644 index 00000000..95c5390b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/GridEventFaultEnum.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of grid event that caused this */ +public enum GridEventFaultEnum { + CurrentImbalance, + LocalEmergency, + LowInputPower, + OverCurrent, + OverFrequency, + OverVoltage, + PhaseRotation, + RemoteEmergency, + UnderFrequency, + UnderVoltage, + VoltageImbalance +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/HashAlgorithmEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/HashAlgorithmEnum.java new file mode 100644 index 00000000..685af9a1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/HashAlgorithmEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Used algorithms for the hashes provided. */ +public enum HashAlgorithmEnum { + SHA256, + SHA384, + SHA512 +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Hysteresis.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Hysteresis.java new file mode 100644 index 00000000..b1c3fe1c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Hysteresis.java @@ -0,0 +1,286 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** HysteresisType */ +public final class Hysteresis { + /** + * High value for return to normal operation after a grid event, in absolute value. This value + * adopts the same unit as defined by yUnit + */ + @Nullable private Double hysteresisHigh; + + /** + * Low value for return to normal operation after a grid event, in absolute value. This value + * adopts the same unit as defined by yUnit + */ + @Nullable private Double hysteresisLow; + + /** + * Delay in seconds, once grid parameter within HysteresisLow and HysteresisHigh, for the EV to + * return to normal operation after a grid event. + */ + @Nullable private Double hysteresisDelay; + + /** + * Set default rate of change (ramp rate %/s) for the EV to return to normal operation after a + * grid event + */ + @Nullable private Double hysteresisGradient; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the Hysteresis class */ + public Hysteresis() {} + + /** + * Gets high value for return to normal operation after a grid event, in absolute value. This + * value adopts the same unit as defined by yUnit + * + * @return High value for return to normal operation after a grid event, in absolute value + */ + @Nullable + public Double getHysteresisHigh() { + return hysteresisHigh; + } + + /** + * Sets high value for return to normal operation after a grid event, in absolute value. This + * value adopts the same unit as defined by yUnit + * + * @param hysteresisHigh High value for return to normal operation after a grid event, in absolute + * value + */ + public void setHysteresisHigh(@Nullable Double hysteresisHigh) { + this.hysteresisHigh = hysteresisHigh; + } + + /** + * Adds high value for return to normal operation after a grid event, in absolute value. This + * value adopts the same unit as defined by yUnit + * + * @param hysteresisHigh High value for return to normal operation after a grid event, in absolute + * value + * @return this + */ + public Hysteresis withHysteresisHigh(@Nullable Double hysteresisHigh) { + setHysteresisHigh(hysteresisHigh); + return this; + } + + /** + * Gets low value for return to normal operation after a grid event, in absolute value. This value + * adopts the same unit as defined by yUnit + * + * @return Low value for return to normal operation after a grid event, in absolute value + */ + @Nullable + public Double getHysteresisLow() { + return hysteresisLow; + } + + /** + * Sets low value for return to normal operation after a grid event, in absolute value. This value + * adopts the same unit as defined by yUnit + * + * @param hysteresisLow Low value for return to normal operation after a grid event, in absolute + * value + */ + public void setHysteresisLow(@Nullable Double hysteresisLow) { + this.hysteresisLow = hysteresisLow; + } + + /** + * Adds low value for return to normal operation after a grid event, in absolute value. This value + * adopts the same unit as defined by yUnit + * + * @param hysteresisLow Low value for return to normal operation after a grid event, in absolute + * value + * @return this + */ + public Hysteresis withHysteresisLow(@Nullable Double hysteresisLow) { + setHysteresisLow(hysteresisLow); + return this; + } + + /** + * Gets delay in seconds, once grid parameter within HysteresisLow and HysteresisHigh, for the EV + * to return to normal operation after a grid event. + * + * @return Delay in seconds, once grid parameter within HysteresisLow and HysteresisHigh, for the + * EV to return to normal operation after a grid event + */ + @Nullable + public Double getHysteresisDelay() { + return hysteresisDelay; + } + + /** + * Sets delay in seconds, once grid parameter within HysteresisLow and HysteresisHigh, for the EV + * to return to normal operation after a grid event. + * + * @param hysteresisDelay Delay in seconds, once grid parameter within HysteresisLow and + * HysteresisHigh, for the EV to return to normal operation after a grid event + */ + public void setHysteresisDelay(@Nullable Double hysteresisDelay) { + this.hysteresisDelay = hysteresisDelay; + } + + /** + * Adds delay in seconds, once grid parameter within HysteresisLow and HysteresisHigh, for the EV + * to return to normal operation after a grid event. + * + * @param hysteresisDelay Delay in seconds, once grid parameter within HysteresisLow and + * HysteresisHigh, for the EV to return to normal operation after a grid event + * @return this + */ + public Hysteresis withHysteresisDelay(@Nullable Double hysteresisDelay) { + setHysteresisDelay(hysteresisDelay); + return this; + } + + /** + * Gets set default rate of change (ramp rate %/s) for the EV to return to normal operation after + * a grid event + * + * @return Set default rate of change (ramp rate %/s) for the EV to return to normal operation + * after a grid event + */ + @Nullable + public Double getHysteresisGradient() { + return hysteresisGradient; + } + + /** + * Sets set default rate of change (ramp rate %/s) for the EV to return to normal operation after + * a grid event + * + * @param hysteresisGradient Set default rate of change (ramp rate %/s) for the EV to return to + * normal operation after a grid event + */ + public void setHysteresisGradient(@Nullable Double hysteresisGradient) { + this.hysteresisGradient = hysteresisGradient; + } + + /** + * Adds set default rate of change (ramp rate %/s) for the EV to return to normal operation after + * a grid event + * + * @param hysteresisGradient Set default rate of change (ramp rate %/s) for the EV to return to + * normal operation after a grid event + * @return this + */ + public Hysteresis withHysteresisGradient(@Nullable Double hysteresisGradient) { + setHysteresisGradient(hysteresisGradient); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Hysteresis withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Hysteresis that = (Hysteresis) o; + return Objects.equals(hysteresisHigh, that.hysteresisHigh) + && Objects.equals(hysteresisLow, that.hysteresisLow) + && Objects.equals(hysteresisDelay, that.hysteresisDelay) + && Objects.equals(hysteresisGradient, that.hysteresisGradient) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + hysteresisHigh, hysteresisLow, hysteresisDelay, hysteresisGradient, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("hysteresisHigh", hysteresisHigh) + .add("hysteresisLow", hysteresisLow) + .add("hysteresisDelay", hysteresisDelay) + .add("hysteresisGradient", hysteresisGradient) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IdToken.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IdToken.java new file mode 100644 index 00000000..8f8f9c1a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IdToken.java @@ -0,0 +1,266 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ +public final class IdToken { + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private AdditionalInfo[] additionalInfo; + + /** + * IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also + * contain a UUID. + */ + private String idToken; + + /** Enumeration of possible idToken types. Values defined in Appendix as IdTokenEnumStringType. */ + private String type; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the IdToken class + * + * @param idToken IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can + * for example also contain a UUID. + * @param type Enumeration of possible idToken types. Values defined in Appendix as + * IdTokenEnumStringType. + */ + public IdToken(String idToken, String type) { + setIdToken(idToken); + setType(type); + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public AdditionalInfo[] getAdditionalInfo() { + return additionalInfo; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param additionalInfo A case insensitive identifier to use for the authorization and the type + * of authorization to support multiple forms of identifiers + */ + public void setAdditionalInfo(@Nullable AdditionalInfo[] additionalInfo) { + if (!isValidAdditionalInfo(additionalInfo)) { + throw new PropertyConstraintException(additionalInfo, "additionalInfo is invalid"); + } + this.additionalInfo = additionalInfo; + } + + /** + * Returns whether the given additionalInfo is valid + * + * @param additionalInfo the additionalInfo to check the validity of + * @return {@code true} if additionalInfo is valid, {@code false} if not + */ + private boolean isValidAdditionalInfo(@Nullable AdditionalInfo[] additionalInfo) { + return additionalInfo == null + || (additionalInfo.length >= 1 + && Arrays.stream(additionalInfo).allMatch(item -> item.validate())); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param additionalInfo A case insensitive identifier to use for the authorization and the type + * of authorization to support multiple forms of identifiers + * @return this + */ + public IdToken withAdditionalInfo(@Nullable AdditionalInfo[] additionalInfo) { + setAdditionalInfo(additionalInfo); + return this; + } + + /** + * Gets idToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example + * also contain a UUID. + * + * @return IdToken is case insensitive + */ + public String getIdToken() { + return idToken; + } + + /** + * Sets idToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example + * also contain a UUID. + * + * @param idToken IdToken is case insensitive + */ + public void setIdToken(String idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(String idToken) { + return idToken != null && idToken.length() <= 255; + } + + /** + * Gets enumeration of possible idToken types. Values defined in Appendix as + * IdTokenEnumStringType. + * + * @return Enumeration of possible idToken types + */ + public String getType() { + return type; + } + + /** + * Sets enumeration of possible idToken types. Values defined in Appendix as + * IdTokenEnumStringType. + * + * @param type Enumeration of possible idToken types + */ + public void setType(String type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(String type) { + return type != null && type.length() <= 20; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public IdToken withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidAdditionalInfo(additionalInfo) + && isValidIdToken(idToken) + && isValidType(type) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IdToken that = (IdToken) o; + return Arrays.equals(additionalInfo, that.additionalInfo) + && Objects.equals(idToken, that.idToken) + && Objects.equals(type, that.type) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(additionalInfo), idToken, type, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("additionalInfo", additionalInfo) + .add("idToken", idToken) + .add("type", type) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IdTokenInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IdTokenInfo.java new file mode 100644 index 00000000..b669d05d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IdTokenInfo.java @@ -0,0 +1,524 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Status information about an identifier. It is advised to not stop charging for a token that + * expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not + * given, the status has no end date. + */ +public final class IdTokenInfo { + /** Current status of the ID Token. */ + private AuthorizationStatusEnum status; + + /** Date and Time after which the token must be considered invalid. */ + @Nullable private ZonedDateTime cacheExpiryDateTime; + + /** + * Priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse + * overrules this one. + */ + @Nullable private Integer chargingPriority; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken groupIdToken; + + /** + * Preferred user interface language of identifier user. Contains a language code as defined in + * [RFC5646]. + */ + @Nullable private String language1; + + /** + * Second preferred user interface language of identifier user. Don’t use when language1 is + * omitted, has to be different from language1. Contains a language code as defined in [RFC5646]. + */ + @Nullable private String language2; + + /** + * Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire + * Charging Station. + */ + @Nullable private Integer[] evseId; + + /** Message details, for a message to be displayed on a Charging Station. */ + @Nullable private MessageContent personalMessage; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the IdTokenInfo class + * + * @param status Current status of the ID Token. + */ + public IdTokenInfo(AuthorizationStatusEnum status) { + setStatus(status); + } + + /** + * Gets current status of the ID Token. + * + * @return Current status of the ID Token + */ + public AuthorizationStatusEnum getStatus() { + return status; + } + + /** + * Sets current status of the ID Token. + * + * @param status Current status of the ID Token + */ + public void setStatus(AuthorizationStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(AuthorizationStatusEnum status) { + return status != null; + } + + /** + * Gets date and Time after which the token must be considered invalid. + * + * @return Date and Time after which the token must be considered invalid + */ + @Nullable + public ZonedDateTime getCacheExpiryDateTime() { + return cacheExpiryDateTime; + } + + /** + * Sets date and Time after which the token must be considered invalid. + * + * @param cacheExpiryDateTime Date and Time after which the token must be considered invalid + */ + public void setCacheExpiryDateTime(@Nullable ZonedDateTime cacheExpiryDateTime) { + this.cacheExpiryDateTime = cacheExpiryDateTime; + } + + /** + * Adds date and Time after which the token must be considered invalid. + * + * @param cacheExpiryDateTime Date and Time after which the token must be considered invalid + * @return this + */ + public IdTokenInfo withCacheExpiryDateTime(@Nullable ZonedDateTime cacheExpiryDateTime) { + setCacheExpiryDateTime(cacheExpiryDateTime); + return this; + } + + /** + * Gets priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse + * overrules this one. + * + * @return Priority from a business point of view + */ + @Nullable + public Integer getChargingPriority() { + return chargingPriority; + } + + /** + * Sets priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse + * overrules this one. + * + * @param chargingPriority Priority from a business point of view + */ + public void setChargingPriority(@Nullable Integer chargingPriority) { + this.chargingPriority = chargingPriority; + } + + /** + * Adds priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse + * overrules this one. + * + * @param chargingPriority Priority from a business point of view + * @return this + */ + public IdTokenInfo withChargingPriority(@Nullable Integer chargingPriority) { + setChargingPriority(chargingPriority); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getGroupIdToken() { + return groupIdToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setGroupIdToken(@Nullable IdToken groupIdToken) { + if (!isValidGroupIdToken(groupIdToken)) { + throw new PropertyConstraintException(groupIdToken, "groupIdToken is invalid"); + } + this.groupIdToken = groupIdToken; + } + + /** + * Returns whether the given groupIdToken is valid + * + * @param groupIdToken the groupIdToken to check the validity of + * @return {@code true} if groupIdToken is valid, {@code false} if not + */ + private boolean isValidGroupIdToken(@Nullable IdToken groupIdToken) { + return groupIdToken == null || groupIdToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public IdTokenInfo withGroupIdToken(@Nullable IdToken groupIdToken) { + setGroupIdToken(groupIdToken); + return this; + } + + /** + * Gets preferred user interface language of identifier user. Contains a language code as defined + * in [RFC5646]. + * + * @return Preferred user interface language of identifier user + */ + @Nullable + public String getLanguage1() { + return language1; + } + + /** + * Sets preferred user interface language of identifier user. Contains a language code as defined + * in [RFC5646]. + * + * @param language1 Preferred user interface language of identifier user + */ + public void setLanguage1(@Nullable String language1) { + if (!isValidLanguage1(language1)) { + throw new PropertyConstraintException(language1, "language1 is invalid"); + } + this.language1 = language1; + } + + /** + * Returns whether the given language1 is valid + * + * @param language1 the language1 to check the validity of + * @return {@code true} if language1 is valid, {@code false} if not + */ + private boolean isValidLanguage1(@Nullable String language1) { + return language1 == null || language1.length() <= 8; + } + + /** + * Adds preferred user interface language of identifier user. Contains a language code as defined + * in [RFC5646]. + * + * @param language1 Preferred user interface language of identifier user + * @return this + */ + public IdTokenInfo withLanguage1(@Nullable String language1) { + setLanguage1(language1); + return this; + } + + /** + * Gets second preferred user interface language of identifier user. Don’t use when language1 is + * omitted, has to be different from language1. Contains a language code as defined in [RFC5646]. + * + * @return Second preferred user interface language of identifier user + */ + @Nullable + public String getLanguage2() { + return language2; + } + + /** + * Sets second preferred user interface language of identifier user. Don’t use when language1 is + * omitted, has to be different from language1. Contains a language code as defined in [RFC5646]. + * + * @param language2 Second preferred user interface language of identifier user + */ + public void setLanguage2(@Nullable String language2) { + if (!isValidLanguage2(language2)) { + throw new PropertyConstraintException(language2, "language2 is invalid"); + } + this.language2 = language2; + } + + /** + * Returns whether the given language2 is valid + * + * @param language2 the language2 to check the validity of + * @return {@code true} if language2 is valid, {@code false} if not + */ + private boolean isValidLanguage2(@Nullable String language2) { + return language2 == null || language2.length() <= 8; + } + + /** + * Adds second preferred user interface language of identifier user. Don’t use when language1 is + * omitted, has to be different from language1. Contains a language code as defined in [RFC5646]. + * + * @param language2 Second preferred user interface language of identifier user + * @return this + */ + public IdTokenInfo withLanguage2(@Nullable String language2) { + setLanguage2(language2); + return this; + } + + /** + * Gets only used when the IdToken is only valid for one or more specific EVSEs, not for the + * entire Charging Station. + * + * @return Only used when the IdToken is only valid for one or more specific EVSEs, not for the + * entire Charging Station + */ + @Nullable + public Integer[] getEvseId() { + return evseId; + } + + /** + * Sets only used when the IdToken is only valid for one or more specific EVSEs, not for the + * entire Charging Station. + * + * @param evseId Only used when the IdToken is only valid for one or more specific EVSEs, not for + * the entire Charging Station + */ + public void setEvseId(@Nullable Integer[] evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer[] evseId) { + return evseId == null || (evseId.length >= 1); + } + + /** + * Adds only used when the IdToken is only valid for one or more specific EVSEs, not for the + * entire Charging Station. + * + * @param evseId Only used when the IdToken is only valid for one or more specific EVSEs, not for + * the entire Charging Station + * @return this + */ + public IdTokenInfo withEvseId(@Nullable Integer[] evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageContent getPersonalMessage() { + return personalMessage; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param personalMessage Message details, for a message to be displayed on a Charging Station + */ + public void setPersonalMessage(@Nullable MessageContent personalMessage) { + if (!isValidPersonalMessage(personalMessage)) { + throw new PropertyConstraintException(personalMessage, "personalMessage is invalid"); + } + this.personalMessage = personalMessage; + } + + /** + * Returns whether the given personalMessage is valid + * + * @param personalMessage the personalMessage to check the validity of + * @return {@code true} if personalMessage is valid, {@code false} if not + */ + private boolean isValidPersonalMessage(@Nullable MessageContent personalMessage) { + return personalMessage == null || personalMessage.validate(); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param personalMessage Message details, for a message to be displayed on a Charging Station + * @return this + */ + public IdTokenInfo withPersonalMessage(@Nullable MessageContent personalMessage) { + setPersonalMessage(personalMessage); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public IdTokenInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidStatus(status) + && isValidGroupIdToken(groupIdToken) + && isValidLanguage1(language1) + && isValidLanguage2(language2) + && isValidEvseId(evseId) + && isValidPersonalMessage(personalMessage) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IdTokenInfo that = (IdTokenInfo) o; + return Objects.equals(status, that.status) + && Objects.equals(cacheExpiryDateTime, that.cacheExpiryDateTime) + && Objects.equals(chargingPriority, that.chargingPriority) + && Objects.equals(groupIdToken, that.groupIdToken) + && Objects.equals(language1, that.language1) + && Objects.equals(language2, that.language2) + && Arrays.equals(evseId, that.evseId) + && Objects.equals(personalMessage, that.personalMessage) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + status, + cacheExpiryDateTime, + chargingPriority, + groupIdToken, + language1, + language2, + Arrays.hashCode(evseId), + personalMessage, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("status", status) + .add("cacheExpiryDateTime", cacheExpiryDateTime) + .add("chargingPriority", chargingPriority) + .add("groupIdToken", groupIdToken) + .add("language1", language1) + .add("language2", language2) + .add("evseId", evseId) + .add("personalMessage", personalMessage) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/InstallCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/InstallCertificateStatusEnum.java new file mode 100644 index 00000000..2e3e4687 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/InstallCertificateStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Charging Station indicates if installation was successful. */ +public enum InstallCertificateStatusEnum { + Accepted, + Rejected, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/InstallCertificateUseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/InstallCertificateUseEnum.java new file mode 100644 index 00000000..744ac6b5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/InstallCertificateUseEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The certificate type that is sent. */ +public enum InstallCertificateUseEnum { + V2GRootCertificate, + MORootCertificate, + ManufacturerRootCertificate, + CSMSRootCertificate, + OEMRootCertificate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IslandingDetectionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IslandingDetectionEnum.java new file mode 100644 index 00000000..4160d58e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/IslandingDetectionEnum.java @@ -0,0 +1,44 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** IslandingDetectionEnumType */ +public enum IslandingDetectionEnum { + NoAntiIslandingSupport, + RoCoF, + UVP_OVP, + UFP_OFP, + VoltageVectorShift, + ZeroCrossingDetection, + OtherPassive, + ImpedanceMeasurement, + ImpedanceAtFrequency, + SlipModeFrequencyShift, + SandiaFrequencyShift, + SandiaVoltageShift, + FrequencyJump, + RCLQFactor, + OtherActive +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Iso15118EVCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Iso15118EVCertificateStatusEnum.java new file mode 100644 index 00000000..c7bc85d2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Iso15118EVCertificateStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the message was processed properly. */ +public enum Iso15118EVCertificateStatusEnum { + Accepted, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitAtSoC.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitAtSoC.java new file mode 100644 index 00000000..0b1ebc12 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitAtSoC.java @@ -0,0 +1,197 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** LimitAtSoCType */ +public final class LimitAtSoC { + /** The SoC value beyond which the charging rate limit should be applied. */ + private Integer soc; + + /** + * Charging rate limit beyond the SoC value. The unit is defined by + * chargingSchedule.chargingRateUnit. + */ + private Double limit; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the LimitAtSoC class + * + * @param soc The SoC value beyond which the charging rate limit should be applied. + * @param limit Charging rate limit beyond the SoC value. The unit is defined by + * chargingSchedule.chargingRateUnit. + */ + public LimitAtSoC(Integer soc, Double limit) { + setSoc(soc); + setLimit(limit); + } + + /** + * Gets the SoC value beyond which the charging rate limit should be applied. + * + * @return The SoC value beyond which the charging rate limit should be applied + */ + public Integer getSoc() { + return soc; + } + + /** + * Sets the SoC value beyond which the charging rate limit should be applied. + * + * @param soc The SoC value beyond which the charging rate limit should be applied + */ + public void setSoc(Integer soc) { + if (!isValidSoc(soc)) { + throw new PropertyConstraintException(soc, "soc is invalid"); + } + this.soc = soc; + } + + /** + * Returns whether the given soc is valid + * + * @param soc the soc to check the validity of + * @return {@code true} if soc is valid, {@code false} if not + */ + private boolean isValidSoc(Integer soc) { + return soc != null && soc >= 0 && soc <= 100; + } + + /** + * Gets charging rate limit beyond the SoC value. The unit is defined by + * chargingSchedule.chargingRateUnit. + * + * @return Charging rate limit beyond the SoC value + */ + public Double getLimit() { + return limit; + } + + /** + * Sets charging rate limit beyond the SoC value. The unit is defined by + * chargingSchedule.chargingRateUnit. + * + * @param limit Charging rate limit beyond the SoC value + */ + public void setLimit(Double limit) { + if (!isValidLimit(limit)) { + throw new PropertyConstraintException(limit, "limit is invalid"); + } + this.limit = limit; + } + + /** + * Returns whether the given limit is valid + * + * @param limit the limit to check the validity of + * @return {@code true} if limit is valid, {@code false} if not + */ + private boolean isValidLimit(Double limit) { + return limit != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LimitAtSoC withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidSoc(soc) && isValidLimit(limit) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LimitAtSoC that = (LimitAtSoC) o; + return Objects.equals(soc, that.soc) + && Objects.equals(limit, that.limit) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(soc, limit, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("soc", soc) + .add("limit", limit) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitMaxDischarge.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitMaxDischarge.java new file mode 100644 index 00000000..53a4c8df --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitMaxDischarge.java @@ -0,0 +1,316 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** LimitMaxDischargeType */ +public final class LimitMaxDischarge { + /** Priority of setting (0=highest) */ + private Integer priority; + + /** + * Only for PowerMonitoring. + * + *

The value specifies a percentage (0 to 100) of the rated maximum discharge power of EV. The + * PowerMonitoring curve becomes active when power exceeds this percentage. + */ + @Nullable private Double pctMaxDischargePower; + + /** powerMonitoringMustTrip */ + @Nullable private DERCurve powerMonitoringMustTrip; + + /** Time when this setting becomes active */ + @Nullable private ZonedDateTime startTime; + + /** Duration in seconds that this setting is active */ + @Nullable private Double duration; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the LimitMaxDischarge class + * + * @param priority Priority of setting (0=highest) + */ + public LimitMaxDischarge(Integer priority) { + setPriority(priority); + } + + /** + * Gets priority of setting (0=highest) + * + * @return Priority of setting (0=highest) + */ + public Integer getPriority() { + return priority; + } + + /** + * Sets priority of setting (0=highest) + * + * @param priority Priority of setting (0=highest) + */ + public void setPriority(Integer priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(Integer priority) { + return priority != null && priority >= 0; + } + + /** + * Gets only for PowerMonitoring. + * + * @return Only for PowerMonitoring + */ + @Nullable + public Double getPctMaxDischargePower() { + return pctMaxDischargePower; + } + + /** + * Sets only for PowerMonitoring. + * + * @param pctMaxDischargePower Only for PowerMonitoring + */ + public void setPctMaxDischargePower(@Nullable Double pctMaxDischargePower) { + this.pctMaxDischargePower = pctMaxDischargePower; + } + + /** + * Adds only for PowerMonitoring. + * + * @param pctMaxDischargePower Only for PowerMonitoring + * @return this + */ + public LimitMaxDischarge withPctMaxDischargePower(@Nullable Double pctMaxDischargePower) { + setPctMaxDischargePower(pctMaxDischargePower); + return this; + } + + /** + * Gets powerMonitoringMustTrip + * + * @return powerMonitoringMustTrip + */ + @Nullable + public DERCurve getPowerMonitoringMustTrip() { + return powerMonitoringMustTrip; + } + + /** + * Sets powerMonitoringMustTrip + * + * @param powerMonitoringMustTrip powerMonitoringMustTrip + */ + public void setPowerMonitoringMustTrip(@Nullable DERCurve powerMonitoringMustTrip) { + if (!isValidPowerMonitoringMustTrip(powerMonitoringMustTrip)) { + throw new PropertyConstraintException( + powerMonitoringMustTrip, "powerMonitoringMustTrip is invalid"); + } + this.powerMonitoringMustTrip = powerMonitoringMustTrip; + } + + /** + * Returns whether the given powerMonitoringMustTrip is valid + * + * @param powerMonitoringMustTrip the powerMonitoringMustTrip to check the validity of + * @return {@code true} if powerMonitoringMustTrip is valid, {@code false} if not + */ + private boolean isValidPowerMonitoringMustTrip(@Nullable DERCurve powerMonitoringMustTrip) { + return powerMonitoringMustTrip == null || powerMonitoringMustTrip.validate(); + } + + /** + * Adds powerMonitoringMustTrip + * + * @param powerMonitoringMustTrip powerMonitoringMustTrip + * @return this + */ + public LimitMaxDischarge withPowerMonitoringMustTrip(@Nullable DERCurve powerMonitoringMustTrip) { + setPowerMonitoringMustTrip(powerMonitoringMustTrip); + return this; + } + + /** + * Gets time when this setting becomes active + * + * @return Time when this setting becomes active + */ + @Nullable + public ZonedDateTime getStartTime() { + return startTime; + } + + /** + * Sets time when this setting becomes active + * + * @param startTime Time when this setting becomes active + */ + public void setStartTime(@Nullable ZonedDateTime startTime) { + this.startTime = startTime; + } + + /** + * Adds time when this setting becomes active + * + * @param startTime Time when this setting becomes active + * @return this + */ + public LimitMaxDischarge withStartTime(@Nullable ZonedDateTime startTime) { + setStartTime(startTime); + return this; + } + + /** + * Gets duration in seconds that this setting is active + * + * @return Duration in seconds that this setting is active + */ + @Nullable + public Double getDuration() { + return duration; + } + + /** + * Sets duration in seconds that this setting is active + * + * @param duration Duration in seconds that this setting is active + */ + public void setDuration(@Nullable Double duration) { + this.duration = duration; + } + + /** + * Adds duration in seconds that this setting is active + * + * @param duration Duration in seconds that this setting is active + * @return this + */ + public LimitMaxDischarge withDuration(@Nullable Double duration) { + setDuration(duration); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LimitMaxDischarge withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriority(priority) + && isValidPowerMonitoringMustTrip(powerMonitoringMustTrip) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LimitMaxDischarge that = (LimitMaxDischarge) o; + return Objects.equals(priority, that.priority) + && Objects.equals(pctMaxDischargePower, that.pctMaxDischargePower) + && Objects.equals(powerMonitoringMustTrip, that.powerMonitoringMustTrip) + && Objects.equals(startTime, that.startTime) + && Objects.equals(duration, that.duration) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + priority, pctMaxDischargePower, powerMonitoringMustTrip, startTime, duration, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priority", priority) + .add("pctMaxDischargePower", pctMaxDischargePower) + .add("powerMonitoringMustTrip", powerMonitoringMustTrip) + .add("startTime", startTime) + .add("duration", duration) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitMaxDischargeGet.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitMaxDischargeGet.java new file mode 100644 index 00000000..82be721e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LimitMaxDischargeGet.java @@ -0,0 +1,279 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** LimitMaxDischargeGetType */ +public final class LimitMaxDischargeGet { + /** Id of setting */ + private String id; + + /** True if setting is a default control. */ + private Boolean isDefault; + + /** + * True if this setting is superseded by a higher priority setting (i.e. lower value of priority) + */ + private Boolean isSuperseded; + + /** limitMaxDischarge */ + private LimitMaxDischarge limitMaxDischarge; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the LimitMaxDischargeGet class + * + * @param id Id of setting + * @param isDefault True if setting is a default control. + * @param isSuperseded True if this setting is superseded by a higher priority setting (i.e. lower + * value of priority) + * @param limitMaxDischarge limitMaxDischarge + */ + public LimitMaxDischargeGet( + String id, Boolean isDefault, Boolean isSuperseded, LimitMaxDischarge limitMaxDischarge) { + setId(id); + setIsDefault(isDefault); + setIsSuperseded(isSuperseded); + setLimitMaxDischarge(limitMaxDischarge); + } + + /** + * Gets id of setting + * + * @return Id of setting + */ + public String getId() { + return id; + } + + /** + * Sets id of setting + * + * @param id Id of setting + */ + public void setId(String id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(String id) { + return id != null && id.length() <= 36; + } + + /** + * Gets true if setting is a default control. + * + * @return True if setting is a default control + */ + public Boolean getIsDefault() { + return isDefault; + } + + /** + * Sets true if setting is a default control. + * + * @param isDefault True if setting is a default control + */ + public void setIsDefault(Boolean isDefault) { + if (!isValidIsDefault(isDefault)) { + throw new PropertyConstraintException(isDefault, "isDefault is invalid"); + } + this.isDefault = isDefault; + } + + /** + * Returns whether the given isDefault is valid + * + * @param isDefault the isDefault to check the validity of + * @return {@code true} if isDefault is valid, {@code false} if not + */ + private boolean isValidIsDefault(Boolean isDefault) { + return isDefault != null; + } + + /** + * Gets true if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + * + * @return True if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + */ + public Boolean getIsSuperseded() { + return isSuperseded; + } + + /** + * Sets true if this setting is superseded by a higher priority setting (i.e. lower value of + * priority) + * + * @param isSuperseded True if this setting is superseded by a higher priority setting (i.e. lower + * value of priority) + */ + public void setIsSuperseded(Boolean isSuperseded) { + if (!isValidIsSuperseded(isSuperseded)) { + throw new PropertyConstraintException(isSuperseded, "isSuperseded is invalid"); + } + this.isSuperseded = isSuperseded; + } + + /** + * Returns whether the given isSuperseded is valid + * + * @param isSuperseded the isSuperseded to check the validity of + * @return {@code true} if isSuperseded is valid, {@code false} if not + */ + private boolean isValidIsSuperseded(Boolean isSuperseded) { + return isSuperseded != null; + } + + /** + * Gets limitMaxDischarge + * + * @return limitMaxDischarge + */ + public LimitMaxDischarge getLimitMaxDischarge() { + return limitMaxDischarge; + } + + /** + * Sets limitMaxDischarge + * + * @param limitMaxDischarge limitMaxDischarge + */ + public void setLimitMaxDischarge(LimitMaxDischarge limitMaxDischarge) { + if (!isValidLimitMaxDischarge(limitMaxDischarge)) { + throw new PropertyConstraintException(limitMaxDischarge, "limitMaxDischarge is invalid"); + } + this.limitMaxDischarge = limitMaxDischarge; + } + + /** + * Returns whether the given limitMaxDischarge is valid + * + * @param limitMaxDischarge the limitMaxDischarge to check the validity of + * @return {@code true} if limitMaxDischarge is valid, {@code false} if not + */ + private boolean isValidLimitMaxDischarge(LimitMaxDischarge limitMaxDischarge) { + return limitMaxDischarge != null && limitMaxDischarge.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LimitMaxDischargeGet withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) + && isValidIsDefault(isDefault) + && isValidIsSuperseded(isSuperseded) + && isValidLimitMaxDischarge(limitMaxDischarge) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LimitMaxDischargeGet that = (LimitMaxDischargeGet) o; + return Objects.equals(id, that.id) + && Objects.equals(isDefault, that.isDefault) + && Objects.equals(isSuperseded, that.isSuperseded) + && Objects.equals(limitMaxDischarge, that.limitMaxDischarge) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(id, isDefault, isSuperseded, limitMaxDischarge, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("isDefault", isDefault) + .add("isSuperseded", isSuperseded) + .add("limitMaxDischarge", limitMaxDischarge) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LocationEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LocationEnum.java new file mode 100644 index 00000000..35d01e6e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LocationEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Where the measured value has been sampled. Default = "Outlet" */ +public enum LocationEnum { + Body, + Cable, + EV, + Inlet, + Outlet, + Upstream +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogEnum.java new file mode 100644 index 00000000..45af4816 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The type of log file that the Charging Station should send. */ +public enum LogEnum { + DiagnosticsLog, + SecurityLog, + DataCollectorLog +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogParameters.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogParameters.java new file mode 100644 index 00000000..9d76c04e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogParameters.java @@ -0,0 +1,230 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Generic class for the configuration of logging entries. */ +public final class LogParameters { + /** The URL of the location at the remote system where the log should be stored. */ + private String remoteLocation; + + /** The date and time of the oldest logging information to include in the diagnostics. */ + @Nullable private ZonedDateTime oldestTimestamp; + + /** The date and time of the latest logging information to include in the diagnostics. */ + @Nullable private ZonedDateTime latestTimestamp; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the LogParameters class + * + * @param remoteLocation The URL of the location at the remote system where the log should be + * stored. + */ + public LogParameters(String remoteLocation) { + setRemoteLocation(remoteLocation); + } + + /** + * Gets the URL of the location at the remote system where the log should be stored. + * + * @return The URL of the location at the remote system where the log should be stored + */ + public String getRemoteLocation() { + return remoteLocation; + } + + /** + * Sets the URL of the location at the remote system where the log should be stored. + * + * @param remoteLocation The URL of the location at the remote system where the log should be + * stored + */ + public void setRemoteLocation(String remoteLocation) { + if (!isValidRemoteLocation(remoteLocation)) { + throw new PropertyConstraintException(remoteLocation, "remoteLocation is invalid"); + } + this.remoteLocation = remoteLocation; + } + + /** + * Returns whether the given remoteLocation is valid + * + * @param remoteLocation the remoteLocation to check the validity of + * @return {@code true} if remoteLocation is valid, {@code false} if not + */ + private boolean isValidRemoteLocation(String remoteLocation) { + return remoteLocation != null && remoteLocation.length() <= 2000; + } + + /** + * Gets the date and time of the oldest logging information to include in the diagnostics. + * + * @return The date and time of the oldest logging information to include in the diagnostics + */ + @Nullable + public ZonedDateTime getOldestTimestamp() { + return oldestTimestamp; + } + + /** + * Sets the date and time of the oldest logging information to include in the diagnostics. + * + * @param oldestTimestamp The date and time of the oldest logging information to include in the + * diagnostics + */ + public void setOldestTimestamp(@Nullable ZonedDateTime oldestTimestamp) { + this.oldestTimestamp = oldestTimestamp; + } + + /** + * Adds the date and time of the oldest logging information to include in the diagnostics. + * + * @param oldestTimestamp The date and time of the oldest logging information to include in the + * diagnostics + * @return this + */ + public LogParameters withOldestTimestamp(@Nullable ZonedDateTime oldestTimestamp) { + setOldestTimestamp(oldestTimestamp); + return this; + } + + /** + * Gets the date and time of the latest logging information to include in the diagnostics. + * + * @return The date and time of the latest logging information to include in the diagnostics + */ + @Nullable + public ZonedDateTime getLatestTimestamp() { + return latestTimestamp; + } + + /** + * Sets the date and time of the latest logging information to include in the diagnostics. + * + * @param latestTimestamp The date and time of the latest logging information to include in the + * diagnostics + */ + public void setLatestTimestamp(@Nullable ZonedDateTime latestTimestamp) { + this.latestTimestamp = latestTimestamp; + } + + /** + * Adds the date and time of the latest logging information to include in the diagnostics. + * + * @param latestTimestamp The date and time of the latest logging information to include in the + * diagnostics + * @return this + */ + public LogParameters withLatestTimestamp(@Nullable ZonedDateTime latestTimestamp) { + setLatestTimestamp(latestTimestamp); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LogParameters withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidRemoteLocation(remoteLocation) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogParameters that = (LogParameters) o; + return Objects.equals(remoteLocation, that.remoteLocation) + && Objects.equals(oldestTimestamp, that.oldestTimestamp) + && Objects.equals(latestTimestamp, that.latestTimestamp) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(remoteLocation, oldestTimestamp, latestTimestamp, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("remoteLocation", remoteLocation) + .add("oldestTimestamp", oldestTimestamp) + .add("latestTimestamp", latestTimestamp) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogStatusEnum.java new file mode 100644 index 00000000..f7d5e527 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/LogStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** This field indicates whether the Charging Station was able to accept the request. */ +public enum LogStatusEnum { + Accepted, + Rejected, + AcceptedCanceled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MeasurandEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MeasurandEnum.java new file mode 100644 index 00000000..700daf61 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MeasurandEnum.java @@ -0,0 +1,140 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import com.google.gson.annotations.SerializedName; + +/** Type of measurement. Default = "Energy.Active.Import.Register" */ +public enum MeasurandEnum { + @SerializedName("Current.Export") + CurrentExport, + @SerializedName("Current.Export.Offered") + CurrentExportOffered, + @SerializedName("Current.Export.Minimum") + CurrentExportMinimum, + @SerializedName("Current.Import") + CurrentImport, + @SerializedName("Current.Import.Offered") + CurrentImportOffered, + @SerializedName("Current.Import.Minimum") + CurrentImportMinimum, + @SerializedName("Current.Offered") + CurrentOffered, + @SerializedName("Display.PresentSOC") + DisplayPresentSOC, + @SerializedName("Display.MinimumSOC") + DisplayMinimumSOC, + @SerializedName("Display.TargetSOC") + DisplayTargetSOC, + @SerializedName("Display.MaximumSOC") + DisplayMaximumSOC, + @SerializedName("Display.RemainingTimeToMinimumSOC") + DisplayRemainingTimeToMinimumSOC, + @SerializedName("Display.RemainingTimeToTargetSOC") + DisplayRemainingTimeToTargetSOC, + @SerializedName("Display.RemainingTimeToMaximumSOC") + DisplayRemainingTimeToMaximumSOC, + @SerializedName("Display.ChargingComplete") + DisplayChargingComplete, + @SerializedName("Display.BatteryEnergyCapacity") + DisplayBatteryEnergyCapacity, + @SerializedName("Display.InletHot") + DisplayInletHot, + @SerializedName("Energy.Active.Export.Interval") + EnergyActiveExportInterval, + @SerializedName("Energy.Active.Export.Register") + EnergyActiveExportRegister, + @SerializedName("Energy.Active.Import.Interval") + EnergyActiveImportInterval, + @SerializedName("Energy.Active.Import.Register") + EnergyActiveImportRegister, + @SerializedName("Energy.Active.Import.CableLoss") + EnergyActiveImportCableLoss, + @SerializedName("Energy.Active.Import.LocalGeneration.Register") + EnergyActiveImportLocalGenerationRegister, + @SerializedName("Energy.Active.Net") + EnergyActiveNet, + @SerializedName("Energy.Active.Setpoint.Interval") + EnergyActiveSetpointInterval, + @SerializedName("Energy.Apparent.Export") + EnergyApparentExport, + @SerializedName("Energy.Apparent.Import") + EnergyApparentImport, + @SerializedName("Energy.Apparent.Net") + EnergyApparentNet, + @SerializedName("Energy.Reactive.Export.Interval") + EnergyReactiveExportInterval, + @SerializedName("Energy.Reactive.Export.Register") + EnergyReactiveExportRegister, + @SerializedName("Energy.Reactive.Import.Interval") + EnergyReactiveImportInterval, + @SerializedName("Energy.Reactive.Import.Register") + EnergyReactiveImportRegister, + @SerializedName("Energy.Reactive.Net") + EnergyReactiveNet, + @SerializedName("EnergyRequest.Target") + EnergyRequestTarget, + @SerializedName("EnergyRequest.Minimum") + EnergyRequestMinimum, + @SerializedName("EnergyRequest.Maximum") + EnergyRequestMaximum, + @SerializedName("EnergyRequest.Minimum.V2X") + EnergyRequestMinimumV2X, + @SerializedName("EnergyRequest.Maximum.V2X") + EnergyRequestMaximumV2X, + @SerializedName("EnergyRequest.Bulk") + EnergyRequestBulk, + Frequency, + @SerializedName("Power.Active.Export") + PowerActiveExport, + @SerializedName("Power.Active.Import") + PowerActiveImport, + @SerializedName("Power.Active.Setpoint") + PowerActiveSetpoint, + @SerializedName("Power.Active.Residual") + PowerActiveResidual, + @SerializedName("Power.Export.Minimum") + PowerExportMinimum, + @SerializedName("Power.Export.Offered") + PowerExportOffered, + @SerializedName("Power.Factor") + PowerFactor, + @SerializedName("Power.Import.Offered") + PowerImportOffered, + @SerializedName("Power.Import.Minimum") + PowerImportMinimum, + @SerializedName("Power.Offered") + PowerOffered, + @SerializedName("Power.Reactive.Export") + PowerReactiveExport, + @SerializedName("Power.Reactive.Import") + PowerReactiveImport, + SoC, + Voltage, + @SerializedName("Voltage.Minimum") + VoltageMinimum, + @SerializedName("Voltage.Maximum") + VoltageMaximum +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageContent.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageContent.java new file mode 100644 index 00000000..0b1e84a3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageContent.java @@ -0,0 +1,247 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Message details, for a message to be displayed on a Charging Station. */ +public final class MessageContent { + /** Format of the message. */ + private MessageFormatEnum format; + + /** Message language identifier. Contains a language code as defined in [RFC5646]. */ + @Nullable private String language; + + /** + * Required. Message contents. + * + *

Maximum length supported by Charging Station is given in + * OCPPCommCtrlr.FieldLength["MessageContentType.content"]. Maximum length defaults to 1024. + */ + private String content; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the MessageContent class + * + * @param format Format of the message. + * @param content Required. Message contents. + */ + public MessageContent(MessageFormatEnum format, String content) { + setFormat(format); + setContent(content); + } + + /** + * Gets format of the message. + * + * @return Format of the message + */ + public MessageFormatEnum getFormat() { + return format; + } + + /** + * Sets format of the message. + * + * @param format Format of the message + */ + public void setFormat(MessageFormatEnum format) { + if (!isValidFormat(format)) { + throw new PropertyConstraintException(format, "format is invalid"); + } + this.format = format; + } + + /** + * Returns whether the given format is valid + * + * @param format the format to check the validity of + * @return {@code true} if format is valid, {@code false} if not + */ + private boolean isValidFormat(MessageFormatEnum format) { + return format != null; + } + + /** + * Gets message language identifier. Contains a language code as defined in [RFC5646]. + * + * @return Message language identifier + */ + @Nullable + public String getLanguage() { + return language; + } + + /** + * Sets message language identifier. Contains a language code as defined in [RFC5646]. + * + * @param language Message language identifier + */ + public void setLanguage(@Nullable String language) { + if (!isValidLanguage(language)) { + throw new PropertyConstraintException(language, "language is invalid"); + } + this.language = language; + } + + /** + * Returns whether the given language is valid + * + * @param language the language to check the validity of + * @return {@code true} if language is valid, {@code false} if not + */ + private boolean isValidLanguage(@Nullable String language) { + return language == null || language.length() <= 8; + } + + /** + * Adds message language identifier. Contains a language code as defined in [RFC5646]. + * + * @param language Message language identifier + * @return this + */ + public MessageContent withLanguage(@Nullable String language) { + setLanguage(language); + return this; + } + + /** + * Gets required. Message contents. + * + * @return Required + */ + public String getContent() { + return content; + } + + /** + * Sets required. Message contents. + * + * @param content Required + */ + public void setContent(String content) { + if (!isValidContent(content)) { + throw new PropertyConstraintException(content, "content is invalid"); + } + this.content = content; + } + + /** + * Returns whether the given content is valid + * + * @param content the content to check the validity of + * @return {@code true} if content is valid, {@code false} if not + */ + private boolean isValidContent(String content) { + return content != null && content.length() <= 1024; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MessageContent withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidFormat(format) + && isValidLanguage(language) + && isValidContent(content) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MessageContent that = (MessageContent) o; + return Objects.equals(format, that.format) + && Objects.equals(language, that.language) + && Objects.equals(content, that.content) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(format, language, content, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("format", format) + .add("language", language) + .add("content", content) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageFormatEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageFormatEnum.java new file mode 100644 index 00000000..bb4b3479 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageFormatEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Format of the message. */ +public enum MessageFormatEnum { + ASCII, + HTML, + URI, + UTF8, + QRCODE +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageInfo.java new file mode 100644 index 00000000..f329617d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageInfo.java @@ -0,0 +1,526 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Message details, for a message to be displayed on a Charging Station. */ +public final class MessageInfo { + /** A physical or logical component */ + @Nullable private Component display; + + /** + * Unique id within an exchange context. It is defined within the OCPP context as a positive + * Integer value (greater or equal to zero). + */ + private Integer id; + + /** With what priority should this message be shown */ + private MessagePriorityEnum priority; + + /** + * During what state should this message be shown. When omitted this message should be shown in + * any state of the Charging Station. + */ + @Nullable private MessageStateEnum state; + + /** From what date-time should this message be shown. If omitted: directly. */ + @Nullable private ZonedDateTime startDateTime; + + /** + * Until what date-time should this message be shown, after this date/time this message SHALL be + * removed. + */ + @Nullable private ZonedDateTime endDateTime; + + /** + * During which transaction shall this message be shown. Message SHALL be removed by the Charging + * Station after transaction has ended. + */ + @Nullable private String transactionId; + + /** Message details, for a message to be displayed on a Charging Station. */ + private MessageContent message; + + /** Message details, for a message to be displayed on a Charging Station. */ + @Nullable private MessageContent[] messageExtra; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the MessageInfo class + * + * @param id Unique id within an exchange context. It is defined within the OCPP context as a + * positive Integer value (greater or equal to zero). + * @param priority With what priority should this message be shown + * @param message Message details, for a message to be displayed on a Charging Station. + */ + public MessageInfo(Integer id, MessagePriorityEnum priority, MessageContent message) { + setId(id); + setPriority(priority); + setMessage(message); + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + @Nullable + public Component getDisplay() { + return display; + } + + /** + * Sets a physical or logical component + * + * @param display A physical or logical component + */ + public void setDisplay(@Nullable Component display) { + if (!isValidDisplay(display)) { + throw new PropertyConstraintException(display, "display is invalid"); + } + this.display = display; + } + + /** + * Returns whether the given display is valid + * + * @param display the display to check the validity of + * @return {@code true} if display is valid, {@code false} if not + */ + private boolean isValidDisplay(@Nullable Component display) { + return display == null || display.validate(); + } + + /** + * Adds a physical or logical component + * + * @param display A physical or logical component + * @return this + */ + public MessageInfo withDisplay(@Nullable Component display) { + setDisplay(display); + return this; + } + + /** + * Gets unique id within an exchange context. It is defined within the OCPP context as a positive + * Integer value (greater or equal to zero). + * + * @return Unique id within an exchange context + */ + public Integer getId() { + return id; + } + + /** + * Sets unique id within an exchange context. It is defined within the OCPP context as a positive + * Integer value (greater or equal to zero). + * + * @param id Unique id within an exchange context + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets with what priority should this message be shown + * + * @return With what priority should this message be shown + */ + public MessagePriorityEnum getPriority() { + return priority; + } + + /** + * Sets with what priority should this message be shown + * + * @param priority With what priority should this message be shown + */ + public void setPriority(MessagePriorityEnum priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(MessagePriorityEnum priority) { + return priority != null; + } + + /** + * Gets during what state should this message be shown. When omitted this message should be shown + * in any state of the Charging Station. + * + * @return During what state should this message be shown + */ + @Nullable + public MessageStateEnum getState() { + return state; + } + + /** + * Sets during what state should this message be shown. When omitted this message should be shown + * in any state of the Charging Station. + * + * @param state During what state should this message be shown + */ + public void setState(@Nullable MessageStateEnum state) { + this.state = state; + } + + /** + * Adds during what state should this message be shown. When omitted this message should be shown + * in any state of the Charging Station. + * + * @param state During what state should this message be shown + * @return this + */ + public MessageInfo withState(@Nullable MessageStateEnum state) { + setState(state); + return this; + } + + /** + * Gets from what date-time should this message be shown. If omitted: directly. + * + * @return From what date-time should this message be shown + */ + @Nullable + public ZonedDateTime getStartDateTime() { + return startDateTime; + } + + /** + * Sets from what date-time should this message be shown. If omitted: directly. + * + * @param startDateTime From what date-time should this message be shown + */ + public void setStartDateTime(@Nullable ZonedDateTime startDateTime) { + this.startDateTime = startDateTime; + } + + /** + * Adds from what date-time should this message be shown. If omitted: directly. + * + * @param startDateTime From what date-time should this message be shown + * @return this + */ + public MessageInfo withStartDateTime(@Nullable ZonedDateTime startDateTime) { + setStartDateTime(startDateTime); + return this; + } + + /** + * Gets until what date-time should this message be shown, after this date/time this message SHALL + * be removed. + * + * @return Until what date-time should this message be shown, after this date/time this message + * SHALL be removed + */ + @Nullable + public ZonedDateTime getEndDateTime() { + return endDateTime; + } + + /** + * Sets until what date-time should this message be shown, after this date/time this message SHALL + * be removed. + * + * @param endDateTime Until what date-time should this message be shown, after this date/time this + * message SHALL be removed + */ + public void setEndDateTime(@Nullable ZonedDateTime endDateTime) { + this.endDateTime = endDateTime; + } + + /** + * Adds until what date-time should this message be shown, after this date/time this message SHALL + * be removed. + * + * @param endDateTime Until what date-time should this message be shown, after this date/time this + * message SHALL be removed + * @return this + */ + public MessageInfo withEndDateTime(@Nullable ZonedDateTime endDateTime) { + setEndDateTime(endDateTime); + return this; + } + + /** + * Gets during which transaction shall this message be shown. Message SHALL be removed by the + * Charging Station after transaction has ended. + * + * @return During which transaction shall this message be shown + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets during which transaction shall this message be shown. Message SHALL be removed by the + * Charging Station after transaction has ended. + * + * @param transactionId During which transaction shall this message be shown + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds during which transaction shall this message be shown. Message SHALL be removed by the + * Charging Station after transaction has ended. + * + * @param transactionId During which transaction shall this message be shown + * @return this + */ + public MessageInfo withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + public MessageContent getMessage() { + return message; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param message Message details, for a message to be displayed on a Charging Station + */ + public void setMessage(MessageContent message) { + if (!isValidMessage(message)) { + throw new PropertyConstraintException(message, "message is invalid"); + } + this.message = message; + } + + /** + * Returns whether the given message is valid + * + * @param message the message to check the validity of + * @return {@code true} if message is valid, {@code false} if not + */ + private boolean isValidMessage(MessageContent message) { + return message != null && message.validate(); + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageContent[] getMessageExtra() { + return messageExtra; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param messageExtra Message details, for a message to be displayed on a Charging Station + */ + public void setMessageExtra(@Nullable MessageContent[] messageExtra) { + if (!isValidMessageExtra(messageExtra)) { + throw new PropertyConstraintException(messageExtra, "messageExtra is invalid"); + } + this.messageExtra = messageExtra; + } + + /** + * Returns whether the given messageExtra is valid + * + * @param messageExtra the messageExtra to check the validity of + * @return {@code true} if messageExtra is valid, {@code false} if not + */ + private boolean isValidMessageExtra(@Nullable MessageContent[] messageExtra) { + return messageExtra == null + || (messageExtra.length >= 1 + && messageExtra.length <= 4 + && Arrays.stream(messageExtra).allMatch(item -> item.validate())); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param messageExtra Message details, for a message to be displayed on a Charging Station + * @return this + */ + public MessageInfo withMessageExtra(@Nullable MessageContent[] messageExtra) { + setMessageExtra(messageExtra); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MessageInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDisplay(display) + && isValidId(id) + && isValidPriority(priority) + && isValidTransactionId(transactionId) + && isValidMessage(message) + && isValidMessageExtra(messageExtra) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MessageInfo that = (MessageInfo) o; + return Objects.equals(display, that.display) + && Objects.equals(id, that.id) + && Objects.equals(priority, that.priority) + && Objects.equals(state, that.state) + && Objects.equals(startDateTime, that.startDateTime) + && Objects.equals(endDateTime, that.endDateTime) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(message, that.message) + && Arrays.equals(messageExtra, that.messageExtra) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + display, + id, + priority, + state, + startDateTime, + endDateTime, + transactionId, + message, + Arrays.hashCode(messageExtra), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("display", display) + .add("id", id) + .add("priority", priority) + .add("state", state) + .add("startDateTime", startDateTime) + .add("endDateTime", endDateTime) + .add("transactionId", transactionId) + .add("message", message) + .add("messageExtra", messageExtra) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessagePriorityEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessagePriorityEnum.java new file mode 100644 index 00000000..e2f78b4b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessagePriorityEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** With what priority should this message be shown */ +public enum MessagePriorityEnum { + AlwaysFront, + InFront, + NormalCycle +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageStateEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageStateEnum.java new file mode 100644 index 00000000..85851cc2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageStateEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * During what state should this message be shown. When omitted this message should be shown in any + * state of the Charging Station. + */ +public enum MessageStateEnum { + Charging, + Faulted, + Idle, + Unavailable, + Suspended, + Discharging +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageTriggerEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageTriggerEnum.java new file mode 100644 index 00000000..b6f28761 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MessageTriggerEnum.java @@ -0,0 +1,42 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of message to be triggered. */ +public enum MessageTriggerEnum { + BootNotification, + LogStatusNotification, + FirmwareStatusNotification, + Heartbeat, + MeterValues, + SignChargingStationCertificate, + SignV2GCertificate, + SignV2G20Certificate, + StatusNotification, + TransactionEvent, + SignCombinedCertificate, + PublishFirmwareStatusNotification, + CustomTrigger +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MeterValue.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MeterValue.java new file mode 100644 index 00000000..71e806c7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MeterValue.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All sampled + * values in a MeterValue are sampled at the same point in time. + */ +public final class MeterValue { + /** + * Single sampled value in MeterValues. Each value can be accompanied by optional fields. + * + *

To save on mobile data usage, default values of all of the optional fields are such that. + * The value without any additional fields will be interpreted, as a register reading of active + * import energy in Wh (Watt-hour) units. + */ + private SampledValue[] sampledValue; + + /** Timestamp for measured value(s). */ + private ZonedDateTime timestamp; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the MeterValue class + * + * @param sampledValue Single sampled value in MeterValues. Each value can be accompanied by + * optional fields. + * @param timestamp Timestamp for measured value(s). + */ + public MeterValue(SampledValue[] sampledValue, ZonedDateTime timestamp) { + setSampledValue(sampledValue); + setTimestamp(timestamp); + } + + /** + * Gets single sampled value in MeterValues. Each value can be accompanied by optional fields. + * + * @return Single sampled value in MeterValues + */ + public SampledValue[] getSampledValue() { + return sampledValue; + } + + /** + * Sets single sampled value in MeterValues. Each value can be accompanied by optional fields. + * + * @param sampledValue Single sampled value in MeterValues + */ + public void setSampledValue(SampledValue[] sampledValue) { + if (!isValidSampledValue(sampledValue)) { + throw new PropertyConstraintException(sampledValue, "sampledValue is invalid"); + } + this.sampledValue = sampledValue; + } + + /** + * Returns whether the given sampledValue is valid + * + * @param sampledValue the sampledValue to check the validity of + * @return {@code true} if sampledValue is valid, {@code false} if not + */ + private boolean isValidSampledValue(SampledValue[] sampledValue) { + return sampledValue != null + && sampledValue.length >= 1 + && Arrays.stream(sampledValue).allMatch(item -> item.validate()); + } + + /** + * Gets timestamp for measured value(s). + * + * @return Timestamp for measured value(s) + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets timestamp for measured value(s). + * + * @param timestamp Timestamp for measured value(s) + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MeterValue withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidSampledValue(sampledValue) + && isValidTimestamp(timestamp) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MeterValue that = (MeterValue) o; + return Arrays.equals(sampledValue, that.sampledValue) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(sampledValue), timestamp, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("sampledValue", sampledValue) + .add("timestamp", timestamp) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MobilityNeedsModeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MobilityNeedsModeEnum.java new file mode 100644 index 00000000..4922a4f5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MobilityNeedsModeEnum.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Value of EVCC indicates that EV determines min/target SOC and departure time. + * + *

+ * A value of EVCCSECC indicates that charging station or CSMS may also update min/target SOC and
+ * departure time.
+ * *ISO 15118-20:*
+ * ServiceSelectionReq(SelectedEnergyTransferService)
+ * 
+ */ +public enum MobilityNeedsModeEnum { + EVCC, + EVCC_SECC +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Modem.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Modem.java new file mode 100644 index 00000000..ae06e976 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Modem.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Parameters required for initiating and maintaining wireless communication with other devices. */ +public final class Modem { + /** The ICCID of the modem’s SIM card. */ + @Nullable private String iccid; + + /** The IMSI of the modem’s SIM card. */ + @Nullable private String imsi; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the Modem class */ + public Modem() {} + + /** + * Gets the ICCID of the modem’s SIM card. + * + * @return The ICCID of the modem’s SIM card + */ + @Nullable + public String getIccid() { + return iccid; + } + + /** + * Sets the ICCID of the modem’s SIM card. + * + * @param iccid The ICCID of the modem’s SIM card + */ + public void setIccid(@Nullable String iccid) { + if (!isValidIccid(iccid)) { + throw new PropertyConstraintException(iccid, "iccid is invalid"); + } + this.iccid = iccid; + } + + /** + * Returns whether the given iccid is valid + * + * @param iccid the iccid to check the validity of + * @return {@code true} if iccid is valid, {@code false} if not + */ + private boolean isValidIccid(@Nullable String iccid) { + return iccid == null || iccid.length() <= 20; + } + + /** + * Adds the ICCID of the modem’s SIM card. + * + * @param iccid The ICCID of the modem’s SIM card + * @return this + */ + public Modem withIccid(@Nullable String iccid) { + setIccid(iccid); + return this; + } + + /** + * Gets the IMSI of the modem’s SIM card. + * + * @return The IMSI of the modem’s SIM card + */ + @Nullable + public String getImsi() { + return imsi; + } + + /** + * Sets the IMSI of the modem’s SIM card. + * + * @param imsi The IMSI of the modem’s SIM card + */ + public void setImsi(@Nullable String imsi) { + if (!isValidImsi(imsi)) { + throw new PropertyConstraintException(imsi, "imsi is invalid"); + } + this.imsi = imsi; + } + + /** + * Returns whether the given imsi is valid + * + * @param imsi the imsi to check the validity of + * @return {@code true} if imsi is valid, {@code false} if not + */ + private boolean isValidImsi(@Nullable String imsi) { + return imsi == null || imsi.length() <= 20; + } + + /** + * Adds the IMSI of the modem’s SIM card. + * + * @param imsi The IMSI of the modem’s SIM card + * @return this + */ + public Modem withImsi(@Nullable String imsi) { + setImsi(imsi); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Modem withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidIccid(iccid) && isValidImsi(imsi) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Modem that = (Modem) o; + return Objects.equals(iccid, that.iccid) + && Objects.equals(imsi, that.imsi) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(iccid, imsi, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("iccid", iccid) + .add("imsi", imsi) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitorEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitorEnum.java new file mode 100644 index 00000000..e09ab406 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitorEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The type of this monitor, e.g. a threshold, delta or periodic monitor. */ +public enum MonitorEnum { + UpperThreshold, + LowerThreshold, + Delta, + Periodic, + PeriodicClockAligned, + TargetDelta, + TargetDeltaRelative +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringBaseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringBaseEnum.java new file mode 100644 index 00000000..ef65d994 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringBaseEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Specify which monitoring base will be set */ +public enum MonitoringBaseEnum { + All, + FactoryDefault, + HardWiredOnly +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringCriterionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringCriterionEnum.java new file mode 100644 index 00000000..caa1f976 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringCriterionEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** MonitoringCriterionEnumType */ +public enum MonitoringCriterionEnum { + ThresholdMonitoring, + DeltaMonitoring, + PeriodicMonitoring +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringData.java new file mode 100644 index 00000000..0c3fad6a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MonitoringData.java @@ -0,0 +1,236 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold parameters of SetVariableMonitoring request. */ +public final class MonitoringData { + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** A monitoring setting for a variable. */ + private VariableMonitoring[] variableMonitoring; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the MonitoringData class + * + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + * @param variableMonitoring A monitoring setting for a variable. + */ + public MonitoringData( + Component component, Variable variable, VariableMonitoring[] variableMonitoring) { + setComponent(component); + setVariable(variable); + setVariableMonitoring(variableMonitoring); + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets a monitoring setting for a variable. + * + * @return A monitoring setting for a variable + */ + public VariableMonitoring[] getVariableMonitoring() { + return variableMonitoring; + } + + /** + * Sets a monitoring setting for a variable. + * + * @param variableMonitoring A monitoring setting for a variable + */ + public void setVariableMonitoring(VariableMonitoring[] variableMonitoring) { + if (!isValidVariableMonitoring(variableMonitoring)) { + throw new PropertyConstraintException(variableMonitoring, "variableMonitoring is invalid"); + } + this.variableMonitoring = variableMonitoring; + } + + /** + * Returns whether the given variableMonitoring is valid + * + * @param variableMonitoring the variableMonitoring to check the validity of + * @return {@code true} if variableMonitoring is valid, {@code false} if not + */ + private boolean isValidVariableMonitoring(VariableMonitoring[] variableMonitoring) { + return variableMonitoring != null + && variableMonitoring.length >= 1 + && Arrays.stream(variableMonitoring).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MonitoringData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidComponent(component) + && isValidVariable(variable) + && isValidVariableMonitoring(variableMonitoring) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonitoringData that = (MonitoringData) o; + return Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Arrays.equals(variableMonitoring, that.variableMonitoring) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(component, variable, Arrays.hashCode(variableMonitoring), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("component", component) + .add("variable", variable) + .add("variableMonitoring", variableMonitoring) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MutabilityEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MutabilityEnum.java new file mode 100644 index 00000000..434c99ee --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/MutabilityEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The mutability of this attribute. Default is ReadWrite when omitted. */ +public enum MutabilityEnum { + ReadOnly, + WriteOnly, + ReadWrite +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NetworkConnectionProfile.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NetworkConnectionProfile.java new file mode 100644 index 00000000..a6784453 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NetworkConnectionProfile.java @@ -0,0 +1,621 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * The NetworkConnectionProfile defines the functional and technical parameters of a communication + * link. + */ +public final class NetworkConnectionProfile { + /** + * Collection of configuration data needed to make a data-connection over a cellular network. + * + *

NOTE: When asking a GSM modem to dial in, it is possible to specify which mobile operator + * should be used. This can be done with the mobile country code (MCC) in combination with a + * mobile network code (MNC). Example: If your preferred network is Vodafone Netherlands, the + * MCC=204 and the MNC=04 which means the key PreferredNetwork = 20404 Some modems allows to + * specify a preferred network, which means, if this network is not available, a different network + * is used. If you specify UseOnlyPreferredNetwork and this network is not available, the modem + * will not dial in. + */ + @Nullable private APN apn; + + /** + * This field is ignored, since the OCPP version to use is determined during the websocket + * handshake. The field is only kept for backwards compatibility with the OCPP 2.0.1 JSON schema. + */ + @Nullable private OCPPVersionEnum ocppVersion; + + /** + * Applicable Network Interface. Charging Station is allowed to use a different network interface + * to connect if the given one does not work. + */ + private OCPPInterfaceEnum ocppInterface; + + /** + * The transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.x, but is + * supported by earlier versions of OCPP. + */ + private OCPPTransportEnum ocppTransport; + + /** + * Duration in seconds before a message send by the Charging Station via this network connection + * times-out. The best setting depends on the underlying network and response times of the CSMS. + * If you are looking for a some guideline: use 30 seconds as a starting point. + */ + private Integer messageTimeout; + + /** + * URL of the CSMS(s) that this Charging Station communicates with, without the Charging Station + * identity part. + * + *

The SecurityCtrlr.Identity field is appended to ocppCsmsUrl to provide the full websocket + * URL. + */ + private String ocppCsmsUrl; + + /** The security profile used when connecting to the CSMS with this NetworkConnectionProfile. */ + private Integer securityProfile; + + /** Charging Station identity to be used as the basic authentication username. */ + @Nullable private String identity; + + /** BasicAuthPassword to use for security profile 1 or 2. */ + @Nullable private String basicAuthPassword; + + /** VPN Configuration settings */ + @Nullable private VPN vpn; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the NetworkConnectionProfile class + * + * @param ocppInterface Applicable Network Interface. Charging Station is allowed to use a + * different network interface to connect if the given one does not work. + * @param ocppTransport The transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in + * OCPP 2.x, but is supported by earlier versions of OCPP. + * @param messageTimeout Duration in seconds before a message send by the Charging Station via + * this network connection times-out. The best setting depends on the underlying network and + * response times of the CSMS. If you are looking for a some guideline: use 30 seconds as a + * starting point. + * @param ocppCsmsUrl URL of the CSMS(s) that this Charging Station communicates with, without the + * Charging Station identity part. + * @param securityProfile The security profile used when connecting to the CSMS with this + * NetworkConnectionProfile. + */ + public NetworkConnectionProfile( + OCPPInterfaceEnum ocppInterface, + OCPPTransportEnum ocppTransport, + Integer messageTimeout, + String ocppCsmsUrl, + Integer securityProfile) { + setOcppInterface(ocppInterface); + setOcppTransport(ocppTransport); + setMessageTimeout(messageTimeout); + setOcppCsmsUrl(ocppCsmsUrl); + setSecurityProfile(securityProfile); + } + + /** + * Gets collection of configuration data needed to make a data-connection over a cellular network. + * + * @return Collection of configuration data needed to make a data-connection over a cellular + * network + */ + @Nullable + public APN getApn() { + return apn; + } + + /** + * Sets collection of configuration data needed to make a data-connection over a cellular network. + * + * @param apn Collection of configuration data needed to make a data-connection over a cellular + * network + */ + public void setApn(@Nullable APN apn) { + if (!isValidApn(apn)) { + throw new PropertyConstraintException(apn, "apn is invalid"); + } + this.apn = apn; + } + + /** + * Returns whether the given apn is valid + * + * @param apn the apn to check the validity of + * @return {@code true} if apn is valid, {@code false} if not + */ + private boolean isValidApn(@Nullable APN apn) { + return apn == null || apn.validate(); + } + + /** + * Adds collection of configuration data needed to make a data-connection over a cellular network. + * + * @param apn Collection of configuration data needed to make a data-connection over a cellular + * network + * @return this + */ + public NetworkConnectionProfile withApn(@Nullable APN apn) { + setApn(apn); + return this; + } + + /** + * Gets this field is ignored, since the OCPP version to use is determined during the websocket + * handshake. The field is only kept for backwards compatibility with the OCPP 2.0.1 JSON schema. + * + * @return This field is ignored, since the OCPP version to use is determined during the websocket + * handshake + */ + @Nullable + public OCPPVersionEnum getOcppVersion() { + return ocppVersion; + } + + /** + * Sets this field is ignored, since the OCPP version to use is determined during the websocket + * handshake. The field is only kept for backwards compatibility with the OCPP 2.0.1 JSON schema. + * + * @param ocppVersion This field is ignored, since the OCPP version to use is determined during + * the websocket handshake + */ + public void setOcppVersion(@Nullable OCPPVersionEnum ocppVersion) { + this.ocppVersion = ocppVersion; + } + + /** + * Adds this field is ignored, since the OCPP version to use is determined during the websocket + * handshake. The field is only kept for backwards compatibility with the OCPP 2.0.1 JSON schema. + * + * @param ocppVersion This field is ignored, since the OCPP version to use is determined during + * the websocket handshake + * @return this + */ + public NetworkConnectionProfile withOcppVersion(@Nullable OCPPVersionEnum ocppVersion) { + setOcppVersion(ocppVersion); + return this; + } + + /** + * Gets applicable Network Interface. Charging Station is allowed to use a different network + * interface to connect if the given one does not work. + * + * @return Applicable Network Interface + */ + public OCPPInterfaceEnum getOcppInterface() { + return ocppInterface; + } + + /** + * Sets applicable Network Interface. Charging Station is allowed to use a different network + * interface to connect if the given one does not work. + * + * @param ocppInterface Applicable Network Interface + */ + public void setOcppInterface(OCPPInterfaceEnum ocppInterface) { + if (!isValidOcppInterface(ocppInterface)) { + throw new PropertyConstraintException(ocppInterface, "ocppInterface is invalid"); + } + this.ocppInterface = ocppInterface; + } + + /** + * Returns whether the given ocppInterface is valid + * + * @param ocppInterface the ocppInterface to check the validity of + * @return {@code true} if ocppInterface is valid, {@code false} if not + */ + private boolean isValidOcppInterface(OCPPInterfaceEnum ocppInterface) { + return ocppInterface != null; + } + + /** + * Gets the transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.x, but + * is supported by earlier versions of OCPP. + * + * @return The transport protocol (e.g. SOAP or JSON) + */ + public OCPPTransportEnum getOcppTransport() { + return ocppTransport; + } + + /** + * Sets the transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.x, but + * is supported by earlier versions of OCPP. + * + * @param ocppTransport The transport protocol (e.g. SOAP or JSON) + */ + public void setOcppTransport(OCPPTransportEnum ocppTransport) { + if (!isValidOcppTransport(ocppTransport)) { + throw new PropertyConstraintException(ocppTransport, "ocppTransport is invalid"); + } + this.ocppTransport = ocppTransport; + } + + /** + * Returns whether the given ocppTransport is valid + * + * @param ocppTransport the ocppTransport to check the validity of + * @return {@code true} if ocppTransport is valid, {@code false} if not + */ + private boolean isValidOcppTransport(OCPPTransportEnum ocppTransport) { + return ocppTransport != null; + } + + /** + * Gets duration in seconds before a message send by the Charging Station via this network + * connection times-out. The best setting depends on the underlying network and response times of + * the CSMS. If you are looking for a some guideline: use 30 seconds as a starting point. + * + * @return Duration in seconds before a message send by the Charging Station via this network + * connection times-out + */ + public Integer getMessageTimeout() { + return messageTimeout; + } + + /** + * Sets duration in seconds before a message send by the Charging Station via this network + * connection times-out. The best setting depends on the underlying network and response times of + * the CSMS. If you are looking for a some guideline: use 30 seconds as a starting point. + * + * @param messageTimeout Duration in seconds before a message send by the Charging Station via + * this network connection times-out + */ + public void setMessageTimeout(Integer messageTimeout) { + if (!isValidMessageTimeout(messageTimeout)) { + throw new PropertyConstraintException(messageTimeout, "messageTimeout is invalid"); + } + this.messageTimeout = messageTimeout; + } + + /** + * Returns whether the given messageTimeout is valid + * + * @param messageTimeout the messageTimeout to check the validity of + * @return {@code true} if messageTimeout is valid, {@code false} if not + */ + private boolean isValidMessageTimeout(Integer messageTimeout) { + return messageTimeout != null; + } + + /** + * Gets URL of the CSMS(s) that this Charging Station communicates with, without the Charging + * Station identity part. + * + * @return URL of the CSMS(s) that this Charging Station communicates with, without the Charging + * Station identity part + */ + public String getOcppCsmsUrl() { + return ocppCsmsUrl; + } + + /** + * Sets URL of the CSMS(s) that this Charging Station communicates with, without the Charging + * Station identity part. + * + * @param ocppCsmsUrl URL of the CSMS(s) that this Charging Station communicates with, without the + * Charging Station identity part + */ + public void setOcppCsmsUrl(String ocppCsmsUrl) { + if (!isValidOcppCsmsUrl(ocppCsmsUrl)) { + throw new PropertyConstraintException(ocppCsmsUrl, "ocppCsmsUrl is invalid"); + } + this.ocppCsmsUrl = ocppCsmsUrl; + } + + /** + * Returns whether the given ocppCsmsUrl is valid + * + * @param ocppCsmsUrl the ocppCsmsUrl to check the validity of + * @return {@code true} if ocppCsmsUrl is valid, {@code false} if not + */ + private boolean isValidOcppCsmsUrl(String ocppCsmsUrl) { + return ocppCsmsUrl != null && ocppCsmsUrl.length() <= 2000; + } + + /** + * Gets the security profile used when connecting to the CSMS with this NetworkConnectionProfile. + * + * @return The security profile used when connecting to the CSMS with this + * NetworkConnectionProfile + */ + public Integer getSecurityProfile() { + return securityProfile; + } + + /** + * Sets the security profile used when connecting to the CSMS with this NetworkConnectionProfile. + * + * @param securityProfile The security profile used when connecting to the CSMS with this + * NetworkConnectionProfile + */ + public void setSecurityProfile(Integer securityProfile) { + if (!isValidSecurityProfile(securityProfile)) { + throw new PropertyConstraintException(securityProfile, "securityProfile is invalid"); + } + this.securityProfile = securityProfile; + } + + /** + * Returns whether the given securityProfile is valid + * + * @param securityProfile the securityProfile to check the validity of + * @return {@code true} if securityProfile is valid, {@code false} if not + */ + private boolean isValidSecurityProfile(Integer securityProfile) { + return securityProfile != null && securityProfile >= 0; + } + + /** + * Gets charging Station identity to be used as the basic authentication username. + * + * @return Charging Station identity to be used as the basic authentication username + */ + @Nullable + public String getIdentity() { + return identity; + } + + /** + * Sets charging Station identity to be used as the basic authentication username. + * + * @param identity Charging Station identity to be used as the basic authentication username + */ + public void setIdentity(@Nullable String identity) { + if (!isValidIdentity(identity)) { + throw new PropertyConstraintException(identity, "identity is invalid"); + } + this.identity = identity; + } + + /** + * Returns whether the given identity is valid + * + * @param identity the identity to check the validity of + * @return {@code true} if identity is valid, {@code false} if not + */ + private boolean isValidIdentity(@Nullable String identity) { + return identity == null || identity.length() <= 48; + } + + /** + * Adds charging Station identity to be used as the basic authentication username. + * + * @param identity Charging Station identity to be used as the basic authentication username + * @return this + */ + public NetworkConnectionProfile withIdentity(@Nullable String identity) { + setIdentity(identity); + return this; + } + + /** + * Gets basicAuthPassword to use for security profile 1 or 2. + * + * @return BasicAuthPassword to use for security profile 1 or 2 + */ + @Nullable + public String getBasicAuthPassword() { + return basicAuthPassword; + } + + /** + * Sets basicAuthPassword to use for security profile 1 or 2. + * + * @param basicAuthPassword BasicAuthPassword to use for security profile 1 or 2 + */ + public void setBasicAuthPassword(@Nullable String basicAuthPassword) { + if (!isValidBasicAuthPassword(basicAuthPassword)) { + throw new PropertyConstraintException(basicAuthPassword, "basicAuthPassword is invalid"); + } + this.basicAuthPassword = basicAuthPassword; + } + + /** + * Returns whether the given basicAuthPassword is valid + * + * @param basicAuthPassword the basicAuthPassword to check the validity of + * @return {@code true} if basicAuthPassword is valid, {@code false} if not + */ + private boolean isValidBasicAuthPassword(@Nullable String basicAuthPassword) { + return basicAuthPassword == null || basicAuthPassword.length() <= 64; + } + + /** + * Adds basicAuthPassword to use for security profile 1 or 2. + * + * @param basicAuthPassword BasicAuthPassword to use for security profile 1 or 2 + * @return this + */ + public NetworkConnectionProfile withBasicAuthPassword(@Nullable String basicAuthPassword) { + setBasicAuthPassword(basicAuthPassword); + return this; + } + + /** + * Gets VPN Configuration settings + * + * @return VPN Configuration settings + */ + @Nullable + public VPN getVpn() { + return vpn; + } + + /** + * Sets VPN Configuration settings + * + * @param vpn VPN Configuration settings + */ + public void setVpn(@Nullable VPN vpn) { + if (!isValidVpn(vpn)) { + throw new PropertyConstraintException(vpn, "vpn is invalid"); + } + this.vpn = vpn; + } + + /** + * Returns whether the given vpn is valid + * + * @param vpn the vpn to check the validity of + * @return {@code true} if vpn is valid, {@code false} if not + */ + private boolean isValidVpn(@Nullable VPN vpn) { + return vpn == null || vpn.validate(); + } + + /** + * Adds VPN Configuration settings + * + * @param vpn VPN Configuration settings + * @return this + */ + public NetworkConnectionProfile withVpn(@Nullable VPN vpn) { + setVpn(vpn); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NetworkConnectionProfile withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidApn(apn) + && isValidOcppInterface(ocppInterface) + && isValidOcppTransport(ocppTransport) + && isValidMessageTimeout(messageTimeout) + && isValidOcppCsmsUrl(ocppCsmsUrl) + && isValidSecurityProfile(securityProfile) + && isValidIdentity(identity) + && isValidBasicAuthPassword(basicAuthPassword) + && isValidVpn(vpn) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkConnectionProfile that = (NetworkConnectionProfile) o; + return Objects.equals(apn, that.apn) + && Objects.equals(ocppVersion, that.ocppVersion) + && Objects.equals(ocppInterface, that.ocppInterface) + && Objects.equals(ocppTransport, that.ocppTransport) + && Objects.equals(messageTimeout, that.messageTimeout) + && Objects.equals(ocppCsmsUrl, that.ocppCsmsUrl) + && Objects.equals(securityProfile, that.securityProfile) + && Objects.equals(identity, that.identity) + && Objects.equals(basicAuthPassword, that.basicAuthPassword) + && Objects.equals(vpn, that.vpn) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + apn, + ocppVersion, + ocppInterface, + ocppTransport, + messageTimeout, + ocppCsmsUrl, + securityProfile, + identity, + basicAuthPassword, + vpn, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("apn", apn) + .add("ocppVersion", ocppVersion) + .add("ocppInterface", ocppInterface) + .add("ocppTransport", ocppTransport) + .add("messageTimeout", messageTimeout) + .add("ocppCsmsUrl", ocppCsmsUrl) + .add("securityProfile", securityProfile) + .add("identity", identity) + .add("basicAuthPassword", basicAuthPassword) + .add("vpn", vpn) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NotifyAllowedEnergyTransferStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NotifyAllowedEnergyTransferStatusEnum.java new file mode 100644 index 00000000..ae4934bc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NotifyAllowedEnergyTransferStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** NotifyAllowedEnergyTransferStatusEnumType */ +public enum NotifyAllowedEnergyTransferStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NotifyEVChargingNeedsStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NotifyEVChargingNeedsStatusEnum.java new file mode 100644 index 00000000..36bd8852 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/NotifyEVChargingNeedsStatusEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Returns whether the CSMS has been able to process the message successfully. It does not imply + * that the evChargingNeeds can be met with the current charging profile. + */ +public enum NotifyEVChargingNeedsStatusEnum { + Accepted, + Rejected, + Processing, + NoChargingProfile +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPInterfaceEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPInterfaceEnum.java new file mode 100644 index 00000000..2ccacfd3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPInterfaceEnum.java @@ -0,0 +1,41 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Applicable Network Interface. Charging Station is allowed to use a different network interface to + * connect if the given one does not work. + */ +public enum OCPPInterfaceEnum { + Wired0, + Wired1, + Wired2, + Wired3, + Wireless0, + Wireless1, + Wireless2, + Wireless3, + Any +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPTransportEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPTransportEnum.java new file mode 100644 index 00000000..4361cac7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPTransportEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * The transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.x, but is + * supported by earlier versions of OCPP. + */ +public enum OCPPTransportEnum { + SOAP, + JSON +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPVersionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPVersionEnum.java new file mode 100644 index 00000000..70ac59d6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCPPVersionEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * This field is ignored, since the OCPP version to use is determined during the websocket + * handshake. The field is only kept for backwards compatibility with the OCPP 2.0.1 JSON schema. + */ +public enum OCPPVersionEnum { + OCPP12, + OCPP15, + OCPP16, + OCPP20, + OCPP201, + OCPP21 +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCSPRequestData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCSPRequestData.java new file mode 100644 index 00000000..f2b1bdd7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OCSPRequestData.java @@ -0,0 +1,340 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Information about a certificate for an OCSP check. */ +public final class OCSPRequestData { + /** Used algorithms for the hashes provided. */ + private HashAlgorithmEnum hashAlgorithm; + + /** + * The hash of the issuer’s distinguished name (DN), that must be calculated over the DER encoding + * of the issuer’s name field in the certificate being checked. + */ + private String issuerNameHash; + + /** + * The hash of the DER encoded public key: the value (excluding tag and length) of the subject + * public key field in the issuer’s certificate. + */ + private String issuerKeyHash; + + /** + * The string representation of the hexadecimal value of the serial number without the prefix "0x" + * and without leading zeroes. + */ + private String serialNumber; + + /** The responder URL (Case insensitive). */ + private String responderURL; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the OCSPRequestData class + * + * @param hashAlgorithm Used algorithms for the hashes provided. + * @param issuerNameHash The hash of the issuer’s distinguished name (DN), that must be calculated + * over the DER encoding of the issuer’s name field in the certificate being checked. + * @param issuerKeyHash The hash of the DER encoded public key: the value (excluding tag and + * length) of the subject public key field in the issuer’s certificate. + * @param serialNumber The string representation of the hexadecimal value of the serial number + * without the prefix "0x" and without leading zeroes. + * @param responderURL The responder URL (Case insensitive). + */ + public OCSPRequestData( + HashAlgorithmEnum hashAlgorithm, + String issuerNameHash, + String issuerKeyHash, + String serialNumber, + String responderURL) { + setHashAlgorithm(hashAlgorithm); + setIssuerNameHash(issuerNameHash); + setIssuerKeyHash(issuerKeyHash); + setSerialNumber(serialNumber); + setResponderURL(responderURL); + } + + /** + * Gets used algorithms for the hashes provided. + * + * @return Used algorithms for the hashes provided + */ + public HashAlgorithmEnum getHashAlgorithm() { + return hashAlgorithm; + } + + /** + * Sets used algorithms for the hashes provided. + * + * @param hashAlgorithm Used algorithms for the hashes provided + */ + public void setHashAlgorithm(HashAlgorithmEnum hashAlgorithm) { + if (!isValidHashAlgorithm(hashAlgorithm)) { + throw new PropertyConstraintException(hashAlgorithm, "hashAlgorithm is invalid"); + } + this.hashAlgorithm = hashAlgorithm; + } + + /** + * Returns whether the given hashAlgorithm is valid + * + * @param hashAlgorithm the hashAlgorithm to check the validity of + * @return {@code true} if hashAlgorithm is valid, {@code false} if not + */ + private boolean isValidHashAlgorithm(HashAlgorithmEnum hashAlgorithm) { + return hashAlgorithm != null; + } + + /** + * Gets the hash of the issuer’s distinguished name (DN), that must be calculated over the DER + * encoding of the issuer’s name field in the certificate being checked. + * + * @return The hash of the issuer’s distinguished name (DN), that must be calculated over the DER + * encoding of the issuer’s name field in the certificate being checked + */ + public String getIssuerNameHash() { + return issuerNameHash; + } + + /** + * Sets the hash of the issuer’s distinguished name (DN), that must be calculated over the DER + * encoding of the issuer’s name field in the certificate being checked. + * + * @param issuerNameHash The hash of the issuer’s distinguished name (DN), that must be calculated + * over the DER encoding of the issuer’s name field in the certificate being checked + */ + public void setIssuerNameHash(String issuerNameHash) { + if (!isValidIssuerNameHash(issuerNameHash)) { + throw new PropertyConstraintException(issuerNameHash, "issuerNameHash is invalid"); + } + this.issuerNameHash = issuerNameHash; + } + + /** + * Returns whether the given issuerNameHash is valid + * + * @param issuerNameHash the issuerNameHash to check the validity of + * @return {@code true} if issuerNameHash is valid, {@code false} if not + */ + private boolean isValidIssuerNameHash(String issuerNameHash) { + return issuerNameHash != null && issuerNameHash.length() <= 128; + } + + /** + * Gets the hash of the DER encoded public key: the value (excluding tag and length) of the + * subject public key field in the issuer’s certificate. + * + * @return The hash of the DER encoded public key: the value (excluding tag and length) of the + * subject public key field in the issuer’s certificate + */ + public String getIssuerKeyHash() { + return issuerKeyHash; + } + + /** + * Sets the hash of the DER encoded public key: the value (excluding tag and length) of the + * subject public key field in the issuer’s certificate. + * + * @param issuerKeyHash The hash of the DER encoded public key: the value (excluding tag and + * length) of the subject public key field in the issuer’s certificate + */ + public void setIssuerKeyHash(String issuerKeyHash) { + if (!isValidIssuerKeyHash(issuerKeyHash)) { + throw new PropertyConstraintException(issuerKeyHash, "issuerKeyHash is invalid"); + } + this.issuerKeyHash = issuerKeyHash; + } + + /** + * Returns whether the given issuerKeyHash is valid + * + * @param issuerKeyHash the issuerKeyHash to check the validity of + * @return {@code true} if issuerKeyHash is valid, {@code false} if not + */ + private boolean isValidIssuerKeyHash(String issuerKeyHash) { + return issuerKeyHash != null && issuerKeyHash.length() <= 128; + } + + /** + * Gets the string representation of the hexadecimal value of the serial number without the prefix + * "0x" and without leading zeroes. + * + * @return The string representation of the hexadecimal value of the serial number without the + * prefix "0x" and without leading zeroes + */ + public String getSerialNumber() { + return serialNumber; + } + + /** + * Sets the string representation of the hexadecimal value of the serial number without the prefix + * "0x" and without leading zeroes. + * + * @param serialNumber The string representation of the hexadecimal value of the serial number + * without the prefix "0x" and without leading zeroes + */ + public void setSerialNumber(String serialNumber) { + if (!isValidSerialNumber(serialNumber)) { + throw new PropertyConstraintException(serialNumber, "serialNumber is invalid"); + } + this.serialNumber = serialNumber; + } + + /** + * Returns whether the given serialNumber is valid + * + * @param serialNumber the serialNumber to check the validity of + * @return {@code true} if serialNumber is valid, {@code false} if not + */ + private boolean isValidSerialNumber(String serialNumber) { + return serialNumber != null && serialNumber.length() <= 40; + } + + /** + * Gets the responder URL (Case insensitive). + * + * @return The responder URL (Case insensitive) + */ + public String getResponderURL() { + return responderURL; + } + + /** + * Sets the responder URL (Case insensitive). + * + * @param responderURL The responder URL (Case insensitive) + */ + public void setResponderURL(String responderURL) { + if (!isValidResponderURL(responderURL)) { + throw new PropertyConstraintException(responderURL, "responderURL is invalid"); + } + this.responderURL = responderURL; + } + + /** + * Returns whether the given responderURL is valid + * + * @param responderURL the responderURL to check the validity of + * @return {@code true} if responderURL is valid, {@code false} if not + */ + private boolean isValidResponderURL(String responderURL) { + return responderURL != null && responderURL.length() <= 2000; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public OCSPRequestData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidHashAlgorithm(hashAlgorithm) + && isValidIssuerNameHash(issuerNameHash) + && isValidIssuerKeyHash(issuerKeyHash) + && isValidSerialNumber(serialNumber) + && isValidResponderURL(responderURL) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OCSPRequestData that = (OCSPRequestData) o; + return Objects.equals(hashAlgorithm, that.hashAlgorithm) + && Objects.equals(issuerNameHash, that.issuerNameHash) + && Objects.equals(issuerKeyHash, that.issuerKeyHash) + && Objects.equals(serialNumber, that.serialNumber) + && Objects.equals(responderURL, that.responderURL) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + hashAlgorithm, issuerNameHash, issuerKeyHash, serialNumber, responderURL, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("hashAlgorithm", hashAlgorithm) + .add("issuerNameHash", issuerNameHash) + .add("issuerKeyHash", issuerKeyHash) + .add("serialNumber", serialNumber) + .add("responderURL", responderURL) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OperationModeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OperationModeEnum.java new file mode 100644 index 00000000..bd1d2370 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OperationModeEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The operationMode that is currently in effect for the transaction. */ +public enum OperationModeEnum { + Idle, + ChargingOnly, + CentralSetpoint, + ExternalSetpoint, + ExternalLimits, + CentralFrequency, + LocalFrequency, + LocalLoadBalancing +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OperationalStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OperationalStatusEnum.java new file mode 100644 index 00000000..1b4d3483 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OperationalStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The type of availability change that the Charging Station should perform. */ +public enum OperationalStatusEnum { + Inoperative, + Operative +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OverstayRule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OverstayRule.java new file mode 100644 index 00000000..72b6fd29 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OverstayRule.java @@ -0,0 +1,290 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Part of ISO 15118-20 price schedule. */ +public final class OverstayRule { + /** Part of ISO 15118-20 price schedule. */ + private RationalNumber overstayFee; + + /** Human readable string to identify the overstay rule. */ + @Nullable private String overstayRuleDescription; + + /** + * Time in seconds after trigger of the parent Overstay Rules for this particular fee to apply. + */ + private Integer startTime; + + /** Time till overstay will be reapplied */ + private Integer overstayFeePeriod; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the OverstayRule class + * + * @param overstayFee Part of ISO 15118-20 price schedule. + * @param startTime Time in seconds after trigger of the parent Overstay Rules for this particular + * fee to apply. + * @param overstayFeePeriod Time till overstay will be reapplied + */ + public OverstayRule(RationalNumber overstayFee, Integer startTime, Integer overstayFeePeriod) { + setOverstayFee(overstayFee); + setStartTime(startTime); + setOverstayFeePeriod(overstayFeePeriod); + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public RationalNumber getOverstayFee() { + return overstayFee; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param overstayFee Part of ISO 15118-20 price schedule + */ + public void setOverstayFee(RationalNumber overstayFee) { + if (!isValidOverstayFee(overstayFee)) { + throw new PropertyConstraintException(overstayFee, "overstayFee is invalid"); + } + this.overstayFee = overstayFee; + } + + /** + * Returns whether the given overstayFee is valid + * + * @param overstayFee the overstayFee to check the validity of + * @return {@code true} if overstayFee is valid, {@code false} if not + */ + private boolean isValidOverstayFee(RationalNumber overstayFee) { + return overstayFee != null && overstayFee.validate(); + } + + /** + * Gets human readable string to identify the overstay rule. + * + * @return Human readable string to identify the overstay rule + */ + @Nullable + public String getOverstayRuleDescription() { + return overstayRuleDescription; + } + + /** + * Sets human readable string to identify the overstay rule. + * + * @param overstayRuleDescription Human readable string to identify the overstay rule + */ + public void setOverstayRuleDescription(@Nullable String overstayRuleDescription) { + if (!isValidOverstayRuleDescription(overstayRuleDescription)) { + throw new PropertyConstraintException( + overstayRuleDescription, "overstayRuleDescription is invalid"); + } + this.overstayRuleDescription = overstayRuleDescription; + } + + /** + * Returns whether the given overstayRuleDescription is valid + * + * @param overstayRuleDescription the overstayRuleDescription to check the validity of + * @return {@code true} if overstayRuleDescription is valid, {@code false} if not + */ + private boolean isValidOverstayRuleDescription(@Nullable String overstayRuleDescription) { + return overstayRuleDescription == null || overstayRuleDescription.length() <= 32; + } + + /** + * Adds human readable string to identify the overstay rule. + * + * @param overstayRuleDescription Human readable string to identify the overstay rule + * @return this + */ + public OverstayRule withOverstayRuleDescription(@Nullable String overstayRuleDescription) { + setOverstayRuleDescription(overstayRuleDescription); + return this; + } + + /** + * Gets time in seconds after trigger of the parent Overstay Rules for this particular fee to + * apply. + * + * @return Time in seconds after trigger of the parent Overstay Rules for this particular fee to + * apply + */ + public Integer getStartTime() { + return startTime; + } + + /** + * Sets time in seconds after trigger of the parent Overstay Rules for this particular fee to + * apply. + * + * @param startTime Time in seconds after trigger of the parent Overstay Rules for this particular + * fee to apply + */ + public void setStartTime(Integer startTime) { + if (!isValidStartTime(startTime)) { + throw new PropertyConstraintException(startTime, "startTime is invalid"); + } + this.startTime = startTime; + } + + /** + * Returns whether the given startTime is valid + * + * @param startTime the startTime to check the validity of + * @return {@code true} if startTime is valid, {@code false} if not + */ + private boolean isValidStartTime(Integer startTime) { + return startTime != null; + } + + /** + * Gets time till overstay will be reapplied + * + * @return Time till overstay will be reapplied + */ + public Integer getOverstayFeePeriod() { + return overstayFeePeriod; + } + + /** + * Sets time till overstay will be reapplied + * + * @param overstayFeePeriod Time till overstay will be reapplied + */ + public void setOverstayFeePeriod(Integer overstayFeePeriod) { + if (!isValidOverstayFeePeriod(overstayFeePeriod)) { + throw new PropertyConstraintException(overstayFeePeriod, "overstayFeePeriod is invalid"); + } + this.overstayFeePeriod = overstayFeePeriod; + } + + /** + * Returns whether the given overstayFeePeriod is valid + * + * @param overstayFeePeriod the overstayFeePeriod to check the validity of + * @return {@code true} if overstayFeePeriod is valid, {@code false} if not + */ + private boolean isValidOverstayFeePeriod(Integer overstayFeePeriod) { + return overstayFeePeriod != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public OverstayRule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidOverstayFee(overstayFee) + && isValidOverstayRuleDescription(overstayRuleDescription) + && isValidStartTime(startTime) + && isValidOverstayFeePeriod(overstayFeePeriod) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OverstayRule that = (OverstayRule) o; + return Objects.equals(overstayFee, that.overstayFee) + && Objects.equals(overstayRuleDescription, that.overstayRuleDescription) + && Objects.equals(startTime, that.startTime) + && Objects.equals(overstayFeePeriod, that.overstayFeePeriod) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + overstayFee, overstayRuleDescription, startTime, overstayFeePeriod, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("overstayFee", overstayFee) + .add("overstayRuleDescription", overstayRuleDescription) + .add("startTime", startTime) + .add("overstayFeePeriod", overstayFeePeriod) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OverstayRuleList.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OverstayRuleList.java new file mode 100644 index 00000000..76631fb4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/OverstayRuleList.java @@ -0,0 +1,245 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Part of ISO 15118-20 price schedule. */ +public final class OverstayRuleList { + /** Part of ISO 15118-20 price schedule. */ + @Nullable private RationalNumber overstayPowerThreshold; + + /** Part of ISO 15118-20 price schedule. */ + private OverstayRule[] overstayRule; + + /** Time till overstay is applied in seconds. */ + @Nullable private Integer overstayTimeThreshold; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the OverstayRuleList class + * + * @param overstayRule Part of ISO 15118-20 price schedule. + */ + public OverstayRuleList(OverstayRule[] overstayRule) { + setOverstayRule(overstayRule); + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + @Nullable + public RationalNumber getOverstayPowerThreshold() { + return overstayPowerThreshold; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param overstayPowerThreshold Part of ISO 15118-20 price schedule + */ + public void setOverstayPowerThreshold(@Nullable RationalNumber overstayPowerThreshold) { + if (!isValidOverstayPowerThreshold(overstayPowerThreshold)) { + throw new PropertyConstraintException( + overstayPowerThreshold, "overstayPowerThreshold is invalid"); + } + this.overstayPowerThreshold = overstayPowerThreshold; + } + + /** + * Returns whether the given overstayPowerThreshold is valid + * + * @param overstayPowerThreshold the overstayPowerThreshold to check the validity of + * @return {@code true} if overstayPowerThreshold is valid, {@code false} if not + */ + private boolean isValidOverstayPowerThreshold(@Nullable RationalNumber overstayPowerThreshold) { + return overstayPowerThreshold == null || overstayPowerThreshold.validate(); + } + + /** + * Adds part of ISO 15118-20 price schedule. + * + * @param overstayPowerThreshold Part of ISO 15118-20 price schedule + * @return this + */ + public OverstayRuleList withOverstayPowerThreshold( + @Nullable RationalNumber overstayPowerThreshold) { + setOverstayPowerThreshold(overstayPowerThreshold); + return this; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public OverstayRule[] getOverstayRule() { + return overstayRule; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param overstayRule Part of ISO 15118-20 price schedule + */ + public void setOverstayRule(OverstayRule[] overstayRule) { + if (!isValidOverstayRule(overstayRule)) { + throw new PropertyConstraintException(overstayRule, "overstayRule is invalid"); + } + this.overstayRule = overstayRule; + } + + /** + * Returns whether the given overstayRule is valid + * + * @param overstayRule the overstayRule to check the validity of + * @return {@code true} if overstayRule is valid, {@code false} if not + */ + private boolean isValidOverstayRule(OverstayRule[] overstayRule) { + return overstayRule != null + && overstayRule.length >= 1 + && overstayRule.length <= 5 + && Arrays.stream(overstayRule).allMatch(item -> item.validate()); + } + + /** + * Gets time till overstay is applied in seconds. + * + * @return Time till overstay is applied in seconds + */ + @Nullable + public Integer getOverstayTimeThreshold() { + return overstayTimeThreshold; + } + + /** + * Sets time till overstay is applied in seconds. + * + * @param overstayTimeThreshold Time till overstay is applied in seconds + */ + public void setOverstayTimeThreshold(@Nullable Integer overstayTimeThreshold) { + this.overstayTimeThreshold = overstayTimeThreshold; + } + + /** + * Adds time till overstay is applied in seconds. + * + * @param overstayTimeThreshold Time till overstay is applied in seconds + * @return this + */ + public OverstayRuleList withOverstayTimeThreshold(@Nullable Integer overstayTimeThreshold) { + setOverstayTimeThreshold(overstayTimeThreshold); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public OverstayRuleList withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidOverstayPowerThreshold(overstayPowerThreshold) + && isValidOverstayRule(overstayRule) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OverstayRuleList that = (OverstayRuleList) o; + return Objects.equals(overstayPowerThreshold, that.overstayPowerThreshold) + && Arrays.equals(overstayRule, that.overstayRule) + && Objects.equals(overstayTimeThreshold, that.overstayTimeThreshold) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + overstayPowerThreshold, Arrays.hashCode(overstayRule), overstayTimeThreshold, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("overstayPowerThreshold", overstayPowerThreshold) + .add("overstayRule", overstayRule) + .add("overstayTimeThreshold", overstayTimeThreshold) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PaymentStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PaymentStatusEnum.java new file mode 100644 index 00000000..45b8e642 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PaymentStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The status of the settlement attempt. */ +public enum PaymentStatusEnum { + Settled, + Canceled, + Rejected, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PeriodicEventStreamParams.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PeriodicEventStreamParams.java new file mode 100644 index 00000000..0f3b0a31 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PeriodicEventStreamParams.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** PeriodicEventStreamParamsType */ +public final class PeriodicEventStreamParams { + /** Time in seconds after which stream data is sent. */ + @Nullable private Integer interval; + + /** Number of items to be sent together in stream. */ + @Nullable private Integer values; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the PeriodicEventStreamParams class */ + public PeriodicEventStreamParams() {} + + /** + * Gets time in seconds after which stream data is sent. + * + * @return Time in seconds after which stream data is sent + */ + @Nullable + public Integer getInterval() { + return interval; + } + + /** + * Sets time in seconds after which stream data is sent. + * + * @param interval Time in seconds after which stream data is sent + */ + public void setInterval(@Nullable Integer interval) { + if (!isValidInterval(interval)) { + throw new PropertyConstraintException(interval, "interval is invalid"); + } + this.interval = interval; + } + + /** + * Returns whether the given interval is valid + * + * @param interval the interval to check the validity of + * @return {@code true} if interval is valid, {@code false} if not + */ + private boolean isValidInterval(@Nullable Integer interval) { + return interval == null || (interval >= 0); + } + + /** + * Adds time in seconds after which stream data is sent. + * + * @param interval Time in seconds after which stream data is sent + * @return this + */ + public PeriodicEventStreamParams withInterval(@Nullable Integer interval) { + setInterval(interval); + return this; + } + + /** + * Gets number of items to be sent together in stream. + * + * @return Number of items to be sent together in stream + */ + @Nullable + public Integer getValues() { + return values; + } + + /** + * Sets number of items to be sent together in stream. + * + * @param values Number of items to be sent together in stream + */ + public void setValues(@Nullable Integer values) { + if (!isValidValues(values)) { + throw new PropertyConstraintException(values, "values is invalid"); + } + this.values = values; + } + + /** + * Returns whether the given values is valid + * + * @param values the values to check the validity of + * @return {@code true} if values is valid, {@code false} if not + */ + private boolean isValidValues(@Nullable Integer values) { + return values == null || (values >= 0); + } + + /** + * Adds number of items to be sent together in stream. + * + * @param values Number of items to be sent together in stream + * @return this + */ + public PeriodicEventStreamParams withValues(@Nullable Integer values) { + setValues(values); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PeriodicEventStreamParams withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidInterval(interval) && isValidValues(values) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PeriodicEventStreamParams that = (PeriodicEventStreamParams) o; + return Objects.equals(interval, that.interval) + && Objects.equals(values, that.values) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(interval, values, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("interval", interval) + .add("values", values) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PhaseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PhaseEnum.java new file mode 100644 index 00000000..fd37b330 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PhaseEnum.java @@ -0,0 +1,51 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import com.google.gson.annotations.SerializedName; + +/** + * How the measured value is to be interpreted. For instance between L1 and neutral (L1-N) Please + * note that not all values of phase are applicable to all Measurands. When phase is absent, the + * measured value is interpreted as an overall value. + */ +public enum PhaseEnum { + L1, + L2, + L3, + N, + @SerializedName("L1-N") + L1_N, + @SerializedName("L2-N") + L2_N, + @SerializedName("L3-N") + L3_N, + @SerializedName("L1-L2") + L1_L2, + @SerializedName("L2-L3") + L2_L3, + @SerializedName("L3-L1") + L3_L1 +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PowerDuringCessationEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PowerDuringCessationEnum.java new file mode 100644 index 00000000..09ed1f31 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PowerDuringCessationEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Parameter is only sent, if the EV has to feed-in power or reactive power during fault-ride + * through (FRT) as defined by HVMomCess curve and LVMomCess curve. + */ +public enum PowerDuringCessationEnum { + Active, + Reactive +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PreconditioningStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PreconditioningStatusEnum.java new file mode 100644 index 00000000..74581336 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PreconditioningStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The current preconditioning status of the BMS in the EV. Default value is Unknown. */ +public enum PreconditioningStatusEnum { + Unknown, + Ready, + NotReady, + Preconditioning +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Price.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Price.java new file mode 100644 index 00000000..73f2644d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Price.java @@ -0,0 +1,233 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Price with and without tax. At least one of exclTax, inclTax must be present. */ +public final class Price { + /** Price/cost excluding tax. Can be absent if inclTax is present. */ + @Nullable private Double exclTax; + + /** Price/cost including tax. Can be absent if exclTax is present. */ + @Nullable private Double inclTax; + + /** Tax percentage */ + @Nullable private TaxRate[] taxRates; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the Price class */ + public Price() {} + + /** + * Gets price/cost excluding tax. Can be absent if inclTax is present. + * + * @return Price/cost excluding tax + */ + @Nullable + public Double getExclTax() { + return exclTax; + } + + /** + * Sets price/cost excluding tax. Can be absent if inclTax is present. + * + * @param exclTax Price/cost excluding tax + */ + public void setExclTax(@Nullable Double exclTax) { + this.exclTax = exclTax; + } + + /** + * Adds price/cost excluding tax. Can be absent if inclTax is present. + * + * @param exclTax Price/cost excluding tax + * @return this + */ + public Price withExclTax(@Nullable Double exclTax) { + setExclTax(exclTax); + return this; + } + + /** + * Gets price/cost including tax. Can be absent if exclTax is present. + * + * @return Price/cost including tax + */ + @Nullable + public Double getInclTax() { + return inclTax; + } + + /** + * Sets price/cost including tax. Can be absent if exclTax is present. + * + * @param inclTax Price/cost including tax + */ + public void setInclTax(@Nullable Double inclTax) { + this.inclTax = inclTax; + } + + /** + * Adds price/cost including tax. Can be absent if exclTax is present. + * + * @param inclTax Price/cost including tax + * @return this + */ + public Price withInclTax(@Nullable Double inclTax) { + setInclTax(inclTax); + return this; + } + + /** + * Gets tax percentage + * + * @return Tax percentage + */ + @Nullable + public TaxRate[] getTaxRates() { + return taxRates; + } + + /** + * Sets tax percentage + * + * @param taxRates Tax percentage + */ + public void setTaxRates(@Nullable TaxRate[] taxRates) { + if (!isValidTaxRates(taxRates)) { + throw new PropertyConstraintException(taxRates, "taxRates is invalid"); + } + this.taxRates = taxRates; + } + + /** + * Returns whether the given taxRates is valid + * + * @param taxRates the taxRates to check the validity of + * @return {@code true} if taxRates is valid, {@code false} if not + */ + private boolean isValidTaxRates(@Nullable TaxRate[] taxRates) { + return taxRates == null + || (taxRates.length >= 1 + && taxRates.length <= 5 + && Arrays.stream(taxRates).allMatch(item -> item.validate())); + } + + /** + * Adds tax percentage + * + * @param taxRates Tax percentage + * @return this + */ + public Price withTaxRates(@Nullable TaxRate[] taxRates) { + setTaxRates(taxRates); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Price withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidTaxRates(taxRates) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Price that = (Price) o; + return Objects.equals(exclTax, that.exclTax) + && Objects.equals(inclTax, that.inclTax) + && Arrays.equals(taxRates, that.taxRates) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(exclTax, inclTax, Arrays.hashCode(taxRates), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("exclTax", exclTax) + .add("inclTax", inclTax) + .add("taxRates", taxRates) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceLevelSchedule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceLevelSchedule.java new file mode 100644 index 00000000..88df8781 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceLevelSchedule.java @@ -0,0 +1,346 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * The PriceLevelScheduleType is modeled after the same type that is defined in ISO 15118-20, such + * that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON (in + * OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not + * invalidate the signature. + */ +public final class PriceLevelSchedule { + /** Part of ISO 15118-20 price schedule. */ + private PriceLevelScheduleEntry[] priceLevelScheduleEntries; + + /** Starting point of this price schedule. */ + private ZonedDateTime timeAnchor; + + /** Unique ID of this price schedule. */ + private Integer priceScheduleId; + + /** Description of the price schedule. */ + @Nullable private String priceScheduleDescription; + + /** The overall number of distinct price level elements used across all PriceLevelSchedules. */ + private Integer numberOfPriceLevels; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PriceLevelSchedule class + * + * @param priceLevelScheduleEntries Part of ISO 15118-20 price schedule. + * @param timeAnchor Starting point of this price schedule. + * @param priceScheduleId Unique ID of this price schedule. + * @param numberOfPriceLevels The overall number of distinct price level elements used across all + * PriceLevelSchedules. + */ + public PriceLevelSchedule( + PriceLevelScheduleEntry[] priceLevelScheduleEntries, + ZonedDateTime timeAnchor, + Integer priceScheduleId, + Integer numberOfPriceLevels) { + setPriceLevelScheduleEntries(priceLevelScheduleEntries); + setTimeAnchor(timeAnchor); + setPriceScheduleId(priceScheduleId); + setNumberOfPriceLevels(numberOfPriceLevels); + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public PriceLevelScheduleEntry[] getPriceLevelScheduleEntries() { + return priceLevelScheduleEntries; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param priceLevelScheduleEntries Part of ISO 15118-20 price schedule + */ + public void setPriceLevelScheduleEntries(PriceLevelScheduleEntry[] priceLevelScheduleEntries) { + if (!isValidPriceLevelScheduleEntries(priceLevelScheduleEntries)) { + throw new PropertyConstraintException( + priceLevelScheduleEntries, "priceLevelScheduleEntries is invalid"); + } + this.priceLevelScheduleEntries = priceLevelScheduleEntries; + } + + /** + * Returns whether the given priceLevelScheduleEntries is valid + * + * @param priceLevelScheduleEntries the priceLevelScheduleEntries to check the validity of + * @return {@code true} if priceLevelScheduleEntries is valid, {@code false} if not + */ + private boolean isValidPriceLevelScheduleEntries( + PriceLevelScheduleEntry[] priceLevelScheduleEntries) { + return priceLevelScheduleEntries != null + && priceLevelScheduleEntries.length >= 1 + && priceLevelScheduleEntries.length <= 100 + && Arrays.stream(priceLevelScheduleEntries).allMatch(item -> item.validate()); + } + + /** + * Gets starting point of this price schedule. + * + * @return Starting point of this price schedule + */ + public ZonedDateTime getTimeAnchor() { + return timeAnchor; + } + + /** + * Sets starting point of this price schedule. + * + * @param timeAnchor Starting point of this price schedule + */ + public void setTimeAnchor(ZonedDateTime timeAnchor) { + if (!isValidTimeAnchor(timeAnchor)) { + throw new PropertyConstraintException(timeAnchor, "timeAnchor is invalid"); + } + this.timeAnchor = timeAnchor; + } + + /** + * Returns whether the given timeAnchor is valid + * + * @param timeAnchor the timeAnchor to check the validity of + * @return {@code true} if timeAnchor is valid, {@code false} if not + */ + private boolean isValidTimeAnchor(ZonedDateTime timeAnchor) { + return timeAnchor != null; + } + + /** + * Gets unique ID of this price schedule. + * + * @return Unique ID of this price schedule + */ + public Integer getPriceScheduleId() { + return priceScheduleId; + } + + /** + * Sets unique ID of this price schedule. + * + * @param priceScheduleId Unique ID of this price schedule + */ + public void setPriceScheduleId(Integer priceScheduleId) { + if (!isValidPriceScheduleId(priceScheduleId)) { + throw new PropertyConstraintException(priceScheduleId, "priceScheduleId is invalid"); + } + this.priceScheduleId = priceScheduleId; + } + + /** + * Returns whether the given priceScheduleId is valid + * + * @param priceScheduleId the priceScheduleId to check the validity of + * @return {@code true} if priceScheduleId is valid, {@code false} if not + */ + private boolean isValidPriceScheduleId(Integer priceScheduleId) { + return priceScheduleId != null && priceScheduleId >= 0; + } + + /** + * Gets description of the price schedule. + * + * @return Description of the price schedule + */ + @Nullable + public String getPriceScheduleDescription() { + return priceScheduleDescription; + } + + /** + * Sets description of the price schedule. + * + * @param priceScheduleDescription Description of the price schedule + */ + public void setPriceScheduleDescription(@Nullable String priceScheduleDescription) { + if (!isValidPriceScheduleDescription(priceScheduleDescription)) { + throw new PropertyConstraintException( + priceScheduleDescription, "priceScheduleDescription is invalid"); + } + this.priceScheduleDescription = priceScheduleDescription; + } + + /** + * Returns whether the given priceScheduleDescription is valid + * + * @param priceScheduleDescription the priceScheduleDescription to check the validity of + * @return {@code true} if priceScheduleDescription is valid, {@code false} if not + */ + private boolean isValidPriceScheduleDescription(@Nullable String priceScheduleDescription) { + return priceScheduleDescription == null || priceScheduleDescription.length() <= 32; + } + + /** + * Adds description of the price schedule. + * + * @param priceScheduleDescription Description of the price schedule + * @return this + */ + public PriceLevelSchedule withPriceScheduleDescription( + @Nullable String priceScheduleDescription) { + setPriceScheduleDescription(priceScheduleDescription); + return this; + } + + /** + * Gets the overall number of distinct price level elements used across all PriceLevelSchedules. + * + * @return The overall number of distinct price level elements used across all PriceLevelSchedules + */ + public Integer getNumberOfPriceLevels() { + return numberOfPriceLevels; + } + + /** + * Sets the overall number of distinct price level elements used across all PriceLevelSchedules. + * + * @param numberOfPriceLevels The overall number of distinct price level elements used across all + * PriceLevelSchedules + */ + public void setNumberOfPriceLevels(Integer numberOfPriceLevels) { + if (!isValidNumberOfPriceLevels(numberOfPriceLevels)) { + throw new PropertyConstraintException(numberOfPriceLevels, "numberOfPriceLevels is invalid"); + } + this.numberOfPriceLevels = numberOfPriceLevels; + } + + /** + * Returns whether the given numberOfPriceLevels is valid + * + * @param numberOfPriceLevels the numberOfPriceLevels to check the validity of + * @return {@code true} if numberOfPriceLevels is valid, {@code false} if not + */ + private boolean isValidNumberOfPriceLevels(Integer numberOfPriceLevels) { + return numberOfPriceLevels != null && numberOfPriceLevels >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PriceLevelSchedule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriceLevelScheduleEntries(priceLevelScheduleEntries) + && isValidTimeAnchor(timeAnchor) + && isValidPriceScheduleId(priceScheduleId) + && isValidPriceScheduleDescription(priceScheduleDescription) + && isValidNumberOfPriceLevels(numberOfPriceLevels) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PriceLevelSchedule that = (PriceLevelSchedule) o; + return Arrays.equals(priceLevelScheduleEntries, that.priceLevelScheduleEntries) + && Objects.equals(timeAnchor, that.timeAnchor) + && Objects.equals(priceScheduleId, that.priceScheduleId) + && Objects.equals(priceScheduleDescription, that.priceScheduleDescription) + && Objects.equals(numberOfPriceLevels, that.numberOfPriceLevels) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(priceLevelScheduleEntries), + timeAnchor, + priceScheduleId, + priceScheduleDescription, + numberOfPriceLevels, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priceLevelScheduleEntries", priceLevelScheduleEntries) + .add("timeAnchor", timeAnchor) + .add("priceScheduleId", priceScheduleId) + .add("priceScheduleDescription", priceScheduleDescription) + .add("numberOfPriceLevels", numberOfPriceLevels) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceLevelScheduleEntry.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceLevelScheduleEntry.java new file mode 100644 index 00000000..71520224 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceLevelScheduleEntry.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Part of ISO 15118-20 price schedule. */ +public final class PriceLevelScheduleEntry { + /** The amount of seconds that define the duration of this given PriceLevelScheduleEntry. */ + private Integer duration; + + /** + * The price level of this PriceLevelScheduleEntry (referring to NumberOfPriceLevels). Small + * values for the PriceLevel represent a cheaper PriceLevelScheduleEntry. Large values for the + * PriceLevel represent a more expensive PriceLevelScheduleEntry. + */ + private Integer priceLevel; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PriceLevelScheduleEntry class + * + * @param duration The amount of seconds that define the duration of this given + * PriceLevelScheduleEntry. + * @param priceLevel The price level of this PriceLevelScheduleEntry (referring to + * NumberOfPriceLevels). Small values for the PriceLevel represent a cheaper + * PriceLevelScheduleEntry. Large values for the PriceLevel represent a more expensive + * PriceLevelScheduleEntry. + */ + public PriceLevelScheduleEntry(Integer duration, Integer priceLevel) { + setDuration(duration); + setPriceLevel(priceLevel); + } + + /** + * Gets the amount of seconds that define the duration of this given PriceLevelScheduleEntry. + * + * @return The amount of seconds that define the duration of this given PriceLevelScheduleEntry + */ + public Integer getDuration() { + return duration; + } + + /** + * Sets the amount of seconds that define the duration of this given PriceLevelScheduleEntry. + * + * @param duration The amount of seconds that define the duration of this given + * PriceLevelScheduleEntry + */ + public void setDuration(Integer duration) { + if (!isValidDuration(duration)) { + throw new PropertyConstraintException(duration, "duration is invalid"); + } + this.duration = duration; + } + + /** + * Returns whether the given duration is valid + * + * @param duration the duration to check the validity of + * @return {@code true} if duration is valid, {@code false} if not + */ + private boolean isValidDuration(Integer duration) { + return duration != null; + } + + /** + * Gets the price level of this PriceLevelScheduleEntry (referring to NumberOfPriceLevels). Small + * values for the PriceLevel represent a cheaper PriceLevelScheduleEntry. Large values for the + * PriceLevel represent a more expensive PriceLevelScheduleEntry. + * + * @return The price level of this PriceLevelScheduleEntry (referring to NumberOfPriceLevels) + */ + public Integer getPriceLevel() { + return priceLevel; + } + + /** + * Sets the price level of this PriceLevelScheduleEntry (referring to NumberOfPriceLevels). Small + * values for the PriceLevel represent a cheaper PriceLevelScheduleEntry. Large values for the + * PriceLevel represent a more expensive PriceLevelScheduleEntry. + * + * @param priceLevel The price level of this PriceLevelScheduleEntry (referring to + * NumberOfPriceLevels) + */ + public void setPriceLevel(Integer priceLevel) { + if (!isValidPriceLevel(priceLevel)) { + throw new PropertyConstraintException(priceLevel, "priceLevel is invalid"); + } + this.priceLevel = priceLevel; + } + + /** + * Returns whether the given priceLevel is valid + * + * @param priceLevel the priceLevel to check the validity of + * @return {@code true} if priceLevel is valid, {@code false} if not + */ + private boolean isValidPriceLevel(Integer priceLevel) { + return priceLevel != null && priceLevel >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PriceLevelScheduleEntry withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDuration(duration) + && isValidPriceLevel(priceLevel) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PriceLevelScheduleEntry that = (PriceLevelScheduleEntry) o; + return Objects.equals(duration, that.duration) + && Objects.equals(priceLevel, that.priceLevel) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(duration, priceLevel, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("duration", duration) + .add("priceLevel", priceLevel) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceRule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceRule.java new file mode 100644 index 00000000..6e89df04 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceRule.java @@ -0,0 +1,395 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Part of ISO 15118-20 price schedule. */ +public final class PriceRule { + /** + * The duration of the parking fee period (in seconds). When the time enters into a + * ParkingFeePeriod, the ParkingFee will apply to the session. . + */ + @Nullable private Integer parkingFeePeriod; + + /** Number of grams of CO2 per kWh. */ + @Nullable private Integer carbonDioxideEmission; + + /** Percentage of the power that is created by renewable resources. */ + @Nullable private Integer renewableGenerationPercentage; + + /** Part of ISO 15118-20 price schedule. */ + private RationalNumber energyFee; + + /** Part of ISO 15118-20 price schedule. */ + @Nullable private RationalNumber parkingFee; + + /** Part of ISO 15118-20 price schedule. */ + private RationalNumber powerRangeStart; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PriceRule class + * + * @param energyFee Part of ISO 15118-20 price schedule. + * @param powerRangeStart Part of ISO 15118-20 price schedule. + */ + public PriceRule(RationalNumber energyFee, RationalNumber powerRangeStart) { + setEnergyFee(energyFee); + setPowerRangeStart(powerRangeStart); + } + + /** + * Gets the duration of the parking fee period (in seconds). When the time enters into a + * ParkingFeePeriod, the ParkingFee will apply to the session. . + * + * @return The duration of the parking fee period (in seconds) + */ + @Nullable + public Integer getParkingFeePeriod() { + return parkingFeePeriod; + } + + /** + * Sets the duration of the parking fee period (in seconds). When the time enters into a + * ParkingFeePeriod, the ParkingFee will apply to the session. . + * + * @param parkingFeePeriod The duration of the parking fee period (in seconds) + */ + public void setParkingFeePeriod(@Nullable Integer parkingFeePeriod) { + this.parkingFeePeriod = parkingFeePeriod; + } + + /** + * Adds the duration of the parking fee period (in seconds). When the time enters into a + * ParkingFeePeriod, the ParkingFee will apply to the session. . + * + * @param parkingFeePeriod The duration of the parking fee period (in seconds) + * @return this + */ + public PriceRule withParkingFeePeriod(@Nullable Integer parkingFeePeriod) { + setParkingFeePeriod(parkingFeePeriod); + return this; + } + + /** + * Gets number of grams of CO2 per kWh. + * + * @return Number of grams of CO2 per kWh + */ + @Nullable + public Integer getCarbonDioxideEmission() { + return carbonDioxideEmission; + } + + /** + * Sets number of grams of CO2 per kWh. + * + * @param carbonDioxideEmission Number of grams of CO2 per kWh + */ + public void setCarbonDioxideEmission(@Nullable Integer carbonDioxideEmission) { + if (!isValidCarbonDioxideEmission(carbonDioxideEmission)) { + throw new PropertyConstraintException( + carbonDioxideEmission, "carbonDioxideEmission is invalid"); + } + this.carbonDioxideEmission = carbonDioxideEmission; + } + + /** + * Returns whether the given carbonDioxideEmission is valid + * + * @param carbonDioxideEmission the carbonDioxideEmission to check the validity of + * @return {@code true} if carbonDioxideEmission is valid, {@code false} if not + */ + private boolean isValidCarbonDioxideEmission(@Nullable Integer carbonDioxideEmission) { + return carbonDioxideEmission == null || (carbonDioxideEmission >= 0); + } + + /** + * Adds number of grams of CO2 per kWh. + * + * @param carbonDioxideEmission Number of grams of CO2 per kWh + * @return this + */ + public PriceRule withCarbonDioxideEmission(@Nullable Integer carbonDioxideEmission) { + setCarbonDioxideEmission(carbonDioxideEmission); + return this; + } + + /** + * Gets percentage of the power that is created by renewable resources. + * + * @return Percentage of the power that is created by renewable resources + */ + @Nullable + public Integer getRenewableGenerationPercentage() { + return renewableGenerationPercentage; + } + + /** + * Sets percentage of the power that is created by renewable resources. + * + * @param renewableGenerationPercentage Percentage of the power that is created by renewable + * resources + */ + public void setRenewableGenerationPercentage(@Nullable Integer renewableGenerationPercentage) { + if (!isValidRenewableGenerationPercentage(renewableGenerationPercentage)) { + throw new PropertyConstraintException( + renewableGenerationPercentage, "renewableGenerationPercentage is invalid"); + } + this.renewableGenerationPercentage = renewableGenerationPercentage; + } + + /** + * Returns whether the given renewableGenerationPercentage is valid + * + * @param renewableGenerationPercentage the renewableGenerationPercentage to check the validity of + * @return {@code true} if renewableGenerationPercentage is valid, {@code false} if not + */ + private boolean isValidRenewableGenerationPercentage( + @Nullable Integer renewableGenerationPercentage) { + return renewableGenerationPercentage == null + || (renewableGenerationPercentage >= 0 && renewableGenerationPercentage <= 100); + } + + /** + * Adds percentage of the power that is created by renewable resources. + * + * @param renewableGenerationPercentage Percentage of the power that is created by renewable + * resources + * @return this + */ + public PriceRule withRenewableGenerationPercentage( + @Nullable Integer renewableGenerationPercentage) { + setRenewableGenerationPercentage(renewableGenerationPercentage); + return this; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public RationalNumber getEnergyFee() { + return energyFee; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param energyFee Part of ISO 15118-20 price schedule + */ + public void setEnergyFee(RationalNumber energyFee) { + if (!isValidEnergyFee(energyFee)) { + throw new PropertyConstraintException(energyFee, "energyFee is invalid"); + } + this.energyFee = energyFee; + } + + /** + * Returns whether the given energyFee is valid + * + * @param energyFee the energyFee to check the validity of + * @return {@code true} if energyFee is valid, {@code false} if not + */ + private boolean isValidEnergyFee(RationalNumber energyFee) { + return energyFee != null && energyFee.validate(); + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + @Nullable + public RationalNumber getParkingFee() { + return parkingFee; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param parkingFee Part of ISO 15118-20 price schedule + */ + public void setParkingFee(@Nullable RationalNumber parkingFee) { + if (!isValidParkingFee(parkingFee)) { + throw new PropertyConstraintException(parkingFee, "parkingFee is invalid"); + } + this.parkingFee = parkingFee; + } + + /** + * Returns whether the given parkingFee is valid + * + * @param parkingFee the parkingFee to check the validity of + * @return {@code true} if parkingFee is valid, {@code false} if not + */ + private boolean isValidParkingFee(@Nullable RationalNumber parkingFee) { + return parkingFee == null || parkingFee.validate(); + } + + /** + * Adds part of ISO 15118-20 price schedule. + * + * @param parkingFee Part of ISO 15118-20 price schedule + * @return this + */ + public PriceRule withParkingFee(@Nullable RationalNumber parkingFee) { + setParkingFee(parkingFee); + return this; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public RationalNumber getPowerRangeStart() { + return powerRangeStart; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param powerRangeStart Part of ISO 15118-20 price schedule + */ + public void setPowerRangeStart(RationalNumber powerRangeStart) { + if (!isValidPowerRangeStart(powerRangeStart)) { + throw new PropertyConstraintException(powerRangeStart, "powerRangeStart is invalid"); + } + this.powerRangeStart = powerRangeStart; + } + + /** + * Returns whether the given powerRangeStart is valid + * + * @param powerRangeStart the powerRangeStart to check the validity of + * @return {@code true} if powerRangeStart is valid, {@code false} if not + */ + private boolean isValidPowerRangeStart(RationalNumber powerRangeStart) { + return powerRangeStart != null && powerRangeStart.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PriceRule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCarbonDioxideEmission(carbonDioxideEmission) + && isValidRenewableGenerationPercentage(renewableGenerationPercentage) + && isValidEnergyFee(energyFee) + && isValidParkingFee(parkingFee) + && isValidPowerRangeStart(powerRangeStart) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PriceRule that = (PriceRule) o; + return Objects.equals(parkingFeePeriod, that.parkingFeePeriod) + && Objects.equals(carbonDioxideEmission, that.carbonDioxideEmission) + && Objects.equals(renewableGenerationPercentage, that.renewableGenerationPercentage) + && Objects.equals(energyFee, that.energyFee) + && Objects.equals(parkingFee, that.parkingFee) + && Objects.equals(powerRangeStart, that.powerRangeStart) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + parkingFeePeriod, + carbonDioxideEmission, + renewableGenerationPercentage, + energyFee, + parkingFee, + powerRangeStart, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("parkingFeePeriod", parkingFeePeriod) + .add("carbonDioxideEmission", carbonDioxideEmission) + .add("renewableGenerationPercentage", renewableGenerationPercentage) + .add("energyFee", energyFee) + .add("parkingFee", parkingFee) + .add("powerRangeStart", powerRangeStart) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceRuleStack.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceRuleStack.java new file mode 100644 index 00000000..7be763a4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriceRuleStack.java @@ -0,0 +1,203 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Part of ISO 15118-20 price schedule. */ +public final class PriceRuleStack { + /** + * Duration of the stack of price rules. he amount of seconds that define the duration of the + * given PriceRule(s). + */ + private Integer duration; + + /** Part of ISO 15118-20 price schedule. */ + private PriceRule[] priceRule; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the PriceRuleStack class + * + * @param duration Duration of the stack of price rules. he amount of seconds that define the + * duration of the given PriceRule(s). + * @param priceRule Part of ISO 15118-20 price schedule. + */ + public PriceRuleStack(Integer duration, PriceRule[] priceRule) { + setDuration(duration); + setPriceRule(priceRule); + } + + /** + * Gets duration of the stack of price rules. he amount of seconds that define the duration of the + * given PriceRule(s). + * + * @return Duration of the stack of price rules + */ + public Integer getDuration() { + return duration; + } + + /** + * Sets duration of the stack of price rules. he amount of seconds that define the duration of the + * given PriceRule(s). + * + * @param duration Duration of the stack of price rules + */ + public void setDuration(Integer duration) { + if (!isValidDuration(duration)) { + throw new PropertyConstraintException(duration, "duration is invalid"); + } + this.duration = duration; + } + + /** + * Returns whether the given duration is valid + * + * @param duration the duration to check the validity of + * @return {@code true} if duration is valid, {@code false} if not + */ + private boolean isValidDuration(Integer duration) { + return duration != null; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public PriceRule[] getPriceRule() { + return priceRule; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param priceRule Part of ISO 15118-20 price schedule + */ + public void setPriceRule(PriceRule[] priceRule) { + if (!isValidPriceRule(priceRule)) { + throw new PropertyConstraintException(priceRule, "priceRule is invalid"); + } + this.priceRule = priceRule; + } + + /** + * Returns whether the given priceRule is valid + * + * @param priceRule the priceRule to check the validity of + * @return {@code true} if priceRule is valid, {@code false} if not + */ + private boolean isValidPriceRule(PriceRule[] priceRule) { + return priceRule != null + && priceRule.length >= 1 + && priceRule.length <= 8 + && Arrays.stream(priceRule).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PriceRuleStack withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDuration(duration) + && isValidPriceRule(priceRule) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PriceRuleStack that = (PriceRuleStack) o; + return Objects.equals(duration, that.duration) + && Arrays.equals(priceRule, that.priceRule) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(duration, Arrays.hashCode(priceRule), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("duration", duration) + .add("priceRule", priceRule) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriorityChargingStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriorityChargingStatusEnum.java new file mode 100644 index 00000000..19a13a58 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PriorityChargingStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Result of the request. */ +public enum PriorityChargingStatusEnum { + Accepted, + Rejected, + NoProfile +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PublishFirmwareStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PublishFirmwareStatusEnum.java new file mode 100644 index 00000000..58049f7e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/PublishFirmwareStatusEnum.java @@ -0,0 +1,39 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The progress status of the publishfirmware installation. */ +public enum PublishFirmwareStatusEnum { + Idle, + DownloadScheduled, + Downloading, + Downloaded, + Published, + DownloadFailed, + DownloadPaused, + InvalidChecksum, + ChecksumVerified, + PublishFailed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RationalNumber.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RationalNumber.java new file mode 100644 index 00000000..0b0c1da7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RationalNumber.java @@ -0,0 +1,191 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Part of ISO 15118-20 price schedule. */ +public final class RationalNumber { + /** The exponent to base 10 (dec) */ + private Integer exponent; + + /** Value which shall be multiplied. */ + private Integer value; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the RationalNumber class + * + * @param exponent The exponent to base 10 (dec) + * @param value Value which shall be multiplied. + */ + public RationalNumber(Integer exponent, Integer value) { + setExponent(exponent); + setValue(value); + } + + /** + * Gets the exponent to base 10 (dec) + * + * @return The exponent to base 10 (dec) + */ + public Integer getExponent() { + return exponent; + } + + /** + * Sets the exponent to base 10 (dec) + * + * @param exponent The exponent to base 10 (dec) + */ + public void setExponent(Integer exponent) { + if (!isValidExponent(exponent)) { + throw new PropertyConstraintException(exponent, "exponent is invalid"); + } + this.exponent = exponent; + } + + /** + * Returns whether the given exponent is valid + * + * @param exponent the exponent to check the validity of + * @return {@code true} if exponent is valid, {@code false} if not + */ + private boolean isValidExponent(Integer exponent) { + return exponent != null; + } + + /** + * Gets value which shall be multiplied. + * + * @return Value which shall be multiplied + */ + public Integer getValue() { + return value; + } + + /** + * Sets value which shall be multiplied. + * + * @param value Value which shall be multiplied + */ + public void setValue(Integer value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(Integer value) { + return value != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RationalNumber withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidExponent(exponent) && isValidValue(value) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RationalNumber that = (RationalNumber) o; + return Objects.equals(exponent, that.exponent) + && Objects.equals(value, that.value) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(exponent, value, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("exponent", exponent) + .add("value", value) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReactivePowerParams.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReactivePowerParams.java new file mode 100644 index 00000000..7ae754d7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReactivePowerParams.java @@ -0,0 +1,226 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** ReactivePowerParamsType */ +public final class ReactivePowerParams { + /** + * Only for VoltVar curve: The nominal ac voltage (rms) adjustment to the voltage curve points for + * Volt-Var curves (percentage). + */ + @Nullable private Double vRef; + + /** Only for VoltVar: Enable/disable autonomous VRef adjustment */ + @Nullable private Boolean autonomousVRefEnable; + + /** Only for VoltVar: Adjustment range for VRef time constant */ + @Nullable private Double autonomousVRefTimeConstant; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ReactivePowerParams class */ + public ReactivePowerParams() {} + + /** + * Gets only for VoltVar curve: The nominal ac voltage (rms) adjustment to the voltage curve + * points for Volt-Var curves (percentage). + * + * @return Only for VoltVar curve: The nominal ac voltage (rms) adjustment to the voltage curve + * points for Volt-Var curves (percentage) + */ + @Nullable + public Double getVRef() { + return vRef; + } + + /** + * Sets only for VoltVar curve: The nominal ac voltage (rms) adjustment to the voltage curve + * points for Volt-Var curves (percentage). + * + * @param vRef Only for VoltVar curve: The nominal ac voltage (rms) adjustment to the voltage + * curve points for Volt-Var curves (percentage) + */ + public void setVRef(@Nullable Double vRef) { + this.vRef = vRef; + } + + /** + * Adds only for VoltVar curve: The nominal ac voltage (rms) adjustment to the voltage curve + * points for Volt-Var curves (percentage). + * + * @param vRef Only for VoltVar curve: The nominal ac voltage (rms) adjustment to the voltage + * curve points for Volt-Var curves (percentage) + * @return this + */ + public ReactivePowerParams withVRef(@Nullable Double vRef) { + setVRef(vRef); + return this; + } + + /** + * Gets only for VoltVar: Enable/disable autonomous VRef adjustment + * + * @return Only for VoltVar: Enable/disable autonomous VRef adjustment + */ + @Nullable + public Boolean getAutonomousVRefEnable() { + return autonomousVRefEnable; + } + + /** + * Sets only for VoltVar: Enable/disable autonomous VRef adjustment + * + * @param autonomousVRefEnable Only for VoltVar: Enable/disable autonomous VRef adjustment + */ + public void setAutonomousVRefEnable(@Nullable Boolean autonomousVRefEnable) { + this.autonomousVRefEnable = autonomousVRefEnable; + } + + /** + * Adds only for VoltVar: Enable/disable autonomous VRef adjustment + * + * @param autonomousVRefEnable Only for VoltVar: Enable/disable autonomous VRef adjustment + * @return this + */ + public ReactivePowerParams withAutonomousVRefEnable(@Nullable Boolean autonomousVRefEnable) { + setAutonomousVRefEnable(autonomousVRefEnable); + return this; + } + + /** + * Gets only for VoltVar: Adjustment range for VRef time constant + * + * @return Only for VoltVar: Adjustment range for VRef time constant + */ + @Nullable + public Double getAutonomousVRefTimeConstant() { + return autonomousVRefTimeConstant; + } + + /** + * Sets only for VoltVar: Adjustment range for VRef time constant + * + * @param autonomousVRefTimeConstant Only for VoltVar: Adjustment range for VRef time constant + */ + public void setAutonomousVRefTimeConstant(@Nullable Double autonomousVRefTimeConstant) { + this.autonomousVRefTimeConstant = autonomousVRefTimeConstant; + } + + /** + * Adds only for VoltVar: Adjustment range for VRef time constant + * + * @param autonomousVRefTimeConstant Only for VoltVar: Adjustment range for VRef time constant + * @return this + */ + public ReactivePowerParams withAutonomousVRefTimeConstant( + @Nullable Double autonomousVRefTimeConstant) { + setAutonomousVRefTimeConstant(autonomousVRefTimeConstant); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReactivePowerParams withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReactivePowerParams that = (ReactivePowerParams) o; + return Objects.equals(vRef, that.vRef) + && Objects.equals(autonomousVRefEnable, that.autonomousVRefEnable) + && Objects.equals(autonomousVRefTimeConstant, that.autonomousVRefTimeConstant) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(vRef, autonomousVRefEnable, autonomousVRefTimeConstant, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("vRef", vRef) + .add("autonomousVRefEnable", autonomousVRefEnable) + .add("autonomousVRefTimeConstant", autonomousVRefTimeConstant) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReadingContextEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReadingContextEnum.java new file mode 100644 index 00000000..9a606bf3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReadingContextEnum.java @@ -0,0 +1,45 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import com.google.gson.annotations.SerializedName; + +/** Type of detail value: start, end or sample. Default = "Sample.Periodic" */ +public enum ReadingContextEnum { + @SerializedName("Interruption.Begin") + InterruptionBegin, + @SerializedName("Interruption.End") + InterruptionEnd, + Other, + @SerializedName("Sample.Clock") + SampleClock, + @SerializedName("Sample.Periodic") + SamplePeriodic, + @SerializedName("Transaction.Begin") + TransactionBegin, + @SerializedName("Transaction.End") + TransactionEnd, + Trigger +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReasonEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReasonEnum.java new file mode 100644 index 00000000..a5b1f837 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReasonEnum.java @@ -0,0 +1,57 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * The stoppedReason is the reason/event that initiated the process of stopping the transaction. It + * will normally be the user stopping authorization via card (Local or MasterPass) or app (Remote), + * but it can also be CSMS revoking authorization (DeAuthorized), or disconnecting the EV when + * TxStopPoint = EVConnected (EVDisconnected). Most other reasons are related to technical faults or + * energy limitations. + * + *

MAY only be omitted when stoppedReason is "Local" + */ +public enum ReasonEnum { + DeAuthorized, + EmergencyStop, + EnergyLimitReached, + EVDisconnected, + GroundFault, + ImmediateReset, + MasterPass, + Local, + LocalOutOfCredit, + Other, + OvercurrentFault, + PowerLoss, + PowerQuality, + Reboot, + Remote, + SOCLimitReached, + StoppedByEV, + TimeLimitReached, + Timeout, + ReqEnergyTransferRejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RecurrencyKindEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RecurrencyKindEnum.java new file mode 100644 index 00000000..bc74c074 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RecurrencyKindEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The start point of a recurrence. */ +public enum RecurrencyKindEnum { + Daily, + Weekly +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RegistrationStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RegistrationStatusEnum.java new file mode 100644 index 00000000..6a1e82e8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RegistrationStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Charging Station has been registered within the CSMS. */ +public enum RegistrationStatusEnum { + Accepted, + Pending, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RelativeTimeInterval.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RelativeTimeInterval.java new file mode 100644 index 00000000..8287e2b2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RelativeTimeInterval.java @@ -0,0 +1,188 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** RelativeTimeIntervalType */ +public final class RelativeTimeInterval { + /** Start of the interval, in seconds from NOW. */ + private Integer start; + + /** Duration of the interval, in seconds. */ + @Nullable private Integer duration; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the RelativeTimeInterval class + * + * @param start Start of the interval, in seconds from NOW. + */ + public RelativeTimeInterval(Integer start) { + setStart(start); + } + + /** + * Gets start of the interval, in seconds from NOW. + * + * @return Start of the interval, in seconds from NOW + */ + public Integer getStart() { + return start; + } + + /** + * Sets start of the interval, in seconds from NOW. + * + * @param start Start of the interval, in seconds from NOW + */ + public void setStart(Integer start) { + if (!isValidStart(start)) { + throw new PropertyConstraintException(start, "start is invalid"); + } + this.start = start; + } + + /** + * Returns whether the given start is valid + * + * @param start the start to check the validity of + * @return {@code true} if start is valid, {@code false} if not + */ + private boolean isValidStart(Integer start) { + return start != null; + } + + /** + * Gets duration of the interval, in seconds. + * + * @return Duration of the interval, in seconds + */ + @Nullable + public Integer getDuration() { + return duration; + } + + /** + * Sets duration of the interval, in seconds. + * + * @param duration Duration of the interval, in seconds + */ + public void setDuration(@Nullable Integer duration) { + this.duration = duration; + } + + /** + * Adds duration of the interval, in seconds. + * + * @param duration Duration of the interval, in seconds + * @return this + */ + public RelativeTimeInterval withDuration(@Nullable Integer duration) { + setDuration(duration); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RelativeTimeInterval withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidStart(start) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RelativeTimeInterval that = (RelativeTimeInterval) o; + return Objects.equals(start, that.start) + && Objects.equals(duration, that.duration) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(start, duration, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("start", start) + .add("duration", duration) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReportBaseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReportBaseEnum.java new file mode 100644 index 00000000..3f9a1f1d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReportBaseEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The report base. */ +public enum ReportBaseEnum { + ConfigurationInventory, + FullInventory, + SummaryInventory +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReportData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReportData.java new file mode 100644 index 00000000..56a55766 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReportData.java @@ -0,0 +1,294 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to report components, variables and variable attributes and characteristics. */ +public final class ReportData { + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** Attribute data of a variable. */ + private VariableAttribute[] variableAttribute; + + /** Fixed read-only parameters of a variable. */ + @Nullable private VariableCharacteristics variableCharacteristics; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the ReportData class + * + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + * @param variableAttribute Attribute data of a variable. + */ + public ReportData(Component component, Variable variable, VariableAttribute[] variableAttribute) { + setComponent(component); + setVariable(variable); + setVariableAttribute(variableAttribute); + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets attribute data of a variable. + * + * @return Attribute data of a variable + */ + public VariableAttribute[] getVariableAttribute() { + return variableAttribute; + } + + /** + * Sets attribute data of a variable. + * + * @param variableAttribute Attribute data of a variable + */ + public void setVariableAttribute(VariableAttribute[] variableAttribute) { + if (!isValidVariableAttribute(variableAttribute)) { + throw new PropertyConstraintException(variableAttribute, "variableAttribute is invalid"); + } + this.variableAttribute = variableAttribute; + } + + /** + * Returns whether the given variableAttribute is valid + * + * @param variableAttribute the variableAttribute to check the validity of + * @return {@code true} if variableAttribute is valid, {@code false} if not + */ + private boolean isValidVariableAttribute(VariableAttribute[] variableAttribute) { + return variableAttribute != null + && variableAttribute.length >= 1 + && variableAttribute.length <= 4 + && Arrays.stream(variableAttribute).allMatch(item -> item.validate()); + } + + /** + * Gets fixed read-only parameters of a variable. + * + * @return Fixed read-only parameters of a variable + */ + @Nullable + public VariableCharacteristics getVariableCharacteristics() { + return variableCharacteristics; + } + + /** + * Sets fixed read-only parameters of a variable. + * + * @param variableCharacteristics Fixed read-only parameters of a variable + */ + public void setVariableCharacteristics( + @Nullable VariableCharacteristics variableCharacteristics) { + if (!isValidVariableCharacteristics(variableCharacteristics)) { + throw new PropertyConstraintException( + variableCharacteristics, "variableCharacteristics is invalid"); + } + this.variableCharacteristics = variableCharacteristics; + } + + /** + * Returns whether the given variableCharacteristics is valid + * + * @param variableCharacteristics the variableCharacteristics to check the validity of + * @return {@code true} if variableCharacteristics is valid, {@code false} if not + */ + private boolean isValidVariableCharacteristics( + @Nullable VariableCharacteristics variableCharacteristics) { + return variableCharacteristics == null || variableCharacteristics.validate(); + } + + /** + * Adds fixed read-only parameters of a variable. + * + * @param variableCharacteristics Fixed read-only parameters of a variable + * @return this + */ + public ReportData withVariableCharacteristics( + @Nullable VariableCharacteristics variableCharacteristics) { + setVariableCharacteristics(variableCharacteristics); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReportData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidComponent(component) + && isValidVariable(variable) + && isValidVariableAttribute(variableAttribute) + && isValidVariableCharacteristics(variableCharacteristics) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportData that = (ReportData) o; + return Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Arrays.equals(variableAttribute, that.variableAttribute) + && Objects.equals(variableCharacteristics, that.variableCharacteristics) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + component, + variable, + Arrays.hashCode(variableAttribute), + variableCharacteristics, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("component", component) + .add("variable", variable) + .add("variableAttribute", variableAttribute) + .add("variableCharacteristics", variableCharacteristics) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RequestStartStopStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RequestStartStopStatusEnum.java new file mode 100644 index 00000000..b11264cb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/RequestStartStopStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Status indicating whether Charging Station accepts the request to stop a transaction. */ +public enum RequestStartStopStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReservationUpdateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReservationUpdateStatusEnum.java new file mode 100644 index 00000000..c2779aaa --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReservationUpdateStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The updated reservation status. */ +public enum ReservationUpdateStatusEnum { + Expired, + Removed, + NoTransaction +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReserveNowStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReserveNowStatusEnum.java new file mode 100644 index 00000000..9209844f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ReserveNowStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The success or failure of the reservation. */ +public enum ReserveNowStatusEnum { + Accepted, + Faulted, + Occupied, + Rejected, + Unavailable +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ResetEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ResetEnum.java new file mode 100644 index 00000000..c17af8e3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ResetEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The type of reset that the Charging Station or EVSE should perform. */ +public enum ResetEnum { + Immediate, + OnIdle, + ImmediateAndResume +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ResetStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ResetStatusEnum.java new file mode 100644 index 00000000..27179470 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/ResetStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Charging Station is able to perform the reset. */ +public enum ResetStatusEnum { + Accepted, + Rejected, + Scheduled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SalesTariff.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SalesTariff.java new file mode 100644 index 00000000..d635bdb8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SalesTariff.java @@ -0,0 +1,315 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A SalesTariff provided by a Mobility Operator (EMSP) . NOTE: This dataType is based on dataTypes + * from ISO 15118-2. + */ +public final class SalesTariff { + /** + * SalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier + * for one schedule throughout a charging session. + */ + private Integer id; + + /** A human readable title/short description of the sales tariff e.g. for HMI display purposes. */ + @Nullable private String salesTariffDescription; + + /** The overall number of distinct price levels used across all provided SalesTariff elements. */ + @Nullable private Integer numEPriceLevels; + + /** salesTariffEntry */ + private SalesTariffEntry[] salesTariffEntry; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SalesTariff class + * + * @param id SalesTariff identifier used to identify one sales tariff. An SAID remains a unique + * identifier for one schedule throughout a charging session. + * @param salesTariffEntry salesTariffEntry + */ + public SalesTariff(Integer id, SalesTariffEntry[] salesTariffEntry) { + setId(id); + setSalesTariffEntry(salesTariffEntry); + } + + /** + * Gets salesTariff identifier used to identify one sales tariff. An SAID remains a unique + * identifier for one schedule throughout a charging session. + * + * @return SalesTariff identifier used to identify one sales tariff + */ + public Integer getId() { + return id; + } + + /** + * Sets salesTariff identifier used to identify one sales tariff. An SAID remains a unique + * identifier for one schedule throughout a charging session. + * + * @param id SalesTariff identifier used to identify one sales tariff + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets a human readable title/short description of the sales tariff e.g. for HMI display + * purposes. + * + * @return A human readable title/short description of the sales tariff e.g. for HMI display + * purposes + */ + @Nullable + public String getSalesTariffDescription() { + return salesTariffDescription; + } + + /** + * Sets a human readable title/short description of the sales tariff e.g. for HMI display + * purposes. + * + * @param salesTariffDescription A human readable title/short description of the sales tariff e.g. + * for HMI display purposes + */ + public void setSalesTariffDescription(@Nullable String salesTariffDescription) { + if (!isValidSalesTariffDescription(salesTariffDescription)) { + throw new PropertyConstraintException( + salesTariffDescription, "salesTariffDescription is invalid"); + } + this.salesTariffDescription = salesTariffDescription; + } + + /** + * Returns whether the given salesTariffDescription is valid + * + * @param salesTariffDescription the salesTariffDescription to check the validity of + * @return {@code true} if salesTariffDescription is valid, {@code false} if not + */ + private boolean isValidSalesTariffDescription(@Nullable String salesTariffDescription) { + return salesTariffDescription == null || salesTariffDescription.length() <= 32; + } + + /** + * Adds a human readable title/short description of the sales tariff e.g. for HMI display + * purposes. + * + * @param salesTariffDescription A human readable title/short description of the sales tariff e.g. + * for HMI display purposes + * @return this + */ + public SalesTariff withSalesTariffDescription(@Nullable String salesTariffDescription) { + setSalesTariffDescription(salesTariffDescription); + return this; + } + + /** + * Gets the overall number of distinct price levels used across all provided SalesTariff elements. + * + * @return The overall number of distinct price levels used across all provided SalesTariff + * elements + */ + @Nullable + public Integer getNumEPriceLevels() { + return numEPriceLevels; + } + + /** + * Sets the overall number of distinct price levels used across all provided SalesTariff elements. + * + * @param numEPriceLevels The overall number of distinct price levels used across all provided + * SalesTariff elements + */ + public void setNumEPriceLevels(@Nullable Integer numEPriceLevels) { + if (!isValidNumEPriceLevels(numEPriceLevels)) { + throw new PropertyConstraintException(numEPriceLevels, "numEPriceLevels is invalid"); + } + this.numEPriceLevels = numEPriceLevels; + } + + /** + * Returns whether the given numEPriceLevels is valid + * + * @param numEPriceLevels the numEPriceLevels to check the validity of + * @return {@code true} if numEPriceLevels is valid, {@code false} if not + */ + private boolean isValidNumEPriceLevels(@Nullable Integer numEPriceLevels) { + return numEPriceLevels == null || (numEPriceLevels >= 0); + } + + /** + * Adds the overall number of distinct price levels used across all provided SalesTariff elements. + * + * @param numEPriceLevels The overall number of distinct price levels used across all provided + * SalesTariff elements + * @return this + */ + public SalesTariff withNumEPriceLevels(@Nullable Integer numEPriceLevels) { + setNumEPriceLevels(numEPriceLevels); + return this; + } + + /** + * Gets salesTariffEntry + * + * @return salesTariffEntry + */ + public SalesTariffEntry[] getSalesTariffEntry() { + return salesTariffEntry; + } + + /** + * Sets salesTariffEntry + * + * @param salesTariffEntry salesTariffEntry + */ + public void setSalesTariffEntry(SalesTariffEntry[] salesTariffEntry) { + if (!isValidSalesTariffEntry(salesTariffEntry)) { + throw new PropertyConstraintException(salesTariffEntry, "salesTariffEntry is invalid"); + } + this.salesTariffEntry = salesTariffEntry; + } + + /** + * Returns whether the given salesTariffEntry is valid + * + * @param salesTariffEntry the salesTariffEntry to check the validity of + * @return {@code true} if salesTariffEntry is valid, {@code false} if not + */ + private boolean isValidSalesTariffEntry(SalesTariffEntry[] salesTariffEntry) { + return salesTariffEntry != null + && salesTariffEntry.length >= 1 + && salesTariffEntry.length <= 1024 + && Arrays.stream(salesTariffEntry).allMatch(item -> item.validate()); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SalesTariff withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) + && isValidSalesTariffDescription(salesTariffDescription) + && isValidNumEPriceLevels(numEPriceLevels) + && isValidSalesTariffEntry(salesTariffEntry) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SalesTariff that = (SalesTariff) o; + return Objects.equals(id, that.id) + && Objects.equals(salesTariffDescription, that.salesTariffDescription) + && Objects.equals(numEPriceLevels, that.numEPriceLevels) + && Arrays.equals(salesTariffEntry, that.salesTariffEntry) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + id, salesTariffDescription, numEPriceLevels, Arrays.hashCode(salesTariffEntry), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("salesTariffDescription", salesTariffDescription) + .add("numEPriceLevels", numEPriceLevels) + .add("salesTariffEntry", salesTariffEntry) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SalesTariffEntry.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SalesTariffEntry.java new file mode 100644 index 00000000..371b774d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SalesTariffEntry.java @@ -0,0 +1,268 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** SalesTariffEntryType */ +public final class SalesTariffEntry { + /** relativeTimeInterval */ + private RelativeTimeInterval relativeTimeInterval; + + /** + * The price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the + * EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more + * expensive TariffEntry. + */ + @Nullable private Integer ePriceLevel; + + /** consumptionCost */ + @Nullable private ConsumptionCost[] consumptionCost; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SalesTariffEntry class + * + * @param relativeTimeInterval relativeTimeInterval + */ + public SalesTariffEntry(RelativeTimeInterval relativeTimeInterval) { + setRelativeTimeInterval(relativeTimeInterval); + } + + /** + * Gets relativeTimeInterval + * + * @return relativeTimeInterval + */ + public RelativeTimeInterval getRelativeTimeInterval() { + return relativeTimeInterval; + } + + /** + * Sets relativeTimeInterval + * + * @param relativeTimeInterval relativeTimeInterval + */ + public void setRelativeTimeInterval(RelativeTimeInterval relativeTimeInterval) { + if (!isValidRelativeTimeInterval(relativeTimeInterval)) { + throw new PropertyConstraintException( + relativeTimeInterval, "relativeTimeInterval is invalid"); + } + this.relativeTimeInterval = relativeTimeInterval; + } + + /** + * Returns whether the given relativeTimeInterval is valid + * + * @param relativeTimeInterval the relativeTimeInterval to check the validity of + * @return {@code true} if relativeTimeInterval is valid, {@code false} if not + */ + private boolean isValidRelativeTimeInterval(RelativeTimeInterval relativeTimeInterval) { + return relativeTimeInterval != null && relativeTimeInterval.validate(); + } + + /** + * Gets the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for + * the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a + * more expensive TariffEntry. + * + * @return The price level of this SalesTariffEntry (referring to NumEPriceLevels) + */ + @Nullable + public Integer getEPriceLevel() { + return ePriceLevel; + } + + /** + * Sets the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for + * the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a + * more expensive TariffEntry. + * + * @param ePriceLevel The price level of this SalesTariffEntry (referring to NumEPriceLevels) + */ + public void setEPriceLevel(@Nullable Integer ePriceLevel) { + if (!isValidEPriceLevel(ePriceLevel)) { + throw new PropertyConstraintException(ePriceLevel, "ePriceLevel is invalid"); + } + this.ePriceLevel = ePriceLevel; + } + + /** + * Returns whether the given ePriceLevel is valid + * + * @param ePriceLevel the ePriceLevel to check the validity of + * @return {@code true} if ePriceLevel is valid, {@code false} if not + */ + private boolean isValidEPriceLevel(@Nullable Integer ePriceLevel) { + return ePriceLevel == null || (ePriceLevel >= 0); + } + + /** + * Adds the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for + * the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a + * more expensive TariffEntry. + * + * @param ePriceLevel The price level of this SalesTariffEntry (referring to NumEPriceLevels) + * @return this + */ + public SalesTariffEntry withEPriceLevel(@Nullable Integer ePriceLevel) { + setEPriceLevel(ePriceLevel); + return this; + } + + /** + * Gets consumptionCost + * + * @return consumptionCost + */ + @Nullable + public ConsumptionCost[] getConsumptionCost() { + return consumptionCost; + } + + /** + * Sets consumptionCost + * + * @param consumptionCost consumptionCost + */ + public void setConsumptionCost(@Nullable ConsumptionCost[] consumptionCost) { + if (!isValidConsumptionCost(consumptionCost)) { + throw new PropertyConstraintException(consumptionCost, "consumptionCost is invalid"); + } + this.consumptionCost = consumptionCost; + } + + /** + * Returns whether the given consumptionCost is valid + * + * @param consumptionCost the consumptionCost to check the validity of + * @return {@code true} if consumptionCost is valid, {@code false} if not + */ + private boolean isValidConsumptionCost(@Nullable ConsumptionCost[] consumptionCost) { + return consumptionCost == null + || (consumptionCost.length >= 1 + && consumptionCost.length <= 3 + && Arrays.stream(consumptionCost).allMatch(item -> item.validate())); + } + + /** + * Adds consumptionCost + * + * @param consumptionCost consumptionCost + * @return this + */ + public SalesTariffEntry withConsumptionCost(@Nullable ConsumptionCost[] consumptionCost) { + setConsumptionCost(consumptionCost); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SalesTariffEntry withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidRelativeTimeInterval(relativeTimeInterval) + && isValidEPriceLevel(ePriceLevel) + && isValidConsumptionCost(consumptionCost) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SalesTariffEntry that = (SalesTariffEntry) o; + return Objects.equals(relativeTimeInterval, that.relativeTimeInterval) + && Objects.equals(ePriceLevel, that.ePriceLevel) + && Arrays.equals(consumptionCost, that.consumptionCost) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + relativeTimeInterval, ePriceLevel, Arrays.hashCode(consumptionCost), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("relativeTimeInterval", relativeTimeInterval) + .add("ePriceLevel", ePriceLevel) + .add("consumptionCost", consumptionCost) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SampledValue.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SampledValue.java new file mode 100644 index 00000000..3e760fa1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SampledValue.java @@ -0,0 +1,406 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Single sampled value in MeterValues. Each value can be accompanied by optional fields. + * + *

To save on mobile data usage, default values of all of the optional fields are such that. The + * value without any additional fields will be interpreted, as a register reading of active import + * energy in Wh (Watt-hour) units. + */ +public final class SampledValue { + /** The measured value. */ + private Double value; + + /** Type of measurement. Default = "Energy.Active.Import.Register" */ + @Nullable private MeasurandEnum measurand; + + /** Type of detail value: start, end or sample. Default = "Sample.Periodic" */ + @Nullable private ReadingContextEnum context; + + /** + * How the measured value is to be interpreted. For instance between L1 and neutral (L1-N) Please + * note that not all values of phase are applicable to all Measurands. When phase is absent, the + * measured value is interpreted as an overall value. + */ + @Nullable private PhaseEnum phase; + + /** Where the measured value has been sampled. Default = "Outlet" */ + @Nullable private LocationEnum location; + + /** A signed version of the meter value. */ + @Nullable private SignedMeterValue signedMeterValue; + + /** A UnitOfMeasure with a multiplier */ + @Nullable private UnitOfMeasure unitOfMeasure; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SampledValue class + * + * @param value The measured value. + */ + public SampledValue(Double value) { + setValue(value); + } + + /** + * Gets the measured value. + * + * @return The measured value + */ + public Double getValue() { + return value; + } + + /** + * Sets the measured value. + * + * @param value The measured value + */ + public void setValue(Double value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(Double value) { + return value != null; + } + + /** + * Gets type of measurement. Default = "Energy.Active.Import.Register" + * + * @return Type of measurement + */ + public MeasurandEnum getMeasurand() { + return measurand != null ? measurand : MeasurandEnum.EnergyActiveImportRegister; + } + + /** + * Sets type of measurement. Default = "Energy.Active.Import.Register" + * + * @param measurand Type of measurement + */ + public void setMeasurand(@Nullable MeasurandEnum measurand) { + this.measurand = measurand; + } + + /** + * Adds type of measurement. Default = "Energy.Active.Import.Register" + * + * @param measurand Type of measurement + * @return this + */ + public SampledValue withMeasurand(@Nullable MeasurandEnum measurand) { + setMeasurand(measurand); + return this; + } + + /** + * Gets type of detail value: start, end or sample. Default = "Sample.Periodic" + * + * @return Type of detail value: start, end or sample + */ + public ReadingContextEnum getContext() { + return context != null ? context : ReadingContextEnum.SamplePeriodic; + } + + /** + * Sets type of detail value: start, end or sample. Default = "Sample.Periodic" + * + * @param context Type of detail value: start, end or sample + */ + public void setContext(@Nullable ReadingContextEnum context) { + this.context = context; + } + + /** + * Adds type of detail value: start, end or sample. Default = "Sample.Periodic" + * + * @param context Type of detail value: start, end or sample + * @return this + */ + public SampledValue withContext(@Nullable ReadingContextEnum context) { + setContext(context); + return this; + } + + /** + * Gets how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) + * Please note that not all values of phase are applicable to all Measurands. When phase is + * absent, the measured value is interpreted as an overall value. + * + * @return How the measured value is to be interpreted + */ + @Nullable + public PhaseEnum getPhase() { + return phase; + } + + /** + * Sets how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) + * Please note that not all values of phase are applicable to all Measurands. When phase is + * absent, the measured value is interpreted as an overall value. + * + * @param phase How the measured value is to be interpreted + */ + public void setPhase(@Nullable PhaseEnum phase) { + this.phase = phase; + } + + /** + * Adds how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) + * Please note that not all values of phase are applicable to all Measurands. When phase is + * absent, the measured value is interpreted as an overall value. + * + * @param phase How the measured value is to be interpreted + * @return this + */ + public SampledValue withPhase(@Nullable PhaseEnum phase) { + setPhase(phase); + return this; + } + + /** + * Gets where the measured value has been sampled. Default = "Outlet" + * + * @return Where the measured value has been sampled + */ + public LocationEnum getLocation() { + return location != null ? location : LocationEnum.Outlet; + } + + /** + * Sets where the measured value has been sampled. Default = "Outlet" + * + * @param location Where the measured value has been sampled + */ + public void setLocation(@Nullable LocationEnum location) { + this.location = location; + } + + /** + * Adds where the measured value has been sampled. Default = "Outlet" + * + * @param location Where the measured value has been sampled + * @return this + */ + public SampledValue withLocation(@Nullable LocationEnum location) { + setLocation(location); + return this; + } + + /** + * Gets a signed version of the meter value. + * + * @return A signed version of the meter value + */ + @Nullable + public SignedMeterValue getSignedMeterValue() { + return signedMeterValue; + } + + /** + * Sets a signed version of the meter value. + * + * @param signedMeterValue A signed version of the meter value + */ + public void setSignedMeterValue(@Nullable SignedMeterValue signedMeterValue) { + if (!isValidSignedMeterValue(signedMeterValue)) { + throw new PropertyConstraintException(signedMeterValue, "signedMeterValue is invalid"); + } + this.signedMeterValue = signedMeterValue; + } + + /** + * Returns whether the given signedMeterValue is valid + * + * @param signedMeterValue the signedMeterValue to check the validity of + * @return {@code true} if signedMeterValue is valid, {@code false} if not + */ + private boolean isValidSignedMeterValue(@Nullable SignedMeterValue signedMeterValue) { + return signedMeterValue == null || signedMeterValue.validate(); + } + + /** + * Adds a signed version of the meter value. + * + * @param signedMeterValue A signed version of the meter value + * @return this + */ + public SampledValue withSignedMeterValue(@Nullable SignedMeterValue signedMeterValue) { + setSignedMeterValue(signedMeterValue); + return this; + } + + /** + * Gets a UnitOfMeasure with a multiplier + * + * @return A UnitOfMeasure with a multiplier + */ + @Nullable + public UnitOfMeasure getUnitOfMeasure() { + return unitOfMeasure; + } + + /** + * Sets a UnitOfMeasure with a multiplier + * + * @param unitOfMeasure A UnitOfMeasure with a multiplier + */ + public void setUnitOfMeasure(@Nullable UnitOfMeasure unitOfMeasure) { + if (!isValidUnitOfMeasure(unitOfMeasure)) { + throw new PropertyConstraintException(unitOfMeasure, "unitOfMeasure is invalid"); + } + this.unitOfMeasure = unitOfMeasure; + } + + /** + * Returns whether the given unitOfMeasure is valid + * + * @param unitOfMeasure the unitOfMeasure to check the validity of + * @return {@code true} if unitOfMeasure is valid, {@code false} if not + */ + private boolean isValidUnitOfMeasure(@Nullable UnitOfMeasure unitOfMeasure) { + return unitOfMeasure == null || unitOfMeasure.validate(); + } + + /** + * Adds a UnitOfMeasure with a multiplier + * + * @param unitOfMeasure A UnitOfMeasure with a multiplier + * @return this + */ + public SampledValue withUnitOfMeasure(@Nullable UnitOfMeasure unitOfMeasure) { + setUnitOfMeasure(unitOfMeasure); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SampledValue withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidValue(value) + && isValidSignedMeterValue(signedMeterValue) + && isValidUnitOfMeasure(unitOfMeasure) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SampledValue that = (SampledValue) o; + return Objects.equals(value, that.value) + && Objects.equals(measurand, that.measurand) + && Objects.equals(context, that.context) + && Objects.equals(phase, that.phase) + && Objects.equals(location, that.location) + && Objects.equals(signedMeterValue, that.signedMeterValue) + && Objects.equals(unitOfMeasure, that.unitOfMeasure) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + value, measurand, context, phase, location, signedMeterValue, unitOfMeasure, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("value", value) + .add("measurand", measurand) + .add("context", context) + .add("phase", phase) + .add("location", location) + .add("signedMeterValue", signedMeterValue) + .add("unitOfMeasure", unitOfMeasure) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SendLocalListStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SendLocalListStatusEnum.java new file mode 100644 index 00000000..6934bb45 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SendLocalListStatusEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Whether the Charging Station has successfully received and applied the update of the Local + * Authorization List. + */ +public enum SendLocalListStatusEnum { + Accepted, + Failed, + VersionMismatch +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringData.java new file mode 100644 index 00000000..6c621a70 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringData.java @@ -0,0 +1,511 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold parameters of SetVariableMonitoring request. */ +public final class SetMonitoringData { + /** + * An id SHALL only be given to replace an existing monitor. The Charging Station handles the + * generation of id's for new monitors. + */ + @Nullable private Integer id; + + /** periodicEventStream */ + @Nullable private PeriodicEventStreamParams periodicEventStream; + + /** + * Monitor only active when a transaction is ongoing on a component relevant to this transaction. + * Default = false. + */ + @Nullable private Boolean transaction; + + /** + * Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + */ + private Double value; + + /** The type of this monitor, e.g. a threshold, delta or periodic monitor. */ + private MonitorEnum type; + + /** + * The severity that will be assigned to an event that is triggered by this monitor. The severity + * range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + *

+   * The severity levels have the following meaning:
+   * *0-Danger*
+   * Lives are potentially in danger. Urgent attention is needed and action should be taken
+   * immediately.
+   * *1-Hardware Failure*
+   * That the Charging Station is unable to continue regular operations due to Hardware issues.
+   * Action is required.
+   * *2-System Failure*
+   * That the Charging Station is unable to continue regular operations due to software or minor
+   * hardware issues. Action is required.
+   * *3-Critical*
+   * A critical error. Action is required.
+   * *4-Error*
+   * A non-urgent error. Action is required.
+   * *5-Alert*
+   * An alert event. Default severity for any type of monitoring event.
+   * *6-Warning*
+   * A warning event. Action may be required.
+   * *7-Notice*
+   * An unusual event. No immediate action is required.
+   * *8-Informational*
+   * A regular operational event. May be used for reporting, measuring throughput, etc. No action is
+   * required.
+   * *9-Debug*
+   * Information useful to developers for debugging, not useful during operations.
+   * 
+ */ + private Integer severity; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetMonitoringData class + * + * @param value Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this + * is the interval in seconds. + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor. + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public SetMonitoringData( + Double value, MonitorEnum type, Integer severity, Component component, Variable variable) { + setValue(value); + setType(type); + setSeverity(severity); + setComponent(component); + setVariable(variable); + } + + /** + * Gets an id SHALL only be given to replace an existing monitor. The Charging Station handles the + * generation of id's for new monitors. + * + * @return An id SHALL only be given to replace an existing monitor + */ + @Nullable + public Integer getId() { + return id; + } + + /** + * Sets an id SHALL only be given to replace an existing monitor. The Charging Station handles the + * generation of id's for new monitors. + * + * @param id An id SHALL only be given to replace an existing monitor + */ + public void setId(@Nullable Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(@Nullable Integer id) { + return id == null || (id >= 0); + } + + /** + * Adds an id SHALL only be given to replace an existing monitor. The Charging Station handles the + * generation of id's for new monitors. + * + * @param id An id SHALL only be given to replace an existing monitor + * @return this + */ + public SetMonitoringData withId(@Nullable Integer id) { + setId(id); + return this; + } + + /** + * Gets periodicEventStream + * + * @return periodicEventStream + */ + @Nullable + public PeriodicEventStreamParams getPeriodicEventStream() { + return periodicEventStream; + } + + /** + * Sets periodicEventStream + * + * @param periodicEventStream periodicEventStream + */ + public void setPeriodicEventStream(@Nullable PeriodicEventStreamParams periodicEventStream) { + if (!isValidPeriodicEventStream(periodicEventStream)) { + throw new PropertyConstraintException(periodicEventStream, "periodicEventStream is invalid"); + } + this.periodicEventStream = periodicEventStream; + } + + /** + * Returns whether the given periodicEventStream is valid + * + * @param periodicEventStream the periodicEventStream to check the validity of + * @return {@code true} if periodicEventStream is valid, {@code false} if not + */ + private boolean isValidPeriodicEventStream( + @Nullable PeriodicEventStreamParams periodicEventStream) { + return periodicEventStream == null || periodicEventStream.validate(); + } + + /** + * Adds periodicEventStream + * + * @param periodicEventStream periodicEventStream + * @return this + */ + public SetMonitoringData withPeriodicEventStream( + @Nullable PeriodicEventStreamParams periodicEventStream) { + setPeriodicEventStream(periodicEventStream); + return this; + } + + /** + * Gets monitor only active when a transaction is ongoing on a component relevant to this + * transaction. Default = false. + * + * @return Monitor only active when a transaction is ongoing on a component relevant to this + * transaction + */ + public Boolean getTransaction() { + return transaction != null ? transaction : false; + } + + /** + * Sets monitor only active when a transaction is ongoing on a component relevant to this + * transaction. Default = false. + * + * @param transaction Monitor only active when a transaction is ongoing on a component relevant to + * this transaction + */ + public void setTransaction(@Nullable Boolean transaction) { + this.transaction = transaction; + } + + /** + * Adds monitor only active when a transaction is ongoing on a component relevant to this + * transaction. Default = false. + * + * @param transaction Monitor only active when a transaction is ongoing on a component relevant to + * this transaction + * @return this + */ + public SetMonitoringData withTransaction(@Nullable Boolean transaction) { + setTransaction(transaction); + return this; + } + + /** + * Gets value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + * + * @return Value for threshold or delta monitoring + */ + public Double getValue() { + return value; + } + + /** + * Sets value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + * + * @param value Value for threshold or delta monitoring + */ + public void setValue(Double value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(Double value) { + return value != null; + } + + /** + * Gets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @return The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public MonitorEnum getType() { + return type; + } + + /** + * Sets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public void setType(MonitorEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(MonitorEnum type) { + return type != null; + } + + /** + * Gets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @return The severity that will be assigned to an event that is triggered by this monitor + */ + public Integer getSeverity() { + return severity; + } + + /** + * Sets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor + */ + public void setSeverity(Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(Integer severity) { + return severity != null && severity >= 0; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) + && isValidPeriodicEventStream(periodicEventStream) + && isValidValue(value) + && isValidType(type) + && isValidSeverity(severity) + && isValidComponent(component) + && isValidVariable(variable) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringData that = (SetMonitoringData) o; + return Objects.equals(id, that.id) + && Objects.equals(periodicEventStream, that.periodicEventStream) + && Objects.equals(transaction, that.transaction) + && Objects.equals(value, that.value) + && Objects.equals(type, that.type) + && Objects.equals(severity, that.severity) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + periodicEventStream, + transaction, + value, + type, + severity, + component, + variable, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("periodicEventStream", periodicEventStream) + .add("transaction", transaction) + .add("value", value) + .add("type", type) + .add("severity", severity) + .add("component", component) + .add("variable", variable) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringResult.java new file mode 100644 index 00000000..517f562f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringResult.java @@ -0,0 +1,465 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold result of SetVariableMonitoring request. */ +public final class SetMonitoringResult { + /** + * Id given to the VariableMonitor by the Charging Station. The Id is only returned when status is + * accepted. Installed VariableMonitors should have unique id's but the id's of removed Installed + * monitors should have unique id's but the id's of removed monitors MAY be reused. + */ + @Nullable private Integer id; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Status is OK if a value could be returned. Otherwise this will indicate the reason why a value + * could not be returned. + */ + private SetMonitoringStatusEnum status; + + /** The type of this monitor, e.g. a threshold, delta or periodic monitor. */ + private MonitorEnum type; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * The severity that will be assigned to an event that is triggered by this monitor. The severity + * range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + *
+   * The severity levels have the following meaning:
+   * *0-Danger*
+   * Lives are potentially in danger. Urgent attention is needed and action should be taken
+   * immediately.
+   * *1-Hardware Failure*
+   * That the Charging Station is unable to continue regular operations due to Hardware issues.
+   * Action is required.
+   * *2-System Failure*
+   * That the Charging Station is unable to continue regular operations due to software or minor
+   * hardware issues. Action is required.
+   * *3-Critical*
+   * A critical error. Action is required.
+   * *4-Error*
+   * A non-urgent error. Action is required.
+   * *5-Alert*
+   * An alert event. Default severity for any type of monitoring event.
+   * *6-Warning*
+   * A warning event. Action may be required.
+   * *7-Notice*
+   * An unusual event. No immediate action is required.
+   * *8-Informational*
+   * A regular operational event. May be used for reporting, measuring throughput, etc. No action is
+   * required.
+   * *9-Debug*
+   * Information useful to developers for debugging, not useful during operations.
+   * 
+ */ + private Integer severity; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetMonitoringResult class + * + * @param status Status is OK if a value could be returned. Otherwise this will indicate the + * reason why a value could not be returned. + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor. + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + */ + public SetMonitoringResult( + SetMonitoringStatusEnum status, + MonitorEnum type, + Component component, + Variable variable, + Integer severity) { + setStatus(status); + setType(type); + setComponent(component); + setVariable(variable); + setSeverity(severity); + } + + /** + * Gets id given to the VariableMonitor by the Charging Station. The Id is only returned when + * status is accepted. Installed VariableMonitors should have unique id's but the id's of removed + * Installed monitors should have unique id's but the id's of removed monitors MAY be reused. + * + * @return Id given to the VariableMonitor by the Charging Station + */ + @Nullable + public Integer getId() { + return id; + } + + /** + * Sets id given to the VariableMonitor by the Charging Station. The Id is only returned when + * status is accepted. Installed VariableMonitors should have unique id's but the id's of removed + * Installed monitors should have unique id's but the id's of removed monitors MAY be reused. + * + * @param id Id given to the VariableMonitor by the Charging Station + */ + public void setId(@Nullable Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(@Nullable Integer id) { + return id == null || (id >= 0); + } + + /** + * Adds id given to the VariableMonitor by the Charging Station. The Id is only returned when + * status is accepted. Installed VariableMonitors should have unique id's but the id's of removed + * Installed monitors should have unique id's but the id's of removed monitors MAY be reused. + * + * @param id Id given to the VariableMonitor by the Charging Station + * @return this + */ + public SetMonitoringResult withId(@Nullable Integer id) { + setId(id); + return this; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetMonitoringResult withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets status is OK if a value could be returned. Otherwise this will indicate the reason why a + * value could not be returned. + * + * @return Status is OK if a value could be returned + */ + public SetMonitoringStatusEnum getStatus() { + return status; + } + + /** + * Sets status is OK if a value could be returned. Otherwise this will indicate the reason why a + * value could not be returned. + * + * @param status Status is OK if a value could be returned + */ + public void setStatus(SetMonitoringStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(SetMonitoringStatusEnum status) { + return status != null; + } + + /** + * Gets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @return The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public MonitorEnum getType() { + return type; + } + + /** + * Sets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public void setType(MonitorEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(MonitorEnum type) { + return type != null; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @return The severity that will be assigned to an event that is triggered by this monitor + */ + public Integer getSeverity() { + return severity; + } + + /** + * Sets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor + */ + public void setSeverity(Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(Integer severity) { + return severity != null && severity >= 0; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) + && isValidStatusInfo(statusInfo) + && isValidStatus(status) + && isValidType(type) + && isValidComponent(component) + && isValidVariable(variable) + && isValidSeverity(severity) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringResult that = (SetMonitoringResult) o; + return Objects.equals(id, that.id) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(status, that.status) + && Objects.equals(type, that.type) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Objects.equals(severity, that.severity) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(id, statusInfo, status, type, component, variable, severity, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("statusInfo", statusInfo) + .add("status", status) + .add("type", type) + .add("component", component) + .add("variable", variable) + .add("severity", severity) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringStatusEnum.java new file mode 100644 index 00000000..c89320c4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetMonitoringStatusEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * Status is OK if a value could be returned. Otherwise this will indicate the reason why a value + * could not be returned. + */ +public enum SetMonitoringStatusEnum { + Accepted, + UnknownComponent, + UnknownVariable, + UnsupportedMonitorType, + Rejected, + Duplicate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetNetworkProfileStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetNetworkProfileStatusEnum.java new file mode 100644 index 00000000..5e450ef9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetNetworkProfileStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Result of operation. */ +public enum SetNetworkProfileStatusEnum { + Accepted, + Rejected, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableData.java new file mode 100644 index 00000000..be761fac --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableData.java @@ -0,0 +1,276 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** SetVariableDataType */ +public final class SetVariableData { + /** Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. */ + @Nullable private AttributeEnum attributeType; + + /** + * Value to be assigned to attribute of variable. This value is allowed to be an empty string + * (""). + * + *

The Configuration Variable ConfigurationValueSize can be used to limit + * SetVariableData.attributeValue and VariableCharacteristics.valuesList. The max size of these + * values will always remain equal. + */ + private String attributeValue; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetVariableData class + * + * @param attributeValue Value to be assigned to attribute of variable. This value is allowed to + * be an empty string (""). + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public SetVariableData(String attributeValue, Component component, Variable variable) { + setAttributeValue(attributeValue); + setComponent(component); + setVariable(variable); + } + + /** + * Gets type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @return Type of attribute: Actual, Target, MinSet, MaxSet + */ + public AttributeEnum getAttributeType() { + return attributeType != null ? attributeType : AttributeEnum.Actual; + } + + /** + * Sets type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @param attributeType Type of attribute: Actual, Target, MinSet, MaxSet + */ + public void setAttributeType(@Nullable AttributeEnum attributeType) { + this.attributeType = attributeType; + } + + /** + * Adds type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @param attributeType Type of attribute: Actual, Target, MinSet, MaxSet + * @return this + */ + public SetVariableData withAttributeType(@Nullable AttributeEnum attributeType) { + setAttributeType(attributeType); + return this; + } + + /** + * Gets value to be assigned to attribute of variable. This value is allowed to be an empty string + * (""). + * + * @return Value to be assigned to attribute of variable + */ + public String getAttributeValue() { + return attributeValue; + } + + /** + * Sets value to be assigned to attribute of variable. This value is allowed to be an empty string + * (""). + * + * @param attributeValue Value to be assigned to attribute of variable + */ + public void setAttributeValue(String attributeValue) { + if (!isValidAttributeValue(attributeValue)) { + throw new PropertyConstraintException(attributeValue, "attributeValue is invalid"); + } + this.attributeValue = attributeValue; + } + + /** + * Returns whether the given attributeValue is valid + * + * @param attributeValue the attributeValue to check the validity of + * @return {@code true} if attributeValue is valid, {@code false} if not + */ + private boolean isValidAttributeValue(String attributeValue) { + return attributeValue != null && attributeValue.length() <= 2500; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariableData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidAttributeValue(attributeValue) + && isValidComponent(component) + && isValidVariable(variable) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariableData that = (SetVariableData) o; + return Objects.equals(attributeType, that.attributeType) + && Objects.equals(attributeValue, that.attributeValue) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(attributeType, attributeValue, component, variable, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("attributeType", attributeType) + .add("attributeValue", attributeValue) + .add("component", component) + .add("variable", variable) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableResult.java new file mode 100644 index 00000000..47115880 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableResult.java @@ -0,0 +1,317 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** SetVariableResultType */ +public final class SetVariableResult { + /** Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. */ + @Nullable private AttributeEnum attributeType; + + /** Result status of setting the variable. */ + private SetVariableStatusEnum attributeStatus; + + /** More information about the status. */ + @Nullable private StatusInfo attributeStatusInfo; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SetVariableResult class + * + * @param attributeStatus Result status of setting the variable. + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public SetVariableResult( + SetVariableStatusEnum attributeStatus, Component component, Variable variable) { + setAttributeStatus(attributeStatus); + setComponent(component); + setVariable(variable); + } + + /** + * Gets type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @return Type of attribute: Actual, Target, MinSet, MaxSet + */ + public AttributeEnum getAttributeType() { + return attributeType != null ? attributeType : AttributeEnum.Actual; + } + + /** + * Sets type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @param attributeType Type of attribute: Actual, Target, MinSet, MaxSet + */ + public void setAttributeType(@Nullable AttributeEnum attributeType) { + this.attributeType = attributeType; + } + + /** + * Adds type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @param attributeType Type of attribute: Actual, Target, MinSet, MaxSet + * @return this + */ + public SetVariableResult withAttributeType(@Nullable AttributeEnum attributeType) { + setAttributeType(attributeType); + return this; + } + + /** + * Gets result status of setting the variable. + * + * @return Result status of setting the variable + */ + public SetVariableStatusEnum getAttributeStatus() { + return attributeStatus; + } + + /** + * Sets result status of setting the variable. + * + * @param attributeStatus Result status of setting the variable + */ + public void setAttributeStatus(SetVariableStatusEnum attributeStatus) { + if (!isValidAttributeStatus(attributeStatus)) { + throw new PropertyConstraintException(attributeStatus, "attributeStatus is invalid"); + } + this.attributeStatus = attributeStatus; + } + + /** + * Returns whether the given attributeStatus is valid + * + * @param attributeStatus the attributeStatus to check the validity of + * @return {@code true} if attributeStatus is valid, {@code false} if not + */ + private boolean isValidAttributeStatus(SetVariableStatusEnum attributeStatus) { + return attributeStatus != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getAttributeStatusInfo() { + return attributeStatusInfo; + } + + /** + * Sets more information about the status. + * + * @param attributeStatusInfo More information about the status + */ + public void setAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + if (!isValidAttributeStatusInfo(attributeStatusInfo)) { + throw new PropertyConstraintException(attributeStatusInfo, "attributeStatusInfo is invalid"); + } + this.attributeStatusInfo = attributeStatusInfo; + } + + /** + * Returns whether the given attributeStatusInfo is valid + * + * @param attributeStatusInfo the attributeStatusInfo to check the validity of + * @return {@code true} if attributeStatusInfo is valid, {@code false} if not + */ + private boolean isValidAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + return attributeStatusInfo == null || attributeStatusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param attributeStatusInfo More information about the status + * @return this + */ + public SetVariableResult withAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + setAttributeStatusInfo(attributeStatusInfo); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariableResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidAttributeStatus(attributeStatus) + && isValidAttributeStatusInfo(attributeStatusInfo) + && isValidComponent(component) + && isValidVariable(variable) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariableResult that = (SetVariableResult) o; + return Objects.equals(attributeType, that.attributeType) + && Objects.equals(attributeStatus, that.attributeStatus) + && Objects.equals(attributeStatusInfo, that.attributeStatusInfo) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + attributeType, attributeStatus, attributeStatusInfo, component, variable, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("attributeType", attributeType) + .add("attributeStatus", attributeStatus) + .add("attributeStatusInfo", attributeStatusInfo) + .add("component", component) + .add("variable", variable) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableStatusEnum.java new file mode 100644 index 00000000..baf59f5a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SetVariableStatusEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Result status of setting the variable. */ +public enum SetVariableStatusEnum { + Accepted, + Rejected, + UnknownComponent, + UnknownVariable, + NotSupportedAttributeType, + RebootRequired +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SignedMeterValue.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SignedMeterValue.java new file mode 100644 index 00000000..8a3225be --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/SignedMeterValue.java @@ -0,0 +1,315 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A signed version of the meter value. */ +public final class SignedMeterValue { + /** + * Base64 encoded, contains the signed data from the meter in the format specified in + * encodingMethod, which might contain more then just the meter value. It can contain information + * like timestamps, reference to a customer etc. + */ + private String signedMeterData; + + /** + * Method used to create the digital signature. Optional, if already included in signedMeterData. + * Standard values for this are defined in Appendix as SigningMethodEnumStringType. + */ + @Nullable private String signingMethod; + + /** Format used by the energy meter to encode the meter data. For example: OCMF or EDL. */ + private String encodingMethod; + + /** Base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue. */ + @Nullable private String publicKey; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the SignedMeterValue class + * + * @param signedMeterData Base64 encoded, contains the signed data from the meter in the format + * specified in encodingMethod, which might contain more then just the meter value. It can + * contain information like timestamps, reference to a customer etc. + * @param encodingMethod Format used by the energy meter to encode the meter data. For example: + * OCMF or EDL. + */ + public SignedMeterValue(String signedMeterData, String encodingMethod) { + setSignedMeterData(signedMeterData); + setEncodingMethod(encodingMethod); + } + + /** + * Gets base64 encoded, contains the signed data from the meter in the format specified in + * encodingMethod, which might contain more then just the meter value. It can contain information + * like timestamps, reference to a customer etc. + * + * @return Base64 encoded, contains the signed data from the meter in the format specified in + * encodingMethod, which might contain more then just the meter value + */ + public String getSignedMeterData() { + return signedMeterData; + } + + /** + * Sets base64 encoded, contains the signed data from the meter in the format specified in + * encodingMethod, which might contain more then just the meter value. It can contain information + * like timestamps, reference to a customer etc. + * + * @param signedMeterData Base64 encoded, contains the signed data from the meter in the format + * specified in encodingMethod, which might contain more then just the meter value + */ + public void setSignedMeterData(String signedMeterData) { + if (!isValidSignedMeterData(signedMeterData)) { + throw new PropertyConstraintException(signedMeterData, "signedMeterData is invalid"); + } + this.signedMeterData = signedMeterData; + } + + /** + * Returns whether the given signedMeterData is valid + * + * @param signedMeterData the signedMeterData to check the validity of + * @return {@code true} if signedMeterData is valid, {@code false} if not + */ + private boolean isValidSignedMeterData(String signedMeterData) { + return signedMeterData != null && signedMeterData.length() <= 32768; + } + + /** + * Gets method used to create the digital signature. Optional, if already included in + * signedMeterData. Standard values for this are defined in Appendix as + * SigningMethodEnumStringType. + * + * @return Method used to create the digital signature + */ + @Nullable + public String getSigningMethod() { + return signingMethod; + } + + /** + * Sets method used to create the digital signature. Optional, if already included in + * signedMeterData. Standard values for this are defined in Appendix as + * SigningMethodEnumStringType. + * + * @param signingMethod Method used to create the digital signature + */ + public void setSigningMethod(@Nullable String signingMethod) { + if (!isValidSigningMethod(signingMethod)) { + throw new PropertyConstraintException(signingMethod, "signingMethod is invalid"); + } + this.signingMethod = signingMethod; + } + + /** + * Returns whether the given signingMethod is valid + * + * @param signingMethod the signingMethod to check the validity of + * @return {@code true} if signingMethod is valid, {@code false} if not + */ + private boolean isValidSigningMethod(@Nullable String signingMethod) { + return signingMethod == null || signingMethod.length() <= 50; + } + + /** + * Adds method used to create the digital signature. Optional, if already included in + * signedMeterData. Standard values for this are defined in Appendix as + * SigningMethodEnumStringType. + * + * @param signingMethod Method used to create the digital signature + * @return this + */ + public SignedMeterValue withSigningMethod(@Nullable String signingMethod) { + setSigningMethod(signingMethod); + return this; + } + + /** + * Gets format used by the energy meter to encode the meter data. For example: OCMF or EDL. + * + * @return Format used by the energy meter to encode the meter data + */ + public String getEncodingMethod() { + return encodingMethod; + } + + /** + * Sets format used by the energy meter to encode the meter data. For example: OCMF or EDL. + * + * @param encodingMethod Format used by the energy meter to encode the meter data + */ + public void setEncodingMethod(String encodingMethod) { + if (!isValidEncodingMethod(encodingMethod)) { + throw new PropertyConstraintException(encodingMethod, "encodingMethod is invalid"); + } + this.encodingMethod = encodingMethod; + } + + /** + * Returns whether the given encodingMethod is valid + * + * @param encodingMethod the encodingMethod to check the validity of + * @return {@code true} if encodingMethod is valid, {@code false} if not + */ + private boolean isValidEncodingMethod(String encodingMethod) { + return encodingMethod != null && encodingMethod.length() <= 50; + } + + /** + * Gets base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue. + * + * @return Base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue + */ + @Nullable + public String getPublicKey() { + return publicKey; + } + + /** + * Sets base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue. + * + * @param publicKey Base64 encoded, sending depends on configuration variable + * PublicKeyWithSignedMeterValue + */ + public void setPublicKey(@Nullable String publicKey) { + if (!isValidPublicKey(publicKey)) { + throw new PropertyConstraintException(publicKey, "publicKey is invalid"); + } + this.publicKey = publicKey; + } + + /** + * Returns whether the given publicKey is valid + * + * @param publicKey the publicKey to check the validity of + * @return {@code true} if publicKey is valid, {@code false} if not + */ + private boolean isValidPublicKey(@Nullable String publicKey) { + return publicKey == null || publicKey.length() <= 2500; + } + + /** + * Adds base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue. + * + * @param publicKey Base64 encoded, sending depends on configuration variable + * PublicKeyWithSignedMeterValue + * @return this + */ + public SignedMeterValue withPublicKey(@Nullable String publicKey) { + setPublicKey(publicKey); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SignedMeterValue withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidSignedMeterData(signedMeterData) + && isValidSigningMethod(signingMethod) + && isValidEncodingMethod(encodingMethod) + && isValidPublicKey(publicKey) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SignedMeterValue that = (SignedMeterValue) o; + return Objects.equals(signedMeterData, that.signedMeterData) + && Objects.equals(signingMethod, that.signingMethod) + && Objects.equals(encodingMethod, that.encodingMethod) + && Objects.equals(publicKey, that.publicKey) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(signedMeterData, signingMethod, encodingMethod, publicKey, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("signedMeterData", signedMeterData) + .add("signingMethod", signingMethod) + .add("encodingMethod", encodingMethod) + .add("publicKey", publicKey) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/StatusInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/StatusInfo.java new file mode 100644 index 00000000..ba54efcd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/StatusInfo.java @@ -0,0 +1,209 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** More information about the status. */ +public final class StatusInfo { + /** + * A predefined code for the reason why the status is returned in this response. The string is + * case-insensitive. + */ + private String reasonCode; + + /** Additional text to provide detailed information. */ + @Nullable private String additionalInfo; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the StatusInfo class + * + * @param reasonCode A predefined code for the reason why the status is returned in this response. + * The string is case-insensitive. + */ + public StatusInfo(String reasonCode) { + setReasonCode(reasonCode); + } + + /** + * Gets a predefined code for the reason why the status is returned in this response. The string + * is case-insensitive. + * + * @return A predefined code for the reason why the status is returned in this response + */ + public String getReasonCode() { + return reasonCode; + } + + /** + * Sets a predefined code for the reason why the status is returned in this response. The string + * is case-insensitive. + * + * @param reasonCode A predefined code for the reason why the status is returned in this response + */ + public void setReasonCode(String reasonCode) { + if (!isValidReasonCode(reasonCode)) { + throw new PropertyConstraintException(reasonCode, "reasonCode is invalid"); + } + this.reasonCode = reasonCode; + } + + /** + * Returns whether the given reasonCode is valid + * + * @param reasonCode the reasonCode to check the validity of + * @return {@code true} if reasonCode is valid, {@code false} if not + */ + private boolean isValidReasonCode(String reasonCode) { + return reasonCode != null && reasonCode.length() <= 20; + } + + /** + * Gets additional text to provide detailed information. + * + * @return Additional text to provide detailed information + */ + @Nullable + public String getAdditionalInfo() { + return additionalInfo; + } + + /** + * Sets additional text to provide detailed information. + * + * @param additionalInfo Additional text to provide detailed information + */ + public void setAdditionalInfo(@Nullable String additionalInfo) { + if (!isValidAdditionalInfo(additionalInfo)) { + throw new PropertyConstraintException(additionalInfo, "additionalInfo is invalid"); + } + this.additionalInfo = additionalInfo; + } + + /** + * Returns whether the given additionalInfo is valid + * + * @param additionalInfo the additionalInfo to check the validity of + * @return {@code true} if additionalInfo is valid, {@code false} if not + */ + private boolean isValidAdditionalInfo(@Nullable String additionalInfo) { + return additionalInfo == null || additionalInfo.length() <= 1024; + } + + /** + * Adds additional text to provide detailed information. + * + * @param additionalInfo Additional text to provide detailed information + * @return this + */ + public StatusInfo withAdditionalInfo(@Nullable String additionalInfo) { + setAdditionalInfo(additionalInfo); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public StatusInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidReasonCode(reasonCode) + && isValidAdditionalInfo(additionalInfo) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StatusInfo that = (StatusInfo) o; + return Objects.equals(reasonCode, that.reasonCode) + && Objects.equals(additionalInfo, that.additionalInfo) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(reasonCode, additionalInfo, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("reasonCode", reasonCode) + .add("additionalInfo", additionalInfo) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/StreamDataElement.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/StreamDataElement.java new file mode 100644 index 00000000..13484034 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/StreamDataElement.java @@ -0,0 +1,192 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** StreamDataElementType */ +public final class StreamDataElement { + /** Offset relative to basetime of this message. basetime + t is timestamp of recorded value. */ + private Double t; + + /** v */ + private String v; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the StreamDataElement class + * + * @param t Offset relative to basetime of this message. basetime + t is timestamp of recorded + * value. + * @param v v + */ + public StreamDataElement(Double t, String v) { + setT(t); + setV(v); + } + + /** + * Gets offset relative to basetime of this message. basetime + t is timestamp of recorded value. + * + * @return Offset relative to basetime of this message + */ + public Double getT() { + return t; + } + + /** + * Sets offset relative to basetime of this message. basetime + t is timestamp of recorded value. + * + * @param t Offset relative to basetime of this message + */ + public void setT(Double t) { + if (!isValidT(t)) { + throw new PropertyConstraintException(t, "t is invalid"); + } + this.t = t; + } + + /** + * Returns whether the given t is valid + * + * @param t the t to check the validity of + * @return {@code true} if t is valid, {@code false} if not + */ + private boolean isValidT(Double t) { + return t != null; + } + + /** + * Gets v + * + * @return v + */ + public String getV() { + return v; + } + + /** + * Sets v + * + * @param v v + */ + public void setV(String v) { + if (!isValidV(v)) { + throw new PropertyConstraintException(v, "v is invalid"); + } + this.v = v; + } + + /** + * Returns whether the given v is valid + * + * @param v the v to check the validity of + * @return {@code true} if v is valid, {@code false} if not + */ + private boolean isValidV(String v) { + return v != null && v.length() <= 2500; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public StreamDataElement withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidT(t) && isValidV(v) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StreamDataElement that = (StreamDataElement) o; + return Objects.equals(t, that.t) + && Objects.equals(v, that.v) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(t, v, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("t", t) + .add("v", v) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Tariff.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Tariff.java new file mode 100644 index 00000000..cfa61fdb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Tariff.java @@ -0,0 +1,698 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A tariff is described by fields with prices for: energy, charging time, idle time, fixed fee, + * reservation time, + * + *

+ * reservation fixed fee.
+ * Each of these fields may have (optional) conditions that specify when a price is applicable.
+ * The description contains a human-readable explanation of the tariff to be shown to the user.
+ * The other fields are parameters that define the tariff. These are used by the charging station to
+ * calculate the price.
+ * 
+ */ +public final class Tariff { + /** Unique id of tariff */ + private String tariffId; + + /** Message details, for a message to be displayed on a Charging Station. */ + @Nullable private MessageContent[] description; + + /** Currency code according to ISO 4217 */ + private String currency; + + /** Price elements and tax for energy */ + @Nullable private TariffEnergy energy; + + /** Time when this tariff becomes active. When absent, it is immediately active. */ + @Nullable private ZonedDateTime validFrom; + + /** Price elements and tax for time */ + @Nullable private TariffTime chargingTime; + + /** Price elements and tax for time */ + @Nullable private TariffTime idleTime; + + /** fixedFee */ + @Nullable private TariffFixed fixedFee; + + /** Price elements and tax for time */ + @Nullable private TariffTime reservationTime; + + /** reservationFixed */ + @Nullable private TariffFixed reservationFixed; + + /** Price with and without tax. At least one of exclTax, inclTax must be present. */ + @Nullable private Price minCost; + + /** Price with and without tax. At least one of exclTax, inclTax must be present. */ + @Nullable private Price maxCost; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Tariff class + * + * @param tariffId Unique id of tariff + * @param currency Currency code according to ISO 4217 + */ + public Tariff(String tariffId, String currency) { + setTariffId(tariffId); + setCurrency(currency); + } + + /** + * Gets unique id of tariff + * + * @return Unique id of tariff + */ + public String getTariffId() { + return tariffId; + } + + /** + * Sets unique id of tariff + * + * @param tariffId Unique id of tariff + */ + public void setTariffId(String tariffId) { + if (!isValidTariffId(tariffId)) { + throw new PropertyConstraintException(tariffId, "tariffId is invalid"); + } + this.tariffId = tariffId; + } + + /** + * Returns whether the given tariffId is valid + * + * @param tariffId the tariffId to check the validity of + * @return {@code true} if tariffId is valid, {@code false} if not + */ + private boolean isValidTariffId(String tariffId) { + return tariffId != null && tariffId.length() <= 60; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageContent[] getDescription() { + return description; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param description Message details, for a message to be displayed on a Charging Station + */ + public void setDescription(@Nullable MessageContent[] description) { + if (!isValidDescription(description)) { + throw new PropertyConstraintException(description, "description is invalid"); + } + this.description = description; + } + + /** + * Returns whether the given description is valid + * + * @param description the description to check the validity of + * @return {@code true} if description is valid, {@code false} if not + */ + private boolean isValidDescription(@Nullable MessageContent[] description) { + return description == null + || (description.length >= 1 + && description.length <= 10 + && Arrays.stream(description).allMatch(item -> item.validate())); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param description Message details, for a message to be displayed on a Charging Station + * @return this + */ + public Tariff withDescription(@Nullable MessageContent[] description) { + setDescription(description); + return this; + } + + /** + * Gets currency code according to ISO 4217 + * + * @return Currency code according to ISO 4217 + */ + public String getCurrency() { + return currency; + } + + /** + * Sets currency code according to ISO 4217 + * + * @param currency Currency code according to ISO 4217 + */ + public void setCurrency(String currency) { + if (!isValidCurrency(currency)) { + throw new PropertyConstraintException(currency, "currency is invalid"); + } + this.currency = currency; + } + + /** + * Returns whether the given currency is valid + * + * @param currency the currency to check the validity of + * @return {@code true} if currency is valid, {@code false} if not + */ + private boolean isValidCurrency(String currency) { + return currency != null && currency.length() <= 3; + } + + /** + * Gets price elements and tax for energy + * + * @return Price elements and tax for energy + */ + @Nullable + public TariffEnergy getEnergy() { + return energy; + } + + /** + * Sets price elements and tax for energy + * + * @param energy Price elements and tax for energy + */ + public void setEnergy(@Nullable TariffEnergy energy) { + if (!isValidEnergy(energy)) { + throw new PropertyConstraintException(energy, "energy is invalid"); + } + this.energy = energy; + } + + /** + * Returns whether the given energy is valid + * + * @param energy the energy to check the validity of + * @return {@code true} if energy is valid, {@code false} if not + */ + private boolean isValidEnergy(@Nullable TariffEnergy energy) { + return energy == null || energy.validate(); + } + + /** + * Adds price elements and tax for energy + * + * @param energy Price elements and tax for energy + * @return this + */ + public Tariff withEnergy(@Nullable TariffEnergy energy) { + setEnergy(energy); + return this; + } + + /** + * Gets time when this tariff becomes active. When absent, it is immediately active. + * + * @return Time when this tariff becomes active + */ + @Nullable + public ZonedDateTime getValidFrom() { + return validFrom; + } + + /** + * Sets time when this tariff becomes active. When absent, it is immediately active. + * + * @param validFrom Time when this tariff becomes active + */ + public void setValidFrom(@Nullable ZonedDateTime validFrom) { + this.validFrom = validFrom; + } + + /** + * Adds time when this tariff becomes active. When absent, it is immediately active. + * + * @param validFrom Time when this tariff becomes active + * @return this + */ + public Tariff withValidFrom(@Nullable ZonedDateTime validFrom) { + setValidFrom(validFrom); + return this; + } + + /** + * Gets price elements and tax for time + * + * @return Price elements and tax for time + */ + @Nullable + public TariffTime getChargingTime() { + return chargingTime; + } + + /** + * Sets price elements and tax for time + * + * @param chargingTime Price elements and tax for time + */ + public void setChargingTime(@Nullable TariffTime chargingTime) { + if (!isValidChargingTime(chargingTime)) { + throw new PropertyConstraintException(chargingTime, "chargingTime is invalid"); + } + this.chargingTime = chargingTime; + } + + /** + * Returns whether the given chargingTime is valid + * + * @param chargingTime the chargingTime to check the validity of + * @return {@code true} if chargingTime is valid, {@code false} if not + */ + private boolean isValidChargingTime(@Nullable TariffTime chargingTime) { + return chargingTime == null || chargingTime.validate(); + } + + /** + * Adds price elements and tax for time + * + * @param chargingTime Price elements and tax for time + * @return this + */ + public Tariff withChargingTime(@Nullable TariffTime chargingTime) { + setChargingTime(chargingTime); + return this; + } + + /** + * Gets price elements and tax for time + * + * @return Price elements and tax for time + */ + @Nullable + public TariffTime getIdleTime() { + return idleTime; + } + + /** + * Sets price elements and tax for time + * + * @param idleTime Price elements and tax for time + */ + public void setIdleTime(@Nullable TariffTime idleTime) { + if (!isValidIdleTime(idleTime)) { + throw new PropertyConstraintException(idleTime, "idleTime is invalid"); + } + this.idleTime = idleTime; + } + + /** + * Returns whether the given idleTime is valid + * + * @param idleTime the idleTime to check the validity of + * @return {@code true} if idleTime is valid, {@code false} if not + */ + private boolean isValidIdleTime(@Nullable TariffTime idleTime) { + return idleTime == null || idleTime.validate(); + } + + /** + * Adds price elements and tax for time + * + * @param idleTime Price elements and tax for time + * @return this + */ + public Tariff withIdleTime(@Nullable TariffTime idleTime) { + setIdleTime(idleTime); + return this; + } + + /** + * Gets fixedFee + * + * @return fixedFee + */ + @Nullable + public TariffFixed getFixedFee() { + return fixedFee; + } + + /** + * Sets fixedFee + * + * @param fixedFee fixedFee + */ + public void setFixedFee(@Nullable TariffFixed fixedFee) { + if (!isValidFixedFee(fixedFee)) { + throw new PropertyConstraintException(fixedFee, "fixedFee is invalid"); + } + this.fixedFee = fixedFee; + } + + /** + * Returns whether the given fixedFee is valid + * + * @param fixedFee the fixedFee to check the validity of + * @return {@code true} if fixedFee is valid, {@code false} if not + */ + private boolean isValidFixedFee(@Nullable TariffFixed fixedFee) { + return fixedFee == null || fixedFee.validate(); + } + + /** + * Adds fixedFee + * + * @param fixedFee fixedFee + * @return this + */ + public Tariff withFixedFee(@Nullable TariffFixed fixedFee) { + setFixedFee(fixedFee); + return this; + } + + /** + * Gets price elements and tax for time + * + * @return Price elements and tax for time + */ + @Nullable + public TariffTime getReservationTime() { + return reservationTime; + } + + /** + * Sets price elements and tax for time + * + * @param reservationTime Price elements and tax for time + */ + public void setReservationTime(@Nullable TariffTime reservationTime) { + if (!isValidReservationTime(reservationTime)) { + throw new PropertyConstraintException(reservationTime, "reservationTime is invalid"); + } + this.reservationTime = reservationTime; + } + + /** + * Returns whether the given reservationTime is valid + * + * @param reservationTime the reservationTime to check the validity of + * @return {@code true} if reservationTime is valid, {@code false} if not + */ + private boolean isValidReservationTime(@Nullable TariffTime reservationTime) { + return reservationTime == null || reservationTime.validate(); + } + + /** + * Adds price elements and tax for time + * + * @param reservationTime Price elements and tax for time + * @return this + */ + public Tariff withReservationTime(@Nullable TariffTime reservationTime) { + setReservationTime(reservationTime); + return this; + } + + /** + * Gets reservationFixed + * + * @return reservationFixed + */ + @Nullable + public TariffFixed getReservationFixed() { + return reservationFixed; + } + + /** + * Sets reservationFixed + * + * @param reservationFixed reservationFixed + */ + public void setReservationFixed(@Nullable TariffFixed reservationFixed) { + if (!isValidReservationFixed(reservationFixed)) { + throw new PropertyConstraintException(reservationFixed, "reservationFixed is invalid"); + } + this.reservationFixed = reservationFixed; + } + + /** + * Returns whether the given reservationFixed is valid + * + * @param reservationFixed the reservationFixed to check the validity of + * @return {@code true} if reservationFixed is valid, {@code false} if not + */ + private boolean isValidReservationFixed(@Nullable TariffFixed reservationFixed) { + return reservationFixed == null || reservationFixed.validate(); + } + + /** + * Adds reservationFixed + * + * @param reservationFixed reservationFixed + * @return this + */ + public Tariff withReservationFixed(@Nullable TariffFixed reservationFixed) { + setReservationFixed(reservationFixed); + return this; + } + + /** + * Gets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @return Price with and without tax + */ + @Nullable + public Price getMinCost() { + return minCost; + } + + /** + * Sets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param minCost Price with and without tax + */ + public void setMinCost(@Nullable Price minCost) { + if (!isValidMinCost(minCost)) { + throw new PropertyConstraintException(minCost, "minCost is invalid"); + } + this.minCost = minCost; + } + + /** + * Returns whether the given minCost is valid + * + * @param minCost the minCost to check the validity of + * @return {@code true} if minCost is valid, {@code false} if not + */ + private boolean isValidMinCost(@Nullable Price minCost) { + return minCost == null || minCost.validate(); + } + + /** + * Adds price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param minCost Price with and without tax + * @return this + */ + public Tariff withMinCost(@Nullable Price minCost) { + setMinCost(minCost); + return this; + } + + /** + * Gets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @return Price with and without tax + */ + @Nullable + public Price getMaxCost() { + return maxCost; + } + + /** + * Sets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param maxCost Price with and without tax + */ + public void setMaxCost(@Nullable Price maxCost) { + if (!isValidMaxCost(maxCost)) { + throw new PropertyConstraintException(maxCost, "maxCost is invalid"); + } + this.maxCost = maxCost; + } + + /** + * Returns whether the given maxCost is valid + * + * @param maxCost the maxCost to check the validity of + * @return {@code true} if maxCost is valid, {@code false} if not + */ + private boolean isValidMaxCost(@Nullable Price maxCost) { + return maxCost == null || maxCost.validate(); + } + + /** + * Adds price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param maxCost Price with and without tax + * @return this + */ + public Tariff withMaxCost(@Nullable Price maxCost) { + setMaxCost(maxCost); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Tariff withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidTariffId(tariffId) + && isValidDescription(description) + && isValidCurrency(currency) + && isValidEnergy(energy) + && isValidChargingTime(chargingTime) + && isValidIdleTime(idleTime) + && isValidFixedFee(fixedFee) + && isValidReservationTime(reservationTime) + && isValidReservationFixed(reservationFixed) + && isValidMinCost(minCost) + && isValidMaxCost(maxCost) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tariff that = (Tariff) o; + return Objects.equals(tariffId, that.tariffId) + && Arrays.equals(description, that.description) + && Objects.equals(currency, that.currency) + && Objects.equals(energy, that.energy) + && Objects.equals(validFrom, that.validFrom) + && Objects.equals(chargingTime, that.chargingTime) + && Objects.equals(idleTime, that.idleTime) + && Objects.equals(fixedFee, that.fixedFee) + && Objects.equals(reservationTime, that.reservationTime) + && Objects.equals(reservationFixed, that.reservationFixed) + && Objects.equals(minCost, that.minCost) + && Objects.equals(maxCost, that.maxCost) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + tariffId, + Arrays.hashCode(description), + currency, + energy, + validFrom, + chargingTime, + idleTime, + fixedFee, + reservationTime, + reservationFixed, + minCost, + maxCost, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("tariffId", tariffId) + .add("description", description) + .add("currency", currency) + .add("energy", energy) + .add("validFrom", validFrom) + .add("chargingTime", chargingTime) + .add("idleTime", idleTime) + .add("fixedFee", fixedFee) + .add("reservationTime", reservationTime) + .add("reservationFixed", reservationFixed) + .add("minCost", minCost) + .add("maxCost", maxCost) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffAssignment.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffAssignment.java new file mode 100644 index 00000000..4c4667d5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffAssignment.java @@ -0,0 +1,335 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Shows assignment of tariffs to EVSE or IdToken. */ +public final class TariffAssignment { + /** Tariff id. */ + private String tariffId; + + /** Kind of tariff (driver/default) */ + private TariffKindEnum tariffKind; + + /** Date/time when this tariff become active. */ + @Nullable private ZonedDateTime validFrom; + + /** evseIds */ + @Nullable private Integer[] evseIds; + + /** IdTokens related to tariff */ + @Nullable private String[] idTokens; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TariffAssignment class + * + * @param tariffId Tariff id. + * @param tariffKind Kind of tariff (driver/default) + */ + public TariffAssignment(String tariffId, TariffKindEnum tariffKind) { + setTariffId(tariffId); + setTariffKind(tariffKind); + } + + /** + * Gets tariff id. + * + * @return Tariff id + */ + public String getTariffId() { + return tariffId; + } + + /** + * Sets tariff id. + * + * @param tariffId Tariff id + */ + public void setTariffId(String tariffId) { + if (!isValidTariffId(tariffId)) { + throw new PropertyConstraintException(tariffId, "tariffId is invalid"); + } + this.tariffId = tariffId; + } + + /** + * Returns whether the given tariffId is valid + * + * @param tariffId the tariffId to check the validity of + * @return {@code true} if tariffId is valid, {@code false} if not + */ + private boolean isValidTariffId(String tariffId) { + return tariffId != null && tariffId.length() <= 60; + } + + /** + * Gets kind of tariff (driver/default) + * + * @return Kind of tariff (driver/default) + */ + public TariffKindEnum getTariffKind() { + return tariffKind; + } + + /** + * Sets kind of tariff (driver/default) + * + * @param tariffKind Kind of tariff (driver/default) + */ + public void setTariffKind(TariffKindEnum tariffKind) { + if (!isValidTariffKind(tariffKind)) { + throw new PropertyConstraintException(tariffKind, "tariffKind is invalid"); + } + this.tariffKind = tariffKind; + } + + /** + * Returns whether the given tariffKind is valid + * + * @param tariffKind the tariffKind to check the validity of + * @return {@code true} if tariffKind is valid, {@code false} if not + */ + private boolean isValidTariffKind(TariffKindEnum tariffKind) { + return tariffKind != null; + } + + /** + * Gets date/time when this tariff become active. + * + * @return Date/time when this tariff become active + */ + @Nullable + public ZonedDateTime getValidFrom() { + return validFrom; + } + + /** + * Sets date/time when this tariff become active. + * + * @param validFrom Date/time when this tariff become active + */ + public void setValidFrom(@Nullable ZonedDateTime validFrom) { + this.validFrom = validFrom; + } + + /** + * Adds date/time when this tariff become active. + * + * @param validFrom Date/time when this tariff become active + * @return this + */ + public TariffAssignment withValidFrom(@Nullable ZonedDateTime validFrom) { + setValidFrom(validFrom); + return this; + } + + /** + * Gets evseIds + * + * @return evseIds + */ + @Nullable + public Integer[] getEvseIds() { + return evseIds; + } + + /** + * Sets evseIds + * + * @param evseIds evseIds + */ + public void setEvseIds(@Nullable Integer[] evseIds) { + if (!isValidEvseIds(evseIds)) { + throw new PropertyConstraintException(evseIds, "evseIds is invalid"); + } + this.evseIds = evseIds; + } + + /** + * Returns whether the given evseIds is valid + * + * @param evseIds the evseIds to check the validity of + * @return {@code true} if evseIds is valid, {@code false} if not + */ + private boolean isValidEvseIds(@Nullable Integer[] evseIds) { + return evseIds == null || (evseIds.length >= 1); + } + + /** + * Adds evseIds + * + * @param evseIds evseIds + * @return this + */ + public TariffAssignment withEvseIds(@Nullable Integer[] evseIds) { + setEvseIds(evseIds); + return this; + } + + /** + * Gets idTokens related to tariff + * + * @return IdTokens related to tariff + */ + @Nullable + public String[] getIdTokens() { + return idTokens; + } + + /** + * Sets idTokens related to tariff + * + * @param idTokens IdTokens related to tariff + */ + public void setIdTokens(@Nullable String[] idTokens) { + if (!isValidIdTokens(idTokens)) { + throw new PropertyConstraintException(idTokens, "idTokens is invalid"); + } + this.idTokens = idTokens; + } + + /** + * Returns whether the given idTokens is valid + * + * @param idTokens the idTokens to check the validity of + * @return {@code true} if idTokens is valid, {@code false} if not + */ + private boolean isValidIdTokens(@Nullable String[] idTokens) { + return idTokens == null + || (idTokens.length >= 1 && Arrays.stream(idTokens).allMatch(item -> item.length() <= 255)); + } + + /** + * Adds idTokens related to tariff + * + * @param idTokens IdTokens related to tariff + * @return this + */ + public TariffAssignment withIdTokens(@Nullable String[] idTokens) { + setIdTokens(idTokens); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffAssignment withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidTariffId(tariffId) + && isValidTariffKind(tariffKind) + && isValidEvseIds(evseIds) + && isValidIdTokens(idTokens) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffAssignment that = (TariffAssignment) o; + return Objects.equals(tariffId, that.tariffId) + && Objects.equals(tariffKind, that.tariffKind) + && Objects.equals(validFrom, that.validFrom) + && Arrays.equals(evseIds, that.evseIds) + && Arrays.equals(idTokens, that.idTokens) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + tariffId, + tariffKind, + validFrom, + Arrays.hashCode(evseIds), + Arrays.hashCode(idTokens), + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("tariffId", tariffId) + .add("tariffKind", tariffKind) + .add("validFrom", validFrom) + .add("evseIds", evseIds) + .add("idTokens", idTokens) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffChangeStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffChangeStatusEnum.java new file mode 100644 index 00000000..3ce122d0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffChangeStatusEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Status of the operation */ +public enum TariffChangeStatusEnum { + Accepted, + Rejected, + TooManyElements, + ConditionNotSupported, + TxNotFound, + NoCurrencyChange +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffClearStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffClearStatusEnum.java new file mode 100644 index 00000000..727de049 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffClearStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** TariffClearStatusEnumType */ +public enum TariffClearStatusEnum { + Accepted, + Rejected, + NoTariff +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffConditions.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffConditions.java new file mode 100644 index 00000000..39629288 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffConditions.java @@ -0,0 +1,955 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * These conditions describe if and when a TariffEnergyType or TariffTimeType applies during a + * transaction. + * + *

When more than one restriction is set, they are to be treated as a logical AND. All need to be + * valid before this price is active. + * + *

For reverse energy flow (discharging) negative values of energy, power and current are used. + * + *

NOTE: minXXX (where XXX = Kwh/A/Kw) must be read as "closest to zero", and maxXXX as "furthest + * from zero". For example, a *charging* power range from 10 kW to 50 kWh is given by minPower = + * 10000 and maxPower = 50000, and a *discharging* power range from -10 kW to -50 kW is given by + * minPower = -10 and maxPower = -50. + * + *

NOTE: startTimeOfDay and endTimeOfDay are in local time, because it is the time in the tariff + * as it is shown to the EV driver at the Charging Station. A Charging Station will convert this to + * the internal time zone that it uses (which is recommended to be UTC, see section Generic chapter + * 3.1) when performing cost calculation. + */ +public final class TariffConditions { + /** + * Start time of day in local time. + * + *

+   * Format as per RFC 3339: time-hour ":" time-minute
+   * Must be in 24h format with leading zeros. Hour/Minute separator: ":"
+   * 
+ * + * Regex: ([0-1][0-9]\|2[0-3]):[0-5][0-9] + */ + @Nullable private String startTimeOfDay; + + /** + * End time of day in local time. Same syntax as startTimeOfDay. + * + *
+   * If end time is before start time then the period wraps around to the next day.
+   * To stop at end of the day use: 00:00.
+   * 
+ */ + @Nullable private String endTimeOfDay; + + /** Day(s) of the week this is tariff applies. */ + @Nullable private DayOfWeekEnum[] dayOfWeek; + + /** + * Start date in local time, for example: 2015-12-24. + * + *
+   * Valid from this day (inclusive).
+   * Format as per RFC 3339: full-date
+   *
+   * 
+ * + * Regex: ([12][0-9]{3})-(0[1-9]\|1[0-2])-(0[1-9]\|[12][0-9]\|3[01]) + */ + @Nullable private String validFromDate; + + /** + * End date in local time, for example: 2015-12-27. Valid until this day (exclusive). Same syntax + * as validFromDate. + */ + @Nullable private String validToDate; + + /** Type of EVSE (AC, DC) this tariff applies to. */ + @Nullable private EvseKindEnum evseKind; + + /** + * Minimum consumed energy in Wh, for example 20000 Wh. Valid from this amount of energy + * (inclusive) being used. + */ + @Nullable private Double minEnergy; + + /** + * Maximum consumed energy in Wh, for example 50000 Wh. Valid until this amount of energy + * (exclusive) being used. + */ + @Nullable private Double maxEnergy; + + /** + * Sum of the minimum current (in Amperes) over all phases, for example 5 A. + * + *
+   * When the EV is charging with more than, or equal to, the defined amount of current, this price
+   * is/becomes active. If the charging current is or becomes lower, this price is not or no longer
+   * valid and becomes inactive.
+   * This is NOT about the minimum current over the entire transaction.
+   * 
+ */ + @Nullable private Double minCurrent; + + /** + * Sum of the maximum current (in Amperes) over all phases, for example 20 A. When the EV is + * charging with less than the defined amount of current, this price becomes/is active. If the + * charging current is or becomes higher, this price is not or no longer valid and becomes + * inactive. This is NOT about the maximum current over the entire transaction. + */ + @Nullable private Double maxCurrent; + + /** + * Minimum power in W, for example 5000 W. When the EV is charging with more than, or equal to, + * the defined amount of power, this price is/becomes active. If the charging power is or becomes + * lower, this price is not or no longer valid and becomes inactive. This is NOT about the minimum + * power over the entire transaction. + */ + @Nullable private Double minPower; + + /** + * Maximum power in W, for example 20000 W. When the EV is charging with less than the defined + * amount of power, this price becomes/is active. If the charging power is or becomes higher, this + * price is not or no longer valid and becomes inactive. This is NOT about the maximum power over + * the entire transaction. + */ + @Nullable private Double maxPower; + + /** + * Minimum duration in seconds the transaction (charging and idle) MUST last (inclusive). When the + * duration of a transaction is longer than the defined value, this price is or becomes active. + * Before that moment, this price is not yet active. + */ + @Nullable private Integer minTime; + + /** + * Maximum duration in seconds the transaction (charging and idle) MUST last (exclusive). When the + * duration of a transaction is shorter than the defined value, this price is or becomes active. + * After that moment, this price is no longer active. + */ + @Nullable private Integer maxTime; + + /** + * Minimum duration in seconds the charging MUST last (inclusive). When the duration of a charging + * is longer than the defined value, this price is or becomes active. Before that moment, this + * price is not yet active. + */ + @Nullable private Integer minChargingTime; + + /** + * Maximum duration in seconds the charging MUST last (exclusive). When the duration of a charging + * is shorter than the defined value, this price is or becomes active. After that moment, this + * price is no longer active. + */ + @Nullable private Integer maxChargingTime; + + /** + * Minimum duration in seconds the idle period (i.e. not charging) MUST last (inclusive). When the + * duration of the idle time is longer than the defined value, this price is or becomes active. + * Before that moment, this price is not yet active. + */ + @Nullable private Integer minIdleTime; + + /** + * Maximum duration in seconds the idle period (i.e. not charging) MUST last (exclusive). When the + * duration of idle time is shorter than the defined value, this price is or becomes active. After + * that moment, this price is no longer active. + */ + @Nullable private Integer maxIdleTime; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the TariffConditions class */ + public TariffConditions() {} + + /** + * Gets start time of day in local time. + * + * @return Start time of day in local time + */ + @Nullable + public String getStartTimeOfDay() { + return startTimeOfDay; + } + + /** + * Sets start time of day in local time. + * + * @param startTimeOfDay Start time of day in local time + */ + public void setStartTimeOfDay(@Nullable String startTimeOfDay) { + this.startTimeOfDay = startTimeOfDay; + } + + /** + * Adds start time of day in local time. + * + * @param startTimeOfDay Start time of day in local time + * @return this + */ + public TariffConditions withStartTimeOfDay(@Nullable String startTimeOfDay) { + setStartTimeOfDay(startTimeOfDay); + return this; + } + + /** + * Gets end time of day in local time. Same syntax as startTimeOfDay. + * + * @return End time of day in local time + */ + @Nullable + public String getEndTimeOfDay() { + return endTimeOfDay; + } + + /** + * Sets end time of day in local time. Same syntax as startTimeOfDay. + * + * @param endTimeOfDay End time of day in local time + */ + public void setEndTimeOfDay(@Nullable String endTimeOfDay) { + this.endTimeOfDay = endTimeOfDay; + } + + /** + * Adds end time of day in local time. Same syntax as startTimeOfDay. + * + * @param endTimeOfDay End time of day in local time + * @return this + */ + public TariffConditions withEndTimeOfDay(@Nullable String endTimeOfDay) { + setEndTimeOfDay(endTimeOfDay); + return this; + } + + /** + * Gets day(s) of the week this is tariff applies. + * + * @return Day(s) of the week this is tariff applies + */ + @Nullable + public DayOfWeekEnum[] getDayOfWeek() { + return dayOfWeek; + } + + /** + * Sets day(s) of the week this is tariff applies. + * + * @param dayOfWeek Day(s) of the week this is tariff applies + */ + public void setDayOfWeek(@Nullable DayOfWeekEnum[] dayOfWeek) { + if (!isValidDayOfWeek(dayOfWeek)) { + throw new PropertyConstraintException(dayOfWeek, "dayOfWeek is invalid"); + } + this.dayOfWeek = dayOfWeek; + } + + /** + * Returns whether the given dayOfWeek is valid + * + * @param dayOfWeek the dayOfWeek to check the validity of + * @return {@code true} if dayOfWeek is valid, {@code false} if not + */ + private boolean isValidDayOfWeek(@Nullable DayOfWeekEnum[] dayOfWeek) { + return dayOfWeek == null || (dayOfWeek.length >= 1 && dayOfWeek.length <= 7); + } + + /** + * Adds day(s) of the week this is tariff applies. + * + * @param dayOfWeek Day(s) of the week this is tariff applies + * @return this + */ + public TariffConditions withDayOfWeek(@Nullable DayOfWeekEnum[] dayOfWeek) { + setDayOfWeek(dayOfWeek); + return this; + } + + /** + * Gets start date in local time, for example: 2015-12-24. + * + * @return Start date in local time, for example: 2015-12-24 + */ + @Nullable + public String getValidFromDate() { + return validFromDate; + } + + /** + * Sets start date in local time, for example: 2015-12-24. + * + * @param validFromDate Start date in local time, for example: 2015-12-24 + */ + public void setValidFromDate(@Nullable String validFromDate) { + this.validFromDate = validFromDate; + } + + /** + * Adds start date in local time, for example: 2015-12-24. + * + * @param validFromDate Start date in local time, for example: 2015-12-24 + * @return this + */ + public TariffConditions withValidFromDate(@Nullable String validFromDate) { + setValidFromDate(validFromDate); + return this; + } + + /** + * Gets end date in local time, for example: 2015-12-27. Valid until this day (exclusive). Same + * syntax as validFromDate. + * + * @return End date in local time, for example: 2015-12-27 + */ + @Nullable + public String getValidToDate() { + return validToDate; + } + + /** + * Sets end date in local time, for example: 2015-12-27. Valid until this day (exclusive). Same + * syntax as validFromDate. + * + * @param validToDate End date in local time, for example: 2015-12-27 + */ + public void setValidToDate(@Nullable String validToDate) { + this.validToDate = validToDate; + } + + /** + * Adds end date in local time, for example: 2015-12-27. Valid until this day (exclusive). Same + * syntax as validFromDate. + * + * @param validToDate End date in local time, for example: 2015-12-27 + * @return this + */ + public TariffConditions withValidToDate(@Nullable String validToDate) { + setValidToDate(validToDate); + return this; + } + + /** + * Gets type of EVSE (AC, DC) this tariff applies to. + * + * @return Type of EVSE (AC, DC) this tariff applies to + */ + @Nullable + public EvseKindEnum getEvseKind() { + return evseKind; + } + + /** + * Sets type of EVSE (AC, DC) this tariff applies to. + * + * @param evseKind Type of EVSE (AC, DC) this tariff applies to + */ + public void setEvseKind(@Nullable EvseKindEnum evseKind) { + this.evseKind = evseKind; + } + + /** + * Adds type of EVSE (AC, DC) this tariff applies to. + * + * @param evseKind Type of EVSE (AC, DC) this tariff applies to + * @return this + */ + public TariffConditions withEvseKind(@Nullable EvseKindEnum evseKind) { + setEvseKind(evseKind); + return this; + } + + /** + * Gets minimum consumed energy in Wh, for example 20000 Wh. Valid from this amount of energy + * (inclusive) being used. + * + * @return Minimum consumed energy in Wh, for example 20000 Wh + */ + @Nullable + public Double getMinEnergy() { + return minEnergy; + } + + /** + * Sets minimum consumed energy in Wh, for example 20000 Wh. Valid from this amount of energy + * (inclusive) being used. + * + * @param minEnergy Minimum consumed energy in Wh, for example 20000 Wh + */ + public void setMinEnergy(@Nullable Double minEnergy) { + this.minEnergy = minEnergy; + } + + /** + * Adds minimum consumed energy in Wh, for example 20000 Wh. Valid from this amount of energy + * (inclusive) being used. + * + * @param minEnergy Minimum consumed energy in Wh, for example 20000 Wh + * @return this + */ + public TariffConditions withMinEnergy(@Nullable Double minEnergy) { + setMinEnergy(minEnergy); + return this; + } + + /** + * Gets maximum consumed energy in Wh, for example 50000 Wh. Valid until this amount of energy + * (exclusive) being used. + * + * @return Maximum consumed energy in Wh, for example 50000 Wh + */ + @Nullable + public Double getMaxEnergy() { + return maxEnergy; + } + + /** + * Sets maximum consumed energy in Wh, for example 50000 Wh. Valid until this amount of energy + * (exclusive) being used. + * + * @param maxEnergy Maximum consumed energy in Wh, for example 50000 Wh + */ + public void setMaxEnergy(@Nullable Double maxEnergy) { + this.maxEnergy = maxEnergy; + } + + /** + * Adds maximum consumed energy in Wh, for example 50000 Wh. Valid until this amount of energy + * (exclusive) being used. + * + * @param maxEnergy Maximum consumed energy in Wh, for example 50000 Wh + * @return this + */ + public TariffConditions withMaxEnergy(@Nullable Double maxEnergy) { + setMaxEnergy(maxEnergy); + return this; + } + + /** + * Gets sum of the minimum current (in Amperes) over all phases, for example 5 A. + * + * @return Sum of the minimum current (in Amperes) over all phases, for example 5 A + */ + @Nullable + public Double getMinCurrent() { + return minCurrent; + } + + /** + * Sets sum of the minimum current (in Amperes) over all phases, for example 5 A. + * + * @param minCurrent Sum of the minimum current (in Amperes) over all phases, for example 5 A + */ + public void setMinCurrent(@Nullable Double minCurrent) { + this.minCurrent = minCurrent; + } + + /** + * Adds sum of the minimum current (in Amperes) over all phases, for example 5 A. + * + * @param minCurrent Sum of the minimum current (in Amperes) over all phases, for example 5 A + * @return this + */ + public TariffConditions withMinCurrent(@Nullable Double minCurrent) { + setMinCurrent(minCurrent); + return this; + } + + /** + * Gets sum of the maximum current (in Amperes) over all phases, for example 20 A. When the EV is + * charging with less than the defined amount of current, this price becomes/is active. If the + * charging current is or becomes higher, this price is not or no longer valid and becomes + * inactive. This is NOT about the maximum current over the entire transaction. + * + * @return Sum of the maximum current (in Amperes) over all phases, for example 20 A + */ + @Nullable + public Double getMaxCurrent() { + return maxCurrent; + } + + /** + * Sets sum of the maximum current (in Amperes) over all phases, for example 20 A. When the EV is + * charging with less than the defined amount of current, this price becomes/is active. If the + * charging current is or becomes higher, this price is not or no longer valid and becomes + * inactive. This is NOT about the maximum current over the entire transaction. + * + * @param maxCurrent Sum of the maximum current (in Amperes) over all phases, for example 20 A + */ + public void setMaxCurrent(@Nullable Double maxCurrent) { + this.maxCurrent = maxCurrent; + } + + /** + * Adds sum of the maximum current (in Amperes) over all phases, for example 20 A. When the EV is + * charging with less than the defined amount of current, this price becomes/is active. If the + * charging current is or becomes higher, this price is not or no longer valid and becomes + * inactive. This is NOT about the maximum current over the entire transaction. + * + * @param maxCurrent Sum of the maximum current (in Amperes) over all phases, for example 20 A + * @return this + */ + public TariffConditions withMaxCurrent(@Nullable Double maxCurrent) { + setMaxCurrent(maxCurrent); + return this; + } + + /** + * Gets minimum power in W, for example 5000 W. When the EV is charging with more than, or equal + * to, the defined amount of power, this price is/becomes active. If the charging power is or + * becomes lower, this price is not or no longer valid and becomes inactive. This is NOT about the + * minimum power over the entire transaction. + * + * @return Minimum power in W, for example 5000 W + */ + @Nullable + public Double getMinPower() { + return minPower; + } + + /** + * Sets minimum power in W, for example 5000 W. When the EV is charging with more than, or equal + * to, the defined amount of power, this price is/becomes active. If the charging power is or + * becomes lower, this price is not or no longer valid and becomes inactive. This is NOT about the + * minimum power over the entire transaction. + * + * @param minPower Minimum power in W, for example 5000 W + */ + public void setMinPower(@Nullable Double minPower) { + this.minPower = minPower; + } + + /** + * Adds minimum power in W, for example 5000 W. When the EV is charging with more than, or equal + * to, the defined amount of power, this price is/becomes active. If the charging power is or + * becomes lower, this price is not or no longer valid and becomes inactive. This is NOT about the + * minimum power over the entire transaction. + * + * @param minPower Minimum power in W, for example 5000 W + * @return this + */ + public TariffConditions withMinPower(@Nullable Double minPower) { + setMinPower(minPower); + return this; + } + + /** + * Gets maximum power in W, for example 20000 W. When the EV is charging with less than the + * defined amount of power, this price becomes/is active. If the charging power is or becomes + * higher, this price is not or no longer valid and becomes inactive. This is NOT about the + * maximum power over the entire transaction. + * + * @return Maximum power in W, for example 20000 W + */ + @Nullable + public Double getMaxPower() { + return maxPower; + } + + /** + * Sets maximum power in W, for example 20000 W. When the EV is charging with less than the + * defined amount of power, this price becomes/is active. If the charging power is or becomes + * higher, this price is not or no longer valid and becomes inactive. This is NOT about the + * maximum power over the entire transaction. + * + * @param maxPower Maximum power in W, for example 20000 W + */ + public void setMaxPower(@Nullable Double maxPower) { + this.maxPower = maxPower; + } + + /** + * Adds maximum power in W, for example 20000 W. When the EV is charging with less than the + * defined amount of power, this price becomes/is active. If the charging power is or becomes + * higher, this price is not or no longer valid and becomes inactive. This is NOT about the + * maximum power over the entire transaction. + * + * @param maxPower Maximum power in W, for example 20000 W + * @return this + */ + public TariffConditions withMaxPower(@Nullable Double maxPower) { + setMaxPower(maxPower); + return this; + } + + /** + * Gets minimum duration in seconds the transaction (charging and idle) MUST last (inclusive). + * When the duration of a transaction is longer than the defined value, this price is or becomes + * active. Before that moment, this price is not yet active. + * + * @return Minimum duration in seconds the transaction (charging and idle) MUST last (inclusive) + */ + @Nullable + public Integer getMinTime() { + return minTime; + } + + /** + * Sets minimum duration in seconds the transaction (charging and idle) MUST last (inclusive). + * When the duration of a transaction is longer than the defined value, this price is or becomes + * active. Before that moment, this price is not yet active. + * + * @param minTime Minimum duration in seconds the transaction (charging and idle) MUST last + * (inclusive) + */ + public void setMinTime(@Nullable Integer minTime) { + this.minTime = minTime; + } + + /** + * Adds minimum duration in seconds the transaction (charging and idle) MUST last (inclusive). + * When the duration of a transaction is longer than the defined value, this price is or becomes + * active. Before that moment, this price is not yet active. + * + * @param minTime Minimum duration in seconds the transaction (charging and idle) MUST last + * (inclusive) + * @return this + */ + public TariffConditions withMinTime(@Nullable Integer minTime) { + setMinTime(minTime); + return this; + } + + /** + * Gets maximum duration in seconds the transaction (charging and idle) MUST last (exclusive). + * When the duration of a transaction is shorter than the defined value, this price is or becomes + * active. After that moment, this price is no longer active. + * + * @return Maximum duration in seconds the transaction (charging and idle) MUST last (exclusive) + */ + @Nullable + public Integer getMaxTime() { + return maxTime; + } + + /** + * Sets maximum duration in seconds the transaction (charging and idle) MUST last (exclusive). + * When the duration of a transaction is shorter than the defined value, this price is or becomes + * active. After that moment, this price is no longer active. + * + * @param maxTime Maximum duration in seconds the transaction (charging and idle) MUST last + * (exclusive) + */ + public void setMaxTime(@Nullable Integer maxTime) { + this.maxTime = maxTime; + } + + /** + * Adds maximum duration in seconds the transaction (charging and idle) MUST last (exclusive). + * When the duration of a transaction is shorter than the defined value, this price is or becomes + * active. After that moment, this price is no longer active. + * + * @param maxTime Maximum duration in seconds the transaction (charging and idle) MUST last + * (exclusive) + * @return this + */ + public TariffConditions withMaxTime(@Nullable Integer maxTime) { + setMaxTime(maxTime); + return this; + } + + /** + * Gets minimum duration in seconds the charging MUST last (inclusive). When the duration of a + * charging is longer than the defined value, this price is or becomes active. Before that moment, + * this price is not yet active. + * + * @return Minimum duration in seconds the charging MUST last (inclusive) + */ + @Nullable + public Integer getMinChargingTime() { + return minChargingTime; + } + + /** + * Sets minimum duration in seconds the charging MUST last (inclusive). When the duration of a + * charging is longer than the defined value, this price is or becomes active. Before that moment, + * this price is not yet active. + * + * @param minChargingTime Minimum duration in seconds the charging MUST last (inclusive) + */ + public void setMinChargingTime(@Nullable Integer minChargingTime) { + this.minChargingTime = minChargingTime; + } + + /** + * Adds minimum duration in seconds the charging MUST last (inclusive). When the duration of a + * charging is longer than the defined value, this price is or becomes active. Before that moment, + * this price is not yet active. + * + * @param minChargingTime Minimum duration in seconds the charging MUST last (inclusive) + * @return this + */ + public TariffConditions withMinChargingTime(@Nullable Integer minChargingTime) { + setMinChargingTime(minChargingTime); + return this; + } + + /** + * Gets maximum duration in seconds the charging MUST last (exclusive). When the duration of a + * charging is shorter than the defined value, this price is or becomes active. After that moment, + * this price is no longer active. + * + * @return Maximum duration in seconds the charging MUST last (exclusive) + */ + @Nullable + public Integer getMaxChargingTime() { + return maxChargingTime; + } + + /** + * Sets maximum duration in seconds the charging MUST last (exclusive). When the duration of a + * charging is shorter than the defined value, this price is or becomes active. After that moment, + * this price is no longer active. + * + * @param maxChargingTime Maximum duration in seconds the charging MUST last (exclusive) + */ + public void setMaxChargingTime(@Nullable Integer maxChargingTime) { + this.maxChargingTime = maxChargingTime; + } + + /** + * Adds maximum duration in seconds the charging MUST last (exclusive). When the duration of a + * charging is shorter than the defined value, this price is or becomes active. After that moment, + * this price is no longer active. + * + * @param maxChargingTime Maximum duration in seconds the charging MUST last (exclusive) + * @return this + */ + public TariffConditions withMaxChargingTime(@Nullable Integer maxChargingTime) { + setMaxChargingTime(maxChargingTime); + return this; + } + + /** + * Gets minimum duration in seconds the idle period (i.e. not charging) MUST last (inclusive). + * When the duration of the idle time is longer than the defined value, this price is or becomes + * active. Before that moment, this price is not yet active. + * + * @return Minimum duration in seconds the idle period (i.e. not charging) MUST last (inclusive) + */ + @Nullable + public Integer getMinIdleTime() { + return minIdleTime; + } + + /** + * Sets minimum duration in seconds the idle period (i.e. not charging) MUST last (inclusive). + * When the duration of the idle time is longer than the defined value, this price is or becomes + * active. Before that moment, this price is not yet active. + * + * @param minIdleTime Minimum duration in seconds the idle period (i.e. not charging) MUST last + * (inclusive) + */ + public void setMinIdleTime(@Nullable Integer minIdleTime) { + this.minIdleTime = minIdleTime; + } + + /** + * Adds minimum duration in seconds the idle period (i.e. not charging) MUST last (inclusive). + * When the duration of the idle time is longer than the defined value, this price is or becomes + * active. Before that moment, this price is not yet active. + * + * @param minIdleTime Minimum duration in seconds the idle period (i.e. not charging) MUST last + * (inclusive) + * @return this + */ + public TariffConditions withMinIdleTime(@Nullable Integer minIdleTime) { + setMinIdleTime(minIdleTime); + return this; + } + + /** + * Gets maximum duration in seconds the idle period (i.e. not charging) MUST last (exclusive). + * When the duration of idle time is shorter than the defined value, this price is or becomes + * active. After that moment, this price is no longer active. + * + * @return Maximum duration in seconds the idle period (i.e. not charging) MUST last (exclusive) + */ + @Nullable + public Integer getMaxIdleTime() { + return maxIdleTime; + } + + /** + * Sets maximum duration in seconds the idle period (i.e. not charging) MUST last (exclusive). + * When the duration of idle time is shorter than the defined value, this price is or becomes + * active. After that moment, this price is no longer active. + * + * @param maxIdleTime Maximum duration in seconds the idle period (i.e. not charging) MUST last + * (exclusive) + */ + public void setMaxIdleTime(@Nullable Integer maxIdleTime) { + this.maxIdleTime = maxIdleTime; + } + + /** + * Adds maximum duration in seconds the idle period (i.e. not charging) MUST last (exclusive). + * When the duration of idle time is shorter than the defined value, this price is or becomes + * active. After that moment, this price is no longer active. + * + * @param maxIdleTime Maximum duration in seconds the idle period (i.e. not charging) MUST last + * (exclusive) + * @return this + */ + public TariffConditions withMaxIdleTime(@Nullable Integer maxIdleTime) { + setMaxIdleTime(maxIdleTime); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffConditions withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDayOfWeek(dayOfWeek) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffConditions that = (TariffConditions) o; + return Objects.equals(startTimeOfDay, that.startTimeOfDay) + && Objects.equals(endTimeOfDay, that.endTimeOfDay) + && Arrays.equals(dayOfWeek, that.dayOfWeek) + && Objects.equals(validFromDate, that.validFromDate) + && Objects.equals(validToDate, that.validToDate) + && Objects.equals(evseKind, that.evseKind) + && Objects.equals(minEnergy, that.minEnergy) + && Objects.equals(maxEnergy, that.maxEnergy) + && Objects.equals(minCurrent, that.minCurrent) + && Objects.equals(maxCurrent, that.maxCurrent) + && Objects.equals(minPower, that.minPower) + && Objects.equals(maxPower, that.maxPower) + && Objects.equals(minTime, that.minTime) + && Objects.equals(maxTime, that.maxTime) + && Objects.equals(minChargingTime, that.minChargingTime) + && Objects.equals(maxChargingTime, that.maxChargingTime) + && Objects.equals(minIdleTime, that.minIdleTime) + && Objects.equals(maxIdleTime, that.maxIdleTime) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + startTimeOfDay, + endTimeOfDay, + Arrays.hashCode(dayOfWeek), + validFromDate, + validToDate, + evseKind, + minEnergy, + maxEnergy, + minCurrent, + maxCurrent, + minPower, + maxPower, + minTime, + maxTime, + minChargingTime, + maxChargingTime, + minIdleTime, + maxIdleTime, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("startTimeOfDay", startTimeOfDay) + .add("endTimeOfDay", endTimeOfDay) + .add("dayOfWeek", dayOfWeek) + .add("validFromDate", validFromDate) + .add("validToDate", validToDate) + .add("evseKind", evseKind) + .add("minEnergy", minEnergy) + .add("maxEnergy", maxEnergy) + .add("minCurrent", minCurrent) + .add("maxCurrent", maxCurrent) + .add("minPower", minPower) + .add("maxPower", maxPower) + .add("minTime", minTime) + .add("maxTime", maxTime) + .add("minChargingTime", minChargingTime) + .add("maxChargingTime", maxChargingTime) + .add("minIdleTime", minIdleTime) + .add("maxIdleTime", maxIdleTime) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffConditionsFixed.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffConditionsFixed.java new file mode 100644 index 00000000..9202ed41 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffConditionsFixed.java @@ -0,0 +1,501 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * These conditions describe if a FixedPrice applies at start of the transaction. + * + *

When more than one restriction is set, they are to be treated as a logical AND. All need to be + * valid before this price is active. + * + *

NOTE: startTimeOfDay and endTimeOfDay are in local time, because it is the time in the tariff + * as it is shown to the EV driver at the Charging Station. A Charging Station will convert this to + * the internal time zone that it uses (which is recommended to be UTC, see section Generic chapter + * 3.1) when performing cost calculation. + */ +public final class TariffConditionsFixed { + /** + * Start time of day in local time. + * + *

+   * Format as per RFC 3339: time-hour ":" time-minute
+   * Must be in 24h format with leading zeros. Hour/Minute separator: ":"
+   * 
+ * + * Regex: ([0-1][0-9]\|2[0-3]):[0-5][0-9] + */ + @Nullable private String startTimeOfDay; + + /** + * End time of day in local time. Same syntax as startTimeOfDay. + * + *
+   * If end time is before start time then the period wraps around to the next day.
+   * To stop at end of the day use: 00:00.
+   * 
+ */ + @Nullable private String endTimeOfDay; + + /** Day(s) of the week this is tariff applies. */ + @Nullable private DayOfWeekEnum[] dayOfWeek; + + /** + * Start date in local time, for example: 2015-12-24. + * + *
+   * Valid from this day (inclusive).
+   * Format as per RFC 3339: full-date
+   *
+   * 
+ * + * Regex: ([12][0-9]{3})-(0[1-9]\|1[0-2])-(0[1-9]\|[12][0-9]\|3[01]) + */ + @Nullable private String validFromDate; + + /** + * End date in local time, for example: 2015-12-27. Valid until this day (exclusive). Same syntax + * as validFromDate. + */ + @Nullable private String validToDate; + + /** Type of EVSE (AC, DC) this tariff applies to. */ + @Nullable private EvseKindEnum evseKind; + + /** + * For which payment brand this (adhoc) tariff applies. Can be used to add a surcharge for certain + * payment brands. Based on value of additionalIdToken from idToken.additionalInfo.type = + * "PaymentBrand". + */ + @Nullable private String paymentBrand; + + /** + * Type of adhoc payment, e.g. CC, Debit. Based on value of additionalIdToken from + * idToken.additionalInfo.type = "PaymentRecognition". + */ + @Nullable private String paymentRecognition; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the TariffConditionsFixed class */ + public TariffConditionsFixed() {} + + /** + * Gets start time of day in local time. + * + * @return Start time of day in local time + */ + @Nullable + public String getStartTimeOfDay() { + return startTimeOfDay; + } + + /** + * Sets start time of day in local time. + * + * @param startTimeOfDay Start time of day in local time + */ + public void setStartTimeOfDay(@Nullable String startTimeOfDay) { + this.startTimeOfDay = startTimeOfDay; + } + + /** + * Adds start time of day in local time. + * + * @param startTimeOfDay Start time of day in local time + * @return this + */ + public TariffConditionsFixed withStartTimeOfDay(@Nullable String startTimeOfDay) { + setStartTimeOfDay(startTimeOfDay); + return this; + } + + /** + * Gets end time of day in local time. Same syntax as startTimeOfDay. + * + * @return End time of day in local time + */ + @Nullable + public String getEndTimeOfDay() { + return endTimeOfDay; + } + + /** + * Sets end time of day in local time. Same syntax as startTimeOfDay. + * + * @param endTimeOfDay End time of day in local time + */ + public void setEndTimeOfDay(@Nullable String endTimeOfDay) { + this.endTimeOfDay = endTimeOfDay; + } + + /** + * Adds end time of day in local time. Same syntax as startTimeOfDay. + * + * @param endTimeOfDay End time of day in local time + * @return this + */ + public TariffConditionsFixed withEndTimeOfDay(@Nullable String endTimeOfDay) { + setEndTimeOfDay(endTimeOfDay); + return this; + } + + /** + * Gets day(s) of the week this is tariff applies. + * + * @return Day(s) of the week this is tariff applies + */ + @Nullable + public DayOfWeekEnum[] getDayOfWeek() { + return dayOfWeek; + } + + /** + * Sets day(s) of the week this is tariff applies. + * + * @param dayOfWeek Day(s) of the week this is tariff applies + */ + public void setDayOfWeek(@Nullable DayOfWeekEnum[] dayOfWeek) { + if (!isValidDayOfWeek(dayOfWeek)) { + throw new PropertyConstraintException(dayOfWeek, "dayOfWeek is invalid"); + } + this.dayOfWeek = dayOfWeek; + } + + /** + * Returns whether the given dayOfWeek is valid + * + * @param dayOfWeek the dayOfWeek to check the validity of + * @return {@code true} if dayOfWeek is valid, {@code false} if not + */ + private boolean isValidDayOfWeek(@Nullable DayOfWeekEnum[] dayOfWeek) { + return dayOfWeek == null || (dayOfWeek.length >= 1 && dayOfWeek.length <= 7); + } + + /** + * Adds day(s) of the week this is tariff applies. + * + * @param dayOfWeek Day(s) of the week this is tariff applies + * @return this + */ + public TariffConditionsFixed withDayOfWeek(@Nullable DayOfWeekEnum[] dayOfWeek) { + setDayOfWeek(dayOfWeek); + return this; + } + + /** + * Gets start date in local time, for example: 2015-12-24. + * + * @return Start date in local time, for example: 2015-12-24 + */ + @Nullable + public String getValidFromDate() { + return validFromDate; + } + + /** + * Sets start date in local time, for example: 2015-12-24. + * + * @param validFromDate Start date in local time, for example: 2015-12-24 + */ + public void setValidFromDate(@Nullable String validFromDate) { + this.validFromDate = validFromDate; + } + + /** + * Adds start date in local time, for example: 2015-12-24. + * + * @param validFromDate Start date in local time, for example: 2015-12-24 + * @return this + */ + public TariffConditionsFixed withValidFromDate(@Nullable String validFromDate) { + setValidFromDate(validFromDate); + return this; + } + + /** + * Gets end date in local time, for example: 2015-12-27. Valid until this day (exclusive). Same + * syntax as validFromDate. + * + * @return End date in local time, for example: 2015-12-27 + */ + @Nullable + public String getValidToDate() { + return validToDate; + } + + /** + * Sets end date in local time, for example: 2015-12-27. Valid until this day (exclusive). Same + * syntax as validFromDate. + * + * @param validToDate End date in local time, for example: 2015-12-27 + */ + public void setValidToDate(@Nullable String validToDate) { + this.validToDate = validToDate; + } + + /** + * Adds end date in local time, for example: 2015-12-27. Valid until this day (exclusive). Same + * syntax as validFromDate. + * + * @param validToDate End date in local time, for example: 2015-12-27 + * @return this + */ + public TariffConditionsFixed withValidToDate(@Nullable String validToDate) { + setValidToDate(validToDate); + return this; + } + + /** + * Gets type of EVSE (AC, DC) this tariff applies to. + * + * @return Type of EVSE (AC, DC) this tariff applies to + */ + @Nullable + public EvseKindEnum getEvseKind() { + return evseKind; + } + + /** + * Sets type of EVSE (AC, DC) this tariff applies to. + * + * @param evseKind Type of EVSE (AC, DC) this tariff applies to + */ + public void setEvseKind(@Nullable EvseKindEnum evseKind) { + this.evseKind = evseKind; + } + + /** + * Adds type of EVSE (AC, DC) this tariff applies to. + * + * @param evseKind Type of EVSE (AC, DC) this tariff applies to + * @return this + */ + public TariffConditionsFixed withEvseKind(@Nullable EvseKindEnum evseKind) { + setEvseKind(evseKind); + return this; + } + + /** + * Gets for which payment brand this (adhoc) tariff applies. Can be used to add a surcharge for + * certain payment brands. Based on value of additionalIdToken from idToken.additionalInfo.type = + * "PaymentBrand". + * + * @return For which payment brand this (adhoc) tariff applies + */ + @Nullable + public String getPaymentBrand() { + return paymentBrand; + } + + /** + * Sets for which payment brand this (adhoc) tariff applies. Can be used to add a surcharge for + * certain payment brands. Based on value of additionalIdToken from idToken.additionalInfo.type = + * "PaymentBrand". + * + * @param paymentBrand For which payment brand this (adhoc) tariff applies + */ + public void setPaymentBrand(@Nullable String paymentBrand) { + if (!isValidPaymentBrand(paymentBrand)) { + throw new PropertyConstraintException(paymentBrand, "paymentBrand is invalid"); + } + this.paymentBrand = paymentBrand; + } + + /** + * Returns whether the given paymentBrand is valid + * + * @param paymentBrand the paymentBrand to check the validity of + * @return {@code true} if paymentBrand is valid, {@code false} if not + */ + private boolean isValidPaymentBrand(@Nullable String paymentBrand) { + return paymentBrand == null || paymentBrand.length() <= 20; + } + + /** + * Adds for which payment brand this (adhoc) tariff applies. Can be used to add a surcharge for + * certain payment brands. Based on value of additionalIdToken from idToken.additionalInfo.type = + * "PaymentBrand". + * + * @param paymentBrand For which payment brand this (adhoc) tariff applies + * @return this + */ + public TariffConditionsFixed withPaymentBrand(@Nullable String paymentBrand) { + setPaymentBrand(paymentBrand); + return this; + } + + /** + * Gets type of adhoc payment, e.g. CC, Debit. Based on value of additionalIdToken from + * idToken.additionalInfo.type = "PaymentRecognition". + * + * @return Type of adhoc payment, e.g. CC, Debit + */ + @Nullable + public String getPaymentRecognition() { + return paymentRecognition; + } + + /** + * Sets type of adhoc payment, e.g. CC, Debit. Based on value of additionalIdToken from + * idToken.additionalInfo.type = "PaymentRecognition". + * + * @param paymentRecognition Type of adhoc payment, e.g. CC, Debit + */ + public void setPaymentRecognition(@Nullable String paymentRecognition) { + if (!isValidPaymentRecognition(paymentRecognition)) { + throw new PropertyConstraintException(paymentRecognition, "paymentRecognition is invalid"); + } + this.paymentRecognition = paymentRecognition; + } + + /** + * Returns whether the given paymentRecognition is valid + * + * @param paymentRecognition the paymentRecognition to check the validity of + * @return {@code true} if paymentRecognition is valid, {@code false} if not + */ + private boolean isValidPaymentRecognition(@Nullable String paymentRecognition) { + return paymentRecognition == null || paymentRecognition.length() <= 20; + } + + /** + * Adds type of adhoc payment, e.g. CC, Debit. Based on value of additionalIdToken from + * idToken.additionalInfo.type = "PaymentRecognition". + * + * @param paymentRecognition Type of adhoc payment, e.g. CC, Debit + * @return this + */ + public TariffConditionsFixed withPaymentRecognition(@Nullable String paymentRecognition) { + setPaymentRecognition(paymentRecognition); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffConditionsFixed withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidDayOfWeek(dayOfWeek) + && isValidPaymentBrand(paymentBrand) + && isValidPaymentRecognition(paymentRecognition) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffConditionsFixed that = (TariffConditionsFixed) o; + return Objects.equals(startTimeOfDay, that.startTimeOfDay) + && Objects.equals(endTimeOfDay, that.endTimeOfDay) + && Arrays.equals(dayOfWeek, that.dayOfWeek) + && Objects.equals(validFromDate, that.validFromDate) + && Objects.equals(validToDate, that.validToDate) + && Objects.equals(evseKind, that.evseKind) + && Objects.equals(paymentBrand, that.paymentBrand) + && Objects.equals(paymentRecognition, that.paymentRecognition) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + startTimeOfDay, + endTimeOfDay, + Arrays.hashCode(dayOfWeek), + validFromDate, + validToDate, + evseKind, + paymentBrand, + paymentRecognition, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("startTimeOfDay", startTimeOfDay) + .add("endTimeOfDay", endTimeOfDay) + .add("dayOfWeek", dayOfWeek) + .add("validFromDate", validFromDate) + .add("validToDate", validToDate) + .add("evseKind", evseKind) + .add("paymentBrand", paymentBrand) + .add("paymentRecognition", paymentRecognition) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffCostEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffCostEnum.java new file mode 100644 index 00000000..51494efa --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffCostEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of cost: normal or the minimum or maximum cost. */ +public enum TariffCostEnum { + NormalCost, + MinCost, + MaxCost +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffEnergy.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffEnergy.java new file mode 100644 index 00000000..ad5fe223 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffEnergy.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Price elements and tax for energy */ +public final class TariffEnergy { + /** Tariff with optional conditions for an energy price. */ + private TariffEnergyPrice[] prices; + + /** Tax percentage */ + @Nullable private TaxRate[] taxRates; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TariffEnergy class + * + * @param prices Tariff with optional conditions for an energy price. + */ + public TariffEnergy(TariffEnergyPrice[] prices) { + setPrices(prices); + } + + /** + * Gets tariff with optional conditions for an energy price. + * + * @return Tariff with optional conditions for an energy price + */ + public TariffEnergyPrice[] getPrices() { + return prices; + } + + /** + * Sets tariff with optional conditions for an energy price. + * + * @param prices Tariff with optional conditions for an energy price + */ + public void setPrices(TariffEnergyPrice[] prices) { + if (!isValidPrices(prices)) { + throw new PropertyConstraintException(prices, "prices is invalid"); + } + this.prices = prices; + } + + /** + * Returns whether the given prices is valid + * + * @param prices the prices to check the validity of + * @return {@code true} if prices is valid, {@code false} if not + */ + private boolean isValidPrices(TariffEnergyPrice[] prices) { + return prices != null + && prices.length >= 1 + && Arrays.stream(prices).allMatch(item -> item.validate()); + } + + /** + * Gets tax percentage + * + * @return Tax percentage + */ + @Nullable + public TaxRate[] getTaxRates() { + return taxRates; + } + + /** + * Sets tax percentage + * + * @param taxRates Tax percentage + */ + public void setTaxRates(@Nullable TaxRate[] taxRates) { + if (!isValidTaxRates(taxRates)) { + throw new PropertyConstraintException(taxRates, "taxRates is invalid"); + } + this.taxRates = taxRates; + } + + /** + * Returns whether the given taxRates is valid + * + * @param taxRates the taxRates to check the validity of + * @return {@code true} if taxRates is valid, {@code false} if not + */ + private boolean isValidTaxRates(@Nullable TaxRate[] taxRates) { + return taxRates == null + || (taxRates.length >= 1 + && taxRates.length <= 5 + && Arrays.stream(taxRates).allMatch(item -> item.validate())); + } + + /** + * Adds tax percentage + * + * @param taxRates Tax percentage + * @return this + */ + public TariffEnergy withTaxRates(@Nullable TaxRate[] taxRates) { + setTaxRates(taxRates); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffEnergy withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPrices(prices) && isValidTaxRates(taxRates) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffEnergy that = (TariffEnergy) o; + return Arrays.equals(prices, that.prices) + && Arrays.equals(taxRates, that.taxRates) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(prices), Arrays.hashCode(taxRates), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("prices", prices) + .add("taxRates", taxRates) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffEnergyPrice.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffEnergyPrice.java new file mode 100644 index 00000000..a928dc02 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffEnergyPrice.java @@ -0,0 +1,227 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Tariff with optional conditions for an energy price. */ +public final class TariffEnergyPrice { + /** Price per kWh (excl. tax) for this element. */ + private Double priceKwh; + + /** + * These conditions describe if and when a TariffEnergyType or TariffTimeType applies during a + * transaction. + * + *

When more than one restriction is set, they are to be treated as a logical AND. All need to + * be valid before this price is active. + * + *

For reverse energy flow (discharging) negative values of energy, power and current are used. + * + *

NOTE: minXXX (where XXX = Kwh/A/Kw) must be read as "closest to zero", and maxXXX as + * "furthest from zero". For example, a *charging* power range from 10 kW to 50 kWh is given by + * minPower = 10000 and maxPower = 50000, and a *discharging* power range from -10 kW to -50 kW is + * given by minPower = -10 and maxPower = -50. + * + *

NOTE: startTimeOfDay and endTimeOfDay are in local time, because it is the time in the + * tariff as it is shown to the EV driver at the Charging Station. A Charging Station will convert + * this to the internal time zone that it uses (which is recommended to be UTC, see section + * Generic chapter 3.1) when performing cost calculation. + */ + @Nullable private TariffConditions conditions; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TariffEnergyPrice class + * + * @param priceKwh Price per kWh (excl. tax) for this element. + */ + public TariffEnergyPrice(Double priceKwh) { + setPriceKwh(priceKwh); + } + + /** + * Gets price per kWh (excl. tax) for this element. + * + * @return Price per kWh (excl + */ + public Double getPriceKwh() { + return priceKwh; + } + + /** + * Sets price per kWh (excl. tax) for this element. + * + * @param priceKwh Price per kWh (excl + */ + public void setPriceKwh(Double priceKwh) { + if (!isValidPriceKwh(priceKwh)) { + throw new PropertyConstraintException(priceKwh, "priceKwh is invalid"); + } + this.priceKwh = priceKwh; + } + + /** + * Returns whether the given priceKwh is valid + * + * @param priceKwh the priceKwh to check the validity of + * @return {@code true} if priceKwh is valid, {@code false} if not + */ + private boolean isValidPriceKwh(Double priceKwh) { + return priceKwh != null; + } + + /** + * Gets these conditions describe if and when a TariffEnergyType or TariffTimeType applies during + * a transaction. + * + * @return These conditions describe if and when a TariffEnergyType or TariffTimeType applies + * during a transaction + */ + @Nullable + public TariffConditions getConditions() { + return conditions; + } + + /** + * Sets these conditions describe if and when a TariffEnergyType or TariffTimeType applies during + * a transaction. + * + * @param conditions These conditions describe if and when a TariffEnergyType or TariffTimeType + * applies during a transaction + */ + public void setConditions(@Nullable TariffConditions conditions) { + if (!isValidConditions(conditions)) { + throw new PropertyConstraintException(conditions, "conditions is invalid"); + } + this.conditions = conditions; + } + + /** + * Returns whether the given conditions is valid + * + * @param conditions the conditions to check the validity of + * @return {@code true} if conditions is valid, {@code false} if not + */ + private boolean isValidConditions(@Nullable TariffConditions conditions) { + return conditions == null || conditions.validate(); + } + + /** + * Adds these conditions describe if and when a TariffEnergyType or TariffTimeType applies during + * a transaction. + * + * @param conditions These conditions describe if and when a TariffEnergyType or TariffTimeType + * applies during a transaction + * @return this + */ + public TariffEnergyPrice withConditions(@Nullable TariffConditions conditions) { + setConditions(conditions); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffEnergyPrice withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriceKwh(priceKwh) + && isValidConditions(conditions) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffEnergyPrice that = (TariffEnergyPrice) o; + return Objects.equals(priceKwh, that.priceKwh) + && Objects.equals(conditions, that.conditions) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(priceKwh, conditions, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priceKwh", priceKwh) + .add("conditions", conditions) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffFixed.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffFixed.java new file mode 100644 index 00000000..ea4c250a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffFixed.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** TariffFixedType */ +public final class TariffFixed { + /** Tariff with optional conditions for a fixed price. */ + private TariffFixedPrice[] prices; + + /** Tax percentage */ + @Nullable private TaxRate[] taxRates; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TariffFixed class + * + * @param prices Tariff with optional conditions for a fixed price. + */ + public TariffFixed(TariffFixedPrice[] prices) { + setPrices(prices); + } + + /** + * Gets tariff with optional conditions for a fixed price. + * + * @return Tariff with optional conditions for a fixed price + */ + public TariffFixedPrice[] getPrices() { + return prices; + } + + /** + * Sets tariff with optional conditions for a fixed price. + * + * @param prices Tariff with optional conditions for a fixed price + */ + public void setPrices(TariffFixedPrice[] prices) { + if (!isValidPrices(prices)) { + throw new PropertyConstraintException(prices, "prices is invalid"); + } + this.prices = prices; + } + + /** + * Returns whether the given prices is valid + * + * @param prices the prices to check the validity of + * @return {@code true} if prices is valid, {@code false} if not + */ + private boolean isValidPrices(TariffFixedPrice[] prices) { + return prices != null + && prices.length >= 1 + && Arrays.stream(prices).allMatch(item -> item.validate()); + } + + /** + * Gets tax percentage + * + * @return Tax percentage + */ + @Nullable + public TaxRate[] getTaxRates() { + return taxRates; + } + + /** + * Sets tax percentage + * + * @param taxRates Tax percentage + */ + public void setTaxRates(@Nullable TaxRate[] taxRates) { + if (!isValidTaxRates(taxRates)) { + throw new PropertyConstraintException(taxRates, "taxRates is invalid"); + } + this.taxRates = taxRates; + } + + /** + * Returns whether the given taxRates is valid + * + * @param taxRates the taxRates to check the validity of + * @return {@code true} if taxRates is valid, {@code false} if not + */ + private boolean isValidTaxRates(@Nullable TaxRate[] taxRates) { + return taxRates == null + || (taxRates.length >= 1 + && taxRates.length <= 5 + && Arrays.stream(taxRates).allMatch(item -> item.validate())); + } + + /** + * Adds tax percentage + * + * @param taxRates Tax percentage + * @return this + */ + public TariffFixed withTaxRates(@Nullable TaxRate[] taxRates) { + setTaxRates(taxRates); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffFixed withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPrices(prices) && isValidTaxRates(taxRates) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffFixed that = (TariffFixed) o; + return Arrays.equals(prices, that.prices) + && Arrays.equals(taxRates, that.taxRates) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(prices), Arrays.hashCode(taxRates), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("prices", prices) + .add("taxRates", taxRates) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffFixedPrice.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffFixedPrice.java new file mode 100644 index 00000000..c4d4bdba --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffFixedPrice.java @@ -0,0 +1,213 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Tariff with optional conditions for a fixed price. */ +public final class TariffFixedPrice { + /** + * These conditions describe if a FixedPrice applies at start of the transaction. + * + *

When more than one restriction is set, they are to be treated as a logical AND. All need to + * be valid before this price is active. + * + *

NOTE: startTimeOfDay and endTimeOfDay are in local time, because it is the time in the + * tariff as it is shown to the EV driver at the Charging Station. A Charging Station will convert + * this to the internal time zone that it uses (which is recommended to be UTC, see section + * Generic chapter 3.1) when performing cost calculation. + */ + @Nullable private TariffConditionsFixed conditions; + + /** Fixed price for this element e.g. a start fee. */ + private Double priceFixed; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TariffFixedPrice class + * + * @param priceFixed Fixed price for this element e.g. a start fee. + */ + public TariffFixedPrice(Double priceFixed) { + setPriceFixed(priceFixed); + } + + /** + * Gets these conditions describe if a FixedPrice applies at start of the transaction. + * + * @return These conditions describe if a FixedPrice applies at start of the transaction + */ + @Nullable + public TariffConditionsFixed getConditions() { + return conditions; + } + + /** + * Sets these conditions describe if a FixedPrice applies at start of the transaction. + * + * @param conditions These conditions describe if a FixedPrice applies at start of the transaction + */ + public void setConditions(@Nullable TariffConditionsFixed conditions) { + if (!isValidConditions(conditions)) { + throw new PropertyConstraintException(conditions, "conditions is invalid"); + } + this.conditions = conditions; + } + + /** + * Returns whether the given conditions is valid + * + * @param conditions the conditions to check the validity of + * @return {@code true} if conditions is valid, {@code false} if not + */ + private boolean isValidConditions(@Nullable TariffConditionsFixed conditions) { + return conditions == null || conditions.validate(); + } + + /** + * Adds these conditions describe if a FixedPrice applies at start of the transaction. + * + * @param conditions These conditions describe if a FixedPrice applies at start of the transaction + * @return this + */ + public TariffFixedPrice withConditions(@Nullable TariffConditionsFixed conditions) { + setConditions(conditions); + return this; + } + + /** + * Gets fixed price for this element e.g. a start fee. + * + * @return Fixed price for this element e.g. a start fee + */ + public Double getPriceFixed() { + return priceFixed; + } + + /** + * Sets fixed price for this element e.g. a start fee. + * + * @param priceFixed Fixed price for this element e.g. a start fee + */ + public void setPriceFixed(Double priceFixed) { + if (!isValidPriceFixed(priceFixed)) { + throw new PropertyConstraintException(priceFixed, "priceFixed is invalid"); + } + this.priceFixed = priceFixed; + } + + /** + * Returns whether the given priceFixed is valid + * + * @param priceFixed the priceFixed to check the validity of + * @return {@code true} if priceFixed is valid, {@code false} if not + */ + private boolean isValidPriceFixed(Double priceFixed) { + return priceFixed != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffFixedPrice withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidConditions(conditions) + && isValidPriceFixed(priceFixed) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffFixedPrice that = (TariffFixedPrice) o; + return Objects.equals(conditions, that.conditions) + && Objects.equals(priceFixed, that.priceFixed) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(conditions, priceFixed, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("conditions", conditions) + .add("priceFixed", priceFixed) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffGetStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffGetStatusEnum.java new file mode 100644 index 00000000..794869c1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffGetStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Status of operation */ +public enum TariffGetStatusEnum { + Accepted, + Rejected, + NoTariff +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffKindEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffKindEnum.java new file mode 100644 index 00000000..93e788c0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffKindEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Kind of tariff (driver/default) */ +public enum TariffKindEnum { + DefaultTariff, + DriverTariff +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffSetStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffSetStatusEnum.java new file mode 100644 index 00000000..be4379b8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffSetStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** TariffSetStatusEnumType */ +public enum TariffSetStatusEnum { + Accepted, + Rejected, + TooManyElements, + ConditionNotSupported, + DuplicateTariffId +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffTime.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffTime.java new file mode 100644 index 00000000..68fdc957 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffTime.java @@ -0,0 +1,207 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Price elements and tax for time */ +public final class TariffTime { + /** Tariff with optional conditions for a time duration price. */ + private TariffTimePrice[] prices; + + /** Tax percentage */ + @Nullable private TaxRate[] taxRates; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TariffTime class + * + * @param prices Tariff with optional conditions for a time duration price. + */ + public TariffTime(TariffTimePrice[] prices) { + setPrices(prices); + } + + /** + * Gets tariff with optional conditions for a time duration price. + * + * @return Tariff with optional conditions for a time duration price + */ + public TariffTimePrice[] getPrices() { + return prices; + } + + /** + * Sets tariff with optional conditions for a time duration price. + * + * @param prices Tariff with optional conditions for a time duration price + */ + public void setPrices(TariffTimePrice[] prices) { + if (!isValidPrices(prices)) { + throw new PropertyConstraintException(prices, "prices is invalid"); + } + this.prices = prices; + } + + /** + * Returns whether the given prices is valid + * + * @param prices the prices to check the validity of + * @return {@code true} if prices is valid, {@code false} if not + */ + private boolean isValidPrices(TariffTimePrice[] prices) { + return prices != null + && prices.length >= 1 + && Arrays.stream(prices).allMatch(item -> item.validate()); + } + + /** + * Gets tax percentage + * + * @return Tax percentage + */ + @Nullable + public TaxRate[] getTaxRates() { + return taxRates; + } + + /** + * Sets tax percentage + * + * @param taxRates Tax percentage + */ + public void setTaxRates(@Nullable TaxRate[] taxRates) { + if (!isValidTaxRates(taxRates)) { + throw new PropertyConstraintException(taxRates, "taxRates is invalid"); + } + this.taxRates = taxRates; + } + + /** + * Returns whether the given taxRates is valid + * + * @param taxRates the taxRates to check the validity of + * @return {@code true} if taxRates is valid, {@code false} if not + */ + private boolean isValidTaxRates(@Nullable TaxRate[] taxRates) { + return taxRates == null + || (taxRates.length >= 1 + && taxRates.length <= 5 + && Arrays.stream(taxRates).allMatch(item -> item.validate())); + } + + /** + * Adds tax percentage + * + * @param taxRates Tax percentage + * @return this + */ + public TariffTime withTaxRates(@Nullable TaxRate[] taxRates) { + setTaxRates(taxRates); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffTime withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPrices(prices) && isValidTaxRates(taxRates) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffTime that = (TariffTime) o; + return Arrays.equals(prices, that.prices) + && Arrays.equals(taxRates, that.taxRates) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(prices), Arrays.hashCode(taxRates), customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("prices", prices) + .add("taxRates", taxRates) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffTimePrice.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffTimePrice.java new file mode 100644 index 00000000..ff0834d3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TariffTimePrice.java @@ -0,0 +1,227 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Tariff with optional conditions for a time duration price. */ +public final class TariffTimePrice { + /** Price per minute (excl. tax) for this element. */ + private Double priceMinute; + + /** + * These conditions describe if and when a TariffEnergyType or TariffTimeType applies during a + * transaction. + * + *

When more than one restriction is set, they are to be treated as a logical AND. All need to + * be valid before this price is active. + * + *

For reverse energy flow (discharging) negative values of energy, power and current are used. + * + *

NOTE: minXXX (where XXX = Kwh/A/Kw) must be read as "closest to zero", and maxXXX as + * "furthest from zero". For example, a *charging* power range from 10 kW to 50 kWh is given by + * minPower = 10000 and maxPower = 50000, and a *discharging* power range from -10 kW to -50 kW is + * given by minPower = -10 and maxPower = -50. + * + *

NOTE: startTimeOfDay and endTimeOfDay are in local time, because it is the time in the + * tariff as it is shown to the EV driver at the Charging Station. A Charging Station will convert + * this to the internal time zone that it uses (which is recommended to be UTC, see section + * Generic chapter 3.1) when performing cost calculation. + */ + @Nullable private TariffConditions conditions; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TariffTimePrice class + * + * @param priceMinute Price per minute (excl. tax) for this element. + */ + public TariffTimePrice(Double priceMinute) { + setPriceMinute(priceMinute); + } + + /** + * Gets price per minute (excl. tax) for this element. + * + * @return Price per minute (excl + */ + public Double getPriceMinute() { + return priceMinute; + } + + /** + * Sets price per minute (excl. tax) for this element. + * + * @param priceMinute Price per minute (excl + */ + public void setPriceMinute(Double priceMinute) { + if (!isValidPriceMinute(priceMinute)) { + throw new PropertyConstraintException(priceMinute, "priceMinute is invalid"); + } + this.priceMinute = priceMinute; + } + + /** + * Returns whether the given priceMinute is valid + * + * @param priceMinute the priceMinute to check the validity of + * @return {@code true} if priceMinute is valid, {@code false} if not + */ + private boolean isValidPriceMinute(Double priceMinute) { + return priceMinute != null; + } + + /** + * Gets these conditions describe if and when a TariffEnergyType or TariffTimeType applies during + * a transaction. + * + * @return These conditions describe if and when a TariffEnergyType or TariffTimeType applies + * during a transaction + */ + @Nullable + public TariffConditions getConditions() { + return conditions; + } + + /** + * Sets these conditions describe if and when a TariffEnergyType or TariffTimeType applies during + * a transaction. + * + * @param conditions These conditions describe if and when a TariffEnergyType or TariffTimeType + * applies during a transaction + */ + public void setConditions(@Nullable TariffConditions conditions) { + if (!isValidConditions(conditions)) { + throw new PropertyConstraintException(conditions, "conditions is invalid"); + } + this.conditions = conditions; + } + + /** + * Returns whether the given conditions is valid + * + * @param conditions the conditions to check the validity of + * @return {@code true} if conditions is valid, {@code false} if not + */ + private boolean isValidConditions(@Nullable TariffConditions conditions) { + return conditions == null || conditions.validate(); + } + + /** + * Adds these conditions describe if and when a TariffEnergyType or TariffTimeType applies during + * a transaction. + * + * @param conditions These conditions describe if and when a TariffEnergyType or TariffTimeType + * applies during a transaction + * @return this + */ + public TariffTimePrice withConditions(@Nullable TariffConditions conditions) { + setConditions(conditions); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TariffTimePrice withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidPriceMinute(priceMinute) + && isValidConditions(conditions) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TariffTimePrice that = (TariffTimePrice) o; + return Objects.equals(priceMinute, that.priceMinute) + && Objects.equals(conditions, that.conditions) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(priceMinute, conditions, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("priceMinute", priceMinute) + .add("conditions", conditions) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TaxRate.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TaxRate.java new file mode 100644 index 00000000..3522b85c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TaxRate.java @@ -0,0 +1,250 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Tax percentage */ +public final class TaxRate { + /** Type of this tax, e.g. "Federal ", "State", for information on receipt. */ + private String type; + + /** Tax percentage */ + private Double tax; + + /** + * Stack level for this type of tax. Default value, when absent, is 0. + * + *

+   * stack = 0: tax on net price;
+   * stack = 1: tax added on top of stack 0;
+   * stack = 2: tax added on top of stack 1, etc.
+   * 
+ */ + @Nullable private Integer stack; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TaxRate class + * + * @param type Type of this tax, e.g. "Federal ", "State", for information on receipt. + * @param tax Tax percentage + */ + public TaxRate(String type, Double tax) { + setType(type); + setTax(tax); + } + + /** + * Gets type of this tax, e.g. "Federal ", "State", for information on receipt. + * + * @return Type of this tax, e.g. "Federal ", "State", for information on receipt + */ + public String getType() { + return type; + } + + /** + * Sets type of this tax, e.g. "Federal ", "State", for information on receipt. + * + * @param type Type of this tax, e.g. "Federal ", "State", for information on receipt + */ + public void setType(String type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(String type) { + return type != null && type.length() <= 20; + } + + /** + * Gets tax percentage + * + * @return Tax percentage + */ + public Double getTax() { + return tax; + } + + /** + * Sets tax percentage + * + * @param tax Tax percentage + */ + public void setTax(Double tax) { + if (!isValidTax(tax)) { + throw new PropertyConstraintException(tax, "tax is invalid"); + } + this.tax = tax; + } + + /** + * Returns whether the given tax is valid + * + * @param tax the tax to check the validity of + * @return {@code true} if tax is valid, {@code false} if not + */ + private boolean isValidTax(Double tax) { + return tax != null; + } + + /** + * Gets stack level for this type of tax. Default value, when absent, is 0. + * + * @return Stack level for this type of tax + */ + @Nullable + public Integer getStack() { + return stack; + } + + /** + * Sets stack level for this type of tax. Default value, when absent, is 0. + * + * @param stack Stack level for this type of tax + */ + public void setStack(@Nullable Integer stack) { + if (!isValidStack(stack)) { + throw new PropertyConstraintException(stack, "stack is invalid"); + } + this.stack = stack; + } + + /** + * Returns whether the given stack is valid + * + * @param stack the stack to check the validity of + * @return {@code true} if stack is valid, {@code false} if not + */ + private boolean isValidStack(@Nullable Integer stack) { + return stack == null || (stack >= 0); + } + + /** + * Adds stack level for this type of tax. Default value, when absent, is 0. + * + * @param stack Stack level for this type of tax + * @return this + */ + public TaxRate withStack(@Nullable Integer stack) { + setStack(stack); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TaxRate withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidType(type) + && isValidTax(tax) + && isValidStack(stack) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TaxRate that = (TaxRate) o; + return Objects.equals(type, that.type) + && Objects.equals(tax, that.tax) + && Objects.equals(stack, that.stack) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(type, tax, stack, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("type", type) + .add("tax", tax) + .add("stack", stack) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TaxRule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TaxRule.java new file mode 100644 index 00000000..750c4fbc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TaxRule.java @@ -0,0 +1,450 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Part of ISO 15118-20 price schedule. */ +public final class TaxRule { + /** Id for the tax rule. */ + private Integer taxRuleID; + + /** Human readable string to identify the tax rule. */ + @Nullable private String taxRuleName; + + /** Whether the tax is included in any price or not. */ + @Nullable private Boolean taxIncludedInPrice; + + /** Whether this tax applies to Energy Fees. */ + private Boolean appliesToEnergyFee; + + /** Whether this tax applies to Parking Fees. */ + private Boolean appliesToParkingFee; + + /** Whether this tax applies to Overstay Fees. */ + private Boolean appliesToOverstayFee; + + /** Whether this tax applies to Minimum/Maximum Cost. */ + private Boolean appliesToMinimumMaximumCost; + + /** Part of ISO 15118-20 price schedule. */ + private RationalNumber taxRate; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TaxRule class + * + * @param taxRuleID Id for the tax rule. + * @param appliesToEnergyFee Whether this tax applies to Energy Fees. + * @param appliesToParkingFee Whether this tax applies to Parking Fees. + * @param appliesToOverstayFee Whether this tax applies to Overstay Fees. + * @param appliesToMinimumMaximumCost Whether this tax applies to Minimum/Maximum Cost. + * @param taxRate Part of ISO 15118-20 price schedule. + */ + public TaxRule( + Integer taxRuleID, + Boolean appliesToEnergyFee, + Boolean appliesToParkingFee, + Boolean appliesToOverstayFee, + Boolean appliesToMinimumMaximumCost, + RationalNumber taxRate) { + setTaxRuleID(taxRuleID); + setAppliesToEnergyFee(appliesToEnergyFee); + setAppliesToParkingFee(appliesToParkingFee); + setAppliesToOverstayFee(appliesToOverstayFee); + setAppliesToMinimumMaximumCost(appliesToMinimumMaximumCost); + setTaxRate(taxRate); + } + + /** + * Gets id for the tax rule. + * + * @return Id for the tax rule + */ + public Integer getTaxRuleID() { + return taxRuleID; + } + + /** + * Sets id for the tax rule. + * + * @param taxRuleID Id for the tax rule + */ + public void setTaxRuleID(Integer taxRuleID) { + if (!isValidTaxRuleID(taxRuleID)) { + throw new PropertyConstraintException(taxRuleID, "taxRuleID is invalid"); + } + this.taxRuleID = taxRuleID; + } + + /** + * Returns whether the given taxRuleID is valid + * + * @param taxRuleID the taxRuleID to check the validity of + * @return {@code true} if taxRuleID is valid, {@code false} if not + */ + private boolean isValidTaxRuleID(Integer taxRuleID) { + return taxRuleID != null && taxRuleID >= 0; + } + + /** + * Gets human readable string to identify the tax rule. + * + * @return Human readable string to identify the tax rule + */ + @Nullable + public String getTaxRuleName() { + return taxRuleName; + } + + /** + * Sets human readable string to identify the tax rule. + * + * @param taxRuleName Human readable string to identify the tax rule + */ + public void setTaxRuleName(@Nullable String taxRuleName) { + if (!isValidTaxRuleName(taxRuleName)) { + throw new PropertyConstraintException(taxRuleName, "taxRuleName is invalid"); + } + this.taxRuleName = taxRuleName; + } + + /** + * Returns whether the given taxRuleName is valid + * + * @param taxRuleName the taxRuleName to check the validity of + * @return {@code true} if taxRuleName is valid, {@code false} if not + */ + private boolean isValidTaxRuleName(@Nullable String taxRuleName) { + return taxRuleName == null || taxRuleName.length() <= 100; + } + + /** + * Adds human readable string to identify the tax rule. + * + * @param taxRuleName Human readable string to identify the tax rule + * @return this + */ + public TaxRule withTaxRuleName(@Nullable String taxRuleName) { + setTaxRuleName(taxRuleName); + return this; + } + + /** + * Gets whether the tax is included in any price or not. + * + * @return Whether the tax is included in any price or not + */ + @Nullable + public Boolean getTaxIncludedInPrice() { + return taxIncludedInPrice; + } + + /** + * Sets whether the tax is included in any price or not. + * + * @param taxIncludedInPrice Whether the tax is included in any price or not + */ + public void setTaxIncludedInPrice(@Nullable Boolean taxIncludedInPrice) { + this.taxIncludedInPrice = taxIncludedInPrice; + } + + /** + * Adds whether the tax is included in any price or not. + * + * @param taxIncludedInPrice Whether the tax is included in any price or not + * @return this + */ + public TaxRule withTaxIncludedInPrice(@Nullable Boolean taxIncludedInPrice) { + setTaxIncludedInPrice(taxIncludedInPrice); + return this; + } + + /** + * Gets whether this tax applies to Energy Fees. + * + * @return Whether this tax applies to Energy Fees + */ + public Boolean getAppliesToEnergyFee() { + return appliesToEnergyFee; + } + + /** + * Sets whether this tax applies to Energy Fees. + * + * @param appliesToEnergyFee Whether this tax applies to Energy Fees + */ + public void setAppliesToEnergyFee(Boolean appliesToEnergyFee) { + if (!isValidAppliesToEnergyFee(appliesToEnergyFee)) { + throw new PropertyConstraintException(appliesToEnergyFee, "appliesToEnergyFee is invalid"); + } + this.appliesToEnergyFee = appliesToEnergyFee; + } + + /** + * Returns whether the given appliesToEnergyFee is valid + * + * @param appliesToEnergyFee the appliesToEnergyFee to check the validity of + * @return {@code true} if appliesToEnergyFee is valid, {@code false} if not + */ + private boolean isValidAppliesToEnergyFee(Boolean appliesToEnergyFee) { + return appliesToEnergyFee != null; + } + + /** + * Gets whether this tax applies to Parking Fees. + * + * @return Whether this tax applies to Parking Fees + */ + public Boolean getAppliesToParkingFee() { + return appliesToParkingFee; + } + + /** + * Sets whether this tax applies to Parking Fees. + * + * @param appliesToParkingFee Whether this tax applies to Parking Fees + */ + public void setAppliesToParkingFee(Boolean appliesToParkingFee) { + if (!isValidAppliesToParkingFee(appliesToParkingFee)) { + throw new PropertyConstraintException(appliesToParkingFee, "appliesToParkingFee is invalid"); + } + this.appliesToParkingFee = appliesToParkingFee; + } + + /** + * Returns whether the given appliesToParkingFee is valid + * + * @param appliesToParkingFee the appliesToParkingFee to check the validity of + * @return {@code true} if appliesToParkingFee is valid, {@code false} if not + */ + private boolean isValidAppliesToParkingFee(Boolean appliesToParkingFee) { + return appliesToParkingFee != null; + } + + /** + * Gets whether this tax applies to Overstay Fees. + * + * @return Whether this tax applies to Overstay Fees + */ + public Boolean getAppliesToOverstayFee() { + return appliesToOverstayFee; + } + + /** + * Sets whether this tax applies to Overstay Fees. + * + * @param appliesToOverstayFee Whether this tax applies to Overstay Fees + */ + public void setAppliesToOverstayFee(Boolean appliesToOverstayFee) { + if (!isValidAppliesToOverstayFee(appliesToOverstayFee)) { + throw new PropertyConstraintException( + appliesToOverstayFee, "appliesToOverstayFee is invalid"); + } + this.appliesToOverstayFee = appliesToOverstayFee; + } + + /** + * Returns whether the given appliesToOverstayFee is valid + * + * @param appliesToOverstayFee the appliesToOverstayFee to check the validity of + * @return {@code true} if appliesToOverstayFee is valid, {@code false} if not + */ + private boolean isValidAppliesToOverstayFee(Boolean appliesToOverstayFee) { + return appliesToOverstayFee != null; + } + + /** + * Gets whether this tax applies to Minimum/Maximum Cost. + * + * @return Whether this tax applies to Minimum/Maximum Cost + */ + public Boolean getAppliesToMinimumMaximumCost() { + return appliesToMinimumMaximumCost; + } + + /** + * Sets whether this tax applies to Minimum/Maximum Cost. + * + * @param appliesToMinimumMaximumCost Whether this tax applies to Minimum/Maximum Cost + */ + public void setAppliesToMinimumMaximumCost(Boolean appliesToMinimumMaximumCost) { + if (!isValidAppliesToMinimumMaximumCost(appliesToMinimumMaximumCost)) { + throw new PropertyConstraintException( + appliesToMinimumMaximumCost, "appliesToMinimumMaximumCost is invalid"); + } + this.appliesToMinimumMaximumCost = appliesToMinimumMaximumCost; + } + + /** + * Returns whether the given appliesToMinimumMaximumCost is valid + * + * @param appliesToMinimumMaximumCost the appliesToMinimumMaximumCost to check the validity of + * @return {@code true} if appliesToMinimumMaximumCost is valid, {@code false} if not + */ + private boolean isValidAppliesToMinimumMaximumCost(Boolean appliesToMinimumMaximumCost) { + return appliesToMinimumMaximumCost != null; + } + + /** + * Gets part of ISO 15118-20 price schedule. + * + * @return Part of ISO 15118-20 price schedule + */ + public RationalNumber getTaxRate() { + return taxRate; + } + + /** + * Sets part of ISO 15118-20 price schedule. + * + * @param taxRate Part of ISO 15118-20 price schedule + */ + public void setTaxRate(RationalNumber taxRate) { + if (!isValidTaxRate(taxRate)) { + throw new PropertyConstraintException(taxRate, "taxRate is invalid"); + } + this.taxRate = taxRate; + } + + /** + * Returns whether the given taxRate is valid + * + * @param taxRate the taxRate to check the validity of + * @return {@code true} if taxRate is valid, {@code false} if not + */ + private boolean isValidTaxRate(RationalNumber taxRate) { + return taxRate != null && taxRate.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TaxRule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidTaxRuleID(taxRuleID) + && isValidTaxRuleName(taxRuleName) + && isValidAppliesToEnergyFee(appliesToEnergyFee) + && isValidAppliesToParkingFee(appliesToParkingFee) + && isValidAppliesToOverstayFee(appliesToOverstayFee) + && isValidAppliesToMinimumMaximumCost(appliesToMinimumMaximumCost) + && isValidTaxRate(taxRate) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TaxRule that = (TaxRule) o; + return Objects.equals(taxRuleID, that.taxRuleID) + && Objects.equals(taxRuleName, that.taxRuleName) + && Objects.equals(taxIncludedInPrice, that.taxIncludedInPrice) + && Objects.equals(appliesToEnergyFee, that.appliesToEnergyFee) + && Objects.equals(appliesToParkingFee, that.appliesToParkingFee) + && Objects.equals(appliesToOverstayFee, that.appliesToOverstayFee) + && Objects.equals(appliesToMinimumMaximumCost, that.appliesToMinimumMaximumCost) + && Objects.equals(taxRate, that.taxRate) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + taxRuleID, + taxRuleName, + taxIncludedInPrice, + appliesToEnergyFee, + appliesToParkingFee, + appliesToOverstayFee, + appliesToMinimumMaximumCost, + taxRate, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("taxRuleID", taxRuleID) + .add("taxRuleName", taxRuleName) + .add("taxIncludedInPrice", taxIncludedInPrice) + .add("appliesToEnergyFee", appliesToEnergyFee) + .add("appliesToParkingFee", appliesToParkingFee) + .add("appliesToOverstayFee", appliesToOverstayFee) + .add("appliesToMinimumMaximumCost", appliesToMinimumMaximumCost) + .add("taxRate", taxRate) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalCost.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalCost.java new file mode 100644 index 00000000..5d559343 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalCost.java @@ -0,0 +1,545 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * The cost calculated during a transaction. It is used both for running cost and final cost of the + * transaction. + */ +public final class TotalCost { + /** Currency of the costs in ISO 4217 Code. */ + private String currency; + + /** Type of cost: normal or the minimum or maximum cost. */ + private TariffCostEnum typeOfCost; + + /** Price with and without tax. At least one of exclTax, inclTax must be present. */ + @Nullable private Price fixed; + + /** Price with and without tax. At least one of exclTax, inclTax must be present. */ + @Nullable private Price energy; + + /** Price with and without tax. At least one of exclTax, inclTax must be present. */ + @Nullable private Price chargingTime; + + /** Price with and without tax. At least one of exclTax, inclTax must be present. */ + @Nullable private Price idleTime; + + /** Price with and without tax. At least one of exclTax, inclTax must be present. */ + @Nullable private Price reservationTime; + + /** Price with and without tax. At least one of exclTax, inclTax must be present. */ + @Nullable private Price reservationFixed; + + /** + * Total cost with and without tax. Contains the total of energy, charging time, idle time, fixed + * and reservation costs including and/or excluding tax. + */ + private TotalPrice total; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TotalCost class + * + * @param currency Currency of the costs in ISO 4217 Code. + * @param typeOfCost Type of cost: normal or the minimum or maximum cost. + * @param total Total cost with and without tax. Contains the total of energy, charging time, idle + * time, fixed and reservation costs including and/or excluding tax. + */ + public TotalCost(String currency, TariffCostEnum typeOfCost, TotalPrice total) { + setCurrency(currency); + setTypeOfCost(typeOfCost); + setTotal(total); + } + + /** + * Gets currency of the costs in ISO 4217 Code. + * + * @return Currency of the costs in ISO 4217 Code + */ + public String getCurrency() { + return currency; + } + + /** + * Sets currency of the costs in ISO 4217 Code. + * + * @param currency Currency of the costs in ISO 4217 Code + */ + public void setCurrency(String currency) { + if (!isValidCurrency(currency)) { + throw new PropertyConstraintException(currency, "currency is invalid"); + } + this.currency = currency; + } + + /** + * Returns whether the given currency is valid + * + * @param currency the currency to check the validity of + * @return {@code true} if currency is valid, {@code false} if not + */ + private boolean isValidCurrency(String currency) { + return currency != null && currency.length() <= 3; + } + + /** + * Gets type of cost: normal or the minimum or maximum cost. + * + * @return Type of cost: normal or the minimum or maximum cost + */ + public TariffCostEnum getTypeOfCost() { + return typeOfCost; + } + + /** + * Sets type of cost: normal or the minimum or maximum cost. + * + * @param typeOfCost Type of cost: normal or the minimum or maximum cost + */ + public void setTypeOfCost(TariffCostEnum typeOfCost) { + if (!isValidTypeOfCost(typeOfCost)) { + throw new PropertyConstraintException(typeOfCost, "typeOfCost is invalid"); + } + this.typeOfCost = typeOfCost; + } + + /** + * Returns whether the given typeOfCost is valid + * + * @param typeOfCost the typeOfCost to check the validity of + * @return {@code true} if typeOfCost is valid, {@code false} if not + */ + private boolean isValidTypeOfCost(TariffCostEnum typeOfCost) { + return typeOfCost != null; + } + + /** + * Gets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @return Price with and without tax + */ + @Nullable + public Price getFixed() { + return fixed; + } + + /** + * Sets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param fixed Price with and without tax + */ + public void setFixed(@Nullable Price fixed) { + if (!isValidFixed(fixed)) { + throw new PropertyConstraintException(fixed, "fixed is invalid"); + } + this.fixed = fixed; + } + + /** + * Returns whether the given fixed is valid + * + * @param fixed the fixed to check the validity of + * @return {@code true} if fixed is valid, {@code false} if not + */ + private boolean isValidFixed(@Nullable Price fixed) { + return fixed == null || fixed.validate(); + } + + /** + * Adds price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param fixed Price with and without tax + * @return this + */ + public TotalCost withFixed(@Nullable Price fixed) { + setFixed(fixed); + return this; + } + + /** + * Gets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @return Price with and without tax + */ + @Nullable + public Price getEnergy() { + return energy; + } + + /** + * Sets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param energy Price with and without tax + */ + public void setEnergy(@Nullable Price energy) { + if (!isValidEnergy(energy)) { + throw new PropertyConstraintException(energy, "energy is invalid"); + } + this.energy = energy; + } + + /** + * Returns whether the given energy is valid + * + * @param energy the energy to check the validity of + * @return {@code true} if energy is valid, {@code false} if not + */ + private boolean isValidEnergy(@Nullable Price energy) { + return energy == null || energy.validate(); + } + + /** + * Adds price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param energy Price with and without tax + * @return this + */ + public TotalCost withEnergy(@Nullable Price energy) { + setEnergy(energy); + return this; + } + + /** + * Gets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @return Price with and without tax + */ + @Nullable + public Price getChargingTime() { + return chargingTime; + } + + /** + * Sets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param chargingTime Price with and without tax + */ + public void setChargingTime(@Nullable Price chargingTime) { + if (!isValidChargingTime(chargingTime)) { + throw new PropertyConstraintException(chargingTime, "chargingTime is invalid"); + } + this.chargingTime = chargingTime; + } + + /** + * Returns whether the given chargingTime is valid + * + * @param chargingTime the chargingTime to check the validity of + * @return {@code true} if chargingTime is valid, {@code false} if not + */ + private boolean isValidChargingTime(@Nullable Price chargingTime) { + return chargingTime == null || chargingTime.validate(); + } + + /** + * Adds price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param chargingTime Price with and without tax + * @return this + */ + public TotalCost withChargingTime(@Nullable Price chargingTime) { + setChargingTime(chargingTime); + return this; + } + + /** + * Gets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @return Price with and without tax + */ + @Nullable + public Price getIdleTime() { + return idleTime; + } + + /** + * Sets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param idleTime Price with and without tax + */ + public void setIdleTime(@Nullable Price idleTime) { + if (!isValidIdleTime(idleTime)) { + throw new PropertyConstraintException(idleTime, "idleTime is invalid"); + } + this.idleTime = idleTime; + } + + /** + * Returns whether the given idleTime is valid + * + * @param idleTime the idleTime to check the validity of + * @return {@code true} if idleTime is valid, {@code false} if not + */ + private boolean isValidIdleTime(@Nullable Price idleTime) { + return idleTime == null || idleTime.validate(); + } + + /** + * Adds price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param idleTime Price with and without tax + * @return this + */ + public TotalCost withIdleTime(@Nullable Price idleTime) { + setIdleTime(idleTime); + return this; + } + + /** + * Gets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @return Price with and without tax + */ + @Nullable + public Price getReservationTime() { + return reservationTime; + } + + /** + * Sets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param reservationTime Price with and without tax + */ + public void setReservationTime(@Nullable Price reservationTime) { + if (!isValidReservationTime(reservationTime)) { + throw new PropertyConstraintException(reservationTime, "reservationTime is invalid"); + } + this.reservationTime = reservationTime; + } + + /** + * Returns whether the given reservationTime is valid + * + * @param reservationTime the reservationTime to check the validity of + * @return {@code true} if reservationTime is valid, {@code false} if not + */ + private boolean isValidReservationTime(@Nullable Price reservationTime) { + return reservationTime == null || reservationTime.validate(); + } + + /** + * Adds price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param reservationTime Price with and without tax + * @return this + */ + public TotalCost withReservationTime(@Nullable Price reservationTime) { + setReservationTime(reservationTime); + return this; + } + + /** + * Gets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @return Price with and without tax + */ + @Nullable + public Price getReservationFixed() { + return reservationFixed; + } + + /** + * Sets price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param reservationFixed Price with and without tax + */ + public void setReservationFixed(@Nullable Price reservationFixed) { + if (!isValidReservationFixed(reservationFixed)) { + throw new PropertyConstraintException(reservationFixed, "reservationFixed is invalid"); + } + this.reservationFixed = reservationFixed; + } + + /** + * Returns whether the given reservationFixed is valid + * + * @param reservationFixed the reservationFixed to check the validity of + * @return {@code true} if reservationFixed is valid, {@code false} if not + */ + private boolean isValidReservationFixed(@Nullable Price reservationFixed) { + return reservationFixed == null || reservationFixed.validate(); + } + + /** + * Adds price with and without tax. At least one of exclTax, inclTax must be present. + * + * @param reservationFixed Price with and without tax + * @return this + */ + public TotalCost withReservationFixed(@Nullable Price reservationFixed) { + setReservationFixed(reservationFixed); + return this; + } + + /** + * Gets total cost with and without tax. Contains the total of energy, charging time, idle time, + * fixed and reservation costs including and/or excluding tax. + * + * @return Total cost with and without tax + */ + public TotalPrice getTotal() { + return total; + } + + /** + * Sets total cost with and without tax. Contains the total of energy, charging time, idle time, + * fixed and reservation costs including and/or excluding tax. + * + * @param total Total cost with and without tax + */ + public void setTotal(TotalPrice total) { + if (!isValidTotal(total)) { + throw new PropertyConstraintException(total, "total is invalid"); + } + this.total = total; + } + + /** + * Returns whether the given total is valid + * + * @param total the total to check the validity of + * @return {@code true} if total is valid, {@code false} if not + */ + private boolean isValidTotal(TotalPrice total) { + return total != null && total.validate(); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TotalCost withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCurrency(currency) + && isValidTypeOfCost(typeOfCost) + && isValidFixed(fixed) + && isValidEnergy(energy) + && isValidChargingTime(chargingTime) + && isValidIdleTime(idleTime) + && isValidReservationTime(reservationTime) + && isValidReservationFixed(reservationFixed) + && isValidTotal(total) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TotalCost that = (TotalCost) o; + return Objects.equals(currency, that.currency) + && Objects.equals(typeOfCost, that.typeOfCost) + && Objects.equals(fixed, that.fixed) + && Objects.equals(energy, that.energy) + && Objects.equals(chargingTime, that.chargingTime) + && Objects.equals(idleTime, that.idleTime) + && Objects.equals(reservationTime, that.reservationTime) + && Objects.equals(reservationFixed, that.reservationFixed) + && Objects.equals(total, that.total) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + currency, + typeOfCost, + fixed, + energy, + chargingTime, + idleTime, + reservationTime, + reservationFixed, + total, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("currency", currency) + .add("typeOfCost", typeOfCost) + .add("fixed", fixed) + .add("energy", energy) + .add("chargingTime", chargingTime) + .add("idleTime", idleTime) + .add("reservationTime", reservationTime) + .add("reservationFixed", reservationFixed) + .add("total", total) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalPrice.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalPrice.java new file mode 100644 index 00000000..b3f27e6f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalPrice.java @@ -0,0 +1,184 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Total cost with and without tax. Contains the total of energy, charging time, idle time, fixed + * and reservation costs including and/or excluding tax. + */ +public final class TotalPrice { + /** Price/cost excluding tax. Can be absent if inclTax is present. */ + @Nullable private Double exclTax; + + /** Price/cost including tax. Can be absent if exclTax is present. */ + @Nullable private Double inclTax; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the TotalPrice class */ + public TotalPrice() {} + + /** + * Gets price/cost excluding tax. Can be absent if inclTax is present. + * + * @return Price/cost excluding tax + */ + @Nullable + public Double getExclTax() { + return exclTax; + } + + /** + * Sets price/cost excluding tax. Can be absent if inclTax is present. + * + * @param exclTax Price/cost excluding tax + */ + public void setExclTax(@Nullable Double exclTax) { + this.exclTax = exclTax; + } + + /** + * Adds price/cost excluding tax. Can be absent if inclTax is present. + * + * @param exclTax Price/cost excluding tax + * @return this + */ + public TotalPrice withExclTax(@Nullable Double exclTax) { + setExclTax(exclTax); + return this; + } + + /** + * Gets price/cost including tax. Can be absent if exclTax is present. + * + * @return Price/cost including tax + */ + @Nullable + public Double getInclTax() { + return inclTax; + } + + /** + * Sets price/cost including tax. Can be absent if exclTax is present. + * + * @param inclTax Price/cost including tax + */ + public void setInclTax(@Nullable Double inclTax) { + this.inclTax = inclTax; + } + + /** + * Adds price/cost including tax. Can be absent if exclTax is present. + * + * @param inclTax Price/cost including tax + * @return this + */ + public TotalPrice withInclTax(@Nullable Double inclTax) { + setInclTax(inclTax); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TotalPrice withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TotalPrice that = (TotalPrice) o; + return Objects.equals(exclTax, that.exclTax) + && Objects.equals(inclTax, that.inclTax) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(exclTax, inclTax, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("exclTax", exclTax) + .add("inclTax", inclTax) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalUsage.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalUsage.java new file mode 100644 index 00000000..e520e597 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TotalUsage.java @@ -0,0 +1,283 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** The calculated usage of energy, charging time and idle time during a transaction. */ +public final class TotalUsage { + /** energy */ + private Double energy; + + /** + * Total duration of the charging session (including the duration of charging and not charging), + * in seconds. + */ + private Integer chargingTime; + + /** + * Total duration of the charging session where the EV was not charging (no energy was transferred + * between EVSE and EV), in seconds. + */ + private Integer idleTime; + + /** Total time of reservation in seconds. */ + @Nullable private Integer reservationTime; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the TotalUsage class + * + * @param energy energy + * @param chargingTime Total duration of the charging session (including the duration of charging + * and not charging), in seconds. + * @param idleTime Total duration of the charging session where the EV was not charging (no energy + * was transferred between EVSE and EV), in seconds. + */ + public TotalUsage(Double energy, Integer chargingTime, Integer idleTime) { + setEnergy(energy); + setChargingTime(chargingTime); + setIdleTime(idleTime); + } + + /** + * Gets energy + * + * @return energy + */ + public Double getEnergy() { + return energy; + } + + /** + * Sets energy + * + * @param energy energy + */ + public void setEnergy(Double energy) { + if (!isValidEnergy(energy)) { + throw new PropertyConstraintException(energy, "energy is invalid"); + } + this.energy = energy; + } + + /** + * Returns whether the given energy is valid + * + * @param energy the energy to check the validity of + * @return {@code true} if energy is valid, {@code false} if not + */ + private boolean isValidEnergy(Double energy) { + return energy != null; + } + + /** + * Gets total duration of the charging session (including the duration of charging and not + * charging), in seconds. + * + * @return Total duration of the charging session (including the duration of charging and not + * charging), in seconds + */ + public Integer getChargingTime() { + return chargingTime; + } + + /** + * Sets total duration of the charging session (including the duration of charging and not + * charging), in seconds. + * + * @param chargingTime Total duration of the charging session (including the duration of charging + * and not charging), in seconds + */ + public void setChargingTime(Integer chargingTime) { + if (!isValidChargingTime(chargingTime)) { + throw new PropertyConstraintException(chargingTime, "chargingTime is invalid"); + } + this.chargingTime = chargingTime; + } + + /** + * Returns whether the given chargingTime is valid + * + * @param chargingTime the chargingTime to check the validity of + * @return {@code true} if chargingTime is valid, {@code false} if not + */ + private boolean isValidChargingTime(Integer chargingTime) { + return chargingTime != null; + } + + /** + * Gets total duration of the charging session where the EV was not charging (no energy was + * transferred between EVSE and EV), in seconds. + * + * @return Total duration of the charging session where the EV was not charging (no energy was + * transferred between EVSE and EV), in seconds + */ + public Integer getIdleTime() { + return idleTime; + } + + /** + * Sets total duration of the charging session where the EV was not charging (no energy was + * transferred between EVSE and EV), in seconds. + * + * @param idleTime Total duration of the charging session where the EV was not charging (no energy + * was transferred between EVSE and EV), in seconds + */ + public void setIdleTime(Integer idleTime) { + if (!isValidIdleTime(idleTime)) { + throw new PropertyConstraintException(idleTime, "idleTime is invalid"); + } + this.idleTime = idleTime; + } + + /** + * Returns whether the given idleTime is valid + * + * @param idleTime the idleTime to check the validity of + * @return {@code true} if idleTime is valid, {@code false} if not + */ + private boolean isValidIdleTime(Integer idleTime) { + return idleTime != null; + } + + /** + * Gets total time of reservation in seconds. + * + * @return Total time of reservation in seconds + */ + @Nullable + public Integer getReservationTime() { + return reservationTime; + } + + /** + * Sets total time of reservation in seconds. + * + * @param reservationTime Total time of reservation in seconds + */ + public void setReservationTime(@Nullable Integer reservationTime) { + this.reservationTime = reservationTime; + } + + /** + * Adds total time of reservation in seconds. + * + * @param reservationTime Total time of reservation in seconds + * @return this + */ + public TotalUsage withReservationTime(@Nullable Integer reservationTime) { + setReservationTime(reservationTime); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TotalUsage withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidEnergy(energy) + && isValidChargingTime(chargingTime) + && isValidIdleTime(idleTime) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TotalUsage that = (TotalUsage) o; + return Objects.equals(energy, that.energy) + && Objects.equals(chargingTime, that.chargingTime) + && Objects.equals(idleTime, that.idleTime) + && Objects.equals(reservationTime, that.reservationTime) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(energy, chargingTime, idleTime, reservationTime, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("energy", energy) + .add("chargingTime", chargingTime) + .add("idleTime", idleTime) + .add("reservationTime", reservationTime) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Transaction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Transaction.java new file mode 100644 index 00000000..c7d7b48f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Transaction.java @@ -0,0 +1,479 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** TransactionType */ +public final class Transaction { + /** The Id of the transaction. */ + private String transactionId; + + /** + * Current charging state, is required when state has changed. Omitted when there is no + * communication between EVSE and EV, because no cable is plugged in. + */ + @Nullable private ChargingStateEnum chargingState; + + /** + * The total time that energy flowed from EVSE to EV during the transaction (in seconds). Note + * that timeSpentCharging is smaller or equal to the duration of the transaction. + */ + @Nullable private Integer timeSpentCharging; + + /** + * The stoppedReason is the reason/event that initiated the process of stopping the transaction. + * It will normally be the user stopping authorization via card (Local or MasterPass) or app + * (Remote), but it can also be CSMS revoking authorization (DeAuthorized), or disconnecting the + * EV when TxStopPoint = EVConnected (EVDisconnected). Most other reasons are related to technical + * faults or energy limitations. + * + *

MAY only be omitted when stoppedReason is "Local" + */ + @Nullable private ReasonEnum stoppedReason; + + /** + * The ID given to remote start request (RequestStartTransactionRequest. This enables to CSMS to + * match the started transaction to the given start request. + */ + @Nullable private Integer remoteStartId; + + /** The operationMode that is currently in effect for the transaction. */ + @Nullable private OperationModeEnum operationMode; + + /** Id of tariff in use for transaction */ + @Nullable private String tariffId; + + /** Cost, energy, time or SoC limit for a transaction. */ + @Nullable private TransactionLimit transactionLimit; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Transaction class + * + * @param transactionId The Id of the transaction. + */ + public Transaction(String transactionId) { + setTransactionId(transactionId); + } + + /** + * Gets the Id of the transaction. + * + * @return The Id of the transaction + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the Id of the transaction. + * + * @param transactionId The Id of the transaction + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + /** + * Gets current charging state, is required when state has changed. Omitted when there is no + * communication between EVSE and EV, because no cable is plugged in. + * + * @return Current charging state, is required when state has changed + */ + @Nullable + public ChargingStateEnum getChargingState() { + return chargingState; + } + + /** + * Sets current charging state, is required when state has changed. Omitted when there is no + * communication between EVSE and EV, because no cable is plugged in. + * + * @param chargingState Current charging state, is required when state has changed + */ + public void setChargingState(@Nullable ChargingStateEnum chargingState) { + this.chargingState = chargingState; + } + + /** + * Adds current charging state, is required when state has changed. Omitted when there is no + * communication between EVSE and EV, because no cable is plugged in. + * + * @param chargingState Current charging state, is required when state has changed + * @return this + */ + public Transaction withChargingState(@Nullable ChargingStateEnum chargingState) { + setChargingState(chargingState); + return this; + } + + /** + * Gets the total time that energy flowed from EVSE to EV during the transaction (in seconds). + * Note that timeSpentCharging is smaller or equal to the duration of the transaction. + * + * @return The total time that energy flowed from EVSE to EV during the transaction (in seconds) + */ + @Nullable + public Integer getTimeSpentCharging() { + return timeSpentCharging; + } + + /** + * Sets the total time that energy flowed from EVSE to EV during the transaction (in seconds). + * Note that timeSpentCharging is smaller or equal to the duration of the transaction. + * + * @param timeSpentCharging The total time that energy flowed from EVSE to EV during the + * transaction (in seconds) + */ + public void setTimeSpentCharging(@Nullable Integer timeSpentCharging) { + this.timeSpentCharging = timeSpentCharging; + } + + /** + * Adds the total time that energy flowed from EVSE to EV during the transaction (in seconds). + * Note that timeSpentCharging is smaller or equal to the duration of the transaction. + * + * @param timeSpentCharging The total time that energy flowed from EVSE to EV during the + * transaction (in seconds) + * @return this + */ + public Transaction withTimeSpentCharging(@Nullable Integer timeSpentCharging) { + setTimeSpentCharging(timeSpentCharging); + return this; + } + + /** + * Gets the stoppedReason is the reason/event that initiated the process of stopping the + * transaction. It will normally be the user stopping authorization via card (Local or MasterPass) + * or app (Remote), but it can also be CSMS revoking authorization (DeAuthorized), or + * disconnecting the EV when TxStopPoint = EVConnected (EVDisconnected). Most other reasons are + * related to technical faults or energy limitations. + * + * @return The stoppedReason is the reason/event that initiated the process of stopping the + * transaction + */ + @Nullable + public ReasonEnum getStoppedReason() { + return stoppedReason; + } + + /** + * Sets the stoppedReason is the reason/event that initiated the process of stopping the + * transaction. It will normally be the user stopping authorization via card (Local or MasterPass) + * or app (Remote), but it can also be CSMS revoking authorization (DeAuthorized), or + * disconnecting the EV when TxStopPoint = EVConnected (EVDisconnected). Most other reasons are + * related to technical faults or energy limitations. + * + * @param stoppedReason The stoppedReason is the reason/event that initiated the process of + * stopping the transaction + */ + public void setStoppedReason(@Nullable ReasonEnum stoppedReason) { + this.stoppedReason = stoppedReason; + } + + /** + * Adds the stoppedReason is the reason/event that initiated the process of stopping the + * transaction. It will normally be the user stopping authorization via card (Local or MasterPass) + * or app (Remote), but it can also be CSMS revoking authorization (DeAuthorized), or + * disconnecting the EV when TxStopPoint = EVConnected (EVDisconnected). Most other reasons are + * related to technical faults or energy limitations. + * + * @param stoppedReason The stoppedReason is the reason/event that initiated the process of + * stopping the transaction + * @return this + */ + public Transaction withStoppedReason(@Nullable ReasonEnum stoppedReason) { + setStoppedReason(stoppedReason); + return this; + } + + /** + * Gets the ID given to remote start request (RequestStartTransactionRequest. This enables to CSMS + * to match the started transaction to the given start request. + * + * @return The ID given to remote start request (RequestStartTransactionRequest + */ + @Nullable + public Integer getRemoteStartId() { + return remoteStartId; + } + + /** + * Sets the ID given to remote start request (RequestStartTransactionRequest. This enables to CSMS + * to match the started transaction to the given start request. + * + * @param remoteStartId The ID given to remote start request (RequestStartTransactionRequest + */ + public void setRemoteStartId(@Nullable Integer remoteStartId) { + this.remoteStartId = remoteStartId; + } + + /** + * Adds the ID given to remote start request (RequestStartTransactionRequest. This enables to CSMS + * to match the started transaction to the given start request. + * + * @param remoteStartId The ID given to remote start request (RequestStartTransactionRequest + * @return this + */ + public Transaction withRemoteStartId(@Nullable Integer remoteStartId) { + setRemoteStartId(remoteStartId); + return this; + } + + /** + * Gets the operationMode that is currently in effect for the transaction. + * + * @return The operationMode that is currently in effect for the transaction + */ + @Nullable + public OperationModeEnum getOperationMode() { + return operationMode; + } + + /** + * Sets the operationMode that is currently in effect for the transaction. + * + * @param operationMode The operationMode that is currently in effect for the transaction + */ + public void setOperationMode(@Nullable OperationModeEnum operationMode) { + this.operationMode = operationMode; + } + + /** + * Adds the operationMode that is currently in effect for the transaction. + * + * @param operationMode The operationMode that is currently in effect for the transaction + * @return this + */ + public Transaction withOperationMode(@Nullable OperationModeEnum operationMode) { + setOperationMode(operationMode); + return this; + } + + /** + * Gets id of tariff in use for transaction + * + * @return Id of tariff in use for transaction + */ + @Nullable + public String getTariffId() { + return tariffId; + } + + /** + * Sets id of tariff in use for transaction + * + * @param tariffId Id of tariff in use for transaction + */ + public void setTariffId(@Nullable String tariffId) { + if (!isValidTariffId(tariffId)) { + throw new PropertyConstraintException(tariffId, "tariffId is invalid"); + } + this.tariffId = tariffId; + } + + /** + * Returns whether the given tariffId is valid + * + * @param tariffId the tariffId to check the validity of + * @return {@code true} if tariffId is valid, {@code false} if not + */ + private boolean isValidTariffId(@Nullable String tariffId) { + return tariffId == null || tariffId.length() <= 60; + } + + /** + * Adds id of tariff in use for transaction + * + * @param tariffId Id of tariff in use for transaction + * @return this + */ + public Transaction withTariffId(@Nullable String tariffId) { + setTariffId(tariffId); + return this; + } + + /** + * Gets cost, energy, time or SoC limit for a transaction. + * + * @return Cost, energy, time or SoC limit for a transaction + */ + @Nullable + public TransactionLimit getTransactionLimit() { + return transactionLimit; + } + + /** + * Sets cost, energy, time or SoC limit for a transaction. + * + * @param transactionLimit Cost, energy, time or SoC limit for a transaction + */ + public void setTransactionLimit(@Nullable TransactionLimit transactionLimit) { + if (!isValidTransactionLimit(transactionLimit)) { + throw new PropertyConstraintException(transactionLimit, "transactionLimit is invalid"); + } + this.transactionLimit = transactionLimit; + } + + /** + * Returns whether the given transactionLimit is valid + * + * @param transactionLimit the transactionLimit to check the validity of + * @return {@code true} if transactionLimit is valid, {@code false} if not + */ + private boolean isValidTransactionLimit(@Nullable TransactionLimit transactionLimit) { + return transactionLimit == null || transactionLimit.validate(); + } + + /** + * Adds cost, energy, time or SoC limit for a transaction. + * + * @param transactionLimit Cost, energy, time or SoC limit for a transaction + * @return this + */ + public Transaction withTransactionLimit(@Nullable TransactionLimit transactionLimit) { + setTransactionLimit(transactionLimit); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Transaction withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidTransactionId(transactionId) + && isValidTariffId(tariffId) + && isValidTransactionLimit(transactionLimit) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Transaction that = (Transaction) o; + return Objects.equals(transactionId, that.transactionId) + && Objects.equals(chargingState, that.chargingState) + && Objects.equals(timeSpentCharging, that.timeSpentCharging) + && Objects.equals(stoppedReason, that.stoppedReason) + && Objects.equals(remoteStartId, that.remoteStartId) + && Objects.equals(operationMode, that.operationMode) + && Objects.equals(tariffId, that.tariffId) + && Objects.equals(transactionLimit, that.transactionLimit) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + transactionId, + chargingState, + timeSpentCharging, + stoppedReason, + remoteStartId, + operationMode, + tariffId, + transactionLimit, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("transactionId", transactionId) + .add("chargingState", chargingState) + .add("timeSpentCharging", timeSpentCharging) + .add("stoppedReason", stoppedReason) + .add("remoteStartId", remoteStartId) + .add("operationMode", operationMode) + .add("tariffId", tariffId) + .add("transactionLimit", transactionLimit) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TransactionEventEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TransactionEventEnum.java new file mode 100644 index 00000000..eb70b44f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TransactionEventEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** + * The type of this event. The first TransactionEvent of a transaction SHALL contain: "Started" The + * last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL contain: "Updated" + */ +public enum TransactionEventEnum { + Ended, + Started, + Updated +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TransactionLimit.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TransactionLimit.java new file mode 100644 index 00000000..daeef11a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TransactionLimit.java @@ -0,0 +1,264 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Cost, energy, time or SoC limit for a transaction. */ +public final class TransactionLimit { + /** Maximum allowed cost of transaction in currency of tariff. */ + @Nullable private Double maxCost; + + /** Maximum allowed energy in Wh to charge in transaction. */ + @Nullable private Double maxEnergy; + + /** Maximum duration of transaction in seconds from start to end. */ + @Nullable private Integer maxTime; + + /** Maximum State of Charge of EV in percentage. */ + @Nullable private Integer maxSoC; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the TransactionLimit class */ + public TransactionLimit() {} + + /** + * Gets maximum allowed cost of transaction in currency of tariff. + * + * @return Maximum allowed cost of transaction in currency of tariff + */ + @Nullable + public Double getMaxCost() { + return maxCost; + } + + /** + * Sets maximum allowed cost of transaction in currency of tariff. + * + * @param maxCost Maximum allowed cost of transaction in currency of tariff + */ + public void setMaxCost(@Nullable Double maxCost) { + this.maxCost = maxCost; + } + + /** + * Adds maximum allowed cost of transaction in currency of tariff. + * + * @param maxCost Maximum allowed cost of transaction in currency of tariff + * @return this + */ + public TransactionLimit withMaxCost(@Nullable Double maxCost) { + setMaxCost(maxCost); + return this; + } + + /** + * Gets maximum allowed energy in Wh to charge in transaction. + * + * @return Maximum allowed energy in Wh to charge in transaction + */ + @Nullable + public Double getMaxEnergy() { + return maxEnergy; + } + + /** + * Sets maximum allowed energy in Wh to charge in transaction. + * + * @param maxEnergy Maximum allowed energy in Wh to charge in transaction + */ + public void setMaxEnergy(@Nullable Double maxEnergy) { + this.maxEnergy = maxEnergy; + } + + /** + * Adds maximum allowed energy in Wh to charge in transaction. + * + * @param maxEnergy Maximum allowed energy in Wh to charge in transaction + * @return this + */ + public TransactionLimit withMaxEnergy(@Nullable Double maxEnergy) { + setMaxEnergy(maxEnergy); + return this; + } + + /** + * Gets maximum duration of transaction in seconds from start to end. + * + * @return Maximum duration of transaction in seconds from start to end + */ + @Nullable + public Integer getMaxTime() { + return maxTime; + } + + /** + * Sets maximum duration of transaction in seconds from start to end. + * + * @param maxTime Maximum duration of transaction in seconds from start to end + */ + public void setMaxTime(@Nullable Integer maxTime) { + this.maxTime = maxTime; + } + + /** + * Adds maximum duration of transaction in seconds from start to end. + * + * @param maxTime Maximum duration of transaction in seconds from start to end + * @return this + */ + public TransactionLimit withMaxTime(@Nullable Integer maxTime) { + setMaxTime(maxTime); + return this; + } + + /** + * Gets maximum State of Charge of EV in percentage. + * + * @return Maximum State of Charge of EV in percentage + */ + @Nullable + public Integer getMaxSoC() { + return maxSoC; + } + + /** + * Sets maximum State of Charge of EV in percentage. + * + * @param maxSoC Maximum State of Charge of EV in percentage + */ + public void setMaxSoC(@Nullable Integer maxSoC) { + if (!isValidMaxSoC(maxSoC)) { + throw new PropertyConstraintException(maxSoC, "maxSoC is invalid"); + } + this.maxSoC = maxSoC; + } + + /** + * Returns whether the given maxSoC is valid + * + * @param maxSoC the maxSoC to check the validity of + * @return {@code true} if maxSoC is valid, {@code false} if not + */ + private boolean isValidMaxSoC(@Nullable Integer maxSoC) { + return maxSoC == null || (maxSoC >= 0 && maxSoC <= 100); + } + + /** + * Adds maximum State of Charge of EV in percentage. + * + * @param maxSoC Maximum State of Charge of EV in percentage + * @return this + */ + public TransactionLimit withMaxSoC(@Nullable Integer maxSoC) { + setMaxSoC(maxSoC); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TransactionLimit withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidMaxSoC(maxSoC) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransactionLimit that = (TransactionLimit) o; + return Objects.equals(maxCost, that.maxCost) + && Objects.equals(maxEnergy, that.maxEnergy) + && Objects.equals(maxTime, that.maxTime) + && Objects.equals(maxSoC, that.maxSoC) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(maxCost, maxEnergy, maxTime, maxSoC, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("maxCost", maxCost) + .add("maxEnergy", maxEnergy) + .add("maxTime", maxTime) + .add("maxSoC", maxSoC) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TriggerMessageStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TriggerMessageStatusEnum.java new file mode 100644 index 00000000..ee3a2741 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TriggerMessageStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Charging Station will send the requested notification or not. */ +public enum TriggerMessageStatusEnum { + Accepted, + Rejected, + NotImplemented +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TriggerReasonEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TriggerReasonEnum.java new file mode 100644 index 00000000..4c2d7678 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/TriggerReasonEnum.java @@ -0,0 +1,58 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Reason the Charging Station sends this message to the CSMS */ +public enum TriggerReasonEnum { + AbnormalCondition, + Authorized, + CablePluggedIn, + ChargingRateChanged, + ChargingStateChanged, + CostLimitReached, + Deauthorized, + EnergyLimitReached, + EVCommunicationLost, + EVConnectTimeout, + EVDeparted, + EVDetected, + LimitSet, + MeterValueClock, + MeterValuePeriodic, + OperationModeChanged, + RemoteStart, + RemoteStop, + ResetCommand, + RunningCost, + SignedDataReceived, + SoCLimitReached, + StopAuthorized, + TariffChanged, + TariffNotAccepted, + TimeLimitReached, + Trigger, + TxResumed, + UnlockCommand +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnitOfMeasure.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnitOfMeasure.java new file mode 100644 index 00000000..bf2e37a8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnitOfMeasure.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A UnitOfMeasure with a multiplier */ +public final class UnitOfMeasure { + /** + * Unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. This field + * SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. If an + * applicable unit is available in that list, otherwise a "custom" unit might be used. + */ + @Nullable private String unit; + + /** + * Multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 raised to + * the 3rd power. Default is 0. + * + *

The multiplier only multiplies the value of the measurand. It does not specify a conversion + * between units, for example, kW and W. + */ + @Nullable private Integer multiplier; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the UnitOfMeasure class */ + public UnitOfMeasure() {} + + /** + * Gets unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. This + * field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. + * If an applicable unit is available in that list, otherwise a "custom" unit might be used. + * + * @return Unit of the value + */ + public String getUnit() { + return unit != null ? unit : "Wh"; + } + + /** + * Sets unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. This + * field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. + * If an applicable unit is available in that list, otherwise a "custom" unit might be used. + * + * @param unit Unit of the value + */ + public void setUnit(@Nullable String unit) { + if (!isValidUnit(unit)) { + throw new PropertyConstraintException(unit, "unit is invalid"); + } + this.unit = unit; + } + + /** + * Returns whether the given unit is valid + * + * @param unit the unit to check the validity of + * @return {@code true} if unit is valid, {@code false} if not + */ + private boolean isValidUnit(@Nullable String unit) { + return unit == null || unit.length() <= 20; + } + + /** + * Adds unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. This + * field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. + * If an applicable unit is available in that list, otherwise a "custom" unit might be used. + * + * @param unit Unit of the value + * @return this + */ + public UnitOfMeasure withUnit(@Nullable String unit) { + setUnit(unit); + return this; + } + + /** + * Gets multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 + * raised to the 3rd power. Default is 0. + * + * @return Multiplier, this value represents the exponent to base 10 + */ + public Integer getMultiplier() { + return multiplier != null ? multiplier : 0; + } + + /** + * Sets multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 + * raised to the 3rd power. Default is 0. + * + * @param multiplier Multiplier, this value represents the exponent to base 10 + */ + public void setMultiplier(@Nullable Integer multiplier) { + this.multiplier = multiplier; + } + + /** + * Adds multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 + * raised to the 3rd power. Default is 0. + * + * @param multiplier Multiplier, this value represents the exponent to base 10 + * @return this + */ + public UnitOfMeasure withMultiplier(@Nullable Integer multiplier) { + setMultiplier(multiplier); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnitOfMeasure withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidUnit(unit) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnitOfMeasure that = (UnitOfMeasure) o; + return Objects.equals(unit, that.unit) + && Objects.equals(multiplier, that.multiplier) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(unit, multiplier, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("unit", unit) + .add("multiplier", multiplier) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnlockStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnlockStatusEnum.java new file mode 100644 index 00000000..48b772d5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnlockStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Charging Station has unlocked the connector. */ +public enum UnlockStatusEnum { + Unlocked, + UnlockFailed, + OngoingAuthorizedTransaction, + UnknownConnector +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnpublishFirmwareStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnpublishFirmwareStatusEnum.java new file mode 100644 index 00000000..143e3cf7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UnpublishFirmwareStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Whether the Local Controller succeeded in unpublishing the firmware. */ +public enum UnpublishFirmwareStatusEnum { + DownloadOngoing, + NoFirmware, + Unpublished +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UpdateEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UpdateEnum.java new file mode 100644 index 00000000..0bf0defc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UpdateEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The type of update (full or differential) of this request. */ +public enum UpdateEnum { + Differential, + Full +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UpdateFirmwareStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UpdateFirmwareStatusEnum.java new file mode 100644 index 00000000..b349c389 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UpdateFirmwareStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** This field indicates whether the Charging Station was able to accept the request. */ +public enum UpdateFirmwareStatusEnum { + Accepted, + Rejected, + AcceptedCanceled, + InvalidCertificate, + RevokedCertificate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UploadLogStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UploadLogStatusEnum.java new file mode 100644 index 00000000..f80d480b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/UploadLogStatusEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** The status of the log upload. */ +public enum UploadLogStatusEnum { + BadMessage, + Idle, + NotSupportedOperation, + PermissionDenied, + Uploaded, + UploadFailure, + Uploading, + AcceptedCanceled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XChargingParameters.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XChargingParameters.java new file mode 100644 index 00000000..4f234feb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XChargingParameters.java @@ -0,0 +1,1213 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charging parameters for ISO 15118-20, also supporting V2X charging/discharging.+ All values are + * greater or equal to zero, with the exception of EVMinEnergyRequest, EVMaxEnergyRequest, + * EVTargetEnergyRequest, EVMinV2XEnergyRequest and EVMaxV2XEnergyRequest. + */ +public final class V2XChargingParameters { + /** + * Minimum charge power in W, defined by max(EV, EVSE). This field represents the sum of all + * phases, unless values are provided for L2 and L3, in which case this field represents phase L1. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePower + */ + @Nullable private Double minChargePower; + + /** + * Minimum charge power on phase L2 in W, defined by max(EV, EVSE). Relates to: *ISO 15118-20*: + * BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePowerL2 + */ + @Nullable private Double minChargePower_L2; + + /** + * Minimum charge power on phase L3 in W, defined by max(EV, EVSE). Relates to: *ISO 15118-20*: + * BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePowerL3 + */ + @Nullable private Double minChargePower_L3; + + /** + * Maximum charge (absorbed) power in W, defined by min(EV, EVSE) at unity power factor. + * + *

This field represents the sum of all phases, unless values are provided for L2 and L3, in + * which case this field represents phase L1. It corresponds to the ChaWMax attribute in the IEC + * 61850. + * + *

+   * It is usually equivalent to the rated apparent power of the EV when discharging (ChaVAMax) in
+   * IEC 61850.
+   *
+   * 
+ * + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePower + */ + @Nullable private Double maxChargePower; + + /** + * Maximum charge power on phase L2 in W, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL2 + */ + @Nullable private Double maxChargePower_L2; + + /** + * Maximum charge power on phase L3 in W, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL3 + */ + @Nullable private Double maxChargePower_L3; + + /** + * Minimum discharge (injected) power in W, defined by max(EV, EVSE) at unity power factor. Value + * non-negative. + * + *
+   * This field represents the sum of all phases, unless values are provided for L2 and L3, in which
+   * case this field represents phase L1.
+   * It corresponds to the WMax attribute in the IEC 61850.
+   * 
+ * + * It is usually equivalent to the rated apparent power of the EV when discharging (VAMax + * attribute in the IEC 61850). + * + *

Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePower + */ + @Nullable private Double minDischargePower; + + /** + * Minimum discharge power on phase L2 in W, defined by max(EV, EVSE). Value non-negative. Relates + * to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePowerL2 + */ + @Nullable private Double minDischargePower_L2; + + /** + * Minimum discharge power on phase L3 in W, defined by max(EV, EVSE). Value non-negative. Relates + * to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePowerL3 + */ + @Nullable private Double minDischargePower_L3; + + /** + * Maximum discharge (injected) power in W, defined by min(EV, EVSE) at unity power factor. Value + * non-negative. This field represents the sum of all phases, unless values are provided for L2 + * and L3, in which case this field represents phase L1. Relates to: *ISO 15118-20*: + * BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePower + */ + @Nullable private Double maxDischargePower; + + /** + * Maximum discharge power on phase L2 in W, defined by min(EV, EVSE). Value non-negative. Relates + * to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePoweL2 + */ + @Nullable private Double maxDischargePower_L2; + + /** + * Maximum discharge power on phase L3 in W, defined by min(EV, EVSE). Value non-negative. Relates + * to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePowerL3 + */ + @Nullable private Double maxDischargePower_L3; + + /** + * Minimum charge current in A, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumChargeCurrent + */ + @Nullable private Double minChargeCurrent; + + /** + * Maximum charge current in A, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumChargeCurrent + */ + @Nullable private Double maxChargeCurrent; + + /** + * Minimum discharge current in A, defined by max(EV, EVSE). Value non-negative. Relates to: *ISO + * 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMinimumDischargeCurrent + */ + @Nullable private Double minDischargeCurrent; + + /** + * Maximum discharge current in A, defined by min(EV, EVSE). Value non-negative. Relates to: *ISO + * 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMaximumDischargeCurrent + */ + @Nullable private Double maxDischargeCurrent; + + /** + * Minimum voltage in V, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumVoltage + */ + @Nullable private Double minVoltage; + + /** + * Maximum voltage in V, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumVoltage + */ + @Nullable private Double maxVoltage; + + /** + * Energy to requested state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVTargetEnergyRequest + */ + @Nullable private Double evTargetEnergyRequest; + + /** + * Energy to minimum allowed state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMinimumEnergyRequest + */ + @Nullable private Double evMinEnergyRequest; + + /** + * Energy to maximum state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMaximumEnergyRequest + */ + @Nullable private Double evMaxEnergyRequest; + + /** + * Energy (in Wh) to minimum state of charge for cycling (V2X) activity. Positive value means that + * current state of charge is below V2X range. Relates to: *ISO 15118-20*: + * DynamicSEReqControlModeType: EVMinimumV2XEnergyRequest + */ + @Nullable private Double evMinV2XEnergyRequest; + + /** + * Energy (in Wh) to maximum state of charge for cycling (V2X) activity. Negative value indicates + * that current state of charge is above V2X range. Relates to: *ISO 15118-20*: + * DynamicSEReqControlModeType: EVMaximumV2XEnergyRequest + */ + @Nullable private Double evMaxV2XEnergyRequest; + + /** + * Target state of charge at departure as percentage. Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: TargetSOC + */ + @Nullable private Integer targetSoC; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the V2XChargingParameters class */ + public V2XChargingParameters() {} + + /** + * Gets minimum charge power in W, defined by max(EV, EVSE). This field represents the sum of all + * phases, unless values are provided for L2 and L3, in which case this field represents phase L1. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePower + * + * @return Minimum charge power in W, defined by max(EV, EVSE) + */ + @Nullable + public Double getMinChargePower() { + return minChargePower; + } + + /** + * Sets minimum charge power in W, defined by max(EV, EVSE). This field represents the sum of all + * phases, unless values are provided for L2 and L3, in which case this field represents phase L1. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePower + * + * @param minChargePower Minimum charge power in W, defined by max(EV, EVSE) + */ + public void setMinChargePower(@Nullable Double minChargePower) { + this.minChargePower = minChargePower; + } + + /** + * Adds minimum charge power in W, defined by max(EV, EVSE). This field represents the sum of all + * phases, unless values are provided for L2 and L3, in which case this field represents phase L1. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePower + * + * @param minChargePower Minimum charge power in W, defined by max(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMinChargePower(@Nullable Double minChargePower) { + setMinChargePower(minChargePower); + return this; + } + + /** + * Gets minimum charge power on phase L2 in W, defined by max(EV, EVSE). Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePowerL2 + * + * @return Minimum charge power on phase L2 in W, defined by max(EV, EVSE) + */ + @Nullable + public Double getMinChargePower_L2() { + return minChargePower_L2; + } + + /** + * Sets minimum charge power on phase L2 in W, defined by max(EV, EVSE). Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePowerL2 + * + * @param minChargePower_L2 Minimum charge power on phase L2 in W, defined by max(EV, EVSE) + */ + public void setMinChargePower_L2(@Nullable Double minChargePower_L2) { + this.minChargePower_L2 = minChargePower_L2; + } + + /** + * Adds minimum charge power on phase L2 in W, defined by max(EV, EVSE). Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePowerL2 + * + * @param minChargePower_L2 Minimum charge power on phase L2 in W, defined by max(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMinChargePower_L2(@Nullable Double minChargePower_L2) { + setMinChargePower_L2(minChargePower_L2); + return this; + } + + /** + * Gets minimum charge power on phase L3 in W, defined by max(EV, EVSE). Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePowerL3 + * + * @return Minimum charge power on phase L3 in W, defined by max(EV, EVSE) + */ + @Nullable + public Double getMinChargePower_L3() { + return minChargePower_L3; + } + + /** + * Sets minimum charge power on phase L3 in W, defined by max(EV, EVSE). Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePowerL3 + * + * @param minChargePower_L3 Minimum charge power on phase L3 in W, defined by max(EV, EVSE) + */ + public void setMinChargePower_L3(@Nullable Double minChargePower_L3) { + this.minChargePower_L3 = minChargePower_L3; + } + + /** + * Adds minimum charge power on phase L3 in W, defined by max(EV, EVSE). Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumChargePowerL3 + * + * @param minChargePower_L3 Minimum charge power on phase L3 in W, defined by max(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMinChargePower_L3(@Nullable Double minChargePower_L3) { + setMinChargePower_L3(minChargePower_L3); + return this; + } + + /** + * Gets maximum charge (absorbed) power in W, defined by min(EV, EVSE) at unity power factor. + * + * @return Maximum charge (absorbed) power in W, defined by min(EV, EVSE) at unity power factor + */ + @Nullable + public Double getMaxChargePower() { + return maxChargePower; + } + + /** + * Sets maximum charge (absorbed) power in W, defined by min(EV, EVSE) at unity power factor. + * + * @param maxChargePower Maximum charge (absorbed) power in W, defined by min(EV, EVSE) at unity + * power factor + */ + public void setMaxChargePower(@Nullable Double maxChargePower) { + this.maxChargePower = maxChargePower; + } + + /** + * Adds maximum charge (absorbed) power in W, defined by min(EV, EVSE) at unity power factor. + * + * @param maxChargePower Maximum charge (absorbed) power in W, defined by min(EV, EVSE) at unity + * power factor + * @return this + */ + public V2XChargingParameters withMaxChargePower(@Nullable Double maxChargePower) { + setMaxChargePower(maxChargePower); + return this; + } + + /** + * Gets maximum charge power on phase L2 in W, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL2 + * + * @return Maximum charge power on phase L2 in W, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL2 + */ + @Nullable + public Double getMaxChargePower_L2() { + return maxChargePower_L2; + } + + /** + * Sets maximum charge power on phase L2 in W, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL2 + * + * @param maxChargePower_L2 Maximum charge power on phase L2 in W, defined by min(EV, EVSE) + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL2 + */ + public void setMaxChargePower_L2(@Nullable Double maxChargePower_L2) { + this.maxChargePower_L2 = maxChargePower_L2; + } + + /** + * Adds maximum charge power on phase L2 in W, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL2 + * + * @param maxChargePower_L2 Maximum charge power on phase L2 in W, defined by min(EV, EVSE) + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL2 + * @return this + */ + public V2XChargingParameters withMaxChargePower_L2(@Nullable Double maxChargePower_L2) { + setMaxChargePower_L2(maxChargePower_L2); + return this; + } + + /** + * Gets maximum charge power on phase L3 in W, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL3 + * + * @return Maximum charge power on phase L3 in W, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL3 + */ + @Nullable + public Double getMaxChargePower_L3() { + return maxChargePower_L3; + } + + /** + * Sets maximum charge power on phase L3 in W, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL3 + * + * @param maxChargePower_L3 Maximum charge power on phase L3 in W, defined by min(EV, EVSE) + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL3 + */ + public void setMaxChargePower_L3(@Nullable Double maxChargePower_L3) { + this.maxChargePower_L3 = maxChargePower_L3; + } + + /** + * Adds maximum charge power on phase L3 in W, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL3 + * + * @param maxChargePower_L3 Maximum charge power on phase L3 in W, defined by min(EV, EVSE) + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumChargePowerL3 + * @return this + */ + public V2XChargingParameters withMaxChargePower_L3(@Nullable Double maxChargePower_L3) { + setMaxChargePower_L3(maxChargePower_L3); + return this; + } + + /** + * Gets minimum discharge (injected) power in W, defined by max(EV, EVSE) at unity power factor. + * Value non-negative. + * + * @return Minimum discharge (injected) power in W, defined by max(EV, EVSE) at unity power factor + */ + @Nullable + public Double getMinDischargePower() { + return minDischargePower; + } + + /** + * Sets minimum discharge (injected) power in W, defined by max(EV, EVSE) at unity power factor. + * Value non-negative. + * + * @param minDischargePower Minimum discharge (injected) power in W, defined by max(EV, EVSE) at + * unity power factor + */ + public void setMinDischargePower(@Nullable Double minDischargePower) { + this.minDischargePower = minDischargePower; + } + + /** + * Adds minimum discharge (injected) power in W, defined by max(EV, EVSE) at unity power factor. + * Value non-negative. + * + * @param minDischargePower Minimum discharge (injected) power in W, defined by max(EV, EVSE) at + * unity power factor + * @return this + */ + public V2XChargingParameters withMinDischargePower(@Nullable Double minDischargePower) { + setMinDischargePower(minDischargePower); + return this; + } + + /** + * Gets minimum discharge power on phase L2 in W, defined by max(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePowerL2 + * + * @return Minimum discharge power on phase L2 in W, defined by max(EV, EVSE) + */ + @Nullable + public Double getMinDischargePower_L2() { + return minDischargePower_L2; + } + + /** + * Sets minimum discharge power on phase L2 in W, defined by max(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePowerL2 + * + * @param minDischargePower_L2 Minimum discharge power on phase L2 in W, defined by max(EV, EVSE) + */ + public void setMinDischargePower_L2(@Nullable Double minDischargePower_L2) { + this.minDischargePower_L2 = minDischargePower_L2; + } + + /** + * Adds minimum discharge power on phase L2 in W, defined by max(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePowerL2 + * + * @param minDischargePower_L2 Minimum discharge power on phase L2 in W, defined by max(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMinDischargePower_L2(@Nullable Double minDischargePower_L2) { + setMinDischargePower_L2(minDischargePower_L2); + return this; + } + + /** + * Gets minimum discharge power on phase L3 in W, defined by max(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePowerL3 + * + * @return Minimum discharge power on phase L3 in W, defined by max(EV, EVSE) + */ + @Nullable + public Double getMinDischargePower_L3() { + return minDischargePower_L3; + } + + /** + * Sets minimum discharge power on phase L3 in W, defined by max(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePowerL3 + * + * @param minDischargePower_L3 Minimum discharge power on phase L3 in W, defined by max(EV, EVSE) + */ + public void setMinDischargePower_L3(@Nullable Double minDischargePower_L3) { + this.minDischargePower_L3 = minDischargePower_L3; + } + + /** + * Adds minimum discharge power on phase L3 in W, defined by max(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMinimumDischargePowerL3 + * + * @param minDischargePower_L3 Minimum discharge power on phase L3 in W, defined by max(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMinDischargePower_L3(@Nullable Double minDischargePower_L3) { + setMinDischargePower_L3(minDischargePower_L3); + return this; + } + + /** + * Gets maximum discharge (injected) power in W, defined by min(EV, EVSE) at unity power factor. + * Value non-negative. This field represents the sum of all phases, unless values are provided for + * L2 and L3, in which case this field represents phase L1. Relates to: *ISO 15118-20*: + * BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePower + * + * @return Maximum discharge (injected) power in W, defined by min(EV, EVSE) at unity power factor + */ + @Nullable + public Double getMaxDischargePower() { + return maxDischargePower; + } + + /** + * Sets maximum discharge (injected) power in W, defined by min(EV, EVSE) at unity power factor. + * Value non-negative. This field represents the sum of all phases, unless values are provided for + * L2 and L3, in which case this field represents phase L1. Relates to: *ISO 15118-20*: + * BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePower + * + * @param maxDischargePower Maximum discharge (injected) power in W, defined by min(EV, EVSE) at + * unity power factor + */ + public void setMaxDischargePower(@Nullable Double maxDischargePower) { + this.maxDischargePower = maxDischargePower; + } + + /** + * Adds maximum discharge (injected) power in W, defined by min(EV, EVSE) at unity power factor. + * Value non-negative. This field represents the sum of all phases, unless values are provided for + * L2 and L3, in which case this field represents phase L1. Relates to: *ISO 15118-20*: + * BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePower + * + * @param maxDischargePower Maximum discharge (injected) power in W, defined by min(EV, EVSE) at + * unity power factor + * @return this + */ + public V2XChargingParameters withMaxDischargePower(@Nullable Double maxDischargePower) { + setMaxDischargePower(maxDischargePower); + return this; + } + + /** + * Gets maximum discharge power on phase L2 in W, defined by min(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePoweL2 + * + * @return Maximum discharge power on phase L2 in W, defined by min(EV, EVSE) + */ + @Nullable + public Double getMaxDischargePower_L2() { + return maxDischargePower_L2; + } + + /** + * Sets maximum discharge power on phase L2 in W, defined by min(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePoweL2 + * + * @param maxDischargePower_L2 Maximum discharge power on phase L2 in W, defined by min(EV, EVSE) + */ + public void setMaxDischargePower_L2(@Nullable Double maxDischargePower_L2) { + this.maxDischargePower_L2 = maxDischargePower_L2; + } + + /** + * Adds maximum discharge power on phase L2 in W, defined by min(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePoweL2 + * + * @param maxDischargePower_L2 Maximum discharge power on phase L2 in W, defined by min(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMaxDischargePower_L2(@Nullable Double maxDischargePower_L2) { + setMaxDischargePower_L2(maxDischargePower_L2); + return this; + } + + /** + * Gets maximum discharge power on phase L3 in W, defined by min(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePowerL3 + * + * @return Maximum discharge power on phase L3 in W, defined by min(EV, EVSE) + */ + @Nullable + public Double getMaxDischargePower_L3() { + return maxDischargePower_L3; + } + + /** + * Sets maximum discharge power on phase L3 in W, defined by min(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePowerL3 + * + * @param maxDischargePower_L3 Maximum discharge power on phase L3 in W, defined by min(EV, EVSE) + */ + public void setMaxDischargePower_L3(@Nullable Double maxDischargePower_L3) { + this.maxDischargePower_L3 = maxDischargePower_L3; + } + + /** + * Adds maximum discharge power on phase L3 in W, defined by min(EV, EVSE). Value non-negative. + * Relates to: *ISO 15118-20*: BPTAC/DCCPDReqEnergyTransferModeType: EVMaximumDischargePowerL3 + * + * @param maxDischargePower_L3 Maximum discharge power on phase L3 in W, defined by min(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMaxDischargePower_L3(@Nullable Double maxDischargePower_L3) { + setMaxDischargePower_L3(maxDischargePower_L3); + return this; + } + + /** + * Gets minimum charge current in A, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumChargeCurrent + * + * @return Minimum charge current in A, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumChargeCurrent + */ + @Nullable + public Double getMinChargeCurrent() { + return minChargeCurrent; + } + + /** + * Sets minimum charge current in A, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumChargeCurrent + * + * @param minChargeCurrent Minimum charge current in A, defined by max(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMinimumChargeCurrent + */ + public void setMinChargeCurrent(@Nullable Double minChargeCurrent) { + this.minChargeCurrent = minChargeCurrent; + } + + /** + * Adds minimum charge current in A, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumChargeCurrent + * + * @param minChargeCurrent Minimum charge current in A, defined by max(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMinimumChargeCurrent + * @return this + */ + public V2XChargingParameters withMinChargeCurrent(@Nullable Double minChargeCurrent) { + setMinChargeCurrent(minChargeCurrent); + return this; + } + + /** + * Gets maximum charge current in A, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumChargeCurrent + * + * @return Maximum charge current in A, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumChargeCurrent + */ + @Nullable + public Double getMaxChargeCurrent() { + return maxChargeCurrent; + } + + /** + * Sets maximum charge current in A, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumChargeCurrent + * + * @param maxChargeCurrent Maximum charge current in A, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMaximumChargeCurrent + */ + public void setMaxChargeCurrent(@Nullable Double maxChargeCurrent) { + this.maxChargeCurrent = maxChargeCurrent; + } + + /** + * Adds maximum charge current in A, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumChargeCurrent + * + * @param maxChargeCurrent Maximum charge current in A, defined by min(EV, EVSE) Relates to: *ISO + * 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMaximumChargeCurrent + * @return this + */ + public V2XChargingParameters withMaxChargeCurrent(@Nullable Double maxChargeCurrent) { + setMaxChargeCurrent(maxChargeCurrent); + return this; + } + + /** + * Gets minimum discharge current in A, defined by max(EV, EVSE). Value non-negative. Relates to: + * *ISO 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMinimumDischargeCurrent + * + * @return Minimum discharge current in A, defined by max(EV, EVSE) + */ + @Nullable + public Double getMinDischargeCurrent() { + return minDischargeCurrent; + } + + /** + * Sets minimum discharge current in A, defined by max(EV, EVSE). Value non-negative. Relates to: + * *ISO 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMinimumDischargeCurrent + * + * @param minDischargeCurrent Minimum discharge current in A, defined by max(EV, EVSE) + */ + public void setMinDischargeCurrent(@Nullable Double minDischargeCurrent) { + this.minDischargeCurrent = minDischargeCurrent; + } + + /** + * Adds minimum discharge current in A, defined by max(EV, EVSE). Value non-negative. Relates to: + * *ISO 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMinimumDischargeCurrent + * + * @param minDischargeCurrent Minimum discharge current in A, defined by max(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMinDischargeCurrent(@Nullable Double minDischargeCurrent) { + setMinDischargeCurrent(minDischargeCurrent); + return this; + } + + /** + * Gets maximum discharge current in A, defined by min(EV, EVSE). Value non-negative. Relates to: + * *ISO 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMaximumDischargeCurrent + * + * @return Maximum discharge current in A, defined by min(EV, EVSE) + */ + @Nullable + public Double getMaxDischargeCurrent() { + return maxDischargeCurrent; + } + + /** + * Sets maximum discharge current in A, defined by min(EV, EVSE). Value non-negative. Relates to: + * *ISO 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMaximumDischargeCurrent + * + * @param maxDischargeCurrent Maximum discharge current in A, defined by min(EV, EVSE) + */ + public void setMaxDischargeCurrent(@Nullable Double maxDischargeCurrent) { + this.maxDischargeCurrent = maxDischargeCurrent; + } + + /** + * Adds maximum discharge current in A, defined by min(EV, EVSE). Value non-negative. Relates to: + * *ISO 15118-20*: BPTDCCPDReqEnergyTransferModeType: EVMaximumDischargeCurrent + * + * @param maxDischargeCurrent Maximum discharge current in A, defined by min(EV, EVSE) + * @return this + */ + public V2XChargingParameters withMaxDischargeCurrent(@Nullable Double maxDischargeCurrent) { + setMaxDischargeCurrent(maxDischargeCurrent); + return this; + } + + /** + * Gets minimum voltage in V, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumVoltage + * + * @return Minimum voltage in V, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumVoltage + */ + @Nullable + public Double getMinVoltage() { + return minVoltage; + } + + /** + * Sets minimum voltage in V, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumVoltage + * + * @param minVoltage Minimum voltage in V, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumVoltage + */ + public void setMinVoltage(@Nullable Double minVoltage) { + this.minVoltage = minVoltage; + } + + /** + * Adds minimum voltage in V, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumVoltage + * + * @param minVoltage Minimum voltage in V, defined by max(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMinimumVoltage + * @return this + */ + public V2XChargingParameters withMinVoltage(@Nullable Double minVoltage) { + setMinVoltage(minVoltage); + return this; + } + + /** + * Gets maximum voltage in V, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumVoltage + * + * @return Maximum voltage in V, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumVoltage + */ + @Nullable + public Double getMaxVoltage() { + return maxVoltage; + } + + /** + * Sets maximum voltage in V, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumVoltage + * + * @param maxVoltage Maximum voltage in V, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumVoltage + */ + public void setMaxVoltage(@Nullable Double maxVoltage) { + this.maxVoltage = maxVoltage; + } + + /** + * Adds maximum voltage in V, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumVoltage + * + * @param maxVoltage Maximum voltage in V, defined by min(EV, EVSE) Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: EVMaximumVoltage + * @return this + */ + public V2XChargingParameters withMaxVoltage(@Nullable Double maxVoltage) { + setMaxVoltage(maxVoltage); + return this; + } + + /** + * Gets energy to requested state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVTargetEnergyRequest + * + * @return Energy to requested state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVTargetEnergyRequest + */ + @Nullable + public Double getEvTargetEnergyRequest() { + return evTargetEnergyRequest; + } + + /** + * Sets energy to requested state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVTargetEnergyRequest + * + * @param evTargetEnergyRequest Energy to requested state of charge in Wh Relates to: *ISO + * 15118-20*: Dynamic/ScheduledSEReqControlModeType: EVTargetEnergyRequest + */ + public void setEvTargetEnergyRequest(@Nullable Double evTargetEnergyRequest) { + this.evTargetEnergyRequest = evTargetEnergyRequest; + } + + /** + * Adds energy to requested state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVTargetEnergyRequest + * + * @param evTargetEnergyRequest Energy to requested state of charge in Wh Relates to: *ISO + * 15118-20*: Dynamic/ScheduledSEReqControlModeType: EVTargetEnergyRequest + * @return this + */ + public V2XChargingParameters withEvTargetEnergyRequest(@Nullable Double evTargetEnergyRequest) { + setEvTargetEnergyRequest(evTargetEnergyRequest); + return this; + } + + /** + * Gets energy to minimum allowed state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMinimumEnergyRequest + * + * @return Energy to minimum allowed state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMinimumEnergyRequest + */ + @Nullable + public Double getEvMinEnergyRequest() { + return evMinEnergyRequest; + } + + /** + * Sets energy to minimum allowed state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMinimumEnergyRequest + * + * @param evMinEnergyRequest Energy to minimum allowed state of charge in Wh Relates to: *ISO + * 15118-20*: Dynamic/ScheduledSEReqControlModeType: EVMinimumEnergyRequest + */ + public void setEvMinEnergyRequest(@Nullable Double evMinEnergyRequest) { + this.evMinEnergyRequest = evMinEnergyRequest; + } + + /** + * Adds energy to minimum allowed state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMinimumEnergyRequest + * + * @param evMinEnergyRequest Energy to minimum allowed state of charge in Wh Relates to: *ISO + * 15118-20*: Dynamic/ScheduledSEReqControlModeType: EVMinimumEnergyRequest + * @return this + */ + public V2XChargingParameters withEvMinEnergyRequest(@Nullable Double evMinEnergyRequest) { + setEvMinEnergyRequest(evMinEnergyRequest); + return this; + } + + /** + * Gets energy to maximum state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMaximumEnergyRequest + * + * @return Energy to maximum state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMaximumEnergyRequest + */ + @Nullable + public Double getEvMaxEnergyRequest() { + return evMaxEnergyRequest; + } + + /** + * Sets energy to maximum state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMaximumEnergyRequest + * + * @param evMaxEnergyRequest Energy to maximum state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMaximumEnergyRequest + */ + public void setEvMaxEnergyRequest(@Nullable Double evMaxEnergyRequest) { + this.evMaxEnergyRequest = evMaxEnergyRequest; + } + + /** + * Adds energy to maximum state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMaximumEnergyRequest + * + * @param evMaxEnergyRequest Energy to maximum state of charge in Wh Relates to: *ISO 15118-20*: + * Dynamic/ScheduledSEReqControlModeType: EVMaximumEnergyRequest + * @return this + */ + public V2XChargingParameters withEvMaxEnergyRequest(@Nullable Double evMaxEnergyRequest) { + setEvMaxEnergyRequest(evMaxEnergyRequest); + return this; + } + + /** + * Gets energy (in Wh) to minimum state of charge for cycling (V2X) activity. Positive value means + * that current state of charge is below V2X range. Relates to: *ISO 15118-20*: + * DynamicSEReqControlModeType: EVMinimumV2XEnergyRequest + * + * @return Energy (in Wh) to minimum state of charge for cycling (V2X) activity + */ + @Nullable + public Double getEvMinV2XEnergyRequest() { + return evMinV2XEnergyRequest; + } + + /** + * Sets energy (in Wh) to minimum state of charge for cycling (V2X) activity. Positive value means + * that current state of charge is below V2X range. Relates to: *ISO 15118-20*: + * DynamicSEReqControlModeType: EVMinimumV2XEnergyRequest + * + * @param evMinV2XEnergyRequest Energy (in Wh) to minimum state of charge for cycling (V2X) + * activity + */ + public void setEvMinV2XEnergyRequest(@Nullable Double evMinV2XEnergyRequest) { + this.evMinV2XEnergyRequest = evMinV2XEnergyRequest; + } + + /** + * Adds energy (in Wh) to minimum state of charge for cycling (V2X) activity. Positive value means + * that current state of charge is below V2X range. Relates to: *ISO 15118-20*: + * DynamicSEReqControlModeType: EVMinimumV2XEnergyRequest + * + * @param evMinV2XEnergyRequest Energy (in Wh) to minimum state of charge for cycling (V2X) + * activity + * @return this + */ + public V2XChargingParameters withEvMinV2XEnergyRequest(@Nullable Double evMinV2XEnergyRequest) { + setEvMinV2XEnergyRequest(evMinV2XEnergyRequest); + return this; + } + + /** + * Gets energy (in Wh) to maximum state of charge for cycling (V2X) activity. Negative value + * indicates that current state of charge is above V2X range. Relates to: *ISO 15118-20*: + * DynamicSEReqControlModeType: EVMaximumV2XEnergyRequest + * + * @return Energy (in Wh) to maximum state of charge for cycling (V2X) activity + */ + @Nullable + public Double getEvMaxV2XEnergyRequest() { + return evMaxV2XEnergyRequest; + } + + /** + * Sets energy (in Wh) to maximum state of charge for cycling (V2X) activity. Negative value + * indicates that current state of charge is above V2X range. Relates to: *ISO 15118-20*: + * DynamicSEReqControlModeType: EVMaximumV2XEnergyRequest + * + * @param evMaxV2XEnergyRequest Energy (in Wh) to maximum state of charge for cycling (V2X) + * activity + */ + public void setEvMaxV2XEnergyRequest(@Nullable Double evMaxV2XEnergyRequest) { + this.evMaxV2XEnergyRequest = evMaxV2XEnergyRequest; + } + + /** + * Adds energy (in Wh) to maximum state of charge for cycling (V2X) activity. Negative value + * indicates that current state of charge is above V2X range. Relates to: *ISO 15118-20*: + * DynamicSEReqControlModeType: EVMaximumV2XEnergyRequest + * + * @param evMaxV2XEnergyRequest Energy (in Wh) to maximum state of charge for cycling (V2X) + * activity + * @return this + */ + public V2XChargingParameters withEvMaxV2XEnergyRequest(@Nullable Double evMaxV2XEnergyRequest) { + setEvMaxV2XEnergyRequest(evMaxV2XEnergyRequest); + return this; + } + + /** + * Gets target state of charge at departure as percentage. Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: TargetSOC + * + * @return Target state of charge at departure as percentage + */ + @Nullable + public Integer getTargetSoC() { + return targetSoC; + } + + /** + * Sets target state of charge at departure as percentage. Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: TargetSOC + * + * @param targetSoC Target state of charge at departure as percentage + */ + public void setTargetSoC(@Nullable Integer targetSoC) { + if (!isValidTargetSoC(targetSoC)) { + throw new PropertyConstraintException(targetSoC, "targetSoC is invalid"); + } + this.targetSoC = targetSoC; + } + + /** + * Returns whether the given targetSoC is valid + * + * @param targetSoC the targetSoC to check the validity of + * @return {@code true} if targetSoC is valid, {@code false} if not + */ + private boolean isValidTargetSoC(@Nullable Integer targetSoC) { + return targetSoC == null || (targetSoC >= 0 && targetSoC <= 100); + } + + /** + * Adds target state of charge at departure as percentage. Relates to: *ISO 15118-20*: + * BPTDCCPDReqEnergyTransferModeType: TargetSOC + * + * @param targetSoC Target state of charge at departure as percentage + * @return this + */ + public V2XChargingParameters withTargetSoC(@Nullable Integer targetSoC) { + setTargetSoC(targetSoC); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public V2XChargingParameters withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidTargetSoC(targetSoC) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V2XChargingParameters that = (V2XChargingParameters) o; + return Objects.equals(minChargePower, that.minChargePower) + && Objects.equals(minChargePower_L2, that.minChargePower_L2) + && Objects.equals(minChargePower_L3, that.minChargePower_L3) + && Objects.equals(maxChargePower, that.maxChargePower) + && Objects.equals(maxChargePower_L2, that.maxChargePower_L2) + && Objects.equals(maxChargePower_L3, that.maxChargePower_L3) + && Objects.equals(minDischargePower, that.minDischargePower) + && Objects.equals(minDischargePower_L2, that.minDischargePower_L2) + && Objects.equals(minDischargePower_L3, that.minDischargePower_L3) + && Objects.equals(maxDischargePower, that.maxDischargePower) + && Objects.equals(maxDischargePower_L2, that.maxDischargePower_L2) + && Objects.equals(maxDischargePower_L3, that.maxDischargePower_L3) + && Objects.equals(minChargeCurrent, that.minChargeCurrent) + && Objects.equals(maxChargeCurrent, that.maxChargeCurrent) + && Objects.equals(minDischargeCurrent, that.minDischargeCurrent) + && Objects.equals(maxDischargeCurrent, that.maxDischargeCurrent) + && Objects.equals(minVoltage, that.minVoltage) + && Objects.equals(maxVoltage, that.maxVoltage) + && Objects.equals(evTargetEnergyRequest, that.evTargetEnergyRequest) + && Objects.equals(evMinEnergyRequest, that.evMinEnergyRequest) + && Objects.equals(evMaxEnergyRequest, that.evMaxEnergyRequest) + && Objects.equals(evMinV2XEnergyRequest, that.evMinV2XEnergyRequest) + && Objects.equals(evMaxV2XEnergyRequest, that.evMaxV2XEnergyRequest) + && Objects.equals(targetSoC, that.targetSoC) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + minChargePower, + minChargePower_L2, + minChargePower_L3, + maxChargePower, + maxChargePower_L2, + maxChargePower_L3, + minDischargePower, + minDischargePower_L2, + minDischargePower_L3, + maxDischargePower, + maxDischargePower_L2, + maxDischargePower_L3, + minChargeCurrent, + maxChargeCurrent, + minDischargeCurrent, + maxDischargeCurrent, + minVoltage, + maxVoltage, + evTargetEnergyRequest, + evMinEnergyRequest, + evMaxEnergyRequest, + evMinV2XEnergyRequest, + evMaxV2XEnergyRequest, + targetSoC, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("minChargePower", minChargePower) + .add("minChargePower_L2", minChargePower_L2) + .add("minChargePower_L3", minChargePower_L3) + .add("maxChargePower", maxChargePower) + .add("maxChargePower_L2", maxChargePower_L2) + .add("maxChargePower_L3", maxChargePower_L3) + .add("minDischargePower", minDischargePower) + .add("minDischargePower_L2", minDischargePower_L2) + .add("minDischargePower_L3", minDischargePower_L3) + .add("maxDischargePower", maxDischargePower) + .add("maxDischargePower_L2", maxDischargePower_L2) + .add("maxDischargePower_L3", maxDischargePower_L3) + .add("minChargeCurrent", minChargeCurrent) + .add("maxChargeCurrent", maxChargeCurrent) + .add("minDischargeCurrent", minDischargeCurrent) + .add("maxDischargeCurrent", maxDischargeCurrent) + .add("minVoltage", minVoltage) + .add("maxVoltage", maxVoltage) + .add("evTargetEnergyRequest", evTargetEnergyRequest) + .add("evMinEnergyRequest", evMinEnergyRequest) + .add("evMaxEnergyRequest", evMaxEnergyRequest) + .add("evMinV2XEnergyRequest", evMinV2XEnergyRequest) + .add("evMaxV2XEnergyRequest", evMaxV2XEnergyRequest) + .add("targetSoC", targetSoC) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XFreqWattPoint.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XFreqWattPoint.java new file mode 100644 index 00000000..e32757da --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XFreqWattPoint.java @@ -0,0 +1,191 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A point of a frequency-watt curve. */ +public final class V2XFreqWattPoint { + /** Net frequency in Hz. */ + private Double frequency; + + /** Power in W to charge (positive) or discharge (negative) at specified frequency. */ + private Double power; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the V2XFreqWattPoint class + * + * @param frequency Net frequency in Hz. + * @param power Power in W to charge (positive) or discharge (negative) at specified frequency. + */ + public V2XFreqWattPoint(Double frequency, Double power) { + setFrequency(frequency); + setPower(power); + } + + /** + * Gets net frequency in Hz. + * + * @return Net frequency in Hz + */ + public Double getFrequency() { + return frequency; + } + + /** + * Sets net frequency in Hz. + * + * @param frequency Net frequency in Hz + */ + public void setFrequency(Double frequency) { + if (!isValidFrequency(frequency)) { + throw new PropertyConstraintException(frequency, "frequency is invalid"); + } + this.frequency = frequency; + } + + /** + * Returns whether the given frequency is valid + * + * @param frequency the frequency to check the validity of + * @return {@code true} if frequency is valid, {@code false} if not + */ + private boolean isValidFrequency(Double frequency) { + return frequency != null; + } + + /** + * Gets power in W to charge (positive) or discharge (negative) at specified frequency. + * + * @return Power in W to charge (positive) or discharge (negative) at specified frequency + */ + public Double getPower() { + return power; + } + + /** + * Sets power in W to charge (positive) or discharge (negative) at specified frequency. + * + * @param power Power in W to charge (positive) or discharge (negative) at specified frequency + */ + public void setPower(Double power) { + if (!isValidPower(power)) { + throw new PropertyConstraintException(power, "power is invalid"); + } + this.power = power; + } + + /** + * Returns whether the given power is valid + * + * @param power the power to check the validity of + * @return {@code true} if power is valid, {@code false} if not + */ + private boolean isValidPower(Double power) { + return power != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public V2XFreqWattPoint withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidFrequency(frequency) && isValidPower(power) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V2XFreqWattPoint that = (V2XFreqWattPoint) o; + return Objects.equals(frequency, that.frequency) + && Objects.equals(power, that.power) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(frequency, power, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("frequency", frequency) + .add("power", power) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XSignalWattPoint.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XSignalWattPoint.java new file mode 100644 index 00000000..0093a1d3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/V2XSignalWattPoint.java @@ -0,0 +1,191 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A point of a signal-watt curve. */ +public final class V2XSignalWattPoint { + /** Signal value from an AFRRSignalRequest. */ + private Integer signal; + + /** Power in W to charge (positive) or discharge (negative) at specified frequency. */ + private Double power; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the V2XSignalWattPoint class + * + * @param signal Signal value from an AFRRSignalRequest. + * @param power Power in W to charge (positive) or discharge (negative) at specified frequency. + */ + public V2XSignalWattPoint(Integer signal, Double power) { + setSignal(signal); + setPower(power); + } + + /** + * Gets signal value from an AFRRSignalRequest. + * + * @return Signal value from an AFRRSignalRequest + */ + public Integer getSignal() { + return signal; + } + + /** + * Sets signal value from an AFRRSignalRequest. + * + * @param signal Signal value from an AFRRSignalRequest + */ + public void setSignal(Integer signal) { + if (!isValidSignal(signal)) { + throw new PropertyConstraintException(signal, "signal is invalid"); + } + this.signal = signal; + } + + /** + * Returns whether the given signal is valid + * + * @param signal the signal to check the validity of + * @return {@code true} if signal is valid, {@code false} if not + */ + private boolean isValidSignal(Integer signal) { + return signal != null; + } + + /** + * Gets power in W to charge (positive) or discharge (negative) at specified frequency. + * + * @return Power in W to charge (positive) or discharge (negative) at specified frequency + */ + public Double getPower() { + return power; + } + + /** + * Sets power in W to charge (positive) or discharge (negative) at specified frequency. + * + * @param power Power in W to charge (positive) or discharge (negative) at specified frequency + */ + public void setPower(Double power) { + if (!isValidPower(power)) { + throw new PropertyConstraintException(power, "power is invalid"); + } + this.power = power; + } + + /** + * Returns whether the given power is valid + * + * @param power the power to check the validity of + * @return {@code true} if power is valid, {@code false} if not + */ + private boolean isValidPower(Double power) { + return power != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public V2XSignalWattPoint withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidSignal(signal) && isValidPower(power) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V2XSignalWattPoint that = (V2XSignalWattPoint) o; + return Objects.equals(signal, that.signal) + && Objects.equals(power, that.power) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(signal, power, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("signal", signal) + .add("power", power) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VPN.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VPN.java new file mode 100644 index 00000000..15c7ea02 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VPN.java @@ -0,0 +1,359 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** VPN Configuration settings */ +public final class VPN { + /** VPN Server Address */ + private String server; + + /** VPN User */ + private String user; + + /** VPN group. */ + @Nullable private String group; + + /** VPN Password. */ + private String password; + + /** VPN shared secret. */ + private String key; + + /** Type of VPN */ + private VPNEnum type; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the VPN class + * + * @param server VPN Server Address + * @param user VPN User + * @param password VPN Password. + * @param key VPN shared secret. + * @param type Type of VPN + */ + public VPN(String server, String user, String password, String key, VPNEnum type) { + setServer(server); + setUser(user); + setPassword(password); + setKey(key); + setType(type); + } + + /** + * Gets VPN Server Address + * + * @return VPN Server Address + */ + public String getServer() { + return server; + } + + /** + * Sets VPN Server Address + * + * @param server VPN Server Address + */ + public void setServer(String server) { + if (!isValidServer(server)) { + throw new PropertyConstraintException(server, "server is invalid"); + } + this.server = server; + } + + /** + * Returns whether the given server is valid + * + * @param server the server to check the validity of + * @return {@code true} if server is valid, {@code false} if not + */ + private boolean isValidServer(String server) { + return server != null && server.length() <= 2000; + } + + /** + * Gets VPN User + * + * @return VPN User + */ + public String getUser() { + return user; + } + + /** + * Sets VPN User + * + * @param user VPN User + */ + public void setUser(String user) { + if (!isValidUser(user)) { + throw new PropertyConstraintException(user, "user is invalid"); + } + this.user = user; + } + + /** + * Returns whether the given user is valid + * + * @param user the user to check the validity of + * @return {@code true} if user is valid, {@code false} if not + */ + private boolean isValidUser(String user) { + return user != null && user.length() <= 50; + } + + /** + * Gets VPN group. + * + * @return VPN group + */ + @Nullable + public String getGroup() { + return group; + } + + /** + * Sets VPN group. + * + * @param group VPN group + */ + public void setGroup(@Nullable String group) { + if (!isValidGroup(group)) { + throw new PropertyConstraintException(group, "group is invalid"); + } + this.group = group; + } + + /** + * Returns whether the given group is valid + * + * @param group the group to check the validity of + * @return {@code true} if group is valid, {@code false} if not + */ + private boolean isValidGroup(@Nullable String group) { + return group == null || group.length() <= 50; + } + + /** + * Adds VPN group. + * + * @param group VPN group + * @return this + */ + public VPN withGroup(@Nullable String group) { + setGroup(group); + return this; + } + + /** + * Gets VPN Password. + * + * @return VPN Password + */ + public String getPassword() { + return password; + } + + /** + * Sets VPN Password. + * + * @param password VPN Password + */ + public void setPassword(String password) { + if (!isValidPassword(password)) { + throw new PropertyConstraintException(password, "password is invalid"); + } + this.password = password; + } + + /** + * Returns whether the given password is valid + * + * @param password the password to check the validity of + * @return {@code true} if password is valid, {@code false} if not + */ + private boolean isValidPassword(String password) { + return password != null && password.length() <= 64; + } + + /** + * Gets VPN shared secret. + * + * @return VPN shared secret + */ + public String getKey() { + return key; + } + + /** + * Sets VPN shared secret. + * + * @param key VPN shared secret + */ + public void setKey(String key) { + if (!isValidKey(key)) { + throw new PropertyConstraintException(key, "key is invalid"); + } + this.key = key; + } + + /** + * Returns whether the given key is valid + * + * @param key the key to check the validity of + * @return {@code true} if key is valid, {@code false} if not + */ + private boolean isValidKey(String key) { + return key != null && key.length() <= 255; + } + + /** + * Gets type of VPN + * + * @return Type of VPN + */ + public VPNEnum getType() { + return type; + } + + /** + * Sets type of VPN + * + * @param type Type of VPN + */ + public void setType(VPNEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(VPNEnum type) { + return type != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VPN withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidServer(server) + && isValidUser(user) + && isValidGroup(group) + && isValidPassword(password) + && isValidKey(key) + && isValidType(type) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VPN that = (VPN) o; + return Objects.equals(server, that.server) + && Objects.equals(user, that.user) + && Objects.equals(group, that.group) + && Objects.equals(password, that.password) + && Objects.equals(key, that.key) + && Objects.equals(type, that.type) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(server, user, group, password, key, type, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("server", server) + .add("user", user) + .add("group", group) + .add("password", password) + .add("key", key) + .add("type", type) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VPNEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VPNEnum.java new file mode 100644 index 00000000..a91a3284 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VPNEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +/** Type of VPN */ +public enum VPNEnum { + IKEv2, + IPSec, + L2TP, + PPTP +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Variable.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Variable.java new file mode 100644 index 00000000..270887cd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/Variable.java @@ -0,0 +1,213 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Reference key to a component-variable. */ +public final class Variable { + /** + * Name of the variable. Name should be taken from the list of standardized variable names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + */ + private String name; + + /** + * Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly + * advised to use Camel Case. + */ + @Nullable private String instance; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the Variable class + * + * @param name Name of the variable. Name should be taken from the list of standardized variable + * names whenever possible. Case Insensitive. strongly advised to use Camel Case. + */ + public Variable(String name) { + setName(name); + } + + /** + * Gets name of the variable. Name should be taken from the list of standardized variable names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + * + * @return Name of the variable + */ + public String getName() { + return name; + } + + /** + * Sets name of the variable. Name should be taken from the list of standardized variable names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + * + * @param name Name of the variable + */ + public void setName(String name) { + if (!isValidName(name)) { + throw new PropertyConstraintException(name, "name is invalid"); + } + this.name = name; + } + + /** + * Returns whether the given name is valid + * + * @param name the name to check the validity of + * @return {@code true} if name is valid, {@code false} if not + */ + private boolean isValidName(String name) { + return name != null && name.length() <= 50; + } + + /** + * Gets name of instance in case the variable exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @return Name of instance in case the variable exists as multiple instances + */ + @Nullable + public String getInstance() { + return instance; + } + + /** + * Sets name of instance in case the variable exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @param instance Name of instance in case the variable exists as multiple instances + */ + public void setInstance(@Nullable String instance) { + if (!isValidInstance(instance)) { + throw new PropertyConstraintException(instance, "instance is invalid"); + } + this.instance = instance; + } + + /** + * Returns whether the given instance is valid + * + * @param instance the instance to check the validity of + * @return {@code true} if instance is valid, {@code false} if not + */ + private boolean isValidInstance(@Nullable String instance) { + return instance == null || instance.length() <= 50; + } + + /** + * Adds name of instance in case the variable exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @param instance Name of instance in case the variable exists as multiple instances + * @return this + */ + public Variable withInstance(@Nullable String instance) { + setInstance(instance); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Variable withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidName(name) && isValidInstance(instance) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Variable that = (Variable) o; + return Objects.equals(name, that.name) + && Objects.equals(instance, that.instance) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(name, instance, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("name", name) + .add("instance", instance) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableAttribute.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableAttribute.java new file mode 100644 index 00000000..f511b415 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableAttribute.java @@ -0,0 +1,313 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Attribute data of a variable. */ +public final class VariableAttribute { + /** Attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent. */ + @Nullable private AttributeEnum type; + + /** + * Value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + * + *

The Configuration Variable ReportingValueSize can be used to limit + * GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max + * size of these values will always remain equal. + */ + @Nullable private String value; + + /** The mutability of this attribute. Default is ReadWrite when omitted. */ + @Nullable private MutabilityEnum mutability; + + /** + * Whether value will be persistent across system reboots or power down. Default when omitted is + * false. + */ + @Nullable private Boolean persistent; + + /** + * Whether value that will never be changed by the Charging Station at runtime. Default when + * omitted is false. + */ + @Nullable private Boolean constant; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the VariableAttribute class */ + public VariableAttribute() {} + + /** + * Gets attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent. + * + * @return Attribute: Actual, MinSet, MaxSet, etc + */ + public AttributeEnum getType() { + return type != null ? type : AttributeEnum.Actual; + } + + /** + * Sets attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent. + * + * @param type Attribute: Actual, MinSet, MaxSet, etc + */ + public void setType(@Nullable AttributeEnum type) { + this.type = type; + } + + /** + * Adds attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent. + * + * @param type Attribute: Actual, MinSet, MaxSet, etc + * @return this + */ + public VariableAttribute withType(@Nullable AttributeEnum type) { + setType(type); + return this; + } + + /** + * Gets value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + * + * @return Value of the attribute + */ + @Nullable + public String getValue() { + return value; + } + + /** + * Sets value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + * + * @param value Value of the attribute + */ + public void setValue(@Nullable String value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(@Nullable String value) { + return value == null || value.length() <= 2500; + } + + /** + * Adds value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + * + * @param value Value of the attribute + * @return this + */ + public VariableAttribute withValue(@Nullable String value) { + setValue(value); + return this; + } + + /** + * Gets the mutability of this attribute. Default is ReadWrite when omitted. + * + * @return The mutability of this attribute + */ + public MutabilityEnum getMutability() { + return mutability != null ? mutability : MutabilityEnum.ReadWrite; + } + + /** + * Sets the mutability of this attribute. Default is ReadWrite when omitted. + * + * @param mutability The mutability of this attribute + */ + public void setMutability(@Nullable MutabilityEnum mutability) { + this.mutability = mutability; + } + + /** + * Adds the mutability of this attribute. Default is ReadWrite when omitted. + * + * @param mutability The mutability of this attribute + * @return this + */ + public VariableAttribute withMutability(@Nullable MutabilityEnum mutability) { + setMutability(mutability); + return this; + } + + /** + * Gets whether value will be persistent across system reboots or power down. Default when omitted + * is false. + * + * @return Whether value will be persistent across system reboots or power down + */ + public Boolean getPersistent() { + return persistent != null ? persistent : false; + } + + /** + * Sets whether value will be persistent across system reboots or power down. Default when omitted + * is false. + * + * @param persistent Whether value will be persistent across system reboots or power down + */ + public void setPersistent(@Nullable Boolean persistent) { + this.persistent = persistent; + } + + /** + * Adds whether value will be persistent across system reboots or power down. Default when omitted + * is false. + * + * @param persistent Whether value will be persistent across system reboots or power down + * @return this + */ + public VariableAttribute withPersistent(@Nullable Boolean persistent) { + setPersistent(persistent); + return this; + } + + /** + * Gets whether value that will never be changed by the Charging Station at runtime. Default when + * omitted is false. + * + * @return Whether value that will never be changed by the Charging Station at runtime + */ + public Boolean getConstant() { + return constant != null ? constant : false; + } + + /** + * Sets whether value that will never be changed by the Charging Station at runtime. Default when + * omitted is false. + * + * @param constant Whether value that will never be changed by the Charging Station at runtime + */ + public void setConstant(@Nullable Boolean constant) { + this.constant = constant; + } + + /** + * Adds whether value that will never be changed by the Charging Station at runtime. Default when + * omitted is false. + * + * @param constant Whether value that will never be changed by the Charging Station at runtime + * @return this + */ + public VariableAttribute withConstant(@Nullable Boolean constant) { + setConstant(constant); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VariableAttribute withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidValue(value) && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VariableAttribute that = (VariableAttribute) o; + return Objects.equals(type, that.type) + && Objects.equals(value, that.value) + && Objects.equals(mutability, that.mutability) + && Objects.equals(persistent, that.persistent) + && Objects.equals(constant, that.constant) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(type, value, mutability, persistent, constant, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("type", type) + .add("value", value) + .add("mutability", mutability) + .add("persistent", persistent) + .add("constant", constant) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableCharacteristics.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableCharacteristics.java new file mode 100644 index 00000000..cee1d796 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableCharacteristics.java @@ -0,0 +1,453 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Fixed read-only parameters of a variable. */ +public final class VariableCharacteristics { + /** Unit of the variable. When the transmitted value has a unit, this field SHALL be included. */ + @Nullable private String unit; + + /** Data type of this variable. */ + private DataEnum dataType; + + /** Minimum possible value of this variable. */ + @Nullable private Double minLimit; + + /** + * Maximum possible value of this variable. When the datatype of this Variable is String, + * OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) + * string. + */ + @Nullable private Double maxLimit; + + /** Maximum number of elements from valuesList that are supported as attributeValue. */ + @Nullable private Integer maxElements; + + /** + * Mandatory when dataType = OptionList, MemberList or SequenceList. In that case valuesList + * specifies the allowed values for the type. + * + *

The length of this field can be limited by DeviceDataCtrlr.ConfigurationValueSize. + * + *

* OptionList: The (Actual) Variable value must be a single value from the reported (CSV) + * enumeration list. + * + *

* MemberList: The (Actual) Variable value may be an (unordered) (sub-)set of the reported + * (CSV) valid values list. + * + *

* SequenceList: The (Actual) Variable value may be an ordered (priority, etc) (sub-)set of + * the reported (CSV) valid values. + * + *

This is a comma separated list. + * + *

The Configuration Variable ConfigurationValueSize can be used to limit + * SetVariableData.attributeValue and VariableCharacteristics.valuesList. The max size of these + * values will always remain equal. + */ + @Nullable private String valuesList; + + /** Flag indicating if this variable supports monitoring. */ + private Boolean supportsMonitoring; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the VariableCharacteristics class + * + * @param dataType Data type of this variable. + * @param supportsMonitoring Flag indicating if this variable supports monitoring. + */ + public VariableCharacteristics(DataEnum dataType, Boolean supportsMonitoring) { + setDataType(dataType); + setSupportsMonitoring(supportsMonitoring); + } + + /** + * Gets unit of the variable. When the transmitted value has a unit, this field SHALL be included. + * + * @return Unit of the variable + */ + @Nullable + public String getUnit() { + return unit; + } + + /** + * Sets unit of the variable. When the transmitted value has a unit, this field SHALL be included. + * + * @param unit Unit of the variable + */ + public void setUnit(@Nullable String unit) { + if (!isValidUnit(unit)) { + throw new PropertyConstraintException(unit, "unit is invalid"); + } + this.unit = unit; + } + + /** + * Returns whether the given unit is valid + * + * @param unit the unit to check the validity of + * @return {@code true} if unit is valid, {@code false} if not + */ + private boolean isValidUnit(@Nullable String unit) { + return unit == null || unit.length() <= 16; + } + + /** + * Adds unit of the variable. When the transmitted value has a unit, this field SHALL be included. + * + * @param unit Unit of the variable + * @return this + */ + public VariableCharacteristics withUnit(@Nullable String unit) { + setUnit(unit); + return this; + } + + /** + * Gets data type of this variable. + * + * @return Data type of this variable + */ + public DataEnum getDataType() { + return dataType; + } + + /** + * Sets data type of this variable. + * + * @param dataType Data type of this variable + */ + public void setDataType(DataEnum dataType) { + if (!isValidDataType(dataType)) { + throw new PropertyConstraintException(dataType, "dataType is invalid"); + } + this.dataType = dataType; + } + + /** + * Returns whether the given dataType is valid + * + * @param dataType the dataType to check the validity of + * @return {@code true} if dataType is valid, {@code false} if not + */ + private boolean isValidDataType(DataEnum dataType) { + return dataType != null; + } + + /** + * Gets minimum possible value of this variable. + * + * @return Minimum possible value of this variable + */ + @Nullable + public Double getMinLimit() { + return minLimit; + } + + /** + * Sets minimum possible value of this variable. + * + * @param minLimit Minimum possible value of this variable + */ + public void setMinLimit(@Nullable Double minLimit) { + this.minLimit = minLimit; + } + + /** + * Adds minimum possible value of this variable. + * + * @param minLimit Minimum possible value of this variable + * @return this + */ + public VariableCharacteristics withMinLimit(@Nullable Double minLimit) { + setMinLimit(minLimit); + return this; + } + + /** + * Gets maximum possible value of this variable. When the datatype of this Variable is String, + * OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) + * string. + * + * @return Maximum possible value of this variable + */ + @Nullable + public Double getMaxLimit() { + return maxLimit; + } + + /** + * Sets maximum possible value of this variable. When the datatype of this Variable is String, + * OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) + * string. + * + * @param maxLimit Maximum possible value of this variable + */ + public void setMaxLimit(@Nullable Double maxLimit) { + this.maxLimit = maxLimit; + } + + /** + * Adds maximum possible value of this variable. When the datatype of this Variable is String, + * OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) + * string. + * + * @param maxLimit Maximum possible value of this variable + * @return this + */ + public VariableCharacteristics withMaxLimit(@Nullable Double maxLimit) { + setMaxLimit(maxLimit); + return this; + } + + /** + * Gets maximum number of elements from valuesList that are supported as attributeValue. + * + * @return Maximum number of elements from valuesList that are supported as attributeValue + */ + @Nullable + public Integer getMaxElements() { + return maxElements; + } + + /** + * Sets maximum number of elements from valuesList that are supported as attributeValue. + * + * @param maxElements Maximum number of elements from valuesList that are supported as + * attributeValue + */ + public void setMaxElements(@Nullable Integer maxElements) { + if (!isValidMaxElements(maxElements)) { + throw new PropertyConstraintException(maxElements, "maxElements is invalid"); + } + this.maxElements = maxElements; + } + + /** + * Returns whether the given maxElements is valid + * + * @param maxElements the maxElements to check the validity of + * @return {@code true} if maxElements is valid, {@code false} if not + */ + private boolean isValidMaxElements(@Nullable Integer maxElements) { + return maxElements == null || (maxElements >= 1); + } + + /** + * Adds maximum number of elements from valuesList that are supported as attributeValue. + * + * @param maxElements Maximum number of elements from valuesList that are supported as + * attributeValue + * @return this + */ + public VariableCharacteristics withMaxElements(@Nullable Integer maxElements) { + setMaxElements(maxElements); + return this; + } + + /** + * Gets mandatory when dataType = OptionList, MemberList or SequenceList. In that case valuesList + * specifies the allowed values for the type. + * + * @return Mandatory when dataType = OptionList, MemberList or SequenceList + */ + @Nullable + public String getValuesList() { + return valuesList; + } + + /** + * Sets mandatory when dataType = OptionList, MemberList or SequenceList. In that case valuesList + * specifies the allowed values for the type. + * + * @param valuesList Mandatory when dataType = OptionList, MemberList or SequenceList + */ + public void setValuesList(@Nullable String valuesList) { + if (!isValidValuesList(valuesList)) { + throw new PropertyConstraintException(valuesList, "valuesList is invalid"); + } + this.valuesList = valuesList; + } + + /** + * Returns whether the given valuesList is valid + * + * @param valuesList the valuesList to check the validity of + * @return {@code true} if valuesList is valid, {@code false} if not + */ + private boolean isValidValuesList(@Nullable String valuesList) { + return valuesList == null || valuesList.length() <= 1000; + } + + /** + * Adds mandatory when dataType = OptionList, MemberList or SequenceList. In that case valuesList + * specifies the allowed values for the type. + * + * @param valuesList Mandatory when dataType = OptionList, MemberList or SequenceList + * @return this + */ + public VariableCharacteristics withValuesList(@Nullable String valuesList) { + setValuesList(valuesList); + return this; + } + + /** + * Gets flag indicating if this variable supports monitoring. + * + * @return Flag indicating if this variable supports monitoring + */ + public Boolean getSupportsMonitoring() { + return supportsMonitoring; + } + + /** + * Sets flag indicating if this variable supports monitoring. + * + * @param supportsMonitoring Flag indicating if this variable supports monitoring + */ + public void setSupportsMonitoring(Boolean supportsMonitoring) { + if (!isValidSupportsMonitoring(supportsMonitoring)) { + throw new PropertyConstraintException(supportsMonitoring, "supportsMonitoring is invalid"); + } + this.supportsMonitoring = supportsMonitoring; + } + + /** + * Returns whether the given supportsMonitoring is valid + * + * @param supportsMonitoring the supportsMonitoring to check the validity of + * @return {@code true} if supportsMonitoring is valid, {@code false} if not + */ + private boolean isValidSupportsMonitoring(Boolean supportsMonitoring) { + return supportsMonitoring != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VariableCharacteristics withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidUnit(unit) + && isValidDataType(dataType) + && isValidMaxElements(maxElements) + && isValidValuesList(valuesList) + && isValidSupportsMonitoring(supportsMonitoring) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VariableCharacteristics that = (VariableCharacteristics) o; + return Objects.equals(unit, that.unit) + && Objects.equals(dataType, that.dataType) + && Objects.equals(minLimit, that.minLimit) + && Objects.equals(maxLimit, that.maxLimit) + && Objects.equals(maxElements, that.maxElements) + && Objects.equals(valuesList, that.valuesList) + && Objects.equals(supportsMonitoring, that.supportsMonitoring) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash( + unit, + dataType, + minLimit, + maxLimit, + maxElements, + valuesList, + supportsMonitoring, + customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("unit", unit) + .add("dataType", dataType) + .add("minLimit", minLimit) + .add("maxLimit", maxLimit) + .add("maxElements", maxElements) + .add("valuesList", valuesList) + .add("supportsMonitoring", supportsMonitoring) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableMonitoring.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableMonitoring.java new file mode 100644 index 00000000..00b738fd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VariableMonitoring.java @@ -0,0 +1,405 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A monitoring setting for a variable. */ +public final class VariableMonitoring { + /** The identifier of the monitor. */ + private Integer id; + + /** + * Monitor only active when a transaction is ongoing on a component relevant to this transaction. + */ + private Boolean transaction; + + /** + * Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + */ + private Double value; + + /** The type of this monitor, e.g. a threshold, delta or periodic monitor. */ + private MonitorEnum type; + + /** + * The severity that will be assigned to an event that is triggered by this monitor. The severity + * range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + *

+   * The severity levels have the following meaning:
+   * *0-Danger*
+   * Lives are potentially in danger. Urgent attention is needed and action should be taken
+   * immediately.
+   * *1-Hardware Failure*
+   * That the Charging Station is unable to continue regular operations due to Hardware issues.
+   * Action is required.
+   * *2-System Failure*
+   * That the Charging Station is unable to continue regular operations due to software or minor
+   * hardware issues. Action is required.
+   * *3-Critical*
+   * A critical error. Action is required.
+   * *4-Error*
+   * A non-urgent error. Action is required.
+   * *5-Alert*
+   * An alert event. Default severity for any type of monitoring event.
+   * *6-Warning*
+   * A warning event. Action may be required.
+   * *7-Notice*
+   * An unusual event. No immediate action is required.
+   * *8-Informational*
+   * A regular operational event. May be used for reporting, measuring throughput, etc. No action is
+   * required.
+   * *9-Debug*
+   * Information useful to developers for debugging, not useful during operations.
+   * 
+ */ + private Integer severity; + + /** Type of monitor. */ + private EventNotificationEnum eventNotificationType; + + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Constructor for the VariableMonitoring class + * + * @param id The identifier of the monitor. + * @param transaction Monitor only active when a transaction is ongoing on a component relevant to + * this transaction. + * @param value Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this + * is the interval in seconds. + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor. + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * @param eventNotificationType Type of monitor. + */ + public VariableMonitoring( + Integer id, + Boolean transaction, + Double value, + MonitorEnum type, + Integer severity, + EventNotificationEnum eventNotificationType) { + setId(id); + setTransaction(transaction); + setValue(value); + setType(type); + setSeverity(severity); + setEventNotificationType(eventNotificationType); + } + + /** + * Gets the identifier of the monitor. + * + * @return The identifier of the monitor + */ + public Integer getId() { + return id; + } + + /** + * Sets the identifier of the monitor. + * + * @param id The identifier of the monitor + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null && id >= 0; + } + + /** + * Gets monitor only active when a transaction is ongoing on a component relevant to this + * transaction. + * + * @return Monitor only active when a transaction is ongoing on a component relevant to this + * transaction + */ + public Boolean getTransaction() { + return transaction; + } + + /** + * Sets monitor only active when a transaction is ongoing on a component relevant to this + * transaction. + * + * @param transaction Monitor only active when a transaction is ongoing on a component relevant to + * this transaction + */ + public void setTransaction(Boolean transaction) { + if (!isValidTransaction(transaction)) { + throw new PropertyConstraintException(transaction, "transaction is invalid"); + } + this.transaction = transaction; + } + + /** + * Returns whether the given transaction is valid + * + * @param transaction the transaction to check the validity of + * @return {@code true} if transaction is valid, {@code false} if not + */ + private boolean isValidTransaction(Boolean transaction) { + return transaction != null; + } + + /** + * Gets value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + * + * @return Value for threshold or delta monitoring + */ + public Double getValue() { + return value; + } + + /** + * Sets value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + * + * @param value Value for threshold or delta monitoring + */ + public void setValue(Double value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(Double value) { + return value != null; + } + + /** + * Gets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @return The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public MonitorEnum getType() { + return type; + } + + /** + * Sets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public void setType(MonitorEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(MonitorEnum type) { + return type != null; + } + + /** + * Gets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @return The severity that will be assigned to an event that is triggered by this monitor + */ + public Integer getSeverity() { + return severity; + } + + /** + * Sets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor + */ + public void setSeverity(Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(Integer severity) { + return severity != null && severity >= 0; + } + + /** + * Gets type of monitor. + * + * @return Type of monitor + */ + public EventNotificationEnum getEventNotificationType() { + return eventNotificationType; + } + + /** + * Sets type of monitor. + * + * @param eventNotificationType Type of monitor + */ + public void setEventNotificationType(EventNotificationEnum eventNotificationType) { + if (!isValidEventNotificationType(eventNotificationType)) { + throw new PropertyConstraintException( + eventNotificationType, "eventNotificationType is invalid"); + } + this.eventNotificationType = eventNotificationType; + } + + /** + * Returns whether the given eventNotificationType is valid + * + * @param eventNotificationType the eventNotificationType to check the validity of + * @return {@code true} if eventNotificationType is valid, {@code false} if not + */ + private boolean isValidEventNotificationType(EventNotificationEnum eventNotificationType) { + return eventNotificationType != null; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VariableMonitoring withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidId(id) + && isValidTransaction(transaction) + && isValidValue(value) + && isValidType(type) + && isValidSeverity(severity) + && isValidEventNotificationType(eventNotificationType) + && isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VariableMonitoring that = (VariableMonitoring) o; + return Objects.equals(id, that.id) + && Objects.equals(transaction, that.transaction) + && Objects.equals(value, that.value) + && Objects.equals(type, that.type) + && Objects.equals(severity, that.severity) + && Objects.equals(eventNotificationType, that.eventNotificationType) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(id, transaction, value, type, severity, eventNotificationType, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("transaction", transaction) + .add("value", value) + .add("type", type) + .add("severity", severity) + .add("eventNotificationType", eventNotificationType) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VoltageParams.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VoltageParams.java new file mode 100644 index 00000000..78ff8b33 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/types/VoltageParams.java @@ -0,0 +1,251 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** VoltageParamsType */ +public final class VoltageParams { + /** + * EN 50549-1 chapter 4.9.3.4 Voltage threshold for the 10 min time window mean value monitoring. + * The 10 min mean is recalculated up to every 3 s. If the present voltage is above this threshold + * for more than the time defined by hv10MinMeanValue, the EV must trip. This value is mandatory + * if hv10MinMeanTripDelay is set. + */ + @Nullable private Double hv10MinMeanValue; + + /** + * Time for which the voltage is allowed to stay above the 10 min mean value. After this time, the + * EV must trip. This value is mandatory if OverVoltageMeanValue10min is set. + */ + @Nullable private Double hv10MinMeanTripDelay; + + /** + * Parameter is only sent, if the EV has to feed-in power or reactive power during fault-ride + * through (FRT) as defined by HVMomCess curve and LVMomCess curve. + */ + @Nullable private PowerDuringCessationEnum powerDuringCessation; + + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the VoltageParams class */ + public VoltageParams() {} + + /** + * Gets EN 50549-1 chapter 4.9.3.4 Voltage threshold for the 10 min time window mean value + * monitoring. The 10 min mean is recalculated up to every 3 s. If the present voltage is above + * this threshold for more than the time defined by hv10MinMeanValue, the EV must trip. This value + * is mandatory if hv10MinMeanTripDelay is set. + * + * @return EN 50549-1 chapter 4.9.3.4 Voltage threshold for the 10 min time window mean value + * monitoring + */ + @Nullable + public Double getHv10MinMeanValue() { + return hv10MinMeanValue; + } + + /** + * Sets EN 50549-1 chapter 4.9.3.4 Voltage threshold for the 10 min time window mean value + * monitoring. The 10 min mean is recalculated up to every 3 s. If the present voltage is above + * this threshold for more than the time defined by hv10MinMeanValue, the EV must trip. This value + * is mandatory if hv10MinMeanTripDelay is set. + * + * @param hv10MinMeanValue EN 50549-1 chapter 4.9.3.4 Voltage threshold for the 10 min time window + * mean value monitoring + */ + public void setHv10MinMeanValue(@Nullable Double hv10MinMeanValue) { + this.hv10MinMeanValue = hv10MinMeanValue; + } + + /** + * Adds EN 50549-1 chapter 4.9.3.4 Voltage threshold for the 10 min time window mean value + * monitoring. The 10 min mean is recalculated up to every 3 s. If the present voltage is above + * this threshold for more than the time defined by hv10MinMeanValue, the EV must trip. This value + * is mandatory if hv10MinMeanTripDelay is set. + * + * @param hv10MinMeanValue EN 50549-1 chapter 4.9.3.4 Voltage threshold for the 10 min time window + * mean value monitoring + * @return this + */ + public VoltageParams withHv10MinMeanValue(@Nullable Double hv10MinMeanValue) { + setHv10MinMeanValue(hv10MinMeanValue); + return this; + } + + /** + * Gets time for which the voltage is allowed to stay above the 10 min mean value. After this + * time, the EV must trip. This value is mandatory if OverVoltageMeanValue10min is set. + * + * @return Time for which the voltage is allowed to stay above the 10 min mean value + */ + @Nullable + public Double getHv10MinMeanTripDelay() { + return hv10MinMeanTripDelay; + } + + /** + * Sets time for which the voltage is allowed to stay above the 10 min mean value. After this + * time, the EV must trip. This value is mandatory if OverVoltageMeanValue10min is set. + * + * @param hv10MinMeanTripDelay Time for which the voltage is allowed to stay above the 10 min mean + * value + */ + public void setHv10MinMeanTripDelay(@Nullable Double hv10MinMeanTripDelay) { + this.hv10MinMeanTripDelay = hv10MinMeanTripDelay; + } + + /** + * Adds time for which the voltage is allowed to stay above the 10 min mean value. After this + * time, the EV must trip. This value is mandatory if OverVoltageMeanValue10min is set. + * + * @param hv10MinMeanTripDelay Time for which the voltage is allowed to stay above the 10 min mean + * value + * @return this + */ + public VoltageParams withHv10MinMeanTripDelay(@Nullable Double hv10MinMeanTripDelay) { + setHv10MinMeanTripDelay(hv10MinMeanTripDelay); + return this; + } + + /** + * Gets parameter is only sent, if the EV has to feed-in power or reactive power during fault-ride + * through (FRT) as defined by HVMomCess curve and LVMomCess curve. + * + * @return Parameter is only sent, if the EV has to feed-in power or reactive power during + * fault-ride through (FRT) as defined by HVMomCess curve and LVMomCess curve + */ + @Nullable + public PowerDuringCessationEnum getPowerDuringCessation() { + return powerDuringCessation; + } + + /** + * Sets parameter is only sent, if the EV has to feed-in power or reactive power during fault-ride + * through (FRT) as defined by HVMomCess curve and LVMomCess curve. + * + * @param powerDuringCessation Parameter is only sent, if the EV has to feed-in power or reactive + * power during fault-ride through (FRT) as defined by HVMomCess curve and LVMomCess curve + */ + public void setPowerDuringCessation(@Nullable PowerDuringCessationEnum powerDuringCessation) { + this.powerDuringCessation = powerDuringCessation; + } + + /** + * Adds parameter is only sent, if the EV has to feed-in power or reactive power during fault-ride + * through (FRT) as defined by HVMomCess curve and LVMomCess curve. + * + * @param powerDuringCessation Parameter is only sent, if the EV has to feed-in power or reactive + * power during fault-ride through (FRT) as defined by HVMomCess curve and LVMomCess curve + * @return this + */ + public VoltageParams withPowerDuringCessation( + @Nullable PowerDuringCessationEnum powerDuringCessation) { + setPowerDuringCessation(powerDuringCessation); + return this; + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VoltageParams withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VoltageParams that = (VoltageParams) o; + return Objects.equals(hv10MinMeanValue, that.hv10MinMeanValue) + && Objects.equals(hv10MinMeanTripDelay, that.hv10MinMeanTripDelay) + && Objects.equals(powerDuringCessation, that.powerDuringCessation) + && Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(hv10MinMeanValue, hv10MinMeanTripDelay, powerDuringCessation, customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("hv10MinMeanValue", hv10MinMeanValue) + .add("hv10MinMeanTripDelay", hv10MinMeanTripDelay) + .add("powerDuringCessation", powerDuringCessation) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/pom.xml b/pom.xml index 9e1c714d..8dcf543f 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,10 @@ ocpp-v2-test + + UTF-8 + + @@ -105,7 +109,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.4 + 3.2.4 sign-artifacts From 31aea97a6a47a87f8c567d4515b5a868a66196d1 Mon Sep 17 00:00:00 2001 From: Robert Schlabbach Date: Sun, 14 Dec 2025 10:56:32 +0100 Subject: [PATCH 2/4] Implement OCPP 2.1 RPC Layer Extensions Implement the CALLRESULTERROR RPC as a response to a CALLRESULT, in case that failed internal validation, or if the completion action last added to the CompletionStage returned by send() using .whenComplete[Async]() throws any exception. Add an optional confirmationError() callback method to the ClientEvents and ServerEvents interfaces to allow the application to get notified about an incoming CALLRESULTERROR. The application may use the uniqueId parameter to match it to the Request#getOcppMessageId() of one of the requests it last responded to, provided it keeps track of them. Implement the SEND RPC as requests which do not have a confirmation type. These are sent through the existing send() method, returning a CompletableFuture which is already completed when the method returns, to which a completion action can be added to check whether a local exception prevented the request from being sent. Fix the only OCPP message using the SEND RPC, NotifyPeriodicEventStream, and add its missing Feature and Function handlers. The handler for this message is a void method, as it has no response. Remove sending CALLERROR in response to anything other than a CALL, except for the RpcFrameworkError when the message could not be parsed. Simplify the pendingPromises synchronization in Session by using the ConcurrentHashMap class rather than HashMap. Fix a few typos encountered along the way. --- ocpp-common/build.gradle | 1 + ocpp-common/pom.xml | 5 + .../ocpp/AsyncPromiseFulfillerDecorator.java | 5 +- .../main/java/eu/chargetime/ocpp/Client.java | 37 ++++- .../java/eu/chargetime/ocpp/ClientEvents.java | 3 + .../java/eu/chargetime/ocpp/Communicator.java | 97 ++++++++++- .../chargetime/ocpp/CommunicatorEvents.java | 25 +++ .../eu/chargetime/ocpp/FeatureRepository.java | 4 +- .../java/eu/chargetime/ocpp/ISession.java | 2 + .../main/java/eu/chargetime/ocpp/Promise.java | 69 ++++++++ .../eu/chargetime/ocpp/PromiseFulfiller.java | 5 +- .../eu/chargetime/ocpp/PromiseRepository.java | 4 +- .../eu/chargetime/ocpp/RequestDispatcher.java | 3 +- .../main/java/eu/chargetime/ocpp/Server.java | 47 +++++- .../java/eu/chargetime/ocpp/ServerEvents.java | 7 + .../main/java/eu/chargetime/ocpp/Session.java | 154 ++++++++++++++---- .../eu/chargetime/ocpp/SessionEvents.java | 27 ++- .../ocpp/SimplePromiseFulfiller.java | 13 +- .../eu/chargetime/ocpp/feature/Feature.java | 13 +- .../ocpp/model/CallErrorMessage.java | 12 ++ .../ocpp/model/CallResultErrorMessage.java | 30 ++++ .../eu/chargetime/ocpp/model/SendMessage.java | 30 ++++ .../eu/chargetime/ocpp/test/ClientTest.java | 1 + .../ocpp/test/CommunicatorTest.java | 11 ++ .../eu/chargetime/ocpp/test/ServerTest.java | 1 + .../eu/chargetime/ocpp/test/SessionTest.java | 1 + .../eu/chargetime/ocpp/JSONCommunicator.java | 93 +++++++---- .../eu/chargetime/ocpp/SOAPCommunicator.java | 11 ++ .../ocpp/TimeoutSessionDecorator.java | 14 +- .../ocpp/feature/FunctionFeature.java | 4 +- .../ocpp/feature/function/Function.java | 4 +- .../NotifyPeriodicEventStreamFeature.java | 53 ++++++ .../function/ClientDiagnosticsFunction.java | 15 ++ .../ServerDiagnosticsEventHandler.java | 8 + .../function/ServerDiagnosticsFunction.java | 5 + .../messages/NotifyPeriodicEventStream.java | 9 +- 36 files changed, 721 insertions(+), 102 deletions(-) create mode 100644 ocpp-common/src/main/java/eu/chargetime/ocpp/Promise.java create mode 100644 ocpp-common/src/main/java/eu/chargetime/ocpp/model/CallResultErrorMessage.java create mode 100644 ocpp-common/src/main/java/eu/chargetime/ocpp/model/SendMessage.java create mode 100644 ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyPeriodicEventStreamFeature.java diff --git a/ocpp-common/build.gradle b/ocpp-common/build.gradle index b2b08469..e445be44 100644 --- a/ocpp-common/build.gradle +++ b/ocpp-common/build.gradle @@ -3,6 +3,7 @@ */ dependencies { + compile 'com.google.code.findbugs:jsr305:3.0.2' compile 'org.slf4j:slf4j-api:2.0.17' compile 'ch.qos.logback:logback-classic:1.3.16' compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' diff --git a/ocpp-common/pom.xml b/ocpp-common/pom.xml index 588cc028..15e3f018 100644 --- a/ocpp-common/pom.xml +++ b/ocpp-common/pom.xml @@ -38,6 +38,11 @@ + + com.google.code.findbugs + jsr305 + 3.0.2 + javax.xml.bind jaxb-api diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/AsyncPromiseFulfillerDecorator.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/AsyncPromiseFulfillerDecorator.java index bbf2e0b1..71a7ca9b 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/AsyncPromiseFulfillerDecorator.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/AsyncPromiseFulfillerDecorator.java @@ -30,6 +30,7 @@ of this software and associated documentation files (the "Software"), to deal import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import javax.annotation.Nullable; public class AsyncPromiseFulfillerDecorator implements PromiseFulfiller { @@ -43,7 +44,9 @@ public static void setExecutor(ExecutorService newExecutor) { @Override public void fulfill( - CompletableFuture promise, SessionEvents eventHandler, Request request) { + @Nullable CompletableFuture promise, + SessionEvents eventHandler, + Request request) { executor.submit(() -> promiseFulfiller.fulfill(promise, eventHandler, request)); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java index 1dec69f6..bd3f9f90 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java @@ -32,6 +32,8 @@ of this software and associated documentation files (the "Software"), to deal import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,11 +73,23 @@ public void connect(String uri, ClientEvents events) { new SessionEvents() { @Override - public void handleConfirmation(String uniqueId, Confirmation confirmation) { + public void handleConfirmation(String uniqueId, @Nullable Confirmation confirmation) { Optional> promiseOptional = promiseRepository.getPromise(uniqueId); if (promiseOptional.isPresent()) { promiseOptional.get().complete(confirmation); + // join completion to catch and rethrow any exceptions thrown in the last added + // completion action, so that a CALLRESULTERROR may be produced from it. + try { + promiseOptional.get().join(); + } catch (CompletionException e) { + Throwable cause = e.getCause() != null ? e.getCause() : e; + if (cause instanceof RuntimeException) { + throw (RuntimeException) cause; + } else { + throw new RuntimeException(cause); + } + } } else { logger.debug("Promise not found for confirmation {}", confirmation); } @@ -112,6 +126,18 @@ public void handleError( } } + @Override + public void handleConfirmationError( + String uniqueId, String errorCode, String errorDescription, Object payload) { + logger.error( + "Received an error which occurred while processing a call result: " + + "uniqueId {}: errorCode: {}, errorDescription: {}", + uniqueId, + errorCode, + errorDescription); + events.confirmationError(uniqueId, errorCode, errorDescription, payload); + } + @Override public void handleConnectionClosed() { if (events != null) events.connectionClosed(); @@ -137,7 +163,8 @@ public void disconnect() { * Send a {@link Request} to the server. Can only send {@link Request} that the client supports. * * @param request outgoing request - * @return call back object, will be fulfilled with confirmation when received + * @return call back object, will be fulfilled with confirmation when received or {@code null} if + * the request has no confirmation, or exceptionally if a local or remote error occurred. * @throws UnsupportedFeatureException trying to send a request from an unsupported feature * @throws OccurenceConstraintException Thrown if the request isn't valid. * @see CompletableFuture @@ -166,7 +193,11 @@ public CompletableFuture send(Request request) promiseRepository.removePromise(requestUuid); }); - session.sendRequest(featureOptional.get().getAction(), request, requestUuid); + if (featureOptional.get().getConfirmationType() != null) { + session.sendRequest(featureOptional.get().getAction(), request, requestUuid); + } else { + session.sendMessage(featureOptional.get().getAction(), request, requestUuid); + } return promise; } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/ClientEvents.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/ClientEvents.java index 4f3c15cc..4b1b0461 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/ClientEvents.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/ClientEvents.java @@ -31,4 +31,7 @@ public interface ClientEvents { void connectionOpened(); void connectionClosed(); + + default void confirmationError( + String uniqueId, String errorCode, String errorDescription, Object payload) {}; } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java index e667e32f..83ddff4e 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java @@ -41,9 +41,9 @@ of this software and associated documentation files (the "Software"), to deal public abstract class Communicator { private static final Logger logger = LoggerFactory.getLogger(Communicator.class); + private final ArrayDeque transactionQueue; private RetryRunner retryRunner; protected Radio radio; - private ArrayDeque transactionQueue; private CommunicatorEvents events; private boolean failedFlag; @@ -97,6 +97,27 @@ public abstract class Communicator { protected abstract Object makeCallError( String uniqueId, String action, String errorCode, String errorDescription); + /** + * Create a call result error envelope to transmit. + * + * @param uniqueId the id the receiver expects. + * @param errorCode an OCPP error code. + * @param errorDescription an associated error description. + * @return a fully packed message ready to send. + */ + protected abstract Object makeCallResultError( + String uniqueId, String action, String errorCode, String errorDescription); + + /** + * Create a send envelope to transmit to the server. + * + * @param uniqueId the id of the message. + * @param action action name of the feature. + * @param payload packed payload. + * @return a fully packed message ready to send. + */ + protected abstract Object makeSend(String uniqueId, String action, Object payload); + /** * Identify an incoming call and parse it into one of the following: {@link CallMessage} a * request. {@link CallResultMessage} a response. @@ -177,7 +198,7 @@ public synchronized void sendCall(String uniqueId, String action, Request reques } } else if (request.transactionRelated() && transactionQueue != null - && transactionQueue.size() > 0) { + && !transactionQueue.isEmpty()) { transactionQueue.add(call); processTransactionQueue(); } else { @@ -216,7 +237,7 @@ public void sendCallResult(String uniqueId, String action, Confirmation confirma events.onError( uniqueId, "ConfirmationCompletedHandlerFailed", - "The confirmation completed callback handler failed with exception " + e.toString(), + "The confirmation completed callback handler failed with exception " + e, confirmation); } } @@ -240,7 +261,7 @@ public void sendCallResult(String uniqueId, String action, Confirmation confirma public void sendCallError( String uniqueId, String action, String errorCode, String errorDescription) { logger.error( - "An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}", + "An error occurred. Sending this information: uniqueId {}: action: {}, errorCode: {}, errorDescription: {}", uniqueId, action, errorCode, @@ -257,6 +278,65 @@ public void sendCallError( } } + /** + * Send a call result error. If offline, the message is thrown away. + * + * @param uniqueId the id the receiver expects a response to. + * @param errorCode an OCPP error Code + * @param errorDescription a associated error description. + */ + public void sendCallResultError( + String uniqueId, String action, String errorCode, String errorDescription) { + logger.error( + "An error occurred while processing a call result. Sending this information: " + + "uniqueId {}: action: {}, errorCode: {}, errorDescription: {}", + uniqueId, + action, + errorCode, + errorDescription); + try { + radio.send(makeCallResultError(uniqueId, action, errorCode, errorDescription)); + } catch (NotConnectedException ex) { + logger.warn("sendCallResultError() failed", ex); + events.onError( + uniqueId, + "Not connected", + "The call result error couldn't be sent due to the lack of connection", + errorCode); + } + } + + /** + * Send a {@link Request} which has no confirmation. + * + * @param uniqueId the id of the {@link Request}. + * @param action action name of the {@link eu.chargetime.ocpp.feature.Feature}. + * @param request the outgoing {@link Request} + */ + public synchronized void send(String uniqueId, String action, Request request) { + Object call = makeSend(uniqueId, action, packPayload(request)); + + try { + if (radio.isClosed()) { + logger.warn("Not connected: can't send request: {}", request); + events.onError( + uniqueId, + "Not connected", + "The request can't be sent due to the lack of connection", + request); + } else { + radio.send(call); + } + } catch (NotConnectedException ex) { + logger.warn("sendCall() failed: not connected"); + events.onError( + uniqueId, + "Not connected", + "The request can't be sent due to the lack of connection", + request); + } + } + /** Close down the connection. Uses the {@link Transmitter}. */ public void disconnect() { radio.disconnect(); @@ -289,6 +369,10 @@ public void receivedMessage(Object input) { Message message = parse(input); if (message instanceof CallResultMessage) { events.onCallResult(message.getId(), message.getAction(), message.getPayload()); + } else if (message instanceof CallResultErrorMessage) { + CallResultErrorMessage call = (CallResultErrorMessage) message; + events.onCallResultError( + call.getId(), call.getErrorCode(), call.getErrorDescription(), call.getRawPayload()); } else if (message instanceof CallErrorMessage) { failedFlag = true; CallErrorMessage call = (CallErrorMessage) message; @@ -297,6 +381,9 @@ public void receivedMessage(Object input) { } else if (message instanceof CallMessage) { CallMessage call = (CallMessage) message; events.onCall(call.getId(), call.getAction(), call.getPayload()); + } else if (message instanceof SendMessage) { + SendMessage send = (SendMessage) message; + events.onSend(send.getId(), send.getAction(), send.getPayload()); } } @@ -318,7 +405,7 @@ private Object getRetryMessage() { } /** - * Check if a error message was received. + * Check if an error message was received. * * @return whether a fail flag has been raised. */ diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/CommunicatorEvents.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/CommunicatorEvents.java index 3c3572ad..4f3862aa 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/CommunicatorEvents.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/CommunicatorEvents.java @@ -66,6 +66,31 @@ public interface CommunicatorEvents { */ void onError(String id, String errorCode, String errorDescription, Object payload); + /** + * Handle call result error. + * + *

Hint: Use the id to identify the original call result. You can use {@link Communicator}s + * unpackPayload method. + * + * @param id unique id used to identify the original call result. + * @param errorCode short text to categorize the error. + * @param errorDescription a longer text to describe the error. + * @param payload Object payload attached to the error. + */ + void onCallResultError(String id, String errorCode, String errorDescription, Object payload); + + /** + * Handle send. + * + *

Hint: Use the action name to identify the feature, you can then choose to use {@link + * Communicator}s unpackPayload method. + * + * @param id unique id. + * @param action action name used to identify the feature. + * @param payload raw payload. + */ + void onSend(String id, String action, Object payload); + /** The connection was disconnected. */ void onDisconnected(); diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/FeatureRepository.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/FeatureRepository.java index c83667d7..054fd79c 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/FeatureRepository.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/FeatureRepository.java @@ -73,7 +73,9 @@ public void addFeatureProfile(Profile profile) { public void addFeature(Feature feature) { actionMap.put(feature.getAction(), feature); classMap.put(feature.getRequestType(), feature); - classMap.put(feature.getConfirmationType(), feature); + if (feature.getConfirmationType() != null) { + classMap.put(feature.getConfirmationType(), feature); + } } /** diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java index 5f71357a..cdd0cee1 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java @@ -47,5 +47,7 @@ public interface ISession { boolean completePendingPromise(String id, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException; + void sendMessage(String action, Request payload, String uuid); + void close(); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Promise.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Promise.java new file mode 100644 index 00000000..7882fa36 --- /dev/null +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Promise.java @@ -0,0 +1,69 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Copyright (C) 2025 Robert Schlabbach + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.BiConsumer; +import javax.annotation.Nonnull; + +/** + * A variation of {@link CompletableFuture} which allows holders of the original class instance to + * {@link #join()} the completion of the last action added using whenComplete[async](). + */ +public class Promise extends CompletableFuture { + private volatile CompletableFuture completion = this; + + @Override + public T join() { + return completion != this ? completion.join() : super.join(); + } + + @Override + @Nonnull + public CompletableFuture whenComplete( + @Nonnull BiConsumer action) { + completion = super.whenComplete(action); + return this; + } + + @Override + @Nonnull + public CompletableFuture whenCompleteAsync( + @Nonnull BiConsumer action) { + completion = super.whenCompleteAsync(action); + return this; + } + + @Override + @Nonnull + public CompletableFuture whenCompleteAsync( + @Nonnull BiConsumer action, Executor executor) { + completion = super.whenCompleteAsync(action, executor); + return this; + } +} diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/PromiseFulfiller.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/PromiseFulfiller.java index 6c52be66..a3538af6 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/PromiseFulfiller.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/PromiseFulfiller.java @@ -28,8 +28,11 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import java.util.concurrent.CompletableFuture; +import javax.annotation.Nullable; public interface PromiseFulfiller { void fulfill( - CompletableFuture promise, SessionEvents eventHandler, Request request); + @Nullable CompletableFuture promise, + SessionEvents eventHandler, + Request request); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/PromiseRepository.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/PromiseRepository.java index 83318dc1..8b658472 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/PromiseRepository.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/PromiseRepository.java @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal public class PromiseRepository implements IPromiseRepository { - private Map> promises; + private final Map> promises; public PromiseRepository() { this.promises = new ConcurrentHashMap<>(); @@ -47,7 +47,7 @@ public PromiseRepository() { * @return call back {@link CompletableFuture} */ public CompletableFuture createPromise(String uniqueId) { - CompletableFuture promise = new CompletableFuture<>(); + CompletableFuture promise = new Promise<>(); promises.put(uniqueId, promise); return promise; } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/RequestDispatcher.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/RequestDispatcher.java index 7ba97fd3..ee657a18 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/RequestDispatcher.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/RequestDispatcher.java @@ -28,6 +28,7 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import java.util.concurrent.CompletableFuture; +import javax.annotation.Nullable; public class RequestDispatcher implements IRequestDispactcher { @@ -38,7 +39,7 @@ public RequestDispatcher(PromiseFulfiller fulfiller) { this.fulfiller = fulfiller; } - public void handleRequest(CompletableFuture promise, Request request) { + public void handleRequest(@Nullable CompletableFuture promise, Request request) { fulfiller.fulfill(promise, eventHandler, request); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java index 4db67320..b0dc3841 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java @@ -33,7 +33,9 @@ of this software and associated documentation files (the "Software"), to deal import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import java.util.concurrent.ConcurrentHashMap; +import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,12 +91,24 @@ public void newSession(ISession session, SessionInformation information) { session.accept( new SessionEvents() { @Override - public void handleConfirmation(String uniqueId, Confirmation confirmation) { - + public void handleConfirmation( + String uniqueId, @Nullable Confirmation confirmation) { Optional> promiseOptional = promiseRepository.getPromise(uniqueId); if (promiseOptional.isPresent()) { promiseOptional.get().complete(confirmation); + // join completion to catch and rethrow any exceptions thrown in the last + // added completion action, so that a CALLRESULTERROR may be produced from it. + try { + promiseOptional.get().join(); + } catch (CompletionException e) { + Throwable cause = e.getCause() != null ? e.getCause() : e; + if (cause instanceof RuntimeException) { + throw (RuntimeException) cause; + } else { + throw new RuntimeException(cause); + } + } } else { logger.debug("Promise not found for confirmation {}", confirmation); } @@ -144,6 +158,24 @@ public void handleError( } } + @Override + public void handleConfirmationError( + String uniqueId, String errorCode, String errorDescription, Object payload) { + logger.error( + "Received an error which occurred while processing a call result: " + + "uniqueId {}: errorCode: {}, errorDescription: {}", + uniqueId, + errorCode, + errorDescription); + Optional sessionIdOptional = getSessionID(session); + if (sessionIdOptional.isPresent()) { + serverEvents.confirmationError( + sessionIdOptional.get(), uniqueId, errorCode, errorDescription, payload); + } else { + logger.warn("Active session not found for {}", session.getSessionId()); + } + } + @Override public void handleConnectionClosed() { Optional sessionIdOptional = getSessionID(session); @@ -190,9 +222,10 @@ public void close() { * * @param sessionIndex Session index of the client. * @param request Request for the client. - * @return Callback handler for when the client responds. + * @return call back object, will be fulfilled with confirmation when received or {@code null} if + * the request has no confirmation, or exceptionally if a local or remote error occurred. * @throws UnsupportedFeatureException Thrown if the feature isn't among the list of supported - * featured. + * features. * @throws OccurenceConstraintException Thrown if the request isn't valid. */ public CompletableFuture send(UUID sessionIndex, Request request) @@ -226,7 +259,11 @@ public CompletableFuture send(UUID sessionIndex, Request request) promiseRepository.removePromise(requestUuid); }); - session.sendRequest(featureOptional.get().getAction(), request, requestUuid); + if (featureOptional.get().getConfirmationType() != null) { + session.sendRequest(featureOptional.get().getAction(), request, requestUuid); + } else { + session.sendMessage(featureOptional.get().getAction(), request, requestUuid); + } return promise; } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java index 83eda55e..45e495ca 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java @@ -35,4 +35,11 @@ void authenticateSession(SessionInformation information, String username, byte[] void newSession(UUID sessionIndex, SessionInformation information); void lostSession(UUID sessionIndex); + + default void confirmationError( + UUID sessionIndex, + String uniqueId, + String errorCode, + String errorDescription, + Object payload) {}; } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java index aa4f4c2b..50a2f195 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java @@ -27,17 +27,18 @@ of this software and associated documentation files (the "Software"), to deal */ import static eu.chargetime.ocpp.ProtocolVersion.OCPP1_6; +import static eu.chargetime.ocpp.ProtocolVersion.OCPP2_0_1; import eu.chargetime.ocpp.feature.Feature; import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import eu.chargetime.ocpp.utilities.MoreObjects; -import java.util.AbstractMap; -import java.util.HashMap; +import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Map; import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,10 +55,9 @@ public class Session implements ISession { private final Queue queue; private final RequestDispatcher dispatcher; private final IFeatureRepository featureRepository; + private final Map>> + pendingPromises = new ConcurrentHashMap<>(); private SessionEvents events; - private final Map< - String, AbstractMap.SimpleImmutableEntry>> - pendingPromises = new HashMap<>(); /** * Handles required injections. @@ -106,6 +106,26 @@ public void sendRequest(String action, Request payload, String uuid) { communicator.sendCall(uuid, action, payload); } + /** + * Send a {@link Request} which has no confirmation. + * + * @param action action name to identify the feature. + * @param payload the {@link Request} payload to send + * @param uuid unique identification to identify the request + */ + public void sendMessage(String action, Request payload, String uuid) { + if (isSendCapableRPC()) { + communicator.send(uuid, action, payload); + events.handleConfirmation(uuid, null); + } else { + events.handleError( + uuid, + "MessageTypeNotSupported", + "SEND message type is not supported in " + featureRepository.getProtocolVersion(), + payload); + } + } + /** * Store a {@link Request} and get the unique id. * @@ -143,7 +163,7 @@ private Optional> getConfirmationType(String uniqu if (requestOptional.isPresent()) { Optional featureOptional = featureRepository.findFeature(requestOptional.get()); if (featureOptional.isPresent()) { - return Optional.of(featureOptional.get().getConfirmationType()); + return Optional.ofNullable(featureOptional.get().getConfirmationType()); } else { logger.debug("Feature for request with id: {} not found in session: {}", uniqueId, this); throw new UnsupportedFeatureException( @@ -182,6 +202,8 @@ public void accept(SessionEvents eventHandler) { private class CommunicatorEventHandler implements CommunicatorEvents { private static final String OCCURRENCE_CONSTRAINT_VIOLATION = "Payload for Action is syntactically correct but at least one of the fields violates occurrence constraints"; + private static final String PROPERTY_CONSTRAINT_VIOLATION = + "Payload is syntactically correct but at least one field contains an invalid value"; private static final String INTERNAL_ERROR = "An internal error occurred and the receiver was not able to process the requested Action successfully"; private static final String UNABLE_TO_PROCESS = "Unable to process action"; @@ -197,36 +219,53 @@ public void onCallResult(String id, String action, Object payload) { if (confirmation.validate()) { events.handleConfirmation(id, confirmation); } else { - communicator.sendCallError( - id, - action, - isLegacyRPC() ? "OccurenceConstraintViolation" : "OccurrenceConstraintViolation", - OCCURRENCE_CONSTRAINT_VIOLATION); + logger.warn(PROPERTY_CONSTRAINT_VIOLATION); + if (isCallResultErrorCapableRPC()) { + communicator.sendCallResultError( + id, action, "PropertyConstraintViolation", PROPERTY_CONSTRAINT_VIOLATION); + } } } else { logger.warn(INTERNAL_ERROR); - communicator.sendCallError(id, action, "InternalError", INTERNAL_ERROR); + if (isCallResultErrorCapableRPC()) { + communicator.sendCallResultError(id, action, "InternalError", INTERNAL_ERROR); + } + } + } catch (OccurenceConstraintException ex) { + logger.warn(ex.getMessage(), ex); + if (isCallResultErrorCapableRPC()) { + communicator.sendCallResultError( + id, action, "OccurrenceConstraintViolation", ex.getMessage()); } } catch (PropertyConstraintException ex) { logger.warn(ex.getMessage(), ex); - communicator.sendCallError(id, action, "TypeConstraintViolation", ex.getMessage()); + if (isCallResultErrorCapableRPC()) { + communicator.sendCallResultError( + id, action, "PropertyConstraintViolation", ex.getMessage()); + } + } catch (SecurityErrorException ex) { + logger.warn(ex.getMessage(), ex); + if (isCallResultErrorCapableRPC()) { + communicator.sendCallResultError(id, action, "SecurityError", ex.getMessage()); + } } catch (UnsupportedFeatureException ex) { - logger.warn(INTERNAL_ERROR, ex); - communicator.sendCallError(id, action, "InternalError", INTERNAL_ERROR); + logger.warn(ex.getMessage(), ex); + if (isCallResultErrorCapableRPC()) { + communicator.sendCallResultError(id, action, "NotSupported", ex.getMessage()); + } } catch (Exception ex) { - logger.warn(UNABLE_TO_PROCESS, ex); - communicator.sendCallError( - id, - action, - isLegacyRPC() ? "FormationViolation" : "FormatViolation", - UNABLE_TO_PROCESS); + logger.warn(ex.getMessage(), ex); + if (isCallResultErrorCapableRPC()) { + communicator.sendCallResultError( + id, action, "InternalError", ex.getClass().getSimpleName() + ": " + ex.getMessage()); + } } } @Override public synchronized void onCall(String id, String action, Object payload) { Optional featureOptional = featureRepository.findFeature(action); - if (!featureOptional.isPresent()) { + if (!featureOptional.isPresent() || featureOptional.get().getConfirmationType() == null) { communicator.sendCallError( id, action, "NotImplemented", "Requested Action is not known by receiver"); } else { @@ -268,6 +307,45 @@ public void onError(String id, String errorCode, String errorDescription, Object events.handleError(id, errorCode, errorDescription, payload); } + @Override + public void onCallResultError( + String id, String errorCode, String errorDescription, Object payload) { + if (!isCallResultErrorCapableRPC()) { + logger.warn( + "Received CALLRESULTERROR message type is not supported in {}", + featureRepository.getProtocolVersion()); + return; + } + events.handleConfirmationError(id, errorCode, errorDescription, payload); + } + + @Override + public void onSend(String id, String action, Object payload) { + if (!isSendCapableRPC()) { + logger.warn( + "Received SEND message type is not supported in {}", + featureRepository.getProtocolVersion()); + return; + } + Optional featureOptional = featureRepository.findFeature(action); + if (!featureOptional.isPresent() || featureOptional.get().getConfirmationType() != null) { + logger.warn("Requested Action {} is not known by receiver", action); + } else { + try { + Request request = + communicator.unpackPayload(payload, featureOptional.get().getRequestType()); + request.setOcppMessageId(id); + if (request.validate()) { + dispatcher.handleRequest(null, request); + } + } catch (PropertyConstraintException | SecurityErrorException ex) { + logger.warn(ex.getMessage(), ex); + } catch (Exception ex) { + logger.warn(UNABLE_TO_PROCESS, ex); + } + } + } + @Override public void onDisconnected() { events.handleConnectionClosed(); @@ -284,28 +362,36 @@ private boolean isLegacyRPC() { } } + private boolean isCallResultErrorCapableRPC() { + ProtocolVersion protocolVersion = featureRepository.getProtocolVersion(); + return protocolVersion != null + && !protocolVersion.equals(OCPP1_6) + && !protocolVersion.equals(OCPP2_0_1); + } + + private boolean isSendCapableRPC() { + ProtocolVersion protocolVersion = featureRepository.getProtocolVersion(); + return protocolVersion != null + && !protocolVersion.equals(OCPP1_6) + && !protocolVersion.equals(OCPP2_0_1); + } + private void addPendingPromise( String id, String action, CompletableFuture promise) { - synchronized (pendingPromises) { - pendingPromises.put(id, new AbstractMap.SimpleImmutableEntry<>(action, promise)); - } + pendingPromises.put(id, new SimpleImmutableEntry<>(action, promise)); } @Override public boolean completePendingPromise(String id, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { - AbstractMap.SimpleImmutableEntry> promiseAction = null; - // synchronization prevents from confirming one promise more than once, as we remove found - // promise - synchronized (pendingPromises) { - promiseAction = pendingPromises.get(id); - if (promiseAction == null) return false; - // remove promise from store - pendingPromises.remove(id); + SimpleImmutableEntry> promiseAction = + pendingPromises.remove(id); + if (promiseAction == null) { + return false; } // check confirmation type, it has to correspond to original request type Optional featureOptional = featureRepository.findFeature(promiseAction.getKey()); - if (featureOptional.isPresent()) { + if (featureOptional.isPresent() && featureOptional.get().getConfirmationType() != null) { if (!featureOptional.get().getConfirmationType().isInstance(confirmation)) { throw new OccurenceConstraintException(); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/SessionEvents.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/SessionEvents.java index dd9b9eb9..aa6a6297 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/SessionEvents.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/SessionEvents.java @@ -2,6 +2,7 @@ import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; +import javax.annotation.Nullable; /* ChargeTime.eu - Java-OCA-OCPP @@ -37,16 +38,17 @@ public interface SessionEvents { * Handle a {@link Confirmation} to a {@link Request}. * * @param uniqueId the unique id used for the {@link Request}. - * @param confirmation the {@link Confirmation} to the {@link Request}. + * @param confirmation the {@link Confirmation} to the {@link Request} or {@code null} if none. */ - void handleConfirmation(String uniqueId, Confirmation confirmation); + void handleConfirmation(String uniqueId, @Nullable Confirmation confirmation); /** - * Handle a incoming {@link Request}. + * Handle an incoming {@link Request}. * * @param request the {@link Request}. - * @return a {@link Confirmation} to send as a response. + * @return a {@link Confirmation} to send as a response or {@code null} if none to send. */ + @Nullable Confirmation handleRequest(Request request) throws UnsupportedFeatureException; /** @@ -60,18 +62,29 @@ boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException; /** - * Handle a error to a {@link Request}. + * Handle an error to a {@link Request}. * - * @param uniqueId the unique identifier for the {@link Request}. + * @param uniqueId the unique identifier of the {@link Request}. * @param errorCode string to indicate the error. * @param errorDescription description of the error. * @param payload a raw payload. */ void handleError(String uniqueId, String errorCode, String errorDescription, Object payload); + /** + * Handle an error to a {@link Confirmation}. + * + * @param uniqueId the unique identifier of the {@link Confirmation}. + * @param errorCode string to indicate the error. + * @param errorDescription description of the error. + * @param payload a raw payload. + */ + void handleConfirmationError( + String uniqueId, String errorCode, String errorDescription, Object payload); + /** Handle a closed connection. */ void handleConnectionClosed(); - /** Handle a opened connection. */ + /** Handle an opened connection. */ void handleConnectionOpened(); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/SimplePromiseFulfiller.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/SimplePromiseFulfiller.java index 4750ab43..40fd10fe 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/SimplePromiseFulfiller.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/SimplePromiseFulfiller.java @@ -28,6 +28,7 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import java.util.concurrent.CompletableFuture; +import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,16 +37,20 @@ public class SimplePromiseFulfiller implements PromiseFulfiller { @Override public void fulfill( - CompletableFuture promise, SessionEvents eventHandler, Request request) { + @Nullable CompletableFuture promise, + SessionEvents eventHandler, + Request request) { try { Confirmation conf = eventHandler.handleRequest(request); - // Confirmation may be null, in this case asynchronous execution is assumed + // Confirmation is optional, for asynchronous completion or requests without confirmation if (conf != null) { eventHandler.asyncCompleteRequest(request.getOcppMessageId(), conf); } } catch (Exception ex) { - logger.warn("fulfillPromis() failed", ex); - promise.completeExceptionally(ex); + logger.warn("fulfillPromise() failed", ex); + if (promise != null) { + promise.completeExceptionally(ex); + } } } } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/feature/Feature.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/feature/Feature.java index 77a56e89..63eb5794 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/feature/Feature.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/feature/Feature.java @@ -28,7 +28,9 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; +import java.lang.reflect.Type; import java.util.UUID; +import javax.annotation.Nullable; /** * Abstract class. Feature ties {@link Request} and {@link Confirmation} types together with an @@ -40,22 +42,23 @@ public interface Feature { * * @param sessionIndex source of the request. * @param request the {@link Request} to be handled. - * @return the {@link Confirmation} to be send back. + * @return the {@link Confirmation} to be sent back. */ Confirmation handleRequest(UUID sessionIndex, Request request); /** - * Get the {@link Request} {@link java.lang.reflect.Type} for the feature. + * Get the {@link Request} {@link Type} for the feature. * - * @return the {@link Request} {@link java.lang.reflect.Type} + * @return the {@link Request} {@link Type} */ Class getRequestType(); /** - * Get the {@link Confirmation} {@link java.lang.reflect.Type} for the feature. + * Get the {@link Confirmation} {@link Type} for the feature. * - * @return the {@link Confirmation} {@link java.lang.reflect.Type}. + * @return the {@link Confirmation} {@link Type} or {@code null} if the feature has none. */ + @Nullable Class getConfirmationType(); /** diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/CallErrorMessage.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/CallErrorMessage.java index 29d83c46..c3e890fe 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/CallErrorMessage.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/CallErrorMessage.java @@ -25,6 +25,8 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import eu.chargetime.ocpp.utilities.MoreObjects; + public class CallErrorMessage extends Message { private String errorCode; private String errorDescription; @@ -53,4 +55,14 @@ public String getRawPayload() { public void setRawPayload(String rawPayload) { this.rawPayload = rawPayload; } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", getId()) + .add("errorCode", errorCode) + .add("errorDescription", errorDescription) + .add("rawPayload", rawPayload) + .toString(); + } } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/CallResultErrorMessage.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/CallResultErrorMessage.java new file mode 100644 index 00000000..520ec9a0 --- /dev/null +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/CallResultErrorMessage.java @@ -0,0 +1,30 @@ +package eu.chargetime.ocpp.model; + +/* +ChargeTime.eu - Java-OCA-OCPP +Copyright (C) 2015-2016 Thomas Volden + +MIT License + +Copyright (C) 2016-2018 Thomas Volden + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +public class CallResultErrorMessage extends CallErrorMessage {} diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/SendMessage.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/SendMessage.java new file mode 100644 index 00000000..4061e367 --- /dev/null +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/SendMessage.java @@ -0,0 +1,30 @@ +package eu.chargetime.ocpp.model; + +/* +ChargeTime.eu - Java-OCA-OCPP +Copyright (C) 2015-2016 Thomas Volden + +MIT License + +Copyright (C) 2016-2018 Thomas Volden + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +public class SendMessage extends Message {} diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java index 7c7defc6..a0b056b5 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java @@ -71,6 +71,7 @@ public void setup() { when(promiseRepository.createPromise(any())) .then(invocation -> new CompletableFuture()); when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); + when(feature.getConfirmationType()).thenAnswer(invocation -> Confirmation.class); when(session.getFeatureRepository()).thenReturn(featureRepository); when(session.storeRequest(any())).then(invocation -> UUID.randomUUID().toString()); client = new Client(session, promiseRepository); diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java index b506f608..38dde140 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java @@ -92,6 +92,17 @@ protected Object makeCallError( return null; } + @Override + protected Object makeCallResultError( + String uniqueId, String action, String errorCode, String errorDescription) { + return null; + } + + @Override + protected Object makeSend(String uniqueId, String action, Object payload) { + return uniqueId; + } + @Override protected Message parse(Object message) { return null; diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java index 01cda803..791028e8 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java @@ -87,6 +87,7 @@ public void setup() { when(promiseRepository.createPromise(any())) .then(invocation -> new CompletableFuture()); when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); + when(feature.getConfirmationType()).thenAnswer(invocation -> Confirmation.class); when(session.getFeatureRepository()).thenReturn(featureRepository); when(session.storeRequest(any())).thenAnswer(invocation -> UUID.randomUUID().toString()); server = new Server(listener, promiseRepository); diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java index 10069f22..e7ed4efe 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java @@ -62,6 +62,7 @@ public class SessionTest { @Before public void setup() throws Exception { when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); + when(feature.getConfirmationType()).thenAnswer(invocation -> Confirmation.class); session = new Session(communicator, queue, fulfiller, featureRepository); doAnswer(invocation -> eventHandler = invocation.getArgument(1, CommunicatorEvents.class)) .when(communicator) diff --git a/ocpp-json/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java b/ocpp-json/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java index 5c068d40..98a0323b 100644 --- a/ocpp-json/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java +++ b/ocpp-json/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java @@ -3,9 +3,11 @@ import com.google.gson.*; import eu.chargetime.ocpp.model.CallErrorMessage; import eu.chargetime.ocpp.model.CallMessage; +import eu.chargetime.ocpp.model.CallResultErrorMessage; import eu.chargetime.ocpp.model.CallResultMessage; import eu.chargetime.ocpp.model.Exclude; import eu.chargetime.ocpp.model.Message; +import eu.chargetime.ocpp.model.SendMessage; import java.lang.reflect.Type; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -71,15 +73,21 @@ public class JSONCommunicator extends Communicator { private static final int INDEX_CALLERROR_DESCRIPTION = 3; private static final int INDEX_CALLERROR_PAYLOAD = 4; + private static final int TYPENUMBER_CALLRESULTERROR = 5; + private static final int INDEX_CALLRESULTERROR_ERRORCODE = 2; + private static final int INDEX_CALLRESULTERROR_DESCRIPTION = 3; + private static final int INDEX_CALLRESULTERROR_PAYLOAD = 4; + + private static final int TYPENUMBER_SEND = 6; + private static final int INDEX_SEND_ACTION = 2; + private static final int INDEX_SEND_PAYLOAD = 3; + private static final int INDEX_UNIQUEID = 1; private static final String CALL_FORMAT = "[2,\"%s\",\"%s\",%s]"; private static final String CALLRESULT_FORMAT = "[3,\"%s\",%s]"; private static final String CALLERROR_FORMAT = "[4,\"%s\",\"%s\",\"%s\",%s]"; - private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - private static final String DATE_FORMAT_WITH_MS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; - private static final int DATE_FORMAT_WITH_MS_LENGTH = 24; - - private boolean hasLongDateFormat = false; + private static final String CALLRESULTERROR_FORMAT = "[5,\"%s\",\"%s\",\"%s\",%s]"; + private static final String SEND_FORMAT = "[6,\"%s\",\"%s\",%s]"; /** * Handle required injections. @@ -117,7 +125,7 @@ public ZonedDateTime deserialize( } } - private static Gson gson; + private static final Gson gson; static { GsonBuilder builder = new GsonBuilder(); @@ -139,7 +147,7 @@ public boolean shouldSkipField(FieldAttributes field) { } @Override - public T unpackPayload(Object payload, Class type) throws Exception { + public T unpackPayload(Object payload, Class type) { return gson.fromJson(payload.toString(), type); } @@ -156,7 +164,7 @@ protected Object makeCallResult(String uniqueId, String action, Object payload) @Override protected Object makeCall(String uniqueId, String action, Object payload) { String message = String.format(CALL_FORMAT, uniqueId, action, payload); - logger.trace("Send a message: {}", message); + logger.trace("Send a request: {}", message); return message; } @@ -166,36 +174,63 @@ protected Object makeCallError( return String.format(CALLERROR_FORMAT, uniqueId, errorCode, errorDescription, "{}"); } + @Override + protected Object makeCallResultError( + String uniqueId, String action, String errorCode, String errorDescription) { + return String.format(CALLRESULTERROR_FORMAT, uniqueId, errorCode, errorDescription, "{}"); + } + + @Override + protected Object makeSend(String uniqueId, String action, Object payload) { + String message = String.format(SEND_FORMAT, uniqueId, action, payload); + logger.trace("Send a message: {}", message); + return message; + } + @Override protected Message parse(Object json) { Message message; - JsonParser parser = new JsonParser(); - JsonArray array = parser.parse(json.toString()).getAsJsonArray(); + JsonArray array = JsonParser.parseString(json.toString()).getAsJsonArray(); String messageId = "-1"; try { messageId = array.get(INDEX_UNIQUEID).getAsString(); - if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALL) { - message = new CallMessage(); - message.setAction(array.get(INDEX_CALL_ACTION).getAsString()); - message.setPayload(array.get(INDEX_CALL_PAYLOAD).toString()); - } else if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALLRESULT) { - message = new CallResultMessage(); - message.setPayload(array.get(INDEX_CALLRESULT_PAYLOAD).toString()); - } else if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALLERROR) { - message = new CallErrorMessage(); - ((CallErrorMessage) message) - .setErrorCode(array.get(INDEX_CALLERROR_ERRORCODE).getAsString()); - ((CallErrorMessage) message) - .setErrorDescription(array.get(INDEX_CALLERROR_DESCRIPTION).getAsString()); - ((CallErrorMessage) message).setRawPayload(array.get(INDEX_CALLERROR_PAYLOAD).toString()); - } else { - logger.error("Unknown message type of message: {}", json.toString()); - sendCallError(messageId, null, "MessageTypeNotSupported", null); - return null; + switch (array.get(INDEX_MESSAGEID).getAsInt()) { + case TYPENUMBER_CALL: + message = new CallMessage(); + message.setAction(array.get(INDEX_CALL_ACTION).getAsString()); + message.setPayload(array.get(INDEX_CALL_PAYLOAD).toString()); + break; + case TYPENUMBER_CALLRESULT: + message = new CallResultMessage(); + message.setPayload(array.get(INDEX_CALLRESULT_PAYLOAD).toString()); + break; + case TYPENUMBER_CALLERROR: + CallErrorMessage error = new CallErrorMessage(); + error.setErrorCode(array.get(INDEX_CALLERROR_ERRORCODE).getAsString()); + error.setErrorDescription(array.get(INDEX_CALLERROR_DESCRIPTION).getAsString()); + error.setRawPayload(array.get(INDEX_CALLERROR_PAYLOAD).toString()); + message = error; + break; + case TYPENUMBER_CALLRESULTERROR: + CallResultErrorMessage resultError = new CallResultErrorMessage(); + resultError.setErrorCode(array.get(INDEX_CALLRESULTERROR_ERRORCODE).getAsString()); + resultError.setErrorDescription( + array.get(INDEX_CALLRESULTERROR_DESCRIPTION).getAsString()); + resultError.setRawPayload(array.get(INDEX_CALLRESULTERROR_PAYLOAD).toString()); + message = resultError; + break; + case TYPENUMBER_SEND: + message = new SendMessage(); + message.setAction(array.get(INDEX_SEND_ACTION).getAsString()); + message.setPayload(array.get(INDEX_SEND_PAYLOAD).toString()); + break; + default: + logger.error("Unknown message type of message: {}", json); + return null; } } catch (Exception e) { - logger.error("Exception while parsing message: {}", json.toString()); + logger.error("Exception while parsing message: {}", json); sendCallError(messageId, null, "RpcFrameworkError", e.getMessage()); return null; } diff --git a/ocpp-v1_6-soap/src/main/java/eu/chargetime/ocpp/SOAPCommunicator.java b/ocpp-v1_6-soap/src/main/java/eu/chargetime/ocpp/SOAPCommunicator.java index 80790107..2bb1383e 100644 --- a/ocpp-v1_6-soap/src/main/java/eu/chargetime/ocpp/SOAPCommunicator.java +++ b/ocpp-v1_6-soap/src/main/java/eu/chargetime/ocpp/SOAPCommunicator.java @@ -166,6 +166,17 @@ protected Object makeCallError( return message; } + @Override + protected Object makeCallResultError( + String uniqueId, String action, String errorCode, String errorDescription) { + throw new UnsupportedOperationException("CALLRESULTERROR is not specified for SOAP"); + } + + @Override + protected Object makeSend(String uniqueId, String action, Object payload) { + throw new UnsupportedOperationException("SEND is not specified for SOAP"); + } + private SOAPMessage createMessage( String uniqueId, String action, Document payload, boolean isResponse) { SOAPMessage message = null; diff --git a/ocpp-v1_6-soap/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java b/ocpp-v1_6-soap/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java index 4c78300b..140fe97c 100644 --- a/ocpp-v1_6-soap/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java +++ b/ocpp-v1_6-soap/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java @@ -31,6 +31,7 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.core.RegistrationStatus; import eu.chargetime.ocpp.utilities.TimeoutTimer; import java.util.UUID; +import javax.annotation.Nullable; public class TimeoutSessionDecorator implements ISession { @@ -103,6 +104,11 @@ public boolean completePendingPromise(String id, Confirmation confirmation) return this.session.completePendingPromise(id, confirmation); } + @Override + public void sendMessage(String action, Request payload, String uuid) { + this.session.sendMessage(action, payload, uuid); + } + @Override public void close() { this.session.close(); @@ -111,7 +117,7 @@ public void close() { private SessionEvents createEventHandler(SessionEvents eventHandler) { return new SessionEvents() { @Override - public void handleConfirmation(String uniqueId, Confirmation confirmation) { + public void handleConfirmation(String uniqueId, @Nullable Confirmation confirmation) { resetTimer(); eventHandler.handleConfirmation(uniqueId, confirmation); } @@ -144,6 +150,12 @@ public void handleError( eventHandler.handleError(uniqueId, errorCode, errorDescription, payload); } + @Override + public void handleConfirmationError( + String uniqueId, String errorCode, String errorDescription, Object payload) { + eventHandler.handleConfirmationError(uniqueId, errorCode, errorDescription, payload); + } + @Override public void handleConnectionClosed() { eventHandler.handleConnectionClosed(); diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/FunctionFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/FunctionFeature.java index 40ea5526..3a0f493e 100644 --- a/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/FunctionFeature.java +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/FunctionFeature.java @@ -30,6 +30,7 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import java.util.UUID; +import javax.annotation.Nullable; public abstract class FunctionFeature implements Feature { @@ -49,8 +50,9 @@ public FunctionFeature(Function ownerFunction) { * * @param sessionIndex source of the request. * @param request the {@link Request} to be handled. - * @return the {@link Confirmation} to be send back. + * @return the {@link Confirmation} to be sent back, or {@code null} if none to be sent back. */ + @Nullable public Confirmation handleRequest(UUID sessionIndex, Request request) { return function.handleRequest(sessionIndex, request); } diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/function/Function.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/function/Function.java index 252e6cbf..af725db8 100644 --- a/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/function/Function.java +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/function/Function.java @@ -32,6 +32,7 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import java.util.UUID; +import javax.annotation.Nullable; /** Interface used for Feature Profiles. */ public interface Function { @@ -48,7 +49,8 @@ public interface Function { * * @param sessionIndex source of the request. * @param request the {@link Request} to be handled. - * @return the {@link Confirmation} to be send. + * @return the {@link Confirmation} to be sent or {@code null} if none to be sent. */ + @Nullable Confirmation handleRequest(UUID sessionIndex, Request request); } diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyPeriodicEventStreamFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyPeriodicEventStreamFeature.java new file mode 100644 index 00000000..7fa179e2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/NotifyPeriodicEventStreamFeature.java @@ -0,0 +1,53 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v21.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.NotifyPeriodicEventStream; + +public class NotifyPeriodicEventStreamFeature extends FunctionFeature { + + public NotifyPeriodicEventStreamFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyPeriodicEventStream.class; + } + + @Override + public Class getConfirmationType() { + return null; + } + + @Override + public String getAction() { + return "NotifyPeriodicEventStream"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsFunction.java index 5e23660f..85e5b380 100644 --- a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsFunction.java +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ClientDiagnosticsFunction.java @@ -54,6 +54,7 @@ public ClientDiagnosticsFunction(ClientDiagnosticsEventHandler eventHandler) { features.add(new LogStatusNotificationFeature(null)); features.add(new NotifyCustomerInformationFeature(null)); features.add(new NotifyMonitoringReportFeature(null)); + features.add(new NotifyPeriodicEventStreamFeature(null)); features.add(new OpenPeriodicEventStreamFeature(null)); features.add(new SetMonitoringBaseFeature(this)); features.add(new SetMonitoringLevelFeature(this)); @@ -135,6 +136,20 @@ public NotifyMonitoringReportRequest createNotifyMonitoringReportRequest( return new NotifyMonitoringReportRequest(requestId, seqNo, generatedAt); } + /** + * Create a client {@link NotifyPeriodicEventStream} with all required fields. + * + * @param data data + * @param id Id of stream. + * @param pending Number of data elements still pending to be sent. + * @param basetime Base timestamp to add to time offset of values. + * @return an instance of {@link NotifyPeriodicEventStream} + */ + public NotifyPeriodicEventStream createNotifyPeriodicEventStream( + StreamDataElement[] data, Integer id, Integer pending, ZonedDateTime basetime) { + return new NotifyPeriodicEventStream(data, id, pending, basetime); + } + /** * Create a client {@link OpenPeriodicEventStreamRequest} with all required fields. * diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsEventHandler.java index 95e71fb2..17ed01b7 100644 --- a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsEventHandler.java +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsEventHandler.java @@ -62,6 +62,14 @@ NotifyCustomerInformationResponse handleNotifyCustomerInformationRequest( NotifyMonitoringReportResponse handleNotifyMonitoringReportRequest( UUID sessionIndex, NotifyMonitoringReportRequest request); + /** + * Handle a {@link NotifyPeriodicEventStream}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyPeriodicEventStream} to handle. + */ + void handleNotifyPeriodicEventStream(UUID sessionIndex, NotifyPeriodicEventStream request); + /** * Handle a {@link OpenPeriodicEventStreamRequest} and return a {@link * OpenPeriodicEventStreamResponse}. diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsFunction.java index 30f4d280..d7ea8d6c 100644 --- a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsFunction.java +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/feature/function/ServerDiagnosticsFunction.java @@ -53,6 +53,7 @@ public ServerDiagnosticsFunction(ServerDiagnosticsEventHandler eventHandler) { features.add(new LogStatusNotificationFeature(this)); features.add(new NotifyCustomerInformationFeature(this)); features.add(new NotifyMonitoringReportFeature(this)); + features.add(new NotifyPeriodicEventStreamFeature(this)); features.add(new OpenPeriodicEventStreamFeature(this)); features.add(new SetMonitoringBaseFeature(null)); features.add(new SetMonitoringLevelFeature(null)); @@ -75,6 +76,10 @@ public Confirmation handleRequest(UUID sessionIndex, Request request) { } else if (request instanceof NotifyMonitoringReportRequest) { return eventHandler.handleNotifyMonitoringReportRequest( sessionIndex, (NotifyMonitoringReportRequest) request); + } else if (request instanceof NotifyPeriodicEventStream) { + eventHandler.handleNotifyPeriodicEventStream( + sessionIndex, (NotifyPeriodicEventStream) request); + return null; } else if (request instanceof OpenPeriodicEventStreamRequest) { return eventHandler.handleOpenPeriodicEventStreamRequest( sessionIndex, (OpenPeriodicEventStreamRequest) request); diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPeriodicEventStream.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPeriodicEventStream.java index fa06a578..33f9e868 100644 --- a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPeriodicEventStream.java +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v21/model/messages/NotifyPeriodicEventStream.java @@ -25,6 +25,7 @@ of this software and associated documentation files (the "Software"), to deal package eu.chargetime.ocpp.v21.model.messages; import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; import eu.chargetime.ocpp.utilities.MoreObjects; import eu.chargetime.ocpp.v21.model.types.CustomData; import eu.chargetime.ocpp.v21.model.types.StreamDataElement; @@ -39,7 +40,7 @@ of this software and associated documentation files (the "Software"), to deal *

OCPP 2.1 Edition 1 (c) OCA, Creative Commons Attribution-NoDerivatives 4.0 International * Public License */ -public final class NotifyPeriodicEventStream { +public final class NotifyPeriodicEventStream extends RequestWithId { /** data */ private StreamDataElement[] data; @@ -240,6 +241,7 @@ public NotifyPeriodicEventStream withCustomData(@Nullable CustomData customData) return this; } + @Override public boolean validate() { return isValidData(data) && isValidId(id) @@ -248,6 +250,11 @@ && isValidBasetime(basetime) && isValidCustomData(customData); } + @Override + public boolean transactionRelated() { + return false; + } + @Override public boolean equals(Object o) { if (this == o) { From 9c78e7b375cb4cfc07513002f43d2a85d2c8081c Mon Sep 17 00:00:00 2001 From: Robert Schlabbach Date: Wed, 17 Dec 2025 23:31:07 +0100 Subject: [PATCH 3/4] Add OCPP 2.1 Multi-Protocol and RPC tests Add multi-protocol integration tests for OCPP 1.6/2.0.1/2.1 protocol selection and exchanging BootNotification messages. Add integration tests for the OCPP 2.1 CALLRESULTERROR and SEND RPCs. --- .../chargetime/ocpp/test/DummyHandlers.java | 55 ++++ .../chargetime/ocpp/test/FakeChargePoint.java | 33 ++- .../eu/chargetime/ocpp/test/FakeCSMS.java | 4 + .../ocpp/test/FakeChargingStation.java | 8 + .../OCPP201MultiProtocolDummyHandlers.java | 7 +- .../test/OCPP201MultiProtocolFakeCSMS.java | 125 ++++++++- ...PP201MultiProtocolFakeChargingStation.java | 62 +++-- .../OCPP21MultiProtocolDummyHandlers.java | 118 ++++++++ .../test/OCPP21MultiProtocolFakeCSMS.java | 101 +++++++ ...CPP21MultiProtocolFakeChargingStation.java | 214 +++++++++++++++ .../OCPP201MultiProtocolIntegrationTest.java | 1 + .../OCPP21MultiProtocolIntegrationTest.java | 251 ++++++++++++++++++ 12 files changed, 954 insertions(+), 25 deletions(-) create mode 100644 ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolDummyHandlers.java create mode 100644 ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolFakeCSMS.java create mode 100644 ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolFakeChargingStation.java create mode 100644 ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolIntegrationTest.java diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java index 6654d9cd..06420672 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java @@ -28,6 +28,7 @@ of this software and associated documentation files (the "Software"), to deal */ import eu.chargetime.ocpp.AuthenticationException; +import eu.chargetime.ocpp.ProtocolVersion; import eu.chargetime.ocpp.ServerEvents; import eu.chargetime.ocpp.feature.profile.ServerCoreEventHandler; import eu.chargetime.ocpp.feature.profile.ServerFirmwareManagementEventHandler; @@ -50,12 +51,18 @@ of this software and associated documentation files (the "Software"), to deal public class DummyHandlers { private boolean riggedToFail; + private boolean riggedToSendInvalidResponse; private Request receivedRequest; private Confirmation receivedConfirmation; + private String receivedConfirmationError; + private String receivedConfirmationErrorDescription; + private String receivedConfirmationErrorUniqueId; + private String currentIdentifier; private UUID currentSessionIndex; + private ProtocolVersion currentProtocolVersion; public ServerCoreEventHandler createServerCoreEventHandler() { return new ServerCoreEventHandler() { @@ -217,15 +224,32 @@ public void authenticateSession( public void newSession(UUID sessionIndex, SessionInformation information) { currentSessionIndex = sessionIndex; currentIdentifier = information.getIdentifier(); + currentProtocolVersion = information.getProtocolVersion(); } @Override public void lostSession(UUID identity) { currentSessionIndex = null; currentIdentifier = null; + currentProtocolVersion = null; // clear receivedConfirmation = null; receivedRequest = null; + receivedConfirmationError = null; + receivedConfirmationErrorDescription = null; + receivedConfirmationErrorUniqueId = null; + } + + @Override + public void confirmationError( + UUID sessionIndex, + String uniqueId, + String errorCode, + String errorDescription, + Object payload) { + receivedConfirmationError = errorCode; + receivedConfirmationErrorDescription = errorDescription; + receivedConfirmationErrorUniqueId = uniqueId; } }; } @@ -234,6 +258,13 @@ public BiConsumer generateWhenCompleteHandler() { return (confirmation, throwable) -> receivedConfirmation = confirmation; } + void setReceivedRequest(Request receivedRequest) { + this.receivedRequest = receivedRequest; + receivedConfirmationError = null; + receivedConfirmationErrorDescription = null; + receivedConfirmationErrorUniqueId = null; + } + T failurePoint(T confirmation) { if (riggedToFail) { riggedToFail = false; @@ -262,6 +293,18 @@ public T getReceivedConfirmation(Class clazz) { return wasLatestConfirmation(clazz) ? (T) receivedConfirmation : null; } + public String getReceivedConfirmationError() { + return receivedConfirmationError; + } + + public String getReceivedConfirmationErrorDescription() { + return receivedConfirmationErrorDescription; + } + + public String getReceivedConfirmationErrorUniqueId() { + return receivedConfirmationErrorUniqueId; + } + public void setRiggedToFail(boolean riggedToFail) { this.riggedToFail = riggedToFail; } @@ -270,6 +313,14 @@ public boolean isRiggedToFail() { return riggedToFail; } + public void setRiggedToSendInvalidResponse(boolean riggedToSendInvalidResponse) { + this.riggedToSendInvalidResponse = riggedToSendInvalidResponse; + } + + public boolean isRiggedToSendInvalidResponse() { + return riggedToSendInvalidResponse; + } + public String getCurrentIdentifier() { return currentIdentifier; } @@ -277,4 +328,8 @@ public String getCurrentIdentifier() { public UUID getCurrentSessionIndex() { return currentSessionIndex; } + + public ProtocolVersion getCurrentProtocolVersion() { + return currentProtocolVersion; + } } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java index f84f2963..0b49ba16 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java @@ -61,6 +61,9 @@ public class FakeChargePoint { Confirmation receivedConfirmation; Request receivedRequest; Throwable receivedException; + String receivedConfirmationError; + String receivedConfirmationErrorDescription; + String receivedConfirmationErrorUniqueId; String url; public FakeChargePoint() throws MalformedURLException { @@ -317,6 +320,14 @@ public void connectionOpened() {} @Override public void connectionClosed() {} + + @Override + public void confirmationError( + String uniqueId, String errorCode, String errorDescription, Object payload) { + receivedConfirmationError = errorCode; + receivedConfirmationErrorDescription = errorDescription; + receivedConfirmationErrorUniqueId = uniqueId; + } }); } catch (Exception ex) { ex.printStackTrace(); @@ -427,11 +438,14 @@ public void sendSignedFirmwareStatusNotificationRequest(FirmwareStatusEnumType s public void clearMemory() { receivedConfirmation = null; + receivedConfirmationError = null; + receivedConfirmationErrorDescription = null; + receivedConfirmationErrorUniqueId = null; receivedException = null; receivedRequest = null; } - private void send(Request request) throws Exception { + void send(Request request) throws Exception { try { client .send(request) @@ -622,4 +636,21 @@ public boolean hasReceivedNotConnectedError() { return ((CallErrorException) receivedException).getErrorCode().equals("Not connected"); return false; } + + public String getReceivedRequestUniqueId() { + Request request = receivedRequest; + return request != null ? request.getOcppMessageId() : null; + } + + public String getReceivedConfirmationError() { + return receivedConfirmationError; + } + + public String getReceivedConfirmationErrorDescription() { + return receivedConfirmationErrorDescription; + } + + public String getReceivedConfirmationErrorUniqueId() { + return receivedConfirmationErrorUniqueId; + } } diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeCSMS.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeCSMS.java index e824ca3e..cb3fbd55 100644 --- a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeCSMS.java +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeCSMS.java @@ -33,4 +33,8 @@ public interface FakeCSMS { int getPort(); void stopServer(); + + void sendGetVariablesRequest(); + + DummyHandlers getDummyHandlers(); } diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeChargingStation.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeChargingStation.java index 353a842f..696d395a 100644 --- a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeChargingStation.java +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeChargingStation.java @@ -39,4 +39,12 @@ public interface FakeChargingStation { ProtocolVersion getProtocolVersion(); void sendBootNotification(String vendor, String model); + + String getReceivedRequestUniqueId(); + + String getReceivedConfirmationError(); + + String getReceivedConfirmationErrorDescription(); + + String getReceivedConfirmationErrorUniqueId(); } diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolDummyHandlers.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolDummyHandlers.java index 0cdffa80..51e884ed 100644 --- a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolDummyHandlers.java +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolDummyHandlers.java @@ -48,14 +48,18 @@ public ServerProvisioningEventHandler createServerProvisioningEventHandler() { @Override public BootNotificationResponse handleBootNotificationRequest( UUID sessionIndex, BootNotificationRequest request) { + setReceivedRequest(request); BootNotificationResponse response = new BootNotificationResponse( - ZonedDateTime.now(ZoneOffset.UTC), 20100, RegistrationStatusEnum.Accepted); + ZonedDateTime.now(ZoneOffset.UTC), + isRiggedToSendInvalidResponse() ? -1 : 1, + RegistrationStatusEnum.Accepted); return failurePoint(response); } @Override public HeartbeatResponse handleHeartbeatRequest(UUID sessionIndex, HeartbeatRequest request) { + setReceivedRequest(request); HeartbeatResponse response = new HeartbeatResponse(ZonedDateTime.now(ZoneOffset.UTC)); return failurePoint(response); } @@ -63,6 +67,7 @@ public HeartbeatResponse handleHeartbeatRequest(UUID sessionIndex, HeartbeatRequ @Override public NotifyReportResponse handleNotifyReportRequest( UUID sessionIndex, NotifyReportRequest request) { + setReceivedRequest(request); NotifyReportResponse response = new NotifyReportResponse(); return failurePoint(response); } diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeCSMS.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeCSMS.java index 4c13ba23..efba35a1 100644 --- a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeCSMS.java +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeCSMS.java @@ -26,11 +26,24 @@ package eu.chargetime.ocpp.test; -import eu.chargetime.ocpp.MultiProtocolJSONServer; -import eu.chargetime.ocpp.ProtocolVersion; +import static eu.chargetime.ocpp.ProtocolVersion.OCPP1_6; +import static eu.chargetime.ocpp.ProtocolVersion.OCPP2_0_1; + +import eu.chargetime.ocpp.*; import eu.chargetime.ocpp.feature.profile.ServerCoreProfile; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; import eu.chargetime.ocpp.v201.feature.function.ServerProvisioningFunction; +import eu.chargetime.ocpp.v201.model.messages.GetVariablesRequest; +import eu.chargetime.ocpp.v201.model.messages.GetVariablesResponse; +import eu.chargetime.ocpp.v201.model.types.Component; +import eu.chargetime.ocpp.v201.model.types.GetVariableData; +import eu.chargetime.ocpp.v201.model.types.Variable; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; /** Multiple protocol capable fake CSMS supporting up to OCPP 2.0.1 */ public class OCPP201MultiProtocolFakeCSMS implements FakeCSMS { @@ -38,24 +51,48 @@ public class OCPP201MultiProtocolFakeCSMS implements FakeCSMS { private final MultiProtocolJSONServer server; private final OCPP201MultiProtocolDummyHandlers dummyHandlers; + private Confirmation receivedConfirmation; + private Throwable receivedException; + /** * Constructs the fake Charging Station Management System * * @param protocolVersions the {@link ProtocolVersion}s to support, ordered by preference */ public OCPP201MultiProtocolFakeCSMS(List protocolVersions) { + this(protocolVersions, new OCPP201MultiProtocolDummyHandlers()); + } + + /** + * Constructs the fake Charging Station Management System + * + * @param protocolVersions the {@link ProtocolVersion}s to support, ordered by preference + * @param dummyHandlers the {@link OCPP201MultiProtocolDummyHandlers} to fake OCPP 2.0.1 protocol + * handling + */ + public OCPP201MultiProtocolFakeCSMS( + List protocolVersions, OCPP201MultiProtocolDummyHandlers dummyHandlers) { + this.dummyHandlers = dummyHandlers; server = new MultiProtocolJSONServer(protocolVersions); - dummyHandlers = new OCPP201MultiProtocolDummyHandlers(); - if (protocolVersions.contains(ProtocolVersion.OCPP1_6)) { + if (protocolVersions.contains(OCPP1_6)) { server.addFeatureProfile(new ServerCoreProfile(dummyHandlers.createServerCoreEventHandler())); } - if (protocolVersions.contains(ProtocolVersion.OCPP2_0_1)) { + if (protocolVersions.contains(OCPP2_0_1)) { server.addFunction( - ProtocolVersion.OCPP2_0_1, + OCPP2_0_1, new ServerProvisioningFunction(dummyHandlers.createServerProvisioningEventHandler())); } } + /** + * Gets the {@link MultiProtocolJSONServer} + * + * @return the {@link MultiProtocolJSONServer} + */ + MultiProtocolJSONServer getServer() { + return server; + } + /** Starts the fake CSMS server on the local host, using an available port */ @Override public void startServer() { @@ -77,4 +114,80 @@ public int getPort() { public void stopServer() { server.close(); } + + /** + * Returns the dummy handlers + * + * @return the dummy handlers + */ + @Override + public DummyHandlers getDummyHandlers() { + return dummyHandlers; + } + + @Override + public void sendGetVariablesRequest() { + if (!OCPP2_0_1.equals(getDummyHandlers().getCurrentProtocolVersion())) { + throw new UnsupportedOperationException( + "Cannot send a GetVariablesRequest for " + + getDummyHandlers().getCurrentProtocolVersion()); + } + GetVariableData getVariableData = new GetVariableData(new Component(""), new Variable("")); + GetVariablesRequest getVariablesRequest = + new GetVariablesRequest(new GetVariableData[] {getVariableData}); + sendRequestAndWaitForResponse(getVariablesRequest, GetVariablesResponse.class); + } + + void sendRequestAndWaitForResponse( + Request request, @Nullable Class responseClass) { + try { + CompletableFuture future = + getServer() + .send(getDummyHandlers().getCurrentSessionIndex(), request) + .toCompletableFuture(); + BiConsumer action = + (confirmation, throwable) -> { + if (confirmation != null) { + receivedConfirmation = confirmation; + receivedException = null; + checkConfirmation(confirmation); + } else if (throwable != null) { + receivedConfirmation = null; + receivedException = throwable; + } else { + receivedConfirmation = null; + receivedException = null; + } + }; + future.whenComplete(action); + try { + future.join(); + } catch (CompletionException e) { + // ignore + } + } catch (NotConnectedException | OccurenceConstraintException | UnsupportedFeatureException e) { + throw new RuntimeException(e); + } + if (receivedException != null) { + throw new RuntimeException("Received exception in response to request", receivedException); + } + if (receivedConfirmation != null && responseClass != null) { + if (!responseClass.isInstance(receivedConfirmation)) { + throw new IllegalArgumentException("Received confirmation is not of expected class"); + } + } else if (responseClass != null) { + throw new IllegalStateException("Received neither a confirmation nor a throwable"); + } + } + + void checkConfirmation(Confirmation confirmation) { + if (confirmation instanceof GetVariablesResponse) { + GetVariablesResponse getVariablesResponse = (GetVariablesResponse) confirmation; + if (getVariablesResponse.getGetVariableResult().length != 1) { + throw new PropertyConstraintException( + getVariablesResponse.getGetVariableResult().length, + "GetVariablesResponse getVariableResult length must be 1"); + } + } + } } diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeChargingStation.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeChargingStation.java index 1322ec94..ead6f6cd 100644 --- a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeChargingStation.java +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeChargingStation.java @@ -29,10 +29,7 @@ import static eu.chargetime.ocpp.ProtocolVersion.OCPP1_6; import static eu.chargetime.ocpp.ProtocolVersion.OCPP2_0_1; -import eu.chargetime.ocpp.MultiProtocolJSONClient; -import eu.chargetime.ocpp.OccurenceConstraintException; -import eu.chargetime.ocpp.ProtocolVersion; -import eu.chargetime.ocpp.UnsupportedFeatureException; +import eu.chargetime.ocpp.*; import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import eu.chargetime.ocpp.model.core.BootNotificationConfirmation; @@ -51,18 +48,12 @@ import eu.chargetime.ocpp.v201.model.messages.SetNetworkProfileResponse; import eu.chargetime.ocpp.v201.model.messages.SetVariablesRequest; import eu.chargetime.ocpp.v201.model.messages.SetVariablesResponse; -import eu.chargetime.ocpp.v201.model.types.BootReasonEnum; -import eu.chargetime.ocpp.v201.model.types.ChargingStation; -import eu.chargetime.ocpp.v201.model.types.GenericDeviceModelStatusEnum; -import eu.chargetime.ocpp.v201.model.types.GetVariableResult; -import eu.chargetime.ocpp.v201.model.types.Modem; -import eu.chargetime.ocpp.v201.model.types.ResetStatusEnum; -import eu.chargetime.ocpp.v201.model.types.SetNetworkProfileStatusEnum; -import eu.chargetime.ocpp.v201.model.types.SetVariableResult; +import eu.chargetime.ocpp.v201.model.types.*; import java.net.MalformedURLException; import java.util.List; import java.util.Objects; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import java.util.function.BiConsumer; import javax.annotation.Nullable; @@ -96,7 +87,17 @@ public GetReportResponse handleGetReportRequest(GetReportRequest request) { @Override public GetVariablesResponse handleGetVariablesRequest(GetVariablesRequest request) { receivedRequest = request; - return new GetVariablesResponse(new GetVariableResult[] {}); + return new GetVariablesResponse( + new GetVariableResult[] { + new GetVariableResult( + GetVariableStatusEnum.UnknownVariable, + new Component(""), + new Variable("")), + new GetVariableResult( + GetVariableStatusEnum.UnknownVariable, + new Component(""), + new Variable("")) + }); } @Override @@ -177,7 +178,8 @@ public void sendBootNotification(String vendor, String model) { sendRequestAndWaitForResponse(request, responseClass); } - void sendRequestAndWaitForResponse(Request request, Class responseClass) { + void sendRequestAndWaitForResponse( + Request request, @Nullable Class responseClass) { try { CompletableFuture future = client.send(request).toCompletableFuture(); BiConsumer action = @@ -185,6 +187,7 @@ void sendRequestAndWaitForResponse(Request request, Class= 0"); + } + } + } } diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolDummyHandlers.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolDummyHandlers.java new file mode 100644 index 00000000..4cc0dbc3 --- /dev/null +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolDummyHandlers.java @@ -0,0 +1,118 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2025 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import static eu.chargetime.ocpp.v21.model.types.GenericStatusEnum.Accepted; + +import eu.chargetime.ocpp.v21.feature.function.ServerDiagnosticsEventHandler; +import eu.chargetime.ocpp.v21.feature.function.ServerProvisioningEventHandler; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.RegistrationStatusEnum; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.UUID; + +/** Dummy handlers for multiple protocol server functions up to OCPP 2.1 */ +public class OCPP21MultiProtocolDummyHandlers extends OCPP201MultiProtocolDummyHandlers { + + /* OCPP 2.1 Provisioning function handlers */ + + public ServerProvisioningEventHandler createOCPP21ServerProvisioningEventHandler() { + return new ServerProvisioningEventHandler() { + @Override + public BootNotificationResponse handleBootNotificationRequest( + UUID sessionIndex, BootNotificationRequest request) { + setReceivedRequest(request); + BootNotificationResponse response = + new BootNotificationResponse( + ZonedDateTime.now(ZoneOffset.UTC), + isRiggedToSendInvalidResponse() ? -1 : 1, + RegistrationStatusEnum.Accepted); + return failurePoint(response); + } + + @Override + public HeartbeatResponse handleHeartbeatRequest(UUID sessionIndex, HeartbeatRequest request) { + setReceivedRequest(request); + HeartbeatResponse response = new HeartbeatResponse(ZonedDateTime.now(ZoneOffset.UTC)); + return failurePoint(response); + } + + @Override + public NotifyReportResponse handleNotifyReportRequest( + UUID sessionIndex, NotifyReportRequest request) { + setReceivedRequest(request); + NotifyReportResponse response = new NotifyReportResponse(); + return failurePoint(response); + } + }; + } + + /* OCPP 2.1 Diagnostics function handlers */ + + public ServerDiagnosticsEventHandler createOCPP21ServerDiagnosticsEventHandler() { + return new ServerDiagnosticsEventHandler() { + @Override + public LogStatusNotificationResponse handleLogStatusNotificationRequest( + UUID sessionIndex, LogStatusNotificationRequest request) { + setReceivedRequest(request); + LogStatusNotificationResponse response = new LogStatusNotificationResponse(); + return failurePoint(response); + } + + @Override + public NotifyCustomerInformationResponse handleNotifyCustomerInformationRequest( + UUID sessionIndex, NotifyCustomerInformationRequest request) { + setReceivedRequest(request); + NotifyCustomerInformationResponse response = new NotifyCustomerInformationResponse(); + return failurePoint(response); + } + + @Override + public NotifyMonitoringReportResponse handleNotifyMonitoringReportRequest( + UUID sessionIndex, NotifyMonitoringReportRequest request) { + setReceivedRequest(request); + NotifyMonitoringReportResponse response = new NotifyMonitoringReportResponse(); + return failurePoint(response); + } + + @Override + public void handleNotifyPeriodicEventStream( + UUID sessionIndex, NotifyPeriodicEventStream request) { + setReceivedRequest(request); + } + + @Override + public OpenPeriodicEventStreamResponse handleOpenPeriodicEventStreamRequest( + UUID sessionIndex, OpenPeriodicEventStreamRequest request) { + setReceivedRequest(request); + OpenPeriodicEventStreamResponse response = new OpenPeriodicEventStreamResponse(Accepted); + return failurePoint(response); + } + }; + } +} diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolFakeCSMS.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolFakeCSMS.java new file mode 100644 index 00000000..9a21dcf4 --- /dev/null +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolFakeCSMS.java @@ -0,0 +1,101 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2025 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import static eu.chargetime.ocpp.ProtocolVersion.OCPP2_1; + +import eu.chargetime.ocpp.*; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.v21.feature.function.ServerDiagnosticsFunction; +import eu.chargetime.ocpp.v21.feature.function.ServerProvisioningFunction; +import eu.chargetime.ocpp.v21.model.messages.GetVariablesRequest; +import eu.chargetime.ocpp.v21.model.messages.GetVariablesResponse; +import eu.chargetime.ocpp.v21.model.types.Component; +import eu.chargetime.ocpp.v21.model.types.GetVariableData; +import eu.chargetime.ocpp.v21.model.types.Variable; +import java.util.List; + +/** Multiple protocol capable fake CSMS supporting up to OCPP 2.1 */ +public class OCPP21MultiProtocolFakeCSMS extends OCPP201MultiProtocolFakeCSMS { + + /** + * Constructs the fake Charging Station Management System + * + * @param protocolVersions the {@link ProtocolVersion}s to support, ordered by preference + */ + public OCPP21MultiProtocolFakeCSMS(List protocolVersions) { + this(protocolVersions, new OCPP21MultiProtocolDummyHandlers()); + } + + /** + * Constructs the fake Charging Station Management System + * + * @param protocolVersions the {@link ProtocolVersion}s to support, ordered by preference + * @param dummyHandlers the {@link OCPP21MultiProtocolDummyHandlers} to fake OCPP 2.1 protocol + * handling + */ + public OCPP21MultiProtocolFakeCSMS( + List protocolVersions, OCPP21MultiProtocolDummyHandlers dummyHandlers) { + super(protocolVersions, dummyHandlers); + if (protocolVersions.contains(OCPP2_1)) { + getServer() + .addFunction( + OCPP2_1, + new ServerProvisioningFunction( + dummyHandlers.createOCPP21ServerProvisioningEventHandler())); + getServer() + .addFunction( + OCPP2_1, + new ServerDiagnosticsFunction( + dummyHandlers.createOCPP21ServerDiagnosticsEventHandler())); + } + } + + @Override + public void sendGetVariablesRequest() { + if (!OCPP2_1.equals(getDummyHandlers().getCurrentProtocolVersion())) { + super.sendGetVariablesRequest(); + } else { + GetVariableData getVariableData = new GetVariableData(new Component(""), new Variable("")); + GetVariablesRequest getVariablesRequest = + new GetVariablesRequest(new GetVariableData[] {getVariableData}); + sendRequestAndWaitForResponse(getVariablesRequest, GetVariablesResponse.class); + } + } + + @Override + void checkConfirmation(Confirmation confirmation) { + if (confirmation instanceof GetVariablesResponse) { + GetVariablesResponse getVariablesResponse = (GetVariablesResponse) confirmation; + if (getVariablesResponse.getGetVariableResult().length != 1) { + throw new PropertyConstraintException( + getVariablesResponse.getGetVariableResult().length, + "GetVariablesResponse getVariableResult length must be 1"); + } + } + } +} diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolFakeChargingStation.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolFakeChargingStation.java new file mode 100644 index 00000000..cc5571a1 --- /dev/null +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolFakeChargingStation.java @@ -0,0 +1,214 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import static eu.chargetime.ocpp.ProtocolVersion.OCPP2_1; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.ProtocolVersion; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.feature.function.ClientDiagnosticsEventHandler; +import eu.chargetime.ocpp.v21.feature.function.ClientDiagnosticsFunction; +import eu.chargetime.ocpp.v21.feature.function.ClientProvisioningEventHandler; +import eu.chargetime.ocpp.v21.feature.function.ClientProvisioningFunction; +import eu.chargetime.ocpp.v21.model.messages.*; +import eu.chargetime.ocpp.v21.model.types.*; +import java.net.MalformedURLException; +import java.util.List; + +/** Multiple protocol capable fake charging station supporting up to OCPP 2.1 */ +public class OCPP21MultiProtocolFakeChargingStation + extends OCPP201MultiProtocolFakeChargingStation { + final ClientProvisioningFunction ocpp21provisioning; + final ClientDiagnosticsFunction ocpp21diagnostics; + + public OCPP21MultiProtocolFakeChargingStation(List protocolVersions) + throws MalformedURLException { + super(protocolVersions); + + ocpp21provisioning = + new ClientProvisioningFunction( + new ClientProvisioningEventHandler() { + @Override + public GetBaseReportResponse handleGetBaseReportRequest( + GetBaseReportRequest request) { + receivedRequest = request; + return new GetBaseReportResponse(GenericDeviceModelStatusEnum.Accepted); + } + + @Override + public GetReportResponse handleGetReportRequest(GetReportRequest request) { + receivedRequest = request; + return new GetReportResponse(GenericDeviceModelStatusEnum.Accepted); + } + + @Override + public GetVariablesResponse handleGetVariablesRequest(GetVariablesRequest request) { + receivedRequest = request; + return new GetVariablesResponse( + new GetVariableResult[] { + new GetVariableResult( + GetVariableStatusEnum.UnknownVariable, + new Component(""), + new Variable("")), + new GetVariableResult( + GetVariableStatusEnum.UnknownVariable, + new Component(""), + new Variable("")) + }); + } + + @Override + public ResetResponse handleResetRequest(ResetRequest request) { + receivedRequest = request; + return new ResetResponse(ResetStatusEnum.Accepted); + } + + @Override + public SetNetworkProfileResponse handleSetNetworkProfileRequest( + SetNetworkProfileRequest request) { + receivedRequest = request; + return new SetNetworkProfileResponse(SetNetworkProfileStatusEnum.Accepted); + } + + @Override + public SetVariablesResponse handleSetVariablesRequest(SetVariablesRequest request) { + receivedRequest = request; + return new SetVariablesResponse(new SetVariableResult[] {}); + } + }); + + ocpp21diagnostics = + new ClientDiagnosticsFunction( + new ClientDiagnosticsEventHandler() { + @Override + public AdjustPeriodicEventStreamResponse handleAdjustPeriodicEventStreamRequest( + AdjustPeriodicEventStreamRequest request) { + receivedRequest = request; + return new AdjustPeriodicEventStreamResponse(GenericStatusEnum.Accepted); + } + + @Override + public ClearVariableMonitoringResponse handleClearVariableMonitoringRequest( + ClearVariableMonitoringRequest request) { + receivedRequest = request; + return new ClearVariableMonitoringResponse(new ClearMonitoringResult[] {}); + } + + @Override + public ClosePeriodicEventStreamResponse handleClosePeriodicEventStreamRequest( + ClosePeriodicEventStreamRequest request) { + receivedRequest = request; + return new ClosePeriodicEventStreamResponse(); + } + + @Override + public CustomerInformationResponse handleCustomerInformationRequest( + CustomerInformationRequest request) { + receivedRequest = request; + return new CustomerInformationResponse(CustomerInformationStatusEnum.Accepted); + } + + @Override + public GetLogResponse handleGetLogRequest(GetLogRequest request) { + receivedRequest = request; + return new GetLogResponse(LogStatusEnum.Accepted); + } + + @Override + public GetMonitoringReportResponse handleGetMonitoringReportRequest( + GetMonitoringReportRequest request) { + receivedRequest = request; + return new GetMonitoringReportResponse(GenericDeviceModelStatusEnum.Accepted); + } + + @Override + public GetPeriodicEventStreamResponse handleGetPeriodicEventStreamRequest( + GetPeriodicEventStreamRequest request) { + receivedRequest = request; + return new GetPeriodicEventStreamResponse(); + } + + @Override + public SetMonitoringBaseResponse handleSetMonitoringBaseRequest( + SetMonitoringBaseRequest request) { + receivedRequest = request; + return new SetMonitoringBaseResponse(GenericDeviceModelStatusEnum.Accepted); + } + + @Override + public SetMonitoringLevelResponse handleSetMonitoringLevelRequest( + SetMonitoringLevelRequest request) { + receivedRequest = request; + return new SetMonitoringLevelResponse(GenericStatusEnum.Accepted); + } + + @Override + public SetVariableMonitoringResponse handleSetVariableMonitoringRequest( + SetVariableMonitoringRequest request) { + receivedRequest = request; + return new SetVariableMonitoringResponse(new SetMonitoringResult[] {}); + } + }); + + if (protocolVersions.contains(OCPP2_1)) { + multiProtocolJSONClient.addFunction(OCPP2_1, ocpp21provisioning); + multiProtocolJSONClient.addFunction(OCPP2_1, ocpp21diagnostics); + } + } + + @Override + public void sendBootNotification(String vendor, String model) { + if (!OCPP2_1.equals(getProtocolVersion())) { + super.sendBootNotification(vendor, model); + } else { + Request request = + ocpp21provisioning.createBootNotificationRequest( + new ChargingStation(model, vendor) + .withSerialNumber("123456789") + .withFirmwareVersion("0.0.1") + .withModem(new Modem().withImsi("1851").withIccid("16610")), + BootReasonEnum.Unknown); + Class responseClass = BootNotificationResponse.class; + sendRequestAndWaitForResponse(request, responseClass); + } + } + + @Override + void checkConfirmation(Confirmation confirmation) { + super.checkConfirmation(confirmation); + if (confirmation instanceof BootNotificationResponse) { + BootNotificationResponse bootNotificationResponse = (BootNotificationResponse) confirmation; + if (bootNotificationResponse.getInterval() < 0) { + throw new PropertyConstraintException( + bootNotificationResponse.getInterval(), + "BootNotificationResponse interval must be >= 0"); + } + } + } +} diff --git a/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java b/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java index 944a2b8b..d1f7d49b 100644 --- a/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java +++ b/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java @@ -129,6 +129,7 @@ public void testMultiProtocolCsmsRunningParallelSessionsWithDifferentProtocolVer reconnectChargingStation(cs16, csms); cs16.sendBootNotification("vendor", "model"); + reconnectChargingStation(cs201, csms); cs201.sendBootNotification("vendor", "model"); } } diff --git a/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolIntegrationTest.java b/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolIntegrationTest.java new file mode 100644 index 00000000..305dc701 --- /dev/null +++ b/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP21MultiProtocolIntegrationTest.java @@ -0,0 +1,251 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import static eu.chargetime.ocpp.ProtocolVersion.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; + +import eu.chargetime.ocpp.ProtocolVersion; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v21.model.messages.BootNotificationRequest; +import eu.chargetime.ocpp.v21.model.messages.NotifyPeriodicEventStream; +import eu.chargetime.ocpp.v21.model.types.StreamDataElement; +import java.net.MalformedURLException; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +/** multiple protocol capable client and server integration test up to OCPP 2.1 */ +@RunWith(MockitoJUnitRunner.class) +public class OCPP21MultiProtocolIntegrationTest { + + private static final List OCPP1_6_ONLY = Collections.singletonList(OCPP1_6); + private static final List OCPP2_0_1_ONLY = Collections.singletonList(OCPP2_0_1); + private static final List OCPP2_1_ONLY = Collections.singletonList(OCPP2_1); + private static final List OCPP1_6_FIRST = + Arrays.asList(OCPP1_6, OCPP2_0_1, OCPP2_1); + private static final List OCPP2_1_FIRST = + Arrays.asList(OCPP2_1, OCPP2_0_1, OCPP1_6); + + private List csmsList; + + @Before + public void setup() { + csmsList = new ArrayList<>(); + } + + @After + public void teardown() { + for (FakeCSMS csms : csmsList) { + csms.stopServer(); + } + } + + private FakeCSMS setupAndStartCSMS(List protocolVersions) { + FakeCSMS csms = new OCPP21MultiProtocolFakeCSMS(protocolVersions); + csmsList.add(csms); + csms.startServer(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // restore thread interrupted state + Thread.currentThread().interrupt(); + throw new RuntimeException(e); + } + assertThat(csms.getPort(), not(0)); + return csms; + } + + private FakeChargingStation buildAndConnectChargingStation( + List protocolVersions, FakeCSMS csms) { + FakeChargingStation cs; + try { + cs = new OCPP21MultiProtocolFakeChargingStation(protocolVersions); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + cs.connect(csms.getPort()); + return cs; + } + + private void reconnectChargingStation(FakeChargingStation cs, FakeCSMS csms) { + cs.disconnect(); + cs.connect(csms.getPort()); + } + + @Test + public void testMultiProtocolChargingStationReconnectingWithDifferentProtocolVersions() { + FakeCSMS ocpp16OnlyCSMS = setupAndStartCSMS(OCPP1_6_ONLY); + FakeChargingStation cs = buildAndConnectChargingStation(OCPP2_1_FIRST, ocpp16OnlyCSMS); + assertThat(cs.getProtocolVersion(), is(OCPP1_6)); + cs.sendBootNotification("vendor", "model"); + + FakeCSMS ocpp201OnlyCSMS = setupAndStartCSMS(OCPP2_0_1_ONLY); + reconnectChargingStation(cs, ocpp201OnlyCSMS); + assertThat(cs.getProtocolVersion(), is(OCPP2_0_1)); + cs.sendBootNotification("vendor", "model"); + + FakeCSMS ocpp21OnlyCSMS = setupAndStartCSMS(OCPP2_1_ONLY); + reconnectChargingStation(cs, ocpp21OnlyCSMS); + assertThat(cs.getProtocolVersion(), is(OCPP2_1)); + cs.sendBootNotification("vendor", "model"); + + reconnectChargingStation(cs, ocpp201OnlyCSMS); + assertThat(cs.getProtocolVersion(), is(OCPP2_0_1)); + cs.sendBootNotification("vendor", "model"); + + reconnectChargingStation(cs, ocpp16OnlyCSMS); + assertThat(cs.getProtocolVersion(), is(OCPP1_6)); + cs.sendBootNotification("vendor", "model"); + } + + @Test + public void testMultiProtocolCsmsRunningParallelSessionsWithDifferentProtocolVersions() { + FakeCSMS csms = setupAndStartCSMS(OCPP2_1_FIRST); + + FakeChargingStation cs16 = buildAndConnectChargingStation(OCPP1_6_ONLY, csms); + cs16.sendBootNotification("vendor", "model"); + + FakeChargingStation cs201 = buildAndConnectChargingStation(OCPP2_0_1_ONLY, csms); + cs201.sendBootNotification("vendor", "model"); + + FakeChargingStation cs21 = buildAndConnectChargingStation(OCPP2_1_ONLY, csms); + cs21.sendBootNotification("vendor", "model"); + + reconnectChargingStation(cs16, csms); + cs16.sendBootNotification("vendor", "model"); + + reconnectChargingStation(cs201, csms); + cs201.sendBootNotification("vendor", "model"); + + reconnectChargingStation(cs21, csms); + cs21.sendBootNotification("vendor", "model"); + } + + @Test + public void testInvalidOCPP21ClientResponseTriggersCALLRESULTERROR() throws InterruptedException { + OCPP21MultiProtocolFakeCSMS csms = + (OCPP21MultiProtocolFakeCSMS) setupAndStartCSMS(OCPP2_1_FIRST); + FakeChargingStation cs = buildAndConnectChargingStation(OCPP2_1_ONLY, csms); + cs.sendBootNotification("vendor", "model"); + + csms.sendGetVariablesRequest(); + Thread.sleep(100); + assertThat(cs.getReceivedConfirmationError(), is("PropertyConstraintViolation")); + assertThat( + cs.getReceivedConfirmationErrorDescription(), + is( + "Validation failed: [GetVariablesResponse getVariableResult length must be 1]. Current Value: [2]")); + assertThat(cs.getReceivedConfirmationErrorUniqueId(), is(cs.getReceivedRequestUniqueId())); + } + + @Test + public void testInvalidOCPP201ClientResponseTriggersNoMessage() throws InterruptedException { + OCPP21MultiProtocolFakeCSMS csms = + (OCPP21MultiProtocolFakeCSMS) setupAndStartCSMS(OCPP2_1_FIRST); + FakeChargingStation cs = buildAndConnectChargingStation(OCPP2_0_1_ONLY, csms); + cs.sendBootNotification("vendor", "model"); + + csms.sendGetVariablesRequest(); + Thread.sleep(100); + assertThat(cs.getReceivedConfirmationError(), is(nullValue())); + assertThat(cs.getReceivedConfirmationErrorDescription(), is(nullValue())); + assertThat(cs.getReceivedConfirmationErrorUniqueId(), is(nullValue())); + } + + @Test + public void testInvalidOCPP21ServerResponseTriggersCALLRESULTERROR() throws InterruptedException { + FakeCSMS csms = setupAndStartCSMS(OCPP2_1_FIRST); + FakeChargingStation cs = buildAndConnectChargingStation(OCPP2_1_ONLY, csms); + csms.getDummyHandlers().setRiggedToSendInvalidResponse(true); + + cs.sendBootNotification("vendor", "model"); + Thread.sleep(100); + Request request = csms.getDummyHandlers().getReceivedRequest(BootNotificationRequest.class); + assertThat(request, is(notNullValue())); + assertThat( + csms.getDummyHandlers().getReceivedConfirmationError(), is("PropertyConstraintViolation")); + assertThat( + csms.getDummyHandlers().getReceivedConfirmationErrorDescription(), + is( + "Validation failed: [BootNotificationResponse interval must be >= 0]. Current Value: [-1]")); + assertThat( + csms.getDummyHandlers().getReceivedConfirmationErrorUniqueId(), + is(request.getOcppMessageId())); + } + + @Test + public void testInvalidOCPP201ServerResponseTriggersNoMessage() throws InterruptedException { + FakeCSMS csms = setupAndStartCSMS(OCPP2_1_FIRST); + FakeChargingStation cs = buildAndConnectChargingStation(OCPP2_0_1_ONLY, csms); + csms.getDummyHandlers().setRiggedToSendInvalidResponse(true); + + cs.sendBootNotification("vendor", "model"); + Thread.sleep(100); + assertThat(csms.getDummyHandlers().getReceivedConfirmationError(), is(nullValue())); + assertThat(csms.getDummyHandlers().getReceivedConfirmationErrorDescription(), is(nullValue())); + assertThat(csms.getDummyHandlers().getReceivedConfirmationErrorUniqueId(), is(nullValue())); + } + + @Test + public void testNotifyPeriodicEventStreamIsTransmittedAndReceived() throws Exception { + FakeCSMS csms = setupAndStartCSMS(OCPP2_1_FIRST); + OCPP21MultiProtocolFakeChargingStation cs = + (OCPP21MultiProtocolFakeChargingStation) buildAndConnectChargingStation(OCPP2_1_ONLY, csms); + cs.sendBootNotification("vendor", "model"); + + StreamDataElement streamDataElement = new StreamDataElement(1234.567d, "230.000"); + NotifyPeriodicEventStream notifyPeriodicEventStream = + new NotifyPeriodicEventStream( + new StreamDataElement[] {streamDataElement}, + 5678, + 0, + ZonedDateTime.now(ZoneOffset.UTC)); + + cs.sendRequestAndWaitForResponse(notifyPeriodicEventStream, null); + assertThat(cs.getReceivedConfirmation(), is(nullValue())); + assertThat(cs.getReceivedException(), is(nullValue())); + + Thread.sleep(100); + assertThat(csms.getDummyHandlers().wasLatestRequest(NotifyPeriodicEventStream.class), is(true)); + assertThat( + csms.getDummyHandlers().getReceivedRequest(NotifyPeriodicEventStream.class), + is(notifyPeriodicEventStream)); + } +} From 7c42c9669dd0d09300579c0a8f46eef45c65a5fa Mon Sep 17 00:00:00 2001 From: Robert Schlabbach Date: Fri, 19 Dec 2025 19:43:26 +0100 Subject: [PATCH 4/4] Update README.md about OCPP 2.1 support. --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 60aad557..46919bd5 100644 --- a/README.md +++ b/README.md @@ -12,22 +12,22 @@ Please note, this is a library and not an application, so there is no main metho The design is driven by test, which will ensure premium software that is easy to adapt and modify to your needs. -The library supports OCPP 1.6 with JSON and SOAP transports and OCPP 2.0.1. +The library supports OCPP 1.6 with JSON and SOAP transports, OCPP 2.0.1 and OCPP 2.1. The following packages are built from the sources: -| Package | Description | -|-------------|-------------------------------------------------------------------| -| ocpp16j | OCPP 1.6 with JSON transport (only) | -| ocpp16s | OCPP 1.6 with SOAP transport (only) | -| ocpp2 | OCPP 2.0.1 (multi-protocol capable, ocpp16j integration possible) | -| | | -| ocpp16 | OCPP 1.6 base dependency package | -| ocpp-common | common dependency package | -| ocpp-json | JSON transport dependency package | -| | | -| ocpp16-test | OCPP 1.6 integration tests | -| ocpp2-test | OCPP 1.6 and 2.0.1 integration tests | +| Package | Description | +|-------------|-----------------------------------------------------------------| +| ocpp16j | OCPP 1.6 with JSON transport (only) | +| ocpp16s | OCPP 1.6 with SOAP transport (only) | +| ocpp2 | OCPP 2.x (multi-protocol capable, ocpp16j integration possible) | +| | | +| ocpp16 | OCPP 1.6 base dependency package | +| ocpp-common | common dependency package | +| ocpp-json | JSON transport dependency package | +| | | +| ocpp16-test | OCPP 1.6 integration tests | +| ocpp2-test | OCPP 1.6 and 2.x integration tests | Incoming request events are split into feature profiles as described in the OCPP specification. I recommend that you download and read the specification from openchargealliance.org