|
@@ -32,31 +32,33 @@ type DeviceService interface {
|
|
|
// GetUpgradeProgress 获取ota升级进度
|
|
|
GetUpgradeProgress(deviceId string) (rpcs.ReplyOtaProgress, error)
|
|
|
// GetDeviceStatus 获取设备状态数据
|
|
|
- GetDeviceStatus(deviceId string) (*gjson.Json, error)
|
|
|
+ GetDeviceStatus(deviceId, productId string) (*gjson.Json, error)
|
|
|
// SetReport 获取设备状态
|
|
|
- SetReport(params models.SendCommandParams) (*gjson.Json, error)
|
|
|
+ SetReport(params models.SendSplitCommandParams) (*gjson.Json, error)
|
|
|
// Restart 重启设备
|
|
|
- Restart(params models.SendCommandParams) error
|
|
|
+ Restart(params models.SendSplitCommandParams) error
|
|
|
// ClearData 清除设备配置数据
|
|
|
- ClearData(params models.SendCommandParams) error
|
|
|
+ ClearData(params models.SendSplitCommandParams) error
|
|
|
// SetDataTrans 设备端自动上报配置
|
|
|
- SetDataTrans(params models.SendCommandParams) error
|
|
|
+ SetDataTrans(params models.SendSplitCommandParams) error
|
|
|
// GetInfo 获取网关信息
|
|
|
- GetInfo(params models.SendCommandParams) (*gjson.Json, error)
|
|
|
+ GetInfo(params models.SendSplitCommandParams) (*gjson.Json, error)
|
|
|
// ForceRun 远程控制某个模块强制运行
|
|
|
- ForceRun(params models.SendCommandParams) error
|
|
|
+ ForceRun(params models.SendSplitCommandParams) error
|
|
|
// SetDeviceId 写入设备id
|
|
|
- SetDeviceId(params models.SendCommandParams) error
|
|
|
+ SetDeviceId(params models.SendSplitCommandParams) error
|
|
|
// SetFjsqStatus 智能分集水器控制
|
|
|
- SetFjsqStatus(params models.SendCommandParams) error
|
|
|
+ SetFjsqStatus(params models.SendSplitCommandParams) error
|
|
|
// SetOutdoorPower 设置水系统外机电源状态
|
|
|
- SetOutdoorPower(params models.SendCommandParams) error
|
|
|
+ SetOutdoorPower(params models.SendSplitCommandParams) error
|
|
|
// SetOutdoorTemp 设置水系统外机出水温度
|
|
|
- SetOutdoorTemp(params models.SendCommandParams) error
|
|
|
+ SetOutdoorTemp(params models.SendSplitCommandParams) error
|
|
|
// SetOutdoorLinkage 开启/关闭水系统联动
|
|
|
- SetOutdoorLinkage(params models.SendCommandParams) error
|
|
|
+ SetOutdoorLinkage(params models.SendSplitCommandParams) error
|
|
|
// SetMixedWaterLinkage 开启/关闭调温中心联动
|
|
|
- SetMixedWaterLinkage(params models.SendCommandParams) error
|
|
|
+ SetMixedWaterLinkage(params models.SendSplitCommandParams) error
|
|
|
+ // SendCommand 下发指令
|
|
|
+ SendCommand(args rpcs.ArgsSendCommand) error
|
|
|
}
|
|
|
|
|
|
type deviceservice struct {
|
|
@@ -206,11 +208,12 @@ func (a deviceservice) GetUpgradeProgress(deviceId string) (rpcs.ReplyOtaProgres
|
|
|
return reply, nil
|
|
|
}
|
|
|
|
|
|
-func (a deviceservice) GetDeviceStatus(deviceId string) (*gjson.Json, error) {
|
|
|
+func (a deviceservice) GetDeviceStatus(deviceId, productId string) (*gjson.Json, error) {
|
|
|
var args rpcs.ArgsGetStatus
|
|
|
args.Id = deviceId
|
|
|
-
|
|
|
+ args.ProductId = productId
|
|
|
var reply rpcs.ReplyStatus
|
|
|
+
|
|
|
err := server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.GetDeviceStatus", args, &reply)
|
|
|
if err != nil {
|
|
|
server.Log.Errorf("设备状态数据获取失败:%v", err)
|
|
@@ -220,7 +223,7 @@ func (a deviceservice) GetDeviceStatus(deviceId string) (*gjson.Json, error) {
|
|
|
}
|
|
|
|
|
|
// SetReport 获取设备状态
|
|
|
-func (a deviceservice) SetReport(params models.SendCommandParams) (*gjson.Json, error) {
|
|
|
+func (a deviceservice) SetReport(params models.SendSplitCommandParams) (*gjson.Json, error) {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.Report)
|
|
@@ -228,11 +231,11 @@ func (a deviceservice) SetReport(params models.SendCommandParams) (*gjson.Json,
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- return a.GetDeviceStatus(params.DeviceId)
|
|
|
+ return a.GetDeviceStatus(params.DeviceId, params.ProductId)
|
|
|
}
|
|
|
|
|
|
// Restart 重启设备
|
|
|
-func (a deviceservice) Restart(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) Restart(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.Restart)
|
|
@@ -240,7 +243,7 @@ func (a deviceservice) Restart(params models.SendCommandParams) error {
|
|
|
}
|
|
|
|
|
|
// ClearData 清除设备配置数据
|
|
|
-func (a deviceservice) ClearData(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) ClearData(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.ClearData)
|
|
@@ -248,7 +251,7 @@ func (a deviceservice) ClearData(params models.SendCommandParams) error {
|
|
|
}
|
|
|
|
|
|
// SetDataTrans 设备端自动上报配置
|
|
|
-func (a deviceservice) SetDataTrans(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) SetDataTrans(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Params = map[string]interface{}{
|
|
@@ -260,7 +263,7 @@ func (a deviceservice) SetDataTrans(params models.SendCommandParams) error {
|
|
|
}
|
|
|
|
|
|
// GetInfo 获取网关信息
|
|
|
-func (a deviceservice) GetInfo(params models.SendCommandParams) (*gjson.Json, error) {
|
|
|
+func (a deviceservice) GetInfo(params models.SendSplitCommandParams) (*gjson.Json, error) {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.GetInfo)
|
|
@@ -271,6 +274,7 @@ func (a deviceservice) GetInfo(params models.SendCommandParams) (*gjson.Json, er
|
|
|
|
|
|
var newArgs rpcs.ArgsGetStatus
|
|
|
newArgs.Id = params.DeviceId
|
|
|
+ newArgs.ProductId = params.ProductId
|
|
|
var reply rpcs.ReplayInfo
|
|
|
|
|
|
err = server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.GetDeviceInfo", newArgs, &reply)
|
|
@@ -282,7 +286,7 @@ func (a deviceservice) GetInfo(params models.SendCommandParams) (*gjson.Json, er
|
|
|
}
|
|
|
|
|
|
// ForceRun 远程控制某个模块强制运行
|
|
|
-func (a deviceservice) ForceRun(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) ForceRun(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.ForceRun)
|
|
@@ -294,7 +298,7 @@ func (a deviceservice) ForceRun(params models.SendCommandParams) error {
|
|
|
}
|
|
|
|
|
|
// SetDeviceId 写入设备id
|
|
|
-func (a deviceservice) SetDeviceId(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) SetDeviceId(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.SetDeviceId)
|
|
@@ -306,7 +310,7 @@ func (a deviceservice) SetDeviceId(params models.SendCommandParams) error {
|
|
|
}
|
|
|
|
|
|
// SetFjsqStatus 智能分集水器控制
|
|
|
-func (a deviceservice) SetFjsqStatus(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) SetFjsqStatus(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.SetFjsqStatus)
|
|
@@ -318,7 +322,7 @@ func (a deviceservice) SetFjsqStatus(params models.SendCommandParams) error {
|
|
|
}
|
|
|
|
|
|
// SetOutdoorPower 设置水系统外机电源状态
|
|
|
-func (a deviceservice) SetOutdoorPower(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) SetOutdoorPower(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.SetOutdoorPower)
|
|
@@ -329,7 +333,7 @@ func (a deviceservice) SetOutdoorPower(params models.SendCommandParams) error {
|
|
|
}
|
|
|
|
|
|
// SetOutdoorTemp 设置水系统外机出水温度
|
|
|
-func (a deviceservice) SetOutdoorTemp(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) SetOutdoorTemp(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.SetOutdoorTemp)
|
|
@@ -341,7 +345,7 @@ func (a deviceservice) SetOutdoorTemp(params models.SendCommandParams) error {
|
|
|
}
|
|
|
|
|
|
// SetOutdoorLinkage 开启/关闭水系统联动
|
|
|
-func (a deviceservice) SetOutdoorLinkage(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) SetOutdoorLinkage(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.SetOutdoorTemp)
|
|
@@ -352,7 +356,7 @@ func (a deviceservice) SetOutdoorLinkage(params models.SendCommandParams) error
|
|
|
}
|
|
|
|
|
|
// SetMixedWaterLinkage 开启/关闭调温中心联动
|
|
|
-func (a deviceservice) SetMixedWaterLinkage(params models.SendCommandParams) error {
|
|
|
+func (a deviceservice) SetMixedWaterLinkage(params models.SendSplitCommandParams) error {
|
|
|
var args rpcs.ArgsSendCommand
|
|
|
args.DeviceId = params.DeviceId
|
|
|
args.Cmd = string(models.SetOutdoorTemp)
|
|
@@ -372,3 +376,14 @@ func (a deviceservice) sendCommand(args rpcs.ArgsSendCommand) error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+// SendCommand 下发指令
|
|
|
+func (a deviceservice) SendCommand(args rpcs.ArgsSendCommand) error {
|
|
|
+ var reply rpcs.ReplySendCommand
|
|
|
+ err := server.RPCCallByName(nil, rpcs.ControllerName, "Controller.SendCommand", args, &reply)
|
|
|
+ if err != nil {
|
|
|
+ server.Log.Errorf("指令下发失败:%v", err)
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|