|
@@ -125,11 +125,26 @@ public class CommSendService {
|
|
*/
|
|
*/
|
|
public void scheduledReadSim() {
|
|
public void scheduledReadSim() {
|
|
l.info("scheduledReadSim");
|
|
l.info("scheduledReadSim");
|
|
- if (isSocketOk()) {
|
|
|
|
- readAllAsync();
|
|
|
|
- } else {
|
|
|
|
- scheduledConnect();
|
|
|
|
|
|
+ //
|
|
|
|
+ try {
|
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
|
+ debugReadSimType("01");
|
|
|
|
+ }
|
|
|
|
+ debugReadAllFaultResistance("01", "0001");
|
|
|
|
+ debugClearAllFault("01", "0001");
|
|
|
|
+ debugWriteAllFault("01", "0001");
|
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
|
+ debugReadAllFaultResistance("01", "0001");
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// if (isSocketOk()) {
|
|
|
|
+// readAllAsync();
|
|
|
|
+// } else {
|
|
|
|
+// scheduledConnect();
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -278,8 +293,7 @@ public class CommSendService {
|
|
|
|
|
|
public List<SimMsg> debugClearAllFault(final String simNum, String simType) throws IOException {
|
|
public List<SimMsg> debugClearAllFault(final String simNum, String simType) throws IOException {
|
|
List<SimMsg> list = new ArrayList<>();
|
|
List<SimMsg> list = new ArrayList<>();
|
|
- String[] array = CommBuildService.CommConst.TYPE_1_BIND_MSG;
|
|
|
|
- for (String b : array) {
|
|
|
|
|
|
+ for (String b : CommBuildService.CommConst.TYPE_1_BIND_MSG) {
|
|
list.add(debugClearOneFault(simNum, b));
|
|
list.add(debugClearOneFault(simNum, b));
|
|
}
|
|
}
|
|
return list;
|
|
return list;
|
|
@@ -287,7 +301,7 @@ public class CommSendService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param s
|
|
* @param s
|
|
- * @param reF 可以为空,表示不关联考试的。
|
|
|
|
|
|
+ * @param reF 可以为空,表示不关联考试的,单独执行的。
|
|
* @param f
|
|
* @param f
|
|
*/
|
|
*/
|
|
public void clearOneFault(Sim s, RealExamFault reF, Fault f) {
|
|
public void clearOneFault(Sim s, RealExamFault reF, Fault f) {
|
|
@@ -324,6 +338,14 @@ public class CommSendService {
|
|
return new SimMsg(msg1, msg2);
|
|
return new SimMsg(msg1, msg2);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public List<SimMsg> debugWriteAllFault(final String simNum, String simType) throws IOException {
|
|
|
|
+ List<SimMsg> list = new ArrayList<>();
|
|
|
|
+ for (String b : CommBuildService.CommConst.TYPE_1_BIND_MSG) {
|
|
|
|
+ list.add(debugWriteOneFault(simNum, b));
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
public void writeOneFault(Sim s, RealExamFault ref, Fault f) {
|
|
public void writeOneFault(Sim s, RealExamFault ref, Fault f) {
|
|
l.info("下发故障:getSimId = {},fault.getName = {}", s.getSimId(), f.getName());
|
|
l.info("下发故障:getSimId = {},fault.getName = {}", s.getSimId(), f.getName());
|
|
try {
|
|
try {
|
|
@@ -378,6 +400,14 @@ public class CommSendService {
|
|
return new SimMsg(msg1, msg2);
|
|
return new SimMsg(msg1, msg2);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public List<SimMsg> debugReadAllFaultResistance(final String simNum, final String simType) throws IOException {
|
|
|
|
+ List<SimMsg> list = new ArrayList<>();
|
|
|
|
+ for (String b : CommBuildService.CommConst.TYPE_1_BIND_MSG) {
|
|
|
|
+ list.add(debugReadOneFaultResistance(simNum, b));
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
public void readOneFaultResistance(Sim s, RealExamFault reF, Fault f, String refState) {
|
|
public void readOneFaultResistance(Sim s, RealExamFault reF, Fault f, String refState) {
|
|
l.info("readOneFaultResistance");
|
|
l.info("readOneFaultResistance");
|
|
try {
|
|
try {
|
|
@@ -437,22 +467,16 @@ public class CommSendService {
|
|
}
|
|
}
|
|
//
|
|
//
|
|
{
|
|
{
|
|
- if (false) {
|
|
|
|
- try {
|
|
|
|
- // sleep ,追求顺序请求。
|
|
|
|
- Thread.sleep(CommBuildService.CommConst.SLEEP);
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
- }
|
|
|
|
|
|
+ try {
|
|
|
|
+ // sleep ,追求顺序请求。
|
|
|
|
+ Thread.sleep(CommBuildService.CommConst.SLEEP);
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//
|
|
//
|
|
|
|
+ openSocket();
|
|
String receiveMsg = null;
|
|
String receiveMsg = null;
|
|
- if (!isSocketOk()) {
|
|
|
|
- openSocket();
|
|
|
|
- l.warn("socket not open!");
|
|
|
|
- return "";
|
|
|
|
- }
|
|
|
|
InputStream is = cachedSocket.getInputStream();
|
|
InputStream is = cachedSocket.getInputStream();
|
|
OutputStream os = cachedSocket.getOutputStream();
|
|
OutputStream os = cachedSocket.getOutputStream();
|
|
os.write(hexStrToByteArrs(sendMsg));
|
|
os.write(hexStrToByteArrs(sendMsg));
|
|
@@ -476,11 +500,13 @@ public class CommSendService {
|
|
if (!commBuildService.checkReceiveMsg(receiveMsg)) {
|
|
if (!commBuildService.checkReceiveMsg(receiveMsg)) {
|
|
// todo:
|
|
// todo:
|
|
l.warn("checkReceiveMsg fail receiveMsg = {}", receiveMsg);
|
|
l.warn("checkReceiveMsg fail receiveMsg = {}", receiveMsg);
|
|
|
|
+ // closeSocket();
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
if (s != null) {
|
|
if (s != null) {
|
|
simService.updateLastReceivedTime(s);
|
|
simService.updateLastReceivedTime(s);
|
|
}
|
|
}
|
|
|
|
+ // closeSocket();
|
|
return receiveMsg;
|
|
return receiveMsg;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -520,6 +546,8 @@ public class CommSendService {
|
|
*/
|
|
*/
|
|
public void closeSocket() throws IOException {
|
|
public void closeSocket() throws IOException {
|
|
if (cachedSocket != null) {
|
|
if (cachedSocket != null) {
|
|
|
|
+ cachedSocket.getInputStream().close();
|
|
|
|
+ cachedSocket.getOutputStream().close();
|
|
cachedSocket.close();
|
|
cachedSocket.close();
|
|
}
|
|
}
|
|
cachedSocket = null;
|
|
cachedSocket = null;
|