#pragma once #include #include #include #include #include #include #include #include "CanMessage.h" #include "types.h" {%- if cpp_namespace is defined and cpp_namespace is not none %} namespace {{ cpp_namespace }} { {%- endif %} enum MsgId : quint16 { {%- for (msg_id_value, msg) in msg_cpp.data.items() %} {{ msg['msg_id'] }} = {{ msg['msg_id_hex_string'] }}, {%- endfor %} }; QString msgIdString(const MsgId msgId); enum ParamType { {%- for type in msg_cpp.paramTypes %} {{ type }}, {%- endfor %} }; // typedef union { // Types::U08 uint8Value; // Types::U16 uint16Value; // Types::U32 uint32Value; // Types::S08 int8Value; // Types::S16 int16Value; // Types::S32 int32Value; // Types::F32 floatValue; // } ParamUnion; union ParamUnion { uint8_t uint8Value; uint16_t uint16Value; uint32_t uint32Value; int8_t int8Value; int16_t int16Value; int32_t int32Value; float floatValue; uint8_t bytes[std::max(sizeof(float), sizeof(uint32_t))]; }; {%- if msg_cpp.data.items() | length %} const QMap payloadSize = { {%- for (msg_id_value, msg) in msg_cpp.data.items() %} { {{ msg['msg_id'] }}, {{ msg['cpp_struct']['payload_size'] }} }, {%- endfor %} }; {%- endif %} {%- for (msg_id_value, msg) in msg_cpp.data.items() %} // {{ msg['msg_id'] }} ({{ msg['msg_id_hex_string'] }}) // payload: {{ msg_cpp.field_list(msg_id_value) | join(", ") }} struct {{ msg['msg_name'] }}Payload { {%- for field in msg['cpp_struct']['payload'] %} {%- if field['type'] == "union" %} union {{ field['name'] }}; {%- else %} Types::{{ field['type'] }} {{ field['name'] }}; {%- endif %} {%- endfor %} {%- if msg['cpp_struct']['payload'] | length %} {% endif %} bool fromQByteArray(const QByteArray &src); void toQByteArray(QByteArray &dst) const; void dump() const; }; {%- endfor %} {%- if cpp_namespace is defined and cpp_namespace is not none %} } // namespace {{ cpp_namespace }} {%- endif %}