rm3100 finished, lis3 set normal datapool entries
invalid removed, will be replaced by default implementation
This commit is contained in:
@ -7,7 +7,11 @@
|
||||
|
||||
MGMHandlerRM3100::MGMHandlerRM3100(object_id_t objectId,
|
||||
object_id_t deviceCommunication, CookieIF* comCookie):
|
||||
DeviceHandlerBase(objectId, deviceCommunication, comCookie) {
|
||||
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
||||
primaryDataset(this) {
|
||||
#if OBSW_ENHANCED_PRINTOUT == 1
|
||||
debugDivider = new PeriodicOperationDivider(10);
|
||||
#endif
|
||||
}
|
||||
|
||||
MGMHandlerRM3100::~MGMHandlerRM3100() {}
|
||||
@ -140,7 +144,9 @@ ReturnValue_t MGMHandlerRM3100::scanForReply(const uint8_t *start,
|
||||
|
||||
ReturnValue_t MGMHandlerRM3100::interpretDeviceReply(
|
||||
DeviceCommandId_t id, const uint8_t *packet) {
|
||||
if(id == RM3100::READ_CMM) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
switch(id) {
|
||||
case(RM3100::READ_CMM): {
|
||||
if(packet[1] == cmmRegValue) {
|
||||
commandExecuted = true;
|
||||
}
|
||||
@ -149,13 +155,14 @@ ReturnValue_t MGMHandlerRM3100::interpretDeviceReply(
|
||||
internalState = STATE_CONFIGURE_CMM;
|
||||
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if(id == RM3100::READ_TMRC) {
|
||||
case(RM3100::READ_TMRC): {
|
||||
if(packet[1] == tmrcRegValue) {
|
||||
commandExecuted = true;
|
||||
// Reading TMRC was commanded.
|
||||
if(mode == MODE_NORMAL) {
|
||||
|
||||
// Reading TMRC was commanded. Trigger event to inform ground.
|
||||
if(mode != _MODE_START_UP) {
|
||||
triggerEvent(tmrcSet, tmrcRegValue, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -163,22 +170,33 @@ ReturnValue_t MGMHandlerRM3100::interpretDeviceReply(
|
||||
internalState = STATE_CONFIGURE_TMRC;
|
||||
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if(id == RM3100::READ_DATA) {
|
||||
// analyze data here.
|
||||
// Field strengths in micro Tesla
|
||||
int32_t fieldStrengthX = (packet[1] << 16 | packet[2] << 8 | packet[3])
|
||||
* scaleFactorX;
|
||||
int32_t fieldStrengthY = (packet[4] << 16 | packet[5] << 8 | packet[6])
|
||||
* scaleFactorY;
|
||||
int32_t fieldStrengthZ = (packet[7] << 16 | packet[8] << 8 | packet[9])
|
||||
* scaleFactorZ;
|
||||
case(RM3100::READ_CYCLE_COUNT): {
|
||||
uint16_t cycleCountX = packet[1] << 8 | packet[2];
|
||||
uint16_t cycleCountY = packet[3] << 8 | packet[4];
|
||||
uint16_t cycleCountZ = packet[5] << 8 | packet[6];
|
||||
if(cycleCountX != cycleCountRegValueX or
|
||||
cycleCountY != cycleCountRegValueY or
|
||||
cycleCountZ != cycleCountRegValueZ) {
|
||||
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
|
||||
}
|
||||
// Reading TMRC was commanded. Trigger event to inform ground.
|
||||
if(mode != _MODE_START_UP) {
|
||||
uint32_t eventParam1 = cycleCountX << 16 | cycleCountY;
|
||||
triggerEvent(cycleCountersSet, eventParam1, cycleCountZ);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
case(RM3100::READ_DATA): {
|
||||
result = handleDataReadout(packet);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t MGMHandlerRM3100::handleCycleCountConfigCommand(
|
||||
@ -252,3 +270,66 @@ ReturnValue_t MGMHandlerRM3100::handleTmrcConfigCommand(
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void MGMHandlerRM3100::fillCommandAndReplyMap() {
|
||||
insertInCommandAndReplyMap(RM3100::CONFIGURE_CMM, 1);
|
||||
insertInCommandAndReplyMap(RM3100::READ_CMM, 1);
|
||||
|
||||
insertInCommandAndReplyMap(RM3100::CONFIGURE_TMRC, 1);
|
||||
insertInCommandAndReplyMap(RM3100::READ_TMRC, 1);
|
||||
|
||||
insertInCommandAndReplyMap(RM3100::CONFIGURE_CYCLE_COUNT, 1);
|
||||
insertInCommandAndReplyMap(RM3100::READ_CYCLE_COUNT, 1);
|
||||
|
||||
insertInCommandAndReplyMap(RM3100::READ_DATA, 1, &primaryDataset);
|
||||
}
|
||||
|
||||
void MGMHandlerRM3100::modeChanged(void) {
|
||||
internalState = STATE_NONE;
|
||||
}
|
||||
|
||||
ReturnValue_t MGMHandlerRM3100::initializeLocalDataPool(
|
||||
LocalDataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_X,
|
||||
new PoolEntry<float>(0.0));
|
||||
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Y,
|
||||
new PoolEntry<float>(0.0));
|
||||
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Z,
|
||||
new PoolEntry<float>(0.0));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
uint32_t MGMHandlerRM3100::getTransitionDelayMs(Mode_t from, Mode_t to) {
|
||||
return 5000;
|
||||
}
|
||||
|
||||
ReturnValue_t MGMHandlerRM3100::handleDataReadout(const uint8_t *packet) {
|
||||
// analyze data here.
|
||||
// Field strengths in micro Tesla
|
||||
int32_t fieldStrengthX = (packet[1] << 16 | packet[2] << 8 | packet[3])
|
||||
* scaleFactorX;
|
||||
int32_t fieldStrengthY = (packet[4] << 16 | packet[5] << 8 | packet[6])
|
||||
* scaleFactorY;
|
||||
int32_t fieldStrengthZ = (packet[7] << 16 | packet[8] << 8 | packet[9])
|
||||
* scaleFactorZ;
|
||||
|
||||
#if OBSW_ENHANCED_PRINTOUT == 1
|
||||
if(debugDivider->checkAndIncrement()) {
|
||||
sif::info << "MGMHandlerLIS3: Magnetic field strength in"
|
||||
" microtesla:" << std::endl;
|
||||
// Set terminal to utf-8 if there is an issue with micro printout.
|
||||
sif::info << "X: " << fieldStrengthX << " \xC2\xB5T" << std::endl;
|
||||
sif::info << "Y: " << fieldStrengthY << " \xC2\xB5T" << std::endl;
|
||||
sif::info << "Z: " << fieldStrengthZ << " \xC2\xB5T" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
ReturnValue_t result = primaryDataset.read(20);
|
||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||
primaryDataset.fieldStrengthX = fieldStrengthX;
|
||||
primaryDataset.fieldStrengthY = fieldStrengthY;
|
||||
primaryDataset.fieldStrengthZ = fieldStrengthZ;
|
||||
primaryDataset.setValidity(true, true);
|
||||
result = primaryDataset.commit(20);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user