updating code from Flying Laptop

This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
2018-07-12 16:29:32 +02:00
parent 1d22a6c97e
commit 575f70ba03
395 changed files with 12807 additions and 8404 deletions

View File

@ -18,7 +18,7 @@
class HasModesIF {
friend class ModeHelper;
public:
static const uint8_t INTERFACE_ID = HAS_MODES_IF;
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_MODES_IF;
static const ReturnValue_t INVALID_MODE = MAKE_RETURN_CODE(0x01);
static const ReturnValue_t TRANS_NOT_ALLOWED = MAKE_RETURN_CODE(0x02);
static const ReturnValue_t IN_TRANSITION = MAKE_RETURN_CODE(0x03);
@ -40,8 +40,7 @@ public:
virtual ~HasModesIF() {
}
virtual MessageQueueId_t getCommandQueue() const = 0;
virtual void getMode(Mode_t *mode, Submode_t *submode) {
}
virtual void getMode(Mode_t *mode, Submode_t *submode) = 0;
protected:
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) {

View File

@ -1,5 +1,6 @@
#include <framework/modes/HasModesIF.h>
#include <framework/modes/ModeHelper.h>
#include <framework/ipc/MessageQueueSenderIF.h>
ModeHelper::ModeHelper(HasModesIF *owner) :
theOneWhoCommandedAMode(0), commandedMode(HasModesIF::MODE_OFF), commandedSubmode(
@ -18,7 +19,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* message) {
switch (message->getCommand()) {
case ModeMessage::CMD_MODE_COMMAND_FORCED:
forced = true;
/*NO BREAK*/
/* NO BREAK falls through*/
case ModeMessage::CMD_MODE_COMMAND: {
mode = ModeMessage::getMode(message);
submode = ModeMessage::getSubmode(message);
@ -26,7 +27,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* message) {
ReturnValue_t result = owner->checkModeCommand(mode, submode, &timeout);
if (result != HasReturnvaluesIF::RETURN_OK) {
ModeMessage::cantReachMode(&reply, result);
sender.sendMessage(message->getSender(), &reply,
MessageQueueSenderIF::sendMessage(message->getSender(), &reply,
owner->getCommandQueue());
break;
}
@ -35,7 +36,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* message) {
commandedMode = mode;
commandedSubmode = submode;
if ((parentQueueId != MessageQueueSender::NO_QUEUE)
if ((parentQueueId != MessageQueueSenderIF::NO_QUEUE)
&& (theOneWhoCommandedAMode != parentQueueId)) {
owner->setToExternalControl();
}
@ -49,7 +50,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* message) {
owner->getMode(&mode, &submode);
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_REPLY, mode,
submode);
sender.sendMessage(message->getSender(), &reply,
MessageQueueSenderIF::sendMessage(message->getSender(), &reply,
owner->getCommandQueue());
}
break;
@ -73,7 +74,7 @@ ReturnValue_t ModeHelper::initialize(MessageQueueId_t parentQueueId) {
void ModeHelper::modeChanged(Mode_t mode, Submode_t submode) {
forced = false;
CommandMessage reply;
if (theOneWhoCommandedAMode != MessageQueueSender::NO_QUEUE) {
if (theOneWhoCommandedAMode != MessageQueueSenderIF::NO_QUEUE) {
if ((mode != commandedMode) || (submode != commandedSubmode)) {
ModeMessage::setModeMessage(&reply,
ModeMessage::REPLY_WRONG_MODE_REPLY, mode, submode);
@ -81,16 +82,16 @@ void ModeHelper::modeChanged(Mode_t mode, Submode_t submode) {
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_REPLY,
mode, submode);
}
sender.sendMessage(theOneWhoCommandedAMode, &reply,
MessageQueueSenderIF::sendMessage(theOneWhoCommandedAMode, &reply,
owner->getCommandQueue());
}
if (theOneWhoCommandedAMode != parentQueueId
&& parentQueueId != MessageQueueSender::NO_QUEUE) {
&& parentQueueId != MessageQueueSenderIF::NO_QUEUE) {
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO, mode,
submode);
sender.sendMessage(parentQueueId, &reply, owner->getCommandQueue());
MessageQueueSenderIF::sendMessage(parentQueueId, &reply, owner->getCommandQueue());
}
theOneWhoCommandedAMode = MessageQueueSender::NO_QUEUE;
theOneWhoCommandedAMode = MessageQueueSenderIF::NO_QUEUE;
}
void ModeHelper::startTimer(uint32_t timeoutMs) {

View File

@ -1,7 +1,6 @@
#ifndef MODEHELPER_H_
#define MODEHELPER_H_
#include <framework/ipc/MessageQueueSender.h>
#include <framework/modes/ModeMessage.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/timemanager/Countdown.h>
@ -43,7 +42,6 @@ protected:
MessageQueueId_t parentQueueId;
Countdown countdown;
MessageQueueSender sender;
bool forced;
};

View File

@ -1,10 +1,3 @@
/*
* ModeMessage.cpp
*
* Created on: 12.07.2013
* Author: tod
*/
#include <framework/modes/ModeMessage.h>
Mode_t ModeMessage::getMode(const CommandMessage* message) {

View File

@ -17,13 +17,13 @@ class ModeMessage {
private:
ModeMessage();
public:
static const uint8_t MESSAGE_ID = MODE_COMMAND_MESSAGE_ID;
static const uint8_t MESSAGE_ID = MESSAGE_TYPE::MODE_COMMAND;
static const Command_t CMD_MODE_COMMAND = MAKE_COMMAND_ID(0x01);//!> Command to set the specified Mode, replies are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies, as this will break the subsystem mode machine!!
static const Command_t CMD_MODE_COMMAND_FORCED = MAKE_COMMAND_ID(0xF1);//!> Command to set the specified Mode, regardless of external control flag, replies are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies, as this will break the subsystem mode machine!!
static const Command_t REPLY_MODE_REPLY = MAKE_COMMAND_ID(0x02);//!> Reply to a CMD_MODE_COMMAND or CMD_MODE_READ
static const Command_t REPLY_MODE_INFO = MAKE_COMMAND_ID(0x03); //!> Unrequested info about the current mode (used for composites to inform their container of a changed mode)
static const Command_t REPLY_CANT_REACH_MODE = MAKE_COMMAND_ID(0x04); //!> Reply in case a mode command can't be executed. Par1: returnCode, Par2: 0
//TODO is there a way we can transmit a returnvalue when responding that the mode is wrong, so we can give a nice failure code when commanded by PUS?
//SHOULDDO is there a way we can transmit a returnvalue when responding that the mode is wrong, so we can give a nice failure code when commanded by PUS?
static const Command_t REPLY_WRONG_MODE_REPLY = MAKE_COMMAND_ID(0x05);//!> Reply to a CMD_MODE_COMMAND, indicating that a mode was commanded and a transition started but was aborted; the parameters contain the mode that was reached
static const Command_t CMD_MODE_READ = MAKE_COMMAND_ID(0x06);//!> Command to read the current mode and reply with a REPLY_MODE_REPLY
static const Command_t CMD_MODE_ANNOUNCE = MAKE_COMMAND_ID(0x07);//!> Command to trigger an ModeInfo Event. This command does NOT have a reply.