mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-15 07:26:44 +08:00
feat: 添加了对串口协议的继电器的支持
This commit is contained in:
@@ -118,6 +118,8 @@ export enum AtxDriverType {
|
||||
Gpio = "gpio",
|
||||
/** USB HID relay module */
|
||||
UsbRelay = "usbrelay",
|
||||
/** Serial/COM port relay (LCUS type) */
|
||||
Serial = "serial",
|
||||
/** Disabled / Not configured */
|
||||
None = "none",
|
||||
}
|
||||
@@ -151,6 +153,8 @@ export interface AtxKeyConfig {
|
||||
pin: number;
|
||||
/** Active level (only applicable to GPIO, ignored for USB Relay) */
|
||||
active_level: ActiveLevel;
|
||||
/** Baud rate for serial relay (start with 9600) */
|
||||
baud_rate: number;
|
||||
}
|
||||
|
||||
/** LED sensing configuration (optional) */
|
||||
@@ -387,6 +391,7 @@ export interface AppConfig {
|
||||
export interface AtxKeyConfigUpdate {
|
||||
driver?: AtxDriverType;
|
||||
device?: string;
|
||||
baud_rate?: number;
|
||||
pin?: number;
|
||||
active_level?: ActiveLevel;
|
||||
}
|
||||
@@ -415,6 +420,8 @@ export interface AtxConfigUpdate {
|
||||
/** Available ATX devices for discovery */
|
||||
export interface AtxDevices {
|
||||
/** Available GPIO chips (/dev/gpiochip*) */
|
||||
/** Available Serial ports (/dev/ttyUSB*) */
|
||||
serial_ports: string[];
|
||||
gpio_chips: string[];
|
||||
/** Available USB HID relay devices (/dev/hidraw*) */
|
||||
usb_relays: string[];
|
||||
|
||||
@@ -350,12 +350,14 @@ const atxConfig = ref({
|
||||
device: '',
|
||||
pin: 0,
|
||||
active_level: 'high' as ActiveLevel,
|
||||
baud_rate: 9600,
|
||||
},
|
||||
reset: {
|
||||
driver: 'none' as AtxDriverType,
|
||||
device: '',
|
||||
pin: 0,
|
||||
active_level: 'high' as ActiveLevel,
|
||||
baud_rate: 9600,
|
||||
},
|
||||
led: {
|
||||
enabled: false,
|
||||
@@ -370,6 +372,7 @@ const atxConfig = ref({
|
||||
const atxDevices = ref<AtxDevices>({
|
||||
gpio_chips: [],
|
||||
usb_relays: [],
|
||||
serial_ports: [],
|
||||
})
|
||||
|
||||
// Encoder backend
|
||||
@@ -927,13 +930,15 @@ async function saveAtxConfig() {
|
||||
driver: atxConfig.value.power.driver,
|
||||
device: atxConfig.value.power.device || undefined,
|
||||
pin: atxConfig.value.power.pin,
|
||||
active_level: atxConfig.value.power.active_level,
|
||||
baud_rate: atxConfig.value.power.baud_rate,
|
||||
},
|
||||
reset: {
|
||||
driver: atxConfig.value.reset.driver,
|
||||
device: atxConfig.value.reset.device || undefined,
|
||||
pin: atxConfig.value.reset.pin,
|
||||
active_level: atxConfig.value.reset.active_level,
|
||||
baud_rate: atxConfig.value.reset.baud_rate
|
||||
active_level: atxConfig.value.reset.active_level,
|
||||
},
|
||||
led: {
|
||||
enabled: atxConfig.value.led.enabled,
|
||||
@@ -955,6 +960,8 @@ async function saveAtxConfig() {
|
||||
function getAtxDevicesForDriver(driver: string): string[] {
|
||||
if (driver === 'gpio') {
|
||||
return atxDevices.value.gpio_chips
|
||||
} else if (driver === 'serial') {
|
||||
return atxDevices.value.serial_ports
|
||||
} else if (driver === 'usbrelay') {
|
||||
return atxDevices.value.usb_relays
|
||||
}
|
||||
@@ -1906,6 +1913,7 @@ onMounted(async () => {
|
||||
<option value="none">{{ t('settings.atxDriverNone') }}</option>
|
||||
<option value="gpio">{{ t('settings.atxDriverGpio') }}</option>
|
||||
<option value="usbrelay">{{ t('settings.atxDriverUsbRelay') }}</option>
|
||||
<option value="serial">Serial (LCUS)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
@@ -1918,7 +1926,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div class="space-y-2">
|
||||
<Label for="power-pin">{{ atxConfig.power.driver === 'usbrelay' ? t('settings.atxChannel') : t('settings.atxPin') }}</Label>
|
||||
<Label for="power-pin">{{ ['usbrelay', 'serial'].includes(atxConfig.power.driver) ? t('settings.atxChannel') : t('settings.atxPin') }}</Label>
|
||||
<Input id="power-pin" type="number" v-model.number="atxConfig.power.pin" min="0" :disabled="atxConfig.power.driver === 'none'" />
|
||||
</div>
|
||||
<div v-if="atxConfig.power.driver === 'gpio'" class="space-y-2">
|
||||
@@ -1928,6 +1936,16 @@ onMounted(async () => {
|
||||
<option value="low">{{ t('settings.atxLevelLow') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="atxConfig.power.driver === 'serial'" class="space-y-2">
|
||||
<Label for="power-baudrate">{{ t('settings.baudRate') }}</Label>
|
||||
<select id="power-baudrate" v-model.number="atxConfig.power.baud_rate" class="w-full h-9 px-3 rounded-md border border-input bg-background text-sm">
|
||||
<option :value="9600">9600</option>
|
||||
<option :value="19200">19200</option>
|
||||
<option :value="38400">38400</option>
|
||||
<option :value="57600">57600</option>
|
||||
<option :value="115200">115200</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -1946,6 +1964,7 @@ onMounted(async () => {
|
||||
<option value="none">{{ t('settings.atxDriverNone') }}</option>
|
||||
<option value="gpio">{{ t('settings.atxDriverGpio') }}</option>
|
||||
<option value="usbrelay">{{ t('settings.atxDriverUsbRelay') }}</option>
|
||||
<option value="serial">Serial (LCUS)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
@@ -1958,7 +1977,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div class="space-y-2">
|
||||
<Label for="reset-pin">{{ atxConfig.reset.driver === 'usbrelay' ? t('settings.atxChannel') : t('settings.atxPin') }}</Label>
|
||||
<Label for="reset-pin">{{ ['usbrelay', 'serial'].includes(atxConfig.reset.driver) ? t('settings.atxChannel') : t('settings.atxPin') }}</Label>
|
||||
<Input id="reset-pin" type="number" v-model.number="atxConfig.reset.pin" min="0" :disabled="atxConfig.reset.driver === 'none'" />
|
||||
</div>
|
||||
<div v-if="atxConfig.reset.driver === 'gpio'" class="space-y-2">
|
||||
@@ -1968,6 +1987,16 @@ onMounted(async () => {
|
||||
<option value="low">{{ t('settings.atxLevelLow') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="atxConfig.reset.driver === 'serial'" class="space-y-2">
|
||||
<Label for="reset-baudrate">{{ t('settings.baudRate') }}</Label>
|
||||
<select id="reset-baudrate" v-model.number="atxConfig.reset.baud_rate" class="w-full h-9 px-3 rounded-md border border-input bg-background text-sm">
|
||||
<option :value="9600">9600</option>
|
||||
<option :value="19200">19200</option>
|
||||
<option :value="38400">38400</option>
|
||||
<option :value="57600">57600</option>
|
||||
<option :value="115200">115200</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user