示例#1
0
void MainWindow::dataReceived(int ind)
{
int  ret;
char buf[MAX_PRINTF_LENGTH] = "";

  //printf("data threadId = %ld\n", (long) QThread::currentThreadId());
  if(opt.arg_debug > 1) printf("rec1 ind=%d s=%d\n",ind,pvbtab[ind].s);
  if(pvbtab[ind].s == -1)
  {
    semaphore.release();
    return;
  }

  if(opt.arg_debug > 1) printf("dataReceived:\n");
  ret = tcp_rec(&pvbtab[ind].s, buf, sizeof(buf)-1);
  if(opt.arg_debug > 1) printf("%s",buf);
  if(ret == -1)
  {
    tcp_close(&pvbtab[ind].s);
    pvbtab[ind].s = -1;
    QPalette palette(QColor(255,0,0));
    statusBar()->setPalette(palette);
    statusBar()->showMessage(l_status_connection_lost);
    pvbtab[ind].rootWidget->setDisabled(1); 
    pvbtab[ind].interpreter.perhapsCloseModalDialog();
    qApp->beep();
  }
  else
  {
    pvbtab[ind].interpreter.interpret(buf);
  }
#ifdef PVUNIX
  if(opt.arg_debug) fflush(stdout);
#endif
  semaphore.release();
  if(opt.arg_debug > 1) printf("rec2\n");
}
示例#2
0
void PvGLWidget::gl_interpret()
{
  if(gldebug) printf("gl_interpret begin\n");
  char line[1024];

  //makeCurrent();
  update();
  while(1)
  {
#ifdef PVWIN32
retry: //XXXLEHRIG
#endif
    if(tcp_rec(s,line,sizeof(line)-1) < 0) 
    {
#ifdef PVWIN32
      goto retry;
#else
      return;
#endif
    }
#ifndef PVDEVELOP
    /*
    if(interpret(line) == -1) 
    {
      return;
    }
    */
    if(line[0] != 'g' || line[1] != 'l')
    {
      if(strncmp(line,"pvGlEnd()",9) == 0)
      {
        if(gldebug) printf("gl_interpret stop wait\n");
        char buf[100];
        sprintf( buf, "pvGlEnd()\n");
        tcp_send(s,buf,strlen(buf));
        if(gldebug) printf("gl_interpret end\n");
        return;
      }
    }
    else if(isValid()) // synchronous interpret opengl commands
    {
      if(gldebug) printf("without delay1 if(isValid)\n");      
      int lsize = list.size();
      if(lsize > 0)
      { // interpret the remembered commands
        int i;
        for(i=0; i<lsize; i++)
        {
          QString line = list.at(i);
          if(gldebug) printf("old_line:%s\n", (const char *) line.toUtf8());      
          interpret(line.toUtf8());
        }
        list.clear();
      }  
      if(gldebug) printf("without delay2 if(isValid) interpret:%s\n", line);      
      interpret(line);
    }
    else // remember opengl commands
    {
      if(gldebug) printf("list.append:%s\n", line);
      list.append(line);
    }  
#endif
  }
}