package com.ruoyi.sim.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.sim.domain.RealExam;
import com.ruoyi.sim.service.impl.CommSendService;
import com.ruoyi.sim.service.impl.MajorService;
import com.ruoyi.sim.service.impl.RealExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sim/iot")
@Api("测试通信Controller")
public class TestIotController extends BaseController {

    @Autowired
    private MajorService majorService;
    @Autowired
    private CommSendService commSnedService;
    @Autowired
    private RealExamService realExamService;

    @ApiOperation("testIot通信")
    @GetMapping(value = "/{codeId}")
    public AjaxResult testIndex(@PathVariable("codeId") Integer codeId) {

        long examId = 2L;
        switch (codeId) {
            case 1: {
                commSnedService.checkAllSimState();
            }
            break;
            case 2: {
                // commSnedService.clearOneFault(null, null, null);
            }
            break;
            case 3: {
                // commSnedService.readOneFaultResistance(null, null);
            }
            break;
            case 4: {
                // commSnedService.writeOneFault(null, null, null);
            }
            break;
            case 5: {
//                for (int i = 0; i < 100; i++) {
//                    commSnedService.readOneFaultResistance(null, null);
//                }
            }
            break;
            case 6: {
                RealExam re = realExamService.selectRealExamByExamId(1L);
                commSnedService.clearListFaultByRealExam(re);
            }
            break;
            case 7: {
                commSnedService.test();
            }
            break;
            case 10: {
                commSnedService.checkAllSimState();
                commSnedService.clearAll();
                RealExam re = realExamService.selectRealExamByExamId(1L);
                commSnedService.clearListFaultByRealExam(re);
            }
            break;
            case 11: {
                commSnedService.readAll();
            }
            break;
            case 12: {
                RealExam re = realExamService.selectRealExamByExamId(1L);
                commSnedService.readOneExamAtLast(re);
                //
            }
            break;

            case 20: {
                realExamService.studentEnterRealExam(examId);
                //
            }
            break;
            case 21: {
                realExamService.studentLoopPrepareRealExam(examId);
                //
            }
            break;
            case 22: {
                realExamService.studentStartRealExam(examId);
                //
            }
            break;
            case 23: {
                realExamService.studentLoopAnsweringRealExam(examId);
                //
            }
            break;
            case 24: {
                realExamService.studentSubmitRealExam(examId);
                //
            }
            break;
            case 25: {
                realExamService.studentLoopPostRealExam(examId);
                //
            }
            break;
        }
        return AjaxResult.success();
    }
}
