Skip to content

Commit f371c57

Browse files
committed
Add optional variable to control the rounding of the timestamps
Signed-off-by: Marc Emmers <m.emmers@alfen.com>
1 parent 71591ea commit f371c57

File tree

6 files changed

+50
-5
lines changed

6 files changed

+50
-5
lines changed

config/v201/component_schemas/standardized/InternalCtrlr.json

+15
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,21 @@
537537
"description": "List of criteria supported for a get custom report. Enabled,Active,Problem,Available",
538538
"default": "Enabled,Active,Problem,Available",
539539
"type": "string"
540+
},
541+
"RoundClockAlignedTimestamps": {
542+
"variable_name": "RoundClockAlignedTimestamps",
543+
"characteristics": {
544+
"supportsMonitoring": false,
545+
"dataType": "boolean"
546+
},
547+
"attributes": [
548+
{
549+
"type": "Actual",
550+
"mutability": "ReadOnly"
551+
}
552+
],
553+
"default": "0",
554+
"type": "boolean"
540555
}
541556
},
542557
"required": [

config/v201/config.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,13 @@
271271
"attributes": {
272272
"Actual": "0"
273273
}
274+
},
275+
"RoundClockAlignedTimestamps": {
276+
"variable_name": "RoundClockAlignedTimestamps",
277+
"attributes": {
278+
"Actual": "0"
279+
}
274280
}
275-
276281
}
277282
},
278283
{

include/ocpp/v201/ctrlr_component_variables.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern const ComponentVariable& LogMessages;
5454
extern const RequiredComponentVariable& LogMessagesFormat;
5555
extern const ComponentVariable& SupportedChargingProfilePurposeTypes;
5656
extern const ComponentVariable& SupportedCriteria;
57+
extern const ComponentVariable& RoundClockAlignedTimestamps;
5758
extern const ComponentVariable& MaxCompositeScheduleDuration;
5859
extern const RequiredComponentVariable& NumberOfConnectors;
5960
extern const ComponentVariable& UseSslDefaultVerifyPaths;

lib/ocpp/v201/charge_point.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -1222,13 +1222,19 @@ void ChargePoint::update_aligned_data_interval() {
12221222
}
12231223
}
12241224

1225+
const bool align_timestamps =
1226+
this->device_model->get_optional_value<bool>(ControllerComponentVariables::RoundClockAlignedTimestamps)
1227+
.value_or(false);
1228+
12251229
// send evseID = 0 values
12261230
auto meter_value = get_latest_meter_value_filtered(this->aligned_data_evse0.retrieve_processed_values(),
12271231
ReadingContextEnum::Sample_Clock,
12281232
ControllerComponentVariables::AlignedDataMeasurands);
12291233

12301234
if (!meter_value.sampledValue.empty()) {
1231-
meter_value.timestamp = utils::align_timestamp(DateTime{}, interval);
1235+
if (align_timestamps) {
1236+
meter_value.timestamp = utils::align_timestamp(DateTime{}, interval);
1237+
}
12321238
this->meter_values_req(0, std::vector<ocpp::v201::MeterValue>(1, meter_value));
12331239
}
12341240
this->aligned_data_evse0.clear_values();
@@ -1243,7 +1249,10 @@ void ChargePoint::update_aligned_data_interval() {
12431249
auto meter_value =
12441250
get_latest_meter_value_filtered(evse->get_idle_meter_value(), ReadingContextEnum::Sample_Clock,
12451251
ControllerComponentVariables::AlignedDataMeasurands);
1246-
meter_value.timestamp = utils::align_timestamp(DateTime{}, interval);
1252+
1253+
if (align_timestamps) {
1254+
meter_value.timestamp = utils::align_timestamp(DateTime{}, interval);
1255+
}
12471256

12481257
if (!meter_value.sampledValue.empty()) {
12491258
// J01.FR.14 this is the only case where we send a MeterValue.req

lib/ocpp/v201/ctrlr_component_variables.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ const ComponentVariable& SupportedCriteria = {
158158
"SupportedCriteria",
159159
}),
160160
};
161+
const ComponentVariable& RoundClockAlignedTimestamps = {
162+
ControllerComponents::InternalCtrlr,
163+
std::nullopt,
164+
std::optional<Variable>({
165+
"RoundClockAlignedTimestamps",
166+
}),
167+
};
161168
const ComponentVariable& SupportedChargingProfilePurposeTypes = {
162169
ControllerComponents::InternalCtrlr,
163170
std::nullopt,

lib/ocpp/v201/evse.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ void Evse::open_transaction(const std::string& transaction_id, const int32_t con
126126
for (auto& item : meter_value.sampledValue) {
127127
item.context = ReadingContextEnum::Sample_Clock;
128128
}
129-
meter_value.timestamp = utils::align_timestamp(DateTime{}, aligned_data_tx_updated_interval);
129+
if (this->device_model
130+
.get_optional_value<bool>(ControllerComponentVariables::RoundClockAlignedTimestamps)
131+
.value_or(false)) {
132+
meter_value.timestamp = utils::align_timestamp(DateTime{}, aligned_data_tx_updated_interval);
133+
}
130134
this->transaction_meter_value_req(meter_value, this->transaction->get_transaction(),
131135
transaction->get_seq_no(), this->transaction->reservation_id);
132136
this->aligned_data_updated.clear_values();
@@ -147,7 +151,11 @@ void Evse::open_transaction(const std::string& transaction_id, const int32_t con
147151
for (auto& item : meter_value.sampledValue) {
148152
item.context = ReadingContextEnum::Sample_Clock;
149153
}
150-
meter_value.timestamp = utils::align_timestamp(DateTime{}, aligned_data_tx_ended_interval);
154+
if (this->device_model
155+
.get_optional_value<bool>(ControllerComponentVariables::RoundClockAlignedTimestamps)
156+
.value_or(false)) {
157+
meter_value.timestamp = utils::align_timestamp(DateTime{}, aligned_data_tx_ended_interval);
158+
}
151159
this->database_handler->transaction_metervalues_insert(this->transaction->transactionId.get(),
152160
meter_value);
153161
this->aligned_data_tx_end.clear_values();

0 commit comments

Comments
 (0)