欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 艺术 > java s7接收Byte字节,接收word转16位二进制

java s7接收Byte字节,接收word转16位二进制

2025/2/8 12:31:19 来源:https://blog.csdn.net/darlene2929/article/details/145451570  浏览:    关键词:java s7接收Byte字节,接收word转16位二进制

1图:
在这里插入图片描述

2.图:
在这里插入图片描述

  try {List list = getNameList();//接收base64S7Connector s7Connector = S7ConnectorFactory.buildTCPConnector().withHost("192.168.46.52").withPort(102).withTimeout(1000) //连接超时时间.withRack(0).withSlot(3).build();List list1 = new ArrayList();byte[] cmdByte = s7Connector.read(DaveArea.DB,101,544,4848);for (int i = 0; i < 272; i++) {int num1 = intCon.extract(Integer.class, cmdByte, 0+((i+1)-1)*2, 2+((i+1)-1)*2);String binary = Integer.toBinaryString(num1);String binary2 = String.format("%16s",binary).replace(' ','0');String dataByte = binary2.substring(4, 5);int dataByte1 = Integer.valueOf(dataByte);list1.add(dataByte1);}s7Connector.close();S7Connector s7Connector2 = S7ConnectorFactory.buildTCPConnector().withHost("192.168.46.52").withPort(102).withTimeout(1000) //连接超时时间.withRack(0).withSlot(3).build();List list2 = new ArrayList();for(int i=0; i<544; i+=2){byte[] cmdByte2 = s7Connector2.read(DaveArea.DB,105,1,i);list2.add(String.valueOf(cmdByte2[0]));}s7Connector2.close();doInsertBCU(list,list1,list2);sleep(5000);} catch (Exception e) {e.printStackTrace();//continue;}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com