Exemplo n.º 1
0
/*!
 * \en 	Handler line current change signal. \_en
 * \ru	Обработчик сигнала изменения строки. Генерирует сигналы
 * deleteLine и saveLine. \_ru
 */
void
wDBTable::lineUpdate( QSql::Op mode)
{
QSqlRecord *rec = sqlCursor()->editBuffer();//currentRecord();
	switch(mode)
	{
		case QSql::Update:
	//	rec =  currentRecord();
		break;
		case QSql::Insert:
		break;
		case QSql::Delete:
		//printf("emit del line\n");
		emit(deleteLine(rec));
		return;
		default:
		break;
	}
	//if(!rec) return;
	//printf(" emit saveLine\n");
	emit(saveLine(rec));
}
Exemplo n.º 2
0
void Connection::finishCon(InputTaker* i)
{
    in=i;
   
    //must remove line already going into this input, IF it exist
    //in->remLine();
    if(in->line!=NULL)
        removeLine(in->line);
   
    //make the actual Value** connection
    in->setInput(out);
   
    inpos =  in->getPos();
    inpos.x+=inpos.w/2;
    inpos.y+=inpos.h/2;
   
    LineData* line = saveLine();
   
    //use this new line(when comps move they update line)
    in->setLine(line);
    out->setLine(line);
   
    reset();
}
Exemplo n.º 3
0
void dataInputHandler1(struct WorkerBuf* pWBuf, uint8_t* data)
{
  int sock;
  int rvl;
  int i;
  int len;
  uint32_t flag;
  uint8_t chanId;
  struct DataHeader *pHeader;
  struct FrameBuf   *frame;
  int total_len = FVL_SRIO_DMA_BUFSIZE/FVL_SRIO_CTL_SUBBUF_NUM;

  printf("Calling dataInputHandler: total length: %d \n",total_len);
  if(0)
    {
	  char strbuf[32];
	  snprintf(strbuf, 32, "cpu-%02d recv", pWBuf->cpu);
	  fvl_hex_dump(strbuf, data, 128);
    }

  LTRACE();
  if(pWBuf->line_length != 0) {
	char *dest;

	dest  = pWBuf->last_line.data;
	dest += pWBuf->line_length;
	memcpy(dest, data, pWBuf->line_restlen);

    LTRACE();
	pHeader = (void*) pWBuf->last_line.data;
	flag    = ntohl(pHeader->flag);
	if(DATA_HEADER_FLAG != flag) {
	  printf("Data last line error! Flag = %x\n", flag);
	}

	frame = saveLine(pWBuf, pHeader);
	if(frame == NULL) {
	  printf("Save last line failed\n");
	}

    LTRACE();
	data      += pWBuf->line_restlen;
	total_len -= pWBuf->line_restlen;

	pWBuf->line_length  = 0;
	pWBuf->line_restlen = 0;
  }

  i = 0;
  while(total_len > 0) {

	pHeader = (void*) data;
	chanId  = pHeader->chanId;
	len     = GETLEN_BY_CHANID(chanId);

    //LTRACE();
	flag    = ntohl(pHeader->flag);
	if(DATA_HEADER_FLAG != flag) {
	  printf("Data #%d error! Flag = %x\n", i, flag);
	  continue;
	}

    //LTRACE();
	frame = saveLine(pWBuf, pHeader);
	if(frame == NULL) {
	  printf("Save line #%d failed\n", pHeader->lineId);
	}
	//else {
	//      printf("Save line #%d success\n", pHeader->lineId);
	//  }

	data      += len;
	total_len -= len;

	if((total_len != 0) && (total_len < len)) {
	  LTRACE();
	  //    fvl_hex_dump("Copylast", data, 128);
	  pWBuf->line_length  = total_len;
	  pWBuf->line_restlen = len - total_len;
	  printf("copy to %p, from %p, size %d\n", pWBuf->last_line.data, data, total_len);
	  memcpy(pWBuf->last_line.data, data, total_len);

	  pHeader = (void*) pWBuf->last_line.data;
	  flag    = ntohl(pHeader->flag);
	  if(DATA_HEADER_FLAG != flag) {
		printf("Copy data last line error! Flag = %x\n", flag);
	  }

	  break;
	}

	i++;
  }

  LTRACE();
  do{
    LTRACE();
	frame = getFullFrame(pWBuf);
	if(frame == NULL) {
	  break;
	}

    LTRACE();
	chanId = pHeader->chanId;
	sock = getSocket(chanId); 

    LTRACE();
	for(i = 0; i < 256; i++) {
	  struct DataLine *line;

	  line = &frame->lines[i];
	  pHeader = (void*) line->header;
	  chanId = pHeader->chanId;
	  len = GETLEN_BY_CHANID(chanId);
	  // send buffer here
	  rvl = fvl_tcp_send(sock, (void*)line->data, len);
	  if(rvl < 0) {
		printf("Send failed!\n");
	  }
	}

	printf("send frame #%d done\n", pHeader->frameId);
	freeFrame(frame);
  } while(1);

  return;
}
Exemplo n.º 4
0
/* ********************************************************************************************* */
void RRT::draw (const RRT* t1, const RRT* t2) {

	// Check the size of a data point - we can only visualize 2 or 3
	size_t numDofs = t1->dofs.size();
	if((numDofs != 2) && (numDofs != 3)) return;

	// ====================================================================
	// Write the data to a file

	// File contains two lines, one for each endpoint of an edge
	FILE* data = fopen(".data", "w");
	size_t step = numDofs * 7;											// 7 characters per double
	size_t numEdges1 = (t1->configVector.size() - 1);
	size_t numEdges2 = ((t2 == NULL) ? 0 : t2->configVector.size() - 1);
	char* line1 = new char[(numEdges1 + numEdges2 + 5) * step];
	char* line2 = new char[(numEdges1 + numEdges2 + 5) * step];

	// Write each node and its parent in the respective lines
	size_t lineIndex = 0;
	const RRT* trees [2] = {t1, t2};
	for(size_t t = 0; t < 2; t++) {

		// Skip the tree if not there
		if(trees[t] == NULL) continue;

		// Draw the edges
		size_t numEdges = trees[t]->configVector.size() - 1;
		for(size_t i = 0; i < numEdges; i++, lineIndex += step) {
			const VectorXd& node = *trees[t]->configVector[i + 1];
			const VectorXd& parent = *trees[t]->configVector[trees[t]->parentVector[i + 1]];
			saveLine(line1, line2, lineIndex, node, parent);
		}
	}

	// Print the start to draw with a special color (we draw a 0 length edge)
	const VectorXd& goal = *t1->configVector[0];
	saveLine(line1, line2, lineIndex, goal, goal);
	lineIndex += step;

	// Write the lines to the file
	fprintf(data, "%s\n", line1);
	fprintf(data, "%s\n", line2);
	fclose(data);

	delete[] line1;
	delete[] line2;

	// ====================================================================
	// Run gnuplot with the pipe call

	// Open gnuplot in a shell terminal
	FILE* gnuplot;
	gnuplot = fopen(".gnuplot", "w");

	// Set options
	fprintf(gnuplot, "");
	fprintf(gnuplot, "set terminal wxt size 600,600;\n");
	fprintf(gnuplot, "set xrange [-3.14:3.14];\n");
	fprintf(gnuplot, "set yrange [-3.14:3.14];\n");
	fprintf(gnuplot, "set size ratio -1;\n");
	if(numDofs == 3) {
		fprintf(gnuplot, "set zrange [-3.14:3.14];\n");
		fprintf(gnuplot, "set xyplane at -3.14;\n");
	}

	// Draw the edges in the file but leave the last edge to draw a special color for the goal
	fprintf(gnuplot, "%s ", ((numDofs == 2) ? "plot" : "splot"));
	for(size_t i = 0; i < numEdges1; i++) 
		drawLine(gnuplot, numDofs, "0000ff", i);
	for(size_t i = 0; i < numEdges2; i++) 
		drawLine(gnuplot, numDofs, "00ffff", i + numEdges1);
	
	// Draw the goal point (fake edge)
	drawLine(gnuplot, numDofs, "00ff00", numEdges1 + numEdges2, true); 

	// Close the pipe
	fprintf(gnuplot, "\n");
	fprintf(gnuplot, "\n");
	fclose(gnuplot);

	// Make the system call
	int status = system("gnuplot -persist .gnuplot");
	assert((status != -1) && "Error in system call in RRT::draw()");
}