# spring-boot-jlibmodbus **Repository Path**: google1/spring-boot-jlibmodbus ## Basic Information - **Project Name**: spring-boot-jlibmodbus - **Description**: jlibmodbus针对modbus监控数据的处理 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 8 - **Forks**: 9 - **Created**: 2021-06-04 - **Last Updated**: 2024-07-08 ## Categories & Tags **Categories**: spring-boot-ext **Tags**: None ## README # spring-boot-jlibmodbs #### 介绍 {**以下是 Gitee 平台说明,您可以替换此简介** Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} #### 软件架构 软件架构说明 #### 安装教程 1. 采用modbusslave进行测试,并行设置多种功能类型 F01:线圈 F02:输入状态 F03:保持寄存器 F04:输入寄存器 2. 项目采用springboot2.4.6+mybatis-plus3.4.3+jlibmodbus+websocket实现Modbus中的数据监控 #### 使用说明 1. 使用PLC数据时:针对寄存器中的数据类型进行的解析,根据具体代码来查看 /** * 将功能对象中的值进行解析 * @param bos * @param funData */ private void parse(List bos, Map funData) { parseF01(bos, funData.get("F01"), "F01"); parseF01(bos, funData.get("F02"), "F02"); parseF02(bos, funData.get("F03"), "F03"); parseF02(bos, funData.get("F04"), "F03"); } private void parseF01(List bos, List data, String type){ bos.forEach(item->{ if (item.getFunNo().equals(type)){ item.setValue(Boolean.getBoolean(data.get(item.getOffset()).toString())?"1":"0"); } }); } private void parseF02(List bos, List data, String type){ bos.forEach(item->{ if(item.getFunNo().equals(type)){ if (item.getType().equals("INT")){ item.setValue(data.get(item.getOffset()).toString()); }else if(item.getType().equals("BIT")){ byte[] bytes = DataUtils.toByteArray(Integer.valueOf(data.get(item.getOffset()).toString())); byte tmp = bytes[0]; bytes[0] = bytes[1]; bytes[1] = tmp; boolean[] bs = DataUtils.toBitsArray(bytes, 16); item.setValue(bs[item.getLocal()]?"1":"0"); }else if (item.getType().equals("FLOAT")){ byte[] bs = new byte[4]; byte[] firstBs = DataUtils.toByteArray(Integer.valueOf(data.get(item.getOffset()).toString())); byte[] secondBs = DataUtils.toByteArray(Integer.valueOf(data.get(item.getOffset()).toString())+1); bs[0] = secondBs[1]; bs[1] = secondBs[0]; bs[2] = firstBs[1]; bs[3] = firstBs[0]; item.setValue(DataUtils.toFloat(bs)+""); } } }); } #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)