|
@ -6,14 +6,6 @@ |
|
|
using namespace iflytop; |
|
|
using namespace iflytop; |
|
|
|
|
|
|
|
|
#define TAG "WCTCM"
|
|
|
#define TAG "WCTCM"
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
#define ACTION_TEST_ENABLE_LOG 5
|
|
|
|
|
|
#define ACTION_TEST_DISABLE_LOG 6
|
|
|
|
|
|
|
|
|
|
|
|
static int32_t prvabs(int32_t v) { |
|
|
static int32_t prvabs(int32_t v) { |
|
|
if (v < 0) { |
|
|
if (v < 0) { |
|
|
return -v; |
|
|
return -v; |
|
@ -52,13 +44,6 @@ int32_t WaterCoolingTemperatureControlModule::getid(int32_t* id) { |
|
|
*id = m_id; |
|
|
*id = m_id; |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
int32_t WaterCoolingTemperatureControlModule::module_clear_error() { |
|
|
|
|
|
creg.module_errorcode = 0; |
|
|
|
|
|
m_fan_ctrl->clearError(); |
|
|
|
|
|
m_pelter_ctrl->clearError(); |
|
|
|
|
|
m_pump_ctrl->clearError(); |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void WaterCoolingTemperatureControlModule::createDefaultConfig(config_t* cfg) { |
|
|
void WaterCoolingTemperatureControlModule::createDefaultConfig(config_t* cfg) { |
|
|
cfg->fanlevel = 90; |
|
|
cfg->fanlevel = 90; |
|
@ -90,10 +75,10 @@ int32_t WaterCoolingTemperatureControlModule::module_xxx_reg(int32_t param_id, b |
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_pid_nowoutput, REG_GET(m_pidmodule.get_output()), ACTION_NONE); |
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_pid_nowoutput, REG_GET(m_pidmodule.get_output()), ACTION_NONE); |
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_pid_feedbackval, REG_GET(read_pid_temperature()), ACTION_NONE); |
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_pid_feedbackval, REG_GET(read_pid_temperature()), ACTION_NONE); |
|
|
|
|
|
|
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_temp0, REG_GET(getTemperatureSensorVal(0) * 100), ACTION_NONE); |
|
|
|
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_temp1, REG_GET(getTemperatureSensorVal(1) * 100), ACTION_NONE); |
|
|
|
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_temp2, REG_GET(getTemperatureSensorVal(2) * 100), ACTION_NONE); |
|
|
|
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_temp3, REG_GET(getTemperatureSensorVal(3) * 100), ACTION_NONE); |
|
|
|
|
|
|
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_temp0, REG_GET(getTemperatureSensorVal(0) * 10 + 0.5), ACTION_NONE); |
|
|
|
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_temp1, REG_GET(getTemperatureSensorVal(1) * 10 + 0.5), ACTION_NONE); |
|
|
|
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_temp2, REG_GET(getTemperatureSensorVal(2) * 10 + 0.5), ACTION_NONE); |
|
|
|
|
|
PROCESS_REG(kreg_water_cooling_tmp_controler_temp3, REG_GET(getTemperatureSensorVal(3) * 10 + 0.5), ACTION_NONE); |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|
return err::kmodule_not_find_reg; |
|
|
return err::kmodule_not_find_reg; |
|
@ -102,11 +87,6 @@ int32_t WaterCoolingTemperatureControlModule::module_xxx_reg(int32_t param_id, b |
|
|
if (!read) module_active_cfg(); |
|
|
if (!read) module_active_cfg(); |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::module_get_status(int32_t* status) { |
|
|
|
|
|
*status = getworkstate(); |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::gettemperature_sensor_state(int32_t& state) { |
|
|
int32_t WaterCoolingTemperatureControlModule::gettemperature_sensor_state(int32_t& state) { |
|
|
for (int32_t i = 0; i < m_n_temperature_sensor; i++) { |
|
|
for (int32_t i = 0; i < m_n_temperature_sensor; i++) { |
|
|
state |= m_temperature_sensor[i]->isOnline() << i; |
|
|
state |= m_temperature_sensor[i]->isOnline() << i; |
|
@ -126,13 +106,27 @@ int32_t WaterCoolingTemperatureControlModule::module_active_cfg() { |
|
|
} |
|
|
} |
|
|
int32_t WaterCoolingTemperatureControlModule::temp_controler_start_hearting(int32_t targetTemperature) { |
|
|
int32_t WaterCoolingTemperatureControlModule::temp_controler_start_hearting(int32_t targetTemperature) { |
|
|
m_thread.stop(); |
|
|
m_thread.stop(); |
|
|
module_clear_error(); |
|
|
|
|
|
ZLOGI(TAG, "module_start"); |
|
|
|
|
|
|
|
|
if (creg.m_module_status == 2) { |
|
|
|
|
|
ZLOGE(TAG, "module is in error state, can not start"); |
|
|
|
|
|
return creg.module_errorcode; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ZLOGI(TAG, "temp_controler_start_hearting %d", targetTemperature); |
|
|
|
|
|
m_target_temperature = targetTemperature * 10; |
|
|
|
|
|
creg.m_module_status = 1; |
|
|
|
|
|
|
|
|
|
|
|
m_fan_ctrl->clearError(); |
|
|
|
|
|
m_pelter_ctrl->clearError(); |
|
|
|
|
|
m_pump_ctrl->clearError(); |
|
|
|
|
|
|
|
|
|
|
|
module_active_cfg(); |
|
|
|
|
|
|
|
|
m_thread.start([this]() { workloop(); }); |
|
|
m_thread.start([this]() { workloop(); }); |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
int32_t WaterCoolingTemperatureControlModule::temp_controler_stop_hearting() { |
|
|
int32_t WaterCoolingTemperatureControlModule::temp_controler_stop_hearting() { |
|
|
m_thread.stop(); |
|
|
m_thread.stop(); |
|
|
|
|
|
creg.m_module_status = 0; |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
int32_t WaterCoolingTemperatureControlModule::module_stop() { return temp_controler_stop_hearting(); } |
|
|
int32_t WaterCoolingTemperatureControlModule::module_stop() { return temp_controler_stop_hearting(); } |
|
@ -192,51 +186,28 @@ void WaterCoolingTemperatureControlModule::workloop() { |
|
|
|
|
|
|
|
|
#define BIT(x, n) ((x >> n) & 0x01)
|
|
|
#define BIT(x, n) ((x >> n) & 0x01)
|
|
|
|
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::getworkstate() { |
|
|
|
|
|
if (creg.module_errorcode != 0) { |
|
|
|
|
|
return 2; |
|
|
|
|
|
} |
|
|
|
|
|
if (!m_thread.isworking()) { |
|
|
|
|
|
return 0; |
|
|
|
|
|
} else { |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::geterrorbitflag0() { |
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief |
|
|
|
|
|
*/ |
|
|
|
|
|
ZITemperatureSensor* sensor = m_temperature_sensor[m_hardwared_config.temp_fb_index]; |
|
|
|
|
|
|
|
|
|
|
|
int32_t errorbitflag = 0; |
|
|
|
|
|
errorbitflag |= m_fan_ctrl->isError() << 0; |
|
|
|
|
|
errorbitflag |= m_pump_ctrl->isError() << 1; |
|
|
|
|
|
errorbitflag |= m_pelter_ctrl->isError() << 2; |
|
|
|
|
|
errorbitflag |= sensor->isError() << 3; |
|
|
|
|
|
|
|
|
|
|
|
// 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_peltier_ctrl[0]) errorbitflag |= m_peltier_ctrl[0]->isFault() << 8;
|
|
|
|
|
|
// if (m_peltier_ctrl[1]) errorbitflag |= m_peltier_ctrl[1]->isFault() << 9;
|
|
|
|
|
|
return errorbitflag; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::checkdevice() { |
|
|
int32_t WaterCoolingTemperatureControlModule::checkdevice() { |
|
|
uint32_t module_errorbitflag0 = geterrorbitflag0(); |
|
|
|
|
|
if (module_errorbitflag0 != 0) { |
|
|
|
|
|
ZLOGE(TAG, "checkdevice errorbitflag0:%d %d %d %d", //
|
|
|
|
|
|
BIT(module_errorbitflag0, 0), //
|
|
|
|
|
|
BIT(module_errorbitflag0, 1), //
|
|
|
|
|
|
BIT(module_errorbitflag0, 2), //
|
|
|
|
|
|
BIT(module_errorbitflag0, 3)); |
|
|
|
|
|
m_pelter_ctrl->dumpErrorInfo(); |
|
|
|
|
|
// TODO 设置错误码
|
|
|
|
|
|
// creg.module_errorcode = err::khwardware_error;
|
|
|
|
|
|
|
|
|
ZITemperatureSensor* sensor = m_temperature_sensor[m_hardwared_config.temp_fb_index]; |
|
|
|
|
|
if (m_fan_ctrl->isError()) { |
|
|
|
|
|
ZLOGE(TAG, "fan_ctrl is error"); |
|
|
|
|
|
creg.module_errorcode = err::kwater_cooling_fan_error; |
|
|
|
|
|
creg.m_module_status = 2; |
|
|
|
|
|
return 1; |
|
|
|
|
|
} else if (m_pump_ctrl->isError()) { |
|
|
|
|
|
ZLOGE(TAG, "pump_ctrl is error"); |
|
|
|
|
|
creg.module_errorcode = err::kwater_cooling_pump_is_error; |
|
|
|
|
|
creg.m_module_status = 2; |
|
|
|
|
|
return 1; |
|
|
|
|
|
} else if (m_pelter_ctrl->isError()) { |
|
|
|
|
|
ZLOGE(TAG, "pelter_ctrl is error"); |
|
|
|
|
|
creg.module_errorcode = err::kwater_cooling_temperature_sensor_error; |
|
|
|
|
|
creg.m_module_status = 2; |
|
|
|
|
|
return 1; |
|
|
|
|
|
} else if (sensor->isError()) { |
|
|
|
|
|
creg.module_errorcode = err::kwater_cooling_temperature_sensor_error; |
|
|
|
|
|
creg.m_module_status = 2; |
|
|
|
|
|
ZLOGE(TAG, "sensor is error"); |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
return 0; |
|
|
return 0; |
|
|