Giter Site home page Giter Site logo

device_adaptor_backend's Introduction

统一数据监控平台

主要为解决以下问题而设计:

  • 避免从OPC取数据,直接从PLC获取数据
  • 统一控制流程问题,指令的发送、调度、回调等
  • 统一数据格式问题,避免维护多种输出或输出的类型、格式等

数据输出格式

每个数据源的每个采集周期输出数据格式如下:

  • fields::数据字段
  • name:数据源标识
  • quality:数据质量
    • 1:Good
    • 2:Disconnect
    • 。。。:待扩展
    • MaxUint8:Unknown
  • timestamp:ms时间戳
[{
"fields":{
    "db40.dbd2":2.87,
    "db40.dbd6":3.46,
    "db40.dbw0":123,
    "db40.dbw112":1234,
    "db40.dbx102.0":1,
    "db40.dbx102.1":1,
    "db40.dbx102.7":0,
    "db40.dbx104.1":1
},
"name":"s7",
"quality":1,
"timestamp":1540261475146
}]

点表格式

db40.dbx102.0:				# <required> 点名称,ASCII编码,便于跨语言使用, 可以自定义
  address: ""				# <required> point在设备中的物理地址,程序用来访问实时数据
  label: start				# <optional> 短名称
  name: 启动		   		   # <optional> 长名称
  unit: 单位				   # <optional> 单位字符串
  point_type: 				# <optional> 点类型 0:模拟量,1:状态量, 2:整形量,3:字符串;默认为模拟量
  tags: ["test"]			# <optional> tag标记
  option:					# <optional> 状态量映射关系
    1: 启动
    0: 停止
  parameter: 0.707423		# <optional> 模拟量系数
  extra:					# <optional> 扩展字段
  	key1: value1
  	key2: value2

PointType

const (
	PointAnalog PointType = iota	//模拟量
	PointDigital					//数字量
	PointInteger					//整形量
	PointString						//字符串
	PointUnknown = math.MaxUint8
)

获取点表接口

接口:GET

Path: /interface/pointMap/:plugin_name

GET /interface/pointMap/fake HTTP/1.1
Host: localhost:8080
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNTQ3MDU1MTU3fQ.Z57HU6zuo0zGOc0-y36wLOePBqnXFLg4PoBCt5M_kRI
Content-Type: application/json

控制功能

接口:POST

Path:/point_value/:deviceName

Content-Type:applicant/json

参数:{"TestTag1", 2, "TestTag2": true, "TestTag3": 1.123}

示例:

POST /point_value/opc HTTP/1.1
Host: localhost:9999
Content-Type: application/json
{
	"Channel1.Device1.Tag1": 0,
	"Tag2": 1.1,
	"Tag3": false
}

报警功能

报警功能走WebSocket接口

Path:/interface/alarm

客户端建立连接后等待接收报警信息

报警信息结构:

{
  "name":"TestAlarm",
  "input_name":"inputs.opc",
  "timestamp":"2018-12-15T12:08:03+08:00"
}

工程相关

前端代码嵌入

获取嵌入打包工具:

go get github.com/rakyll/statik

在后端repo根目录下执行:

cp -r frontend/dist assets/
statik -src=assets/dist

device_adaptor_backend's People

Contributors

mageia avatar gongzhang avatar twosix26 avatar mhli123 avatar

Watchers

 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.