2016-06-15 23:48:41 +02:00
|
|
|
/**
|
|
|
|
* @file Farm1StateOpen.cpp
|
|
|
|
* @brief This file defines the Farm1StateOpen class.
|
|
|
|
* @date 24.04.2013
|
|
|
|
* @author baetz
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "ClcwIF.h"
|
|
|
|
#include "Farm1StateOpen.h"
|
|
|
|
#include "TcTransferFrame.h"
|
|
|
|
#include "VirtualChannelReception.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
Farm1StateOpen::Farm1StateOpen(VirtualChannelReception* setMyVC) : myVC(setMyVC) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t Farm1StateOpen::handleADFrame(TcTransferFrame* frame,
|
|
|
|
ClcwIF* clcw) {
|
|
|
|
int8_t diff = frame->getSequenceNumber() - myVC->vR;
|
|
|
|
if (diff == 0 ) {
|
|
|
|
myVC->vR++;
|
|
|
|
clcw->setRetransmitFlag(false);
|
2018-07-12 16:29:32 +02:00
|
|
|
return RETURN_OK;
|
2016-06-15 23:48:41 +02:00
|
|
|
} else if (diff < myVC->positiveWindow && diff > 0 ) {
|
|
|
|
clcw->setRetransmitFlag(true);
|
|
|
|
return NS_POSITIVE_W;
|
|
|
|
} else if (diff < 0 && diff >= -myVC->negativeWindow) {
|
|
|
|
return NS_NEGATIVE_W;
|
|
|
|
} else {
|
|
|
|
clcw->setLockoutFlag(true);
|
|
|
|
myVC->currentState = &(myVC->lockoutState);
|
|
|
|
return NS_LOCKOUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t Farm1StateOpen::handleBCUnlockCommand( ClcwIF* clcw ) {
|
|
|
|
myVC->farmBCounter++;
|
|
|
|
clcw->setRetransmitFlag(false);
|
|
|
|
return BC_IS_UNLOCK_COMMAND;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t Farm1StateOpen::handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr ) {
|
|
|
|
myVC->farmBCounter++;
|
|
|
|
clcw->setRetransmitFlag(false);
|
|
|
|
myVC->vR = vr;
|
|
|
|
return BC_IS_SET_VR_COMMAND;
|
|
|
|
}
|