1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package main
- import (
- "fmt"
- "smart_tunnel_edge/service"
- "smart_tunnel_edge/timer"
- "smart_tunnel_edge/util/config"
- "smart_tunnel_edge/util/logger"
- )
- func main() {
- logger.InitLog() //初始化日志
- service.InitMqtt() //初始化mqtt
- err := config.LoadSerialConfig()
- if err != nil {
- logger.Logger.Errorf("加载串口配置失败: %v", err)
- return
- }
- //打开串口并监听
- if err := service.OpenSerialPort(config.SerialConfig.SerialMap); err != nil {
- fmt.Printf("处理串口时发生错误: %v", err)
- return
- }
- //初始化设备
- err = config.LoadDevConfig()
- if err != nil {
- logger.Logger.Errorf("加载设备配置失败: %v", err)
- return
- }
- for _, dev := range config.DevConfig.EnvDevs { //循环设备制定采集任务
- go service.StartDeviceCollection(dev)
- }
- service.InitControl()
- go timer.TimeTasks()
- select {}
- }
|