|
|
@ -1,13 +1,19 @@ |
|
|
|
package com.iflytop.gd.app.service.api; |
|
|
|
|
|
|
|
import com.iflytop.gd.app.model.dto.AllSensorDTO; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceCommandService; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceStateService; |
|
|
|
import com.iflytop.gd.common.command.CommandFuture; |
|
|
|
import com.iflytop.gd.common.command.DeviceCommandBundle; |
|
|
|
import com.iflytop.gd.common.command.DeviceCommandGenerator; |
|
|
|
import com.iflytop.gd.common.enums.HeatModuleCode; |
|
|
|
import com.iflytop.gd.common.enums.HeatingType; |
|
|
|
import com.iflytop.gd.common.utils.CommandUtil; |
|
|
|
import com.iflytop.gd.hardware.exception.HardwareException; |
|
|
|
import com.iflytop.gd.hardware.service.GDDeviceStatusService; |
|
|
|
import com.iflytop.gd.hardware.type.IO.InputIOMId; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
@ -16,11 +22,13 @@ import java.util.List; |
|
|
|
/** |
|
|
|
* 测试用 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class TestService { |
|
|
|
private final GDDeviceStatusService gdDeviceStatusService; |
|
|
|
private final DeviceStateService deviceStateService; |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
|
|
|
|
public List<AllSensorDTO> getAllSensor() throws HardwareException { |
|
|
|
List<AllSensorDTO> allSensorDTOList = new ArrayList<>(); |
|
|
@ -56,4 +64,26 @@ public class TestService { |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(code).setTrayStatus(trayStatus); |
|
|
|
} |
|
|
|
|
|
|
|
public void countPackage() throws Exception { |
|
|
|
long startTime = System.nanoTime(); |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.fan1Open(); |
|
|
|
long endTime = System.nanoTime(); |
|
|
|
long duration = endTime - startTime; |
|
|
|
double milliseconds = duration / 1_000_000.0; |
|
|
|
log.info("指令包装时间:{}",milliseconds); |
|
|
|
startTime = System.nanoTime(); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(deviceCommand); |
|
|
|
endTime = System.nanoTime(); |
|
|
|
duration = endTime - startTime; |
|
|
|
milliseconds = duration / 1_000_000.0; |
|
|
|
log.info("指令发送时间:{}",milliseconds); |
|
|
|
CommandUtil.wait(deviceCommandFuture); |
|
|
|
endTime = System.nanoTime(); |
|
|
|
duration = endTime - startTime; |
|
|
|
milliseconds = duration / 1_000_000.0; |
|
|
|
log.info("指令反馈时间:{}",milliseconds); |
|
|
|
deviceCommand = DeviceCommandGenerator.fan1Close(); |
|
|
|
deviceCommandService.sendCommand(deviceCommand); |
|
|
|
} |
|
|
|
|
|
|
|
} |