package com.youchain.modules.quartz.task;

import com.github.s7connector.api.S7Connector;
import com.youchain.businessdata.rest.MoController;
import com.youchain.businessdata.rest.PlcController;
import com.youchain.businessdata.service.TaskService;
import com.youchain.utils.S7ConnectorUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class plcTask {

    private final PlcController plcController;

    @Autowired
    public plcTask(PlcController plcController) {
        this.plcController = plcController;
    }

    public void plcTask() {
        try {
            S7Connector connector = S7ConnectorUtils.connect();
            String mo = S7ConnectorUtils.readMo(connector);
            plcController.scanMo(mo);
        } catch (Exception e) {
            throw new RuntimeException("异常信息" + e.getMessage());
        }
    }
}
