严智鑫
2025-03-13 faa3b0410410415c4ad788c7e0955ef97158df2e
JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/plcTaskThread/MachineRotate.java
@@ -22,17 +22,19 @@
    private S7objectMachine s7objectMachine;
    public static Long machineId = 6L;
    public List<Map> sendRecords = new ArrayList<>();
    public Machine thisMachine;
    public MachineRotate(MachineMapper machineMapper, TaskingService taskingService){
    public MachineRotate(Machine machine,MachineMapper machineMapper, TaskingService taskingService){
        this.thisMachine = machine;
        this.machineMapper = machineMapper;
        this.taskingService = taskingService;
    }
    public void plcStart() {
        //旋转台
        Long machineId=20L;
        Machine machine=machineMapper.selectById(machineId);
        //Long machineId=20L;
        Machine machine=machineMapper.selectById(thisMachine.getId());
        if (s7objectMachine==null){
            s7objectMachine=new S7objectMachine(machine.getIp(),machine.getPort(),"PlcRotate", EPlcType.S1200);
            s7objectMachine=new S7objectMachine(machine.getIp(),machine.getPort(),machine.getFileName(), EPlcType.S1200);
            s7objectMachine.start();
        }
        PlcParameterObject plcParameterObject = s7objectMachine.PlcMesObject;
@@ -60,6 +62,7 @@
        if ("0".equals(plcRequest.getValue())&&!"0".equals(mesSend.getValue())) {
            //发送字置0
            int finishCount=taskingService.finishMachineTask(machine);
            nullMachine(machine);
            log.info("1.发送字置零,清除上次发送的数据{},{},{},{},{}"
                    ,finishCount
                    ,length.getValue()
@@ -71,6 +74,7 @@
            s7objectMachine.plccontrol.writeWord(mesSendId.getAddress(), 0);
            s7objectMachine.plccontrol.writeWord(rotateType.getAddress(), 0);
            s7objectMachine.plccontrol.writeWord(mesSend.getAddress(), 0);
            return;
        }
        if ("1".equals(plcRequestType.getValue())&&"0".equals(mesSendType.getValue())) {
@@ -101,8 +105,8 @@
                        ,tasking.getLength().intValue(),tasking.getWidth().intValue(),1);
                s7objectMachine.plccontrol.writeWord(length.getAddress(), tasking.getLength().intValue());
                s7objectMachine.plccontrol.writeWord(width.getAddress(), tasking.getWidth().intValue());
                s7objectMachine.plccontrol.writeString(mesSendId.getAddress(), tasking.getGlassId().toString());
                s7objectMachine.plccontrol.writeWord(rotateType.getAddress(), 1);
                s7objectMachine.plccontrol.writeString(mesSendId.getAddress(), tasking.getTaskSequence().toString());
                s7objectMachine.plccontrol.writeWord(rotateType.getAddress(), machine.getRotateMode());
                s7objectMachine.plccontrol.writeWord(mesSend.getAddress(), 1);
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String sendRecord=df.format(new Date())+"  "+
@@ -119,6 +123,8 @@
            }else if(!scan_id.isEmpty()){
                taskingService.scanMachineAdd(machine,scan_id);
            }
        }else if("0".equals(plcRequest.getValue())){
            nullMachine(machine);
        }
    }