void TNotificationClient::run(){
	if(serverHostname.isEmpty()){
		return;
	}
	if(sock==0){
		getSocket();
		if(sock->isValid()){
			connect(sock,SIGNAL(disconnected()),this,SLOT(socketClosed()));
			connect(sock,SIGNAL(readyRead()),this,SLOT(newDataAvailable()));
		}
		
	}
	exec();
}
Пример #2
0
void CGlw::refresh()
{
  static int k=0;
  rotation += 4;
    getMessage();
  int i,n=100000;
  for(i=0;i<n;i++)
  {
    updateEq(0.016/n);
  }
  emit newDataAvailable();
  
      //printf("%1.2f \n",(++k)*0.016);
      //fflush(stdout);
  updateGL();
}
// incoming data from external socket:
void KSocketTransactionHandler::processReadyReadData()
{
    qDebug() << " ---------------------------------------------------------------------";
    qDebug() << "KSocketTransactionHandler::processReadyReadData()";


    qint64 bytesAvail = tcpSocket->bytesAvailable();
    qDebug() << bytesAvail;
    QByteArray temp =  tcpSocket->read(bytesAvail);
    qDebug() << QString(temp.toHex());
    qDebug() << QString(temp);
    qDebug() << " ---------------------------------------------------------------------";


    emit newDataAvailable(temp, this);

    return;
}
Пример #4
0
void UResLaserIfObst::handleObst(USmlTag * tag)
{ // handle block with all obstacles in one update
  const int MSL = 200;
  char att[MAX_SML_NAME_LENGTH];
  char val[MSL];
  USmlTag nTag;
//  bool gotTime = false;
  ULineSegment lineSeg;
  bool gotData = false;
  /* format sample:
  <obst cnt="2" tod="1148031884.497858">
    <obstGrp cnt="3" serial="11" update="true">
      <poset name="first">
        <pose x="1162.565" y="1201.157" h="0.822"/>
        <timeofday tod="1148031884.497858"/>
      </poset>
        <poset name="last">
        <pose x="1163.969" y="1202.649" h="0.833"/>
        <timeofday tod="1148031886.772080"/>
      </poset>
      <obst serial="0" noChange="true"/>
      <obst hits="8" valid="true" serial="1">
         .........
      </obst>
      <obst hits="4" valid="true" serial="4">
         ............
      </obst>
    </obstGrp>
    <obstGrp cnt="12" serial="10" update="true">
      .........
    </obstGrp>
  </obst>
  */
  if (tag->cnnVerbose())
    printf("%s ...\n", tag->getTagStart());
  if (varOLog->getBool() != olog.isOpen())
    olog.openLog(varOLog->getBool());
  //
  while (tag->getNextAttribute(att, val, MSL))
  {
    if ((strcasecmp(att, "warning") == 0) or
         (strcasecmp(att, "info") == 0))
    {
      // no data printf("*** failed: %s\n", val);
      break;
    }
    else if (strcasecmp(att, "tod") == 0)
    {
      updTime.setTimeTod(val);
//      gotTime = true;
    }
  }
  if (tag->isAStartTag())
  {
    if (ogLock.tryLock())
    {
      while (tag->getNextTag(&nTag, 200))
      {
        if (nTag.isTagA("obstGrp"))
        { //
          handleObstGrp(&nTag);
          gotData = true;
        }
        else if (nTag.isAStartTag())
          // is an unwanted tag goup - skip
          nTag.skipToEndTag(200);
        // remember to test for endflag too
        else if (nTag.isTagAnEnd(tag->getTagName()))
          break;
      }
      ogLock.unlock();
    }
    else
    {
      //printf("The obstacle resource is locked -- postponding update\n");
      if (tag->isAStartTag())
      tag->skipToEndTag(200);
    }
  }
/*  if (not gotTime)
    // use current time
    updTime.now();*/
  if (gotData)
  {
    varUpdate->add(1);
    varGroups->setInt(groupsCnt);
    varTime->setTime(updTime);
    varSerial->setInt(latestSerial, 0);
    newDataAvailable();
  }
}
Пример #5
0
void UClientFuncPath::handlePathPolygonData(USmlTag * iTag)
{
  bool result;
  USmlTag tag;
  const int MSL = 100;
  char att[MAX_SML_NAME_LENGTH];
  char val[MSL];
  int n, cnt = 0;
  //bool hasEdge = false;
  UPosition * pos;
  UTime t;
  bool * isObst;
  //
  iTag->getNextTag(&tag, 200);
  result = tag.isTagA("UProbPoly");
  if (not result)
  { // unknown tag
    printReply(&tag, "UClientFuncPath::handlePathPolygonData: not mine?");
    // skip the rest until endtag.
    if (tag.isAStartTag())
      tag.skipToEndTag(200);
  }
  if (result and not tag.isAStartTag())
  { // is just a message or a false
    result = false;
    tag.print("");
  }
  if (result)
  { // read size
    while (tag.getNextAttribute(att, val, MSL))
    {
      if (strcasecmp(att, "count") == 0)
        n = sscanf(val, "%d", &cnt);
      else if (strcasecmp(att, "obstFlags") == 0)
        ; //hasEdge = str2bool(val);
    }
    result = (cnt > 0);
  }
  if (result)
  { // now get the guts of the message
    // that is either time or polygon data
    pos = poly->getPoints();
    isObst = poly->getIsObst();
    n = 0;
    while (iTag->getNextTag(&tag, 200))
    {
      if (tag.isTagA("pos2db"))
      {
        pos->z=0.0;
        while (tag.getNextAttribute(att, val, MSL))
        { // read 2d position with obstacle flag
          if (strcasecmp(att, "x") == 0)
            sscanf(val, "%le", &pos->x);
          if (strcasecmp(att, "y") == 0)
            sscanf(val, "%le", &pos->y);
          if (strcasecmp(att, "obst") == 0)
            *isObst = str2bool(val);
        }
        // debug
        //if (verboseMessages)
        //  printf("Got %d pos2db at %f,%f obst(%s)\n",
        //    n, pos->x, pos->y, bool2str(*isObst));
        // debug
        if (n < poly->getPointsMax())
        { // advance --- if space
          n++;
          pos++;
          isObst++;
        }
      }
      else if (tag.isTagA("time"))
      {
        tag.getTime(&t);
        poly->setTime(t);
        // debug
        //if (verboseMessages)
        //  printf("Got time\n");
        // debug end
      }
      else
      { // either an unknown extra information or an end tag
        if (tag.isAnEndTag())
          break;
        if (tag.isAStartTag())
          // extra grouped info
          tag.skipToEndTag(200);
      }
    }
    poly->setPointsCnt(n);
    result = n > 0;
    // debug
    //if (verboseMessages)
    //  printf("Got %d positions in polygon\n", n);
    // debug end
  }
  if (result)
    newDataAvailable(poly);
}
Пример #6
0
void serialPort::readyRead(){
    emit newDataAvailable();
}