12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package modbus
- import (
- "server/model"
- "server/utils"
- "time"
- )
- func GetSunPowerInfo() {
- for _, conn := range model.ConnectionMap {
-
- utils.WriteDevice(SolarEnergyData(), conn)
-
-
-
-
-
-
- }
-
- }
- func GetDeviceInfo() {
- for id, conn := range model.ConnectionMap {
- _, dev, _ := utils.GetDataByDeviceId(id)
- utils.WriteDevice(ReadDeviceInfo(dev.LoopNumber), conn)
- }
- }
- func DealWithOffline() {
- regions, _ := utils.LoadData()
- for i, region := range regions {
- for i2, device := range region.Devices {
- if time.Now().After(device.OnlineTime.Add(4*time.Minute)) && regions[i].Devices[i2].State != 0 {
- regions[i].Devices[i2].State = 0
- }
- }
- }
- utils.SaveData("static/data.json", regions)
- }
|