예제 #1
0
/* Analyze transmission bit after bit */
int findEncodedBitLength(unsigned char level)
{
	levelsCounter++;

	/* Out of range */
	if (levelsCounter >
	    SYNCHRO_LENGTH + LENGTHS_MARGIN + SEPARATOR_LENGTH +
	    LENGTHS_MARGIN) {
		levelsCounter = 1;
		resetRecording();
		previousEncodedBitInRange = 1;
	}

	int encodedBitLength = -1;
	if (level == 0) {
		if (levelOneCounter > SEPARATOR_LENGTH - LENGTHS_MARGIN
		    && levelOneCounter < SEPARATOR_LENGTH + LENGTHS_MARGIN) {
			if (previousEncodedBitInRange) {
				encodedBitLength =
				    levelsCounter - levelOneCounter;
			}
			levelsCounter = 0;
			previousEncodedBitInRange = 1;
		}
		levelOneCounter = 0;
	} else {
		levelOneCounter++;
	}
	return encodedBitLength;
}
예제 #2
0
void decodeBitLength(int length)
{
	/* Signal length too short */
	if (length < ZERO_LENGTH - LENGTHS_MARGIN) {
		return;
	}

	/* Sync bit - Start of data package */
	if (length > SYNCHRO_LENGTH - LENGTHS_MARGIN * 2
	    && length < SYNCHRO_LENGTH + LENGTHS_MARGIN * 2 && !recording) {
		resetRecording();
		recording = 1;

		/* One  */
	} else if (length > ONE_LENGTH - LENGTHS_MARGIN
		   && length < ONE_LENGTH + LENGTHS_MARGIN && recording) {
		encodedBits[encodedBitsIndex++] = 1;

		/* Zero */
	} else if (length > ZERO_LENGTH - LENGTHS_MARGIN
		   && length < ZERO_LENGTH + LENGTHS_MARGIN && recording) {
		encodedBits[encodedBitsIndex++] = 0;

		/* Sync bit - End of data package */
	} else if (length > SYNCHRO_LENGTH - LENGTHS_MARGIN * 2
		   && length < SYNCHRO_LENGTH + LENGTHS_MARGIN * 2
		   && recording) {
		decodeArray();
		resetRecording();
		recording = 1;

		/* Signal length too long */
	} else if (recording) {
		resetRecording();
	}
}
예제 #3
0
void RecorderDialog::createCalculator()
{
    ParametersMapperRecorder *mapper = new ParametersMapperRecorder();

    mapper->setRecorderControlWidget(mRecorderControlWidget);
    mapper->setBaseParametersControlWidget(mBaseControlWidget);
    mapper->setPresentationParametersControlWidget(mPresentationControlWidget);

    connect(mapper, SIGNAL(recorderParamsChanged(QSharedPointer<Recorder>))
            , this, SLOT(recorderControlParametersChanged(QSharedPointer<Recorder>)));

  /*  connect(mapper, SIGNAL(baseParametersParamsChanged(QSharedPointer<BaseParameters>))
            , this, SLOT(baseControlParametersChanged(QSharedPointer<Base>)));*/

    mCalculator = new RecorderThread();

    connect(mapper, SIGNAL(baseParametersParamsChanged(QSharedPointer<BaseParameters>))
            , static_cast<RecorderThread*>(mCalculator)
            , SLOT(baseControlParametersChanged(QSharedPointer<BaseParameters>)));
    connect(mapper, SIGNAL(recorderParamsChanged(QSharedPointer<Recorder>))
            , static_cast<RecorderThread*>(mCalculator)
            , SLOT(recorderControlParametersChanged(QSharedPointer<Recorder>)));
    connect(mapper, SIGNAL(presentationParametersParamsChanged(QSharedPointer<PresentationParameters>))
            , static_cast<RecorderThread*>(mCalculator)
            , SLOT(presentationControlParametersChanged(QSharedPointer<PresentationParameters>)));

    mapper->paramsChanged();

    mParamsMapper = mapper;

    connect(this, SIGNAL(recordingTriggered()), mCalculator, SLOT(toggleRecording()), Qt::QueuedConnection);

    connect(mRecorderControlWidget->ui()->recRestartButton, SIGNAL(released()), mCalculator, SLOT(resetRecording()), Qt::QueuedConnection);
    connect(mRecorderControlWidget->ui()->recPauseButton, SIGNAL(released()), mCalculator, SLOT(toggleRecording()), Qt::QueuedConnection);

    connect(mCalculator, SIGNAL(recordingStateChanged(RecorderThread::RecordingState)), this,
            SLOT(recordingStateChanged(RecorderThread::RecordingState)), Qt::QueuedConnection);

    connect(mCalculator, SIGNAL(errorMessage(QString)),
            this,        SLOT  (errorMessage(QString)), Qt::BlockingQueuedConnection);

}