| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package com.mes.util;
- import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
- import com.mes.ui.Oprno;
- public class S7PLCUtils {
- /** 返回第一个上料完成信号为 true 的工位 */
- public static Oprno isStart(S7PLC s7PLC, Oprno... oprnos) {
- for (Oprno oprno : oprnos) {
- if (s7PLC.readBoolean(oprno.getLoad_complete())) {
- return oprno;
- }
- }
- return null;
- }
- /** 返回第一个下料完成信号为 true 的工位 */
- public static Oprno isFinish(S7PLC s7PLC, Oprno... oprnos) {
- for (Oprno oprno : oprnos) {
- if (s7PLC.readBoolean(oprno.getUnload_complete())) {
- return oprno;
- }
- }
- return null;
- }
- /** 读取工位二维码 */
- public static String getSnInOprno(Oprno oprno, S7PLC s7PLC) {
- return s7PLC.readString(oprno.getProduct_sn(), 50);
- }
- /** 读取工位结果:OK=true,NG=false;都未置位返回 null 语义用 Boolean 包装时此处 NG 优先 */
- public static Boolean getResultInOprno(Oprno oprno, S7PLC s7PLC) {
- Boolean resultOK = s7PLC.readBoolean(oprno.getProcess_result_ok());
- Boolean resultNG = s7PLC.readBoolean(oprno.getProcess_result_ng());
- if (resultNG) {
- return false;
- }
- if (resultOK) {
- return true;
- }
- return null;
- }
- }
|