diff --git a/SensorHub.WellPlus/Properties/AssemblyInfo.cs b/SensorHub.WellPlus/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b0ef1f9 --- /dev/null +++ b/SensorHub.WellPlus/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SensorHub.WellPlus")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SensorHub.WellPlus")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("cdae0e93-0ca1-446f-99a1-2d071f73700c")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SensorHub.WellPlus/Properties/AssemblyInfo.cs b/SensorHub.WellPlus/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b0ef1f9 --- /dev/null +++ b/SensorHub.WellPlus/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SensorHub.WellPlus")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SensorHub.WellPlus")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("cdae0e93-0ca1-446f-99a1-2d071f73700c")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SensorHub.WellPlus/SensorHub.WellPlus.csproj b/SensorHub.WellPlus/SensorHub.WellPlus.csproj new file mode 100644 index 0000000..5042574 --- /dev/null +++ b/SensorHub.WellPlus/SensorHub.WellPlus.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB} + Library + Properties + SensorHub.WellPlus + SensorHub.WellPlus + v4.5 + 512 + + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + false + + + + False + ..\bin\SuperSocket.SocketBase.dll + + + + + + + + + + + + + + + + + + {9bf5d683-f4f2-4d3d-8163-edb3c3d6eafc} + SensorHub.Servers + + + + + \ No newline at end of file diff --git a/SensorHub.WellPlus/Properties/AssemblyInfo.cs b/SensorHub.WellPlus/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b0ef1f9 --- /dev/null +++ b/SensorHub.WellPlus/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SensorHub.WellPlus")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SensorHub.WellPlus")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("cdae0e93-0ca1-446f-99a1-2d071f73700c")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SensorHub.WellPlus/SensorHub.WellPlus.csproj b/SensorHub.WellPlus/SensorHub.WellPlus.csproj new file mode 100644 index 0000000..5042574 --- /dev/null +++ b/SensorHub.WellPlus/SensorHub.WellPlus.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB} + Library + Properties + SensorHub.WellPlus + SensorHub.WellPlus + v4.5 + 512 + + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + false + + + + False + ..\bin\SuperSocket.SocketBase.dll + + + + + + + + + + + + + + + + + + {9bf5d683-f4f2-4d3d-8163-edb3c3d6eafc} + SensorHub.Servers + + + + + \ No newline at end of file diff --git a/SensorHub.WellPlus/WellPlus.cs b/SensorHub.WellPlus/WellPlus.cs new file mode 100644 index 0000000..d9418e9 --- /dev/null +++ b/SensorHub.WellPlus/WellPlus.cs @@ -0,0 +1,147 @@ +using SensorHub.Servers; +using SensorHub.Servers.Commands.CASICCommands; +using SensorHub.Servers.JsonFormat; +using SuperSocket.SocketBase.Command; +using SuperSocket.SocketBase.Protocol; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SensorHub.WellPlus +{ + public class WellPlus : CommandBase + { + public override void ExecuteCommand(CasicSession session, StringRequestInfo requestInfo) + { + //TODO: construct the receving casic data + String preamble = requestInfo.Parameters[0]; + String version = requestInfo.Parameters[1]; + String leng = requestInfo.Parameters[2]; + String devCode = requestInfo.Parameters[3]; + String routeFlag = requestInfo.Parameters[4]; + String dstNodeAddr = requestInfo.Parameters[5]; + String pduType = requestInfo.Parameters[6]; + String seq = requestInfo.Parameters[7]; + String settings = requestInfo.Parameters[8]; + String source = requestInfo.Parameters[9]; + + String devName = "WellPlus"; + + if (source.Contains("-")) + { + session.Send("HTTP/1.1 200 OK\r\n\r\n\r\n"); + session.Close(); + } + + //print the receving data + String devType = "井盖液位一体机"; + String operType = Common.getOpeTypeByPdu(pduType); + session.Logger.Info("AD接收数据:" + requestInfo.Body); + session.Logger.Info("设备类型:" + devType); + session.Logger.Info("操作类型:" + operType); + session.Logger.Info("会话:" + session.HubAddr + "," + session.SessionID); + + List tags = Common.getTags(settings, session); + + //具体业务处理 + String collectDate = ""; + List eventList = new List(); + List datasList = new List(); + List startupList = new List(); + + foreach (Tag tag in tags) + { + if (!(tag is UploadTag)) + { + //非业务处理 + if (tag != null && tag is SystemDateTag) + { + SystemDateTag systemDateTag = tag as SystemDateTag; + collectDate = systemDateTag.CollectDate; + continue; + } + + if (tag != null && tag is SensorStartupTag) + { + SensorStartupTag sensorStartup = tag as SensorStartupTag; + String imei = sensorStartup.IMEI; + String iccid = sensorStartup.ICCID; + + startupList.Add(imei); + startupList.Add(iccid); + + session.Logger.Info("设备开机上报,设备编号DEVCODE:" + devCode + " IMEI:" + imei + " ICCID:" + iccid); + continue; + } + } + else + { + //业务处理 + UploadTag uploadTag = tag as UploadTag; + switch (uploadTag.BizType) + { + case 7: + //开关状态 + TagHandler wellPlusHandler = new WellPlusTagHandler(); + wellPlusHandler.resolve(tag, session); + + if(wellPlusHandler.DataList.Count > 0) + { + DateTime upTime = Convert.ToDateTime(collectDate + " " + wellPlusHandler.CollecTime); + String uptime = upTime.ToString("yyyy") + upTime.ToString("MM") + upTime.ToString("dd") + + upTime.ToString("HH") + upTime.ToString("mm") + upTime.ToString("ss"); + + switch ((byte)wellPlusHandler.DataList[0]) + { + case 0: + datasList.Add(new WellPlusDatasJson(uptime, "00")); + break; + case 1: + eventList.Add("WellPlusOpenAlarm");//井盖开启 + break; + case 2: + // eventList.Add("WellDeviceBadAlarm");//设备故障 + break; + case 3: + // eventList.Add("WellLowBatteryAlarm");//低电量 + break; + case 4: + eventList.Add("WellPlusLevelAlarm"); // 液位超限报警 + break; + default: + eventList.Add("WellPlusUnknown");//未知异常 + break; + } + } + break; + default: + session.Logger.Info("未知业务类型!"); + break; + } + } + } + + //Common.sendMessage(session, "Well", devCode, -1, eventList, datasList, startupList); + Common.kafkaProduce(session, devName, devCode, -1, null, null, null, eventList, datasList, startupList); + + if (source != "433") //433井盖不要求回复 + { + byte[] btPdu = new byte[2]; //2个字节 + if (operType == "TrapRequest") + { + btPdu[0] = 0x05; + } + else if (operType == "StartupRequest") + { + btPdu[0] = 0x09; + } + + btPdu[1] = 0x86; + + Common.sendConfig(session, devCode, routeFlag, source, btPdu); + } + + } + } +} diff --git a/SensorHub.WellPlus/Properties/AssemblyInfo.cs b/SensorHub.WellPlus/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b0ef1f9 --- /dev/null +++ b/SensorHub.WellPlus/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SensorHub.WellPlus")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SensorHub.WellPlus")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("cdae0e93-0ca1-446f-99a1-2d071f73700c")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SensorHub.WellPlus/SensorHub.WellPlus.csproj b/SensorHub.WellPlus/SensorHub.WellPlus.csproj new file mode 100644 index 0000000..5042574 --- /dev/null +++ b/SensorHub.WellPlus/SensorHub.WellPlus.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB} + Library + Properties + SensorHub.WellPlus + SensorHub.WellPlus + v4.5 + 512 + + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + false + + + + False + ..\bin\SuperSocket.SocketBase.dll + + + + + + + + + + + + + + + + + + {9bf5d683-f4f2-4d3d-8163-edb3c3d6eafc} + SensorHub.Servers + + + + + \ No newline at end of file diff --git a/SensorHub.WellPlus/WellPlus.cs b/SensorHub.WellPlus/WellPlus.cs new file mode 100644 index 0000000..d9418e9 --- /dev/null +++ b/SensorHub.WellPlus/WellPlus.cs @@ -0,0 +1,147 @@ +using SensorHub.Servers; +using SensorHub.Servers.Commands.CASICCommands; +using SensorHub.Servers.JsonFormat; +using SuperSocket.SocketBase.Command; +using SuperSocket.SocketBase.Protocol; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SensorHub.WellPlus +{ + public class WellPlus : CommandBase + { + public override void ExecuteCommand(CasicSession session, StringRequestInfo requestInfo) + { + //TODO: construct the receving casic data + String preamble = requestInfo.Parameters[0]; + String version = requestInfo.Parameters[1]; + String leng = requestInfo.Parameters[2]; + String devCode = requestInfo.Parameters[3]; + String routeFlag = requestInfo.Parameters[4]; + String dstNodeAddr = requestInfo.Parameters[5]; + String pduType = requestInfo.Parameters[6]; + String seq = requestInfo.Parameters[7]; + String settings = requestInfo.Parameters[8]; + String source = requestInfo.Parameters[9]; + + String devName = "WellPlus"; + + if (source.Contains("-")) + { + session.Send("HTTP/1.1 200 OK\r\n\r\n\r\n"); + session.Close(); + } + + //print the receving data + String devType = "井盖液位一体机"; + String operType = Common.getOpeTypeByPdu(pduType); + session.Logger.Info("AD接收数据:" + requestInfo.Body); + session.Logger.Info("设备类型:" + devType); + session.Logger.Info("操作类型:" + operType); + session.Logger.Info("会话:" + session.HubAddr + "," + session.SessionID); + + List tags = Common.getTags(settings, session); + + //具体业务处理 + String collectDate = ""; + List eventList = new List(); + List datasList = new List(); + List startupList = new List(); + + foreach (Tag tag in tags) + { + if (!(tag is UploadTag)) + { + //非业务处理 + if (tag != null && tag is SystemDateTag) + { + SystemDateTag systemDateTag = tag as SystemDateTag; + collectDate = systemDateTag.CollectDate; + continue; + } + + if (tag != null && tag is SensorStartupTag) + { + SensorStartupTag sensorStartup = tag as SensorStartupTag; + String imei = sensorStartup.IMEI; + String iccid = sensorStartup.ICCID; + + startupList.Add(imei); + startupList.Add(iccid); + + session.Logger.Info("设备开机上报,设备编号DEVCODE:" + devCode + " IMEI:" + imei + " ICCID:" + iccid); + continue; + } + } + else + { + //业务处理 + UploadTag uploadTag = tag as UploadTag; + switch (uploadTag.BizType) + { + case 7: + //开关状态 + TagHandler wellPlusHandler = new WellPlusTagHandler(); + wellPlusHandler.resolve(tag, session); + + if(wellPlusHandler.DataList.Count > 0) + { + DateTime upTime = Convert.ToDateTime(collectDate + " " + wellPlusHandler.CollecTime); + String uptime = upTime.ToString("yyyy") + upTime.ToString("MM") + upTime.ToString("dd") + + upTime.ToString("HH") + upTime.ToString("mm") + upTime.ToString("ss"); + + switch ((byte)wellPlusHandler.DataList[0]) + { + case 0: + datasList.Add(new WellPlusDatasJson(uptime, "00")); + break; + case 1: + eventList.Add("WellPlusOpenAlarm");//井盖开启 + break; + case 2: + // eventList.Add("WellDeviceBadAlarm");//设备故障 + break; + case 3: + // eventList.Add("WellLowBatteryAlarm");//低电量 + break; + case 4: + eventList.Add("WellPlusLevelAlarm"); // 液位超限报警 + break; + default: + eventList.Add("WellPlusUnknown");//未知异常 + break; + } + } + break; + default: + session.Logger.Info("未知业务类型!"); + break; + } + } + } + + //Common.sendMessage(session, "Well", devCode, -1, eventList, datasList, startupList); + Common.kafkaProduce(session, devName, devCode, -1, null, null, null, eventList, datasList, startupList); + + if (source != "433") //433井盖不要求回复 + { + byte[] btPdu = new byte[2]; //2个字节 + if (operType == "TrapRequest") + { + btPdu[0] = 0x05; + } + else if (operType == "StartupRequest") + { + btPdu[0] = 0x09; + } + + btPdu[1] = 0x86; + + Common.sendConfig(session, devCode, routeFlag, source, btPdu); + } + + } + } +} diff --git a/SensorHub.WellPlus/WellPlusDatasJson.cs b/SensorHub.WellPlus/WellPlusDatasJson.cs new file mode 100644 index 0000000..7ccade4 --- /dev/null +++ b/SensorHub.WellPlus/WellPlusDatasJson.cs @@ -0,0 +1,20 @@ +using SensorHub.Servers.JsonFormat; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SensorHub.WellPlus +{ + public class WellPlusDatasJson : DatasJson + { + public string value { get; set; } //井盖一体机状态 + + public WellPlusDatasJson(string uptime, string value) + { + this.uptime = uptime; + this.value = value; + } + } +} \ No newline at end of file diff --git a/SensorHub.WellPlus/Properties/AssemblyInfo.cs b/SensorHub.WellPlus/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b0ef1f9 --- /dev/null +++ b/SensorHub.WellPlus/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SensorHub.WellPlus")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SensorHub.WellPlus")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("cdae0e93-0ca1-446f-99a1-2d071f73700c")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SensorHub.WellPlus/SensorHub.WellPlus.csproj b/SensorHub.WellPlus/SensorHub.WellPlus.csproj new file mode 100644 index 0000000..5042574 --- /dev/null +++ b/SensorHub.WellPlus/SensorHub.WellPlus.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB} + Library + Properties + SensorHub.WellPlus + SensorHub.WellPlus + v4.5 + 512 + + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + false + + + + False + ..\bin\SuperSocket.SocketBase.dll + + + + + + + + + + + + + + + + + + {9bf5d683-f4f2-4d3d-8163-edb3c3d6eafc} + SensorHub.Servers + + + + + \ No newline at end of file diff --git a/SensorHub.WellPlus/WellPlus.cs b/SensorHub.WellPlus/WellPlus.cs new file mode 100644 index 0000000..d9418e9 --- /dev/null +++ b/SensorHub.WellPlus/WellPlus.cs @@ -0,0 +1,147 @@ +using SensorHub.Servers; +using SensorHub.Servers.Commands.CASICCommands; +using SensorHub.Servers.JsonFormat; +using SuperSocket.SocketBase.Command; +using SuperSocket.SocketBase.Protocol; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SensorHub.WellPlus +{ + public class WellPlus : CommandBase + { + public override void ExecuteCommand(CasicSession session, StringRequestInfo requestInfo) + { + //TODO: construct the receving casic data + String preamble = requestInfo.Parameters[0]; + String version = requestInfo.Parameters[1]; + String leng = requestInfo.Parameters[2]; + String devCode = requestInfo.Parameters[3]; + String routeFlag = requestInfo.Parameters[4]; + String dstNodeAddr = requestInfo.Parameters[5]; + String pduType = requestInfo.Parameters[6]; + String seq = requestInfo.Parameters[7]; + String settings = requestInfo.Parameters[8]; + String source = requestInfo.Parameters[9]; + + String devName = "WellPlus"; + + if (source.Contains("-")) + { + session.Send("HTTP/1.1 200 OK\r\n\r\n\r\n"); + session.Close(); + } + + //print the receving data + String devType = "井盖液位一体机"; + String operType = Common.getOpeTypeByPdu(pduType); + session.Logger.Info("AD接收数据:" + requestInfo.Body); + session.Logger.Info("设备类型:" + devType); + session.Logger.Info("操作类型:" + operType); + session.Logger.Info("会话:" + session.HubAddr + "," + session.SessionID); + + List tags = Common.getTags(settings, session); + + //具体业务处理 + String collectDate = ""; + List eventList = new List(); + List datasList = new List(); + List startupList = new List(); + + foreach (Tag tag in tags) + { + if (!(tag is UploadTag)) + { + //非业务处理 + if (tag != null && tag is SystemDateTag) + { + SystemDateTag systemDateTag = tag as SystemDateTag; + collectDate = systemDateTag.CollectDate; + continue; + } + + if (tag != null && tag is SensorStartupTag) + { + SensorStartupTag sensorStartup = tag as SensorStartupTag; + String imei = sensorStartup.IMEI; + String iccid = sensorStartup.ICCID; + + startupList.Add(imei); + startupList.Add(iccid); + + session.Logger.Info("设备开机上报,设备编号DEVCODE:" + devCode + " IMEI:" + imei + " ICCID:" + iccid); + continue; + } + } + else + { + //业务处理 + UploadTag uploadTag = tag as UploadTag; + switch (uploadTag.BizType) + { + case 7: + //开关状态 + TagHandler wellPlusHandler = new WellPlusTagHandler(); + wellPlusHandler.resolve(tag, session); + + if(wellPlusHandler.DataList.Count > 0) + { + DateTime upTime = Convert.ToDateTime(collectDate + " " + wellPlusHandler.CollecTime); + String uptime = upTime.ToString("yyyy") + upTime.ToString("MM") + upTime.ToString("dd") + + upTime.ToString("HH") + upTime.ToString("mm") + upTime.ToString("ss"); + + switch ((byte)wellPlusHandler.DataList[0]) + { + case 0: + datasList.Add(new WellPlusDatasJson(uptime, "00")); + break; + case 1: + eventList.Add("WellPlusOpenAlarm");//井盖开启 + break; + case 2: + // eventList.Add("WellDeviceBadAlarm");//设备故障 + break; + case 3: + // eventList.Add("WellLowBatteryAlarm");//低电量 + break; + case 4: + eventList.Add("WellPlusLevelAlarm"); // 液位超限报警 + break; + default: + eventList.Add("WellPlusUnknown");//未知异常 + break; + } + } + break; + default: + session.Logger.Info("未知业务类型!"); + break; + } + } + } + + //Common.sendMessage(session, "Well", devCode, -1, eventList, datasList, startupList); + Common.kafkaProduce(session, devName, devCode, -1, null, null, null, eventList, datasList, startupList); + + if (source != "433") //433井盖不要求回复 + { + byte[] btPdu = new byte[2]; //2个字节 + if (operType == "TrapRequest") + { + btPdu[0] = 0x05; + } + else if (operType == "StartupRequest") + { + btPdu[0] = 0x09; + } + + btPdu[1] = 0x86; + + Common.sendConfig(session, devCode, routeFlag, source, btPdu); + } + + } + } +} diff --git a/SensorHub.WellPlus/WellPlusDatasJson.cs b/SensorHub.WellPlus/WellPlusDatasJson.cs new file mode 100644 index 0000000..7ccade4 --- /dev/null +++ b/SensorHub.WellPlus/WellPlusDatasJson.cs @@ -0,0 +1,20 @@ +using SensorHub.Servers.JsonFormat; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SensorHub.WellPlus +{ + public class WellPlusDatasJson : DatasJson + { + public string value { get; set; } //井盖一体机状态 + + public WellPlusDatasJson(string uptime, string value) + { + this.uptime = uptime; + this.value = value; + } + } +} \ No newline at end of file diff --git a/SensorHub.WellPlus/WellPlusTagHandler.cs b/SensorHub.WellPlus/WellPlusTagHandler.cs new file mode 100644 index 0000000..08d7196 --- /dev/null +++ b/SensorHub.WellPlus/WellPlusTagHandler.cs @@ -0,0 +1,43 @@ +using SensorHub.Servers; +using SensorHub.Servers.Commands.CASICCommands; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SensorHub.WellPlus +{ + class WellPlusTagHandler:TagHandler + { + public override bool isThisTag(Tag tag) + { + if (!(tag is UploadTag)) + { + return false; + } + + UploadTag uploadTag = tag as UploadTag; + + return uploadTag.BizType == 7 ? true : false; + } + + public override void resolve(Tag tag, CasicSession session) + { + UploadTag wellPlusTag = tag as UploadTag; + Interval = wellPlusTag.CollectInter; + CollecTime = wellPlusTag.CollectTime; + int len = wellPlusTag.Len; + String dataValue = wellPlusTag.DataValue; + + session.Logger.Info("井盖一体机数据上传TAG:oid:" + wellPlusTag.Oid + " 采集间隔: " + + Interval + "采集时间:" + CollecTime + "上传数值:" + dataValue); + + DataList = new List(); + byte btStatus = byte.Parse(dataValue, System.Globalization.NumberStyles.HexNumber); + + DataList.Add(btStatus); + } + + } +} diff --git a/SensorHub.WellPlus/Properties/AssemblyInfo.cs b/SensorHub.WellPlus/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b0ef1f9 --- /dev/null +++ b/SensorHub.WellPlus/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SensorHub.WellPlus")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SensorHub.WellPlus")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("cdae0e93-0ca1-446f-99a1-2d071f73700c")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SensorHub.WellPlus/SensorHub.WellPlus.csproj b/SensorHub.WellPlus/SensorHub.WellPlus.csproj new file mode 100644 index 0000000..5042574 --- /dev/null +++ b/SensorHub.WellPlus/SensorHub.WellPlus.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB} + Library + Properties + SensorHub.WellPlus + SensorHub.WellPlus + v4.5 + 512 + + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + false + + + + False + ..\bin\SuperSocket.SocketBase.dll + + + + + + + + + + + + + + + + + + {9bf5d683-f4f2-4d3d-8163-edb3c3d6eafc} + SensorHub.Servers + + + + + \ No newline at end of file diff --git a/SensorHub.WellPlus/WellPlus.cs b/SensorHub.WellPlus/WellPlus.cs new file mode 100644 index 0000000..d9418e9 --- /dev/null +++ b/SensorHub.WellPlus/WellPlus.cs @@ -0,0 +1,147 @@ +using SensorHub.Servers; +using SensorHub.Servers.Commands.CASICCommands; +using SensorHub.Servers.JsonFormat; +using SuperSocket.SocketBase.Command; +using SuperSocket.SocketBase.Protocol; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SensorHub.WellPlus +{ + public class WellPlus : CommandBase + { + public override void ExecuteCommand(CasicSession session, StringRequestInfo requestInfo) + { + //TODO: construct the receving casic data + String preamble = requestInfo.Parameters[0]; + String version = requestInfo.Parameters[1]; + String leng = requestInfo.Parameters[2]; + String devCode = requestInfo.Parameters[3]; + String routeFlag = requestInfo.Parameters[4]; + String dstNodeAddr = requestInfo.Parameters[5]; + String pduType = requestInfo.Parameters[6]; + String seq = requestInfo.Parameters[7]; + String settings = requestInfo.Parameters[8]; + String source = requestInfo.Parameters[9]; + + String devName = "WellPlus"; + + if (source.Contains("-")) + { + session.Send("HTTP/1.1 200 OK\r\n\r\n\r\n"); + session.Close(); + } + + //print the receving data + String devType = "井盖液位一体机"; + String operType = Common.getOpeTypeByPdu(pduType); + session.Logger.Info("AD接收数据:" + requestInfo.Body); + session.Logger.Info("设备类型:" + devType); + session.Logger.Info("操作类型:" + operType); + session.Logger.Info("会话:" + session.HubAddr + "," + session.SessionID); + + List tags = Common.getTags(settings, session); + + //具体业务处理 + String collectDate = ""; + List eventList = new List(); + List datasList = new List(); + List startupList = new List(); + + foreach (Tag tag in tags) + { + if (!(tag is UploadTag)) + { + //非业务处理 + if (tag != null && tag is SystemDateTag) + { + SystemDateTag systemDateTag = tag as SystemDateTag; + collectDate = systemDateTag.CollectDate; + continue; + } + + if (tag != null && tag is SensorStartupTag) + { + SensorStartupTag sensorStartup = tag as SensorStartupTag; + String imei = sensorStartup.IMEI; + String iccid = sensorStartup.ICCID; + + startupList.Add(imei); + startupList.Add(iccid); + + session.Logger.Info("设备开机上报,设备编号DEVCODE:" + devCode + " IMEI:" + imei + " ICCID:" + iccid); + continue; + } + } + else + { + //业务处理 + UploadTag uploadTag = tag as UploadTag; + switch (uploadTag.BizType) + { + case 7: + //开关状态 + TagHandler wellPlusHandler = new WellPlusTagHandler(); + wellPlusHandler.resolve(tag, session); + + if(wellPlusHandler.DataList.Count > 0) + { + DateTime upTime = Convert.ToDateTime(collectDate + " " + wellPlusHandler.CollecTime); + String uptime = upTime.ToString("yyyy") + upTime.ToString("MM") + upTime.ToString("dd") + + upTime.ToString("HH") + upTime.ToString("mm") + upTime.ToString("ss"); + + switch ((byte)wellPlusHandler.DataList[0]) + { + case 0: + datasList.Add(new WellPlusDatasJson(uptime, "00")); + break; + case 1: + eventList.Add("WellPlusOpenAlarm");//井盖开启 + break; + case 2: + // eventList.Add("WellDeviceBadAlarm");//设备故障 + break; + case 3: + // eventList.Add("WellLowBatteryAlarm");//低电量 + break; + case 4: + eventList.Add("WellPlusLevelAlarm"); // 液位超限报警 + break; + default: + eventList.Add("WellPlusUnknown");//未知异常 + break; + } + } + break; + default: + session.Logger.Info("未知业务类型!"); + break; + } + } + } + + //Common.sendMessage(session, "Well", devCode, -1, eventList, datasList, startupList); + Common.kafkaProduce(session, devName, devCode, -1, null, null, null, eventList, datasList, startupList); + + if (source != "433") //433井盖不要求回复 + { + byte[] btPdu = new byte[2]; //2个字节 + if (operType == "TrapRequest") + { + btPdu[0] = 0x05; + } + else if (operType == "StartupRequest") + { + btPdu[0] = 0x09; + } + + btPdu[1] = 0x86; + + Common.sendConfig(session, devCode, routeFlag, source, btPdu); + } + + } + } +} diff --git a/SensorHub.WellPlus/WellPlusDatasJson.cs b/SensorHub.WellPlus/WellPlusDatasJson.cs new file mode 100644 index 0000000..7ccade4 --- /dev/null +++ b/SensorHub.WellPlus/WellPlusDatasJson.cs @@ -0,0 +1,20 @@ +using SensorHub.Servers.JsonFormat; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SensorHub.WellPlus +{ + public class WellPlusDatasJson : DatasJson + { + public string value { get; set; } //井盖一体机状态 + + public WellPlusDatasJson(string uptime, string value) + { + this.uptime = uptime; + this.value = value; + } + } +} \ No newline at end of file diff --git a/SensorHub.WellPlus/WellPlusTagHandler.cs b/SensorHub.WellPlus/WellPlusTagHandler.cs new file mode 100644 index 0000000..08d7196 --- /dev/null +++ b/SensorHub.WellPlus/WellPlusTagHandler.cs @@ -0,0 +1,43 @@ +using SensorHub.Servers; +using SensorHub.Servers.Commands.CASICCommands; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SensorHub.WellPlus +{ + class WellPlusTagHandler:TagHandler + { + public override bool isThisTag(Tag tag) + { + if (!(tag is UploadTag)) + { + return false; + } + + UploadTag uploadTag = tag as UploadTag; + + return uploadTag.BizType == 7 ? true : false; + } + + public override void resolve(Tag tag, CasicSession session) + { + UploadTag wellPlusTag = tag as UploadTag; + Interval = wellPlusTag.CollectInter; + CollecTime = wellPlusTag.CollectTime; + int len = wellPlusTag.Len; + String dataValue = wellPlusTag.DataValue; + + session.Logger.Info("井盖一体机数据上传TAG:oid:" + wellPlusTag.Oid + " 采集间隔: " + + Interval + "采集时间:" + CollecTime + "上传数值:" + dataValue); + + DataList = new List(); + byte btStatus = byte.Parse(dataValue, System.Globalization.NumberStyles.HexNumber); + + DataList.Add(btStatus); + } + + } +} diff --git a/SensorHub.sln b/SensorHub.sln index c942047..70f3934 100644 --- a/SensorHub.sln +++ b/SensorHub.sln @@ -56,6 +56,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SensorHub.Tube", "SensorHub.Tube\SensorHub.Tube.csproj", "{D51363CE-EE08-4252-AD3A-6AEF13B5DF81}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SensorHub.WellPlus", "SensorHub.WellPlus\SensorHub.WellPlus.csproj", "{AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -341,6 +343,18 @@ {D51363CE-EE08-4252-AD3A-6AEF13B5DF81}.Release|Mixed Platforms.Build.0 = Release|Any CPU {D51363CE-EE08-4252-AD3A-6AEF13B5DF81}.Release|x86.ActiveCfg = Release|Any CPU {D51363CE-EE08-4252-AD3A-6AEF13B5DF81}.Release|x86.Build.0 = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|x86.ActiveCfg = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|x86.Build.0 = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|Any CPU.Build.0 = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|x86.ActiveCfg = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SensorHub.WellPlus/Properties/AssemblyInfo.cs b/SensorHub.WellPlus/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b0ef1f9 --- /dev/null +++ b/SensorHub.WellPlus/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SensorHub.WellPlus")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SensorHub.WellPlus")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("cdae0e93-0ca1-446f-99a1-2d071f73700c")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SensorHub.WellPlus/SensorHub.WellPlus.csproj b/SensorHub.WellPlus/SensorHub.WellPlus.csproj new file mode 100644 index 0000000..5042574 --- /dev/null +++ b/SensorHub.WellPlus/SensorHub.WellPlus.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB} + Library + Properties + SensorHub.WellPlus + SensorHub.WellPlus + v4.5 + 512 + + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + false + + + + False + ..\bin\SuperSocket.SocketBase.dll + + + + + + + + + + + + + + + + + + {9bf5d683-f4f2-4d3d-8163-edb3c3d6eafc} + SensorHub.Servers + + + + + \ No newline at end of file diff --git a/SensorHub.WellPlus/WellPlus.cs b/SensorHub.WellPlus/WellPlus.cs new file mode 100644 index 0000000..d9418e9 --- /dev/null +++ b/SensorHub.WellPlus/WellPlus.cs @@ -0,0 +1,147 @@ +using SensorHub.Servers; +using SensorHub.Servers.Commands.CASICCommands; +using SensorHub.Servers.JsonFormat; +using SuperSocket.SocketBase.Command; +using SuperSocket.SocketBase.Protocol; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SensorHub.WellPlus +{ + public class WellPlus : CommandBase + { + public override void ExecuteCommand(CasicSession session, StringRequestInfo requestInfo) + { + //TODO: construct the receving casic data + String preamble = requestInfo.Parameters[0]; + String version = requestInfo.Parameters[1]; + String leng = requestInfo.Parameters[2]; + String devCode = requestInfo.Parameters[3]; + String routeFlag = requestInfo.Parameters[4]; + String dstNodeAddr = requestInfo.Parameters[5]; + String pduType = requestInfo.Parameters[6]; + String seq = requestInfo.Parameters[7]; + String settings = requestInfo.Parameters[8]; + String source = requestInfo.Parameters[9]; + + String devName = "WellPlus"; + + if (source.Contains("-")) + { + session.Send("HTTP/1.1 200 OK\r\n\r\n\r\n"); + session.Close(); + } + + //print the receving data + String devType = "井盖液位一体机"; + String operType = Common.getOpeTypeByPdu(pduType); + session.Logger.Info("AD接收数据:" + requestInfo.Body); + session.Logger.Info("设备类型:" + devType); + session.Logger.Info("操作类型:" + operType); + session.Logger.Info("会话:" + session.HubAddr + "," + session.SessionID); + + List tags = Common.getTags(settings, session); + + //具体业务处理 + String collectDate = ""; + List eventList = new List(); + List datasList = new List(); + List startupList = new List(); + + foreach (Tag tag in tags) + { + if (!(tag is UploadTag)) + { + //非业务处理 + if (tag != null && tag is SystemDateTag) + { + SystemDateTag systemDateTag = tag as SystemDateTag; + collectDate = systemDateTag.CollectDate; + continue; + } + + if (tag != null && tag is SensorStartupTag) + { + SensorStartupTag sensorStartup = tag as SensorStartupTag; + String imei = sensorStartup.IMEI; + String iccid = sensorStartup.ICCID; + + startupList.Add(imei); + startupList.Add(iccid); + + session.Logger.Info("设备开机上报,设备编号DEVCODE:" + devCode + " IMEI:" + imei + " ICCID:" + iccid); + continue; + } + } + else + { + //业务处理 + UploadTag uploadTag = tag as UploadTag; + switch (uploadTag.BizType) + { + case 7: + //开关状态 + TagHandler wellPlusHandler = new WellPlusTagHandler(); + wellPlusHandler.resolve(tag, session); + + if(wellPlusHandler.DataList.Count > 0) + { + DateTime upTime = Convert.ToDateTime(collectDate + " " + wellPlusHandler.CollecTime); + String uptime = upTime.ToString("yyyy") + upTime.ToString("MM") + upTime.ToString("dd") + + upTime.ToString("HH") + upTime.ToString("mm") + upTime.ToString("ss"); + + switch ((byte)wellPlusHandler.DataList[0]) + { + case 0: + datasList.Add(new WellPlusDatasJson(uptime, "00")); + break; + case 1: + eventList.Add("WellPlusOpenAlarm");//井盖开启 + break; + case 2: + // eventList.Add("WellDeviceBadAlarm");//设备故障 + break; + case 3: + // eventList.Add("WellLowBatteryAlarm");//低电量 + break; + case 4: + eventList.Add("WellPlusLevelAlarm"); // 液位超限报警 + break; + default: + eventList.Add("WellPlusUnknown");//未知异常 + break; + } + } + break; + default: + session.Logger.Info("未知业务类型!"); + break; + } + } + } + + //Common.sendMessage(session, "Well", devCode, -1, eventList, datasList, startupList); + Common.kafkaProduce(session, devName, devCode, -1, null, null, null, eventList, datasList, startupList); + + if (source != "433") //433井盖不要求回复 + { + byte[] btPdu = new byte[2]; //2个字节 + if (operType == "TrapRequest") + { + btPdu[0] = 0x05; + } + else if (operType == "StartupRequest") + { + btPdu[0] = 0x09; + } + + btPdu[1] = 0x86; + + Common.sendConfig(session, devCode, routeFlag, source, btPdu); + } + + } + } +} diff --git a/SensorHub.WellPlus/WellPlusDatasJson.cs b/SensorHub.WellPlus/WellPlusDatasJson.cs new file mode 100644 index 0000000..7ccade4 --- /dev/null +++ b/SensorHub.WellPlus/WellPlusDatasJson.cs @@ -0,0 +1,20 @@ +using SensorHub.Servers.JsonFormat; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SensorHub.WellPlus +{ + public class WellPlusDatasJson : DatasJson + { + public string value { get; set; } //井盖一体机状态 + + public WellPlusDatasJson(string uptime, string value) + { + this.uptime = uptime; + this.value = value; + } + } +} \ No newline at end of file diff --git a/SensorHub.WellPlus/WellPlusTagHandler.cs b/SensorHub.WellPlus/WellPlusTagHandler.cs new file mode 100644 index 0000000..08d7196 --- /dev/null +++ b/SensorHub.WellPlus/WellPlusTagHandler.cs @@ -0,0 +1,43 @@ +using SensorHub.Servers; +using SensorHub.Servers.Commands.CASICCommands; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SensorHub.WellPlus +{ + class WellPlusTagHandler:TagHandler + { + public override bool isThisTag(Tag tag) + { + if (!(tag is UploadTag)) + { + return false; + } + + UploadTag uploadTag = tag as UploadTag; + + return uploadTag.BizType == 7 ? true : false; + } + + public override void resolve(Tag tag, CasicSession session) + { + UploadTag wellPlusTag = tag as UploadTag; + Interval = wellPlusTag.CollectInter; + CollecTime = wellPlusTag.CollectTime; + int len = wellPlusTag.Len; + String dataValue = wellPlusTag.DataValue; + + session.Logger.Info("井盖一体机数据上传TAG:oid:" + wellPlusTag.Oid + " 采集间隔: " + + Interval + "采集时间:" + CollecTime + "上传数值:" + dataValue); + + DataList = new List(); + byte btStatus = byte.Parse(dataValue, System.Globalization.NumberStyles.HexNumber); + + DataList.Add(btStatus); + } + + } +} diff --git a/SensorHub.sln b/SensorHub.sln index c942047..70f3934 100644 --- a/SensorHub.sln +++ b/SensorHub.sln @@ -56,6 +56,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SensorHub.Tube", "SensorHub.Tube\SensorHub.Tube.csproj", "{D51363CE-EE08-4252-AD3A-6AEF13B5DF81}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SensorHub.WellPlus", "SensorHub.WellPlus\SensorHub.WellPlus.csproj", "{AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -341,6 +343,18 @@ {D51363CE-EE08-4252-AD3A-6AEF13B5DF81}.Release|Mixed Platforms.Build.0 = Release|Any CPU {D51363CE-EE08-4252-AD3A-6AEF13B5DF81}.Release|x86.ActiveCfg = Release|Any CPU {D51363CE-EE08-4252-AD3A-6AEF13B5DF81}.Release|x86.Build.0 = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|x86.ActiveCfg = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Debug|x86.Build.0 = Debug|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|Any CPU.Build.0 = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|x86.ActiveCfg = Release|Any CPU + {AC7C9615-3528-48C2-B7E1-EC810BD0E4DB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TestClass/App.config b/TestClass/App.config index bd32d7c..dfa376d 100644 --- a/TestClass/App.config +++ b/TestClass/App.config @@ -38,6 +38,7 @@ + @@ -58,6 +59,7 @@ + @@ -121,7 +123,7 @@ - + @@ -151,6 +153,7 @@ + @@ -158,10 +161,11 @@ - - + + - + + @@ -176,7 +180,7 @@ - +