config.go 954 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. ScreenPort string `yaml:"screen_port"`
  34. LoudspeakerIp string `yaml:"loudspeaker_ip"`
  35. Branch byte `yaml:"branch"`
  36. }