package NatsServer import ( "Cold_Api/controllers/lib" "github.com/beego/beego/v2/core/logs" "Cold_Api/models/Device" "github.com/vmihailenco/msgpack/v5" ) func Read_DeviceParameter(T_SN, T_mqttid string) { logs.Info("Nats =>", lib.FuncName(), T_SN) err := lib.Nats.Publish("Read_DeviceParameter"+T_mqttid, []byte(T_SN)) if err != nil { logs.Info("Nats =>", lib.FuncName(), err) } } func Read_DeviceSensorParameter(T_SN, T_mqttid string) { logs.Info("Nats =>", lib.FuncName(), T_SN) err := lib.Nats.Publish("Read_DeviceSensorParameter"+T_mqttid, []byte(T_SN)) if err != nil { logs.Info("Nats =>", lib.FuncName(), err) } } func Pu_DeviceParameter(v Device.DeviceParameter, T_mqttid string) { logs.Info("Nats =>", lib.FuncName(), v) b, err := msgpack.Marshal(&v) if err != nil { panic(err) } err = lib.Nats.Publish("Pu_DeviceParameter"+T_mqttid, b) if err != nil { logs.Info("Nats =>", lib.FuncName(), err) } } func Pu_DeviceParameter_Sensor(v Device.DeviceSensorParameter, T_mqttid string) { logs.Info("Nats =>", lib.FuncName(), v) b, err := msgpack.Marshal(&v) if err != nil { panic(err) } err = lib.Nats.Publish("Pu_DeviceParameter_Sensor"+T_mqttid, b) if err != nil { logs.Info("Nats =>", lib.FuncName(), err) } } func Set_DeviceTask(v Device.Device_task, T_mqttid string) { logs.Info("Nats =>", lib.FuncName(), v) b, err := msgpack.Marshal(&v) if err != nil { panic(err) } err = lib.Nats.Publish("Set_DeviceTask"+T_mqttid, b) if err != nil { logs.Info("Nats =>", lib.FuncName(), err) } } func Set_RestartShutdown(v Device.Device_task, T_mqttid string) { logs.Info("Nats =>", lib.FuncName(), v) b, err := msgpack.Marshal(&v) if err != nil { panic(err) } err = lib.Nats.Publish("Set_RestartShutdown"+T_mqttid, b) if err != nil { logs.Info("Nats =>", lib.FuncName(), err) } } func Del_DeviceSensor(v Device.DeviceSensor_Del, T_mqttid string) { logs.Info("Nats =>", lib.FuncName(), v) b, err := msgpack.Marshal(&v) if err != nil { panic(err) } err = lib.Nats.Publish("Del_DeviceSensor"+T_mqttid, b) if err != nil { logs.Info("Nats =>", lib.FuncName(), err) } } func Get_Device_Realtime(v string, T_mqttid string) { //logs.Info("Nats =>", lib.FuncName(),T_mqttid, v) err := lib.Nats.Publish("Get_Device_Realtime"+T_mqttid, []byte(v)) if err != nil { logs.Info("Nats =>", lib.FuncName(), err) } }