Skip to content

Commit

Permalink
PRINT GA correctly in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankZRS committed Feb 2, 2024
1 parent ff15c7f commit 7cbb1cb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
35 changes: 25 additions & 10 deletions knx_iot_virtual_pb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class MyFrame : public wxFrame
void updateInfoButtons();
void updateTextButtons();
void bool2text(bool on_off, char* text);
void int2text(int value, char* text, bool as_ets=true);
void int2text(int value, char* text);
void int2gatext(uint32_t value, char* text, bool as_ets=false);
void int2grpidtext(uint64_t value, char* text, bool as_ets);
void int2scopetext(uint32_t value, char* text);
void double2text(double value, char* text);
Expand Down Expand Up @@ -561,7 +562,7 @@ void MyFrame::OnGroupObjectTable(wxCommandEvent& event)
strcat(text, line);
strcpy(line," ga : [");
for (int i = 0; i < entry->ga_len; i++) {
this->int2text(entry->ga[i], line, ga_conversion);
this->int2gatext(entry->ga[i], line, ga_conversion);
}
strcat(line," ]\n");
strcat(text, line);
Expand Down Expand Up @@ -637,7 +638,7 @@ void MyFrame::OnPublisherTable(wxCommandEvent& event)
if ( entry->ga_len > 0) {
strcpy(line," ga : [");
for (int i = 0; i < entry->ga_len; i++) {
this->int2text(entry->ga[i], line, ga_conversion);
this->int2gatext(entry->ga[i], line, ga_conversion);
}
strcat(line," ]\n");
strcat(text, line);
Expand Down Expand Up @@ -713,7 +714,7 @@ void MyFrame::OnRecipientTable(wxCommandEvent& event)
if ( entry->ga_len > 0) {
strcpy(line," ga : [");
for (int i = 0; i < entry->ga_len; i++) {
this->int2text(entry->ga[i], line, ga_conversion);
this->int2gatext(entry->ga[i], line, ga_conversion);
}
strcat(line," ]\n");
strcat(text, line);
Expand Down Expand Up @@ -885,7 +886,7 @@ void MyFrame::OnAuthTable(wxCommandEvent& event)
sprintf(line, " osc_ga : [");
strcat(text, line);
for (int i = 0; i < my_entry->ga_len; i++) {
this->int2text(my_entry->ga[i], text, ga_conversion);
this->int2gatext(my_entry->ga[i], text, ga_conversion);
}
sprintf(line, " ]\n");
strcat(text, line);
Expand Down Expand Up @@ -1024,11 +1025,25 @@ void MyFrame::bool2text(bool on_off, char* text)
/**
* @brief convert the integer to text for display
*
* @param on_off the integer
* @param text the text to add info too
* @param value the integer
* @param text the text to add info to
*/
void MyFrame::int2text(int value, char* text)
{
char value_text[50];

sprintf(value_text, " %d", value);
strcat(text, value_text);
}

/**
* @brief convert the group address to text for display
*
* @param value the integer
* @param text the text to add info to
* @param as_ets the text as terminology as used in ets
*/
void MyFrame::int2text(int value, char* text, bool as_ets)
void MyFrame::int2gatext(uint32_t value, char* text, bool as_ets)
{
char value_text[50];

Expand All @@ -1047,10 +1062,10 @@ void MyFrame::int2text(int value, char* text, bool as_ets)
uint32_t ga_main = (ga >> 11);
uint32_t ga_middle = (ga >> 8) & 0x7;
uint32_t ga_sub = (ga & 0x000000FF);
sprintf(value_text, " %d/%d/%d", ga_main, ga_middle, ga_sub);
sprintf(value_text, " %lu/%lu/%lu", ga_main, ga_middle, ga_sub);
strcat(text, value_text);
} else {
sprintf(value_text, " %d", value);
sprintf(value_text, " %lu", value);
strcat(text, value_text);
}
}
Expand Down
35 changes: 25 additions & 10 deletions knx_iot_virtual_sa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ class MyFrame : public wxFrame
void updateInfoButtons();
void updateTextButtons();
void bool2text(bool on_off, char* text);
void int2text(int value, char* text, bool as_ets=true);
void int2text(int value, char* text);
void int2gatext(uint32_t value, char* text, bool as_ets=false);
void int2grpidtext(uint64_t value, char* text, bool as_ets);
void int2scopetext(uint32_t value, char* text);
void double2text(double value, char* text);
Expand Down Expand Up @@ -585,7 +586,7 @@ void MyFrame::OnGroupObjectTable(wxCommandEvent& event)
strcat(text, line);
strcpy(line," ga : [");
for (int i = 0; i < entry->ga_len; i++) {
this->int2text(entry->ga[i], line, ga_conversion);
this->int2gatext(entry->ga[i], line, ga_conversion);
}
strcat(line," ]\n");
strcat(text, line);
Expand Down Expand Up @@ -661,7 +662,7 @@ void MyFrame::OnPublisherTable(wxCommandEvent& event)
if ( entry->ga_len > 0) {
strcpy(line," ga : [");
for (int i = 0; i < entry->ga_len; i++) {
this->int2text(entry->ga[i], line, ga_conversion);
this->int2gatext(entry->ga[i], line, ga_conversion);
}
strcat(line," ]\n");
strcat(text, line);
Expand Down Expand Up @@ -737,7 +738,7 @@ void MyFrame::OnRecipientTable(wxCommandEvent& event)
if ( entry->ga_len > 0) {
strcpy(line," ga : [");
for (int i = 0; i < entry->ga_len; i++) {
this->int2text(entry->ga[i], line, ga_conversion);
this->int2gatext(entry->ga[i], line, ga_conversion);
}
strcat(line," ]\n");
strcat(text, line);
Expand Down Expand Up @@ -909,7 +910,7 @@ void MyFrame::OnAuthTable(wxCommandEvent& event)
sprintf(line, " osc_ga : [");
strcat(text, line);
for (int i = 0; i < my_entry->ga_len; i++) {
this->int2text(my_entry->ga[i], text, ga_conversion);
this->int2gatext(my_entry->ga[i], text, ga_conversion);
}
sprintf(line, " ]\n");
strcat(text, line);
Expand Down Expand Up @@ -1048,11 +1049,25 @@ void MyFrame::bool2text(bool on_off, char* text)
/**
* @brief convert the integer to text for display
*
* @param on_off the integer
* @param text the text to add info too
* @param value the integer
* @param text the text to add info to
*/
void MyFrame::int2text(int value, char* text)
{
char value_text[50];

sprintf(value_text, " %d", value);
strcat(text, value_text);
}

/**
* @brief convert the group address to text for display
*
* @param value the integer
* @param text the text to add info to
* @param as_ets the text as terminology as used in ets
*/
void MyFrame::int2text(int value, char* text, bool as_ets)
void MyFrame::int2gatext(uint32_t value, char* text, bool as_ets)
{
char value_text[50];

Expand All @@ -1071,10 +1086,10 @@ void MyFrame::int2text(int value, char* text, bool as_ets)
uint32_t ga_main = (ga >> 11);
uint32_t ga_middle = (ga >> 8) & 0x7;
uint32_t ga_sub = (ga & 0x000000FF);
sprintf(value_text, " %d/%d/%d", ga_main, ga_middle, ga_sub);
sprintf(value_text, " %lu/%lu/%lu", ga_main, ga_middle, ga_sub);
strcat(text, value_text);
} else {
sprintf(value_text, " %d", value);
sprintf(value_text, " %lu", value);
strcat(text, value_text);
}
}
Expand Down

0 comments on commit 7cbb1cb

Please sign in to comment.