mission and config folders added , make file is added
This commit is contained in:
67
mission/core/GenericFactory.cpp
Normal file
67
mission/core/GenericFactory.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
#include "GenericFactory.h"
|
||||
|
||||
#include <OBSWConfig.h>
|
||||
#include <datapool/dataPoolInit.h>
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <objects/systemObjectList.h>
|
||||
#include <tmtc/apid.h>
|
||||
#include <tmtc/pusIds.h>
|
||||
|
||||
#include <fsfw/events/EventManager.h>
|
||||
#include <fsfw/health/HealthTable.h>
|
||||
#include <fsfw/internalError/InternalErrorReporter.h>
|
||||
#include <fsfw/pus/CService200ModeCommanding.h>
|
||||
#include <fsfw/pus/Service17Test.h>
|
||||
#include <fsfw/pus/Service1TelecommandVerification.h>
|
||||
#include <fsfw/pus/Service2DeviceAccess.h>
|
||||
#include <fsfw/pus/Service5EventReporting.h>
|
||||
#include <fsfw/pus/Service8FunctionManagement.h>
|
||||
#include <fsfw/pus/Service9TimeManagement.h>
|
||||
#include <fsfw/tcdistribution/CCSDSDistributor.h>
|
||||
#include <fsfw/tcdistribution/PUSDistributor.h>
|
||||
#include <fsfw/timemanager/TimeStamper.h>
|
||||
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
//TODO: include your headers
|
||||
|
||||
void ObjectFactory::produceGenericObjects() {
|
||||
/* Framework objects */
|
||||
new EventManager(objects::EVENT_MANAGER);
|
||||
new HealthTable(objects::HEALTH_TABLE);
|
||||
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER, 0, 0, 0);
|
||||
new TimeStamper(objects::TIME_STAMPER);
|
||||
new CCSDSDistributor(apid::APID, objects::CCSDS_DISTRIBUTOR);
|
||||
new PUSDistributor(apid::APID, objects::PUS_DISTRIBUTOR,
|
||||
objects::CCSDS_DISTRIBUTOR);
|
||||
new TmFunnel(objects::TM_FUNNEL);
|
||||
|
||||
/* PUS stack */
|
||||
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION,
|
||||
apid::APID, pus::PUS_SERVICE_1, objects::TM_FUNNEL);
|
||||
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS,
|
||||
apid::APID, pus::PUS_SERVICE_2, 3, 10);
|
||||
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING,
|
||||
apid::APID, pus::PUS_SERVICE_5, 50);
|
||||
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT,
|
||||
apid::APID, pus::PUS_SERVICE_8, 3, 10);
|
||||
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::APID,
|
||||
pus::PUS_SERVICE_9);
|
||||
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::APID,
|
||||
pus::PUS_SERVICE_17);
|
||||
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT,
|
||||
apid::APID, pus::PUS_SERVICE_200);
|
||||
|
||||
|
||||
/* Demo objects */
|
||||
|
||||
CookieIF* arduinoCookie = new ARDUINOCookie();
|
||||
//new handler and commIF
|
||||
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
CookieIF* testCookie = new TestCookie(0);
|
||||
new TestEchoComIF(objects::TEST_ECHO_COM_IF);
|
||||
new TestDevice(objects::TEST_DEVICE_HANDLER, objects::TEST_ECHO_COM_IF,
|
||||
testCookie, true);
|
||||
#endif
|
||||
}
|
||||
|
16
mission/core/GenericFactory.h
Normal file
16
mission/core/GenericFactory.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef MISSION_CORE_GENERICFACTORY_H_
|
||||
#define MISSION_CORE_GENERICFACTORY_H_
|
||||
|
||||
|
||||
namespace ObjectFactory {
|
||||
|
||||
/**
|
||||
* @brief Produce hardware independant objects. Called by bsp specific
|
||||
* object factory.
|
||||
*/
|
||||
void produceGenericObjects();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* MISSION_CORE_GENERICFACTORY_H_ */
|
16
mission/mission.mk
Normal file
16
mission/mission.mk
Normal file
@ -0,0 +1,16 @@
|
||||
# add main and others
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp)
|
||||
CSRC += $(wildcard $(CURRENTPATH)/*.c)
|
||||
|
||||
CSRC += $(wildcard $(CURRENTPATH)/core/*.c)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/core/*.cpp)
|
||||
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/devices/*.cpp)
|
||||
CSRC += $(wildcard $(CURRENTPATH)/devices/*.c)
|
||||
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/devices/Visible_Instrument/*.cpp)
|
||||
CSRC += $(wildcard $(CURRENTPATH)/devices/Visible_Instrument/*.c)
|
||||
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/utility/*.cpp)
|
||||
CSRC += $(wildcard $(CURRENTPATH)/utility/*.c)
|
||||
|
20
mission/utility/PusPacketCreator.cpp
Normal file
20
mission/utility/PusPacketCreator.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <fsfw/tmtcpacket/pus/TcPacketBase.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketBase.h>
|
||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <mission/utility/PusPacketCreator.h>
|
||||
#include <iomanip>
|
||||
|
||||
void PusPacketCreator::createPusPacketAndPrint() {
|
||||
// TODO: use TC packet stored here instead..
|
||||
|
||||
// uint8_t packetStore[TcPacketBase::TC_PACKET_MIN_SIZE];
|
||||
// TcPacketBase packet(packetStore);
|
||||
// packet.initSpacePacketHeader(true, true, 0x73, 25);
|
||||
// packet.initializeTcPacket(0x73, 25, 0, 17, 1);
|
||||
// packet.setPacketDataLength(sizeof(PUSTcDataFieldHeader)
|
||||
// + TcPacketBase::CRC_SIZE-1);
|
||||
// packet.setErrorControl();
|
||||
// sif::info << "PUS packet created: " << std::endl;
|
||||
// arrayprinter::print(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
16
mission/utility/PusPacketCreator.h
Normal file
16
mission/utility/PusPacketCreator.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* PusPacketCreator.h
|
||||
*
|
||||
* Created on: 21.03.2019
|
||||
* Author: gaisser
|
||||
*/
|
||||
|
||||
#ifndef MISSION_UTILITY_PUSPACKETCREATOR_H_
|
||||
#define MISSION_UTILITY_PUSPACKETCREATOR_H_
|
||||
|
||||
class PusPacketCreator {
|
||||
public:
|
||||
static void createPusPacketAndPrint();
|
||||
};
|
||||
|
||||
#endif /* MISSION_UTILITY_PUSPACKETCREATOR_H_ */
|
115
mission/utility/TmFunnel.cpp
Normal file
115
mission/utility/TmFunnel.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketBase.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
|
||||
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
|
||||
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
|
||||
|
||||
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth):
|
||||
SystemObject(objectId), messageDepth(messageDepth) {
|
||||
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
TmFunnel::~TmFunnel() {
|
||||
}
|
||||
|
||||
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
|
||||
return tmQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
|
||||
TmTcMessage currentMessage;
|
||||
ReturnValue_t status = tmQueue->receiveMessage(¤tMessage);
|
||||
while(status == HasReturnvaluesIF::RETURN_OK)
|
||||
{
|
||||
status = handlePacket(¤tMessage);
|
||||
if(status != HasReturnvaluesIF::RETURN_OK){
|
||||
break;
|
||||
}
|
||||
status = tmQueue->receiveMessage(¤tMessage);
|
||||
}
|
||||
|
||||
if (status == MessageQueueIF::EMPTY) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) {
|
||||
uint8_t* packetData = nullptr;
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = tmPool->modifyData(message->getStorageId(),
|
||||
&packetData, &size);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
TmPacketBase packet(packetData);
|
||||
packet.setPacketSequenceCount(this->sourceSequenceCount);
|
||||
sourceSequenceCount++;
|
||||
sourceSequenceCount = sourceSequenceCount %
|
||||
SpacePacketBase::LIMIT_SEQUENCE_COUNT;
|
||||
packet.setErrorControl();
|
||||
|
||||
result = tmQueue->sendToDefault(message);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
tmPool->deleteData(message->getStorageId());
|
||||
sif::error << "TmFunnel::handlePacket: Error sending to downlink "
|
||||
"handler" << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
if(storageDestination != objects::NO_OBJECT) {
|
||||
result = storageQueue->sendToDefault(message);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
tmPool->deleteData(message->getStorageId());
|
||||
sif::error << "TmFunnel::handlePacket: Error sending to storage "
|
||||
"handler" << std::endl;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t TmFunnel::initialize() {
|
||||
|
||||
tmPool = objectManager->get<StorageManagerIF>(objects::TM_STORE);
|
||||
if(tmPool == nullptr) {
|
||||
sif::error << "TmFunnel::initialize: TM store not set."
|
||||
<< std::endl;
|
||||
sif::error << "Make sure the tm store is set up properly"
|
||||
" and implements StorageManagerIF" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
AcceptsTelemetryIF* tmTarget =
|
||||
objectManager->get<AcceptsTelemetryIF>(downlinkDestination);
|
||||
if(tmTarget == nullptr){
|
||||
sif::error << "TmFunnel::initialize: Downlink Destination not set."
|
||||
<< std::endl;
|
||||
sif::error << "Make sure the downlink destination object is set up "
|
||||
"properly and implements AcceptsTelemetryIF" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue());
|
||||
|
||||
// Storage destination is optional.
|
||||
if(storageDestination == objects::NO_OBJECT) {
|
||||
return SystemObject::initialize();
|
||||
}
|
||||
|
||||
AcceptsTelemetryIF* storageTarget =
|
||||
objectManager->get<AcceptsTelemetryIF>(storageDestination);
|
||||
if(storageTarget != nullptr) {
|
||||
storageQueue->setDefaultDestination(
|
||||
storageTarget->getReportReceptionQueue());
|
||||
}
|
||||
|
||||
return SystemObject::initialize();
|
||||
}
|
50
mission/utility/TmFunnel.h
Normal file
50
mission/utility/TmFunnel.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef MISSION_UTILITY_TMFUNNEL_H_
|
||||
#define MISSION_UTILITY_TMFUNNEL_H_
|
||||
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
|
||||
#include <fsfw/ipc/MessageQueueIF.h>
|
||||
#include <fsfw/tmtcservices/TmTcMessage.h>
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TM Recipient.
|
||||
* @details
|
||||
* Main telemetry receiver. All generated telemetry is funneled into
|
||||
* this object.
|
||||
* @ingroup utility
|
||||
* @author J. Meier
|
||||
*/
|
||||
class TmFunnel: public AcceptsTelemetryIF,
|
||||
public ExecutableObjectIF,
|
||||
public SystemObject {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
|
||||
virtual ~TmFunnel();
|
||||
|
||||
virtual MessageQueueId_t getReportReceptionQueue(
|
||||
uint8_t virtualChannel = 0) override;
|
||||
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
protected:
|
||||
static object_id_t downlinkDestination;
|
||||
static object_id_t storageDestination;
|
||||
|
||||
private:
|
||||
uint16_t sourceSequenceCount = 0;
|
||||
MessageQueueIF* tmQueue = nullptr;
|
||||
MessageQueueIF* storageQueue = nullptr;
|
||||
|
||||
StorageManagerIF* tmPool = nullptr;
|
||||
uint32_t messageDepth = 0;
|
||||
|
||||
ReturnValue_t handlePacket(TmTcMessage* message);
|
||||
};
|
||||
|
||||
#endif /* MISSION_UTILITY_TMFUNNEL_H_ */
|
Reference in New Issue
Block a user