void smilePrintHeader()
{
  SMILE_PRINT(" ");
  SMILE_PRINT(" =============================================================== ");
  SMILE_PRINT("   %s version %s",APPNAME,APPVERSION);
  SMILE_PRINT("   Build date: %s",APPDATE);
  SMILE_PRINT("   (c) %s by %s",APPCPYEAR,APPCPAUTHOR);
  SMILE_PRINT("   See the file COPYING for details on the license terms!");
  SMILE_PRINT("   %s",APPCPINST);
  SMILE_PRINT(" =============================================================== ");
  SMILE_PRINT(" ");
}
void cCommandlineParser::showUsage(const char *binname)
{
  smilePrintHeader();
  if (binname == NULL) {
    SMILE_PRINT("Usage: SMILExtract [-option (value)] ...");
  } else {
    SMILE_PRINT("Usage: %s [-option (value)] ...",binname);
  }
  SMILE_PRINT(" ");
  SMILE_PRINT(" -h    Show this usage information");
  SMILE_PRINT(" ");
  int i;
  for (i=0; i<N; i++) {
    const char *ty="";
    switch (opt[i].type) {
      case CMDOPT_BOOLEAN:
        if (opt[i].argMandatory) ty="<boolean 0/1>";
        else ty="[boolean 0/1]";
        break;
      case CMDOPT_INT:
        if (opt[i].argMandatory) ty="<integer value>";
       else ty="[integer value]";
        break;
      case CMDOPT_DOUBLE:
        if (opt[i].argMandatory) ty="<float value>";
        else ty="[float value]";
        break;
      case CMDOPT_STR:
        if (opt[i].argMandatory) ty="<string>";
        else ty="[string]";
        break;
      default:
        COMP_ERR("showUsage: unknown option type encountered! (ty=%i for opt # %i)",opt[i].type,i);
    }
    if (opt[i].abbr != 0) {
      SMILE_PRINT(" -%c, -%s  \t %s",opt[i].abbr,opt[i].name,ty);
    } else {
      SMILE_PRINT(" -%s      \t %s",opt[i].name,ty);
    }
    if (opt[i].description) {
      SMILE_PRINT("     %s",opt[i].description);
    }
    switch (opt[i].type) {
      case CMDOPT_BOOLEAN:
      case CMDOPT_INT:
        SMILE_PRINT("     {{ default = %i }}",opt[i].dfltInt);
        break;
      case CMDOPT_DOUBLE:
        SMILE_PRINT("     {{ default = %f }}",opt[i].dfltDouble);
        break;
      case CMDOPT_STR:
        SMILE_PRINT("     {{ default = '%s' }}",opt[i].dfltStr);
        break;
      default:
        COMP_ERR("showUsage: unknown option type encountered! (ty=%i for opt # %i)",opt[i].type,i);
    }
    SMILE_PRINT(" ");
  }
}
void cLibsvmLiveSink::processResult(long long tick, long frameIdx, double time, float res, double *probEstim, int nClasses, double dur)
{
  //ros::Rate loop_rate(10);

//  int count = 0;
//  while (ros::ok())
//  {
//// %EndTag(ROS_OK)%
//    /**
//     * This is a message object. You stuff it with data, and then publish it.
//     */
//// %Tag(FILL_MESSAGE)%
//    std_msgs::String msg;

//    std::stringstream ss;
//    ss << "hello world " << count;
//    msg.data = ss.str();
//// %EndTag(FILL_MESSAGE)%

//// %Tag(ROSCONSOLE)%
//    ROS_INFO("%s", msg.data.c_str());
//// %EndTag(ROSCONSOLE)%

//    /**
//     * The publish() function is how you send messages. The parameter
//     * is the message object. The type of this object must agree with the type
//     * given as a template parameter to the advertise<>() call, as was done
//     * in the constructor above.
//     */
//// %Tag(PUBLISH)%
//    chatter_pub.publish(msg);
//// %EndTag(PUBLISH)%

//// %Tag(SPINONCE)%
//    ros::spinOnce();
//// %EndTag(SPINONCE)%

//// %Tag(RATE_SLEEP)%
//    loop_rate.sleep();
//// %EndTag(RATE_SLEEP)%
//    ++count;
//  }

  std_msgs::String emoMsg;
  std_msgs::String affectMsg;

  if (printResult) {
    if ((nCls>0)&&(nClasses > 0)&&(classNames != NULL)) {
      if (labels!=NULL) {
        if ((int)res >= nClasses) res = (float)(nClasses-1);
        if (res < 0.0) res = 0.0;
        res = (float)labels[(int)res];
      }
      if ((int)res >= nCls) res = (float)nCls;
      if (res < 0.0) res = 0.0;
      SMILE_PRINT("\n LibSAVM  '%s' result (@ time: %f) :  ~~> %s <~~",getInstName(),time,classNames[(int)res]);
      std::string instName = getInstName();
      std::string emoName = "emodbEmotion";
      std::string affectName = "abcAffect";
      if (instName == emoName)
      {
          emoMsg.data = classNames[(int)res];
          emo_pub.publish(emoMsg);
      }
      if (instName == affectName)
      {
          affectMsg.data = classNames[(int)res];
          affect_pub.publish(affectMsg);
      }
    } else {
      SMILE_PRINT("\n LibSBVM  '%s' result (@ time: %f) :  ~~> %.2f <~~",getInstName(),time,res);
    }
    if (probEstim != NULL) {
      int i;
      for (i=0; i<nClasses; i++) {
        int idx = i;
        if (labels!=NULL) idx = labels[i];
        if ((nCls>0)&&(nClasses > 0)&&(classNames != NULL)) {
          if (idx >= nCls) idx=nCls-1;
          if (idx < 0) idx = 0;
          SMILE_PRINT("     prob. class '%s': \t %f",classNames[idx],probEstim[i]);
        } else {
          SMILE_PRINT("     prob. class %i : \t %f",idx,probEstim[i]);
        }
      }
    }
  }


  // send result as componentMessage 
  if (sendResult) {
    cComponentMessage msg("classificationResult", resultMessageName);
    if ((nCls>0)&&(nClasses > 0)&&(classNames != NULL)) {
      if (labels!=NULL) {
        if ((int)res >= nClasses) res = (float)(nClasses-1);
        if (res < 0.0) res = 0.0;
        res = (float)labels[(int)res];
      }
      if ((int)res >= nCls) res = (float)nCls;
      if (res < 0.0) res = 0.0;
      strncpy(msg.msgtext, classNames[(int)res], CMSG_textLen);
    }
    msg.floatData[0] = res;
    msg.intData[0]   = nClasses;
    msg.custData     = probEstim;
    msg.userTime1    = time;
    msg.userTime2    = time+dur;

    // TO TEST .....
    sendComponentMessage( resultRecp, &msg );
    SMILE_IDBG(3,"sending 'classificationResult' message to '%s'",resultRecp);
  }
}