diff options
Diffstat (limited to 'server')
| -rw-r--r-- | server/src/widgetgenerator.cc | 35 | 
1 files changed, 35 insertions, 0 deletions
diff --git a/server/src/widgetgenerator.cc b/server/src/widgetgenerator.cc index 26dcf37..334d4a8 100644 --- a/server/src/widgetgenerator.cc +++ b/server/src/widgetgenerator.cc @@ -28,6 +28,36 @@  #include "configuration.h" +static std::string automap(std::string name) +{ +  std::string group; +  std::string groupcheck = "if("; + +  for(size_t i = 0; i < name.length(); i++) { +    group += name[i]; +    if(name[i] == '.') groupcheck += " and " + group; +    else groupcheck += name[i]; +  } +  groupcheck += " and " + name + ".value and " + name + ".timestamp"; +  groupcheck += ")\n"; + +  std::string automapstring = +    "-- Returning 0, 0 invalidates the result\n" +    "value = 0\n" +    "timestamp = 0\n" +    "\n" +    + groupcheck +  +    "then\n" +    "  value = " + name + ".value\n" +    "  timestamp = " + name + ".timestamp\n" +    "end\n" +    "return value, timestamp\n"; + +  printf("Automap:\n%s\n", automapstring.c_str()); + +  return automapstring; +} +  static std::string send_macro_widget(Macro ¯o,                                       Widget &widget,                                       std::string tabs, @@ -55,6 +85,11 @@ static std::string send_macro_widget(Macro ¯o,        li++;      } +    // Check to see if we should automap +    if(luamap == "") { +      luamap = automap(widget.attributes["map"]); +    } +          //    printf("LUAMAP: %s\n", luamap.c_str()); fflush(stdout);      if(luamap != "") {  | 
