fsfw/datalinklayer/Farm1StateWait.cpp
2016-06-15 23:48:49 +02:00

44 lines
1.2 KiB
C++

/**
* @file Farm1StateWait.cpp
* @brief This file defines the Farm1StateWait class.
* @date 24.04.2013
* @author baetz
*/
#include <framework/datalinklayer/ClcwIF.h>
#include <framework/datalinklayer/Farm1StateWait.h>
#include <framework/datalinklayer/TcTransferFrame.h>
#include <framework/datalinklayer/VirtualChannelReception.h>
Farm1StateWait::Farm1StateWait(VirtualChannelReception* setMyVC) : myVC(setMyVC) {
}
ReturnValue_t Farm1StateWait::handleADFrame(TcTransferFrame* frame,
ClcwIF* clcw) {
int8_t diff = frame->getSequenceNumber() - myVC->vR;
if ( diff < -myVC->negativeWindow || diff >= myVC->positiveWindow ) {
clcw->setLockoutFlag(true);
myVC->currentState = &(myVC->lockoutState);
}
return FARM_IN_WAIT;
}
ReturnValue_t Farm1StateWait::handleBCUnlockCommand(ClcwIF* clcw) {
myVC->farmBCounter++;
clcw->setRetransmitFlag(false);
clcw->setWaitFlag( false );
myVC->currentState = &(myVC->openState);
return BC_IS_UNLOCK_COMMAND;
}
ReturnValue_t Farm1StateWait::handleBCSetVrCommand(ClcwIF* clcw, uint8_t vr) {
myVC->farmBCounter++;
clcw->setWaitFlag( false );
clcw->setRetransmitFlag(false);
myVC->vR = vr;
myVC->currentState = &(myVC->openState);
return BC_IS_SET_VR_COMMAND;
}