|
|
@ -10,6 +10,7 @@ using namespace iflytop; |
|
|
|
#define ACTION_TEST_PELTIER_SET_POWER_LEVEL 1
|
|
|
|
#define ACTION_TEST_PUMP_SET_LEVEL 2
|
|
|
|
#define ACTION_TEST_FAN_SET_LEVEL 3
|
|
|
|
#define ACTION_TEST_DUMP_DC_MOTOR_STATE 4
|
|
|
|
|
|
|
|
void WaterCoolingTemperatureControlModule::initialize(int32_t id, config_t* cfg, hardwared_config_t* hardwaredconfig) { |
|
|
|
#if 0
|
|
|
@ -22,7 +23,7 @@ void WaterCoolingTemperatureControlModule::initialize(int32_t id, config_t* cfg, |
|
|
|
ZGPIO::InputGpioCfg_t ext_output[10]; |
|
|
|
#endif
|
|
|
|
m_id = id; |
|
|
|
|
|
|
|
#if 0
|
|
|
|
for (int32_t i = 0; i < ZARRAY_SIZE(hardwaredconfig->temperature_sensor); i++) { |
|
|
|
if (!hardwaredconfig->temperature_sensor[i]) break; |
|
|
|
m_temperature_sensor[i] = hardwaredconfig->temperature_sensor[i]; |
|
|
@ -42,6 +43,16 @@ void WaterCoolingTemperatureControlModule::initialize(int32_t id, config_t* cfg, |
|
|
|
m_peltier_ctrl[i] = hardwaredconfig->peltier_ctrl[i]; |
|
|
|
m_peltier_ctrl_num++; |
|
|
|
} |
|
|
|
#endif
|
|
|
|
for (int32_t i = 0; i < ZARRAY_SIZE(hardwaredconfig->temperature_sensor); i++) { |
|
|
|
if (!hardwaredconfig->temperature_sensor[i]) break; |
|
|
|
m_temperature_sensor[i] = hardwaredconfig->temperature_sensor[i]; |
|
|
|
m_n_temperature_sensor++; |
|
|
|
} |
|
|
|
|
|
|
|
m_fan_ctrl = hardwaredconfig->fan_ctrl; |
|
|
|
m_pelter_ctrl = hardwaredconfig->pelter_ctrl; |
|
|
|
m_pump_ctrl = hardwaredconfig->pump_ctrl; |
|
|
|
|
|
|
|
m_pidmodule.initialize(&cfg->pid_cfg); |
|
|
|
m_thread.init("WaterCoolingTemperatureControlModule"); |
|
|
@ -117,7 +128,12 @@ int32_t WaterCoolingTemperatureControlModule::do_action(int32_t actioncode) { |
|
|
|
return test_pump_set_level(m_com_reg.module_action_param1); |
|
|
|
} else if (actioncode == ACTION_TEST_FAN_SET_LEVEL) { |
|
|
|
return test_fan_set_level(m_com_reg.module_action_param1); |
|
|
|
} else { |
|
|
|
} else if (actioncode == ACTION_TEST_DUMP_DC_MOTOR_STATE) { |
|
|
|
m_pelter_ctrl->dumpErrorInfo(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
return err::kmodule_not_support_action; |
|
|
|
} |
|
|
|
} |
|
|
@ -180,7 +196,19 @@ void WaterCoolingTemperatureControlModule::workloop() { |
|
|
|
fan_stop(); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::checkdevice() { return 0; } |
|
|
|
#define BIT(x, n) ((x >> n) & 0x01)
|
|
|
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::checkdevice() { |
|
|
|
m_com_reg.module_errorbitflag0 = geterrorbitflag0(); |
|
|
|
if (m_com_reg.module_errorbitflag0 != 0) { |
|
|
|
ZLOGE(TAG, "checkdevice errorbitflag0:%d %d %d", //
|
|
|
|
BIT(m_com_reg.module_errorbitflag0, 0), BIT(m_com_reg.module_errorbitflag0, 1), BIT(m_com_reg.module_errorbitflag0, 2)); |
|
|
|
m_pelter_ctrl->dumpErrorInfo(); |
|
|
|
m_com_reg.module_errorcode = err::khwardware_error; |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* BASIC * |
|
|
@ -190,39 +218,44 @@ float WaterCoolingTemperatureControlModule::read_pid_temperature() { return m_te |
|
|
|
|
|
|
|
void WaterCoolingTemperatureControlModule::pump_start(int32_t pump_speed) { |
|
|
|
ZLOGI(TAG, "pump_start %d", pump_speed); |
|
|
|
m_pump->startModule(pump_speed); |
|
|
|
// m_pump->startModule(pump_speed);
|
|
|
|
m_pump_ctrl->setPumpSpeed(pump_speed); |
|
|
|
} |
|
|
|
void WaterCoolingTemperatureControlModule::pump_stop() { |
|
|
|
ZLOGI(TAG, "pump_stop"); |
|
|
|
m_pump->stopModule(); |
|
|
|
m_pump_ctrl->stop(); |
|
|
|
} |
|
|
|
|
|
|
|
void WaterCoolingTemperatureControlModule::fan_start(int32_t pump_speed) { |
|
|
|
ZLOGI(TAG, "fan_start %d", pump_speed); |
|
|
|
for (int32_t i = 0; i < m_fanNum; i++) { |
|
|
|
m_fanTable[i]->startModule(pump_speed); |
|
|
|
} |
|
|
|
m_fan_ctrl->setFanSpeed(pump_speed); |
|
|
|
// for (int32_t i = 0; i < m_fanNum; i++) {
|
|
|
|
// m_fanTable[i]->startModule(pump_speed);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
void WaterCoolingTemperatureControlModule::fan_stop() { |
|
|
|
ZLOGI(TAG, "fan_stop"); |
|
|
|
for (int32_t i = 0; i < m_fanNum; i++) { |
|
|
|
m_fanTable[i]->stopModule(); |
|
|
|
} |
|
|
|
m_fan_ctrl->stop(); |
|
|
|
// for (int32_t i = 0; i < m_fanNum; i++) {
|
|
|
|
// m_fanTable[i]->stopModule();
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
void WaterCoolingTemperatureControlModule::peltier_set_power_level(int32_t level) { |
|
|
|
ZLOGI(TAG, "peltier_set_power_level %d", level); |
|
|
|
for (int32_t i = 0; i < m_peltier_ctrl_num; i++) { |
|
|
|
m_peltier_ctrl[i]->move(level); |
|
|
|
m_peltier_ctrl[i]->enable(true); |
|
|
|
} |
|
|
|
m_pelter_ctrl->setSpeed(level); |
|
|
|
// for (int32_t i = 0; i < m_peltier_ctrl_num; i++) {
|
|
|
|
// m_peltier_ctrl[i]->move(level);
|
|
|
|
// m_peltier_ctrl[i]->enable(true);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
void WaterCoolingTemperatureControlModule::peltier_stop() { |
|
|
|
ZLOGI(TAG, "peltier_stop"); |
|
|
|
for (int32_t i = 0; i < m_peltier_ctrl_num; i++) { |
|
|
|
m_peltier_ctrl[i]->move(0); |
|
|
|
m_peltier_ctrl[i]->enable(false); |
|
|
|
} |
|
|
|
m_pelter_ctrl->stop(); |
|
|
|
// for (int32_t i = 0; i < m_peltier_ctrl_num; i++) {
|
|
|
|
// m_peltier_ctrl[i]->move(0);
|
|
|
|
// m_peltier_ctrl[i]->enable(false);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::getworkstate() { |
|
|
@ -240,21 +273,20 @@ int32_t WaterCoolingTemperatureControlModule::getworkstate() { |
|
|
|
int32_t WaterCoolingTemperatureControlModule::geterrorbitflag0() { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* |
|
|
|
* bit 0->3 fan0,fan1,fan2,fan3, |
|
|
|
* bit 4->4 pump0, |
|
|
|
* bit 8->9 peltier0_controler,peltier1_controler |
|
|
|
*/ |
|
|
|
int32_t errorbitflag = 0; |
|
|
|
if (m_fanTable[0]) errorbitflag |= m_fanTable[0]->isError() << 0; |
|
|
|
if (m_fanTable[1]) errorbitflag |= m_fanTable[1]->isError() << 1; |
|
|
|
if (m_fanTable[2]) errorbitflag |= m_fanTable[2]->isError() << 2; |
|
|
|
if (m_fanTable[3]) errorbitflag |= m_fanTable[3]->isError() << 3; |
|
|
|
errorbitflag |= m_fan_ctrl->isError() << 0; |
|
|
|
errorbitflag |= m_pump_ctrl->isError() << 1; |
|
|
|
errorbitflag |= m_pelter_ctrl->isError() << 2; |
|
|
|
|
|
|
|
// if (m_fanTable[1]) errorbitflag |= m_fanTable[1]->isError() << 1;
|
|
|
|
// if (m_fanTable[2]) errorbitflag |= m_fanTable[2]->isError() << 2;
|
|
|
|
// if (m_fanTable[3]) errorbitflag |= m_fanTable[3]->isError() << 3;
|
|
|
|
|
|
|
|
if (m_pump) errorbitflag |= m_pump->isError() << 4; |
|
|
|
// if (m_pump) errorbitflag |= m_pump->isError() << 4;
|
|
|
|
|
|
|
|
if (m_peltier_ctrl[0]) errorbitflag |= m_peltier_ctrl[0]->isFault() << 8; |
|
|
|
if (m_peltier_ctrl[1]) errorbitflag |= m_peltier_ctrl[1]->isFault() << 9; |
|
|
|
// if (m_peltier_ctrl[0]) errorbitflag |= m_peltier_ctrl[0]->isFault() << 8;
|
|
|
|
// if (m_peltier_ctrl[1]) errorbitflag |= m_peltier_ctrl[1]->isFault() << 9;
|
|
|
|
return errorbitflag; |
|
|
|
} |
|
|
|
|
|
|
|