From 1d3f575df54f35de6618ef52d3fad697b7e2ef0d Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Tue, 19 Sep 2023 22:28:55 +0200 Subject: [PATCH] gui issues fixed. --- Changelog | 4 +++- guivalues.cc | 17 +++++++++-------- modbussrv.cc | 25 ------------------------- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/Changelog b/Changelog index 544c7ab..ec95769 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ -2023-09-17: +2023-09-19: +- performance issues fixed. +- gui issues if more than 200 values where added fixed. - closing connection if an error occured. 2023-09-16: diff --git a/guivalues.cc b/guivalues.cc index 8e9415b..bf0e2b1 100644 --- a/guivalues.cc +++ b/guivalues.cc @@ -226,8 +226,6 @@ gboolean Value_Loop(gpointer data) { v.reg = atoi(v_reg); v.type = v_type; v.sim = v_sim; - Value_Set (&v); - changed = Value_Simulation(&v); if (changed) { uint16_t regvals[4]; @@ -235,6 +233,14 @@ gboolean Value_Loop(gpointer data) { if (Value_SetValue(v.value, v.type, v.fc, ®stowrite, regvals)) { modbussrv.SetRegValue(v.fc, v.reg, regstowrite, (uint16_t*)regvals); } + gtk_list_store_set(GTK_LIST_STORE(model), &iter, + VALDATA_COL_NAME, v.name.c_str(), + VALDATA_COL_FC, std::to_string(v.fc).c_str(), + VALDATA_COL_REGSTART, std::to_string(v.reg).c_str(), + VALDATA_COL_TYPE, v.type.c_str(), + VALDATA_COL_VALUE, Value_GetValue(v.fc, v.reg, v.type).c_str(), + VALDATA_COL_SIM, v.sim.c_str(), + -1); } g_free(v_name); @@ -266,6 +272,7 @@ void Value_Set(GuiValue *g) { if (strcmp(v_name, g->name.c_str()) == 0) { Value_ModStore(model, &iter, g); changed = 1; + break; } g_free(v_name); } @@ -312,12 +319,6 @@ void Value_ModStore(GtkTreeModel *model, GtkTreeIter *iter, GuiValue *g) { VALDATA_COL_VALUE, Value_GetValue(g->fc, g->reg, g->type).c_str(), VALDATA_COL_SIM, g->sim.c_str(), -1); - - // for (int i = 0; i < 10; i++) { - // float *f = (float *)&modbusdata[2][i]; - // printf ("%f ", *f); - // } - // printf ("\n"); }; diff --git a/modbussrv.cc b/modbussrv.cc index b2e5542..55a8e5b 100644 --- a/modbussrv.cc +++ b/modbussrv.cc @@ -910,31 +910,6 @@ void ModbusSrv::SetRegValue(int fc, int regstart, int count, uint16_t *values) { g_mutex_lock(&servermutex); } -/* // debug del me - printf ("%s:%d %s regs (", __FILE__, __LINE__, __FUNCTION__); - std::string text; - text = ""; - if (fc == 5) fc = 1; - if (fc == 6) fc = 3; - if (fc == 15) fc = 1; - if (fc == 16) fc = 3; - for (int r = 0; r < count; r++) { - unsigned char c; - char hexnum[] = "0123456789ABCDEF"; - - c = *(((unsigned char *)&mbarray[fc-1][regstart+r])+0); - text += hexnum[c/16]; - text += hexnum[c%16]; - - c = *(((unsigned char *)&mbarray[fc-1][regstart+r])+1); - text += hexnum[c/16]; - text += hexnum[c%16]; - - text += ":"; - } - - printf ("%s)\n", text.c_str()); -*/ g_mutex_unlock(&servermutex); };