wu
2024-05-29 e339917989dcd29c08a0000deb41f10ded43dd5d
增加联机状态,更改json文件位置
4个文件已修改
4个文件已添加
646 ■■■■■ 已修改文件
hangzhoumesParent/JsonFile/PlcCacheGlass.json 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/JsonFile/PlcCacheVerticalGlass.json 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/JsonFile/PlcLoadGlass.json 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/JsonFile/PlcdownGlass.json 362 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/WebSocketConfig.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/workstation/controller/UpWorkstationController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/workstation/service/impl/UpWorkstationServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/JsonFile/PlcCacheGlass.json
New file
@@ -0,0 +1,64 @@
{
   "plcAddressBegin":"DB11.0",
   "plcAddressLenght":"80",
   "dataType":"word",
   "parameteInfor":[
      {
         "codeId": "A06_request_word",
         "addressIndex":"0",
         "addressLenght":"2",
         "ratio":"1",
         "unit":"m/min"
      },
      {
          "codeId": "A05_scanning_ID",
          "addressIndex":"2",
          "addressLenght":"30",
          "ratio":"1",
          "unit":""
       },
       {
          "codeId": "Current_slot",
          "addressIndex":"36",
          "addressLenght":"2",
          "ratio":"1",
          "unit":""
       },
        {
          "codeId": "MES_confirmation_word",
          "addressIndex":"38",
          "addressLenght":"2",
          "ratio":"1",
          "unit":""
       },
       {
          "codeId": "A08_glass_status",
          "addressIndex":"68",
          "addressLenght":"2",
          "ratio":"1",
          "unit":""
       },
       {
          "codeId": "A10_glass_status",
          "addressIndex":"70",
          "addressLenght":"2",
          "ratio":"1",
          "unit":""
       },
       {
          "codeId": "A09_prohibit_film_production",
          "addressIndex":"72",
          "addressLenght":"2",
          "ratio":"1",
          "unit":""
       }
       ,
       {
          "codeId": "A10_prohibit_film_production",
          "addressIndex":"74",
          "addressLenght":"2",
          "ratio":"1",
          "unit":""
       }
   ]
}
hangzhoumesParent/JsonFile/PlcCacheVerticalGlass.json
New file
@@ -0,0 +1,57 @@
{
  "plcAddressBegin":"DB.0",
  "plcAddressLenght":"72",
  "dataType":"word",
  "parameteInfor":[
    {
      "codeId": "D01Request",
      "addressIndex":"0",
      "addressLenght":"2",
      "ratio":"1",
      "unit":"m/min"
    },
    {
      "codeId": "D01ID1",
      "addressIndex":"2",
      "addressLenght":"6",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "D04Request",
      "addressIndex":"8",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "D04ID1",
      "addressIndex":"10",
      "addressLenght":"6",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "D02Go",
      "addressIndex":"20",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "D05Go",
      "addressIndex":"22",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    }
  ,
    {
      "codeId": "DeviceStatus",
      "addressIndex":"70",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    }
  ]
}
hangzhoumesParent/JsonFile/PlcLoadGlass.json
New file
@@ -0,0 +1,78 @@
{
  "plcAddressBegin":"DB1.2000",
  "plcAddressLenght":"100",
  "dataType":"word",
  "parameteInfor":[
    {
      "codeId": "loadRequest",
      "addressIndex":"0",
      "addressLenght":"2",
      "ratio":"1",
      "unit":"m/min"
    },
    {
      "codeId": "PlcStatus",
      "addressIndex":"10",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "MesToPlc",
      "addressIndex":"20",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "InkageStatus",
      "addressIndex":"22",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "WorkId",
      "addressIndex":"24",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "GlassWidth",
      "addressIndex":"26",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "GlassHeight",
      "addressIndex":"28",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    }
  ,
    {
      "codeId": "MesToPlcStatus",
      "addressIndex":"40",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "MesToPlcStatusId",
      "addressIndex":"42",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    },
    {
      "codeId": "MesTaskStatus",
      "addressIndex":"56",
      "addressLenght":"2",
      "ratio":"1",
      "unit":""
    }
  ]
}
hangzhoumesParent/JsonFile/PlcdownGlass.json
New file
@@ -0,0 +1,362 @@
{
  "plcAddressBegin": "DB100.0",
  "plcAddressLenght": "142",
  "dataType": "word",
  "parameteInfor": [
    {
      "codeId": "RequestWord",
      "addressIndex": "0",
      "addressLenght": "2"
    },
    {
      "codeId": "G04ID",
      "addressIndex": "2",
      "addressLenght": "2"
    },
    {
      "codeId": "G06RobotTaskRequestWord",
      "addressIndex": "4",
      "addressLenght": "2"
    },
    {
      "codeId": "G06ID",
      "addressIndex": "6",
      "addressLenght": "2"
    },
    {
      "codeId": "G11RobotTaskRequestWord",
      "addressIndex": "8",
      "addressLenght": "2"
    },
    {
      "codeId": "G011ID",
      "addressIndex": "10",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "12",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "14",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "16",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "18",
      "addressLenght": "2"
    },
    {
      "codeId": "MESSendingWord",
      "addressIndex": "20",
      "addressLenght": "2"
    },
    {
      "codeId": "InputGrid",
      "addressIndex": "22",
      "addressLenght": "2"
    },
    {
      "codeId": "OutputGrid",
      "addressIndex": "24",
      "addressLenght": "2"
    },
    {
      "codeId": "OutputID",
      "addressIndex": "26",
      "addressLenght": "2"
    },
    {
      "codeId": "FrontOrRearLowerSlice",
      "addressIndex": "28",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "30",
      "addressLenght": "2"
    },
    {
      "codeId": "G06RobotTaskReply",
      "addressIndex": "32",
      "addressLenght": "2"
    },
    {
      "codeId": "G06Rack",
      "addressIndex": "34",
      "addressLenght": "2"
    },
    {
      "codeId": "G11RobotTaskReply",
      "addressIndex": "36",
      "addressLenght": "2"
    },
    {
      "codeId": "G11Rack",
      "addressIndex": "38",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "40",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "42",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "44",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "46",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "48",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "50",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "52",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "54",
      "addressLenght": "2"
    },
    {
      "codeId": "MESTaskState",
      "addressIndex": "56",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "58",
      "addressLenght": "2"
    },
    {
      "codeId": "AlarmState",
      "addressIndex": "60",
      "addressLenght": "2"
    },
    {
      "codeId": "Alarm1",
      "addressIndex": "62",
      "addressLenght": "2"
    },
    {
      "codeId": "Alarm2",
      "addressIndex": "64",
      "addressLenght": "2"
    },
    {
      "codeId": "Alarm3",
      "addressIndex": "66",
      "addressLenght": "2"
    },
    {
      "codeId": "Alarm4",
      "addressIndex": "68",
      "addressLenght": "2"
    },
    {
      "codeId": "neirong",
      "addressIndex": "70",
      "addressLenght": "2"
    },
    {
      "codeId": "device",
      "addressIndex": "72",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "74",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "76",
      "addressLenght": "2"
    },
    {
      "codeId": "InOut1",
      "addressIndex": "78",
      "addressLenght": "2"
    },
    {
      "codeId": "InOut2",
      "addressIndex": "80",
      "addressLenght": "2"
    },
    {
      "codeId": "InOut3",
      "addressIndex": "82",
      "addressLenght": "2"
    },
    {
      "codeId": "InOut4",
      "addressIndex": "84",
      "addressLenght": "2"
    },
    {
      "codeId": "InOut5",
      "addressIndex": "86",
      "addressLenght": "2"
    },
    {
      "codeId": "InOut6",
      "addressIndex": "88",
      "addressLenght": "2"
    },
    {
      "codeId": "InOut7",
      "addressIndex": "90",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "92",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "94",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "96",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "98",
      "addressLenght": "2"
    },
    {
      "codeId": "spare",
      "addressIndex": "100",
      "addressLenght": "2"
    },
    {
      "codeId": "G04ActionState",
      "addressIndex": "102",
      "addressLenght": "2"
    },
    {
      "codeId": "G05ActionState",
      "addressIndex": "104",
      "addressLenght": "2"
    },
    {
      "codeId": "G06ActionState",
      "addressIndex": "106",
      "addressLenght": "2"
    },
    {
      "codeId": "G07ActionState",
      "addressIndex": "108",
      "addressLenght": "2"
    },
    {
      "codeId": "G08ActionState",
      "addressIndex": "110",
      "addressLenght": "2"
    },
    {
      "codeId": "G09ActionState",
      "addressIndex": "112",
      "addressLenght": "2"
    },
    {
      "codeId": "G10ActionState",
      "addressIndex": "114",
      "addressLenght": "2"
    },
    {
      "codeId": "G11ActionState",
      "addressIndex": "116",
      "addressLenght": "2"
    },
    {
      "codeId": "G12ActionState",
      "addressIndex": "118",
      "addressLenght": "2"
    },
    {
      "codeId": "G13ActionState",
      "addressIndex": "120",
      "addressLenght": "2"
    },
    {
      "codeId": "G04IDS",
      "addressIndex": "122",
      "addressLenght": "2"
    },
    {
      "codeId": "G05IDS",
      "addressIndex": "124",
      "addressLenght": "2"
    },
    {
      "codeId": "G06IDS",
      "addressIndex": "126",
      "addressLenght": "2"
    },
    {
      "codeId": "G07IDS",
      "addressIndex": "128",
      "addressLenght": "2"
    },
    {
      "codeId": "G08IDS",
      "addressIndex": "130",
      "addressLenght": "2"
    },
    {
      "codeId": "G09IDS",
      "addressIndex": "132",
      "addressLenght": "2"
    },
    {
      "codeId": "G10IDS",
      "addressIndex": "134",
      "addressLenght": "2"
    },
    {
      "codeId": "G11IDS",
      "addressIndex": "136",
      "addressLenght": "2"
    },
    {
      "codeId": "G12IDS",
      "addressIndex": "138",
      "addressLenght": "2"
    },
    {
      "codeId": "G13ID",
      "addressIndex": "140",
      "addressLenght": "2"
    }
  ]
}
hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/WebSocketConfig.java
@@ -4,6 +4,9 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
 * @author SNG-010
 */
@Configuration
public class WebSocketConfig {
    /**
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java
@@ -47,33 +47,38 @@
    @Scheduled(fixedDelay = 300)
    public void plcLoadGlassTask() throws InterruptedException {
        try {
            //获取是否有上片请求
            String loadRequest = plcParameterObject.getPlcParameter("loadRequest").getValue();
            String mesToPlc = plcParameterObject.getPlcParameter("MesToPlc").getValue();
            //判断开始上片的工程号
            Engineering engineering = engineeringService.selectInitiate(1);
            if ("1".equals(loadRequest) && engineering != null) {
                log.info("开始上片任务");
                UpPattenUsage upPattenUsage = upWorkstationService.selectPriority(engineering);
                log.info("当有请求时查询当前上片顺序的玻璃信息{}", upPattenUsage);
                UpWorkstation upwork = upWorkstationService.selectWorkstation(upPattenUsage);
                log.info("符合的尺寸的工位玻璃:{}", upwork);
                if (upwork != null) {
                    int workId = upwork.getWorkstationId();//工位id
                    double width = upwork.getPatternWidth();//宽度
                    double height = upwork.getPatternHeight();//高度
                    S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("WorkId").getAddress(), workId);
                    S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("GlassWidth").getAddress(), (long) width);
                    S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("GlassHeight").getAddress(), (long) height);
                    S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 1);
                    //更改上片表状态
                    upPattenUsageService.updateUpPattenUsageState(upPattenUsage, workId);
            //获取联机状态
            String inkageStatus =plcParameterObject.getPlcParameter("MesToPlc").getValue();
            if("1".equals(inkageStatus)) {
                //获取是否有上片请求
                String loadRequest = plcParameterObject.getPlcParameter("loadRequest").getValue();
                String mesToPlc = plcParameterObject.getPlcParameter("MesToPlc").getValue();
                //判断开始上片的工程号
                Engineering engineering = engineeringService.selectInitiate(1);
                if ("1".equals(loadRequest) && engineering != null) {
                    log.info("开始上片任务");
                    UpPattenUsage upPattenUsage = upWorkstationService.selectPriority(engineering);
                    log.info("当有请求时查询当前上片顺序的玻璃信息{}", upPattenUsage);
                    UpWorkstation upwork = upWorkstationService.selectWorkstation(upPattenUsage);
                    log.info("符合的尺寸的工位玻璃:{}", upwork);
                    if (upwork != null) {
                        int workId = upwork.getWorkstationId();//工位id
                        double width = upwork.getPatternWidth();//宽度
                        double height = upwork.getPatternHeight();//高度
                        S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("WorkId").getAddress(), workId);
                        S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("GlassWidth").getAddress(), (long) width);
                        S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("GlassHeight").getAddress(), (long) height);
                        S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 1);
                        //更改上片表状态
                        upPattenUsageService.updateUpPattenUsageState(upPattenUsage, workId);
                    }
                }
            }
            if("1".equals(mesToPlc)&& "0".equals(loadRequest)){
                //请求字为零时,任务字清零
                S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 0);
                if ("1".equals(mesToPlc) && "0".equals(loadRequest)) {
                    //请求字为零时,任务字清零
                    S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 0);
                }
            }
            //执行后休眠300毫秒
            //Thread.sleep(300);
@@ -135,6 +140,29 @@
            }
        }
    }
    @Scheduled(fixedDelay = 5000)
    public void loadGlassStatus(){
        JSONObject jsonObject = new JSONObject();
        //正在进行的任务
        //String inkageStatus =plcParameterObject.getPlcParameter("MesToPlc").getValue();
        String inkageStatus ="1";
        jsonObject.append("InkageStatus", inkageStatus);
        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("loadGlass");
        if (sendwServer != null) {
            for (WebSocketServer webserver : sendwServer) {
                if (webserver != null) {
                    webserver.sendMessage(jsonObject.toString());
                    List<String> messages = webserver.getMessages();
                    if (!messages.isEmpty()) {
                        // // 将最后一个消息转换为整数类型的列表
                        webserver.clearMessages();
                    }
                } else {
                    log.info("Home is closed");
                }
            }
        }
    }
    public void overTask(String loadStatus, int state)  {
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/workstation/controller/UpWorkstationController.java
@@ -53,6 +53,7 @@
    public Result<String> updateMesInkageLoad(@RequestBody short inKageWord) {
        String result = upWorkstationService.updateMesInkageLoad(inKageWord);
        return Result.success(result);
    }
}
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/workstation/service/impl/UpWorkstationServiceImpl.java
@@ -92,7 +92,8 @@
        PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
        log.info("修改设备联动请求为{}:0离线;1联动", inKageWord);
        S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("InkageStatus").getAddress(), inKageWord);
        return "success";
        //读取plc的值
        return plcParameterObject.getPlcParameter("InkageStatus").getValue();
    }
}