|
@ -1,5 +1,7 @@ |
|
|
package com.iflytop.handacid.app.core.listener; |
|
|
package com.iflytop.handacid.app.core.listener; |
|
|
|
|
|
|
|
|
|
|
|
import com.iflytop.handacid.app.core.state.DeviceState; |
|
|
|
|
|
import com.iflytop.handacid.app.service.ChannelCtrlService; |
|
|
import com.iflytop.handacid.hardware.service.AppEventBusService; |
|
|
import com.iflytop.handacid.hardware.service.AppEventBusService; |
|
|
import com.iflytop.handacid.hardware.type.A8kPacket; |
|
|
import com.iflytop.handacid.hardware.type.A8kPacket; |
|
|
import com.iflytop.handacid.hardware.type.CmdId; |
|
|
import com.iflytop.handacid.hardware.type.CmdId; |
|
@ -12,7 +14,6 @@ import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 蓝牙手柄按钮事件监听 |
|
|
* 蓝牙手柄按钮事件监听 |
|
|
* |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
@Component |
|
|
@Component |
|
@ -20,6 +21,8 @@ import org.springframework.stereotype.Component; |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
public class BleGamepadEventListener { |
|
|
public class BleGamepadEventListener { |
|
|
private final AppEventBusService eventBus; |
|
|
private final AppEventBusService eventBus; |
|
|
|
|
|
private final ChannelCtrlService channelCtrlService; |
|
|
|
|
|
private final DeviceState deviceState; |
|
|
|
|
|
|
|
|
@PostConstruct |
|
|
@PostConstruct |
|
|
synchronized public void init() { |
|
|
synchronized public void init() { |
|
@ -28,23 +31,34 @@ public class BleGamepadEventListener { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 事件总线事件处理 |
|
|
* 事件总线事件处理 |
|
|
|
|
|
* |
|
|
* @param event e |
|
|
* @param event e |
|
|
*/ |
|
|
*/ |
|
|
private void onAppEvent(AppEvent event) { |
|
|
private void onAppEvent(AppEvent event) { |
|
|
if (event instanceof A8kHardwareReport canPacket) { |
|
|
if (event instanceof A8kHardwareReport canPacket) { |
|
|
A8kPacket packet = canPacket.getReportPacket(); |
|
|
A8kPacket packet = canPacket.getReportPacket(); |
|
|
CmdId cmdId = CmdId.valueOf(packet.getCmdId()); |
|
|
|
|
|
|
|
|
CmdId cmdId = CmdId.valueOf(packet.getCmdId()); |
|
|
if (CmdId.event_ble_gamepad_liquid_acid.equals(cmdId)) { |
|
|
if (CmdId.event_ble_gamepad_liquid_acid.equals(cmdId)) { |
|
|
//判断当前的设备状态 |
|
|
//判断当前的设备状态 |
|
|
log.info("蓝牙手柄 加酸按钮 按下"); |
|
|
log.info("蓝牙手柄 加酸按钮 按下"); |
|
|
|
|
|
if(deviceState.isSolutionAdding()){ |
|
|
|
|
|
channelCtrlService.solutionAddStop(); |
|
|
|
|
|
}else{ |
|
|
|
|
|
channelCtrlService.solutionAddStart(); |
|
|
|
|
|
} |
|
|
} else if (CmdId.event_ble_gamepad_liquid_acid_prefilling.equals(cmdId)) { |
|
|
} else if (CmdId.event_ble_gamepad_liquid_acid_prefilling.equals(cmdId)) { |
|
|
log.info("蓝牙手柄 预充按钮 按下"); |
|
|
log.info("蓝牙手柄 预充按钮 按下"); |
|
|
} |
|
|
|
|
|
else if (CmdId.event_ble_gamepad_connected.equals(cmdId)) { |
|
|
|
|
|
|
|
|
if(deviceState.isSolutionPreFillStart()){ |
|
|
|
|
|
channelCtrlService.solutionPreFillStart(); |
|
|
|
|
|
}else{ |
|
|
|
|
|
channelCtrlService.solutionPreFillStop(); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (CmdId.event_ble_gamepad_connected.equals(cmdId)) { |
|
|
log.info("蓝牙手柄 连接成功"); |
|
|
log.info("蓝牙手柄 连接成功"); |
|
|
} |
|
|
|
|
|
else if (CmdId.event_ble_gamepad_disconnected.equals(cmdId)) { |
|
|
|
|
|
|
|
|
deviceState.setBluetoothConnected(true); |
|
|
|
|
|
} else if (CmdId.event_ble_gamepad_disconnected.equals(cmdId)) { |
|
|
log.info("蓝牙手柄 连接断开"); |
|
|
log.info("蓝牙手柄 连接断开"); |
|
|
|
|
|
deviceState.setBluetoothConnected(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|