Coder Social home page Coder Social logo

hj-t212-parser's Introduction

HJ/T212 Parser

Build Status Artifact Status

环保部212传输协议

标准

污染源在线自动监控(监测)系统数据传输标准(HJ/T 212-2005) 污染物在线监控(监测)系统数据传输标准(HJ 212-2017代替HJ/T 212-2005)

当前支持特性为:

  • 2005 2017双版协议兼容
  • 解析协议为java对象、Map对象
  • 反向生成协议包
  • 结构校验、CRC校验、字段类型校验
  • 校验启停、解析容错特性开关
  • 码表枚举

使用

通过gradle引入托管在jitpack上的jar包

repositories {
    maven{
        url 'https://jitpack.io'
    }
}
dependencies {
    compile 'com.github.xiaoyao9184.hj-t212-parser:hj-t212-parser:master-SNAPSHOT'
    compile 'com.github.xiaoyao9184.hj-t212-parser:hj-t212-translator:master-SNAPSHOT'
}

通过创建T212Mapper对象,获得读取、写入T212信息的功能 查看此单元代码

String h212 = "##0136ST=32;CN=2011;PW=123456;MN=LD130133000015;CP=&&DataTime=20160824003817;B01-Rtd=36.91;011-Rtd=231.0,011-Flag=N;060-Rtd=1.803,060-Flag=N&&4980\r\n";

T212Mapper mapper = new T212Mapper()
                .enableDefaultVerifyFeatures()
                .enableDefaultParserFeatures();

//从T212字符串中读取Data对象
Data data = mapper.readData(h212);

//.... use data

//create data and set it
data.setPw("000000");
//将Data对象写入成T212字符串
String result = mapper.writeDataAsString(data);

更多高级方式请参阅单元测试代码

类似Jackson的API

如果你使用过Jackson,你会发现以下类在设计方式上非常类似

Jackson类 T212类
ObjectMapper T212Mapper
JsonParser T212Parser
JsonGenerator T212Generator
Deserializers T212Deserializer
Serializers T212Serializer

Segment语法

如果你很了解T212的数据区的结构定义,将会很简单的认同以下抽象语法, 当前使用Segment作为这种语法的代称。

<object> ::= <entry> [;...n]
<entry> ::= key = <value> | key - sub_key = value [,...n]
<value> ::= value | && <object> &&
  • key 是字符串
  • value 是字符串

协议错误修正

版本 位置 错误类型 错误描述 解决办法
2017 28、29页 污染物编码冲突 e701xx 污水提升泵加药量 加药量 使用 e711xx
2017 30页 污染物编码冲突 g119xx 脱硫率入口二氧化硫 SO2 脱硫率 使用 g200xx

hj-t212-parser's People

Contributors

xiaoyao9184 avatar meifu2027 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.