机舱采集器——不在使用

This commit is contained in:
张鹏
2024-11-19 17:19:21 +08:00
parent 813ab44f75
commit 41a0ea682f
1266 changed files with 926903 additions and 250 deletions

Binary file not shown.

View File

@@ -0,0 +1 @@
#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50}#nav{padding:30px}#nav a{font-weight:700;color:#2c3e50}#nav a.router-link-exact-active{color:#42b983}.page[data-v-68b3372b]{width:1920px;height:1080px;background:#f5f5f5}.page .header[data-v-68b3372b]{width:1920px;height:82px;background:#346cf5}.page .header .title[data-v-68b3372b]{font-size:30px;font-family:SourceHanSansCN-Medium,SourceHanSansCN;font-weight:500;color:#fff;line-height:82px;float:left;margin-left:30px}.page .content[data-v-68b3372b]{width:1860px;height:938px;background:#fff;margin:30px}.page .content .sn[data-v-68b3372b]{height:64px;padding:12px 30px;border-bottom:1px solid #dadada}.page .content .sn .sn_content[data-v-68b3372b]{float:left;font-size:24px;font-family:SourceHanSansCN-Bold,SourceHanSansCN;font-weight:700;color:#336bf6;line-height:36px}.page .content .sn .edit_btn[data-v-68b3372b]{float:right;width:94px;height:40px;border-radius:5px}.page .configuration[data-v-68b3372b]{margin:30px}.page .configuration .device[data-v-68b3372b]{position:relative;width:1800px;height:325px;border:1px solid #dadada;border-radius:4px}.page .configuration .device .device_from[data-v-68b3372b]{margin-top:60px}.page .configuration .device .device_from .device_title[data-v-68b3372b]{font-size:18px}.page .configuration .device .device_from .device_input[data-v-68b3372b]{width:100%;height:36px;border-radius:4px;font-size:18px}.page .configuration .device[data-v-68b3372b]:after{content:"设备配置";position:absolute;left:20px;top:-15px;width:80px;text-align:center;font-size:20px;font-weight:500;background:#fff}.page .configuration .channel[data-v-68b3372b]{position:relative;width:1800px;height:465px;border:1px solid #dadada;border-radius:4px;margin-top:30px;padding:30px}.page .configuration .channel[data-v-68b3372b]:after{content:"设备配置";position:absolute;left:20px;top:-15px;width:80px;text-align:center;font-size:20px;font-weight:500;background:#fff}.deviceInput[data-v-68b3372b]{font-size:16px}[data-v-68b3372b] .ant-table-thead>tr>th{font-size:18px;background:hsla(0,0%,95.3%,.67);font-weight:500;font-family:SourceHanSansCN-Medium,SourceHanSansCN;color:#434343}[data-v-68b3372b] .ant-table-thead>tr>th:first-child{background:#fff}.ant-table-striped[data-v-68b3372b] .first_column td:first-child{background-color:hsla(0,0%,95.3%,.67);font-size:18px}.page[data-v-76fe6fa3]{position:relative;width:1920px;height:1080px;background:url(../img/login.3e8bbcda.png)}.page .content[data-v-76fe6fa3]{position:absolute;right:230px;top:430px;width:422px;height:328px;background:#fff;border-radius:4px;padding:41px}.page .content .title[data-v-76fe6fa3]{font-size:36px;font-family:SourceHanSansCN-Regular,SourceHanSansCN;font-weight:400;color:#336bf6;line-height:15px}.page .content .password[data-v-76fe6fa3]{width:340px;height:50px;border-radius:2px;border:1px solid hsla(0,0%,59.2%,.45)}.page .content .submit[data-v-76fe6fa3]{width:340px;height:50px;background:#336bf6;border-radius:2px;margin-top:10px;font-size:24px;font-family:SourceHanSansCN-Regular,SourceHanSansCN}

View File

@@ -0,0 +1 @@
body,html{width:100%;height:100%}input::-ms-clear,input::-ms-reveal{display:none}*,:after,:before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{margin:0}[tabindex="-1"]:focus{outline:none}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5em;font-weight:500}p{margin-top:0;margin-bottom:1em}abbr[data-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline;text-decoration:underline dotted;border-bottom:0;cursor:help}address{margin-bottom:1em;font-style:normal;line-height:inherit}input[type=number],input[type=password],input[type=text],textarea{-webkit-appearance:none}dl,ol,ul{margin-top:0;margin-bottom:1em}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:500}dd{margin-bottom:.5em;margin-left:0}blockquote{margin:0 0 1em}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}code,kbd,pre,samp{font-size:1em;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace}pre{margin-top:0;margin-bottom:1em;overflow:auto}figure{margin:0 0 1em}img{vertical-align:middle;border-style:none}[role=button],a,area,button,input:not([type=range]),label,select,summary,textarea{touch-action:manipulation}table{border-collapse:collapse}caption{padding-top:.75em;padding-bottom:.3em;text-align:left;caption-side:bottom}button,input,optgroup,select,textarea{margin:0;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;margin:0;padding:0;border:0}legend{display:block;width:100%;max-width:100%;margin-bottom:.5em;padding:0;color:inherit;font-size:1.5em;line-height:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item}template{display:none}[hidden]{display:none!important}mark{padding:.2em;background-color:#feffe6}

BIN
1.Software/UI/dist/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 KiB

1
1.Software/UI/dist/index.html vendored Normal file
View File

@@ -0,0 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>风机在线监测系统采集器参数配置</title><link href="/css/app.28a24e8f.css" rel="preload" as="style"><link href="/css/chunk-vendors.3fdb4363.css" rel="preload" as="style"><link href="/js/app.c222699e.js" rel="preload" as="script"><link href="/js/chunk-vendors.089a9f71.js" rel="preload" as="script"><link href="/css/chunk-vendors.3fdb4363.css" rel="stylesheet"><link href="/css/app.28a24e8f.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but fans_monitor doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.089a9f71.js"></script><script src="/js/app.c222699e.js"></script></body></html>

2
1.Software/UI/dist/js/app.c222699e.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50}#nav{padding:30px}#nav a{font-weight:700;color:#2c3e50}#nav a.router-link-exact-active{color:#42b983}.page[data-v-0d4e8ee6]{width:100%;height:100%;background:#f5f5f5}.page .header[data-v-0d4e8ee6]{width:1920px;height:82px;background:#346cf5}.page .header .title[data-v-0d4e8ee6]{font-size:30px;font-family:SourceHanSansCN-Medium,SourceHanSansCN;font-weight:500;color:#fff;line-height:82px;float:left;margin-left:30px}.page .content[data-v-0d4e8ee6]{width:100%;height:100%;background:#fff;margin:30px}.page .content .sn[data-v-0d4e8ee6]{height:64px;padding:12px 30px;border-bottom:1px solid #dadada}.page .content .sn .sn_content[data-v-0d4e8ee6]{float:left;font-size:24px;font-family:SourceHanSansCN-Bold,SourceHanSansCN;font-weight:700;color:#336bf6;line-height:36px}.page .content .sn .edit_btn[data-v-0d4e8ee6]{float:right;width:94px;height:40px;border-radius:5px}.page .configuration[data-v-0d4e8ee6]{margin:30px}.page .configuration .device[data-v-0d4e8ee6]{position:relative;width:100%;height:325px;border:1px solid #dadada;border-radius:4px}.page .configuration .device .device_from[data-v-0d4e8ee6]{margin-top:60px}.page .configuration .device .device_from .device_title[data-v-0d4e8ee6]{font-size:18px}.page .configuration .device .device_from .device_input[data-v-0d4e8ee6]{width:100%;height:36px;border-radius:4px;font-size:18px}.page .configuration .device[data-v-0d4e8ee6]:after{content:"设备配置";position:absolute;left:20px;top:-15px;width:80px;text-align:center;font-size:20px;font-weight:500;background:#fff}.page .configuration .channel[data-v-0d4e8ee6]{position:relative;width:100%;height:100%;border:1px solid #dadada;border-radius:4px;margin-top:30px;padding:30px}.page .configuration .channel[data-v-0d4e8ee6]:after{content:"设备配置";position:absolute;left:20px;top:-15px;width:80px;text-align:center;font-size:20px;font-weight:500;background:#fff}.deviceInput[data-v-0d4e8ee6]{font-size:16px}[data-v-0d4e8ee6] .ant-table-thead>tr>th{font-size:18px;background:hsla(0,0%,95.3%,.67);font-weight:500;font-family:SourceHanSansCN-Medium,SourceHanSansCN;color:#434343}[data-v-0d4e8ee6] .ant-table-thead>tr>th:first-child{background:#fff}.ant-table-striped[data-v-0d4e8ee6] .first_column td:first-child{background-color:hsla(0,0%,95.3%,.67);font-size:18px}.page[data-v-76fe6fa3]{position:relative;width:1920px;height:1080px;background:url(../img/login.3e8bbcda.png)}.page .content[data-v-76fe6fa3]{position:absolute;right:230px;top:430px;width:422px;height:328px;background:#fff;border-radius:4px;padding:41px}.page .content .title[data-v-76fe6fa3]{font-size:36px;font-family:SourceHanSansCN-Regular,SourceHanSansCN;font-weight:400;color:#336bf6;line-height:15px}.page .content .password[data-v-76fe6fa3]{width:340px;height:50px;border-radius:2px;border:1px solid hsla(0,0%,59.2%,.45)}.page .content .submit[data-v-76fe6fa3]{width:340px;height:50px;background:#336bf6;border-radius:2px;margin-top:10px;font-size:24px;font-family:SourceHanSansCN-Regular,SourceHanSansCN}

View File

@@ -0,0 +1 @@
#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50}#nav{padding:30px}#nav a{font-weight:700;color:#2c3e50}#nav a.router-link-exact-active{color:#42b983}.page[data-v-68b3372b]{width:1920px;height:1080px;background:#f5f5f5}.page .header[data-v-68b3372b]{width:1920px;height:82px;background:#346cf5}.page .header .title[data-v-68b3372b]{font-size:30px;font-family:SourceHanSansCN-Medium,SourceHanSansCN;font-weight:500;color:#fff;line-height:82px;float:left;margin-left:30px}.page .content[data-v-68b3372b]{width:1860px;height:938px;background:#fff;margin:30px}.page .content .sn[data-v-68b3372b]{height:64px;padding:12px 30px;border-bottom:1px solid #dadada}.page .content .sn .sn_content[data-v-68b3372b]{float:left;font-size:24px;font-family:SourceHanSansCN-Bold,SourceHanSansCN;font-weight:700;color:#336bf6;line-height:36px}.page .content .sn .edit_btn[data-v-68b3372b]{float:right;width:94px;height:40px;border-radius:5px}.page .configuration[data-v-68b3372b]{margin:30px}.page .configuration .device[data-v-68b3372b]{position:relative;width:1800px;height:325px;border:1px solid #dadada;border-radius:4px}.page .configuration .device .device_from[data-v-68b3372b]{margin-top:60px}.page .configuration .device .device_from .device_title[data-v-68b3372b]{font-size:18px}.page .configuration .device .device_from .device_input[data-v-68b3372b]{width:100%;height:36px;border-radius:4px;font-size:18px}.page .configuration .device[data-v-68b3372b]:after{content:"设备配置";position:absolute;left:20px;top:-15px;width:80px;text-align:center;font-size:20px;font-weight:500;background:#fff}.page .configuration .channel[data-v-68b3372b]{position:relative;width:1800px;height:465px;border:1px solid #dadada;border-radius:4px;margin-top:30px;padding:30px}.page .configuration .channel[data-v-68b3372b]:after{content:"设备配置";position:absolute;left:20px;top:-15px;width:80px;text-align:center;font-size:20px;font-weight:500;background:#fff}.deviceInput[data-v-68b3372b]{font-size:16px}[data-v-68b3372b] .ant-table-thead>tr>th{font-size:18px;background:hsla(0,0%,95.3%,.67);font-weight:500;font-family:SourceHanSansCN-Medium,SourceHanSansCN;color:#434343}[data-v-68b3372b] .ant-table-thead>tr>th:first-child{background:#fff}.ant-table-striped[data-v-68b3372b] .first_column td:first-child{background-color:hsla(0,0%,95.3%,.67);font-size:18px}.page[data-v-76fe6fa3]{position:relative;width:1920px;height:1080px;background:url(../img/login.3e8bbcda.png)}.page .content[data-v-76fe6fa3]{position:absolute;right:230px;top:430px;width:422px;height:328px;background:#fff;border-radius:4px;padding:41px}.page .content .title[data-v-76fe6fa3]{font-size:36px;font-family:SourceHanSansCN-Regular,SourceHanSansCN;font-weight:400;color:#336bf6;line-height:15px}.page .content .password[data-v-76fe6fa3]{width:340px;height:50px;border-radius:2px;border:1px solid hsla(0,0%,59.2%,.45)}.page .content .submit[data-v-76fe6fa3]{width:340px;height:50px;background:#336bf6;border-radius:2px;margin-top:10px;font-size:24px;font-family:SourceHanSansCN-Regular,SourceHanSansCN}

View File

@@ -0,0 +1 @@
body,html{width:100%;height:100%}input::-ms-clear,input::-ms-reveal{display:none}*,:after,:before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{margin:0}[tabindex="-1"]:focus{outline:none}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5em;font-weight:500}p{margin-top:0;margin-bottom:1em}abbr[data-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline;text-decoration:underline dotted;border-bottom:0;cursor:help}address{margin-bottom:1em;font-style:normal;line-height:inherit}input[type=number],input[type=password],input[type=text],textarea{-webkit-appearance:none}dl,ol,ul{margin-top:0;margin-bottom:1em}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:500}dd{margin-bottom:.5em;margin-left:0}blockquote{margin:0 0 1em}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}code,kbd,pre,samp{font-size:1em;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace}pre{margin-top:0;margin-bottom:1em;overflow:auto}figure{margin:0 0 1em}img{vertical-align:middle;border-style:none}[role=button],a,area,button,input:not([type=range]),label,select,summary,textarea{touch-action:manipulation}table{border-collapse:collapse}caption{padding-top:.75em;padding-bottom:.3em;text-align:left;caption-side:bottom}button,input,optgroup,select,textarea{margin:0;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;margin:0;padding:0;border:0}legend{display:block;width:100%;max-width:100%;margin-bottom:.5em;padding:0;color:inherit;font-size:1.5em;line-height:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item}template{display:none}[hidden]{display:none!important}mark{padding:.2em;background-color:#feffe6}

BIN
1.Software/UI/dist2/dist/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 KiB

1
1.Software/UI/dist2/dist/index.html vendored Normal file
View File

@@ -0,0 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>风机在线监测系统采集器参数配置</title><link href="/css/app.07a98a08.css" rel="preload" as="style"><link href="/css/chunk-vendors.3fdb4363.css" rel="preload" as="style"><link href="/js/app.27983fb3.js" rel="preload" as="script"><link href="/js/chunk-vendors.089a9f71.js" rel="preload" as="script"><link href="/css/chunk-vendors.3fdb4363.css" rel="stylesheet"><link href="/css/app.07a98a08.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but fans_monitor doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.089a9f71.js"></script><script src="/js/app.27983fb3.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

0
1.Software/UI/gateway-ui/.gitignore vendored Normal file
View File

View File

@@ -0,0 +1,67 @@
[mqtt]
broker = "192.168.123.200"
ch0_measurpoint = "主轴前轴承"
ch0_measurpointdirection = "水平"
ch0_samplingfrequency = 2000
ch0_samplingtime = 40
ch0_sensorparameters = 500.0
ch1_measurpoint = "主轴后轴承"
ch1_measurpointdirection = "水平"
ch1_samplingfrequency = 2000
ch1_samplingtime = 40
ch1_sensorparameters = 500.0
ch2_measurpoint = "齿轮箱输入轴承"
ch2_measurpointdirection = "水平"
ch2_samplingfrequency = 2000
ch2_samplingtime = 40
ch2_sensorparameters = 500.0
ch3_measurpoint = "齿轮箱高速轴叶轮侧"
ch3_measurpointdirection = "径向"
ch3_samplingfrequency = 4000
ch3_samplingtime = 10
ch3_sensorparameters = 100.0
ch4_measurpoint = "齿轮箱平行级低速级轴承"
ch4_measurpointdirection = "轴向"
ch4_samplingfrequency = 10000
ch4_samplingtime = 6
ch4_sensorparameters = 100.0
ch5_measurpoint = "齿轮箱平行级低速级轴承"
ch5_measurpointdirection = "水平"
ch5_samplingfrequency = 10000
ch5_samplingtime = 6
ch5_sensorparameters = 508.061
ch6_measurpoint = "发电机前轴承"
ch6_measurpointdirection = "径向"
ch6_samplingfrequency = 10000
ch6_samplingtime = 3
ch6_sensorparameters = 508.061
ch7_measurpoint = "发电机后轴承"
ch7_measurpointdirection = "径向"
ch7_samplingfrequency = 10000
ch7_samplingtime = 3
ch7_sensorparameters = 100.0
client_id = "100"
device_id = "10B035041002230110003775"
fansnum = "100"
keepalive = 150
long_rate_strategy = 0
password = ""
port = 1883
sample_rate_strategy = "最大采样频率40KHz*3min"
source = "叶片"
username = ""
windfarm = "安北第四风电场"
[sys]
logpath = "/usr/local/gateway/runtime/log/gateway.log"
ntp = "192.168.123.200"
pidpath = "/usr/local/gateway/runtime/pid/gateway.pid"
secret = "e3274be5c857fb42ab72d786e281b4b8"
[usb]
dbpath = "/usr/local/gateway/runtime/database/gateway.db"
product = 22336
sample_rate = 40000
sample_time = 180
vendor = 1155

Binary file not shown.

View File

@@ -0,0 +1,27 @@
BUILD_DIR = build
SERVICES = gateway-ui
CGO_ENABLED ?= 0
# GOARCH ?= "amd64"
GOARCH ?= arm64
GOOS ?= linux
# GOARM ?= 7
define compile_service
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) go build -ldflags "-s -w" -o ${BUILD_DIR}/$(1) main.go
endef
all: $(SERVICES)
.PHONY: all $(SERVICES)
clean:
rm -rf ${BUILD_DIR}
install:
cp ${BUILD_DIR}/* $(GOBIN)
test:
go test -v -race -count 1 -tags test $(shell go list ./... | grep -v 'vendor\|cmd')
$(SERVICES):
$(call compile_service,$(@))

View File

@@ -0,0 +1,15 @@
network:
version: 2
renderer: networkd
ethernets:
eth1:
dhcp4: "no"
addresses:
- 192.168.123.100/24
routes:
- to: 0.0.0.0/0
via: 192.168.333.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4

View File

@@ -0,0 +1,67 @@
[mqtt]
broker = "192.168.111.112"
ch0_measurpoint = "主轴前轴承"
ch0_measurpointdirection = "水平"
ch0_samplingfrequency = 2000
ch0_samplingtime = 40
ch0_sensorparameters = 500.0
ch1_measurpoint = "主轴后轴承"
ch1_measurpointdirection = "水平"
ch1_samplingfrequency = 2000
ch1_samplingtime = 40
ch1_sensorparameters = 500.0
ch2_measurpoint = "齿轮箱输入轴承"
ch2_measurpointdirection = "水平"
ch2_samplingfrequency = 2000
ch2_samplingtime = 40
ch2_sensorparameters = 500.0
ch3_measurpoint = "齿轮箱高速轴叶轮侧"
ch3_measurpointdirection = "径向"
ch3_samplingfrequency = 4000
ch3_samplingtime = 10
ch3_sensorparameters = 100.0
ch4_measurpoint = "齿轮箱平行级低速级轴承"
ch4_measurpointdirection = "轴向"
ch4_samplingfrequency = 10000
ch4_samplingtime = 6
ch4_sensorparameters = 100.0
ch5_measurpoint = "齿轮箱输出轴承"
ch5_measurpointdirection = "水平"
ch5_samplingfrequency = 10000
ch5_samplingtime = 6
ch5_sensorparameters = 508.061
ch6_measurpoint = "发电机前轴承"
ch6_measurpointdirection = "径向"
ch6_samplingfrequency = 10000
ch6_samplingtime = 3
ch6_sensorparameters = 508.061
ch7_measurpoint = "发电机后轴承"
ch7_measurpointdirection = "径向"
ch7_samplingfrequency = 10000
ch7_samplingtime = 3
ch7_sensorparameters = 100.0
client_id = "308"
device_id = "9543348857670"
fansnum = "888"
keepalive = 150
long_rate_strategy = 0
password = ""
port = 1883
sample_rate_strategy = "最大采样频率40KHz*3min"
source = "叶片"
username = ""
windfarm = "安北第四风电场"
[sys]
logpath = "/usr/local/gateway/runtime/log/gateway.log"
ntp = "0.0.0.0"
pidpath = "/usr/local/gateway/runtime/pid/gateway.pid"
secret = "e3274be5c857fb42ab72d786e281b4b8"
[usb]
dbpath = "/usr/local/gateway/runtime/database/gateway.db"
product = 22336
sample_rate = 40000
sample_time = 180
vendor = 1155

Binary file not shown.

View File

@@ -0,0 +1,93 @@
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw=
github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

View File

@@ -0,0 +1,50 @@
package logger
import (
"errors"
"strings"
)
const (
Error Level = iota + 1
Warn
Info
Debug
)
var ErrInvalidLogLevel = errors.New("unrecognized log level")
// 指定打印日志时的级别
type Level int
var levels = map[Level]string{
Error: "error",
Warn: "warn",
Info: "info",
Debug: "debug",
}
func (lvl Level) String() string {
return levels[lvl]
}
func (lvl Level) isAllowed(logLevel Level) bool {
return lvl <= logLevel
}
// 根据给入的字符串返回日志级别的int值
func (lvl *Level) UnmarshalText(text string) error {
switch strings.ToLower(text) {
case "debug":
*lvl = Debug
case "info":
*lvl = Info
case "warn":
*lvl = Warn
case "error":
*lvl = Error
default:
return ErrInvalidLogLevel
}
return nil
}

View File

@@ -0,0 +1,76 @@
package logger
import (
"fmt"
"io"
logs "log"
"time"
"github.com/go-kit/log"
)
// 打印日志的API
type Logger interface {
Debug(string)
Info(string)
Warn(string)
Error(string)
}
var _ Logger = (*logger)(nil)
type logger struct {
kitLogger log.Logger
level Level
}
// 新建一个go-kit logger的接口封装
func New(out io.Writer, levelText string) (Logger, error) {
var level Level
err := level.UnmarshalText(levelText)
if err != nil {
return nil, fmt.Errorf(`{"level":"error","message":"%s: %s","ts":"%s"}`, err, levelText, time.RFC3339Nano)
}
l := log.NewJSONLogger(log.NewSyncWriter(out))
l = log.With(l, "ts", log.DefaultTimestampUTC)
return &logger{l, level}, err
}
func (l logger) Debug(msg string) {
if Debug.isAllowed(l.level) {
err := l.kitLogger.Log("level", Debug.String(), "message", msg)
if err != nil {
logs.Println(err)
}
}
}
func (l logger) Info(msg string) {
if Info.isAllowed(l.level) {
err := l.kitLogger.Log("level", Info.String(), "message", msg)
if err != nil {
logs.Println(err)
}
}
}
func (l logger) Warn(msg string) {
if Warn.isAllowed(l.level) {
err := l.kitLogger.Log("level", Warn.String(), "message", msg)
if err != nil {
logs.Println(err)
}
}
}
func (l logger) Error(msg string) {
if Error.isAllowed(l.level) {
err := l.kitLogger.Log("level", Error.String(), "message", msg)
if err != nil {
logs.Println(err)
}
}
}

View File

@@ -0,0 +1,136 @@
package main
import (
"context"
"fmt"
l "gateway-ui/log"
"gateway-ui/service"
"gateway-ui/ui"
"log"
"net/http"
"os"
"os/signal"
"time"
assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/gin-gonic/gin"
)
const (
defLogLevel = "debug"
)
func InitRouter(logger l.Logger) *gin.Engine {
r := gin.Default()
var (
css = assetfs.AssetFS{
Asset: ui.Asset,
AssetDir: ui.AssetDir,
AssetInfo: nil,
Prefix: "ui/dist/css",
Fallback: "index.html",
}
img = assetfs.AssetFS{
Asset: ui.Asset,
AssetDir: ui.AssetDir,
AssetInfo: nil,
Prefix: "ui/dist/img",
Fallback: "index.html",
}
js = assetfs.AssetFS{
Asset: ui.Asset,
AssetDir: ui.AssetDir,
AssetInfo: nil,
Prefix: "ui/dist/js",
Fallback: "index.html",
}
fs = assetfs.AssetFS{
Asset: ui.Asset,
AssetDir: ui.AssetDir,
AssetInfo: nil,
Prefix: "ui/dist",
Fallback: "index.html",
}
)
// 加载静态文件
r.StaticFS("/favicon.ico", &fs)
r.StaticFS("/config.ts", &fs)
r.StaticFS("/css", &css)
r.StaticFS("/img", &img)
r.StaticFS("/js", &js)
r.GET("/", func(ctx *gin.Context) {
ctx.Writer.WriteHeader(http.StatusOK)
indexHTML, _ := ui.Asset("ui/dist/index.html")
ctx.Writer.Write(indexHTML)
ctx.Writer.Header().Add("Accept", "text/html")
ctx.Writer.Flush()
})
r.Use(func(context *gin.Context) {
method := context.Request.Method
context.Header("Access-Control-Allow-Origin", "*")
context.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token")
context.Header("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS")
context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
context.Header("Access-Control-Allow-Credentials", "true")
if method == "OPTIONS" {
context.AbortWithStatus(http.StatusNoContent)
}
context.Next()
})
api := r.Group("/api")
h := service.InitHandler(logger)
api.GET("/ping", h.Ping)
api.GET("/conf", h.GetConf)
api.PUT("/conf", h.SetConf)
api.PUT("/upgrade", h.Upgrade)
api.POST("/token", h.GetToken)
return r
}
func main() {
// 初始化日志
logger, err := l.New(os.Stdout, defLogLevel)
if err != nil {
log.Fatalf(fmt.Sprintf("failed to create logger: %s", err))
}
r := InitRouter(logger)
srv := &http.Server{
Addr: "0.0.0.0:9000",
Handler: r,
}
// Listen and Server in 0.0.0.0:8080
go func() {
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
logger.Error(fmt.Sprintf("listen: %s", err))
}
}()
// 等待interrupt信号10秒的超时后关闭服务
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
<-quit
logger.Info("shutdown server...")
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if err := srv.Shutdown(ctx); err != nil {
logger.Error(fmt.Sprintf("server shutdown: %s", err))
}
logger.Info("server exiting!")
}

View File

@@ -0,0 +1,12 @@
network:
version: 2
renderer: networkd
ethernets:
eth1:
dhcp4: no
addresses: [192.168.123.100/24]
routes:
- to: 0.0.0.0/0
via: 192.168.123.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]

View File

@@ -0,0 +1,131 @@
package model
import (
"fmt"
"os"
"github.com/pelletier/go-toml"
)
const (
defConfigFile = "/usr/local/gateway/src/config.toml"
// defConfigFile = "config.toml"
)
type MQTTConfig struct {
Broker string `toml:"broker"`
Port int `toml:"port"`
Client_id string `toml:"client_id"`
Username string `toml:"username"`
Password string `toml:"password"`
Keepalive int `toml:"keepalive"`
Source string `toml:"source"`
Device_id string `toml:"device_id"`
Sample_rate_strategy string `toml:"sample_rate_strategy"`
Long_rate_strategy int `toml:"long_rate_strategy"`
Windfarm string `toml:"windfarm"`
Fansnum string `toml:"fansnum"`
Ch0_measurpoint string `toml:"ch0_measurpoint"`
Ch0_measurpointdirection string `toml:"ch0_measurpointdirection"`
Ch0_sensorparameters float32 `toml:"ch0_sensorparameters"`
Ch0_samplingtime int `toml:"ch0_samplingtime"`
Ch0_samplingfrequency int `toml:"ch0_samplingfrequency"`
Ch1_measurpoint string `toml:"ch1_measurpoint"`
Ch1_measurpointdirection string `toml:"ch1_measurpointdirection"`
Ch1_sensorparameters float32 `toml:"ch1_sensorparameters"`
Ch1_samplingtime int `toml:"ch1_samplingtime"`
Ch1_samplingfrequency int `toml:"ch1_samplingfrequency"`
Ch2_measurpoint string `toml:"ch2_measurpoint"`
Ch2_measurpointdirection string `toml:"ch2_measurpointdirection"`
Ch2_sensorparameters float32 `toml:"ch2_sensorparameters"`
Ch2_samplingtime int `toml:"ch2_samplingtime"`
Ch2_samplingfrequency int `toml:"ch2_samplingfrequency"`
Ch3_measurpoint string `toml:"ch3_measurpoint"`
Ch3_measurpointdirection string `toml:"ch3_measurpointdirection"`
Ch3_sensorparameters float32 `toml:"ch3_sensorparameters"`
Ch3_samplingtime int `toml:"ch3_samplingtime"`
Ch3_samplingfrequency int `toml:"ch3_samplingfrequency"`
Ch4_measurpoint string `toml:"ch4_measurpoint"`
Ch4_measurpointdirection string `toml:"ch4_measurpointdirection"`
Ch4_sensorparameters float32 `toml:"ch4_sensorparameters"`
Ch4_samplingtime int `toml:"ch4_samplingtime"`
Ch4_samplingfrequency int `toml:"ch4_samplingfrequency"`
Ch5_measurpoint string `toml:"ch5_measurpoint"`
Ch5_measurpointdirection string `toml:"ch5_measurpointdirection"`
Ch5_sensorparameters float32 `toml:"ch5_sensorparameters"`
Ch5_samplingtime int `toml:"ch5_samplingtime"`
Ch5_samplingfrequency int `toml:"ch5_samplingfrequency"`
Ch6_measurpoint string `toml:"ch6_measurpoint"`
Ch6_measurpointdirection string `toml:"ch6_measurpointdirection"`
Ch6_sensorparameters float32 `toml:"ch6_sensorparameters"`
Ch6_samplingtime int `toml:"ch6_samplingtime"`
Ch6_samplingfrequency int `toml:"ch6_samplingfrequency"`
Ch7_measurpoint string `toml:"ch7_measurpoint"`
Ch7_measurpointdirection string `toml:"ch7_measurpointdirection"`
Ch7_sensorparameters float32 `toml:"ch7_sensorparameters"`
Ch7_samplingtime int `toml:"ch7_samplingtime"`
Ch7_samplingfrequency int `toml:"ch7_samplingfrequency"`
Ch8_measurpoint string `toml:"ch8_measurpoint"`
Ch8_measurpointdirection string `toml:"ch8_measurpointdirection"`
Ch8_sensorparameters float32 `toml:"ch8_sensorparameters"`
Ch8_samplingtime int `toml:"ch8_samplingtime"`
Ch8_samplingfrequency int `toml:"ch8_samplingfrequency"`
}
type USBConfig struct {
Vendor int `toml:"vendor"`
Product int `toml:"product"`
Sample_rate int `toml:"sample_rate"`
Sample_time int `toml:"sample_time"`
Dbpath string `toml:"dbpath"`
}
type SysConfig struct {
Logpath string `toml:"logpath"`
Pidpath string `toml:"pidpath"`
Ntp string `toml:"ntp"`
Secret string `toml:"secret"`
}
type Config struct {
MQTT MQTTConfig `toml:"mqtt"`
USB USBConfig `toml:"usb"`
Sys SysConfig `toml:"sys"`
}
func (c *Config) Read() (err error) {
data, err := os.ReadFile(defConfigFile)
if err != nil {
err = fmt.Errorf("error reading config file: %s", err)
return
}
if err = toml.Unmarshal(data, c); err != nil {
err = fmt.Errorf("failed to unmarshal config file: %s", err)
return
}
return
}
func (c *Config) Write() (err error) {
data, err := toml.Marshal(c)
if err != nil {
err = fmt.Errorf("failed to marshal config file: %s", err)
return
}
if err = os.WriteFile(defConfigFile, data, os.FileMode(0644)); err != nil {
err = fmt.Errorf("error writing config file: %s", err)
return
}
return
}

View File

@@ -0,0 +1,127 @@
[mqtt]
broker = "192.168.123.2"
port = 1883
client_id = "308"
username = ""
password = ""
keepalive = 150
source = "叶片"
device_id = "9543348857670"
sample_rate_strategy = "最大采样频率40KHz*3min"
long_rate_strategy = 0
windfarm = "安北第三风电场"
fansnum = "308"
ch0_measurpoint = "主轴前轴承" #ch0测点位置
ch0_measurpointdirection = "水平" #ch0测点方向
ch0_sensorparameters = 500 #ch0传感器参数mv/G
ch0_samplingtime = 40 #ch0采样时间
ch0_samplingfrequency = 2000 #ch0采样频率
ch1_measurpoint = "主轴后轴承" #ch1测点位置
ch1_measurpointdirection = "水平" #ch1测点方向
ch1_sensorparameters = 500 #ch1传感器参数mv/G
ch1_samplingtime = 40 #ch1采样时间
ch1_samplingfrequency = 2000 #ch1采样频率
ch2_measurpoint = "齿轮箱输入轴承" #ch2测点位置
ch2_measurpointdirection = "水平" #ch2测点方向
ch2_sensorparameters = 500 #ch2传感器参数mv/G
ch2_samplingtime = 40 #ch2采样时间
ch2_samplingfrequency = 2000 #ch2采样频率
ch3_measurpoint = "齿轮箱高速轴叶轮侧" #ch3测点位置
ch3_measurpointdirection = "径向" #ch3测点方向
ch3_sensorparameters = 100 #ch3传感器参数mv/G
ch3_samplingtime = 10 #ch3采样时间
ch3_samplingfrequency = 4000 #ch3采样频率
ch4_measurpoint = "齿轮箱平行级低速级轴承" #ch4测点位置
ch4_measurpointdirection = "轴向" #ch4测点方向
ch4_sensorparameters = 100 #ch4传感器参数mv/G
ch4_samplingtime = 6 #ch4采样时间
ch4_samplingfrequency = 10000 #ch4采样频率
ch5_measurpoint = "齿轮箱输出轴承" #ch5测点位置
ch5_measurpointdirection = "水平" #ch5测点方向
ch5_sensorparameters = 508.061 #ch5传感器参数mv/G
ch5_samplingtime = 6 #ch5采样时间
ch5_samplingfrequency = 10000 #ch5采样频率
ch6_measurpoint = "发电机前轴承" #ch6测点位置
ch6_measurpointdirection = "径向" #ch6测点方向
ch6_sensorparameters = 508.061 #ch6传感器参数mv/G
ch6_samplingtime = 3 #ch6采样时间
ch6_samplingfrequency = 10000 #ch6采样频率
ch7_measurpoint = "发电机后轴承" #ch7测点位置
ch7_measurpointdirection = "径向" #ch7测点方向
ch7_sensorparameters = 100 #ch7传感器参数mv/G
ch7_samplingtime = 3 #ch7采样时间
ch7_samplingfrequency = 10000 #ch7采样频率
ch8_measurpoint = "主轴前轴承" #ch8测点位置
ch8_measurpointdirection = "水平" #ch8测点方向
ch8_sensorparameters = 500 #ch8传感器参数mv/G
ch8_samplingtime = 40 #ch8采样时间
ch8_samplingfrequency = 2000 #ch8采样频率
ch9_measurpoint = "主轴后轴承" #ch9测点位置
ch9_measurpointdirection = "水平" #ch9测点方向
ch9_sensorparameters = 500 #ch9传感器参数mv/G
ch9_samplingtime = 40 #ch9采样时间
ch9_samplingfrequency = 2000 #ch9采样频率
ch10_measurpoint = "齿轮箱输入轴承" #ch10测点位置
ch10_measurpointdirection = "水平" #ch10测点方向
ch10_sensorparameters = 500 #ch10传感器参数mv/G
ch10_samplingtime = 40 #ch10采样时间
ch10_samplingfrequency = 2000 #ch10采样频率
ch11_measurpoint = "齿轮箱高速轴叶轮侧" #ch11测点位置
ch11_measurpointdirection = "径向" #ch11测点方向
ch11_sensorparameters = 100 #ch11传感器参数mv/G
ch11_samplingtime = 10 #ch11采样时间
ch11_samplingfrequency = 4000 #ch11采样频率
ch12_measurpoint = "齿轮箱平行级低速级轴承" #ch12测点位置
ch12_measurpointdirection = "轴向" #ch12测点方向
ch12_sensorparameters = 100 #ch12传感器参数mv/G
ch12_samplingtime = 6 #ch12采样时间
ch12_samplingfrequency = 10000 #ch12采样频率
ch13_measurpoint = "齿轮箱输出轴承" #ch13测点位置
ch13_measurpointdirection = "水平" #ch13测点方向
ch13_sensorparameters = 508.061 #ch13传感器参数mv/G
ch13_samplingtime = 6 #ch13采样时间
ch13_samplingfrequency = 10000 #ch15采样频率
ch14_measurpoint = "发电机前轴承" #ch14测点位置
ch14_measurpointdirection = "径向" #ch14测点方向
ch14_sensorparameters = 508.061 #ch14传感器参数mv/G
ch14_samplingtime = 3 #ch14采样时间
ch14_samplingfrequency = 10000 #14采样频率
ch15_measurpoint = "发电机后轴承" #ch15测点位置
ch15_measurpointdirection = "径向" #ch15测点方向
ch15_sensorparameters = 100 #ch15传感器参数mv/G
ch15_samplingtime = 3 #ch15采样时间
ch15_samplingfrequency = 10000 #ch15采样频率
[usb]
vendor = 1155
product = 22336
sample_rate = 40000
sample_time = 180
sample_interval = 180
dbpath = "/usr/local/gateway/runtime/database/gateway.db"
[sys]
logpath = "/usr/local/gateway/runtime/log/gateway.log"
pidpath = "/usr/local/gateway/runtime/pid/gateway.pid"
ntp = "0.0.0.0"
secret = "e3274be5c857fb42ab72d786e281b4b8"
# /usr/local/gateway/main.py
# /usr/local/gateway/__init__.py
# /usrlocalt/gateway/src/usb.py

View File

@@ -0,0 +1,61 @@
package model
import (
"fmt"
"os"
"gopkg.in/yaml.v3"
)
const (
defNetConfigFile = "/etc/netplan/01-netcfg.yaml"
// defNetConfigFile = "01-netcfg.yaml"
)
type NetConfig struct {
Network struct {
Version int `yaml:"version"`
Renderer string `yaml:"renderer"`
Ethernets struct {
Eth1 struct {
Dhcp4 string `yaml:"dhcp4"`
Addresses []string `yaml:"addresses"`
Routes []struct {
To string `yaml:"to"`
Via string `yaml:"via"`
} `yaml:"routes"`
Nameservers struct {
Addresses []string `yaml:"addresses"`
} `yaml:"nameservers"`
} `yaml:"eth1"`
} `yaml:"ethernets"`
} `yaml:"network"`
}
func (nc *NetConfig) Read() (err error) {
data, err := os.ReadFile(defNetConfigFile)
if err != nil {
err = fmt.Errorf("error reading netconfig file: %s", err)
return
}
if err = yaml.Unmarshal(data, nc); err != nil {
err = fmt.Errorf("error reading netconfig file: %s", err)
return
}
return
}
func (c *NetConfig) Write() (err error) {
data, err := yaml.Marshal(c)
if err != nil {
err = fmt.Errorf("failed to marshal netconfig file: %s", err)
return
}
if err = os.WriteFile(defNetConfigFile, data, os.FileMode(0644)); err != nil {
err = fmt.Errorf("error writing netconfig file: %s", err)
return
}
return
}

View File

@@ -0,0 +1,5 @@
https://base64.vip/md5.html加密
用户名admin 密码 password
采用md5($admin.$password)方式加密得到secret = "e3274be5c857fb42ab72d786e281b4b8"见config.toml

View File

@@ -0,0 +1,365 @@
package service
import (
"bytes"
"crypto/md5"
"encoding/hex"
"fmt"
"gateway-ui/model"
"net/http"
"os/exec"
"path/filepath"
l "gateway-ui/log"
"github.com/gin-gonic/gin"
)
type Handler struct {
logger l.Logger
}
func InitHandler(logger l.Logger) *Handler {
handler := Handler{
logger: logger,
}
return &handler
}
func (h *Handler) Ping(c *gin.Context) {
h.logger.Info("ping")
c.JSON(http.StatusOK, gin.H{
"message": "pong",
})
}
func (h *Handler) GetConf(c *gin.Context) {
conf := model.Config{}
if err := conf.Read(); err != nil {
c.String(http.StatusInternalServerError, fmt.Sprintf("读取config.toml文件失败: %s", err.Error()))
h.logger.Error(fmt.Sprintf("读取config.toml文件失败: %s", err.Error()))
return
}
netconf := model.NetConfig{}
if err := netconf.Read(); err != nil {
c.String(http.StatusInternalServerError, fmt.Sprintf("读取netcfg.yaml文件失败: %s", err.Error()))
h.logger.Error(fmt.Sprintf("读取netcfg.yaml文件失败: %s", err.Error()))
return
}
res := ConfReq{}
res.Addresses = netconf.Network.Ethernets.Eth1.Addresses[0]
res.Via = netconf.Network.Ethernets.Eth1.Routes[0].Via
res.Broker = conf.MQTT.Broker
h.logger.Info(conf.MQTT.Broker)
res.Client_id = conf.MQTT.Client_id
res.Device_id = conf.MQTT.Device_id
res.Fansnum = conf.MQTT.Fansnum
res.Windfarm = conf.MQTT.Windfarm
res.Ntp = conf.Sys.Ntp
res.Ch0_measurpoint = conf.MQTT.Ch0_measurpoint
res.Ch0_measurpointdirection = conf.MQTT.Ch0_measurpointdirection
res.Ch0_samplingfrequency = conf.MQTT.Ch0_samplingfrequency
res.Ch0_samplingtime = conf.MQTT.Ch0_samplingtime
res.Ch0_sensorparameters = conf.MQTT.Ch0_sensorparameters
res.Ch1_measurpoint = conf.MQTT.Ch1_measurpoint
res.Ch1_measurpointdirection = conf.MQTT.Ch1_measurpointdirection
res.Ch1_samplingfrequency = conf.MQTT.Ch1_samplingfrequency
res.Ch1_samplingtime = conf.MQTT.Ch1_samplingtime
res.Ch1_sensorparameters = conf.MQTT.Ch1_sensorparameters
res.Ch2_measurpoint = conf.MQTT.Ch2_measurpoint
res.Ch2_measurpointdirection = conf.MQTT.Ch2_measurpointdirection
res.Ch2_samplingfrequency = conf.MQTT.Ch2_samplingfrequency
res.Ch2_samplingtime = conf.MQTT.Ch2_samplingtime
res.Ch2_sensorparameters = conf.MQTT.Ch2_sensorparameters
res.Ch3_measurpoint = conf.MQTT.Ch3_measurpoint
res.Ch3_measurpointdirection = conf.MQTT.Ch3_measurpointdirection
res.Ch3_samplingfrequency = conf.MQTT.Ch3_samplingfrequency
res.Ch3_samplingtime = conf.MQTT.Ch3_samplingtime
res.Ch3_sensorparameters = conf.MQTT.Ch3_sensorparameters
res.Ch4_measurpoint = conf.MQTT.Ch4_measurpoint
res.Ch4_measurpointdirection = conf.MQTT.Ch4_measurpointdirection
res.Ch4_samplingfrequency = conf.MQTT.Ch4_samplingfrequency
res.Ch4_samplingtime = conf.MQTT.Ch4_samplingtime
res.Ch4_sensorparameters = conf.MQTT.Ch4_sensorparameters
res.Ch5_measurpoint = conf.MQTT.Ch5_measurpoint
res.Ch5_measurpointdirection = conf.MQTT.Ch5_measurpointdirection
res.Ch5_samplingfrequency = conf.MQTT.Ch5_samplingfrequency
res.Ch5_samplingtime = conf.MQTT.Ch5_samplingtime
res.Ch5_sensorparameters = conf.MQTT.Ch5_sensorparameters
res.Ch6_measurpoint = conf.MQTT.Ch6_measurpoint
res.Ch6_measurpointdirection = conf.MQTT.Ch6_measurpointdirection
res.Ch6_samplingfrequency = conf.MQTT.Ch6_samplingfrequency
res.Ch6_samplingtime = conf.MQTT.Ch6_samplingtime
res.Ch6_sensorparameters = conf.MQTT.Ch6_sensorparameters
res.Ch7_measurpoint = conf.MQTT.Ch7_measurpoint
res.Ch7_measurpointdirection = conf.MQTT.Ch7_measurpointdirection
res.Ch7_samplingfrequency = conf.MQTT.Ch7_samplingfrequency
res.Ch7_samplingtime = conf.MQTT.Ch7_samplingtime
res.Ch7_sensorparameters = conf.MQTT.Ch7_sensorparameters
c.JSON(http.StatusOK, res)
}
func (h *Handler) SetConf(c *gin.Context) {
req := ConfReq{}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, fmt.Sprintf("请求转换JSON失败: %s", err.Error()))
return
}
conf := model.Config{}
if err := conf.Read(); err != nil {
c.JSON(http.StatusInternalServerError, fmt.Sprintf("读取config.toml文件失败: %s", err.Error()))
return
}
netconf := model.NetConfig{}
if err := netconf.Read(); err != nil {
c.JSON(http.StatusInternalServerError, fmt.Sprintf("读取netconf.yaml文件失败: %s", err.Error()))
return
}
if req.Addresses != "" {
netconf.Network.Ethernets.Eth1.Addresses[0] = req.Addresses
}
if req.Via != "" {
netconf.Network.Ethernets.Eth1.Routes[0].Via = req.Via
}
if req.Broker != "" {
conf.MQTT.Broker = req.Broker
}
if req.Client_id != "" {
conf.MQTT.Client_id = req.Client_id
}
if req.Device_id != "" {
conf.MQTT.Device_id = req.Device_id
}
if req.Fansnum != "" {
conf.MQTT.Fansnum = req.Fansnum
}
if req.Windfarm != "" {
conf.MQTT.Windfarm = req.Windfarm
}
if req.Ntp != "" {
conf.Sys.Ntp = req.Ntp
}
if req.Ch0_measurpoint != "" {
conf.MQTT.Ch0_measurpoint = req.Ch0_measurpoint
}
if req.Ch0_measurpointdirection != "" {
conf.MQTT.Ch0_measurpointdirection = req.Ch0_measurpointdirection
}
if req.Ch0_samplingfrequency != 0 {
conf.MQTT.Ch0_samplingfrequency = req.Ch0_samplingfrequency
}
if req.Ch0_samplingtime != 0 {
conf.MQTT.Ch0_samplingtime = req.Ch0_samplingtime
}
if req.Ch0_sensorparameters != 0 {
conf.MQTT.Ch0_sensorparameters = req.Ch0_sensorparameters
}
if req.Ch1_measurpoint != "" {
conf.MQTT.Ch1_measurpoint = req.Ch1_measurpoint
}
if req.Ch1_measurpointdirection != "" {
conf.MQTT.Ch1_measurpointdirection = req.Ch1_measurpointdirection
}
if req.Ch1_samplingfrequency != 0 {
conf.MQTT.Ch1_samplingfrequency = req.Ch1_samplingfrequency
}
if req.Ch1_samplingtime != 0 {
conf.MQTT.Ch1_samplingtime = req.Ch1_samplingtime
}
if req.Ch1_sensorparameters != 0 {
conf.MQTT.Ch1_sensorparameters = req.Ch1_sensorparameters
}
if req.Ch2_measurpoint != "" {
conf.MQTT.Ch2_measurpoint = req.Ch2_measurpoint
}
if req.Ch2_measurpointdirection != "" {
conf.MQTT.Ch2_measurpointdirection = req.Ch2_measurpointdirection
}
if req.Ch2_samplingfrequency != 0 {
conf.MQTT.Ch2_samplingfrequency = req.Ch2_samplingfrequency
}
if req.Ch2_samplingtime != 0 {
conf.MQTT.Ch2_samplingtime = req.Ch2_samplingtime
}
if req.Ch2_sensorparameters != 0 {
conf.MQTT.Ch2_sensorparameters = req.Ch2_sensorparameters
}
if req.Ch3_measurpoint != "" {
conf.MQTT.Ch3_measurpoint = req.Ch3_measurpoint
}
if req.Ch3_measurpointdirection != "" {
conf.MQTT.Ch3_measurpointdirection = req.Ch3_measurpointdirection
}
if req.Ch3_samplingfrequency != 0 {
conf.MQTT.Ch3_samplingfrequency = req.Ch3_samplingfrequency
}
if req.Ch3_samplingtime != 0 {
conf.MQTT.Ch3_samplingtime = req.Ch3_samplingtime
}
if req.Ch3_sensorparameters != 0 {
conf.MQTT.Ch3_sensorparameters = req.Ch3_sensorparameters
}
if req.Ch4_measurpoint != "" {
conf.MQTT.Ch4_measurpoint = req.Ch4_measurpoint
}
if req.Ch4_measurpointdirection != "" {
conf.MQTT.Ch4_measurpointdirection = req.Ch4_measurpointdirection
}
if req.Ch4_samplingfrequency != 0 {
conf.MQTT.Ch4_samplingfrequency = req.Ch4_samplingfrequency
}
if req.Ch4_samplingtime != 0 {
conf.MQTT.Ch4_samplingtime = req.Ch4_samplingtime
}
if req.Ch4_sensorparameters != 0 {
conf.MQTT.Ch4_sensorparameters = req.Ch4_sensorparameters
}
if req.Ch5_measurpoint != "" {
conf.MQTT.Ch5_measurpoint = req.Ch5_measurpoint
}
if req.Ch5_measurpointdirection != "" {
conf.MQTT.Ch5_measurpointdirection = req.Ch5_measurpointdirection
}
if req.Ch5_samplingfrequency != 0 {
conf.MQTT.Ch5_samplingfrequency = req.Ch5_samplingfrequency
}
if req.Ch5_samplingtime != 0 {
conf.MQTT.Ch5_samplingtime = req.Ch5_samplingtime
}
if req.Ch5_sensorparameters != 0 {
conf.MQTT.Ch5_sensorparameters = req.Ch5_sensorparameters
}
if req.Ch6_measurpoint != "" {
conf.MQTT.Ch6_measurpoint = req.Ch6_measurpoint
}
if req.Ch6_measurpointdirection != "" {
conf.MQTT.Ch6_measurpointdirection = req.Ch6_measurpointdirection
}
if req.Ch6_samplingfrequency != 0 {
conf.MQTT.Ch6_samplingfrequency = req.Ch6_samplingfrequency
}
if req.Ch6_samplingtime != 0 {
conf.MQTT.Ch6_samplingtime = req.Ch6_samplingtime
}
if req.Ch6_sensorparameters != 0 {
conf.MQTT.Ch6_sensorparameters = req.Ch6_sensorparameters
}
if req.Ch7_measurpoint != "" {
conf.MQTT.Ch7_measurpoint = req.Ch7_measurpoint
}
if req.Ch7_measurpointdirection != "" {
conf.MQTT.Ch7_measurpointdirection = req.Ch7_measurpointdirection
}
if req.Ch7_samplingfrequency != 0 {
conf.MQTT.Ch7_samplingfrequency = req.Ch7_samplingfrequency
}
if req.Ch7_samplingtime != 0 {
conf.MQTT.Ch7_samplingtime = req.Ch7_samplingtime
}
if req.Ch7_sensorparameters != 0 {
conf.MQTT.Ch7_sensorparameters = req.Ch7_sensorparameters
}
if err := conf.Write(); err != nil {
c.JSON(http.StatusInternalServerError, fmt.Sprintf("修改netcfg.yaml文件失败: %s", err.Error()))
return
}
if req.Addresses != "" || req.Via != "" {
if err := netconf.Write(); err != nil {
c.JSON(http.StatusInternalServerError, fmt.Sprintf("修改config.toml文件失败: %s", err.Error()))
return
}
command := "sleep 1 && netplan apply && sleep 60 && systemctl restart gateway.service"
cmd := exec.Command("/bin/bash", "-c", command)
go cmd.Run()
}
c.JSON(http.StatusOK, "OK")
}
func (h *Handler) GetToken(c *gin.Context) {
user := User{}
err := c.BindJSON(&user)
if err != nil {
c.JSON(http.StatusBadRequest, fmt.Sprintf("参数错误: %s", err.Error()))
return
}
hash := md5.New()
origin := []byte(user.Name)
salt := []byte(user.Password)
_, err = hash.Write(origin)
if err != nil {
c.JSON(http.StatusInternalServerError, fmt.Sprintf("写hash origin错误: %s", err.Error()))
return
}
_, err = hash.Write(salt)
if err != nil {
c.JSON(http.StatusInternalServerError, fmt.Sprintf("写hash salt错误: %s", err.Error()))
return
}
// secret := string(hash.Sum(nil))
secret := hex.EncodeToString(hash.Sum(nil))
conf := model.Config{}
if err := conf.Read(); err != nil {
c.String(http.StatusInternalServerError, fmt.Sprintf("读取secret失败: %s", err.Error()))
return
}
if secret != conf.Sys.Secret {
c.String(http.StatusInternalServerError, "用户名或密码错误")
return
}
c.JSON(http.StatusOK, "OK")
}
func (h *Handler) Upgrade(c *gin.Context) {
// 最大10M
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, int64(10<<20))
header, err := c.FormFile("upload")
if err != nil {
c.JSON(http.StatusBadRequest, fmt.Sprintf("上传文件失败: %s", err.Error()))
return
}
c.SaveUploadedFile(header, header.Filename)
path, err := filepath.Abs(header.Filename)
if err != nil {
c.JSON(http.StatusInternalServerError, fmt.Sprintf("获取绝对路径失败: %s", err.Error()))
return
}
command := "/usr/local/gateway-ui/upgrade.sh " + path
// h.logger.Info(command)
cmd := exec.Command("/bin/bash", "-c", command)
var stderr bytes.Buffer
cmd.Stderr = &stderr
err = cmd.Run()
if err != nil {
c.JSON(http.StatusInternalServerError, fmt.Sprintf("执行升级脚本失败: %s", stderr.String()))
return
}
c.JSON(http.StatusOK, "OK")
}

View File

@@ -0,0 +1,53 @@
package service
import (
"net/http"
"github.com/gin-gonic/gin"
)
type ResponseData struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func ErrorResponse(c *gin.Context, code int, message string) {
c.JSON(code, ResponseData{
Code: code,
Message: message,
Data: nil,
})
}
func SuccessResponse(c *gin.Context, code int, data interface{}) {
c.JSON(code, ResponseData{
Code: code,
Message: "success",
Data: data,
})
}
func UnifiedResponseMiddleware() gin.HandlerFunc {
return func(ctx *gin.Context) {
ctx.Next()
if len(ctx.Errors) > 0 {
err := ctx.Errors.Last()
ErrorResponse(ctx, http.StatusInternalServerError, err.Error())
return
}
if ctx.Writer.Status() == 0 {
ctx.Writer.WriteHeader(http.StatusOK)
}
if ctx.Writer.Status() >= http.StatusOK && ctx.Writer.Status() < http.StatusMultipleChoices {
data, exists := ctx.Get("response_data")
if exists {
SuccessResponse(ctx, ctx.Writer.Status(), data)
return
}
}
}
}

View File

@@ -0,0 +1,74 @@
package service
type User struct {
Name string `json:"name" binding:"required"`
Password string `json:"password" binding:"required"`
}
type ConfReq struct {
Broker string `json:"broker" binding:"required"`
Client_id string `json:"client_id" binding:"required"`
Device_id string `json:"device_id" binding:"required"`
Windfarm string `json:"windfarm" binding:"required"`
Fansnum string `json:"fansnum" binding:"required"`
Addresses string `json:"addresses" binding:"required"`
Via string `json:"via" binding:"required"`
Ntp string `json:"ntp" binding:"required"`
Ch0_measurpoint string `json:"ch0_measurpoint" binding:"required"`
Ch0_measurpointdirection string `json:"ch0_measurpointdirection" binding:"required"`
Ch0_sensorparameters float32 `json:"ch0_sensorparameters" binding:"required"`
Ch0_samplingtime int `json:"ch0_samplingtime" binding:"required"`
Ch0_samplingfrequency int `json:"ch0_samplingfrequency" binding:"required"`
Ch1_measurpoint string `json:"ch1_measurpoint" binding:"required"`
Ch1_measurpointdirection string `json:"ch1_measurpointdirection" binding:"required"`
Ch1_sensorparameters float32 `json:"ch1_sensorparameters" binding:"required"`
Ch1_samplingtime int `json:"ch1_samplingtime" binding:"required"`
Ch1_samplingfrequency int `json:"ch1_samplingfrequency" binding:"required"`
Ch2_measurpoint string `json:"ch2_measurpoint" binding:"required"`
Ch2_measurpointdirection string `json:"ch2_measurpointdirection" binding:"required"`
Ch2_sensorparameters float32 `json:"ch2_sensorparameters" binding:"required"`
Ch2_samplingtime int `json:"ch2_samplingtime" binding:"required"`
Ch2_samplingfrequency int `json:"ch2_samplingfrequency" binding:"required"`
Ch3_measurpoint string `json:"ch3_measurpoint" binding:"required"`
Ch3_measurpointdirection string `json:"ch3_measurpointdirection" binding:"required"`
Ch3_sensorparameters float32 `json:"ch3_sensorparameters" binding:"required"`
Ch3_samplingtime int `json:"ch3_samplingtime" binding:"required"`
Ch3_samplingfrequency int `json:"ch3_samplingfrequency" binding:"required"`
Ch4_measurpoint string `json:"ch4_measurpoint" binding:"required"`
Ch4_measurpointdirection string `json:"ch4_measurpointdirection" binding:"required"`
Ch4_sensorparameters float32 `json:"ch4_sensorparameters" binding:"required"`
Ch4_samplingtime int `json:"ch4_samplingtime" binding:"required"`
Ch4_samplingfrequency int `json:"ch4_samplingfrequency" binding:"required"`
Ch5_measurpoint string `json:"ch5_measurpoint" binding:"required"`
Ch5_measurpointdirection string `json:"ch5_measurpointdirection" binding:"required"`
Ch5_sensorparameters float32 `json:"ch5_sensorparameters" binding:"required"`
Ch5_samplingtime int `json:"ch5_samplingtime" binding:"required"`
Ch5_samplingfrequency int `json:"ch5_samplingfrequency" binding:"required"`
Ch6_measurpoint string `json:"ch6_measurpoint" binding:"required"`
Ch6_measurpointdirection string `json:"ch6_measurpointdirection" binding:"required"`
Ch6_sensorparameters float32 `json:"ch6_sensorparameters" binding:"required"`
Ch6_samplingtime int `json:"ch6_samplingtime" binding:"required"`
Ch6_samplingfrequency int `json:"ch6_samplingfrequency" binding:"required"`
Ch7_measurpoint string `json:"ch7_measurpoint" binding:"required"`
Ch7_measurpointdirection string `json:"ch7_measurpointdirection" binding:"required"`
Ch7_sensorparameters float32 `json:"ch7_sensorparameters" binding:"required"`
Ch7_samplingtime int `json:"ch7_samplingtime" binding:"required"`
Ch7_samplingfrequency int `json:"ch7_samplingfrequency" binding:"required"`
}
type SecretReq struct {
Secret string `json:"secret"`
}

View File

@@ -0,0 +1 @@
#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50}#nav{padding:30px}#nav a{font-weight:700;color:#2c3e50}#nav a.router-link-exact-active{color:#42b983}.page[data-v-68b3372b]{width:1920px;height:1080px;background:#f5f5f5}.page .header[data-v-68b3372b]{width:1920px;height:82px;background:#346cf5}.page .header .title[data-v-68b3372b]{font-size:30px;font-family:SourceHanSansCN-Medium,SourceHanSansCN;font-weight:500;color:#fff;line-height:82px;float:left;margin-left:30px}.page .content[data-v-68b3372b]{width:1860px;height:938px;background:#fff;margin:30px}.page .content .sn[data-v-68b3372b]{height:64px;padding:12px 30px;border-bottom:1px solid #dadada}.page .content .sn .sn_content[data-v-68b3372b]{float:left;font-size:24px;font-family:SourceHanSansCN-Bold,SourceHanSansCN;font-weight:700;color:#336bf6;line-height:36px}.page .content .sn .edit_btn[data-v-68b3372b]{float:right;width:94px;height:40px;border-radius:5px}.page .configuration[data-v-68b3372b]{margin:30px}.page .configuration .device[data-v-68b3372b]{position:relative;width:1800px;height:325px;border:1px solid #dadada;border-radius:4px}.page .configuration .device .device_from[data-v-68b3372b]{margin-top:60px}.page .configuration .device .device_from .device_title[data-v-68b3372b]{font-size:18px}.page .configuration .device .device_from .device_input[data-v-68b3372b]{width:100%;height:36px;border-radius:4px;font-size:18px}.page .configuration .device[data-v-68b3372b]:after{content:"设备配置";position:absolute;left:20px;top:-15px;width:80px;text-align:center;font-size:20px;font-weight:500;background:#fff}.page .configuration .channel[data-v-68b3372b]{position:relative;width:1800px;height:465px;border:1px solid #dadada;border-radius:4px;margin-top:30px;padding:30px}.page .configuration .channel[data-v-68b3372b]:after{content:"设备配置";position:absolute;left:20px;top:-15px;width:80px;text-align:center;font-size:20px;font-weight:500;background:#fff}.deviceInput[data-v-68b3372b]{font-size:16px}[data-v-68b3372b] .ant-table-thead>tr>th{font-size:18px;background:hsla(0,0%,95.3%,.67);font-weight:500;font-family:SourceHanSansCN-Medium,SourceHanSansCN;color:#434343}[data-v-68b3372b] .ant-table-thead>tr>th:first-child{background:#fff}.ant-table-striped[data-v-68b3372b] .first_column td:first-child{background-color:hsla(0,0%,95.3%,.67);font-size:18px}.page[data-v-76fe6fa3]{position:relative;width:1920px;height:1080px;background:url(../img/login.3e8bbcda.png)}.page .content[data-v-76fe6fa3]{position:absolute;right:230px;top:430px;width:422px;height:328px;background:#fff;border-radius:4px;padding:41px}.page .content .title[data-v-76fe6fa3]{font-size:36px;font-family:SourceHanSansCN-Regular,SourceHanSansCN;font-weight:400;color:#336bf6;line-height:15px}.page .content .password[data-v-76fe6fa3]{width:340px;height:50px;border-radius:2px;border:1px solid hsla(0,0%,59.2%,.45)}.page .content .submit[data-v-76fe6fa3]{width:340px;height:50px;background:#336bf6;border-radius:2px;margin-top:10px;font-size:24px;font-family:SourceHanSansCN-Regular,SourceHanSansCN}

View File

@@ -0,0 +1 @@
body,html{width:100%;height:100%}input::-ms-clear,input::-ms-reveal{display:none}*,:after,:before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{margin:0}[tabindex="-1"]:focus{outline:none}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5em;font-weight:500}p{margin-top:0;margin-bottom:1em}abbr[data-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline;text-decoration:underline dotted;border-bottom:0;cursor:help}address{margin-bottom:1em;font-style:normal;line-height:inherit}input[type=number],input[type=password],input[type=text],textarea{-webkit-appearance:none}dl,ol,ul{margin-top:0;margin-bottom:1em}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:500}dd{margin-bottom:.5em;margin-left:0}blockquote{margin:0 0 1em}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}code,kbd,pre,samp{font-size:1em;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace}pre{margin-top:0;margin-bottom:1em;overflow:auto}figure{margin:0 0 1em}img{vertical-align:middle;border-style:none}[role=button],a,area,button,input:not([type=range]),label,select,summary,textarea{touch-action:manipulation}table{border-collapse:collapse}caption{padding-top:.75em;padding-bottom:.3em;text-align:left;caption-side:bottom}button,input,optgroup,select,textarea{margin:0;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;margin:0;padding:0;border:0}legend{display:block;width:100%;max-width:100%;margin-bottom:.5em;padding:0;color:inherit;font-size:1.5em;line-height:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item}template{display:none}[hidden]{display:none!important}mark{padding:.2em;background-color:#feffe6}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 KiB

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>风机在线监测系统采集器参数配置</title><link href="/css/app.28a24e8f.css" rel="preload" as="style"><link href="/css/chunk-vendors.3fdb4363.css" rel="preload" as="style"><link href="/js/app.c222699e.js" rel="preload" as="script"><link href="/js/chunk-vendors.089a9f71.js" rel="preload" as="script"><link href="/css/chunk-vendors.3fdb4363.css" rel="stylesheet"><link href="/css/app.28a24e8f.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but fans_monitor doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.089a9f71.js"></script><script src="/js/app.c222699e.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,116 @@
#!/bin/bash
# 目标路径
BASE_PATH=/usr/local/gateway
BACKUP_PATH=/usr/local/gateway_backup
TMP_PATH=/usr/local/tmp
function backup(){
if [ -d $BASE_PATH ]; then
if [ ! -d $BACKUP_PATH ]; then
mkdir -p $BACKUP_PATH
fi
cp -rf $BASE_PATH/* $BACKUP_PATH/
fi
}
function rollback(){
if [ -d $BASE_PATH ]; then
if [ -d $BACKUP_PATH ]; then
rm -rf $BASE_PATH/*
cp -rf $BACKUP_PATH/* $BASE_PATH/
fi
fi
}
function upgrade(){
if [ ! -d $BASE_PATH ]; then
mkdir -p $BASE_PATH
fi
mkdir -p $TMP_PATH
unzip -d $TMP_PATH $1 > /dev/null 2>&1
if [ 0 -ne $? ];then
echo "解压失败">&2
return 1
fi
rsync -av --progress $TMP_PATH/gateway/* $BASE_PATH/ --exclude bin --exclude include --exclude lib --exclude lib64 --exclude runtime --exclude share --exclude src/config.toml > /dev/null 2>&1
if [ 0 -ne $? ];then
echo "复制文件失败">&2
return 2
fi
return 0
}
function clean(){
rm -rf $BACKUP_PATH/
rm -rf $TMP_PATH/
rm -rf $1
}
function service_ok(){
systemctl status gateway > /dev/null 2>&1
if [ 0 -eq $? ]
then
return 0
else
return 1
fi
}
function stop(){
service_ok
if [ 0 -eq $? ]; then
systemctl stop gateway > /dev/null 2>&1
fi
}
function start(){
stop
cnt=0
while [ 0 -eq 0 ]
do
systemctl start gateway > /dev/null 2>&1
sleep 1
service_ok
if [ 0 -eq $? ]; then
return 0
else
cnt=$[${cnt}+1]
if [ ${cnt} -eq 3 ]; then
return 1
fi
fi
done
}
if [ -n "$1" ];then
stop
backup
upgrade $1
if [ 1 -eq $? ];then
rollback
start
clean $1
exit 1
elif [ 2 -eq $? ];then
rollback
start
clean $1
exit 1
fi
start
if [ 0 -eq $? ];then
clean $1
exit 0
else
rollback
start
echo "服务无法启动,升级失败,回滚到上一版本">&2
clean $1
exit 1
fi
else
echo "没有升级包路径">&2
fi