Skip to content

Commit 6d12a3b

Browse files
committed
tcp-server插件基本正常
1 parent 9558537 commit 6d12a3b

File tree

12 files changed

+110
-101
lines changed

12 files changed

+110
-101
lines changed

cmd/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ import (
1010
"github.com/busy-cloud/boat/service"
1111
_ "github.com/busy-cloud/boat/table"
1212
"github.com/busy-cloud/boat/web"
13-
_ "github.com/busy-cloud/connector"
1413
_ "github.com/busy-cloud/dash"
1514
_ "github.com/busy-cloud/influxdb"
1615
_ "github.com/busy-cloud/modbus"
17-
_ "github.com/busy-cloud/noob"
16+
_ "github.com/busy-cloud/tcp-server"
1817
_ "github.com/busy-cloud/user"
1918
_ "github.com/god-jason/iot-master" //主程序
2019
"github.com/spf13/pflag"

go.mod

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
module github.com/god-jason/iot-master
22

3-
go 1.23.0
3+
go 1.23.6
44

55
require (
66
github.com/PaesslerAG/gval v1.2.4
77
github.com/busy-cloud/boat v0.5.2
88
github.com/busy-cloud/boat-ui v0.5.0
9-
github.com/busy-cloud/connector v0.5.0
109
github.com/busy-cloud/dash v0.5.0
1110
github.com/busy-cloud/influxdb v0.2.3
1211
github.com/busy-cloud/modbus v0.2.13
13-
github.com/busy-cloud/noob v0.5.0
12+
github.com/busy-cloud/tcp-server v0.0.7
1413
github.com/busy-cloud/user v0.5.0
1514
github.com/gin-gonic/gin v1.10.1
1615
github.com/spf13/cast v1.8.0
@@ -22,7 +21,6 @@ require (
2221
require (
2322
filippo.io/edwards25519 v1.1.0 // indirect
2423
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
25-
github.com/busy-cloud/serial v1.6.5 // indirect
2624
github.com/bytedance/sonic v1.13.2 // indirect
2725
github.com/bytedance/sonic/loader v0.2.4 // indirect
2826
github.com/cloudwego/base64x v0.1.5 // indirect
@@ -64,7 +62,6 @@ require (
6462
github.com/modern-go/reflect2 v1.0.2 // indirect
6563
github.com/oapi-codegen/runtime v1.0.0 // indirect
6664
github.com/panjf2000/ants/v2 v2.11.3 // indirect
67-
github.com/panjf2000/gnet/v2 v2.7.0 // indirect
6865
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
6966
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
7067
github.com/robfig/cron/v3 v3.0.1 // indirect
@@ -83,11 +80,8 @@ require (
8380
github.com/tklauser/numcpus v0.10.0 // indirect
8481
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
8582
github.com/ugorji/go/codec v1.2.14 // indirect
86-
github.com/valyala/bytebufferpool v1.0.0 // indirect
8783
github.com/yusufpapurcu/wmi v1.2.4 // indirect
88-
github.com/zgwit/goselect v0.1.3 // indirect
8984
go.uber.org/multierr v1.11.0 // indirect
90-
go.uber.org/zap v1.27.0 // indirect
9185
golang.org/x/arch v0.17.0 // indirect
9286
golang.org/x/crypto v0.38.0 // indirect
9387
golang.org/x/net v0.40.0 // indirect

go.sum

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ github.com/busy-cloud/boat v0.5.2 h1:QUskZpuB6Fr8dPhTK3XM7avaDj2WoCS0CNzojfk9txc
1414
github.com/busy-cloud/boat v0.5.2/go.mod h1:pArkdISo2peFMtlA61Cex6tftBZ7cXDqfgd/UKZ1zIU=
1515
github.com/busy-cloud/boat-ui v0.5.0 h1:yTmAtqjQNQJ4IKR5MBrnb6PzTuR9k0d+1aejW+k87LM=
1616
github.com/busy-cloud/boat-ui v0.5.0/go.mod h1:t9DwLmJyjbPHcm+IKzC9qUE7futO0pLigI9HIPbkhg0=
17-
github.com/busy-cloud/connector v0.5.0 h1:kydyvq+DozOmF+MkkVse8s8KI5xvL6DaYtA6vv1L6gE=
18-
github.com/busy-cloud/connector v0.5.0/go.mod h1:QKpr4iXrUj4nwjUkMxcy5buPQ8emJ8dvSYGuxstbkIA=
1917
github.com/busy-cloud/dash v0.5.0 h1:v7onTsSlRKKPN/OHnczyAfPL8+h0pIzrF6FHNh1IJT8=
2018
github.com/busy-cloud/dash v0.5.0/go.mod h1:YpLLCh50vwRy47NM9FFrAeg07Mh0qLxz6dzqYPJZm9c=
2119
github.com/busy-cloud/influxdb v0.2.3 h1:VW+5/q+/ClImAzrxwNT9zaXIbuHKch6rhKy9sJfOygg=
2220
github.com/busy-cloud/influxdb v0.2.3/go.mod h1:6mfMxknjGxBWcCOaLAkjig6YmssQSQbDPCeGeccCNPM=
2321
github.com/busy-cloud/modbus v0.2.13 h1:nFCxZLWwApU/sz4Nfy4mgQVgbUZDr8HdULFENDm8Ha4=
2422
github.com/busy-cloud/modbus v0.2.13/go.mod h1:voMqngF86wuY2p4BWf7wfI/5xsmDrRLuVBfjhYqijm8=
25-
github.com/busy-cloud/noob v0.5.0 h1:ejX2+YxRJbjbM5+gZeiwJ6htq5reEwAS+ip7b/OSci4=
26-
github.com/busy-cloud/noob v0.5.0/go.mod h1:G91PscNeLeOGag8xd6lsP7uEOOhzIfS26jMDam84kfY=
27-
github.com/busy-cloud/serial v1.6.5 h1:rDq99/cEDFUfZNJ0WmI/6iZz7LvmEDQcyw2gibhLI/E=
28-
github.com/busy-cloud/serial v1.6.5/go.mod h1:8IkXeVoYe424W0/giUH1Z2YTa9eqPDk/FtRcCu/7khI=
23+
github.com/busy-cloud/tcp-server v0.0.7 h1:EM786yhzUTmrh//TbRK/5GsbKcx3fnJHfE5Po23etc0=
24+
github.com/busy-cloud/tcp-server v0.0.7/go.mod h1:OOirzSeZQkmYsQDoWaGz8j1h1BF+7VL9cnSS6YRMcKM=
2925
github.com/busy-cloud/user v0.5.0 h1:Td5MdA9ichR9PCHp3o+FueezP/RW/TVXhYJE3/jGIEY=
3026
github.com/busy-cloud/user v0.5.0/go.mod h1:3d6+JNs3yy0DJXZAJwP7NLFMKpCMa6Ag/ACwCioirxg=
3127
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
@@ -153,8 +149,6 @@ github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
153149
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
154150
github.com/panjf2000/ants/v2 v2.11.3 h1:AfI0ngBoXJmYOpDh9m516vjqoUu2sLrIVgppI9TZVpg=
155151
github.com/panjf2000/ants/v2 v2.11.3/go.mod h1:8u92CYMUc6gyvTIw8Ru7Mt7+/ESnJahz5EVtqfrilek=
156-
github.com/panjf2000/gnet/v2 v2.7.0 h1:gR2fOhHHJ7Ds9tpqc2jxKgjFeaZmorTie5tDvqDAGEI=
157-
github.com/panjf2000/gnet/v2 v2.7.0/go.mod h1:HpNv+iQrIOeil1eyhdnKDlui7jivyMf0K3xwaeHKnh8=
158152
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
159153
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
160154
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -215,18 +209,12 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
215209
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
216210
github.com/ugorji/go/codec v1.2.14 h1:yOQvXCBc3Ij46LRkRoh4Yd5qK6LVOgi0bYOXfb7ifjw=
217211
github.com/ugorji/go/codec v1.2.14/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
218-
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
219-
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
220212
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
221213
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
222-
github.com/zgwit/goselect v0.1.3 h1:0kAVui7agIqP2QchiBnuOHbeMMD+7z72Hmrd9A92Nx0=
223-
github.com/zgwit/goselect v0.1.3/go.mod h1:ygq9Kn15bCJer7uXny3lvsCFPHNnfFBgIOExd3ufUC8=
224214
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
225215
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
226216
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
227217
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
228-
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
229-
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
230218
golang.org/x/arch v0.17.0 h1:4O3dfLzd+lQewptAHqjewQZQDyEdejz3VwgeYwkZneU=
231219
golang.org/x/arch v0.17.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
232220
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=

link/link-api.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package link
2+
3+
import (
4+
"github.com/busy-cloud/boat/api"
5+
"github.com/busy-cloud/boat/curd"
6+
)
7+
8+
func init() {
9+
api.Register("GET", "iot/link/list", curd.ApiList[Link]())
10+
api.Register("POST", "iot/link/search", curd.ApiSearch[Link]())
11+
api.Register("POST", "iot/link/create", curd.ApiCreate[Link]())
12+
api.Register("GET", "iot/link/:id", curd.ApiGet[Link]())
13+
api.Register("POST", "iot/link/:id", curd.ApiUpdate[Link]("id", "name", "description", "linker", "disabled", "protocol", "protocol_options"))
14+
api.Register("GET", "iot/link/:id/delete", curd.ApiDelete[Link]())
15+
api.Register("GET", "iot/link/:id/enable", curd.ApiDisable[Link](false))
16+
api.Register("GET", "iot/link/:id/disable", curd.ApiDisable[Link](true))
17+
18+
}

link/link.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ type Link struct {
2222
}
2323

2424
type Status struct {
25-
Running bool `json:"running"`
26-
Error string `json:"error"`
25+
Running bool `json:"running,omitempty" xorm:"-"`
26+
Error string `json:"error,omitempty" xorm:"-"`
2727
}

pages/device-create.json

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,11 @@
1313
},
1414
{
1515
"type": "button",
16-
"label": "选择连接器ID",
16+
"label": "选择连接ID",
1717
"action": {
1818
"type": "dialog",
19-
"page": "connector/linker-choose",
20-
"after_close": "this.editor.patchValue({linker_id: result.id})"
21-
}
22-
},
23-
{
24-
"type": "button",
25-
"label": "选择TCP连接器ID",
26-
"action": {
27-
"type": "dialog",
28-
"page": "connector/tcp-incoming-choose",
29-
"after_close": "this.editor.patchValue({incoming_id: result.id})"
19+
"page": "iot/link-choose",
20+
"after_close": "this.editor.patchValue({link_id: result.id})"
3021
}
3122
}
3223
],
@@ -57,16 +48,9 @@
5748
}
5849
},
5950
{
60-
"key": "linker_id",
61-
"label": "连接器ID",
62-
"type": "text",
63-
"placeholder": "使用连接器时需要选择"
64-
},
65-
{
66-
"key": "incoming_id",
67-
"label": "TCP连接器ID",
68-
"type": "text",
69-
"placeholder": "TCP服务器时需要选择"
51+
"key": "link_id",
52+
"label": "连接ID",
53+
"type": "text"
7054
},
7155
{
7256
"key": "station",
@@ -86,6 +70,6 @@
8670
"mount": "this.data.product_id=this.params.product_id; setTimeout(()=>this.load_product(), 100)",
8771
"methods": {
8872
"load_product": "this.editor.value.product_id && this.request.get('iot/product/'+this.editor.value.product_id).subscribe(res=>{if(!res.error) this.load_protocol_station(res.data.protocol)})",
89-
"load_protocol_station": ["p", "this.request.get('iot/protocol/'+p).subscribe(res=>{this.content.fields[6].children=res.station; setTimeout(()=>this.editor.rebuild(), 200)})"]
73+
"load_protocol_station": ["p", "this.request.get('iot/protocol/'+p).subscribe(res=>{this.content.fields[5].children=res.station; setTimeout(()=>this.editor.rebuild(), 200)})"]
9074
}
9175
}

pages/device-detail.json

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,14 @@
5656
}
5757
},
5858
{
59-
"key": "linker_id",
60-
"label": "连接器ID",
61-
"type": "text",
62-
"action": {
63-
"type": "page",
64-
"page": "connector/linker-detail",
65-
"params_func": "return {id: data.linker_id}"
66-
}
59+
"key": "linker",
60+
"label": "连接器",
61+
"type": "text"
6762
},
6863
{
69-
"key": "incoming_id",
70-
"label": "TCP连接器ID",
71-
"type": "text",
72-
"action": {
73-
"type": "page",
74-
"page": "connector/tcp-incoming-detail",
75-
"params_func": "return {id: data.incoming_id}"
76-
}
64+
"key": "link_id",
65+
"label": "连接器ID",
66+
"type": "text"
7767
},
7868
{
7969
"key": "station",

pages/device-edit.json

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,11 @@
1313
},
1414
{
1515
"type": "button",
16-
"label": "选择连接器ID",
16+
"label": "选择连接ID",
1717
"action": {
1818
"type": "dialog",
19-
"page": "connector/linker-choose",
20-
"after_close": "this.editor.patchValue({linker_id: result.id})"
21-
}
22-
},
23-
{
24-
"type": "button",
25-
"label": "选择TCP连接器ID",
26-
"action": {
27-
"type": "dialog",
28-
"page": "connector/tcp-incoming-choose",
29-
"after_close": "this.editor.patchValue({incoming_id: result.id})"
19+
"page": "iot/link-choose",
20+
"after_close": "this.editor.patchValue({link_id: result.id})"
3021
}
3122
}
3223
],
@@ -56,16 +47,9 @@
5647
}
5748
},
5849
{
59-
"key": "linker_id",
60-
"label": "连接器ID",
61-
"type": "text",
62-
"placeholder": "使用连接器时需要选择"
63-
},
64-
{
65-
"key": "incoming_id",
66-
"label": "TCP连接器ID",
67-
"type": "text",
68-
"placeholder": "TCP服务器时需要选择"
50+
"key": "link_id",
51+
"label": "连接ID",
52+
"type": "text"
6953
},
7054
{
7155
"key": "station",
@@ -87,6 +71,6 @@
8771
"mount": "",
8872
"methods": {
8973
"load_product": "this.editor.value.product_id && this.request.get('iot/product/'+this.editor.value.product_id).subscribe(res=>{if(!res.error) this.load_protocol_station(res.data.protocol)})",
90-
"load_protocol_station": ["p", "this.request.get('iot/protocol/'+p).subscribe(res=>{this.content.fields[6].children=res.station; setTimeout(()=>this.editor.rebuild(), 200)})"]
74+
"load_protocol_station": ["p", "this.request.get('iot/protocol/'+p).subscribe(res=>{this.content.fields[5].children=res.station; setTimeout(()=>this.editor.rebuild(), 200)})"]
9175
}
9276
}

pages/device-import.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,9 @@
2727
}
2828
},
2929
{
30-
"key": "linker_id",
31-
"label": "连接器ID",
32-
"type": "text",
33-
"placeholder": "使用连接器时需要选择"
34-
},
35-
{
36-
"key": "incoming_id",
37-
"label": "TCP连接器ID",
38-
"type": "text",
39-
"placeholder": "TCP服务器时需要选择"
30+
"key": "link_id",
31+
"label": "连接ID",
32+
"type": "text"
4033
},
4134
{
4235
"key": "station",

pages/device.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,6 @@
110110
"type": "date"
111111
}
112112
],
113-
"search_api": "iot/device/search"
113+
"search_api": "iot/device/search",
114+
"mount": "if(this.params.link_id)this.filter.link_id=this.params.link_id;"
114115
}

0 commit comments

Comments
 (0)