MyJob.go 313 B

1234567891011121314151617181920
  1. package work
  2. import (
  3. "github.com/robfig/cron"
  4. "server/modbus"
  5. "server/service"
  6. )
  7. func MyJob() {
  8. c := cron.New()
  9. _ = c.AddFunc("0 */2 * * * ?", func() {
  10. modbus.GetSunPowerInfo()
  11. })
  12. _ = c.AddFunc("0 * * * * ?", func() {
  13. service.Cron{}.RelayOnOffTimeTask()
  14. modbus.DealWithOffline()
  15. })
  16. c.Start()
  17. }