Browse Source

增加 BLE_GAMEPAD

master
HSZ_HeSongZhen 5 days ago
parent
commit
6eb2bbd471
  1. 2
      src/main/java/com/iflytop/handacid/common/enums/Device.java
  2. 50
      src/main/java/com/iflytop/handacid/hardware/command/handlers/BleGamepadHandler.java

2
src/main/java/com/iflytop/handacid/common/enums/Device.java

@ -11,7 +11,7 @@ public enum Device {
VALVE_2(HardwareType.IO_DEVICE, "阀 2"),
VALVE_3(HardwareType.IO_DEVICE, "阀 3"),
VALVE_4(HardwareType.IO_DEVICE, "阀 4"),
BleGamepadDriver(HardwareType.IO_DEVICE, "蓝牙手柄"),
BLE_GAMEPAD(HardwareType.IO_DEVICE, "蓝牙手柄"),
;
/**

50
src/main/java/com/iflytop/handacid/hardware/command/handlers/BleGamepadHandler.java

@ -0,0 +1,50 @@
package com.iflytop.handacid.hardware.command.handlers;
import com.iflytop.handacid.app.core.command.DeviceCommand;
import com.iflytop.handacid.common.enums.Action;
import com.iflytop.handacid.common.enums.Device;
import com.iflytop.handacid.hardware.command.CommandHandler;
import com.iflytop.handacid.hardware.drivers.OutputIOCtrlDriver;
import com.iflytop.handacid.hardware.type.BleGamepadMid;
import com.iflytop.handacid.hardware.type.IO.OutputIOMId;
import com.iflytop.handacid.hardware.type.MId;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
//
@Slf4j
@Component
@RequiredArgsConstructor
public class BleGamepadHandler extends CommandHandler {
private final OutputIOCtrlDriver driver_;
private final Map<Device, BleGamepadMid> supportCmdDeviceIOOutputMap = Map.ofEntries(
Map.entry(Device.BLE_GAMEPAD, BleGamepadMid.BleGamePad)
);
private final Map<Device, MId> supportCmdDeviceMIdMap = supportCmdDeviceIOOutputMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().mid));
private final Set<Action> supportActions = Set.of(Action.OPEN, Action.CLOSE);
@Override
protected Map<Device, MId> getSupportCmdDeviceMIdMap()
{
return supportCmdDeviceMIdMap;
}
@Override
protected Set<Action> getSupportActions() {
return supportActions;
}
@Override
public void handleCommand(DeviceCommand command) throws Exception {
// 发送命令
}
}
Loading…
Cancel
Save