diff options
Diffstat (limited to 'examples/engine')
-rw-r--r-- | examples/engine/application-generated.cpp | 163 | ||||
-rw-r--r-- | examples/engine/signals.json | 68 |
2 files changed, 231 insertions, 0 deletions
diff --git a/examples/engine/application-generated.cpp b/examples/engine/application-generated.cpp new file mode 100644 index 00000000..cc123b7d --- /dev/null +++ b/examples/engine/application-generated.cpp @@ -0,0 +1,163 @@ +#include "application.hpp" +#include "../can/can-decoder.hpp" + +application_t::application_t() + : can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}} + , can_message_set_{ + {std::make_shared<can_message_set_t>(can_message_set_t{0,"example", + { // beginning can_message_definition_ vector + {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3D9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.speed", + 16, + 16, + 0.250000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "fuel.level.low", + 55, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "fuel.level", + 8, + 8, + 0.392157f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3E9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "vehicle.average.speed", + 0, + 15, + 0.0156250f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x4D1,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.oil.temp", + 16, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.oil.temp.high", + 7, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry + + }, // end can_message_definition vector + { // beginning diagnostic_messages_ vector + + } // end diagnostic_messages_ vector + })} // end can_message_set entry + } // end can_message_set vector +{ + for(auto& cms: can_message_set_) + { + std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition(); + for(auto& cmd : can_messages_definition) + { + cmd->set_parent(cms.get()); + std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals(); + for(auto& sig: can_signals) + { + sig->set_parent(cmd.get()); + } + } + + std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages(); + for(auto& dm : diagnostic_messages) + { + dm->set_parent(cms.get()); + } + } + } + +const std::string application_t::get_diagnostic_bus() const +{ + return ""; +} + + diff --git a/examples/engine/signals.json b/examples/engine/signals.json new file mode 100644 index 00000000..5aaf6564 --- /dev/null +++ b/examples/engine/signals.json @@ -0,0 +1,68 @@ +{ "name": "example", + "extra_sources": [], + "initializers": [], + "loopers": [], + "buses": {}, + "commands": [], + "messages": { + "0x3D9": { + "bus": "hs", + "signals": { + "PT_FuelLevelPct": { + "generic_name": "fuel.level", + "bit_position": 8, + "bit_size": 8, + "factor": 0.392157, + "offset": 0 + }, + "PT_EngineSpeed": { + "generic_name": "engine.speed", + "bit_position": 16, + "bit_size": 16, + "factor": 0.25, + "offset": 0 + }, + "PT_FuelLevelLow": { + "generic_name": "fuel.level.low", + "bit_position": 55, + "bit_size": 1, + "factor": 1, + "offset": 0, + "decoder": "decoder_t::booleanDecoder" + } + } + }, + "0x4D1": { + "bus": "hs", + "signals": { + "PT_EngineOilTempHigh": { + "generic_name": "engine.oil.temp.high", + "bit_position": 7, + "bit_size": 1, + "factor": 1, + "offset": 0, + "decoder": "decoder_t::booleanDecoder" + }, + "PT_EngineOilTemp": { + "generic_name": "engine.oil.temp", + "bit_position": 16, + "bit_size": 8, + "factor": 1, + "offset": 0 + } + } + }, + "0x3E9": { + "bus": "hs", + "signals": { + "PT_VehicleAvgSpeed": { + "generic_name": "vehicle.average.speed", + "bit_position": 0, + "bit_size": 15, + "factor": 0.015625, + "offset": 0 + } + } + } +} +} |