| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.io.Console; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | |
| | | add(2034);add(2035);add(2037); |
| | | // add(2041);add(2042);add(2043);add(2044); |
| | | // add(2045);add(2046);add(2047);add(2048); |
| | | // add(2101);add(2102);add(2103);add(2104);add(2105);add(2106);add(2107);add(2108);add(2109);add(2110); |
| | | // add(2111);add(2112);add(2113);add(2114);add(2115);add(2116);add(2117);add(2118);add(2119);add(2120); |
| | | add(2101);add(2102);add(2103);add(2104);add(2105);add(2106);add(2107);add(2108);add(2109);add(2110); |
| | | add(2111);add(2112);add(2113);add(2114);add(2115);add(2116);add(2117);add(2118);add(2119);add(2120); |
| | | add(4001);add(4003);add(4004);add(4006); |
| | | }}; |
| | | |
| | |
| | | put(2031, 464);put(2032, 348);put(2033, 556);put(2034, 92);put(2035, 0); |
| | | put(2037, 256); |
| | | |
| | | // put(2101, 0);put(2102, 92);put(2103, 184);put(2104, 276);put(2105, 368); |
| | | // put(2106, 460);put(2107, 552);put(2108, 644);put(2109, 736);put(2110, 828); |
| | | // put(2111, 920);put(2112, 1012);put(2113, 1104);put(2114, 1196);put(2115, 1288); |
| | | // put(2116, 1380);put(2117, 1472);put(2118, 1564);put(2119, 1656);put(2120, 1748); |
| | | // put(2121, 1840);put(2122, 1932); |
| | | put(2101, 0);put(2102, 92);put(2103, 184);put(2104, 276);put(2105, 368); |
| | | put(2106, 460);put(2107, 552);put(2108, 644);put(2109, 736);put(2110, 828); |
| | | put(2111, 920);put(2112, 1012);put(2113, 1104);put(2114, 1196);put(2115, 1288); |
| | | put(2116, 1380);put(2117, 1472);put(2118, 1564);put(2119, 1656);put(2120, 1748); |
| | | put(2121, 1840);put(2122, 1932); |
| | | |
| | | put(4001, 0);put(4002, 116);put(4003, 508);put(4004, 392);put(4005, 300); |
| | | put(4006, 208); |
| | |
| | | OperateResultExOne<byte[]> resultPlc = null; |
| | | OperateResultExOne<byte[]> resultAgv = null; |
| | | |
| | | OperateResultExOne<byte[]> resultArm5 = null;//2110 |
| | | OperateResultExOne<byte[]> resultArm6 = null;//2120 |
| | | |
| | | if(staNoSize == 102){ |
| | | result1 = siemensS7Net.Read("DB100.0", (short) (2768));//1001-1028 |
| | | result2 = siemensS7Net.Read("DB101.0", (short) (1268));//1029-1037 |
| | |
| | | result1 = siemensS7Net.Read("DB200.0", (short) (3000));//2001-2030 |
| | | result2 = siemensS7Net.Read("DB201.0", (short) (720));//2031-2037 |
| | | result3 = siemensS7Net.Read("DB400.0", (short) (600));//4001-4006 |
| | | // result6 = siemensS7Net.Read("DB400.0", (short) (7400));//2101-2122 |
| | | result6 = siemensS7Net.Read("DB202.0", (short) (7400));//2101-2122 |
| | | resultErr = siemensS7Net.Read("DB3.0", (short) (354)); |
| | | // resultAgv = siemensS7Net.Read("DB901.0", (short) (7)); //agv取放货请求 |
| | | // resultPlc = siemensS7Net.Read("DB902.0", (short) (7)); //输送线确认 |
| | | resultArm5 = siemensS7Net.Read("DB202.4328", (short) (254));//2110 |
| | | resultArm6 = siemensS7Net.Read("DB202.6888", (short) (254));//2120 |
| | | } |
| | | |
| | | |
| | |
| | | } else if (siteId < 2040) { |
| | | result = result2; |
| | | } else if(siteId<4000){ |
| | | // result = result6; |
| | | if (siteId == 2110) { |
| | | if (resultArm5.IsSuccess) { |
| | | // 转换为字符串 |
| | | String resultString = siemensS7Net.getByteTransform().TransString(resultArm5.Content, 2, 252,"UTF-8"); |
| | | // 去除可能的空字符 |
| | | // resultString = resultString.TrimEnd('\0'); |
| | | // System.out.println("2110Barcode:"+resultString); |
| | | staProtocol.setBarcode(resultString); |
| | | } else { |
| | | staProtocol.setBarcode(""); |
| | | } |
| | | } else if (siteId == 2120){ |
| | | if (resultArm6.IsSuccess) { |
| | | // 转换为字符串 |
| | | String resultString = siemensS7Net.getByteTransform().TransString(resultArm6.Content, 2, 252,"UTF-8"); |
| | | // 去除可能的空字符 |
| | | // resultString = resultString.TrimEnd('\0'); |
| | | // System.out.println("2120Barcode:"+resultString); |
| | | staProtocol.setBarcode(resultString); |
| | | } else { |
| | | staProtocol.setBarcode(""); |
| | | } |
| | | } |
| | | result = result6; |
| | | } |
| | | else { |
| | | result = result3; |
| | |
| | | } |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2)); // 工作号 |
| | | staProtocol.setStaNo((short)siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 12)); // 目标站 |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 16))); //条码 |
| | | |
| | | if (staProtocol.getSiteId()!=2110 && staProtocol.getSiteId()!=2120 ){ |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 16))); //条码 |
| | | } |
| | | if(specialSites2.contains(siteId)){ |
| | | staProtocol.setStaNo((short)siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 48)); // 目标站 |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 52))); //条码 |
| | | if (staProtocol.getSiteId()!=2110 && staProtocol.getSiteId()!=2120 ){ |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 52))); //条码 |
| | | } |
| | | } |
| | | if(staNosErrList.contains(siteId)){ |
| | | Integer offsetErr = siteErrOffsetMap.get(siteId); |
| | |
| | | staProtocol.setAutoing(!status[0]); // 自动 |
| | | boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3 - 4, 3); |
| | | boolean[] statusErr = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3 - 8, 3); |
| | | boolean[] statusSign = siemensS7Net.getByteTransform().TransBool(resultErr.Content, offsetSign, 3); |
| | | // boolean[] statusSign = siemensS7Net.getByteTransform().TransBool(resultErr.Content, offsetSign, 3); |
| | | |
| | | boolean loading = false; |
| | | if(!status1[0]) |
| | | { |
| | |
| | | staProtocol.setDataError(statusErr[18]); |
| | | |
| | | //信号 |
| | | staProtocol.setSensorGArrive(statusSign[0]); |
| | | staProtocol.setSensorGDec(statusSign[1]); |
| | | staProtocol.setSensorGArrive2(statusSign[2]); |
| | | staProtocol.setSensorLimit(statusSign[3]); |
| | | staProtocol.setEmergency(statusSign[4]); |
| | | staProtocol.setSensorGLeave(statusSign[5]); |
| | | staProtocol.setSensorGLeave2(statusSign[6]); |
| | | staProtocol.setSensorCUp(statusSign[7]); |
| | | staProtocol.setSensorCDown(statusSign[8]); |
| | | staProtocol.setLiftMotorFr(statusSign[9]); |
| | | staProtocol.setLineMotorFr(statusSign[10]); |
| | | staProtocol.setTranMotorFr(statusSign[11]); |
| | | staProtocol.setRst1(statusSign[12]); |
| | | staProtocol.setRst2(statusSign[13]); |
| | | staProtocol.setRst3(statusSign[14]); |
| | | staProtocol.setRst4(statusSign[15]); |
| | | staProtocol.setSensorArriveD(statusSign[16]); |
| | | staProtocol.setSensorDecD(statusSign[17]); |
| | | staProtocol.setSensorArriveL(statusSign[18]); |
| | | staProtocol.setSensorDecL(statusSign[19]); |
| | | staProtocol.setSensorArriveR(statusSign[20]); |
| | | staProtocol.setSensorDecR(statusSign[21]); |
| | | // staProtocol.setSensorGArrive(statusSign[0]); |
| | | // staProtocol.setSensorGDec(statusSign[1]); |
| | | // staProtocol.setSensorGArrive2(statusSign[2]); |
| | | // staProtocol.setSensorLimit(statusSign[3]); |
| | | // staProtocol.setEmergency(statusSign[4]); |
| | | // staProtocol.setSensorGLeave(statusSign[5]); |
| | | // staProtocol.setSensorGLeave2(statusSign[6]); |
| | | // staProtocol.setSensorCUp(statusSign[7]); |
| | | // staProtocol.setSensorCDown(statusSign[8]); |
| | | // staProtocol.setLiftMotorFr(statusSign[9]); |
| | | // staProtocol.setLineMotorFr(statusSign[10]); |
| | | // staProtocol.setTranMotorFr(statusSign[11]); |
| | | // staProtocol.setRst1(statusSign[12]); |
| | | // staProtocol.setRst2(statusSign[13]); |
| | | // staProtocol.setRst3(statusSign[14]); |
| | | // staProtocol.setRst4(statusSign[15]); |
| | | // staProtocol.setSensorArriveD(statusSign[16]); |
| | | // staProtocol.setSensorDecD(statusSign[17]); |
| | | // staProtocol.setSensorArriveL(statusSign[18]); |
| | | // staProtocol.setSensorDecL(statusSign[19]); |
| | | // staProtocol.setSensorArriveR(statusSign[20]); |
| | | // staProtocol.setSensorDecR(statusSign[21]); |
| | | |
| | | // Integer offsetAgv = siteAgvOffsetMap.get(siteId); |
| | | // |