Merge branch 'mueller_framework' into front_branch
This commit is contained in:
commit
062ebabb9a
@ -105,18 +105,18 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid) {
|
||||
}
|
||||
|
||||
// and now we set a HK message and send it the HK packet destination.
|
||||
//HousekeepingMessage hkMessage;
|
||||
// hkMessage.setHkReportMessage(sid, storeId);
|
||||
// if(hkQueue == nullptr) {
|
||||
// return QUEUE_NOT_SET;
|
||||
// }
|
||||
//
|
||||
// if(currentHkPacketDestination != MessageQueueIF::NO_QUEUE) {
|
||||
// result = hkQueue->sendMessage(currentHkPacketDestination, &hkMessage);
|
||||
// }
|
||||
// else {
|
||||
// result = hkQueue->sendToDefault(&hkMessage);
|
||||
// }
|
||||
CommandMessage hkMessage;
|
||||
HousekeepingMessage::setHkReportMessage(&hkMessage, sid, storeId);
|
||||
if(hkQueue == nullptr) {
|
||||
return QUEUE_NOT_SET;
|
||||
}
|
||||
|
||||
if(currentHkPacketDestination != MessageQueueIF::NO_QUEUE) {
|
||||
result = hkQueue->sendMessage(currentHkPacketDestination, &hkMessage);
|
||||
}
|
||||
else {
|
||||
result = hkQueue->sendToDefault(&hkMessage);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ ReturnValue_t LocalDataSet::serializeWithValidityBuffer(uint8_t **buffer,
|
||||
if(registeredVariables[count]->isValid()) {
|
||||
// set validity buffer here.
|
||||
this->bitSetter(validityMask + validBufferIndex,
|
||||
validBufferIndexBit, true);
|
||||
validBufferIndexBit);
|
||||
if(validBufferIndexBit == 7) {
|
||||
validBufferIndex ++;
|
||||
validBufferIndexBit = 0;
|
||||
@ -83,13 +83,12 @@ ReturnValue_t LocalDataSet::serializeLocalPoolIds(uint8_t** buffer,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void LocalDataSet::bitSetter(uint8_t* byte, uint8_t position,
|
||||
bool value) const {
|
||||
void LocalDataSet::bitSetter(uint8_t* byte, uint8_t position) const {
|
||||
if(position > 7) {
|
||||
sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl;
|
||||
return;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
*byte |= 1UL << shiftNumber;
|
||||
*byte |= 1 << shiftNumber;
|
||||
}
|
||||
|
||||
|
@ -98,14 +98,10 @@ private:
|
||||
LocalDataPoolManager* hkManager;
|
||||
|
||||
/**
|
||||
* Sets the bit at the bit-position of a byte provided by its address
|
||||
* to the specified value (zero or one).
|
||||
* @param byte Pointer to byte to bitset.
|
||||
* @param position MSB first, 0 to 7 possible.
|
||||
* @param value Value to set.
|
||||
* @return
|
||||
* Set n-th bit of a byte, with n being the position from 0
|
||||
* (most significant bit) to 7 (least significant bit)
|
||||
*/
|
||||
void bitSetter(uint8_t* byte, uint8_t position, bool value) const;
|
||||
void bitSetter(uint8_t* byte, uint8_t position) const;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_ */
|
||||
|
@ -1374,6 +1374,15 @@ ReturnValue_t DeviceHandlerBase::changeCollectionInterval(sid_t sid,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() {
|
||||
// In this function, the task handle should be valid if the task
|
||||
// was implemented correctly. We still check to be 1000 % sure :-)
|
||||
if(executingTask != nullptr) {
|
||||
pstIntervalMs = executingTask->getPeriodMs();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
DataSetIF* DeviceHandlerBase::getDataSetHandle(sid_t sid) {
|
||||
auto iter = deviceReplyMap.find(sid.ownerSetId);
|
||||
if(iter != deviceReplyMap.end()) {
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include <framework/modes/HasModesIF.h>
|
||||
#include <framework/power/PowerSwitchIF.h>
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
#include <framework/tasks/PeriodicTaskIF.h>
|
||||
|
||||
#include <framework/action/ActionHelper.h>
|
||||
#include <framework/health/HealthHelper.h>
|
||||
#include <framework/parameters/ParameterHelper.h>
|
||||
@ -18,6 +20,7 @@
|
||||
#include <framework/datapoollocal/LocalDataPoolManager.h>
|
||||
#include <framework/devicehandlers/DeviceHandlerFailureIsolation.h>
|
||||
#include <framework/datapoollocal/OwnsLocalDataPoolIF.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace Factory{
|
||||
@ -563,6 +566,8 @@ protected:
|
||||
|
||||
/** This is the counter value from performOperation(). */
|
||||
uint8_t pstStep = 0;
|
||||
uint32_t pstIntervalMs = 0;
|
||||
|
||||
/**
|
||||
* Wiretapping flag:
|
||||
*
|
||||
@ -1196,9 +1201,11 @@ private:
|
||||
|
||||
ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message);
|
||||
|
||||
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
||||
DataSetIF* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
void parseReply(const uint8_t* receivedData,
|
||||
size_t receivedDataLen);
|
||||
DataSetIF* getDataSetHandle(sid_t sid) override;
|
||||
};
|
||||
|
||||
#endif /* DEVICEHANDLERBASE_H_ */
|
||||
|
@ -68,6 +68,10 @@ size_t CommandMessage::getMinimumMessageSize() const {
|
||||
return MINIMUM_COMMAND_MESSAGE_SIZE;
|
||||
}
|
||||
|
||||
void CommandMessage::clearCommandMessage() {
|
||||
clear();
|
||||
}
|
||||
|
||||
void CommandMessage::clear() {
|
||||
CommandMessageCleaner::clearCommandMessage(this);
|
||||
}
|
||||
@ -84,18 +88,15 @@ void CommandMessage::setToUnknownCommand() {
|
||||
|
||||
void CommandMessage::setReplyRejected(ReturnValue_t reason,
|
||||
Command_t initialCommand) {
|
||||
std::memcpy(getData(), &reason, sizeof(reason));
|
||||
std::memcpy(getData() + sizeof(reason), &initialCommand,
|
||||
sizeof(initialCommand));
|
||||
setParameter(reason);
|
||||
setParameter2(initialCommand);
|
||||
}
|
||||
|
||||
ReturnValue_t CommandMessage::getReplyRejectedReason(
|
||||
Command_t *initialCommand) const {
|
||||
ReturnValue_t reason = HasReturnvaluesIF::RETURN_FAILED;
|
||||
std::memcpy(&reason, getData(), sizeof(reason));
|
||||
ReturnValue_t reason = getParameter();
|
||||
if(initialCommand != nullptr) {
|
||||
std::memcpy(initialCommand, getData() + sizeof(reason),
|
||||
sizeof(Command_t));
|
||||
*initialCommand = getParameter2();
|
||||
}
|
||||
return reason;
|
||||
}
|
||||
|
@ -111,7 +111,9 @@ public:
|
||||
ReturnValue_t getReplyRejectedReason(
|
||||
Command_t* initialCommand = nullptr) const override;
|
||||
|
||||
|
||||
virtual void clear() override;
|
||||
void clearCommandMessage();
|
||||
|
||||
/**
|
||||
* Extract message ID, which is the first byte of the command ID for the
|
||||
|
@ -94,7 +94,8 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object, bool setTaskIF) {
|
||||
if(setTaskIF) {
|
||||
newObject->setTaskIF(this);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
ReturnValue_t result = newObject->initializeAfterTaskCreation();
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t PeriodicTask::getPeriodMs() const {
|
||||
|
@ -92,7 +92,7 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
|
||||
void FixedTimeslotTask::taskFunctionality() {
|
||||
// A local iterator for the Polling Sequence Table is created to
|
||||
// find the start time for the first entry.
|
||||
SlotListIter slotListIter = pollingSeqTable.current;
|
||||
FixedSlotSequence::SlotListIter slotListIter = pollingSeqTable.current;
|
||||
// Get start time for first entry.
|
||||
chron_ms interval(slotListIter->pollingTimeMs);
|
||||
auto currentStartTime {
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
private:
|
||||
//! External instantiation is forbidden.
|
||||
QueueMapManager();
|
||||
std::atomic<uint32_t> queueCounter = MessageQueueIF::NO_QUEUE + 1;
|
||||
std::atomic<uint32_t> queueCounter = 1;
|
||||
MutexIF* mapLock;
|
||||
QueueMap queueMap;
|
||||
static QueueMapManager* mqManagerInstance;
|
||||
|
@ -36,7 +36,9 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object,
|
||||
if(setTaskIF) {
|
||||
newObject->setTaskIF(this);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
||||
ReturnValue_t result = newObject->initializeAfterTaskCreation();
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) {
|
||||
|
@ -78,7 +78,8 @@ ReturnValue_t MultiObjectTask::addComponent(object_id_t object) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
objectList.push_back(newObject);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
ReturnValue_t result = newObject->initializeAfterTaskCreation();
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t MultiObjectTask::getPeriodMs() const {
|
||||
|
@ -1,15 +1,5 @@
|
||||
/**
|
||||
* @file ExecutableObjectIF.h
|
||||
*
|
||||
* @brief This file contains the definition for the ExecutableObjectIF interface.
|
||||
*
|
||||
* @author Bastian Baetz
|
||||
*
|
||||
* @date 12.03.2012
|
||||
*/
|
||||
|
||||
#ifndef EXECUTABLEOBJECTIF_H_
|
||||
#define EXECUTABLEOBJECTIF_H_
|
||||
#ifndef FRAMEWORK_TASKS_EXECUTABLEOBJECTIF_H_
|
||||
#define FRAMEWORK_TASKS_EXECUTABLEOBJECTIF_H_
|
||||
|
||||
class PeriodicTaskIF;
|
||||
|
||||
@ -20,6 +10,7 @@ class PeriodicTaskIF;
|
||||
* @brief The interface provides a method to execute objects within a task.
|
||||
* @details The performOperation method, that is required by the interface is
|
||||
* executed cyclically within a task context.
|
||||
* @author Bastian Baetz
|
||||
*/
|
||||
class ExecutableObjectIF {
|
||||
public:
|
||||
@ -43,9 +34,20 @@ public:
|
||||
* a reference to the executing task
|
||||
* @param task_ Pointer to the taskIF of this task
|
||||
*/
|
||||
virtual void setTaskIF(PeriodicTaskIF* task_) {
|
||||
virtual void setTaskIF(PeriodicTaskIF* task_) {};
|
||||
|
||||
/**
|
||||
* This function should be called after the object was assigned to a
|
||||
* specific task.
|
||||
*
|
||||
* Example: Can be used to get task execution frequency.
|
||||
* The task is created after initialize() and the object ctors have been
|
||||
* called so the execution frequency can't be cached in initialize()
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t initializeAfterTaskCreation() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* EXECUTABLEOBJECTIF_H_ */
|
||||
#endif /* FRAMEWORK_TASKS_EXECUTABLEOBJECTIF_H_ */
|
||||
|
@ -9,6 +9,7 @@ FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,
|
||||
if(executingTask != nullptr) {
|
||||
handler->setTaskIF(executingTask);
|
||||
}
|
||||
handler->initializeAfterTaskCreation();
|
||||
}
|
||||
|
||||
FixedSequenceSlot::~FixedSequenceSlot() {}
|
||||
|
@ -57,7 +57,9 @@ ReturnValue_t CommandingServiceBase::initialize() {
|
||||
PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>(
|
||||
packetSource);
|
||||
if (packetForwarding == nullptr or distributor == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
sif::error << "CommandingServiceBase::intialize: Packet source or "
|
||||
"packet destination invalid!" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
distributor->registerService(this);
|
||||
@ -68,7 +70,9 @@ ReturnValue_t CommandingServiceBase::initialize() {
|
||||
TCStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
|
||||
|
||||
if (IPCStore == nullptr or TCStore == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
sif::error << "CommandingServiceBase::intialize: IPC store or TC store "
|
||||
"not initialized yet!" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
@ -109,8 +113,8 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
|
||||
* command as failure parameter 1 */
|
||||
if(reply->getCommand() == CommandMessage::REPLY_REJECTED and
|
||||
result == RETURN_FAILED) {
|
||||
result = reply->getReplyRejectedReason(
|
||||
reinterpret_cast<Command_t*>(&failureParameter1));
|
||||
result = reply->getReplyRejectedReason();
|
||||
failureParameter1 = iter->command;
|
||||
}
|
||||
|
||||
switch (result) {
|
||||
@ -176,14 +180,14 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
||||
}
|
||||
else {
|
||||
if (isStep) {
|
||||
nextCommand->clear();
|
||||
nextCommand->clearCommandMessage();
|
||||
verificationReporter.sendFailureReport(
|
||||
TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags,
|
||||
iter->tcInfo.tcPacketId,
|
||||
iter->tcInfo.tcSequenceControl, sendResult,
|
||||
++iter->step, failureParameter1, failureParameter2);
|
||||
} else {
|
||||
nextCommand->clear();
|
||||
nextCommand->clearCommandMessage();
|
||||
verificationReporter.sendFailureReport(
|
||||
TC_VERIFY::COMPLETION_FAILURE,
|
||||
iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId,
|
||||
@ -318,7 +322,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
||||
storedPacket->getPacketSequenceControl();
|
||||
acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket);
|
||||
} else {
|
||||
command.clear();
|
||||
command.clearCommandMessage();
|
||||
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
@ -335,7 +339,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
||||
acceptPacket(TC_VERIFY::COMPLETION_SUCCESS, storedPacket);
|
||||
checkAndExecuteFifo(iter);
|
||||
} else {
|
||||
command.clear();
|
||||
command.clearCommandMessage();
|
||||
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
@ -374,7 +378,7 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) {
|
||||
|
||||
|
||||
void CommandingServiceBase::handleUnrequestedReply(CommandMessage* reply) {
|
||||
reply->clear();
|
||||
reply->clearCommandMessage();
|
||||
}
|
||||
|
||||
|
||||
|
@ -276,7 +276,6 @@ protected:
|
||||
void checkAndExecuteFifo(CommandMapIter iter);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* This method handles internal execution of a command,
|
||||
* once it has been started by @sa{startExecution()} in the request
|
||||
@ -296,10 +295,13 @@ private:
|
||||
void handleCommandQueue();
|
||||
|
||||
/**
|
||||
* @brief Handler function for request queue
|
||||
* @details
|
||||
* Sequence of request queue handling:
|
||||
* isValidSubservice -> getMessageQueueAndObject -> startExecution
|
||||
* Generates Start Success Reports TM[1,3] in subfunction @sa{startExecution()}
|
||||
* or Start Failure Report TM[1,4] by using the TC Verification Service
|
||||
* Generates a Start Success Reports TM[1,3] in subfunction
|
||||
* @sa{startExecution()} or a Start Failure Report TM[1,4] by using the
|
||||
* TC Verification Service.
|
||||
*/
|
||||
void handleRequestQueue();
|
||||
|
||||
|
@ -32,6 +32,10 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle) {
|
||||
this->taskHandle = taskHandle;
|
||||
}
|
||||
|
||||
void PusServiceBase::handleRequestQueue() {
|
||||
TmTcMessage message;
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
@ -108,3 +112,10 @@ ReturnValue_t PusServiceBase::initialize() {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PusServiceBase::initializeAfterTaskCreation() {
|
||||
// If task parameters, for example task frequency are required, this
|
||||
// function should be overriden and the system object task IF can
|
||||
// be used to get those parameters.
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -96,11 +96,20 @@ public:
|
||||
* @return @c RETURN_OK if the periodic performService was successful.
|
||||
* @c RETURN_FAILED else.
|
||||
*/
|
||||
ReturnValue_t performOperation(uint8_t opCode);
|
||||
virtual uint16_t getIdentifier();
|
||||
MessageQueueId_t getRequestQueue();
|
||||
virtual ReturnValue_t initialize();
|
||||
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
virtual uint16_t getIdentifier() override;
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
virtual void setTaskIF(PeriodicTaskIF* taskHandle) override;
|
||||
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
||||
protected:
|
||||
/**
|
||||
* @brief Handle to the underlying task
|
||||
* @details
|
||||
* Will be set by setTaskIF(), which is called on task creation.
|
||||
*/
|
||||
PeriodicTaskIF* taskHandle = nullptr;
|
||||
/**
|
||||
* The APID of this instance of the Service.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user