/* HELP */ #include #include #include #include #include ThermalController::ThermalController(object_id_t objectId, object_id_t powerSwitcher, size_t commandQueueDepth): ControllerBase(objectId, NULL, commandQueueDepth), mode(MODE_ON), submode(HEATER_REDUNDANCY), powerSwitcherId(powerSwitcher), TempValueVec(datapool::Temperature_value, &TCSData, 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_CH2(objects::TCS_SENSOR_CH2, &TempValueVec[1], &TempValueVec, 1, TEMPERATURE_SENSOR_CONFIG, datapool::TEMP_SENSOR_CH2, &TCSData, NULL), HEATER_1(objects::TCS_HEATER_1, objects::TCS_SWITCH_1), REDUNDANT_HEATER_1(objects::TCS_REDUNDANT_HEATER_1, objects::TCS_SWITCH_1R), HEATER_2(objects::TCS_HEATER_2, objects::TCS_SWITCH_2), 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, datapool::HeaterRequest_COMPONENT_1, &TCSData, &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, datapool::HeaterRequest_COMPONENT_2, &TCSData, &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_CH2); heaters.push_back(HEATER_1); heaters.push_back(HEATER_2); redundant_heaters.push_back(REDUNDANT_HEATER_1); redundant_heaters.push_back(REDUNDANT_HEATER_2); components.push_back(TEMPERATURE_COMPONENT_1); components.push_back(TEMPERATURE_COMPONENT_2); } ThermalController::~ThermalController() { } ReturnValue_t ThermalController::initialize() { sif::debug<<"\nDEBUG_TCS: Controller starts initialization. "<get( powerSwitcherId); if (powerSwitcher == NULL) { return HasReturnvaluesIF::RETURN_FAILED; }*/ /* ************************ */ sif::debug<<"\nDEBUG_TCS: Controller ends initialization. "<::iterator iter = sensors.begin(); iter != sensors.end(); iter++) { iter->performHealthOp(); } ControllerBase::performOperation(0); if (mode == MODE_OFF) { return HasReturnvaluesIF::RETURN_OK; } TCSData.read(); for (std::list::iterator iter = sensors.begin(); iter != sensors.end(); iter++) { iter->performOperation(0); } TCSData.commit(); TCSData.read(); //calculateStrategy(true, true); ThermalComponentIF::HeaterRequest request; for (std::list::iterator iter = components.begin(); iter != components.end(); iter++) { request = iter->performOperation(0, true, false); //request = iter->performOperation(0, ThermalComponentIF::SAFE, true, false); } TCSData.commit(); return HasReturnvaluesIF::RETURN_OK; } /*MessageQueueId_t ThermalController::getCommandQueue() const { return commandQueue.getId(); }*/ void ThermalController::performControlOperation() { //Done by overwritten performOperation! } ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { msToReachTheMode = 0; switch (mode) { case MODE_OFF: startTransition(mode, NULL); break; case MODE_ON: if (submode == NO_REDUNDANCY) { return HasReturnvaluesIF::RETURN_OK; } else if (submode == HEATER_REDUNDANCY) { return HasReturnvaluesIF::RETURN_OK; } break; } return HasReturnvaluesIF::RETURN_FAILED; } void ThermalController::startTransition(Mode_t mode, Submode_t submode){ switch (mode) { case MODE_OFF: mode = MODE_ON; break; case MODE_ON: mode = MODE_OFF; break; case NULL: break; default: mode = MODE_OFF; break; } switch (submode) { case NO_REDUNDANCY: submode = HEATER_REDUNDANCY; break; case HEATER_REDUNDANCY: submode = NO_REDUNDANCY; break; case NULL: break; default: submode = NO_REDUNDANCY; break; } } //******************************************************************************************************************************************************************** /*void ThermalController::calculateStrategy(bool announce, bool redundancy) { * * NOT NEEDED NOW * bool changed = false; if (mode == MODE_ON) { if (submode == NO_REDUNDANCY) { if (redundancy){ startTransition(NULL, submode); changed = true; strategy = ThermalModuleIF::ACTIVE_DUAL; break; } else{ changed = true; strategy = ThermalModuleIF::ACTIVE_SINGLE; break; } } else if (submode == HEATER_REDUNDANCY){ if (!redundancy){ startTransition(NULL, submode); changed = true; strategy = ThermalModuleIF::ACTIVE_SINGLE; break; } else{ changed = true; strategy = ThermalModuleIF::ACTIVE_DUAL; break; } } } else { startTransition(mode, NULL); } }*/ /*ReturnValue_t ThermalController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size) { switch (actionId) { case SET_PREHEATING_COMPONENT: { if (size != 1 + sizeof(object_id_t)) { return INVALID_PARAMETERS; } object_id_t objectId; int32_t readSize = size; const uint8_t *pointer = data; SerializeAdapter::deSerialize(&objectId, &pointer, &readSize, true); ThermalComponentIF *component = findComponentByObjectId(objectId); if (component != NULL) { if (component->setTargetState(*pointer) == RETURN_OK) { return EXECUTION_FINISHED; } else { return NOT_ALLOWED; } } } return INVALID_PARAMETERS; case SET_PREHEATING_MODULE: if (size != 2) { return INVALID_PARAMETERS; } switch (*data) { case 0: coreModule.setHeating(data[1] != 0); break; case 1: serviceModule.setHeating(data[1] != 0); break; case 2: payloadModule.setHeating(data[1] != 0); break; default: return INVALID_PARAMETERS; } return EXECUTION_FINISHED; default: return INVALID_ACTION_ID; } }*/ /*ThermalComponentIF* ThermalController::findComponentByObjectId(object_id_t id) { //This method was generated with a regular expression from the ctor code. //More space, but faster than iterating a linked list to find the right id. switch (id) { case objects::TCS_COMPONENT_1: return &TEMPERATURE_COMPONENT_1; case objects::TCS_COMPONENT_2: return &TEMPERATURE_COMPONENT_2; default: return NULL; } }*/ /*void ThermalController::announceMode(bool recursive) { triggerEvent(TCS_CONTROL_STRATEGY, strategy, 0); ControllerBase::announceMode(recursive); }*/