export const cmdNameMap = { door_open: '开门', door_close: '关门', door_stop: '停止开关门', liquid_arm_rotation: '加液机械臂启动', liquid_arm_reset: '加液机械臂复位', liquid_arm_stop: '加液机械臂停止', liquid_pump_start: '启动加液泵', liquid_pump_stop: '停止加液泵', liquid_pump_pre_filling: '预充加液头', liquid_pump_pre_evacuation: '排空加液头', shaker_start: '摇匀', shaker_stop: '停止摇匀', pallet_elevator_lift_up: '托盘上升', pallet_elevator_lift_down: '托盘下降', pallet_elevator_stop: '托盘停止', heater_start: '开始加热', heater_stop: '停止加热', heater_start_heat_maintaining: '启动恒温', heater_stop_heat_maintaining: '停止恒温', cold_trap_start_refrigeration: '启动制冷', cold_trap_stop_refrigeration: '停止制冷', fan_start: '打开风扇', fan_stop: '关闭风扇', transportation_arm_move: '龙门架机械臂移动', transportation_arm_stop: '龙门架机械臂停止移动', transportation_arm_reset: '龙门架机械臂复位', holding_jaw_open: '打开夹爪', holding_jaw_pause: '暂停夹爪', holding_jaw_close: '闭合夹爪', cover_elevator_lift_up: '拍子抬升', cover_elevator_stop: '拍子停止', cover_elevator_reset: '拍子复位', cover_elevator_lift_down: '拍子下降', cold_trap_start_recycle: '开启循环', cold_trap_stop_recycle: '停止循环', } export const generateColors = (count: number): string[] => { const colors: string[] = [] for (let i = 0; i < count; i++) { // Increase hue step to make colors more distinct const hue = (i * 360) / count // Introduce variation in saturation and lightness with larger steps const saturation = 30 + (i % 5) * 20 // Alternate between 30, 50, 70, 90, 110 const lightness = 30 + (i % 4) * 20 // Alternate between 30, 50, 70, 90 // Convert HSL to RGB const rgb = hslToRgb(hue, saturation, lightness) // Convert RGB to hex const hex = rgbToHex(rgb.r, rgb.g, rgb.b) colors.push(hex) } return colors } const hslToRgb = (h: number, s: number, l: number): { r: number, g: number, b: number } => { s /= 100 l /= 100 const k = (n: number) => (n + h / 30) % 12 const a = s * Math.min(l, 1 - l) const f = (n: number) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1))) return { r: Math.round(f(0) * 255), g: Math.round(f(8) * 255), b: Math.round(f(4) * 255), } } const rgbToHex = (r: number, g: number, b: number): string => { const toHex = (c: number) => `0${c.toString(16)}`.slice(-2) return `#${toHex(r)}${toHex(g)}${toHex(b)}` } export const colors = generateColors(100) export function isNumber(value: any) { return typeof value === 'number' && !Number.isNaN(value) } export function formatDateTime(template: string = 'YYYY/MM/DD HH:mm:ss'): string { const now = new Date() const tokens: Record = { YYYY: String(now.getFullYear()), MM: String(now.getMonth() + 1).padStart(2, '0'), DD: String(now.getDate()).padStart(2, '0'), HH: String(now.getHours()).padStart(2, '0'), mm: String(now.getMinutes()).padStart(2, '0'), ss: String(now.getSeconds()).padStart(2, '0'), } return template.replace(/YYYY|MM|DD|HH|mm|ss/g, token => tokens[token]!) }