예제 #1
0
파일: fight.cpp 프로젝트: q4a/attal
void Fight::slot_animateFighting()
{
	attalFightData dataFight;

	if( !_attData->isEmpty() ) {
		if(  !_animatedUnit || !_animatedUnit->isMoving() ) { 
			dataFight = _attData->first();
			processData( dataFight );
			_attData->removeFirst();
		}
		if(  _animatedUnit && _animatedUnit->isMoving() ) {
			dataFight = _attData->first();
			while(( _animatedUnit == dataFight.unit && dataFight.dataType == FIGHT_DATA_MOVE ) ) {
				processData( dataFight );
				_attData->removeFirst();
				dataFight = _attData->first();
			}
		}
	} else {
		_animatedUnit = NULL;
	}

	checkTimer();

}
예제 #2
0
void DocumentLoader::dataReceived(Resource* resource,
                                  const char* data,
                                  size_t length) {
  DCHECK(data);
  DCHECK(length);
  DCHECK_EQ(resource, m_mainResource);
  DCHECK(!m_response.isNull());
  DCHECK(!m_frame->page()->defersLoading());

  if (m_inDataReceived) {
    // If this function is reentered, defer processing of the additional data to
    // the top-level invocation. Reentrant calls can occur because of web
    // platform (mis-)features that require running a nested message loop:
    // - alert(), confirm(), prompt()
    // - Detach of plugin elements.
    // - Synchronous XMLHTTPRequest
    m_dataBuffer->append(data, length);
    return;
  }

  AutoReset<bool> reentrancyProtector(&m_inDataReceived, true);
  processData(data, length);

  // Process data received in reentrant invocations. Note that the invocations
  // of processData() may queue more data in reentrant invocations, so iterate
  // until it's empty.
  const char* segment;
  size_t pos = 0;
  while (size_t length = m_dataBuffer->getSomeData(segment, pos)) {
    processData(segment, length);
    pos += length;
  }
  // All data has been consumed, so flush the buffer.
  m_dataBuffer->clear();
}
예제 #3
0
void SignalProcessor::input(double red, double green, double blue) {
	qDebug() << "SignalProcessor: set Input" << red << green << blue;

	processData(dataRedIn, dataRedOut, red);
	processData(dataGreenIn, dataGreenOut, green);
	processData(dataBlueIn, dataBlueOut, blue);

	emit output(dataRedOut->last(), dataGreenOut->last(), dataBlueOut->last());
	qDebug() << "SignalProcessor: output " << dataRedOut->last() << dataGreenOut->last() << dataBlueOut->last();
}
예제 #4
0
//***********************************************************
//* Process a <noteresource> node.
//***********************************************************
void ImportEnex::processResource(Resource &resource) {
    bool atEnd = false;

    resource.active = true;

    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            QUuid uuid;
            QString g =  uuid.createUuid().toString().replace("{","").replace("}","");
            resource.guid = g;
            if (name == "active") {
                resource.active =  booleanValue();
            }
            if (name == "mime") {
                resource.mime = textValue();
            }
            if (name == "duration") {
                resource.duration = shortValue();
            }
            if (name == "height") {
                resource.height = shortValue();
            }
            if (name == "width") {
                resource.width = shortValue();
            }
            if (name == "data") {
                Data d;
                resource.data = d;
                processData("Data", resource.data);
            }
            if (name == "alternate-data") {
                Data d;
                resource.alternateData = d;
                processData("AlternateData", resource.data);
            }
            if (name == "recognition-data") {
                Data d;
                resource.recognition = d;
                processData("RecognitionData", resource.recognition);
            }
            if (name == "resource-attributes") {
                ResourceAttributes ra;
                resource.attributes = ra;
                processResourceAttributes(resource.attributes);
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "resource" && reader->isEndElement())
            atEnd = true;
    }
}
예제 #5
0
void TcpSockServer::incomingConnection(int socketDescriptor)
{
    qRegisterMetaType <Qlist>("Qlist");

   // qDebug() << QString("Client %1 Comming").arg(socketDescriptor);
    TcpConThread *thread = new TcpConThread(socketDescriptor, this);
//    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    connect(this,SIGNAL(sendKeySettingRequest(Device,RegOperation)),
            thread,SLOT(sendKeySettingRequest(Device,RegOperation)));
    connect(this,SIGNAL(grabWindow()),thread,SLOT(sendGrabWindowRequest()));
    connect(thread,SIGNAL(processData(Qlist)),
            this,SIGNAL(processData(Qlist)));
    thread->start();
}
예제 #6
0
void SAXMzxmlHandler::endElement(const XML_Char *el)
{
	if(isElement("peaks", el))
	{
		processData();
		m_bInPeaks = false;
	}
	else if(isElement("precursorMz", el))
	{
		processData();
		m_bInPrecursorMz = false;
	}
	else if(isElement("scan", el) && m_bInMsLevel2 == true)
	{
		// only add a spectrum without charge (which will lead
		// to internal xtandem charge state guessing) if there
		// were no values parsed from *both* "precursorCharge"
		// or "possibleCharges"
		if ( (m_precursorCharge == 0) && (m_viPossiblePrecursorCharges.size() == 0) ) {
		  // add spectrum, with precursorMz charge
		  pushSpectrum();
		}
		
		else {

		  // add the spectrum with the m_precursorCharge value
		  int originalPrecursorMZ = m_precursorCharge; // do other pushSpectrum calls change this?
		  pushSpectrum(m_precursorCharge);
		  
		  // are there any multiple precursor charges from mzXML 3.1's
		  // possibleCharges?
		  if (m_viPossiblePrecursorCharges.size() > 0) {
		    size_t originalId = m_tId;
		    for (vector<int>::iterator i = m_viPossiblePrecursorCharges.begin();
			 i != m_viPossiblePrecursorCharges.end();
			 ++i) {
		      int z = *i;
		      if (z != originalPrecursorMZ) { // no need to duplicate if already added
			m_tId += 100000000;
			pushSpectrum(z);
		      }
		    }
		    m_tId = originalId;
		  }
		}

		m_bInMsLevel2 = false;
	}
}
예제 #7
0
int cDataMap::read_xml_file(string incdir)
{
	xmlTextReaderPtr reader;
    int ret;
	string genre = incdir + "genre.xml" ;
    string category = incdir + "category.xml" ;

	// read categories and genre into ONE map. They don't share id's (Logic genre div 100 = category, genre is never full 100)

	// categories
    reader = xmlReaderForFile(category.c_str(), "iso-8859-1" , XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
    if (reader != NULL) {
        ret = xmlTextReaderRead(reader);
        while (ret == 1) {
            processData(reader);
            ret = xmlTextReaderRead(reader);
        }
        xmlFreeTextReader(reader);

        if (ret != 0) {
			fprintf(stderr, "epgdata2vdr : failed to parse %s\n", category.c_str() );
			return ret;
		}
    }
	else {
		fprintf(stderr, "Unable to open %s\n", category.c_str());
		return -1;
	}

	// genres
	reader = xmlReaderForFile(genre.c_str(), "iso-8859-1" , XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
    if (reader != NULL) {
        ret = xmlTextReaderRead(reader);
        while (ret == 1) {
            processData(reader);
            ret = xmlTextReaderRead(reader);
        }
        xmlFreeTextReader(reader);
        if (ret != 0) {
			fprintf(stderr, "Failed to parse %s.\n", genre.c_str());
			return ret;
		}
    }
	else {
		fprintf(stderr, "Unable to open %s\n", genre.c_str());
		return -1;
	}
	return 0;
}
예제 #8
0
/*** FUNCTION CODE ***/
int main(int argc, char *argv[]) {
    //Setup Signal handler and atexit functions
	signal(SIGINT, INThandler);                     //Interrupts (calls INThandler) when Ctrl+c (?)
    COM1 = open_serialport("/dev/ttyUSB0",500000); //Open USB port
    Time_struct Curr_time;                          //Create time structure
    Curr_time = get_time();                         //Fill it with current time
    char fname[26];                                 //Create space for filename
    sprintf(fname, "%d-%d-%d-%d:%d:%d:%d.csv", Curr_time.year, Curr_time.month, Curr_time.day, Curr_time.hour, Curr_time.minute, Curr_time.second, Curr_time.msecond); //Create filename (date, time)
    fp = fopen(fname,"w");                          //Open file
    struct sockaddr_in outsock;
    int s_out_sensordata, slen = sizeof(struct sockaddr_in);
    initClientSocket(IMU_PORT, &s_out_sensordata, OPC_IP, &outsock);
    //initClientSocket(65100, &s_out_sensordata, "10.0.0.10", &outsock); //fakeclient
    sensor_data data;
    initBuffer();
    while(running) {
        data = receiveSensorData();
        writeToBuffer(&data);
        if (processData(&data))
            sendSensorData(&data, s_out_sensordata, outsock, slen);
    }
    //At end by Ctrl+c
    printf("Fin\n");
    fclose(fp);                                     //Close file
    return 0;
}
예제 #9
0
void GrooveRequest::post()
{
    QString cacheKey = generateCacheKey();

    if (cacheKey.length()) {
        qDebug() << Q_FUNC_INFO << "Possibly cached request";
        QString cachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation) + "/libgroove/cache/api/" + cacheKey;
        QFile cacheFile(cachePath);
        if (cacheFile.open(QIODevice::ReadOnly)) {
            qDebug() << Q_FUNC_INFO << "Definitely cached request";
            QByteArray response = cacheFile.readAll();
            processData(response);
            return;
        }
    }

    m_request.setHeader(m_request.ContentTypeHeader, "application/json");

    QJson::Serializer serializer;

    qDebug() << Q_FUNC_INFO << "Posting to: " << m_request.url();
    qDebug() << Q_FUNC_INFO << serializer.serialize(buildRequest());

    QNetworkReply *reply = m_client->networkManager()->post(m_request, serializer.serialize(buildRequest()));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SIGNAL(error(QNetworkReply::NetworkError)));
    connect(reply, SIGNAL(finished()), SLOT(onFinished()));
}
예제 #10
0
	void processResData_ByRotID( const std::string& resName, ContainerType& data, RotamerLibrary& _RotLib )
	{
		// Sort the data to increase efficiency below
		std::stable_sort( data.begin(), data.end(), sortPsi);
		std::stable_sort( data.begin(), data.end(), sortPhi);		
		std::stable_sort( data.begin(), data.end(), sortRotID);

		ContainerType subdata;
		
		while( true )
		{
			if( data.size() > 0 && (subdata.size() == 0 || subdata[0].rotID.compare( data.back().rotID,0,4,0 )) )
			{
				subdata.push_back( data.back() );
				data.erase(data.end()-1); // rob the end, not the start (ContainerType<> perfomance reasons!)
			}
			else
			{
				ASSERT( data.size() == (36*36), ParseException, "Assumption error!");
				ASSERT( data[0].phi == -180.0 && data[0].psi == -180.0, ParseException, "Wrong phi/psi");
				for( size_t j = 1; j < data.size(); j++ )
				{	
					ASSERT( data[j].phi == (-180.0+(j/36)*10) && data[j].psi == (-180.0+(j%36)*10), ParseException, "Wrong phi/psi");			
				}
				processData( resName, subdata, _RotLib, 40.0 ); // 40 degree tollerance delta from data[0]
				subdata.clear();
				if( data.size() == 0 )
				{
					return;
				}
			}
		}		
	}
예제 #11
0
    void NewSerialPort::read(std::vector<char>& aDataBuffer,
                             size_t aNumOfBytesToRead)
    {
#if _WIN32
        size_t numBytesRead = 0;

        aDataBuffer.clear();
        aDataBuffer.assign(aNumOfBytesToRead, '\0');

		BOOL result = ReadFile(
            m_serialPortHandle,
            aDataBuffer.data(),
            aNumOfBytesToRead,
            reinterpret_cast<LPDWORD>(&numBytesRead),
            NULL);

		DWORD error = GetLastError();

        if (!result && GetLastError() != ERROR_IO_PENDING)
        {
            throw unknown_error();
        }
        else if (numBytesRead > 0)
        {
            // For an accurate reading of how many bytes were actually read
            aDataBuffer.resize(numBytesRead);
            storeReadData(aDataBuffer);
			processData();
        }

#endif
    }
예제 #12
0
void
WorkerTask::handleMsg(Msg *msg)
{
	// flush any irrelevant messages
	if (msg->getActivityId() != activityId)
		return;

	switch (msg->getCode()) {
	case DfbProcess:
		// perform a DFB/channelization
		lock();
		processData(msg);
		unlock();
		break;
	case DATA_COLLECTION_COMPLETE:
		// all channels are done, time to go
		lock();
		spectrometer->stopSpectrometry(activity);
		activity = 0;
		activityId = -1;
		unlock();
		break;
	case STOP_DX_ACTIVITY:
	case SHUTDOWN_DX:
	case RESTART_DX:
		lock();
		stopActivity(msg);
		unlock();
		terminate();
		break;
	default:
		Fatal(ERR_IMT);
		break;
	}
}
int main(void){
	
	DDRC = 0x00;	
		
	uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
	sei();
	unsigned int c;
	while(1){
		c = uart_getc();
		if(c & UART_NO_DATA){
				/*
			 	* NO UART DATA available
			 	*/
		}
		else{
				/*
				 *  New Data is avialable at the port.
				 *  check the frame for overrun errro
				 */
				if ( c & UART_FRAME_ERROR ){

	   					/* Framing Error detected, i.e no stop bit detected */
						uart_puts_P("UART Frame Error: ");
				}	
				if ( c & UART_OVERRUN_ERROR ){			
	
						/* 
						 *
						 * Overrun, a character already present in the UART UDR register was 
				 		 *
						 * not read by the interrupt handler before the next character arrived,
						 * one or more received characters have been dropped
				  		 *	
				 		 *                                                                  
						 */

						uart_puts_P("UART Overrun Error: ");
		
				}

				if ( c & UART_BUFFER_OVERFLOW ){

						/* 
						 *
					 	 * We are not reading the receive buffer fast enough,
						 *
						 * one or more received character have been dropped 
					 	 *
					 	 */

						uart_puts_P("Buffer overflow error: ");

				}

				processData(c);
			//	PORTC = c;
		}
	}
	return 0;
}
예제 #14
0
void AudioCapture::run()
{
    m_userStop = false;

    while (!m_userStop)
    {
        m_mutex.lock();
        if (m_pause == false && m_captureSize != 0)
        {
            if (readAudio(m_captureSize) == true)
            {
                processData();
            }
            else
            {
                //qDebug() << "Error reading data from audio source";
                usleep(5000);
            }

        }
        else
            usleep(15000);
        m_mutex.unlock();
    }
}
예제 #15
0
파일: Menu.c 프로젝트: awmaker/awmaker
static WMPropList *processSubmenu(WEditMenu * menu)
{
	WEditMenuItem *item;
	WMPropList *pmenu;
	WMPropList *pl;
	char *s;
	int i;

	s = WGetEditMenuTitle(menu);
	pl = WMCreatePLString(s);

	pmenu = WMCreatePLArray(pl, NULL);

	i = 0;
	while ((item = WGetEditMenuItem(menu, i++))) {
		WEditMenu *submenu;

		s = WGetEditMenuItemTitle(item);

		submenu = WGetEditMenuSubmenu(item);
		if (submenu) {
			pl = processSubmenu(submenu);
		} else {
			pl = processData(s, WGetEditMenuItemData(item));
		}

		if (!pl)
			continue;

		WMAddToPLArray(pmenu, pl);
	}

	return pmenu;
}
예제 #16
0
bool ValveRuntimeBox::setValve(int)
{
    Q_ASSERT(m_valve.outputPort()->state().hasData());
    m_valveOpen = m_valve.data().data()[0] != 0;
    m_hasValve = true;
    return processData();
}
예제 #17
0
void shakeData::loadSMC(string filename)
{
	file=filename;
	ifstream input(ofToDataPath(file).c_str());
	string buffer;
	sampFreq=200.;
	bool tagOpen=false;
	int pipeCount=0;
	vector<double> val;
	getline(input, buffer);
	while(buffer.length()&&(buffer[0]=='|'||pipeCount<4)){
		if(buffer.length()&&buffer[0]=='|') pipeCount++;
		getline(input, buffer);
	}
	while (input.peek()!=EOF) {
		getline(input, buffer);
		if(buffer.length()%10==0){
			for(int i=0; i<buffer.length()/10; i++){
				string num(buffer.begin()+10*i,buffer.begin()+10*i+10);
				//uData.push_back(dataPoint(ofToFloat(num),1/sampFreq));
				val.push_back(ofToFloat(num));
			}
		}
	}
	input.close();
	for(unsigned int i=0; i<val.size(); i++){
		uData.push_back(dataPoint(val[i],1/sampFreq));
	}
	processData();
}
예제 #18
0
void shakeData::loadCOSMOS(string filename)
{
	file=filename;
	ifstream input(ofToDataPath(file).c_str());
	string buffer;
	vector<double> val;
	int burn=45;
	while(burn--){
		getline(input, buffer);
	}
	getline(input, buffer);
	int numPoints=ofToInt(buffer.substr(0,buffer.find_first_of(' ',4)));
	sampFreq=1/ofToFloat(buffer.substr(47,4));
	string format=buffer.substr(buffer.find_last_of("(")+1,buffer.find_last_of(")")-(buffer.find_last_of("(")+1));
	cout <<numPoints << " of data, at " << sampFreq << " intervals in " << format << endl;
	vector<string> spl=ofSplitString(format,"f.");
	int pointsPerLine=ofToInt(spl[0]);
	int space=ofToInt(spl[1]);
	while(val.size()<numPoints){
		getline(input, buffer);
		for(unsigned int i=0; i<pointsPerLine&&val.size()<numPoints; i++){
			val.push_back(ofToFloat(buffer.substr(i*space,space)));
		}
	}
	for(unsigned int i=0; i<val.size(); i++){
		uData.push_back(dataPoint(val[i],1/sampFreq));
	}
	input.close();
	processData();
	
}
void MJPEGImageGrabber::onReadyRead()
{
//    qDebug() << "got ready read";
    m_imageData.append(m_reply->readAll());
//    qDebug() << "number of bytes in imageData" << m_imageData.size();

    QByteArray marker(streamSperator, strlen(streamSperator));
//    qDebug() << "Marker " << marker;

    if (!m_imageStarted) {
        int index = m_imageData.indexOf(marker);
        if (index < 0) { // current data doesn't have a image start
//            qDebug() << "not started yet, leaving... looked for marker";
            m_imageData.clear();
            return;
        }
        m_imageStarted = true; //started
        m_imageData = m_imageData.mid(index+marker.length()); // discard data before the start
    }

    int index = m_imageData.indexOf(marker);

    if (index < 0) { // no end yet
//        qDebug() << "frame started but no end yet, leaving...";
        return;
    }

    // end reached, get the frame
//    qDebug() << "one frame complete, process it";
    QByteArray fullFrame = m_imageData.left(index);
    Q_EMIT processData(fullFrame);
    m_imageStarted = false;
    m_imageData = m_imageData.mid(index+marker.length()); // discard data upto the extracted frame
}
예제 #20
0
파일: decoder.cpp 프로젝트: jjardon/eos
void VideoDecoder::update() {
	if (getTimeToNextFrame() > 0)
		return;

	processData();
	copyData();
}
예제 #21
0
void KviHttpRequest::slotSocketReadDataReady()
{
	KVI_ASSERT(m_p->pSocket);

	int iBytes = m_p->pSocket->bytesAvailable();

	if(iBytes <= 0)
	{
		// assume connection closed ?
		slotSocketDisconnected();
		return;
	}

	// FIXME: Avoid double-buffering here!

	KviDataBuffer oBuffer(iBytes);

	int iRead = m_p->pSocket->read((char *)(oBuffer.data()),iBytes);
	if(iRead < iBytes)
	{
		// hum.... what here ?
		if(iRead < 1)
		{
			slotSocketDisconnected();
			return;
		}

		// FIXME
		// well... otherwise just wait.
		// FIXME ?
		oBuffer.resize(iRead);
	}

	processData(&oBuffer);
}
예제 #22
0
MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent), ui(new Ui::MainWindow)
{
	ui->setupUi(this);

	/*connect(&m_tm, SIGNAL(timeout()), this, SLOT(processData()));
	m_tm.setInterval(1);
	m_tm.start();*/

	QTimer *tm = new QTimer(this);
	connect(tm, SIGNAL(timeout()), this, SLOT(draw()));
	tm->setInterval(1000 / 60);
	tm->start();

	m_udp.bind(9999);

	connect(&m_udp, SIGNAL(readyRead()), this, SLOT(processData()));

	ui->visWorld->stat = 0;
	ui->visWorld->pdaData = &m_pdaData;

	ui->visWorld2->stat = 1;
	ui->visWorld2->pdaData = &m_pdaData;

	ui->visScreen->pdaData = &m_pdaData;

	m_pdaData.sphereEnabled = 0;
	ui->widgetSensors->setVisible(true);
	ui->widgetSpheres->setVisible(false);
}
void BodyStreamBuffer::didGetReadable()
{
    if (!m_reader)
        return;

    if (!m_streamNeedsMore) {
        // Perform zero-length read to call close()/error() early.
        size_t readSize;
        WebDataConsumerHandle::Result result = m_reader->read(nullptr, 0, WebDataConsumerHandle::FlagNone, &readSize);
        switch (result) {
        case WebDataConsumerHandle::Ok:
        case WebDataConsumerHandle::ShouldWait:
            return;
        case WebDataConsumerHandle::Done:
            close();
            return;
        case WebDataConsumerHandle::Busy:
        case WebDataConsumerHandle::ResourceExhausted:
        case WebDataConsumerHandle::UnexpectedError:
            error();
            return;
        }
        return;
    }
    processData();
}
예제 #24
0
파일: main.c 프로젝트: UKHASnet/LPC810
/**
 * It processing incoming data by the radio or serial connection. This function
 * has to be continously called to keep the node running. This function also
 * adds a delay which is specified as 100ms per unit. Therefore 1000 = 100 sec
 * @param countdown delay added to this function
 */
void awaitData(int countdown) {

    uint8_t rx_len;

    //Clear buffer
    data_temp[0] = '\0';

    RFM69_setMode(RFM69_MODE_RX);

    while(countdown > 0) {

        // Check rx buffer
        if(RFM69_checkRx() == 1) {
            RFM69_recv(data_temp,  &rx_len);
            data_temp[rx_len - 1] = '\0';
            #ifdef DEBUG
                //rssi = RFM69_lastRssi();
                printf("rx: %s\r\n",data_temp);
                //printf("RSSI: %d\r\n, rssi");
            #endif
            processData(rx_len);
        }

        #ifdef SERIAL_IN
                // Check tx buffer
                checkTxBuffer();
        #endif

        countdown--;
        mrtDelay(100);
    }
}
예제 #25
0
파일: server.cpp 프로젝트: puzzleSEQ/server
void Server::readyRead()
{
	QTcpSocket * socket = static_cast<QTcpSocket *>(sender());
	QByteArray * buffer = _buffers.value(socket);
	qint32 size = *_sizes.value(socket);
	while(socket->bytesAvailable() > 0)
	{
		buffer->append(socket->readAll());
		// While can process data, process it
		while ((buffer->count() >= 4 && size == 0) || (buffer->count() >= size && size > 0))
		{
			// If size of data has received completely, then store it on global variable
			if (buffer->count() >= 4 && size == 0)
			{
				size = arrayToInt(buffer->mid(0, 4));
				buffer->remove(0, 4);
			}
			// If data has received completely
			if (buffer->count() >= size && size > 0)
			{
				QByteArray data = buffer->mid(0, size);
				buffer->remove(0, size);
				size = 0;
				processData(data, socket);
			}
		}
	}
}
예제 #26
0
// renyang - 把接收到的資料放到streamBuffer中
void Receiver::putData(char *buffer, int len)
{
#ifdef REN_DEBUG
	qWarning(QString("Receiver::putData(char *buffer, int %1)").arg(len));
#endif
	// renyang - 應該是要把音訊檔存到檔案中吧
	if (outFile)
	{
		// renyang - 把接收到的資料放到outFile中
		fwrite(buffer, 1, len, outFile);
		fflush(outFile);
	}
	
	// renyang - 若剩下的buffer(MAXBUFSIZE - len)小於streamLen,則表示空間不夠, 出現錯誤啦當有資料送過來, 但是長度確沒有大於0,表示對方出現錯誤或是離開
	// renyang - 也可以說streamLen+len > MAXBUFSIZE則表示目前在記憶體中的資料加上新的資料比最大長度還大
	// renyang - streamLen可以看成MAXBUFSIZE目前使用到哪裡的index
	if (streamLen > (MAXBUFSIZE - len))
	{
		qWarning("Warning: receiver buffer overloaded.");
		// renyang - 把實際的資料刪成剛好可以放到buffer的大小
		len = MAXBUFSIZE - streamLen;
	}
	// renyang - 把收到的資料加到streamBuffer的後面, streamLen是表示目前的stream是用到哪裡
	memcpy(streamBuffer + streamLen, buffer, len);
	// renyang - 增加streamLen
	streamLen += len;
	
	// renyang - 資料完成放到streamBuffer中啦
	if (sync == STREAM_READ_DATA)
	{
		sync = STREAM_OK;
		processData();
	}
}
예제 #27
0
파일: fight.cpp 프로젝트: q4a/attal
void Fight::socketFightEnd()
{
	  
	attalFightData dataFight;

	uchar result = _socket->readChar();

	// process all pending fight data before end of fight
	while( !_attData->isEmpty() ) {
		dataFight = _attData->first();
		processData( dataFight );
		_attData->removeFirst();
	}
	
	fightEnd( result );

/*
	dataFight.result = _socket->readChar();
	dataFight.dataType = FIGHT_DATA_END;

	AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings();

	if( fsettings.isAnimationEnabled ) {
		_attData->append(dataFight);
		checkTimer();
	} else {
		fightEnd( dataFight.result );
	}
*/
}
예제 #28
0
파일: SerialServer.cpp 프로젝트: Craug/cbc
void SerialServer::processTransfer(QByteArray& header)
{
    QDataStream headerStream(&header, QIODevice::ReadOnly);
    
    quint16 startWord;
    quint16 packetCount;
    
    headerStream >> startWord;
    headerStream >> packetCount;
    
    if(startWord != SERIAL_START)
        return;
    qWarning("Got start...");
    qWarning("packetcount=%d", packetCount);
    
    QByteArray compressedData;
    
    for(quint16 i = 0;i < packetCount;i++) {
        QByteArray data;
        if(!readPacket(&data))
            return;
        compressedData += data;
    }
    
    
    QByteArray data = qUncompress(compressedData);
    compressedData.clear();
    compressedData.squeeze();
    
    processData(data);
}
예제 #29
0
파일: YSFRX.cpp 프로젝트: kc2vrj/MMDVM
void CYSFRX::samples(const q15_t* samples, uint8_t length)
{
  for (uint16_t i = 0U; i < length; i++) {
    bool bit = samples[i] < 0;

    if (bit != m_prev) {
      if (m_pll < (PLLMAX / 2U))
        m_pll += INC;
      else
        m_pll -= INC;
    }

    m_prev = bit;

    m_pll += PLLINC;

    if (m_pll >= PLLMAX) {
      m_pll -= PLLMAX;

      if (m_state == YSFRXS_NONE)
        processNone(samples[i]);
      else
        processData(samples[i]);
    }
  }
}
예제 #30
0
ReportManager::ReportManager(_structs * data, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ReportManager)
{
    processSwitch = 0;
    connect(&socketConn, SIGNAL(dataReady(QString)), this, SLOT(processData(QString)));

    ui->setupUi(this);

    for(int i = 1; i <= 12; i++ )
    {
        ui->monthSelector->addItem(QString::number(i));
    }
    // Build list of years
    QDate now = QDate::currentDate();
    int year = now.year();
    QStringList years;
    for(int i =0; i < 5; i++)
    {
        years.append(QString::number(year-i));
    }

    // Add to combo
    ui->yearSelector->addItems(years);

    dataStructs = data;
    ui->startDate->setDate(QDate::currentDate().addDays(-7));
    ui->endDate->setDate(QDate::currentDate());

}