4 changed files with 121 additions and 47 deletions
-
10src/main/java/com/iflytop/colortitration/ColorTitrationApplication.java
-
93src/main/java/com/iflytop/colortitration/common/enums/Device.java
-
25src/main/java/com/iflytop/colortitration/common/enums/HardwareType.java
-
40src/main/java/com/iflytop/colortitration/common/handler/DeviceTypeHandler.java
@ -1,50 +1,51 @@ |
|||||
package com.iflytop.colortitration.common.enums; |
package com.iflytop.colortitration.common.enums; |
||||
|
|
||||
|
import lombok.Getter; |
||||
|
|
||||
public enum Device { |
public enum Device { |
||||
door_motor, |
|
||||
shake_motor, |
|
||||
cap_motor, |
|
||||
dual_robot, |
|
||||
gantry_x, |
|
||||
gantry_y, |
|
||||
gantry_z, |
|
||||
heater_motor_1, |
|
||||
heater_motor_2, |
|
||||
heater_motor_3, |
|
||||
heater_motor_4, |
|
||||
heater_motor_5, |
|
||||
heater_motor_6, |
|
||||
acid_pump_1, |
|
||||
acid_pump_2, |
|
||||
acid_pump_3, |
|
||||
acid_pump_4, |
|
||||
acid_pump_5, |
|
||||
acid_pump_6, |
|
||||
acid_pump_7, |
|
||||
acid_pump_8, |
|
||||
claw, |
|
||||
fan_1, |
|
||||
fan_2, |
|
||||
fan_3, |
|
||||
fan_4, |
|
||||
fan_5, |
|
||||
fan_6, |
|
||||
water_pump_power, |
|
||||
ventilator_power, |
|
||||
heat_rod_1, |
|
||||
heat_rod_2, |
|
||||
heat_rod_3, |
|
||||
heat_rod_4, |
|
||||
heat_rod_5, |
|
||||
heat_rod_6, |
|
||||
vacuum_pump_valve_1, |
|
||||
vacuum_pump_valve_2, |
|
||||
vacuum_pump_valve_3, |
|
||||
vacuum_pump_valve_4, |
|
||||
vacuum_pump_valve_5, |
|
||||
vacuum_pump_valve_6, |
|
||||
tricolor_light, |
|
||||
fill_light, |
|
||||
cold_trap, |
|
||||
photo |
|
||||
|
Z_MOTOR(HardwareType.STEPPER_MOTOR, "Z 轴升降电机"), |
||||
|
CERAMIC_PUMP_1(HardwareType.STEPPER_MOTOR, "陶瓷泵 1"), |
||||
|
CERAMIC_PUMP_2(HardwareType.STEPPER_MOTOR, "陶瓷泵 2"), |
||||
|
BRUSHLESS_PUMP_1(HardwareType.STEPPER_MOTOR, "无刷泵 1"), |
||||
|
BRUSHLESS_PUMP_2(HardwareType.STEPPER_MOTOR, "无刷泵 2"), |
||||
|
BRUSHLESS_PUMP_3(HardwareType.STEPPER_MOTOR, "无刷泵 3"), |
||||
|
BRUSHLESS_PUMP_4(HardwareType.STEPPER_MOTOR, "无刷泵 4"), |
||||
|
BRUSHLESS_PUMP_5(HardwareType.STEPPER_MOTOR, "无刷泵 5"), |
||||
|
BRUSHLESS_PUMP_6(HardwareType.STEPPER_MOTOR, "无刷泵 6"), |
||||
|
BRUSHLESS_PUMP_7(HardwareType.STEPPER_MOTOR, "无刷泵 7"), |
||||
|
BRUSHLESS_PUMP_8(HardwareType.STEPPER_MOTOR, "无刷泵 8"), |
||||
|
BRUSHLESS_PUMP_9(HardwareType.STEPPER_MOTOR, "无刷泵 9"), |
||||
|
BRUSHLESS_PUMP_10(HardwareType.STEPPER_MOTOR, "无刷泵 10"), |
||||
|
STEP_PUMP_1(HardwareType.STEPPER_MOTOR, "步进泵 1"), |
||||
|
STEP_PUMP_2(HardwareType.STEPPER_MOTOR, "步进泵 2"), |
||||
|
STEP_PUMP_3(HardwareType.STEPPER_MOTOR, "步进泵 3"), |
||||
|
STIR_MOTOR_1(HardwareType.STEPPER_MOTOR, "搅拌电机 1"), |
||||
|
STIR_MOTOR_2(HardwareType.STEPPER_MOTOR, "搅拌电机 2"), |
||||
|
CLAW(HardwareType.SERVO_MOTOR, "夹爪"), |
||||
|
DUAL_ROBOT(HardwareType.STEPPER_MOTOR, "双轴机械臂"), |
||||
|
HEAT_ROD_1(HardwareType.IO_DEVICE, "加热棒 1"), |
||||
|
HEAT_ROD_2(HardwareType.IO_DEVICE, "加热棒 2"), |
||||
|
TRICOLOR_LIGHT(HardwareType.IO_DEVICE, "三色灯"); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 设备所属硬件类型 |
||||
|
*/ |
||||
|
@Getter |
||||
|
private final HardwareType type; |
||||
|
/** |
||||
|
* 设备中文描述或显示名 |
||||
|
*/ |
||||
|
@Getter |
||||
|
private final String description; |
||||
|
|
||||
|
Device(HardwareType type, String description) { |
||||
|
this.type = type; |
||||
|
this.description = description; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return this.name(); |
||||
|
} |
||||
} |
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.iflytop.colortitration.common.enums; |
||||
|
|
||||
|
public enum HardwareType { |
||||
|
/** |
||||
|
* 步进电机 |
||||
|
*/ |
||||
|
STEPPER_MOTOR, |
||||
|
/** |
||||
|
* 伺服电机 |
||||
|
*/ |
||||
|
SERVO_MOTOR, |
||||
|
/** |
||||
|
* 通用传感器(温度、湿度等) |
||||
|
*/ |
||||
|
SENSOR, |
||||
|
/** |
||||
|
* IO 控制(阀门、风扇、加热器等) |
||||
|
*/ |
||||
|
IO_DEVICE, |
||||
|
/** |
||||
|
* 相机 |
||||
|
*/ |
||||
|
CAMERA; |
||||
|
|
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
package com.iflytop.colortitration.common.handler; |
||||
|
|
||||
|
import com.iflytop.colortitration.common.enums.Device; |
||||
|
import org.apache.ibatis.type.BaseTypeHandler; |
||||
|
import org.apache.ibatis.type.JdbcType; |
||||
|
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
|
import org.apache.ibatis.type.MappedTypes; |
||||
|
|
||||
|
import java.sql.CallableStatement; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.ResultSet; |
||||
|
import java.sql.SQLException; |
||||
|
|
||||
|
@MappedJdbcTypes(JdbcType.VARCHAR) |
||||
|
@MappedTypes(Device.class) |
||||
|
public class DeviceTypeHandler extends BaseTypeHandler<Device> { |
||||
|
|
||||
|
@Override |
||||
|
public void setNonNullParameter(PreparedStatement ps, int i, Device parameter, JdbcType jdbcType) throws SQLException { |
||||
|
ps.setString(i, parameter.name()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Device getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
|
String name = rs.getString(columnName); |
||||
|
return name == null ? null : Device.valueOf(name); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Device getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
|
String name = rs.getString(columnIndex); |
||||
|
return name == null ? null : Device.valueOf(name); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Device getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
|
String name = cs.getString(columnIndex); |
||||
|
return name == null ? null : Device.valueOf(name); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue