机舱采集器——不在使用
This commit is contained in:
12
1.Software/UI/gateway-ui/model/01-netcfg.yaml
Normal file
12
1.Software/UI/gateway-ui/model/01-netcfg.yaml
Normal 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]
|
||||
131
1.Software/UI/gateway-ui/model/conf.go
Normal file
131
1.Software/UI/gateway-ui/model/conf.go
Normal 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
|
||||
}
|
||||
127
1.Software/UI/gateway-ui/model/config.toml
Normal file
127
1.Software/UI/gateway-ui/model/config.toml
Normal 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
|
||||
|
||||
61
1.Software/UI/gateway-ui/model/netconf.go
Normal file
61
1.Software/UI/gateway-ui/model/netconf.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user