|
|
@@ -45,6 +45,10 @@ namespace BPASmartClient.IoT |
|
|
|
/// 大屏上报Model |
|
|
|
/// </summary> |
|
|
|
public DataVAPI.Tool.IOT.IOTDevSXModel iOTDevSXModel = new DataVAPI.Tool.IOT.IOTDevSXModel() { }; |
|
|
|
/// <summary> |
|
|
|
/// 广播 |
|
|
|
/// </summary> |
|
|
|
public string PubTopic = "/broadcast/" + "grgpECHSL7q" + "/" + "Transit_SetDevice"; |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region API调用 |
|
|
@@ -60,15 +64,9 @@ namespace BPASmartClient.IoT |
|
|
|
{ |
|
|
|
if (DeviceDataV != null && DeviceDataV.GetIsConnected()) |
|
|
|
{ |
|
|
|
string url = DataVApiAddress + "/api/Alarm/Create"; |
|
|
|
alarmTable.ClientId = ClientId; |
|
|
|
alarmTable.devicename = DeviceDataV.deviceTable.devicename; |
|
|
|
string redata = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(alarmTable)); |
|
|
|
if (!string.IsNullOrEmpty(redata)) |
|
|
|
{ |
|
|
|
JsonMsg<AlarmTable> msg = Tools.JsonToObjectTools<JsonMsg<AlarmTable>>(redata); |
|
|
|
id = msg?.obj?.data?.Id; |
|
|
|
} |
|
|
|
DeviceDataV.IOT_Publish(PubTopic, Tools.JsonConvertTools(alarmTable)); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
@@ -78,24 +76,6 @@ namespace BPASmartClient.IoT |
|
|
|
return id; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 根据ID删除告警信息 |
|
|
|
/// </summary> |
|
|
|
/// <param name="alarm"></param> |
|
|
|
public void HttpDeleteAlarm(string id) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(id)) { MessageLog.GetInstance.Show("API调用删除告警信息,ID不能为空!"); return; } |
|
|
|
string url = DataVApiAddress + "/api/Alarm/Delete?id=" + id; |
|
|
|
HttpRequestHelper.HttpGetRequest(url); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
MessageLog.GetInstance.Show(ex.Message); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 增加日志信息 |
|
|
|
/// </summary> |
|
|
@@ -108,15 +88,9 @@ namespace BPASmartClient.IoT |
|
|
|
{ |
|
|
|
if (DeviceDataV != null && DeviceDataV.GetIsConnected()) |
|
|
|
{ |
|
|
|
string url = DataVApiAddress + "/api/Log/Create"; |
|
|
|
logTable.ClientId = ClientId; |
|
|
|
logTable.devicename = DeviceDataV.deviceTable.devicename; |
|
|
|
string redata = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(logTable)); |
|
|
|
if (!string.IsNullOrEmpty(redata)) |
|
|
|
{ |
|
|
|
JsonMsg<LogTable> msg = Tools.JsonToObjectTools<JsonMsg<LogTable>>(redata); |
|
|
|
id = msg?.obj?.data?.Id; |
|
|
|
} |
|
|
|
DeviceDataV.IOT_Publish(PubTopic, Tools.JsonConvertTools(logTable)); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
@@ -147,7 +121,10 @@ namespace BPASmartClient.IoT |
|
|
|
DeviceDataV.DataVMessageAction += DevIOTActionHandler; |
|
|
|
MessageLog.GetInstance.Show($"客户端:【{ClientId}】,设备名称{DeviceDataV.deviceTable.devicename}阿里云连接成功"); |
|
|
|
} |
|
|
|
else MessageLog.GetInstance.ShowEx(message); |
|
|
|
else |
|
|
|
{ |
|
|
|
MessageLog.GetInstance.ShowEx(message); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -159,8 +136,7 @@ namespace BPASmartClient.IoT |
|
|
|
{ |
|
|
|
if (DeviceDataV != null && DeviceDataV.GetIsConnected()) |
|
|
|
{ |
|
|
|
DataVNodeStatus dataVNode = new DataVNodeStatus(); |
|
|
|
dataVNode.data = new List<object>(); |
|
|
|
List<object> dataVNode = new List<object>(); |
|
|
|
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.ForEach(device => |
|
|
|
{ |
|
|
|
var obj=new |
|
|
@@ -174,13 +150,13 @@ namespace BPASmartClient.IoT |
|
|
|
IsHealthColor = !device.IsHealth ? new ALYColor { r = 255, g = 0, b = 0, a = 1 } : new ALYColor { r = 51, g = 232, b = 34, a = 1 }, |
|
|
|
Status = device.Status.GetStatus(), |
|
|
|
}; |
|
|
|
dataVNode.data.Add(obj); |
|
|
|
dataVNode.Add(obj); |
|
|
|
}); |
|
|
|
if (dataVNode.data.Count > 0) |
|
|
|
if (dataVNode.Count > 0) |
|
|
|
{ |
|
|
|
iOTDevSXModel.KZSX = Tools.JsonConvertTools<DevSX>(new DevSX { data = new List<DevSXBase> { new DevSXBase { SXMC = "", SXLX = "" } } }); |
|
|
|
iOTDevSXModel.JBSX = Tools.JsonConvertTools<DevSX>(new DevSX { data = new List<DevSXBase> { new DevSXBase { SXMC = "", SXLX = "" } } }); |
|
|
|
iOTDevSXModel.NodeStatus = Tools.JsonConvertTools<DataVNodeStatus>(dataVNode); |
|
|
|
iOTDevSXModel.NodeStatus = Tools.JsonConvertTools(new { data = dataVNode }); |
|
|
|
DeviceDataV.IOT_Publish(DeviceDataV.PubTopic, iOTDevSXModel.Tojson()); |
|
|
|
} |
|
|
|
} |
|
|
@@ -237,10 +213,4 @@ namespace BPASmartClient.IoT |
|
|
|
set; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class DataVNodeStatus |
|
|
|
{ |
|
|
|
public List<object> data { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
} |