config.go 911 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package util
  2. import (
  3. "github.com/sirupsen/logrus"
  4. "gopkg.in/yaml.v3"
  5. "lc-smartX/lc/model"
  6. "os"
  7. )
  8. var Config = func() config {
  9. var conf config
  10. file, err := os.ReadFile("./config.yaml")
  11. if err != nil {
  12. logrus.Fatal("配置文件读取失败! error:", err)
  13. }
  14. err = yaml.Unmarshal(file, &conf)
  15. if err != nil {
  16. logrus.Fatal("配置文件解析失败! error:", err)
  17. }
  18. return conf
  19. }()
  20. type config struct {
  21. LedServerAddr string `yaml:"ledServerAddr"`
  22. HikServer hikServer `yaml:"hikServer"`
  23. Cameras []model.CameraInfo `yaml:"cameras"`
  24. OutputDevices []OutputDevice `yaml:"outputDevices"`
  25. }
  26. type hikServer struct {
  27. Addr string `yaml:"addr"`
  28. Path string `yaml:"path"`
  29. }
  30. type OutputDevice struct {
  31. Name string `yaml:"name"`
  32. ScreenIp string `yaml:"screen_ip"`
  33. LoudspeakerIp string `yaml:"loudspeaker_ip"`
  34. Branch byte `yaml:"branch"`
  35. }