|
|
@@ -10,7 +10,6 @@ import (
|
|
|
"regexp"
|
|
|
"server/dao"
|
|
|
"server/global"
|
|
|
- "server/service/devices"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
@@ -125,57 +124,57 @@ func (s *Device) Process() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func IsOnline() {
|
|
|
- t := time.NewTicker(5 * time.Second) //每分钟
|
|
|
- for {
|
|
|
- select {
|
|
|
- case <-t.C:
|
|
|
- topic := devices.MqttService.GetTopic("071995171560000000c40808", devices.TopicChanStatus)
|
|
|
- err := devices.MqttService.Publish(topic, "1")
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err.Error())
|
|
|
- }
|
|
|
- fmt.Println("发送了。。。。。。。。。。。。。。。。。。。。。。")
|
|
|
- for _, device := range Devices {
|
|
|
- //commond := `{
|
|
|
- // "setdiscontent0":{
|
|
|
- // "num":"7",
|
|
|
- // "effect":"11",
|
|
|
- // "speed":"3",
|
|
|
- // "stay":"5",
|
|
|
- // "total":"100",
|
|
|
- // "color":"3",
|
|
|
- // "content":"[24M]哈哈哈哈"
|
|
|
- // }
|
|
|
- //}`
|
|
|
-
|
|
|
- //conyuyin := `{"audionumset0":{"num0":"21","num1":"[m0]前方路口,注意来车","num2":"[m1]您已超速,请减速","num3":"[m0]对向来车,请减速","num4":"[m0]双向来车,请减速"}}`
|
|
|
-
|
|
|
- //consy := ``
|
|
|
-
|
|
|
- //gb2312, _ := UTF8ToGB2312(conyuyin)
|
|
|
-
|
|
|
- //n, err := Devices[device.Info.Sn].Conn.Write(gb2312)
|
|
|
- //fmt.Println("我是n,", n)
|
|
|
- //if err != nil {
|
|
|
- // fmt.Println("err:", err)
|
|
|
- //}
|
|
|
- //fmt.Println("发送了。。。。。。。。。。。。。。。。。。。。。。")
|
|
|
- //符合条件
|
|
|
- if time.Now().Add(-2*time.Minute).After(device.LastTime) || device.LastTime.IsZero() {
|
|
|
- state := 0
|
|
|
- err := dao.UpdateScreensStatusBySn(device.Info.Sn, state)
|
|
|
- delete(Devices, device.Info.Sn)
|
|
|
- if err != nil {
|
|
|
- continue
|
|
|
- }
|
|
|
- device.Info.Status = 0
|
|
|
- global.GVA_LOG.Info("设备离线了", zap.String("ScreensName", device.Info.ScreensName))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+//func IsOnline() {
|
|
|
+// t := time.NewTicker(5 * time.Second) //每分钟
|
|
|
+// for {
|
|
|
+// select {
|
|
|
+// case <-t.C:
|
|
|
+// topic := devices.MqttService.GetTopic("071995171560000000c40808", devices.TopicChanStatus)
|
|
|
+// err := devices.MqttService.Publish(topic, "1")
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err.Error())
|
|
|
+// }
|
|
|
+// fmt.Println("发送了。。。。。。。。。。。。。。。。。。。。。。")
|
|
|
+// for _, device := range Devices {
|
|
|
+// //commond := `{
|
|
|
+// // "setdiscontent0":{
|
|
|
+// // "num":"7",
|
|
|
+// // "effect":"11",
|
|
|
+// // "speed":"3",
|
|
|
+// // "stay":"5",
|
|
|
+// // "total":"100",
|
|
|
+// // "color":"3",
|
|
|
+// // "content":"[24M]哈哈哈哈"
|
|
|
+// // }
|
|
|
+// //}`
|
|
|
+//
|
|
|
+// //conyuyin := `{"audionumset0":{"num0":"21","num1":"[m0]前方路口,注意来车","num2":"[m1]您已超速,请减速","num3":"[m0]对向来车,请减速","num4":"[m0]双向来车,请减速"}}`
|
|
|
+//
|
|
|
+// //consy := ``
|
|
|
+//
|
|
|
+// //gb2312, _ := UTF8ToGB2312(conyuyin)
|
|
|
+//
|
|
|
+// //n, err := Devices[device.Info.Sn].Conn.Write(gb2312)
|
|
|
+// //fmt.Println("我是n,", n)
|
|
|
+// //if err != nil {
|
|
|
+// // fmt.Println("err:", err)
|
|
|
+// //}
|
|
|
+// //fmt.Println("发送了。。。。。。。。。。。。。。。。。。。。。。")
|
|
|
+// //符合条件
|
|
|
+// if time.Now().Add(-2*time.Minute).After(device.LastTime) || device.LastTime.IsZero() {
|
|
|
+// state := 0
|
|
|
+// err := dao.UpdateScreensStatusBySn(device.Info.Sn, state)
|
|
|
+// delete(Devices, device.Info.Sn)
|
|
|
+// if err != nil {
|
|
|
+// continue
|
|
|
+// }
|
|
|
+// device.Info.Status = 0
|
|
|
+// global.GVA_LOG.Info("设备离线了", zap.String("ScreensName", device.Info.ScreensName))
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//}
|
|
|
|
|
|
func UTF8ToGB2312(s string) ([]byte, error) {
|
|
|
reader := transform.NewReader(strings.NewReader(s), simplifiedchinese.GB18030.NewEncoder())
|