You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.3 KiB
95 lines
3.3 KiB
package com.iflytop.sgs.hardware.service;
|
|
|
|
import com.iflytop.sgs.common.service.GDDeviceStatusService;
|
|
import com.iflytop.sgs.hardware.drivers.DIDriver.InputDetectDriver;
|
|
import com.iflytop.sgs.hardware.drivers.HeaterRodDriver;
|
|
import com.iflytop.sgs.hardware.drivers.LeisaiServoDriver;
|
|
import com.iflytop.sgs.hardware.drivers.MiniServoDriver.MiniServoDriver;
|
|
import com.iflytop.sgs.hardware.drivers.StepMotorDriver.StepMotorCtrlDriver;
|
|
import com.iflytop.sgs.hardware.exception.HardwareException;
|
|
import com.iflytop.sgs.hardware.type.IO.InputIOMId;
|
|
import com.iflytop.sgs.hardware.type.Servo.LeisaiServoMId;
|
|
import com.iflytop.sgs.hardware.type.StepMotor.StepMotorMId;
|
|
import com.iflytop.sgs.hardware.type.driver.HeaterRodSlavedId;
|
|
import com.iflytop.sgs.hardware.utils.Math.StepMotorConverter;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Slf4j
|
|
@Component
|
|
@RequiredArgsConstructor
|
|
public class GDDeviceStatusServiceImpl implements GDDeviceStatusService {
|
|
private final InputDetectDriver inputDetectDriver;
|
|
private final HeaterRodDriver heaterRodDriver;
|
|
private final StepMotorCtrlDriver stepMotorCtrlDriver;
|
|
private final MiniServoDriver miniServoDriver;
|
|
private final LeisaiServoDriver leisaiServoDriver;
|
|
|
|
/**
|
|
* 获取步进电机的原点状态
|
|
* @param stepMotorMId
|
|
* @return true 在原点 false 不在原点
|
|
*/
|
|
public Boolean stepMotorIsOrigin(StepMotorMId stepMotorMId) throws HardwareException {
|
|
return stepMotorCtrlDriver.stepMotorReadIoState(stepMotorMId, 0);
|
|
}
|
|
|
|
/**
|
|
* 获取XY 伺服的原点状态
|
|
* @param mid
|
|
* @return
|
|
* @throws HardwareException
|
|
*/
|
|
public Boolean getXYServoIsOrigin(LeisaiServoMId mid) throws HardwareException
|
|
{
|
|
return leisaiServoDriver.readIoState(mid, 0);
|
|
}
|
|
|
|
/**
|
|
* 获取传感器信号
|
|
* @param inputIOMIdStr
|
|
* @return
|
|
* @throws HardwareException
|
|
*/
|
|
public Boolean getInputState(String inputIOMIdStr) throws HardwareException {
|
|
InputIOMId inputIOMId = InputIOMId.valueOf(inputIOMIdStr);
|
|
return inputDetectDriver.getIOState(inputIOMId);
|
|
}
|
|
|
|
/**
|
|
* 获取加热棒温度
|
|
* @param heaterRodSlavedIdStr
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public Double getHeaterRodTemperature(String heaterRodSlavedIdStr) throws Exception {
|
|
HeaterRodSlavedId heaterRodSlavedId=HeaterRodSlavedId.valueOf(heaterRodSlavedIdStr);
|
|
return heaterRodDriver.getTemperature(heaterRodSlavedId);
|
|
}
|
|
|
|
/**
|
|
* 获取电机位置
|
|
* @param stepMotorMIdStr
|
|
* @return
|
|
* @throws HardwareException
|
|
*/
|
|
public Double getStepMotorPostion(String stepMotorMIdStr) throws HardwareException {
|
|
StepMotorMId stepMotorMId=StepMotorMId.valueOf(stepMotorMIdStr);
|
|
Integer motorPosition = stepMotorCtrlDriver.stepMotorReadPos(stepMotorMId);
|
|
Double realPosition = StepMotorConverter.toUserPosition(motorPosition);
|
|
return realPosition;
|
|
}
|
|
|
|
/**
|
|
* 获取伺服类电机位置
|
|
* @param mid
|
|
* @return
|
|
* @throws HardwareException
|
|
*/
|
|
public Double getXYServoPosition(LeisaiServoMId mid) throws HardwareException {
|
|
int servoPosition = leisaiServoDriver.readPosition(mid);
|
|
return StepMotorConverter.toUserPosition(servoPosition);
|
|
}
|
|
|
|
}
|