Skip to content

Commit 6ad3712

Browse files
authored
EV 355: Consider & verify "default" and "required" settings for Device Model Variable Attributes (#269)
* add default parsing Signed-off-by: Fabian Klemm <fabian.klemm@pionix.de> * add tests; inject into chargepoint Signed-off-by: Fabian Klemm <fabian.klemm@pionix.de> * run format Signed-off-by: Fabian Klemm <fabian.klemm@pionix.de> * fix integrity sql query Signed-off-by: Fabian Klemm <fabian.klemm@pionix.de> * add default values for required custom telemetry data; improve on error log Signed-off-by: Fabian Klemm <fabian.klemm@pionix.de> * fix codacy issues Signed-off-by: Fabian Klemm <fabian.klemm@pionix.de> * fix codacy issues Signed-off-by: Fabian Klemm <fabian.klemm@pionix.de> --------- Signed-off-by: Fabian Klemm <fabian.klemm@pionix.de>
1 parent 4cff8fe commit 6ad3712

24 files changed

+716
-243
lines changed

config/v201/CMakeLists.txt

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ if (LIBOCPP_INSTALL_DEVICE_MODEL_DATABASE)
2424
)
2525

2626
set(INIT_DEVICE_MODULE_DB_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/init_device_model_db.py")
27-
set(INSERT_DEVICE_MODULE_CONFIG_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/insert_device_model_config.py")
2827
set(DEVICE_MODEL_DATABASE_FILE "device_model_storage.db")
2928

3029
if(NOT LIBOCPP_V201_CONFIG_FILE)
@@ -39,15 +38,15 @@ if (LIBOCPP_INSTALL_DEVICE_MODEL_DATABASE)
3938
message(STATUS "Using ocpp v201 config file path: ${LIBOCPP_V201_CONFIG_FILE}")
4039

4140
execute_process(
42-
COMMAND
43-
${PYTHON_EXECUTABLE} ${INIT_DEVICE_MODULE_DB_SCRIPT} --out ${CMAKE_CURRENT_BINARY_DIR}/${DEVICE_MODEL_DATABASE_FILE} --schemas ${LIBOCPP_COMPONENT_SCHEMAS_PATH}
41+
COMMAND
42+
${PYTHON_EXECUTABLE} ${INIT_DEVICE_MODULE_DB_SCRIPT} init --db ${CMAKE_CURRENT_BINARY_DIR}/${DEVICE_MODEL_DATABASE_FILE} --schemas ${LIBOCPP_COMPONENT_SCHEMAS_PATH}
4443
WORKING_DIRECTORY
4544
${CMAKE_CURRENT_SOURCE_DIR}
4645
)
4746

4847
execute_process(
49-
COMMAND
50-
${PYTHON_EXECUTABLE} ${INSERT_DEVICE_MODULE_CONFIG_SCRIPT} --db ${CMAKE_CURRENT_BINARY_DIR}/${DEVICE_MODEL_DATABASE_FILE} --config ${LIBOCPP_V201_CONFIG_FILE}
48+
COMMAND
49+
${PYTHON_EXECUTABLE} ${INIT_DEVICE_MODULE_DB_SCRIPT} insert --db ${CMAKE_CURRENT_BINARY_DIR}/${DEVICE_MODEL_DATABASE_FILE} --schemas ${LIBOCPP_COMPONENT_SCHEMAS_PATH} --config ${LIBOCPP_V201_CONFIG_FILE}
5150
WORKING_DIRECTORY
5251
${CMAKE_CURRENT_SOURCE_DIR}
5352
)

config/v201/component_schemas/custom/Connector_1_1.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
}
3434
],
3535
"description": "Component exists",
36-
"type": "boolean"
36+
"type": "boolean",
37+
"default": "0"
3738
},
3839
"ChargeProtocol": {
3940
"variable_name": "ChargeProtocol",
@@ -62,7 +63,8 @@
6263
}
6364
],
6465
"description": "A value of ConnectorEnumType (See part 2) plus additionally: cGBT, cChaoJi, OppCharge. Specific type of connector, including sub-variant information. Note: Distinct and orthogonal to Charging Protocol, Power Type, Phases.",
65-
"type": "string"
66+
"type": "string",
67+
"default": ""
6668
},
6769
"ConnectorSupplyPhases": {
6870
"variable_name": "SupplyPhases",
@@ -77,7 +79,8 @@
7779
}
7880
],
7981
"description": "Number of alternating current phases connected/available.",
80-
"type": "integer"
82+
"type": "integer",
83+
"default": "0"
8184
}
8285
},
8386
"required": [

config/v201/component_schemas/custom/Connector_2_1.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
}
3434
],
3535
"description": "Component exists",
36-
"type": "boolean"
36+
"type": "boolean",
37+
"default": "0"
3738
},
3839
"ChargeProtocol": {
3940
"variable_name": "ChargeProtocol",
@@ -62,7 +63,8 @@
6263
}
6364
],
6465
"description": "A value of ConnectorEnumType (See part 2) plus additionally: cGBT, cChaoJi, OppCharge. Specific type of connector, including sub-variant information. Note: Distinct and orthogonal to Charging Protocol, Power Type, Phases.",
65-
"type": "string"
66+
"type": "string",
67+
"default": ""
6668
},
6769
"ConnectorSupplyPhases": {
6870
"variable_name": "SupplyPhases",
@@ -77,7 +79,8 @@
7779
}
7880
],
7981
"description": "Number of alternating current phases connected/available.",
80-
"type": "integer"
82+
"type": "integer",
83+
"default": "0"
8184
}
8285
},
8386
"required": [

config/v201/component_schemas/custom/EVSE_1.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
}
3434
],
3535
"description": "This variable reports current availability state for the EVSE",
36-
"type": "string"
36+
"type": "string",
37+
"default": "Unavailable"
3738
},
3839
"EVSEAvailable": {
3940
"variable_name": "Available",
@@ -48,7 +49,8 @@
4849
}
4950
],
5051
"description": "Component exists",
51-
"type": "boolean"
52+
"type": "boolean",
53+
"default": "0"
5254
},
5355
"EvseId": {
5456
"variable_name": "EvseId",
@@ -78,7 +80,8 @@
7880
}
7981
],
8082
"description": " kW,The variableCharacteristic maxLimit, that holds the maximum power that this EVSE can provide, is required. The Actual value of the instantaneous (real) power is desired, but not required.",
81-
"type": "number"
83+
"type": "number",
84+
"default": "0"
8285
},
8386
"EVSESupplyPhases": {
8487
"variable_name": "SupplyPhases",
@@ -93,7 +96,8 @@
9396
}
9497
],
9598
"description": "Number of alternating current phases connected/available.",
96-
"type": "integer"
99+
"type": "integer",
100+
"default": "0"
97101
},
98102
"ISO15118EvseId": {
99103
"variable_name": "ISO15118EvseId",

config/v201/component_schemas/custom/EVSE_2.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
}
3434
],
3535
"description": "This variable reports current availability state for the EVSE",
36-
"type": "string"
36+
"type": "string",
37+
"default": "Unavailable"
3738
},
3839
"EVSEAvailable": {
3940
"variable_name": "Available",
@@ -48,7 +49,8 @@
4849
}
4950
],
5051
"description": "Component exists",
51-
"type": "boolean"
52+
"type": "boolean",
53+
"default": "0"
5254
},
5355
"EvseId": {
5456
"variable_name": "EvseId",
@@ -78,7 +80,8 @@
7880
}
7981
],
8082
"description": " kW,The variableCharacteristic maxLimit, that holds the maximum power that this EVSE can provide, is required. The Actual value of the instantaneous (real) power is desired, but not required.",
81-
"type": "number"
83+
"type": "number",
84+
"default": "0"
8285
},
8386
"EVSESupplyPhases": {
8487
"variable_name": "SupplyPhases",
@@ -93,7 +96,8 @@
9396
}
9497
],
9598
"description": "Number of alternating current phases connected/available.",
96-
"type": "integer"
99+
"type": "integer",
100+
"default": "0"
97101
},
98102
"ISO15118EvseId": {
99103
"variable_name": "ISO15118EvseId",

config/v201/init_device_model.sql

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ CREATE TABLE IF NOT EXISTS VARIABLE_MONITORING (
4343
"TRANSACTION" INTEGER,
4444
TYPE_ID INTEGER,
4545
"VALUE" DECIMAL,
46-
FOREIGN KEY (VARIABLE_ID) REFERENCES VARIABLE(ID) FOREIGN KEY (TYPE_ID) REFERENCES MONITOR (ID)
46+
FOREIGN KEY (VARIABLE_ID) REFERENCES VARIABLE (ID),
47+
FOREIGN KEY (TYPE_ID) REFERENCES MONITOR (ID)
4748
);
4849
CREATE TABLE IF NOT EXISTS VARIABLE (
4950
ID INTEGER PRIMARY KEY AUTOINCREMENT,
5051
NAME TEXT,
5152
INSTANCE TEXT,
5253
COMPONENT_ID INTEGER,
5354
VARIABLE_CHARACTERISTICS_ID INTEGER,
55+
REQUIRED INTEGER DEFAULT FALSE,
5456
FOREIGN KEY (COMPONENT_ID) REFERENCES COMPONENT (ID),
5557
FOREIGN KEY (VARIABLE_CHARACTERISTICS_ID) REFERENCES VARIABLE_CHARACTERISTICS (ID)
5658
);

0 commit comments

Comments
 (0)