|
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -34,6 +35,23 @@ public class ProbeService {
|
|
|
return probes;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建mock探针
|
|
|
+ */
|
|
|
+// @PostConstruct
|
|
|
+ private void initMockProbe() {
|
|
|
+ Probe a = new Probe((short) 0x0A,
|
|
|
+ 0x5e43bbbb000aL, 0x7F000001, 0xFFFF0000, (byte) 0x35, (byte) 0xAA, (byte) 0x1, (byte) 31,
|
|
|
+ (short) 32, (byte) 0x55, (byte) 0x2, (byte) 35, (short) 36, (byte) 0xAA, (byte) 0xAA,
|
|
|
+ (byte) 0xAA, (byte) 0xAA, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0xAA);
|
|
|
+ Probe b = new Probe((short) 0x0B,
|
|
|
+ 0x6c5a33d92137L, 0x7F000002, 0xFFFF0000, (byte) 0x3A, (byte) 0xAA, (byte) 0x0, (byte) 31,
|
|
|
+ (short) 32, (byte) 0x55, (byte) 0x3, (byte) 35, (short) 36, (byte) 0xAA, (byte) 0xAA,
|
|
|
+ (byte) 0xAA, (byte) 0xAA, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0xAA);
|
|
|
+ probes.put((short) 0x0A, a);
|
|
|
+ probes.put((short) 0x0B, b);
|
|
|
+ }
|
|
|
+
|
|
|
public void listenConfig(String typeStr, String modeStr) {
|
|
|
|
|
|
// byte mode;
|
|
@@ -72,11 +90,29 @@ public class ProbeService {
|
|
|
}
|
|
|
|
|
|
public List<ProbeDto> queryProbes() {
|
|
|
- Collection<Probe> valueCollection = probes.values();
|
|
|
+
|
|
|
+ //------------------
|
|
|
+ // 创建mock数据
|
|
|
+ Probe a = new Probe((short) 0x0A,
|
|
|
+ 0x5e43bbbb000aL, 0x7F000001, 0xFFFF0000, (byte) 0x35, (byte) 0xAA, (byte) 0x1, (byte) 31,
|
|
|
+ (short) 32, (byte) 0x55, (byte) 0x2, (byte) 35, (short) 36, (byte) 0xAA, (byte) 0xAA,
|
|
|
+ (byte) 0xAA, (byte) 0xAA, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0xAA);
|
|
|
+ Probe b = new Probe((short) 0x0B,
|
|
|
+ 0x6c5a33d92137L, 0x7F000002, 0xFFFF0000, (byte) 0x3A, (byte) 0xAA, (byte) 0x0, (byte) 31,
|
|
|
+ (short) 32, (byte) 0x55, (byte) 0x3, (byte) 35, (short) 36, (byte) 0xAA, (byte) 0xAA,
|
|
|
+ (byte) 0xAA, (byte) 0xAA, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0xAA);
|
|
|
List<ProbeDto> res = new ArrayList<>();
|
|
|
- for (Probe probe : valueCollection) {
|
|
|
- res.add(probe.toDto());
|
|
|
- }
|
|
|
+ res.add(a.toDto());
|
|
|
+ res.add(b.toDto());
|
|
|
+
|
|
|
+ // 以上为mock代码
|
|
|
+ //------------------
|
|
|
+ // 以下为原始正常代码
|
|
|
+// Collection<Probe> valueCollection = probes.values();
|
|
|
+// List<ProbeDto> res = new ArrayList<>();
|
|
|
+// for (Probe probe : valueCollection) {
|
|
|
+// res.add(probe.toDto());
|
|
|
+// }
|
|
|
return res;
|
|
|
}
|
|
|
|