增加转台
This commit is contained in:
386
app/app_power.c
386
app/app_power.c
@@ -34,73 +34,73 @@ typedef struct {
|
||||
PowerSystem power_data;
|
||||
static PowerButton power_button = {BUTTON_STATE_INITIAL, 0, 0, 0, {0},0};
|
||||
|
||||
// 电源按钮处理函数
|
||||
static void handlePowerButton(void)
|
||||
{
|
||||
switch (power_button.state)
|
||||
{
|
||||
case BUTTON_STATE_INITIAL:
|
||||
if (power_data.remote_power_switch == app_close())
|
||||
{
|
||||
power_button.state = BUTTON_STATE_SHORT_PRESS_DETECTED;
|
||||
timerStart(&power_button.timer, 500, 0); // 启动短按定时器,500ms
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON_STATE_SHORT_PRESS_DETECTED:
|
||||
if (power_data.remote_power_switch == app_open())
|
||||
{
|
||||
if (power_button.timer.active) // 定时器未到期,短按完成,启动等待长按定时器
|
||||
{
|
||||
power_button.state = BUTTON_STATE_WAIT_FOR_LONG_PRESS;
|
||||
timerStart(&power_button.timer, 500, 0); // 启动等待长按定时器,500ms
|
||||
}
|
||||
}
|
||||
else if (!power_button.timer.active)// 短按定时器到期,按键仍被按下,视为无效,重置为初始状态
|
||||
{
|
||||
power_button.state = BUTTON_STATE_INITIAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON_STATE_WAIT_FOR_LONG_PRESS:
|
||||
if (power_data.remote_power_switch == app_close())// 检测是否在等待时间内进行长按
|
||||
{
|
||||
power_button.state = BUTTON_STATE_LONG_PRESS;
|
||||
timerStart(&power_button.timer, 1000, 0); // 启动长按定时器,1000ms
|
||||
}
|
||||
else if (!power_button.timer.active) // 等待长按超时,重置为初始状态
|
||||
{
|
||||
power_button.state = BUTTON_STATE_INITIAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON_STATE_LONG_PRESS:
|
||||
|
||||
if (!power_button.timer.active)// 长按完成,切换电源状态 20250423 修改不需要判断松开按键就打开控制器
|
||||
{
|
||||
power_button.is_power_on = !power_button.is_power_on;
|
||||
printf("PowerButton: is_power_on = %d\n", power_button.is_power_on);
|
||||
power_button.state = BUTTON_STATE_LONG_PRESS_WAIT;
|
||||
}
|
||||
else if(power_data.remote_power_switch == app_open())
|
||||
{
|
||||
power_button.state = BUTTON_STATE_INITIAL;
|
||||
printf("Long press for short duration");
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
case BUTTON_STATE_LONG_PRESS_WAIT:
|
||||
if (power_data.remote_power_switch == app_open())// 检测按键释放
|
||||
{
|
||||
power_button.state = BUTTON_STATE_INITIAL;
|
||||
printf("Release the button");
|
||||
}
|
||||
default:
|
||||
power_button.state = BUTTON_STATE_INITIAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//// 电源按钮处理函数
|
||||
//static void handlePowerButton(void)
|
||||
//{
|
||||
// switch (power_button.state)
|
||||
// {
|
||||
// case BUTTON_STATE_INITIAL:
|
||||
// if (power_data.remote_power_switch == app_close())
|
||||
// {
|
||||
// power_button.state = BUTTON_STATE_SHORT_PRESS_DETECTED;
|
||||
// timerStart(&power_button.timer, 500, 0); // 启动短按定时器,500ms
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case BUTTON_STATE_SHORT_PRESS_DETECTED:
|
||||
// if (power_data.remote_power_switch == app_open())
|
||||
// {
|
||||
// if (power_button.timer.active) // 定时器未到期,短按完成,启动等待长按定时器
|
||||
// {
|
||||
// power_button.state = BUTTON_STATE_WAIT_FOR_LONG_PRESS;
|
||||
// timerStart(&power_button.timer, 500, 0); // 启动等待长按定时器,500ms
|
||||
// }
|
||||
// }
|
||||
// else if (!power_button.timer.active)// 短按定时器到期,按键仍被按下,视为无效,重置为初始状态
|
||||
// {
|
||||
// power_button.state = BUTTON_STATE_INITIAL;
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case BUTTON_STATE_WAIT_FOR_LONG_PRESS:
|
||||
// if (power_data.remote_power_switch == app_close())// 检测是否在等待时间内进行长按
|
||||
// {
|
||||
// power_button.state = BUTTON_STATE_LONG_PRESS;
|
||||
// timerStart(&power_button.timer, 1000, 0); // 启动长按定时器,1000ms
|
||||
// }
|
||||
// else if (!power_button.timer.active) // 等待长按超时,重置为初始状态
|
||||
// {
|
||||
// power_button.state = BUTTON_STATE_INITIAL;
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case BUTTON_STATE_LONG_PRESS:
|
||||
//
|
||||
// if (!power_button.timer.active)// 长按完成,切换电源状态 20250423 修改不需要判断松开按键就打开控制器
|
||||
// {
|
||||
// power_button.is_power_on = !power_button.is_power_on;
|
||||
// printf("PowerButton: is_power_on = %d\n", power_button.is_power_on);
|
||||
// power_button.state = BUTTON_STATE_LONG_PRESS_WAIT;
|
||||
// }
|
||||
// else if(power_data.remote_power_switch == app_open())
|
||||
// {
|
||||
// power_button.state = BUTTON_STATE_INITIAL;
|
||||
// printf("Long press for short duration");
|
||||
// }
|
||||
// else
|
||||
// break;
|
||||
//
|
||||
// case BUTTON_STATE_LONG_PRESS_WAIT:
|
||||
// if (power_data.remote_power_switch == app_open())// 检测按键释放
|
||||
// {
|
||||
// power_button.state = BUTTON_STATE_INITIAL;
|
||||
// printf("Release the button");
|
||||
// }
|
||||
// default:
|
||||
// power_button.state = BUTTON_STATE_INITIAL;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
// 输出处理函数
|
||||
@@ -113,99 +113,111 @@ static void powerOutput(void *signal_id)
|
||||
{
|
||||
case POWER_PRE_CHARGE:
|
||||
publishMessage(&power_data.pre_charge_finish, 1);//发布预充完成信号,100ms发送一次,直到预充完成
|
||||
un_inf_can_kgf_output1.bit_data.KGF04 = setPowerOn(); // 预充继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOff(); // 高压继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOff(); // 高压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF10 = setPowerOn(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF11 = setPowerOn(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF01 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF02 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF03 = setPowerOn(); // 遥控器
|
||||
un_inf_can_kgf_output2.bit_data.KGF05 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF06 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF04 = setPowerOn(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF01 = setPowerOff(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF02 = setPowerOn(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF03 = setPowerOff(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF05 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF06 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF11 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF12 = setPowerOn(); // 待定
|
||||
// un_inf_can_kgf_output1.bit_data.KGF13 = setPowerOn(); // 前左右红灯
|
||||
// un_inf_can_kgf_output1.bit_data.KGF14 = setPowerOn(); // 后左右红灯
|
||||
un_inf_can_kgf_output1.bit_data.KGF15 = setPowerOn(); // 网络摄像头
|
||||
un_inf_can_kgf_output1.bit_data.KGF16 = setPowerOn(); // 遥控器
|
||||
break;
|
||||
|
||||
case POWER_NEUTRAL:
|
||||
publishMessage(&power_data.pre_charge_finish, 1);//20250316增加,发送空挡信号,保证电机控制器高压上电后,发送空挡信号
|
||||
un_inf_can_kgf_output1.bit_data.KGF04 = setPowerOff(); // 预充继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 高压继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 高压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF10 = setPowerOn(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF11 = setPowerOn(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF01 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF02 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF03 = setPowerOn(); // 遥控器
|
||||
un_inf_can_kgf_output2.bit_data.KGF05 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF06 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF04 = setPowerOn(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF01 = setPowerOff(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF02 = setPowerOn(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF03 = setPowerOff(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF05 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF06 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF11 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF12 = setPowerOn(); // 待定
|
||||
// un_inf_can_kgf_output1.bit_data.KGF13 = setPowerOn(); // 前左右红灯
|
||||
// un_inf_can_kgf_output1.bit_data.KGF14 = setPowerOn(); // 后左右红灯
|
||||
un_inf_can_kgf_output1.bit_data.KGF15 = setPowerOn(); // 网络摄像头
|
||||
un_inf_can_kgf_output1.bit_data.KGF16 = setPowerOn(); // 遥控器
|
||||
break;
|
||||
|
||||
|
||||
case POWER_STANDBY:
|
||||
// 初始状态,只开启基本设备
|
||||
un_inf_can_kgf_output1.bit_data.KGF04 = setPowerOff(); // 预充继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOff(); // 高压继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOff(); // 高压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF10 = setPowerOff(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF11 = setPowerOff(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF01 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF02 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF03 = setPowerOn(); // 遥控器
|
||||
un_inf_can_kgf_output2.bit_data.KGF05 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF06 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF04 = setPowerOn(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF01 = setPowerOff(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF02 = setPowerOn(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF03 = setPowerOff(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF05 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF06 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF11 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF12 = setPowerOn(); // 待定
|
||||
// un_inf_can_kgf_output1.bit_data.KGF13 = setPowerOn(); // 前左右红灯
|
||||
// un_inf_can_kgf_output1.bit_data.KGF14 = setPowerOn(); // 后左右红灯
|
||||
un_inf_can_kgf_output1.bit_data.KGF15 = setPowerOn(); // 网络摄像头
|
||||
un_inf_can_kgf_output1.bit_data.KGF16 = setPowerOn(); // 遥控器
|
||||
break;
|
||||
|
||||
case POWER_WORKING:
|
||||
// 工作状态,除预充继电器外所有设备开启
|
||||
un_inf_can_kgf_output1.bit_data.KGF04 = setPowerOff(); // 预充继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 高压继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 高压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF10 = setPowerOn(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF11 = setPowerOn(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF01 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF02 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF03 = setPowerOn(); // 遥控器
|
||||
un_inf_can_kgf_output2.bit_data.KGF05 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF06 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF04 = setPowerOn(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF01 = setPowerOff(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF02 = setPowerOn(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF03 = setPowerOff(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF05 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF06 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF11 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF12 = setPowerOn(); // 待定
|
||||
// un_inf_can_kgf_output1.bit_data.KGF13 = setPowerOn(); // 前左右红灯
|
||||
// un_inf_can_kgf_output1.bit_data.KGF14 = setPowerOn(); // 后左右红灯
|
||||
un_inf_can_kgf_output1.bit_data.KGF15 = setPowerOn(); // 网络摄像头
|
||||
un_inf_can_kgf_output1.bit_data.KGF16 = setPowerOn(); // 遥控器
|
||||
break;
|
||||
|
||||
case POWER_EMERGENCY:
|
||||
// 急停状态,断开高压
|
||||
un_inf_can_kgf_output1.bit_data.KGF04 = setPowerOff(); // 预充继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOff(); // 高压继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOff(); // 高压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF10 = setPowerOn(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF11 = setPowerOn(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF01 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF02 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF03 = setPowerOn(); // 遥控器
|
||||
un_inf_can_kgf_output2.bit_data.KGF05 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF06 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF04 = setPowerOn(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF01 = setPowerOff(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF02 = setPowerOn(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF03 = setPowerOff(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF05 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF06 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF11 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF12 = setPowerOn(); // 待定
|
||||
// un_inf_can_kgf_output1.bit_data.KGF13 = setPowerOn(); // 前左右红灯
|
||||
// un_inf_can_kgf_output1.bit_data.KGF14 = setPowerOn(); // 后左右红灯
|
||||
un_inf_can_kgf_output1.bit_data.KGF15 = setPowerOn(); // 网络摄像头
|
||||
un_inf_can_kgf_output1.bit_data.KGF16 = setPowerOn(); // 遥控器
|
||||
break;
|
||||
|
||||
case POWER_SLEEP:
|
||||
// 休眠状态,关闭所有设备
|
||||
un_inf_can_kgf_output1.bit_data.KGF04 = setPowerOff(); // 预充继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOff(); // 高压继电器
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOff(); // 高压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF10 = setPowerOff(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF11 = setPowerOff(); // 低压继电器
|
||||
un_inf_can_kgf_output2.bit_data.KGF01 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF02 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output2.bit_data.KGF03 = setPowerOn(); // 遥控器
|
||||
un_inf_can_kgf_output2.bit_data.KGF05 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF06 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 网络交换机
|
||||
un_inf_can_kgf_output2.bit_data.KGF04 = setPowerOn(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF01 = setPowerOff(); // E3
|
||||
un_inf_can_kgf_output1.bit_data.KGF02 = setPowerOn(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF03 = setPowerOff(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF05 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF06 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF11 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF12 = setPowerOn(); // 待定
|
||||
// un_inf_can_kgf_output1.bit_data.KGF13 = setPowerOn(); // 前左右红灯
|
||||
// un_inf_can_kgf_output1.bit_data.KGF14 = setPowerOn(); // 后左右红灯
|
||||
un_inf_can_kgf_output1.bit_data.KGF15 = setPowerOn(); // 网络摄像头
|
||||
un_inf_can_kgf_output1.bit_data.KGF16 = setPowerOn(); // 遥控器
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -213,7 +225,7 @@ static void powerOutput(void *signal_id)
|
||||
}
|
||||
publishMessage(&power_data, 1);
|
||||
publishMessage(&un_inf_can_kgf_output1, 1);
|
||||
publishMessage(&un_inf_can_kgf_output2, 1);
|
||||
// publishMessage(&un_inf_can_kgf_output2, 1);
|
||||
}
|
||||
|
||||
static void wakeupProcess(void *signal_id)
|
||||
@@ -246,13 +258,13 @@ static void powerTimerProcess(void *signal_id)
|
||||
(void)signal_id;
|
||||
|
||||
// 调用电源按钮处理函数
|
||||
handlePowerButton();
|
||||
// handlePowerButton();
|
||||
// 电源按钮状态有变化,保存到参数
|
||||
if (power_button.is_power_on != power_button.old_is_power_on)
|
||||
{
|
||||
setParam("pwr_btn", (float)power_button.is_power_on);
|
||||
power_button.old_is_power_on = power_button.is_power_on;
|
||||
}
|
||||
// if (power_button.is_power_on != power_button.old_is_power_on)
|
||||
// {
|
||||
// setParam("pwr_btn", (float)power_button.is_power_on);
|
||||
// power_button.old_is_power_on = power_button.is_power_on;
|
||||
// }
|
||||
|
||||
// 状态转换逻辑
|
||||
switch (power_data.current_state)
|
||||
@@ -274,7 +286,7 @@ static void powerTimerProcess(void *signal_id)
|
||||
printf("Power: Transitioning from POWER_NEUTRAL to WORKING state\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
power_data.neutral_cnt ++;
|
||||
power_data.current_state = POWER_NEUTRAL; // 空挡
|
||||
power_data.pre_charge_finish = 1; // 预充完成
|
||||
@@ -282,25 +294,27 @@ static void powerTimerProcess(void *signal_id)
|
||||
break;
|
||||
|
||||
case POWER_STANDBY:
|
||||
if (power_data.high_voltage_switch == app_open()) // 高压开关断开
|
||||
{
|
||||
power_data.current_state = POWER_SLEEP; // 休眠
|
||||
printf("Power: Transitioning from STANDBY to SLEEP state\n");
|
||||
}
|
||||
else if (power_button.is_power_on == app_close() && power_data.emergency_stop == app_close()) // 遥控器电源开关闭合且急停开关闭合
|
||||
{
|
||||
power_data.current_state = POWER_EMERGENCY; // 急停
|
||||
printf("Power: Transitioning from STANDBY to EMERGENCY state\n");
|
||||
}
|
||||
|
||||
power_data.current_state = POWER_WORKING; // 休眠 20251005 修改不需要休眠,直接上电
|
||||
// if (power_data.high_voltage_switch == app_open()) // 高压开关断开
|
||||
// {
|
||||
// power_data.current_state = POWER_SLEEP; // 休眠
|
||||
// printf("Power: Transitioning from STANDBY to SLEEP state\n");
|
||||
// }
|
||||
// else if (power_button.is_power_on == app_close() && power_data.emergency_stop == app_close()) // 遥控器电源开关闭合且急停开关闭合
|
||||
// {
|
||||
// power_data.current_state = POWER_EMERGENCY; // 急停
|
||||
// printf("Power: Transitioning from STANDBY to EMERGENCY state\n");
|
||||
// }
|
||||
break;
|
||||
|
||||
case POWER_WORKING:
|
||||
if (power_data.high_voltage_switch == app_open()) // 高压开关断开
|
||||
{
|
||||
power_data.current_state = POWER_SLEEP; // 休眠
|
||||
printf("Power: Transitioning from STANDBY to SLEEP state\n");
|
||||
}
|
||||
else if (power_data.emergency_stop == app_close()) // 急停开关闭合
|
||||
// if (power_data.high_voltage_switch == app_open()) // 高压开关断开
|
||||
// {
|
||||
// power_data.current_state = POWER_SLEEP; // 休眠
|
||||
// printf("Power: Transitioning from STANDBY to SLEEP state\n");
|
||||
//
|
||||
if (power_data.emergency_stop == app_close()) // 急停开关闭合
|
||||
{
|
||||
power_data.current_state = POWER_EMERGENCY; // 急停
|
||||
printf("Power: Transitioning from WORKING to EMERGENCY state\n");
|
||||
@@ -310,17 +324,17 @@ static void powerTimerProcess(void *signal_id)
|
||||
}
|
||||
break;
|
||||
case POWER_EMERGENCY:
|
||||
if (power_data.high_voltage_switch == app_open()) // 高压开关断开
|
||||
{
|
||||
power_data.current_state = POWER_SLEEP; // 休眠
|
||||
printf("Power: Transitioning from EMERGENCY to SLEEP state\n");
|
||||
}
|
||||
else if (power_button.is_power_on == app_open()) // 遥控器电源开关断开
|
||||
{
|
||||
power_data.current_state = POWER_STANDBY; // 待机
|
||||
printf("Power: Transitioning from EMERGENCY to STANDBY state\n");
|
||||
}
|
||||
else if (power_data.emergency_stop == app_open()) // 急停断开
|
||||
// if (power_data.high_voltage_switch == app_open()) // 高压开关断开
|
||||
// {
|
||||
// power_data.current_state = POWER_SLEEP; // 休眠
|
||||
// printf("Power: Transitioning from EMERGENCY to SLEEP state\n");
|
||||
// }
|
||||
// else if (power_button.is_power_on == app_open()) // 遥控器电源开关断开 //20251005 修改不需要电源开关
|
||||
// {
|
||||
// power_data.current_state = POWER_STANDBY; // 待机
|
||||
// printf("Power: Transitioning from EMERGENCY to STANDBY state\n");
|
||||
// }
|
||||
if (power_data.emergency_stop == app_open()) // 急停断开
|
||||
{
|
||||
power_data.current_state = POWER_PRE_CHARGE; // 预充
|
||||
timerStart(&power_data.timer_pre_charge, (uint32_t)(getParam("prCTime") * 1000), 1); // 启动预充定时器
|
||||
@@ -362,10 +376,13 @@ static void powerInput(void *signal_id)
|
||||
memcpy(&old_data, &power_data, sizeof(PowerSystem));
|
||||
|
||||
// 填充数据
|
||||
power_data.emergency_stop_switch = 0;//急停开关 20251005 修改四轮四转车无急停开关以及采集模块 高压
|
||||
power_data.high_voltage_switch = 1;//高压开关
|
||||
|
||||
if (signal_id == &un_sw_sample)
|
||||
{
|
||||
power_data.emergency_stop_switch = (uint8_t)un_sw_sample.bit_data.emergency_stop_switch;//急停开关
|
||||
power_data.high_voltage_switch = (uint8_t)un_sw_sample.bit_data.High_voltage_switch;//高压开关
|
||||
// power_data.emergency_stop_switch = (uint8_t)un_sw_sample.bit_data.emergency_stop_switch;//急停开关
|
||||
// power_data.high_voltage_switch = (uint8_t)un_sw_sample.bit_data.High_voltage_switch;//高压开关
|
||||
}
|
||||
else if ( (signal_id == &un_remote_control_input) && (1 == un_remote_control_input.bit_data.enable) )// 遥控器断线,不更新数据
|
||||
{
|
||||
@@ -408,7 +425,22 @@ void powerAppInit(void)
|
||||
power_data.old_high_voltage_switch = power_data.high_voltage_switch;
|
||||
//恢复急停开关状态
|
||||
power_data.emergency_stop = (uint8_t)getParam("stop_sw");
|
||||
power_data.old_emergency_stop = power_data.emergency_stop;
|
||||
power_data.old_emergency_stop = power_data.emergency_stop;
|
||||
|
||||
un_inf_can_kgf_output1.bit_data.KGF01 = setPowerOff(); // E3 初始化上电默认打开
|
||||
un_inf_can_kgf_output1.bit_data.KGF02 = setPowerOn(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF03 = setPowerOff(); // 导航仪
|
||||
un_inf_can_kgf_output1.bit_data.KGF05 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF06 = setPowerOn(); // 交换机、路由器
|
||||
un_inf_can_kgf_output1.bit_data.KGF07 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF08 = setPowerOn(); // 计算机
|
||||
un_inf_can_kgf_output1.bit_data.KGF09 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF11 = setPowerOn(); // 上装
|
||||
un_inf_can_kgf_output1.bit_data.KGF12 = setPowerOn(); // 待定
|
||||
un_inf_can_kgf_output1.bit_data.KGF13 = setPowerOn(); // 前左右红灯
|
||||
un_inf_can_kgf_output1.bit_data.KGF14 = setPowerOn(); // 后左右红灯
|
||||
un_inf_can_kgf_output1.bit_data.KGF15 = setPowerOn(); // 网络摄像头
|
||||
un_inf_can_kgf_output1.bit_data.KGF16 = setPowerOn(); // 遥控器
|
||||
|
||||
// 订阅输入信号
|
||||
subscribe(&un_sw_sample, powerInput); // 急停开关、高压开关
|
||||
|
||||
Reference in New Issue
Block a user