Commit c873e72e authored by leon.huang's avatar leon.huang

Delete dirty data from all nodes

parent cf469d03
......@@ -11,7 +11,7 @@ using MQTTnet;
using MQTTnet.Client;
using Newtonsoft.Json;
using ModbusDemo;
using Newtonsoft.Json.Linq;
namespace ModbusDemo.Modular
{
class ModualPoll
......@@ -81,7 +81,7 @@ namespace ModbusDemo.Modular
private const byte byX66cRelayRegStartAddress = 16;
public const byte byX66cRelayRegNumber = 6;
public static modual.pcx66C cx66c = new modual.pcx66C(byX66cIdlist);
public static List<byte>listDeleteNodesID = new List<byte>();
public const byte COMMFAILALARM = 3;
public static void vAllNodePoll()
{
......@@ -445,6 +445,7 @@ namespace ModbusDemo.Modular
public static void vSend_Actual_Data(byte byModbusID)
{
string strRes = null;
listDeleteNodesID.Add(byModbusID);
for (int i = 0; i < ModualPoll.byX18xNumber; i++)
{
if (byModbusID == ModualPoll.cx18x.byModbusID[i])
......@@ -852,6 +853,28 @@ namespace ModbusDemo.Modular
await Form1.Publish(Form1.sAlarmTopic,ModualAlarm.sAgainAlarmJson);
}
}
public static string vRemove_Nodes_Data_String(string strSendAllDataJson)
{
if (listDeleteNodesID.Count() != 0)
{
var jsonArray = new JArray();
jsonArray = JArray .Parse(strSendAllDataJson);
for (int i = 0; i < listDeleteNodesID.Count(); i++)
{
for (int j = 0; j < jsonArray.Count(); j++)
{
if (jsonArray[j].Value<string>("addr") == listDeleteNodesID[i].ToString())
{
jsonArray.Remove(jsonArray[j]);
}
}
}
listDeleteNodesID.Clear();
return jsonArray.ToString();
}
return strSendAllDataJson;
}
}
}
......@@ -113,11 +113,11 @@ namespace ModbusDemo.application
}
#endregion
#region 沉砂池开映射
else if (byControlID == 90 && strOperationChannelName[0] == "d4")
else if (byControlID == 39 && strOperationChannelName[0] == "d4")
{
bDelege_Operation = AllPond.cDesiltingPool.cStirrer1.bOpen_Machine;
}
else if (byControlID == 90 && strOperationChannelName[0] == "d5")
else if (byControlID == 39 && strOperationChannelName[0] == "d5")
{
bDelege_Operation = AllPond.cDesiltingPool.cStirrer2.bOpen_Machine;
}
......@@ -201,11 +201,11 @@ namespace ModbusDemo.application
}
#endregion
#region 沉砂池关映射
else if (byControlID == 90 && strOperationChannelName[0] == "d4")
else if (byControlID == 39 && strOperationChannelName[0] == "d4")
{
bDelege_Operation = AllPond.cDesiltingPool.cStirrer1.bClose_Machine;
}
else if (byControlID == 90 && strOperationChannelName[0] == "d5")
else if (byControlID == 39 && strOperationChannelName[0] == "d5")
{
bDelege_Operation = AllPond.cDesiltingPool.cStirrer2.bClose_Machine;
}
......@@ -226,40 +226,40 @@ namespace ModbusDemo.application
#endregion
#region 中控柜关映射和手动映射
#endregion
if (byControlID == 31 && strOperationChannelName[0] == "d1")
{
bDelege_Operation = AllPond.cEastTransitPool.cSouthWater.bClose_Machine;
}
else if (byControlID == 16 && strOperationChannelName[0] == "d0")
{
bDelege_Operation = AllPond.cEastTransitPool.cNorthWater.bClose_Machine;
}
else if (byControlID == 16 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cPumb1.bClose_Machine;
}
else if (byControlID == 35 && strOperationChannelName[0] == "d0")
{
bDelege_Operation = AllPond.cEastTransitPool.cPumb2.bClose_Machine;
}
else if (byControlID == 35 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer1.bClose_Machine;
}
else if (byControlID == 39 && strOperationChannelName[0] == "d0")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer2.bClose_Machine;
}
else if (byControlID == 39 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer3.bClose_Machine;
}
//else if (byControlID == 31 && strOperationChannelName[0] == "d1")
//{
// bDelege_Operation = AllPond.cEastTransitPool.cSouthWater.bClose_Machine;
//}
//else if (byControlID == 16 && strOperationChannelName[0] == "d0")
//{
// bDelege_Operation = AllPond.cEastTransitPool.cNorthWater.bClose_Machine;
//}
//else if (byControlID == 16 && strOperationChannelName[0] == "d2")
//{
// bDelege_Operation = AllPond.cEastTransitPool.cPumb1.bClose_Machine;
//}
//else if (byControlID == 35 && strOperationChannelName[0] == "d0")
//{
// bDelege_Operation = AllPond.cEastTransitPool.cPumb2.bClose_Machine;
//}
//else if (byControlID == 35 && strOperationChannelName[0] == "d2")
//{
// bDelege_Operation = AllPond.cEastTransitPool.cStirrer1.bClose_Machine;
//}
//else if (byControlID == 39 && strOperationChannelName[0] == "d0")
//{
// bDelege_Operation = AllPond.cEastTransitPool.cStirrer2.bClose_Machine;
//}
//else if (byControlID == 39 && strOperationChannelName[0] == "d2")
//{
// bDelege_Operation = AllPond.cEastTransitPool.cStirrer3.bClose_Machine;
//}
else
{
byMapIdleID = byControlID;
strMapIdleChannelName = strOperationChannelName;
byMapIdleControlData = bControlData;
bDelege_Operation = bMap_Idle_Close_Control;
byMapIdleID = byControlID;
strMapIdleChannelName = strOperationChannelName;
byMapIdleControlData = bControlData;
bDelege_Operation = bMap_Idle_Close_Control;
}
}
return bMapStatus;
......
......@@ -26,7 +26,7 @@ namespace ModbusDemo
{
public partial class Form1 : Form
{
const bool LOCALDEBUG = true;
const bool LOCALDEBUG = false;
private bool bStart = false;
AutoResetEvent exitEvent;
private int waitTime;
......@@ -382,6 +382,7 @@ namespace ModbusDemo
{
try
{
mqttData = ModualPoll.vRemove_Nodes_Data_String(mqttData);
await Publish(mqttTopic, mqttData);
}
catch (Exception ex)
......@@ -426,7 +427,7 @@ namespace ModbusDemo
{
totxt.Log("开始执行");
ModualPoll.vAllNodePoll();
mqttData = ModualPoll.stAll_Poll_Package();
mqttData = ModualPoll.vRemove_Nodes_Data_String(ModualPoll.stAll_Poll_Package());
ModualPoll.vCheckAlarm_And_Send(mqttClient);
totxt.Log("执行结束");
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment