Пример #1
0
int main()
{
	inventory invList[MAX_ARR_SIZE];

	int count = 0; // holds the number of cells found in original file
	int newcount = 0; // hold the number of extracted records written to new file
	int requestId;

	char fileName[MAX_FILENAME_LEN];
	char newFile[MAX_FILENAME_LEN];

	cout << "Enter the name of the file to be read: ";
	cin >> fileName; // inventory.txt

	// change last parameter to 10 to test when no room for all data
	if (loadArray(fileName, invList, count, MAX_ARR_SIZE))
	{
		cout << "All data loaded." << endl;
	}
	else
	{
		cout << "Insufficent storage. Unable to load all data." << endl;
	}

	cout << count << " record(s) found" << endl << endl;
	printArray(cout, invList, count);

	cout << endl;
	cout << "Enter new file name: ";
	cin >> newFile;
	cout << "Enter product ID to search for: ";
	cin >> requestId; // product id number

	extractData(newFile, requestId, ORDER_VALUE, invList, count, newcount);
	cout << newcount << " record(s) written to file." << endl << endl;

	return 0;
}
Пример #2
0
SP_CONFIG_MSG getFieldValue(char* line, unsigned int* currentPosition, char* fieldValue)
{
	/* looking for KEY_VAL_DELIMETER */
	SP_SPEICAL_CHAR sc = increasePositionTillReachingValidCharacterOrEOL(line, currentPosition);
	if (KEY_VAL_DELIMETER != sc)
	{
		return SP_CONFIG_INVALID_LINE;
	}

	/* increase the position to follow KEY_VAL_DELIMETER */
	(*currentPosition)++;

	/* looking for the first field value character */
	sc = increasePositionTillReachingValidCharacterOrEOL(line, currentPosition);
	if (REGUALR_CHAR != sc)
	{
		return SP_CONFIG_INVALID_LINE;
	}

	/* extract value */
	sc = extractData(line, currentPosition, fieldValue);

	return SP_CONFIG_SUCCESS;
}
Пример #3
0
int GM862::parseMessage(char *buf){
    char buf2[BUF_LENGTH];
    int state;
    String loc;
//    Serial.print("pm -->");
//    Serial.println(buf);
    if(strstr(buf,"CMTI")){ // incoming txt message
        Serial.println("getting message ... ");
        loc = strstr(buf,",")+1;
        loc = loc.trim();
//        Serial.println("mem loc: " + loc);
        requestModem("AT+CMGL=\"REC UNREAD\"",1000,false,buf2); // list message
	   while(!strstr(buf2,"+CMGL:")){	// wait until the txt message response is sent.
	       getsTimeout(buf2,100);
	   }
//      Serial.print(buf2);
    state = extractData(buf2);
    Serial.print("State Parse: ");
    Serial.println(state);
//    delay(4500);
    deleteMessage(loc);
    }
  return state;
}
Пример #4
0
void handleInCoded(decoderstate* state, uint8_t* buffer, int size) {
    do_debug("in handleInCoded\n");
    datapacket* packet = bufferToData(buffer, size);
    matrix *coeffs, *tmp;
    int bufLen, i, delta;
    uint8_t* dataVector;
    uint8_t* coeffVector;
    uint8_t ackBuffer[100];
    uint16_t loss, total;

    //printf("Data received :\n");
    //dataPacketPrint(*packet);

    do_debug("p->packetNumber = %2x\n", packet->packetNumber);

    // ~~ Allocate blocks & coefficient matrix if necessary ~~
    while(state->currBlock + state->numBlock - 1 < packet->blockNo) {
        do_debug("CurrBlock = %d, numBlock = %d, blockNo of received Data = %d\n", state->currBlock, state->numBlock, packet->blockNo);
        state->blocks = realloc(state->blocks, (state->numBlock + 1) * sizeof(matrix*));
        state->blocks[state->numBlock] = mCreate(BLKSIZE, PACKETSIZE);
        state->coefficients = realloc(state->coefficients, (state->numBlock + 1) * sizeof(matrix*));
        state->coefficients[state->numBlock] = mCreate(BLKSIZE, BLKSIZE);

        state->nPacketsInBlock = realloc(state->nPacketsInBlock, (state->numBlock + 1) * sizeof(int));
        state->nPacketsInBlock[state->numBlock] = 0;

        state->isSentPacketInBlock = realloc(state->isSentPacketInBlock, (state->numBlock + 1) * sizeof(int*));
        state->isSentPacketInBlock[state->numBlock] = malloc(BLKSIZE * sizeof(int));
        for(i = 0; i<BLKSIZE; i++) {
            state->isSentPacketInBlock[state->numBlock][i] = false;
        }

        state->numBlock ++;
    }

    if(packet->blockNo >= state->currBlock) {
        if((packet->packetNumber & BITMASK_NO) >= state->nPacketsInBlock[packet->blockNo - state->currBlock]) { // Try to append
            // Compute coefficients
            coeffs = mCreate(1, BLKSIZE);
            dataVector = calloc(PACKETSIZE, sizeof(uint8_t));
            coeffVector = calloc(BLKSIZE, sizeof(uint8_t));
            if(((packet->packetNumber) & BITMASK_FLAG) ==  FLAG_CLEAR) {
                coeffs->data[0][((packet->packetNumber) & BITMASK_NO)] = 1;
            } else if(((packet->packetNumber) & BITMASK_FLAG) ==  FLAG_CODED) {
                srandom(packet->seqNo);
                tmp = getRandomMatrix(1, BLKSIZE);
                memcpy(coeffs->data[0], tmp->data[0], packet->packetNumber & BITMASK_NO);
                mFree(tmp);
            } else {
                printf("handleInCoded : received a bogus data packet. DIE.");
                exit(1);
            }

            // ~~ Append to the matrix and eventually decode ~~
            memcpy(dataVector, packet->payloadAndSize, packet->size);
            memcpy(coeffVector, coeffs->data[0], BLKSIZE);

            mFree(coeffs);

            if(appendCodedPayload(state, coeffVector, dataVector, packet->blockNo - state->currBlock)) {
                do_debug("Received an innovative packet\n");
                state->stats_nInnovative++;
            } else {
                do_debug("Received packet was not innovative. Drop.\n");
                if(packet->blockNo - state->currBlock == 0) {
                    state->stats_nAppendedNotInnovativeGaloisFirstBlock++;
                } else {
                    state->stats_nAppendedNotInnovativeGaloisOtherBlock++;
                }
            }

            free(dataVector);
            free(coeffVector);
        } else {
            do_debug("Received packet has NO chance to be innovative. Drop.\n");
            state->stats_nAppendedNotInnovativeCounter++;
        }
    } else {
        do_debug("Packet received for an outdated block. Drop.\n");
        state->stats_nOutdated++;
    }

    // ~~ Try to decode ~~
    if((state->numBlock > 0) && (state->nPacketsInBlock[0] > 0)) {
        do_debug("Calling extractData() while numBlock = %d, currBlock = %d, nPacketInBlock[0] = %d\n", state->numBlock, state->currBlock, state->nPacketsInBlock[0]);
        extractData(state);
    }


    // ~~ Update the loss information buffer ~~
    delta = packet->seqNo - state->lastSeqReceived;
    if(delta > 0) {
        for(i = state->lossBuffer->currentIndex + 1; i < (state->lossBuffer->currentIndex + delta); i++) {
            state->lossBuffer->isReceived[i % LOSS_BUFFER_SIZE] = false;
        }
        state->lossBuffer->isReceived[(state->lossBuffer->currentIndex + delta) % LOSS_BUFFER_SIZE] = true;
        state->lossBuffer->currentIndex = (state->lossBuffer->currentIndex + delta) % LOSS_BUFFER_SIZE;
    } else {
        state->lossBuffer->isReceived[(state->lossBuffer->currentIndex + delta + LOSS_BUFFER_SIZE) % LOSS_BUFFER_SIZE] = true;
    }
    state->lastSeqReceived = max(state->lastSeqReceived, packet->seqNo);

    // ~~ Send an ACK back ~~
    ackpacket ack;
    ack.ack_dofs = malloc(DOFS_LENGTH * sizeof(uint8_t));
    for(i = 0; i < DOFS_LENGTH; i++) {
        if(state->numBlock > i) { // If the i-th block is allocated
            // Include the number of packets received
            ack.ack_dofs[i] = state->nPacketsInBlock[i];
        } else {
            // Otherwise, let it just be zero
            ack.ack_dofs[i] = 0;
        }
    }

    ack.ack_seqNo = packet->seqNo;
    ack.ack_currBlock = state->currBlock;

    countLoss(*state, &loss, &total);
    ack.ack_loss = loss;
    ack.ack_total = total;

    //printf("ACK to send :\n");
    //ackPacketPrint(ack);

    ackPacketToBuffer(ack, ackBuffer, &bufLen);
    free(ack.ack_dofs);

    state->ackToSend = realloc(state->ackToSend, (state->nAckToSend + 1) * sizeof(uint8_t*));
    state->ackToSendSize = realloc(state->ackToSendSize, (state->nAckToSend + 1) * sizeof(int));

    state->ackToSend[state->nAckToSend] = malloc(bufLen * sizeof(uint8_t));
    memcpy(state->ackToSend[state->nAckToSend], ackBuffer, bufLen);
    state->ackToSendSize[state->nAckToSend] = bufLen;
    state->nAckToSend ++;

    free(packet->payloadAndSize);
    free(packet);
}
Пример #5
0
int main(int argc, char *argv[]) {

    QApplication a(argc, argv);
    QTextCodec *codec;
#ifdef WIN32
    codec = QTextCodec::codecForName("Windows-1250");
#else
    codec = QTextCodec::codecForName("UTF-8");
#endif
    QTextCodec::setCodecForCStrings(codec);
    QTextCodec::setCodecForLocale(codec);
    QIcon icon(":images/icon.ico");
    a.setWindowIcon(icon);
    setDarkTheme(a);
    QWidget *window = new QWidget();
    QGridLayout *layout = new QGridLayout(window);

    QCheckBox *pictureCheck = new QCheckBox("Picture file:", window);
    pictureCheck->setChecked(true);
    InputLine *picture = new InputLine(window, pictureCheck);
    QLabel *pictureLabel = new QLabel();
    PictureSelection* pictureSelection = new PictureSelection(window, picture, pictureLabel, layout, pictureCheck);
    QPushButton *selectFile = new QPushButton("Browse...", window);
    QLineEdit *path = new QLineEdit(window);
    QLabel *pathLabel = new QLabel("File(s):", window);
    FileSelection selection(window, selectFile, path);
    QPushButton *showData = new QPushButton("Extract data", window);
    QCheckBox *authorCheck = new QCheckBox("Artist:", window);
    authorCheck->setChecked(true);
    InputLine *author = new InputLine(window, authorCheck);
    QCheckBox *albumCheck = new QCheckBox("Album:", window);
    albumCheck->setChecked(true);
    InputLine *album = new InputLine(window, albumCheck);
    QCheckBox *trackCheck = new QCheckBox("Track (number):", window);
    trackCheck->setChecked(true);
    InputLine *track = new InputLine(window, trackCheck);
    QCheckBox *titleCheck = new QCheckBox("Title:", window);
    titleCheck->setChecked(true);
    InputLine *title = new InputLine(window, titleCheck);
    QCheckBox *yearCheck = new QCheckBox("Year:", window);
    yearCheck->setChecked(true);
    InputLine *year = new InputLine(window, yearCheck);
    QCheckBox *genreCheck = new QCheckBox("Genre:", window);
    genreCheck->setChecked(true);
    GenreSelection *genre = new GenreSelection(window, genreCheck);
    QCheckBox* commentCheck = new QCheckBox("Comment:", window);
    commentCheck->setChecked(true);
    CommentEditor *comment = new CommentEditor(window, commentCheck);
    comment->setFixedHeight(50);
    QPushButton *save = new QPushButton("Save data", window);

    QImage *image = new QImage();
    track->setValidator(new QIntValidator(1, 100000000, window));
    year->setValidator(new QIntValidator(0, 2060, window));
    DataEditors *editors = new DataEditors(window, title, track, album, author, year, genre, picture, pictureLabel, image, comment);
    DataExtractor *extractor = new DataExtractor(window, editors, path);
    DataSaver *saver = new DataSaver(window, editors, path);
    QObject::connect(showData, SIGNAL(clicked()), extractor, SLOT(extractData()));
    QObject::connect(save, SIGNAL(clicked()), saver, SLOT(saveData()));
    pictureLabel->setPixmap(QPixmap::fromImage(QImage(":images/nofile.png")));

    int i = 0;
    layout->addWidget(pathLabel, i, 0, 1, 1, 0);
    layout->addWidget(path, i, 1, 1, 1, 0);
    layout->addWidget(selectFile, i, 2, 1, 1, 0);
    i++;
    layout->addWidget(showData, i, 0, 1, 1, 0);
    i++;
    layout->addWidget(pictureCheck, i, 0, 1, 1, 0);
    layout->addWidget(picture, i, 1, 1, 1, 0);
    layout->addWidget(pictureSelection, i, 2, 1, 1, 0);
    i++;
    layout->addWidget(pictureLabel, i, 1, 1, 1, 0);
    i++;
    layout->addWidget(authorCheck, i, 0, 1, 1, 0);
    layout->addWidget(author, i, 1, 1, 1, 0);
    i++;
    layout->addWidget(genreCheck, i, 0, 1, 1, 0);
    layout->addWidget(genre, i, 1, 1, 1, 0);
    i++;
    layout->addWidget(albumCheck, i, 0, 1, 1, 0);
    layout->addWidget(album, i, 1, 1, 1, 0);
    i++;
    layout->addWidget(yearCheck, i, 0, 1, 1, 0);
    layout->addWidget(year, i, 1, 1, 1, 0);
    i++;
    layout->addWidget(trackCheck, i, 0, 1, 1, 0);
    layout->addWidget(track, i, 1, 1, 1, 0);
    i++;
    layout->addWidget(titleCheck, i, 0, 1, 1, 0);
    layout->addWidget(title, i, 1, 1, 1, 0);
    i++;
    layout->addWidget(commentCheck, i, 0, 1, 1, 0);
    layout->addWidget(comment, i, 1, 1, 1, 0);
    i++;
    layout->addWidget(save, i, 2, 1, 1, 0);


    window->setFixedHeight(450);
    window->setFixedWidth(400);
    window->setLayout(layout);
    window->show();

    return a.exec();

}
Пример #6
0
/**
 * Attempts to read the entire WAV header from the data provided
 * 
 * @param sourcePtr A pointer to the byte array to read from
 */
void readWavHeader (uint8_t * sourcePtr){
    extractData(sourcePtr, wavHeader.riffChunk,0,4);
    extractData(sourcePtr, wavHeader.fileSize,4,4);
    extractData(sourcePtr, wavHeader.format,8,4);
    extractData(sourcePtr, wavHeader.formatChunk,12,4);
    extractData(sourcePtr, wavHeader.formatChunkSize,16,4);
    extractData(sourcePtr, wavHeader.audioFormat,20,2);
    extractData(sourcePtr, wavHeader.channelCount,22,2);
    extractData(sourcePtr, wavHeader.sampleRate,24,4);
    extractData(sourcePtr, wavHeader.bytesPerSecond,28,4);
    extractData(sourcePtr, wavHeader.blockAlign,32,2);
    extractData(sourcePtr, wavHeader.bitsPerSample,34,2);
    extractData(sourcePtr, wavHeader.dataChunk,36,4);
    extractData(sourcePtr, wavHeader.dataChunkSize,40,4);
}
Пример #7
0
Schema *decryptSchema(char *schema, char temp, int count, int index) {
	index = 0;
	int i = 0, size = 0, j, numOfAttr;
	bool isSchema;
	char *string1;
	char *string2;
	char *string3;
	int len = strlen(schema);
	char dataSchema[len];
	Schema *s = NULL;
	s = getSchema();
	memcpy(dataSchema, schema, len);
	modifySchema(&string1, dataSchema);

	numOfAttr = getNumbOfAttributes(&string1, &string2);
	char* attr[numOfAttr];
	char* str[numOfAttr];
	populSchema(s, numOfAttr);
	string1 = strtok(NULL, "(");
	for (; i < s->numAttr; i++) {
		string1 = strtok(NULL, ": ");
		schemaAttrName(s, &string1, i);
		str[i] = initStringRef(string1,0);
		populateTableWithDataTypes(s, &string1, i);
			memcpy(str[i], string1, strlen(string1));
	}
	isSchema = false;

	if ((string1 = strtok(NULL, "("))) {
		isSchema = true;
		char *tempExtractedData=NULL;
		tempExtractedData = extractData(&string1);
		i = 0;
		while (tempExtractedData) {
			attr[size] = initStringRef(tempExtractedData,0);
			strcpy(attr[size], tempExtractedData);
			tempExtractedData = strtok(NULL, ", ");
			size =size+ 1;
			i++;
		}
	}

	for (i = 0; i < numOfAttr; i++) {
		len = strlen(str[i]);
		if (len > 0) {
			s->dataTypes[i] = DT_STRING;
			string3 = initStringRef((str[i]),0);
			strncpy(string3, str[i], len);
			extractDataString(&string1, &string3);
			s->typeLength[i] = getNumbOfAttributes(&string1, &string2);
		}
	}

	if (isSchema) {
		s->keyAttrs = (int *) calloc(size, sizeof(int));;   s->keySize = size;


		for (i = 0; i < size; i++) {
			for (j = 0; j < s->numAttr; j++) {
				if (strcmp(attr[i], s->attrNames[j]) == 0)
					s->keyAttrs[i] = j;
			}
		}
	}
	return s;
}
Пример #8
0
__declspec(dllexport) LPXLOPER12 WINAPI CUDAPriceAsian(LPXLOPER12 pxSpot,
        LPXLOPER12 pxStrike,
        LPXLOPER12 pxRiskFreeRate,
        LPXLOPER12 pxVolatility,
        LPXLOPER12 pxExpiry,
        LPXLOPER12 pxCallput,
        int        nTimesteps,
        int        nScenarios)
{
    int ok = 1;
    int n = -1;
    unsigned int i;
    LPXLOPER12 pxRes = (LPXLOPER12)malloc(sizeof(XLOPER12));
    int error = -1;

    unsigned int nOptions = 0;
    float *spot         = 0;
    float *strike       = 0;
    float *riskFreeRate = 0;
    float *volatility   = 0;
    float *expiry       = 0;
    int   *callNotPut   = 0;
    float *value        = 0;

    // First we need to determine how many options we will process
    if (ok)
    {
        n = max(n, getNumberOfRows(pxSpot));
        n = max(n, getNumberOfRows(pxStrike));
        n = max(n, getNumberOfRows(pxRiskFreeRate));
        n = max(n, getNumberOfRows(pxVolatility));
        n = max(n, getNumberOfRows(pxExpiry));
    }

    if (n <= 0)
        ok = 0;
    else
        nOptions = n;

    // Allocate memory to collect the data from Excel
    if (ok && (spot = (float *)malloc(nOptions * sizeof(float))) == NULL)
        ok = 0;

    if (ok && (strike = (float *)malloc(nOptions * sizeof(float))) == NULL)
        ok = 0;

    if (ok && (riskFreeRate = (float *)malloc(nOptions * sizeof(float))) == NULL)
        ok = 0;

    if (ok && (volatility = (float *)malloc(nOptions * sizeof(float))) == NULL)
        ok = 0;

    if (ok && (expiry = (float *)malloc(nOptions * sizeof(float))) == NULL)
        ok = 0;

    if (ok && (callNotPut = (int *)malloc(nOptions * sizeof(int))) == NULL)
        ok = 0;

    if (ok && (value = (float *)malloc(nOptions * sizeof(float))) == NULL)
        ok = 0;

    // Collect data from Excel
    if (ok)
        ok = extractData(pxSpot, nOptions, spot, &error);

    if (ok)
        ok = extractData(pxStrike, nOptions, strike, &error);

    if (ok)
        ok = extractData(pxRiskFreeRate, nOptions, riskFreeRate, &error);

    if (ok)
        ok = extractData(pxVolatility, nOptions, volatility, &error);

    if (ok)
        ok = extractData(pxExpiry, nOptions, expiry, &error);

    if (ok)
        ok = extractData(pxCallput, nOptions, value, &error);

    // Interpret call/put flags, 1 and 2 are exactly representable in fp types
    for (i = 0 ; ok && i < nOptions ; i++)
    {
        if (value[i] == 1.0)
            callNotPut[i] = 1;
        else if (value[i] == 2.0)
            callNotPut[i] = 0;
        else
            ok = 0;

        value[i] = -1;
    }

    // Run the pricing function
    if (ok)
        priceAsianOptions(spot, strike, riskFreeRate, volatility, expiry, callNotPut, value, nOptions, (unsigned int)nTimesteps, (unsigned int)nScenarios);

    // If pricing more than one option then allocate memory for result XLOPER12
    if (ok && nOptions > 1)
    {
        if ((pxRes->val.array.lparray = (LPXLOPER12)malloc(nOptions * sizeof(XLOPER12))) == NULL)
            ok = 0;
    }

    // Copy the result into the XLOPER12
    if (ok)
    {
        if (nOptions > 1)
        {
            for (i = 0 ; i < nOptions ; i++)
            {
                pxRes->val.array.lparray[i].val.num = (double)value[i];
                pxRes->val.array.lparray[i].xltype = xltypeNum;
                pxRes->val.array.rows    = nOptions;
                pxRes->val.array.columns = 1;
            }

            pxRes->xltype = xltypeMulti;
            pxRes->xltype |= xlbitDLLFree;
        }
        else
        {
            pxRes->val.num = value[0];
            pxRes->xltype = xltypeNum;
            pxRes->xltype |= xlbitDLLFree;
        }
    }
    else
    {
        pxRes->val.err = (error < 0) ? xlerrValue : error;
        pxRes->xltype = xltypeErr;
        pxRes->xltype |= xlbitDLLFree;
    }

    // Cleanup
    if (spot)
        free(spot);

    if (strike)
        free(strike);

    if (riskFreeRate)
        free(riskFreeRate);

    if (volatility)
        free(volatility);

    if (expiry)
        free(expiry);

    if (callNotPut)
        free(callNotPut);

    if (value)
        free(value);

    // Note that the pxRes will be freed when Excel calls xlAutoFree12
    return pxRes;
}
Пример #9
0
//==============================================================================
void LineSegmentShapeGeode::refresh()
{
  mUtilized = true;

  extractData(false);
}
Пример #10
0
// fills in fields of the provided message from the buffer, starting at the offset
void readMessage(uint8_t* buff, uint32_t current_offset, cgroups_message_t* message, uint8_t length)
{
	message->length = length;
	extractData(message->payload, current_offset, buff, length);
}
Пример #11
0
// fills in fields of the provided ethernet_header_t from the buffer, starting at the offset
void readEthernetHeader(uint8_t* buff, ethernet_header_t* eth_header, uint32_t current_offset)
{
	extractData((uint8_t*)&eth_header->dest, current_offset + frame_dest_offset, buff, macLength);
	extractData((uint8_t*)&eth_header->source, current_offset + frame_source_offset, buff, macLength);
	extractData((uint8_t*)&eth_header->data_len, current_offset + frame_data_len_offset, buff, int8_len);
}
Пример #12
0
//==============================================================================
void CylinderShapeGeode::refresh()
{
  mUtilized = true;

  extractData();
}
Пример #13
0
//==============================================================================
void EllipsoidShapeGeode::refresh()
{
  mUtilized = true;

  extractData();
}
Пример #14
0
void extractData(decoderstate* state) {
    do_debug("in extractData\n");
    // We only try to extract data on current block.

    int nPackets = state->nPacketsInBlock[0], i, firstNonDecoded = -1;
    uint8_t factor;
    uint16_t size;

    // Find the first non-decoded line :
    for(i = 0; i<nPackets; i++) {
        // Look for decoded packets to send
        if((isZeroAndOneAt(state->coefficients[0]->data[i], i, BLKSIZE)) && !(state->isSentPacketInBlock[0][i])) {
            memcpy(&size, state->blocks[0]->data[i], 2);
            size = ntohs(size);
            do_debug("Got a new decoded packet of size %u to send to the application ! o/\n", size);

            // Append to the sending buffer
            state->dataToSend = realloc(state->dataToSend, (state->nDataToSend + size) * sizeof(uint8_t));
            memcpy(state->dataToSend + state->nDataToSend, state->blocks[0]->data[i] + 2, size);
            state->nDataToSend += size;

            state->isSentPacketInBlock[0][i] = true;
        }
        if( ! isZeroAndOneAt(state->coefficients[0]->data[i], i, BLKSIZE)) {
            firstNonDecoded = i;
            break;
        }
    }

    do_debug("FirstNonDecoded = %d\n", firstNonDecoded);

    if(firstNonDecoded == -1) {
        if((nPackets == BLKSIZE) && (state->isSentPacketInBlock[0][BLKSIZE - 1])) {
            // The entire block has been decoded AND sent
            do_debug("An entire block has been decoded and sent, switch to next block.\n");

            mFree(state->blocks[0]);
            mFree(state->coefficients[0]);
            free(state->isSentPacketInBlock[0]);

            for(i = 0; i < state->numBlock - 1; i++) {
                state->blocks[i] = state->blocks[i+1];
                state->coefficients[i] = state->coefficients[i+1];
                state->nPacketsInBlock[i] = state->nPacketsInBlock[i+1];
                state->isSentPacketInBlock[i] = state->isSentPacketInBlock[i+1];
            }

            state->numBlock--;
            state->currBlock++;

            state->blocks = realloc(state->blocks, state->numBlock * sizeof(matrix*));
            state->coefficients = realloc(state->coefficients, state->numBlock * sizeof(matrix*));
            state->isSentPacketInBlock = realloc(state->isSentPacketInBlock, state->numBlock * sizeof(int*));
            state->nPacketsInBlock = realloc(state->nPacketsInBlock, state->numBlock * sizeof(int));
        }

        return;
    }

    // Try to decode it
    for(i = 0; i<nPackets; i++) {
        if(i!=firstNonDecoded) {
            factor = state->coefficients[0]->data[firstNonDecoded][i];
            rowMulSub(state->coefficients[0]->data[firstNonDecoded], state->coefficients[0]->data[i], factor, BLKSIZE);
            rowMulSub(state->blocks[0]->data[firstNonDecoded], state->blocks[0]->data[i], factor, PACKETSIZE);
        }
    }

    if(isZeroAndOneAt(state->coefficients[0]->data[firstNonDecoded], firstNonDecoded, BLKSIZE)) {
        // We decoded something => call recursively, in case there's something else waiting, or we finished the block
        do_debug("Something got decoded\n");
        extractData(state);
    }
}
Пример #15
0
static bool extractEntry(uint32 off, int level, bool named)
{
    IMAGE_RESOURCE_DIRECTORY_ENTRY  rde;

    if ( off + sizeof(rde) >= ResTop )
        return false;
    if ( !get_many_bytes(ResBase + off, &rde, sizeof(rde)) )
        return false;

    if ( (bool)rde.NameIsString != named )
        return false;

    if ( (bool)rde.DataIsDirectory != (level != 2) )
        return false;

    off += sizeof(rde);

    if ( !named )
    {
        Names[level].Id = rde.Id;
    }
    else
    {
        ea_t npos = rde.NameOffset;
        if( npos < off || npos + 2 >= ResTop )
            return false;
        uint32 nlen = get_word(npos + ResBase)*sizeof(wchar_t);
        if ( !nlen || npos + nlen > ResTop )
            return false;
        wchar_t *p = (wchar_t *)qalloc(nlen + sizeof(wchar_t));
        if ( p == NULL )
        {
            msg("Not enough memory for resource names\n");
            return false;
        }
        if ( !get_many_bytes(npos + sizeof(uint16) + ResBase, p, nlen) )
        {
bad_name:
            qfree(p);
            return false;
        }
        p[nlen/sizeof(wchar_t)] = 0;
        size_t wlen = wcslen(p);
        if ( !wlen || wlen < nlen/2-1 ) goto bad_name;
        Names[level].name = p;
        Names[level].len = uint32((wlen+1)*sizeof(wchar_t));
    }

    if ( level != 2 )
    {
        bool res = false;
        if ( rde.OffsetToDirectory >= off )
            res = extractDirectory(rde.OffsetToDirectory, level+1);

        if ( Names[level].len ) qfree(Names[level].name);
        Names[level].name = NULL;
        Names[level].len  = 0;
        return res;
    }

    if ( rde.OffsetToData < off )
        return false;

    return extractData(rde.OffsetToData);
}
Пример #16
0
//==============================================================================
void BoxShapeGeode::refresh()
{
  mUtilized = true;

  extractData();
}
Пример #17
0
void Rcon::chatMessage(std::size_t &bytes_received)
{
	// Received Chat Messages
	std::string result;
	extractData(bytes_received, 9, result);
	logger->info("CHAT: {0}", result);

	// Respond to Server Msgs i.e chat messages, to prevent timeout
	RconPacket rcon_packet;
	rcon_packet.packetCode = 0x02;
	rcon_packet.cmd_char_workaround = rcon_socket.recv_buffer[8];
	sendPacket(rcon_packet);

	//boost::algorithm::trim(result);
	if (bad_playername_settings.enable || whitelist_settings.enable || rcon_settings.generate_unique_id)
	{
		if (boost::algorithm::starts_with(result, "Player #"))
		{
			if (boost::algorithm::ends_with(result, " connected")) //Whitespace so doesn't pickup on disconnect
			{
				if (bad_playername_settings.enable)
				{
					result = result.substr(8);
					const std::string::size_type found = result.find(" ");
					std::string player_number = result.substr(0, found);
					const std::string::size_type found2 = result.find_last_of("(");
					std::string player_name = result.substr(found+1, found2-(found+1));

					logger->info("DEBUG Connected Player Number: {0}.", player_number);
					logger->info("DEBUG Connected Player Name: {0}.", player_name);

					bool kicked = false;
					checkBadPlayerString(player_number, player_name, kicked);
				}
			}
			else if (boost::algorithm::ends_with(result, "disconnected"))
			{
				auto pos = result.find(" ", result.find("#"));
				std::string player_name = result.substr(pos + 1, result.size() - (pos + 14));

				logger->info("DEBUG Disconnected Player Name: {0}.", player_name);
				if (whitelist_settings.enable || rcon_settings.generate_unique_id)
				{
					if (whitelist_settings.enable)
					{
						whitelist_settings.players_whitelisted.erase(players_name_beguid[player_name]);
						whitelist_settings.players_non_whitelisted.erase(players_name_beguid[player_name]);
					}
					#ifndef RCON_APP
						if (rcon_settings.generate_unique_id)
						{
							// We only bother to generate a key if player has not been kicked
							extension_ptr->delPlayerKey_delayed(players_name_beguid[player_name]); // TODO Change Timer
						}
					#endif
				}
				players_name_beguid.erase(player_name);
			}
		}
		else if (boost::algorithm::starts_with(result, "Verified GUID"))
		{
			auto pos_1 = result.find("(");
			auto pos_2 = result.find(")", pos_1);

			std::string player_guid = result.substr((pos_1 + 1), (pos_2 - (pos_1 + 1)));

			pos_1 = result.find("#");
			pos_2 = result.find(" ", pos_1);
			std::string player_number = result.substr((pos_1 + 1), (pos_2 - (pos_1 + 1)));
			std::string player_name = result.substr(pos_2);

			#if defined(RCON_APP) || (DEBUG_TESTING)
				logger->info("DEBUG Verified Player Number: {0}.", player_number);
				logger->info("DEBUG Verified Player Name: {0}.", player_name);
				logger->info("DEBUG Verified Player GUID: {0}.", player_guid);
			#endif

			players_name_beguid[player_name] = player_guid;

			bool kicked = false;
			if (whitelist_settings.enable)
			{
				checkWhitelistedPlayer(player_number, player_name, player_guid, kicked);
			}

			#ifndef RCON_APP
				if ((!kicked) && rcon_settings.generate_unique_id)
				{
					// We only bother to generate a key if player has not been kicked
					extension_ptr->createPlayerKey_mutexlock(player_guid, 10); // TODO Make this configureable
				}
			#endif
		}
	}
	startReceive();
}
Пример #18
0
void load_file(GtkFileSelection *selector, gpointer file_selector) {
	FILE *stream;
	gchar *pfad;
	gchar *filename;
	gchar txtBuffer[200];
	gchar bouquetName[MAX_TXT_LEN+1];
	bouquetEntry *bouquet;
	channelEntry *channel;
	GNode *node_root;
	GNode *node_bouquet;
	GNode *node_channel;
	gint sumBouquets = 0;
	gint diseqc, transportID, frequenz, symbolRate, fec, polarity, onid, serviceID, serviceType;
	gchar name[MAX_TXT_LEN+1];

	//******************************
	// load bouquets file & fill GNode.
	//******************************
	filename = (gchar*) gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector));
	if (!(stream = fopen(filename, "rb"))){
		GtkWidget* dialog;
		sprintf(txtBuffer,_("Could not read: '%s' \n"),filename);
		dialog = gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,txtIn(txtBuffer));
		center_window(GTK_WINDOW(dialog));
		gtk_dialog_run (GTK_DIALOG (dialog));
		gtk_widget_destroy (dialog);
		return;
	}
	fgets(txtBuffer,BUFFER_SIZE,stream); // xml Version.
	fgets(txtBuffer,BUFFER_SIZE,stream); // ZAPIT - ID.
	if (!strFind(txtBuffer,"<ZAPIT>" )){
		GtkWidget* dialog= gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
			txtIn(_("channel format unknown")));
		gtk_dialog_run (GTK_DIALOG (dialog));
		gtk_widget_destroy (dialog);
		fclose(stream);
		return;
	}

	GTK_LIST_STORE(MW_GET("LEFT_LIST_STORE"))->sort_column_id = -2; 	// switch off sorting.
	clear_left_listview();
	fgets(txtBuffer,BUFFER_SIZE,stream);	// Bouquet-Kennung.
	if (!strFind(txtBuffer,"<BOUQUET" )){
		GtkWidget* dialog= gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
			txtIn(_("This is not a Bouquet File.\n"
							"Please select a bouquet-file like 'bouquets.xml'.")));
		gtk_dialog_run (GTK_DIALOG (dialog));
		gtk_widget_destroy (dialog);
		fclose(stream);
		return;
	}   
	// ***** OK, this seems to be a bouquets file.
	fseek(stream,0,0); 
	fgets(txtBuffer,BUFFER_SIZE,stream); 	// xml Version.
	fgets(txtBuffer,BUFFER_SIZE,stream);	// ZAPIT - ID.

	node_root = MW_GET("LEFT_NODE_ROOT");
	while(1){ // read all Bouquets.
		fgets(txtBuffer,BUFFER_SIZE,stream);	// Bouquet-Daten.
		if (strFind(txtBuffer,"</ZAPIT>" )) break;
		bouquet = malloc(sizeof(bouquetEntry));
		sumBouquets++;
		node_bouquet = g_node_append(node_root, g_node_new(bouquet));
		XMLtoAsc(bouquetName, extractData(txtBuffer,"name"));
		strcpy(bouquet->bouquetName,bouquetName);
		bouquet->hidden = atoi(extractData(txtBuffer,"hidden"));
		bouquet->locked = atoi(extractData(txtBuffer,"locked"));
		node_channel = g_node_last_child (node_bouquet);
		while(1){ // read all channels.
			fgets(txtBuffer,BUFFER_SIZE,stream);
			if (strFind(txtBuffer,"</BOUQUET>" )) break;
			channel = malloc(sizeof(channelEntry));
			node_channel = g_node_append(node_bouquet, g_node_new(channel));
			channel->serviceID= strtol(extractData(txtBuffer,"serviceID"),NULL,16);
			XMLtoAsc(channel->channelName, extractData(txtBuffer,"name"));
			channel->onid= strtol(extractData(txtBuffer,"onid"),NULL, 16);
			channel->frequency = 0;
		}
	}
	fclose(stream);
	// ******************************
	// die services Datei einlesen und die Bouquets in verkette Liste mit diesen
	// Daten ergänzen.
	// ******************************
	pfad=filename+strlen(filename);
	while(*pfad!='\\' && *pfad!='/') pfad--;
	*++pfad='\0';
	strcpy(txtBuffer, filename);
	strcat(txtBuffer,ZAPIT_SERV_NAME);
	if (!(stream = fopen(txtBuffer, "rb"))){
		GtkWidget* dialog;
		strcat(txtBuffer, _(" not found."));
		dialog = gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,txtIn(txtBuffer));
		center_window(GTK_WINDOW(dialog));
		gtk_dialog_run (GTK_DIALOG (dialog));
		gtk_widget_destroy (dialog);
		clear_left_listview();
		return;
	}
	fgets(txtBuffer,BUFFER_SIZE,stream); 	// xml Version.
	fgets(txtBuffer,BUFFER_SIZE,stream);	// ZAPIT-Kennung.

	while (1){ // alle Satelliten einlesen.
		fgets(txtBuffer,BUFFER_SIZE,stream);	// Sat / Kabel Daten.
		if (!strFind(txtBuffer,"<sat" ) && !strFind(txtBuffer,"<cable" )) break;	
		diseqc = atoi(extractData(txtBuffer,"diseqc"));
		while (1){ // alle Transponder einlesen.
			fgets(txtBuffer,BUFFER_SIZE,stream);	// Transponder
			if (strFind(txtBuffer,"</" )) break;
			transportID= strtol(extractData(txtBuffer,"transponder id"),NULL, 16);
			onid = strtol(extractData(txtBuffer,"onid"),NULL,16);
			frequenz= atoi(extractData(txtBuffer,"frequency"));
			symbolRate= atoi(extractData(txtBuffer,"symbol_rate"));
			fec= atoi(extractData(txtBuffer,"fec_inner"));
			polarity= atoi(extractData(txtBuffer,"polarization"));
			while(1){ // Alle Channels einlesen.
				gint test=0;
				fgets(txtBuffer,BUFFER_SIZE,stream);	// Kanaldaten.
				if (strFind(txtBuffer,"</" )) break;
				serviceID = strtol(extractData(txtBuffer,"service_id"),NULL,16);
				XMLtoAsc(name, extractData(txtBuffer,"name"));
				serviceType = strtol(extractData(txtBuffer,"service_type"),NULL,16);
				// ******************************
				// jeden einzelnen Sender in der Liste mit den neuen Daten ergänzen.
				// ******************************
				node_bouquet = g_node_first_child(node_root);
				while (node_bouquet){
					node_channel = g_node_first_child(node_bouquet);
					while (node_channel){
						channel = node_channel->data;
						if ((serviceID == channel->serviceID) && (onid == channel->onid))
						{ // dieser Sender ist in den Bouquets. Also fehlende Daten ergänzen.
							channel->serviceType=serviceType;
							channel->diseqc=diseqc;
							channel->transportID=transportID;
							channel->frequency=frequenz;
							channel->symbolRate=symbolRate;
							channel->fec=fec;
							channel->polarisation=polarity;
							test++;
						}
						node_channel = node_channel->next;
					}
					node_bouquet=node_bouquet->next;
				}
				// ******************************
				// Wenn der Sender aus den Services nicht in den Bouquets vorhanden war und die Liste
				// das komplette Bouquet enthält-> im Bouquet "*NEW*" eintragen.
				// ******************************
				if (!test && sumBouquets > 1){
					node_bouquet = g_node_last_child(node_root);
					bouquet = node_bouquet->data;
					if (strcmp(bouquet->bouquetName, "*NEW*")){
						bouquet = malloc(sizeof(bouquetEntry));
						node_bouquet = g_node_append(node_root, g_node_new(bouquet));
						strcpy(bouquet->bouquetName,"*NEW*");
						bouquet->hidden = FALSE;
						bouquet->locked = FALSE;
						sumBouquets++;
					}
					channel = malloc(sizeof(channelEntry));
					g_node_append(node_bouquet, g_node_new(channel));
					channel->serviceType=serviceType;
					channel->diseqc=diseqc;
					channel->transportID=transportID;
					channel->frequency=frequenz;
					channel->symbolRate=symbolRate;
					channel->fec=fec;
					channel->polarisation=polarity;
					XMLtoAsc(channel->channelName,name);
					channel->onid= onid;
					channel->serviceID= serviceID;
				}
			}
		}
	}
	fclose(stream);
	//******************************
	// Die Bouquets überprüfen. Wenn kein Eintrag bei (z.B.) Frequez vorhanden ist,
	// war der Sender nicht in der services enthalten -> Daten sind nicht komplett!
	// -> löschen. Ebenso wenn Datendienste nicht eingelsen werden sollten.
	//******************************
	node_bouquet = g_node_first_child(node_root);
	while (node_bouquet){
		node_channel = g_node_first_child (node_bouquet);
		while (node_channel){
			channel = node_channel->data;
			if ( (!channel->frequency) || ((!GTK_TOGGLE_BUTTON(MW_GET("OPT_READ_DATA"))->active)
				&& (getServicePic(channel->serviceType) == DATA)) )
			{ // Sender war in der Bouquets-datei, aber nicht in der Services -> Sender löschen.
				node_channel = remove_node(node_channel);
				continue;
			}
			node_channel = node_channel ->next;
		}
		if (!g_node_first_child (node_bouquet)){ // bouquet now empty ? -> delete it.
			node_bouquet = remove_node(node_bouquet);
			sumBouquets--;
			continue;
		}
		node_bouquet = node_bouquet->next;
	}
	gtk_widget_grab_focus(GTK_WIDGET(MW_GET("OPT_READ_SHORT"))); // unfocus search entry.
	fill_left_listview();
}
Пример #19
0
int ComputeTrace::compute(const char *)
{
    //input port object
    const coDistributedObject *obj = p_pointsIn->getCurrentObject();

    if (!obj)
    {
        //no input, no output
        sendError("Did not receive object at port '%s'", p_pointsIn->getName());
        return FAIL;
    }

    const coDoSet *IDset = dynamic_cast<const coDoSet *>(p_IDIn->getCurrentObject());
    if (IDset)
    {
        delete IDs;
        IDs = new int *[IDset->getNumElements()];
        for (int i = 0; i < IDset->getNumElements(); i++)
        {
            const coDoInt *IDObj = dynamic_cast<const coDoInt *>(IDset->getElement(i));
            if (IDObj)
            {
                IDObj->getAddress(&IDs[i]);
            }
            else
            {
                delete IDs;
                IDs = NULL;
                break;
            }
        }
    }
    if (const coDoSet *set = dynamic_cast<const coDoSet *>(obj))
    {
        if (set->getAttribute("TIMESTEP"))
        {
            // the TIMESTEP attribute arguments are not correct on many datasets, use 0 to numElems instead
            // the module fails if m_timestepStart>0
            /*int ret = sscanf(set->getAttribute("TIMESTEP"),"%d %d", &m_timestepStart, &m_timestepStop);
         if(ret == 0)
         {
            sendError("couldn't successfully read TIMESTEP arguments");
            return FAIL;
         }*/
            m_timestepStart = 0;
            m_timestepStop = set->getNumElements() - 1;

            if (m_firsttime)
            {
                m_firsttime = false;
                p_start->setValue(m_timestepStart, m_timestepStop, m_timestepStart);
                p_stop->setValue(m_timestepStart, m_timestepStop, m_timestepStop);
            }
            else
            {
                p_start->setValue(p_start->getValue(), m_timestepStop, m_timestepStart);
                p_stop->setValue(p_stop->getValue(), m_timestepStop, m_timestepStop);
            }
        }

        /* Creating the output object.
       * The TIMESTEP attribute is set automatically since this class
       * is derived of the coSimpleModule class*/
        if (p_traceOut->getObjName())
        {
            std::string name;
            // test if input objects are of coDoSpheres* type
            if (dynamic_cast<const coDoSpheres *>(set->getElement(0)))
            {
                // creating a string that contains all names of
                // all coDoSpheres objects separated by newline escape sequence
                int numElem = set->getNumElements();
                for (int i = 0; i < numElem; i++)
                {
                    name += (set->getElement(i))->getName();
                    name += "\n";
                }
            }

            //Compensating input errors caused by the user
            m_start = p_start->getValue();
            m_stop = p_stop->getValue();

            if (m_start < m_timestepStart)
            {
                sendWarning("start is smaller than the beginning of the timestep; start is set to min_timestep");
                m_start = m_timestepStart;
                p_start->setValue(m_start);
            }

            if (m_stop > m_timestepStop)
            {
                sendWarning("stop is larger than the maximum of timesteps; stop is set to max_timestep");
                m_stop = m_timestepStop;
                p_stop->setValue(m_stop);
            }

            // getting the selected particle string and
            // create the integer vector holding the element
            // indices with coRestraint
            m_particleIndices.clear();
            //fprintf(stderr, "\np_particle->getValue: %s\n", p_particle->getValue() );
            m_particleIndices.add(p_particle->getValue());
            m_particleSelection = m_particleIndices.getValues();

            // setting sorted, newly organized and formatted
            // string as particle string value
            std::string cleanedupString = m_particleIndices.getRestraintString();
            p_particle->setValue(cleanedupString.c_str());

            //Getting number of particles in the first timestep assuming that every
            //new timestep holds the same number of particles
            int no_of_points = 0;
            float min[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
            float max[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
            if (const coDoCoordinates *coord = dynamic_cast<const coDoCoordinates *>(set->getElement(0)))
            {
                no_of_points = coord->getNumElements();
                for (int i = 0; i < no_of_points; ++i)
                {
                    float x, y, z;
                    coord->getPointCoordinates(i, &x, &y, &z);
                    if (x > max[0])
                        max[0] = x;
                    if (y > max[1])
                        max[1] = y;
                    if (z > max[2])
                        max[2] = z;
                    if (x < min[0])
                        min[0] = x;
                    if (y < min[1])
                        min[1] = y;
                    if (z < min[2])
                        min[2] = z;
                }
                p_boundingBoxDimensions->setValue(max[0] - min[0], max[1] - min[1], max[2] - min[2]);
            }
            else if (dynamic_cast<const coDoTriangleStrips *>(set->getElement(0)))
            {
                sendError("Use Manual CPU Billboards instead of Polygons.");
                return FAIL;
            }
            else
            {
                sendError("wrong input type at input port. Type must be either Spheres or Points.");
                return FAIL;
            }

            //test if specified particles smaller than the maximum number of particles
            if (IDs == NULL)
            {
                if (!m_particleSelection.empty() && m_particleSelection.back() >= no_of_points)
                {
                    stringstream range;
                    range << "0-" << no_of_points - 1;
                    sendWarning("The particle index you specified is out of range. Particles out of range will be removed. Valid range is %s", range.str().c_str());
                    while (!m_particleSelection.empty() && m_particleSelection.back() >= no_of_points)
                    {
                        m_particleSelection.pop_back();
                    }
                    std::string modifiedString = m_particleIndices.getRestraintString(m_particleSelection);
                    p_particle->setValue(modifiedString.c_str());
                }

                if (m_particleSelection.size() > p_maxParticleNumber->getValue())
                {
                    while (m_particleSelection.size() > p_maxParticleNumber->getValue())
                        m_particleSelection.pop_back();
                }
            }

            //structure that holds the output components
            coDistributedObject **traceLines = NULL;

            // depending on the selection string create the
            // traces or a NULL object that holds NULL-line elements
            // for every timestep
            bool empty = false;
            if (!p_traceParticle->getValue() || m_particleSelection.empty())
            {
                traceLines = computeDynamicTrace(set, false);
                empty = true;
                fprintf(stderr, "empty: traceLines=%p\n", traceLines);
            }
            else if (p_animate->getValue())
            {
                traceLines = computeDynamicTrace(set, true);
            }
            else
            {
                traceLines = new coDistributedObject *[1];
                traceLines[0] = computeStaticTrace(std::string(p_traceOut->getObjName()), set);
            }

            // creating the output
            coDistributedObject *traces = (p_animate->getValue() || empty)
                                              ? new coDoSet(p_traceOut->getObjName(), traceLines)
                                              : traceLines[0];
            delete[] traceLines;

            if (dynamic_cast<const coDoSpheres *>(set->getElement(0)))
            {
                // creating the feedback object needed for
                // openCOVER<->COVISE interaction
                coFeedback feedback("PickSphere");
                feedback.addPara(p_start);
                feedback.addPara(p_stop);
                feedback.addPara(p_particle);
                feedback.addPara(p_traceParticle);
                feedback.addPara(p_regardInterrupt);

                // all coDoSphere object names are attached to the trace lines
                traces->addAttribute("PICKSPHERE", name.c_str());

                // viewpoint animation parameters
                feedback.addPara(p_animateViewer);
                feedback.addPara(p_animLookAt);

                // attaching the feedback object to trace lines
                feedback.apply(traces);
            }

            // setting the output object
            p_traceOut->setCurrentObject(traces);
        }
        else
        {
            fprintf(stderr, "Covise::getObjName failed\n");
            return FAIL;
        }

        if (p_indexOut->getObjName())
        {
            coDistributedObject *indices = computeFloats(returnIndex, p_indexOut->getObjName());
            p_indexOut->setCurrentObject(indices);
        }
        else
        {
            fprintf(stderr, "Covise::getObjName failed\n");
            return FAIL;
        }

        if (p_fadingOut->getObjName())
        {
            coDistributedObject *fading = computeFloats(fade, p_fadingOut->getObjName());
            p_fadingOut->setCurrentObject(fading);
        }
        else
        {
            fprintf(stderr, "Covise::getObjName failed\n");
            return FAIL;
        }

        if (p_dataOut->getObjName())
        {
            if (const coDoSet *set = dynamic_cast<const coDoSet *>(p_dataIn->getCurrentObject()))
                p_dataOut->setCurrentObject(extractData(p_dataOut->getObjName(), set, p_animate->getValue()));
            else if (p_dataIn->getCurrentObject())
                fprintf(stderr, "need a set of data");
        }
        else
        {
            fprintf(stderr, "Covise::getObjName failed\n");
            return FAIL;
        }
    }
    else
    {
        sendInfo("need a set object with time steps");
        return FAIL;
    }
    return SUCCESS;
}
Пример #20
0
void Tercon::readData(){
    recvBytes.append(port->readAll());
    extractData();
}
Пример #21
0
void HeightmapShapeGeode<S>::refresh()
{
  mUtilized = true;

  extractData();
}