package com.fizz.business.controller;

import com.fizz.business.constants.enums.ExitCutTypeEnum;
import com.fizz.business.constants.enums.OpcMessageType;
import com.fizz.business.domain.msg.EntryMovementMessage;
import com.fizz.business.domain.msg.ExitCutMessage;
import com.fizz.business.domain.msg.ExitMeasureMessage;
import com.fizz.business.domain.msg.ExitMovementMessage;
import com.fizz.business.form.ModSetupResultForm;
import com.fizz.business.service.hanle.OpcReceiverHandler;
import com.fizz.business.vo.ModSetupResultVO;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

import static com.fizz.business.comm.OPC.MessageTestSchedule.measureReStart;
import static com.fizz.business.comm.OPC.MessageTestSchedule.measureStart;

@RestController
@RequestMapping("/api/msgtest")
@Tag(name ="通讯测试")
@Anonymous
public class MessageTestController {

    @Resource
    private OpcReceiverHandler opcReceiverHandler;

    @PostMapping("/entryMove")
    @Operation(summary = "入口移动信号")
    public void entryMove(@RequestBody EntryMovementMessage msg) {
        opcReceiverHandler.onMessageReceived(OpcMessageType.ENTRY_MOVEMENT,msg);
    }

    @PostMapping("/exitCut")
    @Operation(summary = "出口剪切信号")
    public void exitCut(@RequestBody ExitCutMessage msg) {
        opcReceiverHandler.onMessageReceived(OpcMessageType.EXIT_CUT,msg);
    }

    @PostMapping("/exitMove")
    @Operation(summary = "出口移动信号")
    public void exitMove(@RequestBody ExitMovementMessage msg) {
        opcReceiverHandler.onMessageReceived(OpcMessageType.EXIT_MOVEMENT,msg);
    }

    @PostMapping("/exitMeasure")
    @Operation(summary = "出口称重信号")
    public void exitMeasure(@RequestBody ExitMeasureMessage msg) {
        opcReceiverHandler.onMessageReceived(OpcMessageType.EXIT_MEASURE,msg);
    }

    @PostMapping("/lineMeasure/start")
    @Operation(summary = "测量信号-开始")
    public void lineMeasureStart() {
        measureStart = true;
    }

    @PostMapping("/lineMeasure/stop")
    @Operation(summary = "测量信号-停止")
    public void lineMeasureStop() {
        measureStart = false;
    }

    @PostMapping("/lineMeasure/restart")
    @Operation(summary = "测量信号-重置")
    public void lineMeasureRestart() {
        measureReStart = true;
    }
}
