ソースを参照

添加原生命令调试。

tom 2 ヶ月 前
コミット
f1c898fc8c

+ 2 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/constant/FaultConst.java

@@ -19,6 +19,8 @@ public class FaultConst {
     static {
         {
             // 1型
+            // todo:不应该
+            // FAULT_SET_CHECK_PASS.add("0001GZBW0006");
             // 1型不存在
             // 2型
             FAULT_SET_CHECK_PASS.add("0002GZBW0001");

+ 9 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/HardwareCommDebugController.java

@@ -135,7 +135,7 @@ public class HardwareCommDebugController extends BaseController {
         return AjaxResult.success();
     }
 
-    @GetMapping(value = "/buildMsg/")
+    @GetMapping(value = "/buildSendMsgAR/")
     @ApiOperation("拼写带CRC16校验的命令,但是不发送")
     public AjaxResult buildSendMsg(@RequestParam final String simNum,
                                    @RequestParam final String orn,
@@ -145,7 +145,7 @@ public class HardwareCommDebugController extends BaseController {
         return commBuildService.buildSendMsgAR(simNum, orn, cmd, cmdId, data);
     }
 
-    @GetMapping(value = "/buildMsgAndSend/{seatId}")
+    @GetMapping(value = "/buildSendMsgAndSendAR/{seatId}")
     @ApiOperation("拼写带CRC16校验的命令,并发送,返回响应结果")
     public AjaxResult buildMsgAndSend(@PathVariable("seatId") final Long seatId,
                                       @RequestParam final String simNum,
@@ -156,6 +156,13 @@ public class HardwareCommDebugController extends BaseController {
         return commBuildService.buildSendMsgAndSendAR(seatId, simNum, orn, cmd, cmdId, data);
     }
 
+    @GetMapping(value = "/buildSendRawMsgAndSendAR/{seatId}")
+    @ApiOperation(" 拼写带CRC16校验的原生命令,并发送,返回响应结果")
+    public AjaxResult buildMsgAndSend(@PathVariable("seatId") final Long seatId,
+                                      @RequestParam final String raw) {
+        return commBuildService.buildSendRawMsgAndSendAR(seatId, raw);
+    }
+
     /**
      * todo:
      *

+ 20 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/RealExamFault.java

@@ -214,12 +214,32 @@ public class RealExamFault extends BaseEntity {
     /**
      * 选中Yes:0 1 2 4
      * 未选中No:0 1 3 4
+     * <p>
+     * <p>
+     * 选中Yes的故障:0 1 2 3 4
+     * 未选中No:0 1 2 3 4
+     * 故障ID关联状态:[0]-初始化,[1]-已经清除故障,[2]-故障已经下发~出题值填充,[3]-轮询读取~中间答题值填充,[4]-交卷~最终答题值填充
      */
     public interface State {
+        /**
+         * [0]-初始化
+         */
         String INIT = "0";
+        /**
+         * [1]-已经清除故障
+         */
         String CLEARED = "1";
+        /**
+         * [2]-故障已经下发~出题值填充
+         */
         String WRITTEN = "2";
+        /**
+         * [3]-轮询读取~中间答题值填充
+         */
         String LOOP_READ = "3";
+        /**
+         * [4]-交卷~最终答题值填充
+         */
         // todo: String LAST_READED
         String FINISH = "4";
     }

+ 4 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/SimMsg.java

@@ -264,7 +264,8 @@ public class SimMsg extends BaseEntity {
 
     public AjaxResult getDefaultErrorAR() {
         if (Objects.equals(this.result, Result.SUCCESS)) {
-            throw new IllegalArgumentException("参数错误!");
+            // throw new IllegalArgumentException("错误执行!先判断消息对错!");
+            return AjaxResult.success("");
         } else if (Objects.equals(this.result, Result.SOCKET_CONNECT_EXCEPTION)) {
             return AjaxResult.error("模拟器通信连接失败!");
         } else if (Objects.equals(this.result, Result.READ_TIMEOUT_EXCEPTION)) {
@@ -274,8 +275,9 @@ public class SimMsg extends BaseEntity {
         } else if (Objects.equals(this.result, Result.RECEIVE_NOT_MATCH)) {
             return AjaxResult.error("回复报文不匹配!");
         } else {
-            throw new IllegalArgumentException("参数错误!");
+            // throw new IllegalArgumentException("参数错误!");
         }
+        return null;
     }
 
     public interface Result {

+ 18 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommBuildService.java

@@ -169,7 +169,7 @@ public class CommBuildService {
     }
 
     /**
-     * 拼写带CRC16校验的命令,但是不发送
+     * 拼写带CRC16校验的命令,并发送,返回响应结果
      *
      * @param simNum
      * @param orn
@@ -185,4 +185,21 @@ public class CommBuildService {
         SimMsg smR = commSendService.send(smS, seat, sim, 0, 1000L);
         return AjaxResult.success(smR);
     }
+
+    /**
+     * 拼写带CRC16校验的原生命令,并发送,返回响应结果
+     *
+     * @param seatId
+     * @param raw
+     * @return
+     */
+    public AjaxResult buildSendRawMsgAndSendAR(final Long seatId, final String raw) {
+        SimMsg smS = new SimMsg();
+        smS.setSimMsgId(idService.nextId());
+        smS.setSendMsg(raw);
+        Seat seat = seatService.selectSeatBySeatId(seatId);
+        Sim sim = commSendService.getSimBySeatIdNewVer(seatId);
+        SimMsg smR = commSendService.send(smS, seat, sim, 0, 1000L);
+        return AjaxResult.success(smR);
+    }
 }

+ 13 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java

@@ -426,7 +426,7 @@ public class RealExamService {
         Sim sim = simService.selectSimBySimId(re.getSimId());
         // Check:检查模拟器类型
         final String targetSimType = re.getSimType();
-        {
+        if (false) {
             AjaxResult ar = commCheckService.checkOneSimType(seat, true, targetSimType);
             if (ar.isError()) {
                 return ar;
@@ -660,4 +660,16 @@ public class RealExamService {
         vo.setPart3(realExamFaultService.getReportPart3(examId));
         return AjaxResult.success(vo);
     }
+
+    /**
+     * [学员]登录成功后调用
+     *
+     * @param userId
+     * @param ip
+     * @return
+     */
+    public AjaxResult studentLoginSuccess(final Long userId, final String ip) {
+        
+        return AjaxResult.success();
+    }
 }