hangzhoumesParent/moduleService/LoadGlassModule/pom.xml
@@ -9,7 +9,7 @@ </parent> <modelVersion>4.0.0</modelVersion> <artifactId>cacheGlass</artifactId> <artifactId>loadGlass</artifactId> <dependencies> <dependency> <groupId>junit</groupId> hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/LoadGlassModuleApplication.java
@@ -23,6 +23,7 @@ SpringApplication.run(LoadGlassModuleApplication.class, args); } catch (Exception e) { log.error(e.getMessage()); } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/InitUtil.java
New file @@ -0,0 +1,122 @@ package com.mes.common; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.List; public class InitUtil { //初始化word public static PlcParameterObject initword(String jsonFilePath) { try { FileReader fileReader = new FileReader(jsonFilePath); BufferedReader bufferedReader = new BufferedReader(fileReader); StringBuilder content = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { content.append(line); } bufferedReader.close(); fileReader.close(); JSONObject jsonfileobj = new JSONObject(content.toString()); JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor"); PlcParameterObject plcParameterObject = new PlcParameterObject(); plcParameterObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址 plcParameterObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度 for (int i = 0; i < jsonArray.size(); i++) { JSONObject parameterObj = jsonArray.getJSONObject(i); PlcParameterInfo plcParameterInfo = new PlcParameterInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例 String codeid = parameterObj.getStr("codeId"); plcParameterInfo.setCodeId(codeid); plcParameterInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex"))); //plcParameterInfo.setRatio(Integer.valueOf(parameterObj.getStr("ratio"))); plcParameterInfo.setAddressLength(Integer.valueOf(parameterObj.getStr("addressLenght"))); plcParameterInfo.setUnit(parameterObj.getStr("unit")); plcParameterObject.addPlcParameter(plcParameterInfo); } // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02}; // byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); // plcParameterObject.setPlcParameterList(getplcvlues); return plcParameterObject; } catch (IOException e) { e.printStackTrace(); } return null; } //初始化bit public static PlcBitObject initbit(String jsonFilePath) { PlcBitObject plcBitObject = new PlcBitObject(); try { FileReader fileReader = new FileReader(jsonFilePath); BufferedReader bufferedReader = new BufferedReader(fileReader); StringBuilder content = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { content.append(line); } bufferedReader.close(); fileReader.close(); JSONObject jsonfileobj = new JSONObject(content.toString()); JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor"); plcBitObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址 plcBitObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度 for (int i = 0; i < jsonArray.size(); i++) { JSONObject parameterObj = jsonArray.getJSONObject(i); PlcBitInfo plcBitInfo = new PlcBitInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例 String codeid = parameterObj.getStr("codeId"); plcBitInfo.setCodeId(codeid); plcBitInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex"))); plcBitObject.addPlcBit(plcBitInfo); } System.out.println(""); } catch (IOException e) { e.printStackTrace(); } //Boolean[] values1 = { false, true, true, true, false, false, true, false, // false, true ,true }; // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1)); // List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength()); // plcBitObject.setPlcBitList(getplcvlues); return plcBitObject; } // public static void readAndUpdateBitValues(PlcBitObject plcBitObject) { // Boolean[] values1 = { false, true, true, true, false, false, true, false, // false, true ,true }; // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1)); List<Boolean> getplcvlues = S7object.getinstance().plccontrol.ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength()); plcBitObject.setPlcBitList(getplcvlues); } public static void readAndUpdateWordValues(PlcParameterObject plcParameterObject) { // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02}; byte[] getplcvlues = S7object.getinstance().plccontrol.ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); plcParameterObject.setPlcParameterList(getplcvlues); } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/PLCAutoMes.java
New file @@ -0,0 +1,95 @@ package com.mes.common; import java.io.IOException; import static com.mes.common.InitUtil.readAndUpdateWordValues; public class PLCAutoMes extends Thread { // // 用于存储应用程序的配置信息 // private Configuration config; private static InitUtil initUtil; // public static PlcParameterObject PlcMesObject; // public static PlcParameterObject PlcReadObject; // public static PlcParameterObject PlcframeObject; // // 创建一个自定义的 S7 控制器消息处理器对象 // MessageHandler customS7Control = new MessageHandler(); // 单例实例 private static PLCAutoMes instance; // private static String PlcMes = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath(); private static String PlcAlbania = PLCAutoMes.class.getResource("/JsonFile/PlcLoadGlass.json").getPath(); // private static String PlcRead = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath(); // private static String Plcframe = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath(); // private static String PlcParameter = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcParameter.json").getPath(); // private static String PlcSign = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcSign.json").getPath(); // private static String PlcState = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json").getPath(); // private static String PlcAlarm = PLCAutoMes.class.getResource("/JsonFile/PlcAlarm.json").getPath(); // private static String PlcTest = PLCAutoMes.class.getResource("/JsonFile/PlcTest.json").getPath(); // 调用initword方法 // public static PlcParameterObject plcParameterObject = initUtil.initword(PlcParameter); // public static PlcBitObject plcPlcTest = initUtil.initbit(PlcTest); // public static PlcBitObject plcBitObject = initUtil.initbit(PlcSign); // public static PlcParameterObject plcStateObject= initUtil.initword(PlcState); // public static PlcBitObject plcPlcAlarm = initUtil.initbit(PlcAlarm); public static PlcParameterObject PlcMesObject = InitUtil.initword(PlcAlbania); // public static PlcParameterObject PlcReadObject = initUtil.initword(PlcRead); // public static PlcParameterObject PlcframeObject = initUtil.initword(Plcframe); // 私有构造函数 public PLCAutoMes() throws IOException { //config = new Configuration("config.properties"); initUtil = new InitUtil(); } // 获取单例实例 public static synchronized PLCAutoMes getInstance() throws IOException { if (instance == null) { instance = new PLCAutoMes(); } return instance; } @Override public void run() { while (this != null) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } // System.out.println(jsonFilePath); //readAndUpdateWordValues(PlcReadObject); readAndUpdateWordValues(PlcMesObject); //readAndUpdateWordValues(PlcframeObject); // readAndUpdateWordValues(PlcframeObject); // readAndUpdateWordValues(plcStateObject); // int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex(); // // System.out.println(index); // PlcMesObject.getPlcParameter("AddStart").getAddress(index); // // System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index)); // List<String> addresses = new ArrayList<>(); // addresses.add("FeedID"); // addresses.add("AddStart"); // // System.out.println(addresses); // // System.out.println(PlcMesObject.getPlcParameterValues(addresses)); // List<String> addresses2 = new ArrayList<>(); // addresses2.add("FeedID"); // addresses2.add("FeedCarStatus"); //System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); } } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/PlcBitInfo.java
New file @@ -0,0 +1,77 @@ package com.mes.common; public class PlcBitInfo { public PlcBitInfo(String startAddress) { this.startAddress = startAddress; } private String startAddress; // 参数标识 private String codeId; // 参数名称 private String name; // 读取 参数值 private Boolean value; // 参数地址 private int addressIndex; public String getCodeId() { return this.codeId; } public void setCodeId(String codeId) { this.codeId = codeId; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public Boolean getValue() { return this.value; } public void setValue(Boolean value) { this.value = value; } public int getAddressIndex() { return this.addressIndex; } /** * 获取地址 * * @param index 索引地址 */ public String getAddress(int index) { String[] stringdatas = this.startAddress.trim().split("\\."); if (stringdatas.length < 2 ) return null; int dbwindex = 0; int bitindex = 0; if (stringdatas.length == 3) { dbwindex = Integer.parseInt(stringdatas[1]); bitindex = Integer.parseInt(stringdatas[2]); } else return null; dbwindex+=index/8; bitindex+=index%8; return stringdatas[0]+"."+dbwindex+"."+bitindex; } public void setAddressIndex(int addressindex) { this.addressIndex = addressindex; } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/PlcBitObject.java
New file @@ -0,0 +1,142 @@ package com.mes.common; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class PlcBitObject { // 该模块数据类型,数据起始位置 private String plcAddressBegin; // 数据地址长度:第一参数到最后一个参数的长度 private int plcAddressLength; private ArrayList<PlcBitInfo> plcBitList; /** * @return 数据区开始地址 */ public String getPlcAddressBegin() { return plcAddressBegin; } /** * @param plcAddressBegin 设置数据区开始地址 */ public void setPlcAddressBegin(String plcAddressBegin) { this.plcAddressBegin = plcAddressBegin; } /** * @return 数据区 读取所有数据所需的长度(以byte类型为基准) */ public int getPlcAddressLength() { return plcAddressLength; } /** * @return 设置:数据区 读取所有数据所需的长度(以byte类型为基准) */ public void setPlcAddressLength(int plcAddressLength) { this.plcAddressLength = plcAddressLength; } /** * @return 获取参数实例集合 */ public ArrayList<PlcBitInfo> getBitList() { return plcBitList; } /** * 根据参数标识 获取某个参数实例 * * @param codeid 参数标识 * @return 获取某个参数实例 */ public PlcBitInfo getPlcBit(String codeid) { if (plcBitList != null) { for (PlcBitInfo plcbitInfo : plcBitList) { if (plcbitInfo.getCodeId().equals(codeid)) return plcbitInfo; } return null; } else return null; } /** * 根据参数标识 获取某个参数实例 * * @param codeid 参数标识 * @return 获取某个参数实例 */ public List<Boolean> getPlcBitValues(List<String> codeids) { List<Boolean> arrayList = new ArrayList<>(); if (plcBitList != null) { Map<String, Boolean> resultMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 保留插入顺序 for (PlcBitInfo plcBitInfo : plcBitList) { if (codeids.contains(plcBitInfo.getCodeId().toString())) { resultMap.put(plcBitInfo.getCodeId().toString(), plcBitInfo.getValue()); } } for (String codeId : codeids) { // 按照传入参数的顺序遍历 Boolean value = resultMap.get(codeId); if (value != null) { arrayList.add(value); } else { arrayList.add(null); // 如果找不到对应的值,添加 null } } } return arrayList; } public List<String> getAddressListByCodeId(List<String> codeIdList) { List<String> addressList = new ArrayList<>(); for (String codeId : codeIdList) { for (PlcBitInfo plcBitInfo : plcBitList) { if (plcBitInfo.getCodeId().equals(codeId)) { int index = plcBitInfo.getAddressIndex(); String address = plcBitInfo.getAddress(index); if (address != null) { addressList.add(address); } } } } return addressList; } /** * 添加参数实例 * * @param param 参数实例 */ public void addPlcBit(PlcBitInfo param) { if (plcBitList != null) plcBitList.add(param); else { plcBitList = new ArrayList<PlcBitInfo>(); plcBitList.add(param); } } /** * 根据PLC返回的数据 给参数实例赋值 * * @param plcValueArray PLC读取回来的byte类型数据集合 */ public void setPlcBitList(List<Boolean> plcValueArray) { if (plcBitList != null) { for (PlcBitInfo plcbitInfo : plcBitList) { plcbitInfo.setValue(plcValueArray.get(plcbitInfo.getAddressIndex())); } } } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/PlcParameterInfo.java
New file @@ -0,0 +1,128 @@ package com.mes.common; public class PlcParameterInfo { public PlcParameterInfo(String startAddress) { this.startAddress = startAddress; } private String startAddress; // 参数标识 private String codeId; // 参数名称 private String name; // 读取 参数值 private String value; // // 写入 参数值 // private String writeValue; // 参数单位 private String unit; // 参数值转换系数 private int ratio; // 参数地址 private int addressIndex; // 参数地址位长度 private int addressLength; public String getCodeId() { return this.codeId; } public void setCodeId(String codeId) { this.codeId = codeId; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getValue() { return this.value; } public void setValue(String value) { this.value = value; } // public String getWriteValue() { // return this.writeValue; // } // public void setWriteValue(String writeValue) { // this.writeValue = writeValue; // } public String getUnit() { return this.unit; } public void setUnit(String unit) { this.unit = unit; } public int getAddressIndex() { return this.addressIndex; } public void setAddressIndex(int addressindex) { this.addressIndex = addressindex; } public int getAddressLength() { return this.addressLength; } public void setAddressLength(int addresslength) { this.addressLength = addresslength; } public int getRatio() { return this.ratio; } public void setRatio(int ratio) { this.ratio = ratio; } /** * 获取地址 * * @param index 索引地址 */ public String getAddress(int index) { String[] stringdatas = this.startAddress.trim().split("\\."); int addressLength=this.addressLength; if (addressLength < 2 ){ return null; } if (addressLength == 2 ) { int wordindex = index; return stringdatas[0] + "." + wordindex; } if (addressLength == 14 ) { int wordindex = index; //int newIndex = wordindex + 13; return stringdatas[0] + "." + wordindex ; } return null; } public int getPlcAddress() { return addressIndex; } public String getAddress() { return getAddress(this.addressIndex); } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/PlcParameterObject.java
New file @@ -0,0 +1,202 @@ package com.mes.common; import java.lang.reflect.Array; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class PlcParameterObject { // 该模块数据类型,数据起始位置 private String plcAddressBegin; // 数据地址长度:第一参数到最后一个参数的长度 private int plcAddressLength; private ArrayList<PlcParameterInfo> plcParameterList; /** * @return 数据区开始地址 */ public String getPlcAddressBegin() { return plcAddressBegin; } /** * @param plcAddressBegin 设置数据区开始地址 */ public void setPlcAddressBegin(String plcAddressBegin) { this.plcAddressBegin = plcAddressBegin; } /** * @return 数据区 读取所有数据所需的长度(以byte类型为基准) */ public int getPlcAddressLength() { return plcAddressLength; } /** * @return 设置:数据区 读取所有数据所需的长度(以byte类型为基准) */ public void setPlcAddressLength(int plcAddressLength) { this.plcAddressLength = plcAddressLength; } /** * @return 获取参数实例集合 */ public ArrayList<PlcParameterInfo> getPlcParameterList() { return plcParameterList; } /** * 根据参数标识 获取某个参数实例 * * @param codeid 参数标识 * @return 获取某个参数实例 */ public PlcParameterInfo getPlcParameter(String codeid) { if (plcParameterList != null) { for (PlcParameterInfo plcParameterInfo : plcParameterList) { if (plcParameterInfo.getCodeId().equals(codeid)) return plcParameterInfo; } return null; } else return null; } /** * 根据参数标识 获取某个参数实例 * * @param codeids 参数标识 * @return 获取某个参数实例 */ public List<String> getPlcParameterValues(List<String> codeids) { List<String> arrayList = new ArrayList<>(); if (plcParameterList != null) { Map<String, PlcParameterInfo> resultMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 保留插入顺序 for (PlcParameterInfo plcParameterInfo : plcParameterList) { if (codeids.contains(plcParameterInfo.getCodeId())) { resultMap.put(plcParameterInfo.getCodeId(), plcParameterInfo); } } for (String codeId : codeids) { // 按照传入参数的顺序遍历 PlcParameterInfo plcParameterInfo = resultMap.get(codeId); if (plcParameterInfo != null) { arrayList.add(plcParameterInfo.getValue()); } else { arrayList.add(null); // 如果找不到对应的值,添加 null } } } return arrayList; } public List<String> getAddressListByCodeId(List<String> codeIdList) { List<String> addressList = new ArrayList<>(); for (String codeId : codeIdList) { for (PlcParameterInfo plcParameterInfo : plcParameterList) { if (plcParameterInfo.getCodeId().equals(codeId)) { int index = plcParameterInfo.getAddressIndex(); String address = plcParameterInfo.getAddress(index); if (address != null) { addressList.add(address); } } } } return addressList; } /** * 添加参数实例 * * @param param 参数实例 */ public void addPlcParameter(PlcParameterInfo param) { if (plcParameterList != null) plcParameterList.add(param); else { plcParameterList = new ArrayList<PlcParameterInfo>(); plcParameterList.add(param); } } /** * 根据PLC返回的数据 给参数实例赋值 * * @param plcValueArray PLC读取回来的byte类型数据集合 */ public void setPlcParameterList(byte[] plcValueArray) { if (plcParameterList != null) { for (PlcParameterInfo plcParameterInfo : plcParameterList) { byte[] valueList = new byte[plcParameterInfo.getAddressLength()]; // System.out.println(plcParameterInfo.getAddressLength()); for (int i = 0; i < plcParameterInfo.getAddressLength(); i++) { Array.setByte(valueList, i, plcValueArray[plcParameterInfo.getAddressIndex() + i]); } if (plcParameterInfo.getAddressLength()==2) { plcParameterInfo.setValue(String.valueOf(byte2short(valueList))); } else if (plcParameterInfo.getAddressLength()==14) { plcParameterInfo.setValue((byteToHexString(valueList))); } else { String valuestr = new String(valueList); plcParameterInfo.setValue(valuestr); } } } } /** * short类型转byte[] * * @param s short类型值 */ public static byte[] short2byte(short s){ byte[] b = new byte[2]; for(int i = 0; i < 2; i++){ int offset = 16 - (i+1)*8; //因为byte占4个字节,所以要计算偏移量 b[i] = (byte)((s >> offset)&0xff); //把16位分为2个8位进行分别存储 } return b; } /** * byte[]类型转short * * @param b byte[]类型值 */ public static short byte2short(byte[] b){ short l = 0; for (int i = 0; i < 2; i++) { l<<=8; //<<=和我们的 +=是一样的,意思就是 l = l << 8 l |= (b[i] & 0xff); //和上面也是一样的 l = l | (b[i]&0xff) } return l; } public static String byteToHexString(byte[] bytes) { String str = new String(bytes, StandardCharsets.UTF_8); return str; } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/S7object.java
New file @@ -0,0 +1,36 @@ package com.mes.common; import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; import com.mes.tools.S7control; /** * @Author : zhoush * @Date: 2024/4/9 15:13 * @Description: */ public class S7object { public S7control plccontrol; // PLC通讯类实例 private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型 private String ip = "192.168.10.1"; // plc ip地址 private int port = 102; // plc 端口号 private static volatile S7object instance = null; private S7object() { if (plccontrol == null) { plccontrol = new S7control(plcType, ip, port,0,0); } } // 单例模式 获取类的唯一实例 public static S7object getinstance() { if (instance == null) { synchronized (S7object.class) { if (instance == null) { instance = new S7object(); } } } return instance; } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/upworkstation/controller/UpWorkstationController.java
@@ -1,9 +1,13 @@ package com.mes.upworkstation.controller; import org.springframework.web.bind.annotation.RequestMapping; import com.mes.upworkstation.entity.UpWorkstation; import com.mes.upworkstation.service.LoadGlassService; import com.mes.utils.Result; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * <p> @@ -16,6 +20,37 @@ @RestController @RequestMapping("/upWorkstation") public class UpWorkstationController { @Autowired private LoadGlassService loadGlassService; @PostMapping("/SelectAll") //查询现在上片机的玻璃信息 @ResponseBody public Result selectGlassInfo() { List<UpWorkstation> glass = loadGlassService.selectAll(); System.out.println(glass); return Result.build(200,"", glass); } @PostMapping("/insertGlass") //修改一条工位信息,接收实例类字段为宽高厚膜系数量工位id @ResponseBody public void insertGlassinfo(@RequestBody UpWorkstation upwork) { loadGlassService.insertGlass(upwork); } @PostMapping("/deleteGlass") //修改一条工位的玻璃信息,传输工位id将玻璃信息相关字段更改为null @ResponseBody public void selectCutTerritory(int upworkid) { loadGlassService.deleteGlass(upworkid); } @PostMapping("/selectPriority") //开始上片任务 @ResponseBody public void selectPriority() { boolean result = loadGlassService.isCanLoadGlass(); if(result){ loadGlassService.selectPriority(); } } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/upworkstation/service/LoadGlassService.java
@@ -5,54 +5,52 @@ import com.mes.common.PlcParameterObject; import com.mes.upworkstation.entity.UpWorkstation; import com.mes.upworkstation.mapper.LoadGlassMapper; import com.mes.common.S7object; /** * @author SNG-010 */ @Service public class LoadGlassService { private LoadGlassMapper LoadGlassMapper; PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; private LoadGlassMapper loadGlassMapper; //PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; //显示工位上的玻璃信息 public List<UpWorkstation> selectAll() { List<UpWorkstation> glassInfo= LoadGlassMapper.selectALL(); return glassInfo; return loadGlassMapper.selectALL(); } //增加人工输入的工位玻璃信息 public void insertGlass(UpWorkstation upwork) { LoadGlassMapper.insertGlass(upwork); } public void insertGlass(UpWorkstation upwork) { loadGlassMapper.insertGlass(upwork); } //删除人工搬走的玻璃信息 public void deleteGlass(int id) { LoadGlassMapper.deleteGlass(id); loadGlassMapper.deleteGlass(id); } //判断是否可以吸片进行任务 public boolean isCanLoadGlass() { String loadstate=plcmes.getPlcParameter("吸片信号").getValue(); if(loadstate.equals("1")) { return true; }else{ return false; } String loadstart="吸片信号";//plcmes.getPlcParameter("吸片信号").getValue(); return "1".equals(loadstart); } //判断优先吸片位置后发送出片任务 public void selectPriority() { int loadid1=LoadGlassMapper.selectPriority(1); int loadid2=LoadGlassMapper.selectPriority(2); int loadid1=loadGlassMapper.selectPriority(1); int loadid2=loadGlassMapper.selectPriority(2); //判断一二号工位哪边的顺序更先 if(loadid1>loadid2) { //s7control.WriteWord("DB100.10", (short)2); S7object.getinstance().plccontrol.WriteWord("DB100.10", (short)2); }else if(loadid1==loadid2){ //当两个工位上的玻璃数相同时,判断哪个工位上的玻璃数更少,优先清空一个架子 int glassnum1=Integer.parseInt(plcmes.getPlcParameter("玻璃数").getValue()); int glassnum2=Integer.parseInt(plcmes.getPlcParameter("玻璃数").getValue()); int glassnum1=1;//Integer.parseInt(plcmes.getPlcParameter("玻璃数").getValue()); int glassnum2=2;//Integer.parseInt(plcmes.getPlcParameter("玻璃数").getValue()); if(glassnum1>glassnum2){ // s7control.WriteWord("DB100.10", (short)2); S7object.getinstance().plccontrol.WriteWord("DB100.10", (short)2); }else{ //s7control.WriteWord("DB100.10", (short)1); S7object.getinstance().plccontrol.WriteWord("DB100.10", (short)1); } }else{ //s7control.WriteWord("DB100.10", (short)1); S7object.getinstance().plccontrol.WriteWord("DB100.10", (short)1); } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/upworkstation/service/UpWorkstationService.java
@@ -13,4 +13,7 @@ */ public interface UpWorkstationService extends IService<UpWorkstation> { } hangzhoumesParent/moduleService/TemperingGlassModule/pom.xml
@@ -9,7 +9,7 @@ </parent> <modelVersion>4.0.0</modelVersion> <artifactId>cacheGlass</artifactId> <artifactId>temperingGlass</artifactId> <dependencies> <dependency> <groupId>junit</groupId>