Skip to content

Commit

Permalink
Parser: add dot position property
Browse files Browse the repository at this point in the history
Signed-off-by: Norbert Takacs <[email protected]>
  • Loading branch information
norberttak committed May 1, 2024
1 parent c302d8d commit 057ec8d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/ConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ int Configparser::handle_on_lit_or_unlit_or_blink(IniFileSectionHeader section_h
int Configparser::handle_on_line_add(IniFileSectionHeader section_header, std::string key, std::string value, Configuration& config)
{
//line="on_select:SW_ALT,dataref:sim/custom/gauges/compas/pkp_helper_course_L"
//line="on_select:SW_ALT,dataref:sim/custom/gauges/compas/pkp_helper_course_L, dot_position: 2"
//line="on_select:SW_ALT,dataref:sim/custom/gauges/compas/pkp_helper_course_L, minimum_digit_number: 3"
//line="dataref:sim/custom/gauges/compas/pkp_helper_course_L"
//line="dataref:sim/custom/gauges/compas/test[0]
Expand Down Expand Up @@ -658,6 +659,21 @@ int Configparser::handle_on_line_add(IniFileSectionHeader section_header, std::s
}
}

std::string dot_position = "";
get_and_remove_token_pair(m, TOKEN_DOT_POSITION, dot_position);
if (dot_position != "")
{
if (section_header.name == TOKEN_SECTION_MULTI_DISPLAY)
config.class_configs.back().multi_displays[section_header.id]->set_dot_position(condition, stoi(dot_position));
else if (section_header.name == TOKEN_SECTION_DISPLAY)
config.class_configs.back().generic_displays[section_header.id]->set_dot_position(stoi(dot_position));
else
{
Logger(TLogLevel::logERROR) << "parser: invalid line for device type: " << section_header.name << std::endl;
return EXIT_FAILURE;
}
}

// at this point only the dataref/lua/const key-value pair shall remain
if (m.size() != 2)
{
Expand Down
1 change: 1 addition & 0 deletions src/core/ConfigParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Configparser
const std::string TOKEN_BCD = "bcd";
const std::string TOKEN_BLANK_LEADING_ZEROS = "blank_leading_zeros";
const std::string TOKEN_MIN_DIGIT_NUMBER = "minimum_digit_number";
const std::string TOKEN_DOT_POSITION = "dot_position";
const std::string TOKEN_ON_SELECT = "on_select";
const std::string TOKEN_BEGIN = "begin";
const std::string TOKEN_END = "end";
Expand Down

0 comments on commit 057ec8d

Please sign in to comment.