Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: v0.6.5 #210

Merged
merged 138 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
e3608e0
dev: add alias to modbus return
wwhai Nov 16, 2023
951b67a
dev: optimize tdengine and tcp target
wwhai Nov 16, 2023
03e8565
dev: optimize install script
wwhai Nov 16, 2023
764e228
dev: update doc
wwhai Nov 16, 2023
3cd0894
dev: add new system sctipt
wwhai Nov 16, 2023
4394f75
dev: update user api
wwhai Nov 17, 2023
eef2885
dev: rename some paths
wwhai Nov 17, 2023
73bab72
dev: regular some name; add license validate
wwhai Nov 17, 2023
0a5c55d
dev: optimize license manager
wwhai Nov 17, 2023
68acd95
dev: update index.html
wwhai Nov 17, 2023
6f8fef6
dev: optimize Get Vendor Key
wwhai Nov 17, 2023
fc2c7a3
dev: rename api: delete to del
wwhai Nov 18, 2023
64a5079
dev: add more resource; update doc
wwhai Nov 18, 2023
de58c8e
dev: optimize LicenseManager
wwhai Nov 18, 2023
2362f29
doc: add tdengine target doc
wwhai Nov 18, 2023
587c5ed
dev: move api file
wwhai Nov 19, 2023
2c70ff0
dev: add get eth0 addr func
wwhai Nov 19, 2023
cb00d53
ci: remove unused ci; update doc
wwhai Nov 20, 2023
7cb4d2c
fix: fix get unix port list failed
wwhai Nov 20, 2023
92bd644
dev: support user led
wwhai Nov 20, 2023
5ff972d
dev: optimize user led
wwhai Nov 20, 2023
74e1f9b
ci: fix ci
wwhai Nov 20, 2023
57d4992
dev: optimize build script
wwhai Nov 20, 2023
ad1abf4
dev: optimize linux daemon
wwhai Nov 20, 2023
4b46764
dev: add network:Ping function
wwhai Nov 20, 2023
f7c09c7
dev: rm cached index.html
wwhai Nov 20, 2023
65f6d16
dev: rename file
wwhai Nov 20, 2023
b4cb62b
fix :fix udp target delete panic
wwhai Nov 20, 2023
f14054b
dev: rename data to udp
wwhai Nov 20, 2023
5c19c2a
dev: optimize queue
wwhai Nov 21, 2023
f4a2594
fix: fix tcp target
wwhai Nov 21, 2023
aedda0f
dev: optimize tcp target
wwhai Nov 21, 2023
c27bd7d
dev: fix xquque capcity
wwhai Nov 21, 2023
8fc0a1a
dev: enhance http target
wwhai Nov 21, 2023
ce0dc4f
dev: optimize Mem Percent
wwhai Nov 21, 2023
5405691
fix: remove unused package
wwhai Nov 21, 2023
e170ffe
dev: rename dir
wwhai Nov 21, 2023
63ec8e1
dev: rename __DEFAULT_DB_PATH
wwhai Nov 21, 2023
0aa7327
dev: add default index
wwhai Nov 21, 2023
56b446e
dev: update ignore
wwhai Nov 21, 2023
ce3a298
dev: optimize recovery
wwhai Nov 21, 2023
97e343f
fix: fix recover failed
wwhai Nov 21, 2023
e3f0b37
dev: update upgrade api
wwhai Nov 21, 2023
a1f0c14
dev: optimize mem Percent
wwhai Nov 21, 2023
c47efe9
dev: optimize mem Percent
wwhai Nov 22, 2023
b176365
dev: optimize stream play
wwhai Nov 22, 2023
bb81747
dev: update doc
wwhai Nov 22, 2023
bc3ddd9
dev: add hide_banner to ffmpeg
wwhai Nov 22, 2023
27d6f6a
dev: fix update and recover
wwhai Nov 22, 2023
47dd03b
dev: fix recover
wwhai Nov 22, 2023
065188d
dev: add openwrt daemon support
wwhai Nov 23, 2023
fb2c662
dev: fix path error
wwhai Nov 23, 2023
84639f0
dev: fix process nil
wwhai Nov 23, 2023
2263e99
fix: remove unused import
wwhai Nov 23, 2023
1eca8ad
dev: test data recover
wwhai Nov 24, 2023
4450113
dev: enhance daemon
wwhai Nov 24, 2023
bfa51fd
fix: fix daemon failed
wwhai Nov 24, 2023
542a985
dev: fix daemon failed
wwhai Nov 25, 2023
0a02a44
fix: fix recover loop failed
wwhai Nov 26, 2023
ae60035
dev: add upgrade lock
wwhai Nov 26, 2023
0cc0c31
dev: exit 0
wwhai Nov 26, 2023
58e7c79
fix: fix daemon
wwhai Nov 27, 2023
36ec27d
dev: add daemon for common linux
wwhai Nov 27, 2023
f8c8b1a
dev: update some magic value
wwhai Nov 28, 2023
2ba485a
dev: add doc
wwhai Nov 28, 2023
9629158
dev: add lua http api
wwhai Nov 28, 2023
00e1c74
dev: rename func
wwhai Nov 28, 2023
3039ba4
dev: add more log
wwhai Nov 28, 2023
dd6b3bd
fix: fix upgrade failed
wwhai Nov 28, 2023
6629000
dev: add BinToFloat32 Demo
wwhai Nov 28, 2023
f33094a
dev: add modbus parse demo; fix openwrt sctipt
wwhai Nov 29, 2023
dbc5067
dev: enhance compatible for h3
wwhai Nov 29, 2023
df84c3f
dev: optimize LocalDb Query
wwhai Nov 29, 2023
66fb869
dev: add Bin2F32Little function
wwhai Nov 30, 2023
625836d
dev: add InternalEventBus; enhance lua
wwhai Dec 1, 2023
cff7dab
ci: update swag version & remove unused module & ignore go.sum (#212)
BeatTime Dec 3, 2023
acc8888
dev: add event bus
wwhai Dec 3, 2023
a5cd8f4
dev: optimize global context
wwhai Dec 3, 2023
42c88f0
dev: rename modbus_crc_tools
wwhai Dec 3, 2023
d4c605b
dev: add Internal Notifies Api
wwhai Dec 3, 2023
960528c
dev: add internal notify api
wwhai Dec 3, 2023
4ede034
dev: enhance notify; sqlite VACUUM
wwhai Dec 3, 2023
e040348
ci: fix ci failed
wwhai Dec 3, 2023
b9b053e
ci: fix ci failed
wwhai Dec 3, 2023
eed0fed
dev: add notify test
wwhai Dec 4, 2023
9181776
dev: fix get unknown distribution os info failed
wwhai Dec 4, 2023
5c84edc
dev: optimize modbus write api
wwhai Dec 4, 2023
5c62e76
dev; enhance modbus
wwhai Dec 4, 2023
0d1a639
feat: add user lua template api
wwhai Dec 5, 2023
197287b
doc: add some doc
wwhai Dec 5, 2023
098cdcb
fix: fix rule update missing bind list
wwhai Dec 5, 2023
c36c563
dev: add supervisor
wwhai Dec 5, 2023
6e47182
refactor: move api server to component
wwhai Dec 5, 2023
cb00bdc
dev: remove api path
wwhai Dec 6, 2023
4959ee5
dev: add detail filed to UserLuaTemplate
wwhai Dec 6, 2023
7444ac6
dev: add UserLuaTemplateDetail
wwhai Dec 7, 2023
c453e9c
feat: add s7-1200 support
wwhai Dec 7, 2023
09052b8
dev: enhance s1200 driver
wwhai Dec 8, 2023
1678a59
Bugfix/jane/crontask (#213)
BeatTime Dec 9, 2023
fdd7edc
dev: add modbus table api
wwhai Dec 9, 2023
ff933e6
dev: add modbus_data_sheet export api
wwhai Dec 10, 2023
8a05dcd
dev: modbus del All Api support
wwhai Dec 10, 2023
65a786b
fix: fix ModbusPoint create failed
wwhai Dec 10, 2023
e9984f7
fix: fix slaverid save failed
wwhai Dec 10, 2023
d739c10
fix: fix slaverid error
wwhai Dec 10, 2023
0084a74
dev: rename SlaverId
wwhai Dec 10, 2023
a4c602b
fix: fix duplicate UUID
wwhai Dec 10, 2023
1a37424
dev: add Siemens data sheet support
wwhai Dec 11, 2023
fd939cd
dev: fix s1200 status
wwhai Dec 11, 2023
14fd237
fix: fix missing 'type' param
wwhai Dec 11, 2023
19b0e24
dev: add realtime data value for s1200/modbus
wwhai Dec 11, 2023
47162a3
dev: enhancement modbus, plc1200
wwhai Dec 12, 2023
af5877c
fix: fix some warning
wwhai Dec 13, 2023
1eadfee
dev: support data sheet status
wwhai Dec 14, 2023
32d9bb5
fix: fix group unrelease
wwhai Dec 15, 2023
e224070
dev: enhancement queue
wwhai Dec 16, 2023
7e72a8f
fix: fix plc status and realtime Value
wwhai Dec 16, 2023
fc496b5
dev: enhance CURD with Transaction
wwhai Dec 17, 2023
ddaa197
feat: design internal Event Bus first version
wwhai Dec 17, 2023
9d05ccb
dev: delete Topics when no subscribers
wwhai Dec 17, 2023
bc8db3b
dev: add http device; add get snapshot, get logfile API
wwhai Dec 18, 2023
9478c38
fix: fix panic when CancelCTX is nil
wwhai Dec 18, 2023
c088a66
fix: concurrent map write error
wwhai Dec 19, 2023
2626363
fix: fix http, modbus nil panic
wwhai Dec 19, 2023
929b604
dev: enhance binary operate
wwhai Dec 19, 2023
2df6a04
dev: enhance XStore Fuzzy Get
wwhai Dec 19, 2023
4d6a3c7
fix: fix state error
wwhai Dec 20, 2023
b158147
dev: remove unused code
wwhai Dec 21, 2023
d8d77ab
doc: add docs
wwhai Dec 21, 2023
40b0767
dev: remove history heavy bag
wwhai Dec 21, 2023
86a3017
dev: support Variables
wwhai Dec 22, 2023
1733cef
fix: fix concurrent map error
wwhai Dec 22, 2023
ac3156e
dev: enhance rule; optimize dashboard data
wwhai Dec 27, 2023
2f0c02c
dev: add Port to StartRulexApiServer
wwhai Dec 29, 2023
051034c
dev: change plugin path to 'plugware'
wwhai Dec 29, 2023
49970fe
dev: change plugin list path
wwhai Dec 29, 2023
cb68b5b
dev: optimize code
wwhai Dec 30, 2023
f5d6732
dev: enhance version format
wwhai Dec 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 10 additions & 1 deletion .github/workflows/2_build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ jobs:
- name: Linux 构建测试
run: |
sudo apt update -y
sudo apt install jq cloc protobuf-compiler -y
sudo apt install jq cloc protobuf-compiler \
gcc-mingw-w64-x86-64 \
gcc-arm-linux-gnueabi \
gcc-mips-linux-gnu \
gcc-mingw-w64 \
gcc-aarch64-linux-gnu -y
cloc ./
go get
go get -t github.com/hootrhino/rulex/test
make
# for test mqtt
echo "Start Mqtt Server"
Expand All @@ -37,3 +44,5 @@ jobs:
go test -timeout 30s -run ^Test_data_to_tdengine$ github.com/hootrhino/rulex/test -v -count=1
#
go test -timeout 30s -run ^Test_DataToMongo$ github.com/hootrhino/rulex/test -v -count=1
chmod +x ./release_pkg.sh
bash ./release_pkg.sh
35 changes: 0 additions & 35 deletions .github/workflows/3_build-windows.yaml

This file was deleted.

9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ profile*
_release*
_build*
lua-log*
*.txt
*.txt.gz
plugin/http_server/www/*
plugin/http_server/server/www/*
*.txt*
dist/
apps/*.lua
plugin/http_server/www/index.html
plugin/http_server/server/www/index.html
test/script/_temp/*
upload/*
go.sum
component/rulex_api_server/server/www/*
29 changes: 19 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,70 @@ ip=$(shell hostname -I)
memory=$(shell free -m | awk 'NR==2{printf "%.2fGB\n", $$2/1000}')
disk=$(shell df -h | awk '$$NF=="/"{printf "%s\n", $$2}')
arch=$(uname -m)

version=$(shell git describe --tags $(git rev-list --tags --max-count=1))
shortVersion=-X 'github.com/hootrhino/rulex/typex.MainVersion=$(version)'
.PHONY: all
all:
@echo "\e[41m[*] Distro \e[0m: \e[36m ${distro} \e[0m"
@echo "\e[41m[*] Arch \e[0m: \e[36m ${arch} \e[0m"
@echo "\e[41m[*] Arch \e[0m: \e[36m ${arch} \e[0m"
@echo "\e[41m[*] Kernel \e[0m: \e[36m ${kernel} \e[0m"
@echo "\e[41m[*] Cpu \e[0m: \e[36m ${cpu} \e[0m"
@echo "\e[41m[*] Memory \e[0m: \e[36m ${memory} \e[0m"
@echo "\e[41m[*] Host \e[0m: \e[36m ${host} \e[0m"
@echo "\e[41m[*] IP \e[0m: \e[36m ${ip} \e[0m"
@echo "\e[41m[*] Disk \e[0m: \e[36m ${disk} \e[0m"
go generate
make build

.PHONY: build
build:
CGO_ENABLED=1 GOOS=linux
go build -v -ldflags "-s -w" -o ${APP}
go generate
go build -ldflags "$(shortVersion) -s -w" -v -o ${APP}

.PHONY: x64linux
x64linux:
go generate
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc\
go build -ldflags "-s -w -linkmode external -extldflags -static" -o ${APP}-x64linux
go build -ldflags "$(shortVersion) -s -w" -v -o ${APP}-x64linux

.PHONY: windows
windows:
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc\
go build -ldflags "-s -w" -o ${APP}-windows.exe
go build -ldflags "$(shortVersion) -s -w" -o ${APP}-windows.exe

.PHONY: arm32
arm32:
go generate
CGO_ENABLED=1 GOOS=linux GOARCH=arm CC=arm-linux-gnueabi-gcc\
go build -ldflags "-s -w -linkmode external -extldflags -static" -o ${APP}-arm32linux
go build -ldflags "$(shortVersion) -s -w -linkmode external -extldflags -static" -o ${APP}-arm32linux

.PHONY: arm64
arm64:
go generate
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc\
go build -ldflags "-s -w -linkmode external -extldflags -static" -o ${APP}-arm64linux
go build -ldflags "$(shortVersion) -s -w -linkmode external -extldflags -static" -o ${APP}-arm64linux

.PHONY: mips32
mips32:
go generate
# sudo apt-get install gcc-mips-linux-gnu
GOOS=linux GOARCH=mips CGO_ENABLED=1 CC=mips-linux-gnu-gcc\
go build -ldflags "-s -w -linkmode external -extldflags -static" -o ${APP}-mips32linux
go build -ldflags "$(shortVersion) -s -w -linkmode external -extldflags -static" -o ${APP}-mips32linux

.PHONY: mips64
mips64:
go generate
# sudo apt-get install gcc-mips-linux-gnu
GOOS=linux GOARCH=mips64 CGO_ENABLED=1 CC=mips-linux-gnu-gcc\
go build -ldflags "-s -w -linkmode external -extldflags -static" -o ${APP}-mips64linux
go build -ldflags "$(shortVersion) -s -w -linkmode external -extldflags -static" -o ${APP}-mips64linux

.PHONY: mipsel
mipsle:
go generate
# sudo apt-get install gcc-mipsel-linux-gnu
GOOS=linux GOARCH=mipsle CGO_ENABLED=1 GOMIPS=softfloat CC=mipsel-linux-gnu-gcc\
go build -ldflags "-s -w -linkmode external -extldflags -static" -o ${APP}-mipslelinux
go build -ldflags "$(shortVersion) -s -w -linkmode external -extldflags -static" -o ${APP}-mipslelinux

.PHONY: release
release:
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@


## 快速开始
### 源码编译
#### 环境安装
下面是Ubuntu上搭建环境的指令:
```bash
sudo apt install jq cloc protobuf-compiler \
gcc-mingw-w64-x86-64 \
gcc-arm-linux-gnueabi \
gcc-mips-linux-gnu \
gcc-mingw-w64 \
gcc-aarch64-linux-gnu -y
```
> 推荐使用ubuntu开发。

#### 编译
```sh
make
```

### HelloWorld
下面展示一个最简单的设备数据转发案例:
Expand Down
14 changes: 13 additions & 1 deletion bspsupport/eekit_adda_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ import (
DI1 -> PA8
DI2 -> PA9
DI3 -> PA10
USER_GPIO -> PA20
*/
const (
// DO
eekit_DO1 string = "6"
eekit_DO2 string = "7"

// DI
eekit_DI1 string = "8"
eekit_DI2 string = "9"
eekit_DI3 string = "10"
// Use LED
eekit_USER_GPIO string = "20"
)

const (
Expand All @@ -56,11 +60,13 @@ func _EEKIT_GPIOAllInit() int {
gpio8 := "/sys/class/gpio/gpio8/value"
gpio9 := "/sys/class/gpio/gpio9/value"
gpio10 := "/sys/class/gpio/gpio10/value"
gpio20 := "/sys/class/gpio/gpio20/value"
_, err1 := os.Stat(gpio6)
_, err2 := os.Stat(gpio7)
_, err3 := os.Stat(gpio8)
_, err4 := os.Stat(gpio9)
_, err5 := os.Stat(gpio10)
_, err6 := os.Stat(gpio20)
if err1 != nil {
if strings.Contains(err1.Error(), "no such file or directory") {
_EEKIT_GPIOInit(eekit_DO1, eekit_Out)
Expand Down Expand Up @@ -91,6 +97,12 @@ func _EEKIT_GPIOAllInit() int {
fmt.Println("EEKIT_GPIOAllInit DI3 In Mode Ok")
}
}
if err6 != nil {
if strings.Contains(err5.Error(), "no such file or directory") {
_EEKIT_GPIOInit(eekit_USER_GPIO, eekit_Out)
fmt.Println("EEKIT_GPIOAllInit USER_GPIO Out Mode Ok")
}
}
// 返回值无用
return 1
}
Expand Down
24 changes: 19 additions & 5 deletions bspsupport/rhinopi_gpio_ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@

package archsupport

//-----------------------------------------------
// 这是EEKIT网关的DI-DO支持库
//-----------------------------------------------
/*
pins map

DO1 -> PA6
DO2 -> PA7
DI1 -> PA8
DI2 -> PA9
DI3 -> PA10
USER_GPIO -> PA20
*/
import (
"fmt"
"os"
Expand All @@ -27,11 +40,6 @@ import (
*/
const (
__h3_GPIO_PATH = "/sys/class/gpio/gpio%v/value"
// __h3_DO1 = "/sys/class/gpio/gpio6/value" // gpio6
// __h3_DO2 = "/sys/class/gpio/gpio7/value" // gpio7
// __h3_DI1 = "/sys/class/gpio/gpio8/value" // gpio8
// __h3_DI2 = "/sys/class/gpio/gpio9/value" // gpio9
// __h3_DI3 = "/sys/class/gpio/gpio10/value" // gpio10
)

/*
Expand All @@ -54,6 +62,9 @@ func EEKIT_GPIOGetDI2() (int, error) {
func EEKIT_GPIOGetDI3() (int, error) {
return EEKIT_GPIOGetByFile(10)
}
func EEKIT_GPIOGetUserGpio() (int, error) {
return EEKIT_GPIOGetByFile(20)
}
func EEKIT_GPIOGetByFile(pin byte) (int, error) {
return __GPIOGet(fmt.Sprintf(__h3_GPIO_PATH, pin))
}
Expand Down Expand Up @@ -91,6 +102,9 @@ func EEKIT_GPIOSetDI2(value int) error {
func EEKIT_GPIOSetDI3(value int) error {
return EEKIT_GPIOSetByFile(10, value)
}
func EEKIT_GPIOSetUserGpio(value int) error {
return EEKIT_GPIOSetByFile(20, value)
}

func EEKIT_GPIOSetByFile(pin, value int) error {
return __GPIOSet(fmt.Sprintf(__h3_GPIO_PATH, pin), value)
Expand Down
44 changes: 14 additions & 30 deletions common/modbus_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ type Registers struct {
*
*/
type RegisterRW struct {
Tag string `json:"tag" validate:"required" title:"数据Tag"` // 数据Tag
Alias string `json:"alias" validate:"required" title:"别名"` // 别名
Function int `json:"function" validate:"required" title:"Modbus功能"` // Function
SlaverId byte `json:"slaverId" validate:"required" title:"从机ID"` // 从机ID
Address uint16 `json:"address" validate:"required" title:"地址"` // Address
Quantity uint16 `json:"quantity" validate:"required" title:"数量"` // Quantity
Value string `json:"value" title:"值" info:"本地系统的串口路径"` // Value
Tag string `json:"tag" validate:"required" title:"数据Tag"` // 数据Tag
Alias string `json:"alias" validate:"required" title:"别名"` // 别名
Function int `json:"function" validate:"required" title:"Modbus功能"` // Function
SlaverId byte `json:"slaverId" validate:"required" title:"从机ID"` // 从机ID
Address uint16 `json:"address" validate:"required" title:"地址"` // Address
Frequency int64 `json:"frequency" validate:"required" title:"采集频率"` // 间隔
Quantity uint16 `json:"quantity" validate:"required" title:"数量"` // Quantity
Value string `json:"value"` // 运行时数据
}

/*
Expand All @@ -61,28 +62,11 @@ type RegisterW struct {
Values []byte `json:"values"` // Value
}

// Uart "/dev/ttyUSB0"
// BaudRate = 115200
// DataBits = 8
// Parity = "N"
// StopBits = 1
// SlaveId = 1
// Timeout = 5 * time.Second
// TODO: 在0.5以后删除这两个结构体
type RTUConfig struct {
Uart string `json:"uart" validate:"required" title:"串口路径" info:"本地系统的串口路径"`
BaudRate int `json:"baudRate" validate:"required" title:"波特率" info:"串口通信波特率"`
DataBits int `json:"dataBits" validate:"required" title:"数据位" info:"串口通信数据位"`
Parity string `json:"parity" validate:"required" title:"奇偶校验" info:"奇偶校验"`
StopBits int `json:"stopBits" validate:"required" title:"停止位" info:"串口通信停止位"`
}
type ModBusConfig struct {
Mode string `json:"mode" title:"工作模式" info:"UART/TCP"`
Timeout int `json:"timeout" validate:"required" title:"连接超时"`
// Weather allow AutoRequest?
AutoRequest bool `json:"autoRequest" title:"启动轮询"`
// Request Frequency, default 5 second
Frequency int64 `json:"frequency" validate:"required" title:"采集频率"`
Config interface{} `json:"config" validate:"required" title:"工作模式"`
Registers []RegisterRW `json:"registers" validate:"required" title:"寄存器配置"`
Mode string `json:"mode" title:"工作模式" info:"UART/TCP"`
Timeout *int `json:"timeout" validate:"required" title:"连接超时"`
AutoRequest *bool `json:"autoRequest" validate:"required"`
Frequency *int64 `json:"frequency" validate:"required" title:"采集频率"`
Config interface{} `json:"config" validate:"required" title:"工作模式"`
Registers []RegisterRW `json:"registers" validate:"required" title:"寄存器配置"`
}
39 changes: 15 additions & 24 deletions common/siemens_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,21 @@ package common
*
*/
type S1200Config struct {
Host string `json:"host" validate:"required" title:"IP地址"` // 127.0.0.1
Port *int `json:"port" validate:"required" title:"端口号"` // 0
Rack *int `json:"rack" validate:"required" title:"架号"` // 0
Slot *int `json:"slot" validate:"required" title:"槽号"` // 1
Model string `json:"model" validate:"required" title:"型号"` // s7-200 s7 1500
Timeout *int `json:"timeout" validate:"required" title:"连接超时时间"` // 5s
IdleTimeout *int `json:"idleTimeout" validate:"required" title:"心跳超时时间"` // 5s
//
// Weather allow AutoRequest?
AutoRequest bool `json:"autoRequest" title:"启动轮询"`
// Request Frequency, default 5 second
Frequency int64 `json:"frequency" validate:"required" title:"采集频率"`
Blocks []S1200Block `json:"blocks" validate:"required" title:"采集配置"` // Db
Host string `json:"host" validate:"required" title:"IP地址:端口号"` // 127.0.0.1
Model string `json:"model" validate:"required" title:"型号"` // s7-200 s7 1500
Rack *int `json:"rack" validate:"required" title:"架号"` // 0
Slot *int `json:"slot" validate:"required" title:"槽号"` // 1
Timeout *int `json:"timeout" validate:"required" title:"连接超时时间"` // 5s
IdleTimeout *int `json:"idleTimeout" validate:"required" title:"心跳超时时间"` // 5s
AutoRequest *bool `json:"autoRequest" title:"启动轮询"`
Blocks []S1200Block `json:"blocks" validate:"required" title:"采集配置"` // Db
}
type S1200Block struct {
Tag string `json:"tag" title:"数据tag"` // 数据tag
Address int `json:"address" title:"地址"` // 地址
Start int `json:"start" title:"起始地址"` // 起始地址
Size int `json:"size" title:"数据长度"` // 数据长度
}
type S1200BlockValue struct {
Tag string `json:"tag" title:"数据tag"` // 数据tag
Address int `json:"address" title:"地址"` // 地址
Start int `json:"start" title:"起始地址"` // 起始地址
Size int `json:"size" title:"服务地址"` // 数据长度
Value []byte `json:"value" title:"数据长度"` // 值
Tag string `json:"tag" validate:"required" title:"数据tag"` // 数据tag
Type string `json:"type" validate:"required" title:"地址"` // MB | DB |FB
Frequency int64 `json:"frequency" validate:"required" title:"采集频率"`
Address int `json:"address" validate:"required" title:"地址"` // 地址
Start int `json:"start" validate:"required" title:"起始地址"` // 起始地址
Size int `json:"size" validate:"required" title:"服务地址"` // 数据长度
Value string `json:"value,omitempty" validate:"required" title:"数据Hex"` // 值
}
Loading
Loading