예제 #1
0
void ALSSensorChannel::emitData(const TimedUnsigned& value)
{
    if (value.value_ != previousValue_.value_) {
        previousValue_.value_ = value.value_;

        writeToClients((const void*)(&value), sizeof(value));
    }

#ifdef PROVIDE_CONTEXT_INFO
    // Publish the new data via Context FW. Note that setting the same
    // value twice does no harm.
    if (value.value_ < 10) {
        isDarkProperty.setValue(true);
        isBrightProperty.setValue(false);
    }
    else if (value.value_ > 290) {
        isBrightProperty.setValue(true);
        isDarkProperty.setValue(false);
    }
    else {
        isDarkProperty.setValue(false);
        isBrightProperty.setValue(false);
    }
#endif
}
예제 #2
0
int getData()
{
        int i;
        int constant;

        // get as many bytes in the socket to fill up the buffer
        n = recv(sockfd, tempBuf + readCount, length - readCount, MSG_DONTWAIT);        
        if(n>0)
                readCount += n;

        if(readCount == length)        //when get enough data
        {
                // check header constant 
                constant = ((int*)(tempBuf))[0];
                fprintf(stderr, "\nReading header... ");  
                printf("header.constSync is %X\n", constant);
                if(constant != 0xACFDFFBC)
                        error1("ERROR reading from socket, incorrect header placement\n");

                //put data into a buffer
               // for( i = 0 ; i < samp_rate; i++)
                 //       buffer[i] = ((double*)(tempBuf + sizeof(struct fft_header)))[i];
                //fprintf(stderr, "Reading data... ");

                //shift
                // call send to reciever here
                readCount = 0;
                if (list->head != NULL)
                	writeToClients();
        }
        return 1;
}
예제 #3
0
void GyroscopeSensorChannel::emitData(const TimedXyzData& value)
{
    previousSample_ = value;
    writeToClients((const void*)(&value), sizeof(TimedXyzData));
}