Some error fixed. two main problem to solve at this point: adjust the periodic reading of the data through the dh, adjust the operations of the components (error in reading the target state).

This commit is contained in:
mmode 2021-09-14 21:09:06 +02:00
parent 868a461acb
commit 04cfb85311
18 changed files with 64 additions and 51 deletions

View File

@ -150,13 +150,13 @@ void InitMission::createTasks(){
#endif #endif
//Main thread sleep //Main thread sleep
sif::debug << "Starting Tasks in 2 seconds" << std::endl; sif::debug << "Starting Tasks in 3.2 seconds" << std::endl;
TaskFactory::delayTask(2000); TaskFactory::delayTask(3200);
distributerTask->startTask(); distributerTask->startTask();
udpBridgeTask->startTask(); udpBridgeTask->startTask();
udpPollingTask->startTask(); udpPollingTask->startTask();
//serializeTask->startTask(); //serializeTask->startTask();
arduinoTask->startTask(); //arduinoTask->startTask();
controllerTask->startTask(); controllerTask->startTask();
//payloadTask->startTask(); //payloadTask->startTask();

View File

@ -17,9 +17,9 @@ ReturnValue_t pollingSequenceArduinoFunction(
uint32_t length = thisSequence->getPeriodMs(); uint32_t length = thisSequence->getPeriodMs();
thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0, 0); thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0, 0);
thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.2, 1); thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.8, 1);
thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.4, 2); thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.8, 2);
thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.6, 3); thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.8, 3);
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;

View File

@ -67,7 +67,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
this->pstStep = counter; this->pstStep = counter;
if (getComAction() == SEND_WRITE) { if (getComAction() == SEND_WRITE) {
sif::debug<<" DH_base: performOp1"<<std::endl; sif::debug<<"DH_base: performOp1"<<std::endl;
cookieInfo.state = COOKIE_UNUSED; cookieInfo.state = COOKIE_UNUSED;
readCommandQueue(); readCommandQueue();
doStateMachine(); doStateMachine();
@ -83,22 +83,22 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
switch (getComAction()) { switch (getComAction()) {
case SEND_WRITE: case SEND_WRITE:
if ((cookieInfo.state == COOKIE_UNUSED)) { if ((cookieInfo.state == COOKIE_UNUSED)) {
sif::debug<<" DH_base: performOp2"<<std::endl; sif::debug<<"DH_base: performOp2"<<std::endl;
buildInternalCommand(); buildInternalCommand();
} }
sif::debug<<" DH_base: performOp3"<<std::endl; sif::debug<<"DH_base: performOp3"<<std::endl;
doSendWrite(); doSendWrite();
break; break;
case GET_WRITE: case GET_WRITE:
sif::debug<<" DH_base: performOp4"<<std::endl; sif::debug<<"DH_base: performOp4"<<std::endl;
doGetWrite(); doGetWrite();
break; break;
case SEND_READ: case SEND_READ:
sif::debug<<" DH_base: performOp5"<<std::endl; sif::debug<<"DH_base: performOp5"<<std::endl;
doSendRead(); doSendRead();
break; break;
case GET_READ: case GET_READ:
sif::debug<<" DH_base: performOp6"<<std::endl; sif::debug<<"DH_base: performOp6"<<std::endl;
doGetRead(); doGetRead();
cookieInfo.state = COOKIE_UNUSED; cookieInfo.state = COOKIE_UNUSED;
break; break;
@ -669,7 +669,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
handleReply(receivedData, foundId, foundLen); handleReply(receivedData, foundId, foundLen);
break; break;
case APERIODIC_REPLY: { case APERIODIC_REPLY: {
sif::debug<<" DH_base: debug1"<<std::endl; sif::debug<<"DH_base: debug1"<<std::endl;
result = interpretDeviceReply(foundId, receivedData); result = interpretDeviceReply(foundId, receivedData);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::debug<<" DH_base: debug2"<<std::endl; sif::debug<<" DH_base: debug2"<<std::endl;

View File

@ -24,6 +24,13 @@ TCS_ThermalComponent::TCS_ThermalComponent(object_id_t reportingObjectId,
ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL), ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL),
Heater(Heater), RedundantHeater(RedundantHeater), Heater(Heater), RedundantHeater(RedundantHeater),
nopParameters({ parameters.lowerNopLimit, parameters.upperNopLimit }) { nopParameters({ parameters.lowerNopLimit, parameters.upperNopLimit }) {
//Set thermal state once, then leave to operator.
/*DataSet mySet;
PoolVariable<int8_t> writableTargetState(targetStatePoolId, &mySet, PoolVariableIF::VAR_WRITE);
writableTargetState = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
mySet.commit(PoolVariableIF::VALID);*/
} }
TCS_ThermalComponent::~TCS_ThermalComponent() { TCS_ThermalComponent::~TCS_ThermalComponent() {
@ -31,6 +38,7 @@ TCS_ThermalComponent::~TCS_ThermalComponent() {
ThermalComponentIF::HeaterRequest TCS_ThermalComponent::performOperation(uint8_t opCode, bool redundancy, bool dual) { ThermalComponentIF::HeaterRequest TCS_ThermalComponent::performOperation(uint8_t opCode, bool redundancy, bool dual) {
sif::debug<<"DEBUG_COMPONENT: 1"<<std::endl;
// Heater define the Internal State // Heater define the Internal State
if (Heater != NULL) { if (Heater != NULL) {
Heater->performOperation(0); Heater->performOperation(0);
@ -40,9 +48,11 @@ ThermalComponentIF::HeaterRequest TCS_ThermalComponent::performOperation(uint8_t
RedundantHeater->performOperation(0); RedundantHeater->performOperation(0);
} }
} }
sif::debug<<"DEBUG_COMPONENT: 2"<<std::endl;
HeaterRequest request = HEATER_DONT_CARE; HeaterRequest request = HEATER_DONT_CARE;
request = CoreComponent::performOperation(0); request = CoreComponent::performOperation(0);
sif::debug<<"DEBUG_COMPONENT: 3"<<std::endl;
/*if (Heater == NULL) { /*if (Heater == NULL) {
informComponentsAboutHeaterState(false, NONE, priority, request); informComponentsAboutHeaterState(false, NONE, priority, request);
@ -56,26 +66,38 @@ ThermalComponentIF::HeaterRequest TCS_ThermalComponent::performOperation(uint8_t
//Components overwrite the module request. //Components overwrite the module request.
heating = ((request == ThermalComponentIF::HEATER_REQUEST_ON) || heating = ((request == ThermalComponentIF::HEATER_REQUEST_ON) ||
(request == ThermalComponentIF::HEATER_REQUEST_EMERGENCY_ON)); (request == ThermalComponentIF::HEATER_REQUEST_EMERGENCY_ON));
sif::debug<<"DEBUG_COMPONENT: 4"<<std::endl;
} }
// strategy NOT-PASSIVE as default // strategy NOT-PASSIVE as default
if (heating) { if (heating) {
ReturnValue_t result = Heater->set(); ReturnValue_t result = Heater->set();
if (redundancy){ if (redundancy){
if (result != HasReturnvaluesIF::RETURN_OK || dual) { if (result != HasReturnvaluesIF::RETURN_OK || dual) {
sif::debug<<"DEBUG_COMPONENT: 5"<<std::endl;
RedundantHeater->set(); RedundantHeater->set();
sif::debug<<"DEBUG_COMPONENT: 6"<<std::endl;
} else { } else {
sif::debug<<"DEBUG_COMPONENT: 7"<<std::endl;
RedundantHeater->clear(false); RedundantHeater->clear(false);
} sif::debug<<"DEBUG_COMPONENT: 8"<<std::endl;
}
else {
if (result != HasReturnvaluesIF::RETURN_OK)
Heater->clear(false);
} }
} else { } else {
sif::debug<<"DEBUG_COMPONENT: 9"<<std::endl;
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug<<"DEBUG_COMPONENT: 10"<<std::endl;
Heater->clear(false);
sif::debug<<"DEBUG_COMPONENT: 11"<<std::endl;
}
}
} else {
sif::debug<<"DEBUG_COMPONENT: 12"<<std::endl;
Heater->clear(false); Heater->clear(false);
RedundantHeater->clear(false); RedundantHeater->clear(false);
sif::debug<<"DEBUG_COMPONENT: 13"<<std::endl;
} }
sif::debug<<"DEBUG_COMPONENT: 14"<<std::endl;
/*if (strategy == PASSIVE) { /*if (strategy == PASSIVE) {
informComponentsAboutHeaterState(false, NONE, priority, request); informComponentsAboutHeaterState(false, NONE, priority, request);

View File

@ -44,11 +44,9 @@ protected:
TCS_Heater *Heater; TCS_Heater *Heater;
TCS_Heater *RedundantHeater; TCS_Heater *RedundantHeater;
State getState(float temperature, CoreComponent::Parameters parameters, State getState(float temperature, CoreComponent::Parameters parameters, int8_t targetState);
int8_t targetState);
virtual void checkLimits(State state); virtual void checkLimits(State state);
virtual HeaterRequest getHeaterRequest(int8_t targetState, float temperature, virtual HeaterRequest getHeaterRequest(int8_t targetState, float temperature, CoreComponent::Parameters parameters);
CoreComponent::Parameters parameters);
State getIgnoredState(int8_t state); State getIgnoredState(int8_t state);
enum Informee { enum Informee {

View File

@ -10,17 +10,17 @@
ThermalController::ThermalController(object_id_t objectId, object_id_t powerSwitcher, size_t commandQueueDepth): ThermalController::ThermalController(object_id_t objectId, object_id_t powerSwitcher, size_t commandQueueDepth):
ControllerBase(objectId, 0, commandQueueDepth), ControllerBase(objectId, 0, commandQueueDepth),
powerSwitcherId(powerSwitcher), TempValueVec(datapool::Temperature_value, &TCSData, PoolVariableIF::VAR_READ), powerSwitcherId(powerSwitcher), TempValueVec(datapool::Temperature_value, &SensorData, PoolVariableIF::VAR_READ),
TEMPERATURE_SENSOR_CH1(objects::TCS_SENSOR_CH1, &TempValueVec[0], &TempValueVec, 0, TEMPERATURE_SENSOR_CONFIG, datapool::TEMP_SENSOR_CH1, &TCSData, NULL), TEMPERATURE_SENSOR_CH1(objects::TCS_SENSOR_CH1, &TempValueVec[0], &TempValueVec, 0, TEMPERATURE_SENSOR_CONFIG, datapool::TEMP_SENSOR_CH1, &SensorData, NULL),
TEMPERATURE_SENSOR_CH2(objects::TCS_SENSOR_CH2, &TempValueVec[1], &TempValueVec, 1, TEMPERATURE_SENSOR_CONFIG, datapool::TEMP_SENSOR_CH2, &TCSData, NULL), TEMPERATURE_SENSOR_CH2(objects::TCS_SENSOR_CH2, &TempValueVec[1], &TempValueVec, 1, TEMPERATURE_SENSOR_CONFIG, datapool::TEMP_SENSOR_CH2, &SensorData, NULL),
HEATER_1(objects::TCS_HEATER_1, objects::TCS_SWITCH_1), HEATER_1(objects::TCS_HEATER_1, objects::TCS_SWITCH_1),
REDUNDANT_HEATER_1(objects::TCS_REDUNDANT_HEATER_1, objects::TCS_SWITCH_1R), REDUNDANT_HEATER_1(objects::TCS_REDUNDANT_HEATER_1, objects::TCS_SWITCH_1R),
HEATER_2(objects::TCS_HEATER_2, objects::TCS_SWITCH_2), HEATER_2(objects::TCS_HEATER_2, objects::TCS_SWITCH_2),
REDUNDANT_HEATER_2(objects::TCS_REDUNDANT_HEATER_2, objects::TCS_SWITCH_2R), REDUNDANT_HEATER_2(objects::TCS_REDUNDANT_HEATER_2, objects::TCS_SWITCH_2R),
TEMPERATURE_COMPONENT_1(objects::TCS_COMPONENT_1, COMPONENT_DOMAIN_ID, datapool::TEMP_SENSOR_CH1, datapool::TargetState_COMPONENT_1, datapool::CurrentState_COMPONENT_1, TEMPERATURE_COMPONENT_1(objects::TCS_COMPONENT_1, COMPONENT_DOMAIN_ID, datapool::TEMP_SENSOR_CH1, datapool::TargetState_COMPONENT_1, datapool::CurrentState_COMPONENT_1,
datapool::HeaterRequest_COMPONENT_1, &TCSData, &TEMPERATURE_SENSOR_CH1, NULL, NULL, &HEATER_1, &REDUNDANT_HEATER_1, NULL, COMPONENT1_CONFIG, ThermalComponentIF::SAFE), datapool::HeaterRequest_COMPONENT_1, &ComponentData, &TEMPERATURE_SENSOR_CH1, NULL, NULL, &HEATER_1, &REDUNDANT_HEATER_1, NULL, COMPONENT1_CONFIG, ThermalComponentIF::SAFE),
TEMPERATURE_COMPONENT_2(objects::TCS_COMPONENT_2, COMPONENT_DOMAIN_ID + 1, datapool::TEMP_SENSOR_CH2, datapool::TargetState_COMPONENT_2, datapool::CurrentState_COMPONENT_2, TEMPERATURE_COMPONENT_2(objects::TCS_COMPONENT_2, COMPONENT_DOMAIN_ID + 1, datapool::TEMP_SENSOR_CH2, datapool::TargetState_COMPONENT_2, datapool::CurrentState_COMPONENT_2,
datapool::HeaterRequest_COMPONENT_2, &TCSData, &TEMPERATURE_SENSOR_CH2, NULL, NULL, &HEATER_2, &REDUNDANT_HEATER_2, NULL, COMPONENT2_CONFIG, ThermalComponentIF::SAFE) datapool::HeaterRequest_COMPONENT_2, &ComponentData, &TEMPERATURE_SENSOR_CH2, NULL, NULL, &HEATER_2, &REDUNDANT_HEATER_2, NULL, COMPONENT2_CONFIG, ThermalComponentIF::SAFE)
{ {
sensors.push_back(TEMPERATURE_SENSOR_CH1); sensors.push_back(TEMPERATURE_SENSOR_CH1);
sensors.push_back(TEMPERATURE_SENSOR_CH2); sensors.push_back(TEMPERATURE_SENSOR_CH2);
@ -88,38 +88,36 @@ ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) {
ReturnValue_t ThermalController::performOperation(uint8_t opCode) { ReturnValue_t ThermalController::performOperation(uint8_t opCode) {
sif::debug<<"\nDEBUG_TCS: Start of controller operations"<<std::endl; sif::debug<<"DEBUG_TCS: Start of controller operations"<<std::endl;
std::cout << "\nDEBUG_TCS: Start of controller operations" << std::endl;
for (std::list<ArduinoTCSTemperatureSensor>::iterator iter = sensors.begin(); iter != sensors.end(); iter++) { for (std::list<ArduinoTCSTemperatureSensor>::iterator iter = sensors.begin(); iter != sensors.end(); iter++) {
iter->performHealthOp(); iter->performHealthOp();
} }
sif::debug<<"\nDEBUG_TCS: Health ops"<<std::endl; sif::debug<<"DEBUG_TCS: Health ops"<<std::endl;
ControllerBase::performOperation(0); ControllerBase::performOperation(0);
sif::debug<<"\nDEBUG_TCS: Controller ops"<<std::endl; sif::debug<<"DEBUG_TCS: Controller ops"<<std::endl;
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
TCSData.read(); SensorData.read();
for (std::list<ArduinoTCSTemperatureSensor>::iterator iter = sensors.begin(); iter != sensors.end(); iter++) { for (std::list<ArduinoTCSTemperatureSensor>::iterator iter = sensors.begin(); iter != sensors.end(); iter++) {
iter->performOperation(0); iter->performOperation(0);
} }
TCSData.commit(); SensorData.commit();
sif::debug<<"\nDEBUG_TCS: Sensor ops"<<std::endl; sif::debug<<"DEBUG_TCS: Sensor ops"<<std::endl;
TCSData.read(); // ?check the read, separate dataset ComponentData.read();
//calculateStrategy(true, true); //calculateStrategy(true, true);
ThermalComponentIF::HeaterRequest request; ThermalComponentIF::HeaterRequest request;
for (std::list<TCS_ThermalComponent>::iterator iter = components.begin(); iter != components.end(); iter++) { for (std::list<TCS_ThermalComponent>::iterator iter = components.begin(); iter != components.end(); iter++) {
request = iter->performOperation(0, true, false); // request returnvalue request = iter->performOperation(0, true, false); // request returnvalue to check, overridden
//request = iter->performOperation(0, ThermalComponentIF::SAFE, true, false); //request = iter->performOperation(0, ThermalComponentIF::SAFE, true, false);
} }
TCSData.commit(); ComponentData.commit();
sif::debug<<"\nDEBUG_TCS: Component ops"<<std::endl; sif::debug<<"DEBUG_TCS: Component ops"<<std::endl;
std::cout << "\nDEBUG_TCS: End of controller operations" << std::endl;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -50,7 +50,8 @@ private:
object_id_t powerSwitcherId; object_id_t powerSwitcherId;
// definition of dataset // definition of dataset
DataSet TCSData; DataSet SensorData;
DataSet ComponentData;
// definition of dataset variables from datapool // definition of dataset variables from datapool
PoolVector <float, 36> TempValueVec; PoolVector <float, 36> TempValueVec;

View File

@ -10,7 +10,6 @@
#include <mission/DeviceHandler/ArduinoCookie.h> #include <mission/DeviceHandler/ArduinoCookie.h>
#include <fsfw/serialize/SerializeAdapter.h> #include <fsfw/serialize/SerializeAdapter.h>
//#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tmtcservices/CommandingServiceBase.h> #include <fsfw/tmtcservices/CommandingServiceBase.h>
#include <fsfw/tmtcpacket/pus/TmPacketStored.h> #include <fsfw/tmtcpacket/pus/TmPacketStored.h>
@ -200,7 +199,7 @@ ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie,
buffer = &buf_ptr;*/ buffer = &buf_ptr;*/
*buffer = read_buf; *buffer = read_buf;
close(Cookie->Serial_port_number); //close(Cookie->Serial_port_number);
return RETURN_OK; return RETURN_OK;
} }

View File

@ -34,10 +34,6 @@ public:
ArduinoComIF(object_id_t objectId); ArduinoComIF(object_id_t objectId);
virtual ~ArduinoComIF(); virtual ~ArduinoComIF();
/**
* DeviceCommunicationIF overrides
* (see DeviceCommunicationIF documentation)
*/
ReturnValue_t initializeInterface(CookieIF * cookie) override; ReturnValue_t initializeInterface(CookieIF * cookie) override;
ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData, ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
size_t sendLen) override; size_t sendLen) override;
@ -49,24 +45,22 @@ public:
private: private:
// DELETE
/** /**
* Send TM packet which contains received data as TM[17,130]. * Send TM packet which contains received data as TM[17,130].
* Wiretapping will do the same. * Wiretapping will do the same.
* @param data * @param data
* @param len * @param len
*/ */
void sendTmPacket(const uint8_t *data,uint32_t len); //void sendTmPacket(const uint8_t *data,uint32_t len);
AcceptsTelemetryIF* funnel = nullptr; /*AcceptsTelemetryIF* funnel = nullptr;
MessageQueueIF* tmQueue = nullptr; MessageQueueIF* tmQueue = nullptr;
size_t replyMaxLen = 0; size_t replyMaxLen = 0;
using ReplyBuffer = std::vector<uint8_t>; using ReplyBuffer = std::vector<uint8_t>;
std::map<address_t, ReplyBuffer> replyMap; std::map<address_t, ReplyBuffer> replyMap;
uint8_t dummyReplyCounter = 0; uint8_t dummyReplyCounter = 0;
uint16_t packetSubCounter = 0;*/
uint16_t packetSubCounter = 0;
}; };

View File

@ -68,5 +68,6 @@ void ObjectFactory::produceGenericObjects() {
new TestDevice(objects::TEST_DEVICE_HANDLER, objects::TEST_ECHO_COM_IF, new TestDevice(objects::TEST_DEVICE_HANDLER, objects::TEST_ECHO_COM_IF,
testCookie, true); testCookie, true);
#endif*/ #endif*/
} }