-
-/*
- * Build a specific VehicleMessage containing a SimpleMessage.
- */
-openxc_VehicleMessage build_VehicleMessage_with_SimpleMessage(openxc_DynamicField_Type type,
- openxc_SimpleMessage message)
-{
- struct timeb t_msec;
- long long int timestamp_msec;
- if(!ftime(&t_msec))
- {
- timestamp_msec = ((long long int) t_msec.time) * 1000ll +
- (long long int) t_msec.millitm;
-
- return openxc_VehicleMessage v = {.has_type = true,
- .type = openxc_VehicleMessage_Type::openxc_VehicleMessage_Type_SIMPLE,
- .has_simple_message = true,
- .simple_message = message,
- .has_timestamp = true,
- .timestamp = timestamp_msec};
- }
-
- return openxc_VehicleMessage v = {.has_type = true,
- .type = openxc_VehicleMessage_Type::openxc_VehicleMessage_Type_SIMPLE,
- .has_simple_message = true,
- .simple_message = message};
-}
-
-/*
- * Build an openxc_SimpleMessage associating a name to an openxc_DynamicField
- */
-openxc_SimpleMessage build_SimpleMessage(std:string name, openxc_DynamicField value)
-{
- return openxc_SimpleMessage s = {.has_name = true,
- .name = name,
- .has_value = true,
- .value = value};
-}
-
-
-}
-
-/*
- * Build an openxc_DynamicField using its type and an union.
- * Why do not use of union in first place anyway...
- */
-openxc_DynamicField build_DynamicField(openxc_DynamicField_Type type, DynamicField field)
-{
- openxc_DynamicField d = {.has_type = true,
- .type = type};
-
- switch(type)
- {
- case openxc_DynamicField_Type_BOOL:
- d.has_boolean_value = true;
- d.boolean_value = field;
- break;
- case openxc_DynamicField_Type_NUM:
- d.has_numeric_value = true;
- d.numeric_value = field;
- break;
- case openxc_DynamicField_Type_STRING:
- d.has_string_value = true;
- strcpy(d.string_value, field);
- break;
- default:
- return nullptr;
- }
-
- return d;
-}
\ No newline at end of file