FACT++  1.0
void FactGui::infoHandlerService ( DimInfo info)
inlineprivate

Definition at line 2911 of file FactGui.h.

References Time::GetAsStr(), DimInfo::getData(), DimInfo::getFormat(), DimInfo::getName(), DimInfo::getSize(), Converter::GetString(), DimInfo::getTimestamp(), DimInfo::getTimestampMillisecs(), handleDimService(), and str.

2912  {
2913  const string fmt = string(info.getFormat()).empty() ? "C" : info.getFormat();
2914 
2915  stringstream dummy;
2916  const Converter conv(dummy, fmt, false);
2917 
2918  const Time tm(info.getTimestamp(), info.getTimestampMillisecs()*1000);
2919 
2920  stringstream out;
2921  out << "<font size'-1' color='navy'>[";
2922  out << tm.GetAsStr("%H:%M:%S.%f").substr(0,12);
2923  out << "]</font> <B>" << info.getName() << "</B> - ";
2924 
2925  bool iserr = 2;
2926  if (!conv)
2927  {
2928  out << "Compilation of format string '" << fmt << "' failed!";
2929  }
2930  else
2931  {
2932  try
2933  {
2934  const string dat = info.getSize()==0 ? "&lt;empty&gt;" : conv.GetString(info.getData(), info.getSize());
2935  out << dat;
2936  iserr = info.getSize()==0;
2937  }
2938  catch (const runtime_error &e)
2939  {
2940  out << "Conversion to string failed!<pre>" << e.what() << "</pre>";
2941  }
2942  }
2943 
2944  // srand(hash<string>()(string(info.getName())));
2945  // int bg = rand()&0xffffff;
2946 
2947  int bg = hash<string>()(string(info.getName()));
2948 
2949  // allow only light colors
2950  bg = ~(bg&0x1f1f1f)&0xffffff;
2951 
2952  if (iserr==2)
2953  bg = 0xffffff;
2954 
2955  stringstream bgcol;
2956  bgcol << hex << setfill('0') << setw(6) << bg;
2957 
2958  const string col = iserr==0 ? "black" : (iserr==1 ? "#FF6600" : "black");
2959  const string str = "<table width='100%' bgcolor=#"+bgcol.str()+"><tr><td><font color='"+col+"'>"+out.str()+"</font></td></tr></table>";
2960 
2961  QApplication::postEvent(this,
2962  new FunctionEvent(bind(&FactGui::handleDimService, this, str)));
2963  }
char * getFormat()
Definition: diccpp.cxx:120
void handleDimService(const string &txt)
Definition: FactGui.h:2906
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
int getTimestampMillisecs()
Definition: diccpp.cxx:114
int getSize()
Definition: dic.hxx:100
int getTimestamp()
Definition: diccpp.cxx:107
void * getData()
Definition: diccpp.cxx:213
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
Definition: Time.cc:240
A compiler for the DIM data format string.
Definition: Converter.h:16
char * getName()
Definition: dic.hxx:101

+ Here is the call graph for this function: