|
|
@ -4,6 +4,7 @@ import cn.hutool.json.JSONObject; |
|
|
|
import com.qyft.ms.system.model.bo.DeviceCommand; |
|
|
|
import com.qyft.ms.system.service.device.DeviceCommandService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.Setter; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
/** |
|
|
@ -13,6 +14,12 @@ import org.springframework.stereotype.Service; |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class VirtualDeviceService { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
@Setter |
|
|
|
private volatile double humidity = 26; |
|
|
|
@Setter |
|
|
|
private volatile double slideTemperature = 27; |
|
|
|
@Setter |
|
|
|
private volatile double nozzleTemperature = 28; |
|
|
|
|
|
|
|
|
|
|
|
public void completeCommandResponse(DeviceCommand cmdToDevice) { |
|
|
@ -33,7 +40,7 @@ public class VirtualDeviceService { |
|
|
|
if (device.contains("humidity")) { |
|
|
|
if (action.contains("get")) {//获取温度 |
|
|
|
JSONObject data = new JSONObject(); |
|
|
|
data.putOnce("humidity", 26); |
|
|
|
data.putOnce("humidity", humidity); |
|
|
|
jsonObject.putOnce("data", data); |
|
|
|
} |
|
|
|
}else if (device.contains("device")) { |
|
|
@ -47,13 +54,13 @@ public class VirtualDeviceService { |
|
|
|
}else if (device.contains("slide_temperature")) { |
|
|
|
if (action.contains("get")) {//获取设备整体状态 |
|
|
|
JSONObject data = new JSONObject(); |
|
|
|
data.putOnce("temperature", 50); |
|
|
|
data.putOnce("temperature", slideTemperature); |
|
|
|
jsonObject.putOnce("data", data); |
|
|
|
} |
|
|
|
}else if (device.contains("nozzle_temperature")) { |
|
|
|
if (action.contains("get")) {//获取设备整体状态 |
|
|
|
JSONObject data = new JSONObject(); |
|
|
|
data.putOnce("temperature", 60); |
|
|
|
data.putOnce("temperature", nozzleTemperature); |
|
|
|
jsonObject.putOnce("data", data); |
|
|
|
} |
|
|
|
}else if (device.contains("xyz")) { |
|
|
|