1 Star 0 Fork 74

於之 / iec104

forked from ydl / iec104 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Iec 104

目录

项目介绍

      该项目基于Netty实现的底层网络通信,支持从站服务端、主站客户端的模式, 可以通过Master采集数据,  
    也可以通过Slave模拟终端。该项目已经支持: S帧、U帧、总召唤指令、沾包拆包等功能,由于104协议部分内容  
    存在可扩展性,因此本项目只完成通讯部分以及协议的解码和转码部分。在实际使用过程中需要按照硬件厂商提供  
    的点表再将消息部分装换成可识别的业务对象。

使用

主站

    // 创建一个配置文件
    Iec104Config iec104Config  = new Iec104Config();
    // 指定收到多少帧就回复一个S帧
    iec104Config.setFrameAmountMax((short) 1);
    // 终端地址需要和从站保持一致
    iec104Config.setTerminnalAddress((short) 1);
    Iec104MasterFactory.createTcpClientMaster("127.0.0.1", 2404).setDataHandler(new SysDataHandler()).setConfig(iec104Config).run();

从站

    // 创建一个配置文件
    Iec104Config iec104Config  = new Iec104Config();
    // 指定收到多少帧就回复一个S帧
    iec104Config.setFrameAmountMax((short) 1);
    // 终端地址
    iec104Config.setTerminnalAddress((short) 1);
   Iec104SlaveFactory.createTcpServerSlave(2404).setDataHandler(new SysDataHandler()).setConfig(iec104Config).run();

自定义DataHandler

 public class SysDataHandler implements DataHandler {

	@Override
	public void handlerAdded(ChannelHandler ctx) throws Exception {
        // 连接成功后
	}

	@Override
	public void channelRead(ChannelHandler ctx, MessageDetail ruleDetail104) throws Exception {
        // 收到消息后
        
        // 注意 往ctx.writeAndFlush中存放的应该是自己封装的 MessageDetail对象
        ctx.writeAndFlush(BasicInstruction104.getEndGeneralCallRuleDetail104());
	}

其他

项目相关的技术问题、缺陷报告、建议等信息请通过 Issue 发布

感谢

感谢mujave提供的iec项目 https://github.com/mujave/iec

开源协议

MIT © Richard Littauer

MIT License Copyright (c) 2020 ydl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于Netty实现的网络通信,按照104规约解析报文。 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/willbeahero/iec104.git
git@gitee.com:willbeahero/iec104.git
willbeahero
iec104
iec104
master

搜索帮助