├── .gitignore ├── IoTClient.Tool.sln ├── IoTClient.Tool ├── 24px.ico ├── App.config ├── Charts │ ├── BrokenLineChart.cs │ ├── BrokenLineChart.designer.cs │ ├── BrokenLineChart.resx │ └── MeasureModel.cs ├── Common │ ├── ConnectionConfig.cs │ └── Helper │ │ └── StringExtension.cs ├── Controls │ ├── AllenBradleyControl.Designer.cs │ ├── AllenBradleyControl.cs │ ├── AllenBradleyControl.resx │ ├── BACnetControl.Designer.cs │ ├── BACnetControl.cs │ ├── BACnetControl.resx │ ├── MQTTControl.Designer.cs │ ├── MQTTControl.cs │ ├── MQTTControl.resx │ ├── MitsubishiMCControl.Designer.cs │ ├── MitsubishiMCControl.cs │ ├── MitsubishiMCControl.resx │ ├── ModBusAsciiControl.Designer.cs │ ├── ModBusAsciiControl.cs │ ├── ModBusRtuControl.Designer.cs │ ├── ModBusRtuControl.cs │ ├── ModBusTcpControl.Designer.cs │ ├── ModBusTcpControl.cs │ ├── ModbusAsciiControl.resx │ ├── ModbusRtuControl.resx │ ├── ModbusTcpControl.resx │ ├── OmronFinsTcpControl.Designer.cs │ ├── OmronFinsTcpControl.cs │ ├── OmronFinsTcpControl.resx │ ├── OtherControl.Designer.cs │ ├── OtherControl.cs │ ├── OtherControl.resx │ ├── PortsControl.Designer.cs │ ├── PortsControl.cs │ ├── PortsControl.resx │ ├── SiemensControl.Designer.cs │ ├── SiemensControl.cs │ ├── SiemensControl.resx │ ├── SiemensS7_300Control.Designer.cs │ ├── SiemensS7_300Control.cs │ ├── SiemensS7_300Control.resx │ └── TextBoxEx.cs ├── FodyWeavers.xml ├── FodyWeavers.xsd ├── IndexForm.Designer.cs ├── IndexForm.cs ├── IndexForm.resx ├── IoTClient.Tool.csproj ├── IoTClient.ico ├── ModBusTcpForm.Designer.cs ├── ModBusTcpForm.cs ├── ModBusTcpForm.resx ├── Model │ ├── BacNode.cs │ ├── BacProperty.cs │ ├── BacnetPropertyInfo.cs │ ├── ResultBase.cs │ ├── VersionCheckInput.cs │ └── VersionCheckOutput.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── SiemensForm.Designer.cs ├── SiemensForm.cs ├── SiemensForm.resx ├── UpdateLog.Designer.cs ├── UpdateLog.cs ├── UpdateLog.resx ├── UpgradeForm.Designer.cs ├── UpgradeForm.cs ├── UpgradeForm.resx ├── favicon.ico └── packages.config ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc 262 | 263 | #NLog# 264 | **/nlogs/ 265 | *log.*.txt 266 | *.modelproj 267 | 268 | #kdiff3 269 | *.org 270 | /IoTClient.Tests/appsettings.json 271 | /IoTClient/自增版本号打包.ps1 272 | /IoTClient/version.props 273 | /IoTServer/version.props 274 | /IoTServer/自增版本号打包.ps1 275 | /IoTClient/IoTClient/IoTClient.xml 276 | /IoTServer/IoTServer/IoTServer.xml 277 | /packages 278 | -------------------------------------------------------------------------------- /IoTClient.Tool.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30907.101 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTClient.Tool", "IoTClient.Tool\IoTClient.Tool.csproj", "{B1C73EE0-6F67-4DB0-BBAF-EFAFD62457CD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B1C73EE0-6F67-4DB0-BBAF-EFAFD62457CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {B1C73EE0-6F67-4DB0-BBAF-EFAFD62457CD}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {B1C73EE0-6F67-4DB0-BBAF-EFAFD62457CD}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {B1C73EE0-6F67-4DB0-BBAF-EFAFD62457CD}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {CBE079FD-23D5-4D1A-9183-BC2ED5915A55} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /IoTClient.Tool/24px.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaopeiym/IoTClient.Examples/e478e53dec790f0cffcdc1803f87df3bb2438d6c/IoTClient.Tool/24px.ico -------------------------------------------------------------------------------- /IoTClient.Tool/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /IoTClient.Tool/Charts/BrokenLineChart.cs: -------------------------------------------------------------------------------- 1 | using LiveCharts; 2 | using LiveCharts.Configurations; 3 | using LiveCharts.Wpf; 4 | using System; 5 | using System.Windows.Forms; 6 | 7 | namespace IoTClient.Tool 8 | { 9 | public partial class BrokenLineChart : Form 10 | { 11 | public BrokenLineChart(string title) 12 | { 13 | InitializeComponent(); 14 | 15 | StartPosition = FormStartPosition.CenterScreen; 16 | //FormBorderStyle = FormBorderStyle.FixedSingle; 17 | 18 | var mapper = Mappers.Xy() 19 | .X(model => model.DateTime.Ticks) 20 | .Y(model => model.Value); 21 | 22 | Charting.For(mapper); 23 | 24 | ChartValues = new ChartValues(); 25 | cartesianChart1.Series = new SeriesCollection 26 | { 27 | new LineSeries 28 | { 29 | Values = ChartValues, 30 | PointGeometrySize = 1, 31 | StrokeThickness = 2, 32 | Title ="地址: "+ title+" 值:" 33 | } 34 | }; 35 | cartesianChart1.AxisX.Add(new Axis 36 | { 37 | DisableAnimations = true, 38 | LabelFormatter = value => new DateTime((long)value).ToString("mm:ss"), 39 | Separator = new Separator 40 | { 41 | Step = TimeSpan.FromSeconds(5).Ticks 42 | } 43 | }); 44 | 45 | SetAxisLimits(DateTime.Now); 46 | } 47 | 48 | public ChartValues ChartValues { get; set; } 49 | 50 | private void SetAxisLimits(DateTime now) 51 | { 52 | var step = ChartValues.Count * 800 / 1000 / 15f; 53 | var new_step = step <= 1 ? 1 : step; 54 | cartesianChart1.AxisX[0].Separator = new Separator 55 | { 56 | Step = TimeSpan.FromSeconds(new_step).Ticks 57 | }; 58 | //cartesianChart1.AxisX[0].MaxValue = now.Ticks + TimeSpan.FromSeconds(0).Ticks; 59 | //cartesianChart1.AxisX[0].MinValue = now.Ticks - TimeSpan.FromSeconds(60).Ticks; 60 | } 61 | 62 | public void AddData(double value) 63 | { 64 | 65 | var now = DateTime.Now; 66 | 67 | ChartValues.Add(new MeasureModel 68 | { 69 | DateTime = now, 70 | Value = Math.Round(value, 4) 71 | }); 72 | 73 | SetAxisLimits(now); 74 | 75 | if (ChartValues.Count > 400) ChartValues.RemoveAt(0); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /IoTClient.Tool/Charts/BrokenLineChart.designer.cs: -------------------------------------------------------------------------------- 1 | namespace IoTClient.Tool 2 | { 3 | partial class BrokenLineChart 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BrokenLineChart)); 32 | this.cartesianChart1 = new LiveCharts.WinForms.CartesianChart(); 33 | this.SuspendLayout(); 34 | // 35 | // cartesianChart1 36 | // 37 | this.cartesianChart1.Dock = System.Windows.Forms.DockStyle.Fill; 38 | this.cartesianChart1.Location = new System.Drawing.Point(0, 0); 39 | this.cartesianChart1.Name = "cartesianChart1"; 40 | this.cartesianChart1.Size = new System.Drawing.Size(753, 427); 41 | this.cartesianChart1.TabIndex = 1; 42 | this.cartesianChart1.Text = "cartesianChart1"; 43 | // 44 | // BrokenLineChart 45 | // 46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 48 | this.BackColor = System.Drawing.Color.White; 49 | this.ClientSize = new System.Drawing.Size(753, 427); 50 | this.Controls.Add(this.cartesianChart1); 51 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 52 | this.Name = "BrokenLineChart"; 53 | this.Text = "折线图"; 54 | this.ResumeLayout(false); 55 | 56 | } 57 | 58 | #endregion 59 | 60 | private LiveCharts.WinForms.CartesianChart cartesianChart1; 61 | } 62 | } -------------------------------------------------------------------------------- /IoTClient.Tool/Charts/BrokenLineChart.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | 123 | AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 124 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 125 | AAAAAAAAlYlV3pWJVd6ViVXelYlV3pWJVd6ViVXelYlV3pWJVd6ViVXelYlV3pWJVd6ViVXelYlV3pWJ 126 | Vd6UiVWyk4hVEpWJVf+ViVXmlYlV3pWJVd6ViVXelYlV3pWJVd6ViVXelYlV3pWJVd6ViVXelYlV3pWJ 127 | Vd6ViVXelIlVspOIVRKViVX/lYlUeAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 128 | AAAAAAAAAAAAAAAAAAAAAAAAlYlV/5WJVHgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 129 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJWJVf+ViVR4lIhVLJSIVHSSiFcEAAAAAAAAAAAAAAAAlYlVGJWJ 130 | VUaXi1QCAAAAAAAAAAAAAAAAAAAAAAAAAACViVX/lYlUeJWIVHiViVX8lYhUSAAAAAAAAAAAlYlVMJSJ 131 | VN6ViVX0lYlVMgAAAAAAAAAAAAAAAAAAAAAAAAAAlYlV/5WJVHiViVUelYlU7pWIVMaViVQIlIlVYJWJ 132 | VPKViVT0lYlU7pWIVLYAAAAAAAAAAAAAAAAAAAAAAAAAAJWJVf+ViVR4mY9SAJWJVIqViVX/lYlUvpWJ 133 | Vf+ViFXklIhVOJSIVZCViVT6lYhUSgAAAAAAAAAAAAAAAAAAAACViVX/lYlUeAAAAACWiFQYlYhU4pWJ 134 | Vf+ViVW8lIhUHAAAAACUiVUglIhV6pWJVcKWilUKAAAAAAAAAAAAAAAAlYlV/5WJVHgAAAAAAAAAAJSI 135 | VEyUiFRwk4dVCgAAAAAAAAAAAAAAAJSJVIaViVX8lIlUXAAAAAAAAAAAAAAAAJWJVf+ViVR4AAAAAAAA 136 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACTiVQWlIlV7JWIVdqViVUOAAAAAAAAAACViVX/lYlUeAAA 137 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJWJVHSViVX/lYlVdAAAAAAAAAAAlYlV/5WJ 138 | VHgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACUiFUSlIhV2pSJVdgAAAAAAAAAAJWJ 139 | Vf+ViVR4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJWJVTCViFRKAAAAAAAA 140 | AACViVTKlIhUVgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 141 | AAAAAAAA//8AAAABAAAAAQAAf/8AAH//AAB//wAAbz8AAGYfAABgnwAAcc8AAH/PAAB/5wAAf/cAAH/z 142 | AAB//wAAf/8AAA== 143 | 144 | 145 | -------------------------------------------------------------------------------- /IoTClient.Tool/Charts/MeasureModel.cs: -------------------------------------------------------------------------------- 1 | namespace IoTClient.Tool 2 | { 3 | public class MeasureModel 4 | { 5 | public System.DateTime DateTime { get; set; } 6 | public double Value { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /IoTClient.Tool/Common/ConnectionConfig.cs: -------------------------------------------------------------------------------- 1 | using IoTClient.Enums; 2 | using Newtonsoft.Json; 3 | using System.IO; 4 | using System.IO.Ports; 5 | 6 | namespace IoTClient.Tool.Common 7 | { 8 | /// 9 | /// 界面配置信息 10 | /// 11 | public class ConnectionConfig 12 | { 13 | public string ModBusTcp_IP; 14 | public string ModBusTcp_Port; 15 | /// 16 | /// 站号 17 | /// 18 | public string ModBusTcp_StationNumber; 19 | /// 20 | /// 大小端 21 | /// 22 | public EndianFormat ModBusTcp_EndianFormat = EndianFormat.ABCD; 23 | public string ModBusTcp_Address; 24 | public string ModBusTcp_Value; 25 | public bool ModBusTcp_ShowPackage; 26 | public string ModBusTcp_Datatype; 27 | 28 | 29 | public string ModBusRtu_Address; 30 | public string ModBusRtu_Value; 31 | public bool ModBusRtu_ShowPackage; 32 | public string ModBusRtu_PortName; 33 | public string ModBusRtu_BaudRate; 34 | public string ModBusRtu_DataBits; 35 | public StopBits ModBusRtu_StopBits = StopBits.One; 36 | public Parity ModBusRtu_Parity = Parity.None; 37 | public string ModBusRtu_Datatype; 38 | public EndianFormat ModBusRtu_EndianFormat; 39 | public string ModBusRtu_StationNumber; 40 | 41 | public string ModBusAscii_Address; 42 | public string ModBusAscii_Value; 43 | public bool ModBusAscii_ShowPackage; 44 | public string ModBusAscii_PortName; 45 | public string ModBusAscii_BaudRate; 46 | public string ModBusAscii_DataBits; 47 | public StopBits ModBusAscii_StopBits; 48 | public Parity ModBusAscii_Parity; 49 | public EndianFormat ModBusAscii_EndianFormat; 50 | public string ModBusAscii_Datatype; 51 | public string ModBusAscii_StationNumber; 52 | 53 | public string S7200_IP; 54 | public string S7200_Port; 55 | public string S7200_Address; 56 | public string S7200_Value; 57 | public bool S7200_ShowPackage; 58 | public string S7200_Datatype; 59 | 60 | public string S7200Smart_IP; 61 | public string S7200Smart_Port; 62 | public string S7200Smart_Address; 63 | public string S7200Smart_Value; 64 | public bool S7200Smart_ShowPackage; 65 | 66 | public string S7300_IP; 67 | public string S7300_Port; 68 | public string S7300_Address; 69 | public string S7300_Value; 70 | public bool S7300_ShowPackage; 71 | 72 | public string S7400_IP; 73 | public string S7400_Port; 74 | public string S7400_Address; 75 | public string S7400_Value; 76 | public bool S7400_ShowPackage; 77 | 78 | public string S71200_IP; 79 | public string S71200_Port; 80 | public string S71200_Address; 81 | public string S71200_Value; 82 | public bool S71200_ShowPackage; 83 | 84 | public string S71500_IP; 85 | public string S71500_Port; 86 | public string S71500_Address; 87 | public string S71500_Value; 88 | public bool S71500_ShowPackage; 89 | 90 | public string MitsubishiQna3E_IP; 91 | public string MitsubishiQna3E_Port; 92 | public string MitsubishiQna3E_Address; 93 | public string MitsubishiQna3E_Value; 94 | public bool MitsubishiQna3E_ShowPackage; 95 | 96 | public string MitsubishiA1E_IP; 97 | public string MitsubishiA1E_Port; 98 | public string MitsubishiA1E_Address; 99 | public string MitsubishiA1E_Value; 100 | public bool MitsubishiA1E_ShowPackage; 101 | 102 | public string OmronFins_IP; 103 | public string OmronFins_Port; 104 | public string OmronFins_Address; 105 | public string OmronFins_Value; 106 | public bool OmronFins_ShowPackage; 107 | 108 | public string S7200Smart_Datatype; 109 | public string S7300_Datatype; 110 | public string S7400_Datatype; 111 | public string S71200_Datatype; 112 | public string S71500_Datatype; 113 | public string MitsubishiA1E_Datatype; 114 | public string MitsubishiQna3E_Datatype; 115 | public string OmronFins_Datatype; 116 | 117 | public string AllenBradley_IP; 118 | public string AllenBradley_Port; 119 | public string AllenBradley_Address; 120 | public string AllenBradley_Value; 121 | public bool AllenBradley_ShowPackage; 122 | public string AllenBradley_Datatype; 123 | public string AllenBradley_Slot; 124 | 125 | public string S7200_Rack { get; set; } 126 | public string S7200_Slot { get; set; } 127 | public string S7200Smart_Slot { get; set; } 128 | public string S7200Smart_Rack { get; set; } 129 | public string S7300_Slot { get; set; } 130 | public string S7300_Rack { get; set; } 131 | public string S7400_Slot { get; set; } 132 | public string S7400_Rack { get; set; } 133 | public string S71200_Slot { get; set; } 134 | public string S71200_Rack { get; set; } 135 | public string S71500_Slot { get; set; } 136 | public string S71500_Rack { get; set; } 137 | 138 | public static ConnectionConfig GetConfig() 139 | { 140 | var dataString = string.Empty; 141 | var path = @"C:\IoTClient"; 142 | var filePath = path + @"\ConnectionConfig.Data"; 143 | if (File.Exists(filePath)) 144 | dataString = File.ReadAllText(filePath); 145 | else 146 | { 147 | if (!Directory.Exists(path)) 148 | Directory.CreateDirectory(path); 149 | File.SetAttributes(path, FileAttributes.Hidden); 150 | } 151 | return JsonConvert.DeserializeObject(dataString) ?? new ConnectionConfig(); 152 | } 153 | 154 | public void SaveConfig() 155 | { 156 | var dataString = JsonConvert.SerializeObject(this); 157 | var path = @"C:\IoTClient"; 158 | var filePath = path + @"\ConnectionConfig.Data"; 159 | using (FileStream fileStream = new FileStream(filePath, FileMode.Create)) 160 | { 161 | using (StreamWriter sw = new StreamWriter(fileStream)) 162 | { 163 | sw.Write(dataString); 164 | } 165 | } 166 | } 167 | } 168 | } -------------------------------------------------------------------------------- /IoTClient.Tool/Common/Helper/StringExtension.cs: -------------------------------------------------------------------------------- 1 | using IoTClient.Enums; 2 | using System; 3 | 4 | namespace IoTClient.Tool.Helper 5 | { 6 | public static class StringExtension 7 | { 8 | /// 9 | /// 转出对应数据类型 10 | /// 11 | /// 12 | /// 13 | /// 14 | public static object ToDataFormType(this string str, Type type) 15 | { 16 | str = str?.Trim(); 17 | switch (Type.GetTypeCode(type)) 18 | { 19 | case TypeCode.Boolean: 20 | return bool.Parse(str); 21 | case TypeCode.Byte: 22 | return byte.Parse(str); 23 | case TypeCode.Char: 24 | return char.Parse(str); 25 | case TypeCode.DateTime: 26 | return DateTime.Parse(str); 27 | case TypeCode.Decimal: 28 | return decimal.Parse(str); 29 | case TypeCode.Double: 30 | return double.Parse(str); 31 | case TypeCode.Int16: 32 | return short.Parse(str); 33 | case TypeCode.Int32: 34 | return int.Parse(str); 35 | case TypeCode.Int64: 36 | return long.Parse(str); 37 | case TypeCode.SByte: 38 | return sbyte.Parse(str); 39 | case TypeCode.Single: 40 | return float.Parse(str); 41 | case TypeCode.UInt16: 42 | return ushort.Parse(str); 43 | case TypeCode.UInt32: 44 | return uint.Parse(str); 45 | case TypeCode.UInt64: 46 | return ulong.Parse(str); 47 | default: throw new ArgumentException("暂未定义类型"); 48 | } 49 | } 50 | 51 | /// 52 | /// 转出对应数据类型 53 | /// 54 | /// 55 | /// 56 | /// 57 | /// 58 | public static object ToDataFormType(this string value, DataTypeEnum type) 59 | { 60 | object newVlue; 61 | value = value?.Trim(); 62 | switch (type) 63 | { 64 | case DataTypeEnum.Bool: 65 | newVlue = value == "1" || value?.ToLower() == "true"; 66 | break; 67 | case DataTypeEnum.Byte: 68 | newVlue = byte.Parse(value); 69 | break; 70 | case DataTypeEnum.Int16: 71 | newVlue = short.Parse(value); 72 | break; 73 | case DataTypeEnum.UInt16: 74 | newVlue = ushort.Parse(value); 75 | break; 76 | case DataTypeEnum.Int32: 77 | newVlue = int.Parse(value); 78 | break; 79 | case DataTypeEnum.UInt32: 80 | newVlue = uint.Parse(value); 81 | break; 82 | case DataTypeEnum.Float: 83 | newVlue = float.Parse(value); 84 | break; 85 | case DataTypeEnum.String: 86 | newVlue = value; 87 | break; 88 | default: throw new Exception($"暂未定义类型:{type}"); 89 | } 90 | return newVlue; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/AllenBradleyControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/BACnetControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/MQTTControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using MQTTnet.Extensions.ManagedClient; 11 | using MQTTnet; 12 | using MQTTnet.Client.Options; 13 | using System.Security.Cryptography.X509Certificates; 14 | using System.IO; 15 | 16 | namespace IoTClient.Tool.Controls 17 | { 18 | public partial class MQTTControl : UserControl 19 | { 20 | public MQTTControl() 21 | { 22 | InitializeComponent(); 23 | CheckForIllegalCrossThreadCalls = false; 24 | Size = new Size(880, 450); 25 | comboBox1.SelectedIndex = 0; 26 | } 27 | 28 | private void Form1_Load(object sender, EventArgs e) 29 | { 30 | but_Subscribe.Enabled = false; 31 | but_Publish.Enabled = false; 32 | but_Stop.Enabled = false; 33 | txt_ClientID.Text = Guid.NewGuid().ToString(); 34 | checkBox1_CheckedChanged(null, null); 35 | } 36 | 37 | private IManagedMqttClient mqttClient; 38 | private async void but_start_ClickAsync(object sender, EventArgs even) 39 | { 40 | try 41 | { 42 | but_Stop_Click(null, null); 43 | var factory = new MqttFactory(); 44 | mqttClient = factory.CreateManagedMqttClient(); 45 | var mqttClientOptions = new MqttClientOptionsBuilder() 46 | .WithClientId(txt_ClientID.Text?.Trim()) 47 | //.WithTcpServer(txt_Address.Text?.Trim(), int.Parse(txt_Port.Text?.Trim())) 48 | .WithCredentials(txt_UserName.Text, txt_Password.Text); 49 | 50 | if (checkBox1.Checked) 51 | { 52 | if (!File.Exists(txt_ca_file.Text)) 53 | { 54 | MessageBox.Show($"没有找到文件:{txt_ca_file.Text}"); 55 | return; 56 | } 57 | if (!File.Exists(txt_pfx_file.Text)) 58 | { 59 | MessageBox.Show($"没有找到文件:{txt_pfx_file.Text}"); 60 | return; 61 | } 62 | var caCert = X509Certificate.CreateFromCertFile(txt_ca_file.Text); 63 | var clientCert = new X509Certificate2(txt_pfx_file.Text); 64 | mqttClientOptions = mqttClientOptions.WithTls(new MqttClientOptionsBuilderTlsParameters() 65 | { 66 | UseTls = true, 67 | SslProtocol = System.Security.Authentication.SslProtocols.Tls12, 68 | CertificateValidationHandler = (o) => 69 | { 70 | return true; 71 | }, 72 | Certificates = new List(){ 73 | caCert, clientCert 74 | } 75 | }); 76 | } 77 | 78 | if (comboBox1.SelectedIndex == 0) 79 | { 80 | mqttClientOptions = mqttClientOptions.WithTcpServer(txt_Address.Text?.Trim(), int.Parse(txt_Port.Text?.Trim())); 81 | } 82 | else if (comboBox1.SelectedIndex == 1) 83 | { 84 | mqttClientOptions = mqttClientOptions.WithWebSocketServer($"{txt_Address.Text?.Trim()}:{txt_Port.Text?.Trim()}/mqtt").WithTls(); 85 | } 86 | else if (comboBox1.SelectedIndex == 2) 87 | { 88 | mqttClientOptions = mqttClientOptions.WithWebSocketServer($"{txt_Address.Text?.Trim()}:{txt_Port.Text?.Trim()}/mqtt"); 89 | } 90 | 91 | var options = new ManagedMqttClientOptionsBuilder() 92 | .WithAutoReconnectDelay(TimeSpan.FromSeconds(5)) 93 | .WithClientOptions(mqttClientOptions.Build()) 94 | .Build(); 95 | 96 | await mqttClient.StartAsync(options); 97 | 98 | mqttClient.UseDisconnectedHandler(e => 99 | { 100 | WriteLine_1("### 服务器断开连接 ###"); 101 | }); 102 | 103 | 104 | mqttClient.UseApplicationMessageReceivedHandler(e => 105 | { 106 | WriteLine_1("### 收到消息 ###"); 107 | WriteLine_1($"+ Topic = {e.ApplicationMessage.Topic}"); 108 | try 109 | { 110 | WriteLine_1($"+ Payload = {Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}"); 111 | } 112 | catch { } 113 | WriteLine_1($"+ QoS = {e.ApplicationMessage.QualityOfServiceLevel}"); 114 | WriteLine_1($"+ Retain = {e.ApplicationMessage.Retain}"); 115 | WriteLine_1(); 116 | }); 117 | 118 | mqttClient.UseConnectedHandler(e => 119 | { 120 | WriteLine_1("### 连接到服务 ###"); 121 | 122 | but_Start.Enabled = false; 123 | but_Subscribe.Enabled = true; 124 | but_Publish.Enabled = true; 125 | but_Stop.Enabled = true; 126 | }); 127 | } 128 | catch (Exception ex) 129 | { 130 | WriteLine_1($"err:{ex.Message}"); 131 | } 132 | } 133 | 134 | private async void but_Stop_Click(object sender, EventArgs e) 135 | { 136 | if (mqttClient != null) 137 | { 138 | if (mqttClient.IsStarted) 139 | await mqttClient.StopAsync(); 140 | mqttClient.Dispose(); 141 | } 142 | but_Subscribe.Enabled = false; 143 | but_Publish.Enabled = false; 144 | but_Stop.Enabled = false; 145 | but_Start.Enabled = true; 146 | } 147 | 148 | private void WriteLine_1(string msg = "") 149 | { 150 | txt_msg.AppendText($"{msg} \r\n"); 151 | } 152 | 153 | private void WriteLine_2(string msg = "") 154 | { 155 | textBox2.AppendText($"{msg}\r\n"); 156 | } 157 | 158 | private async void but_Subscribe_ClickAsync(object sender, EventArgs e) 159 | { 160 | // Subscribe to a topic 161 | var topic = txt_subscribe_topic.Text?.Trim(); 162 | if (string.IsNullOrWhiteSpace(topic)) 163 | { 164 | WriteLine_1("### 请输入Topic ###"); 165 | return; 166 | } 167 | 168 | await mqttClient.SubscribeAsync(new TopicFilterBuilder().WithTopic(topic).Build()); 169 | 170 | WriteLine_1("### 订阅 ###"); 171 | } 172 | 173 | private async void but_Publish_Click(object sender, EventArgs e) 174 | { 175 | var topic = txt_publish_topic.Text?.Trim(); 176 | var payload = txt_publish_payload.Text?.Trim(); 177 | if (string.IsNullOrWhiteSpace(topic)) 178 | { 179 | WriteLine_1("### 请输入Topic ###"); 180 | return; 181 | } 182 | var result = await mqttClient.PublishAsync(topic, payload); 183 | WriteLine_2($"topic:{topic} payload:{payload} {result.ReasonCode}"); 184 | } 185 | 186 | private void checkBox1_CheckedChanged(object sender, EventArgs e) 187 | { 188 | txt_Port.Text = checkBox1.Checked ? "8883" : "1883"; 189 | txt_pfx_file.Enabled = checkBox1.Checked; 190 | txt_ca_file.Enabled = checkBox1.Checked; 191 | } 192 | 193 | private void txt_ca_file_Click(object sender, EventArgs e) 194 | { 195 | OpenFileDialog fileDialog = new OpenFileDialog(); 196 | fileDialog.Multiselect = true; 197 | fileDialog.Title = "请选择文件"; 198 | fileDialog.Filter = "所有文件(*crt*)|*.crt*"; //设置要选择的文件的类型 199 | if (fileDialog.ShowDialog() == DialogResult.OK) 200 | { 201 | txt_ca_file.Text = fileDialog.FileName;//返回文件的完整路径 202 | txt_ca_file.Select(txt_ca_file.Text.Length, 1); 203 | } 204 | } 205 | 206 | private void txt_pfx_file_Click(object sender, EventArgs e) 207 | { 208 | OpenFileDialog fileDialog = new OpenFileDialog(); 209 | fileDialog.Multiselect = true; 210 | fileDialog.Title = "请选择文件"; 211 | fileDialog.Filter = "所有文件(*pfx*)|*.pfx*"; //设置要选择的文件的类型 212 | if (fileDialog.ShowDialog() == DialogResult.OK) 213 | { 214 | txt_pfx_file.Text = fileDialog.FileName;//返回文件的完整路径 215 | txt_pfx_file.Select(txt_pfx_file.Text.Length, 1); 216 | } 217 | } 218 | 219 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) 220 | { 221 | checkBox1.Enabled = comboBox1.SelectedIndex == 0; 222 | if (!checkBox1.Enabled) checkBox1.Checked = false; 223 | } 224 | } 225 | } 226 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/MQTTControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/MitsubishiMCControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 13 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/ModbusAsciiControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/ModbusRtuControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/ModbusTcpControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | -26, 6 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/OmronFinsTcpControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/OtherControl.cs: -------------------------------------------------------------------------------- 1 | using IoTClient.Common.Helpers; 2 | using System; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Sockets; 6 | using System.Windows.Forms; 7 | using Talk.Redis; 8 | 9 | namespace IoTClient.Tool.Controls 10 | { 11 | public partial class OtherControl : UserControl 12 | { 13 | private Socket socketTcp; 14 | private UdpClient udpClient; 15 | public OtherControl() 16 | { 17 | InitializeComponent(); 18 | but_tcpclose.Enabled = false; 19 | but_tcpsend.Enabled = false; 20 | but_udpclose.Enabled = false; 21 | but_udpsend.Enabled = false; 22 | } 23 | 24 | private void but_crc16calculate_Click(object sender, EventArgs e) 25 | { 26 | if (string.IsNullOrWhiteSpace(txt_crcstr.Text) || txt_crcstr.Text.Trim().Replace(" ", "").Length % 2 != 0) 27 | { 28 | MessageBox.Show("请传入有效的参数"); 29 | return; 30 | } 31 | 32 | var byteArry = DataConvert.StringToByteArray(txt_crcstr.Text?.Trim(), false); 33 | var crc16 = CRC16.GetCRC16(byteArry); 34 | AppendText($"CRC16计算结果:{DataConvert.ByteArrayToString(crc16)}"); 35 | } 36 | 37 | private void AppendText(string content) 38 | { 39 | txt_content.Invoke((Action)(() => 40 | { 41 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}]{content}\r\n"); 42 | })); 43 | } 44 | 45 | private void but_crc16validation_Click(object sender, EventArgs e) 46 | { 47 | if (string.IsNullOrWhiteSpace(txt_crcstr.Text) || txt_crcstr.Text.Trim().Replace(" ", "").Length % 2 != 0) 48 | { 49 | MessageBox.Show("请传入有效的参数"); 50 | return; 51 | } 52 | 53 | var byteArry = DataConvert.StringToByteArray(txt_crcstr.Text?.Trim(), false); 54 | var checkCrc16 = CRC16.CheckCRC16(byteArry); 55 | AppendText($"CRC16验证结果:{txt_crcstr.Text} {checkCrc16}"); 56 | } 57 | 58 | private void label2_Click(object sender, EventArgs e) 59 | { 60 | 61 | } 62 | 63 | private void textBox2_TextChanged(object sender, EventArgs e) 64 | { 65 | 66 | } 67 | 68 | private void but_tcpOpen_Click(object sender, EventArgs e) 69 | { 70 | if (string.IsNullOrWhiteSpace(txt_tcpip.Text) || string.IsNullOrWhiteSpace(txt_tcpport.Text)) 71 | { 72 | MessageBox.Show("请传入有效的IP和端口"); 73 | return; 74 | } 75 | 76 | socketTcp?.Close(); 77 | socketTcp = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 78 | try 79 | { 80 | socketTcp.SendTimeout = 1000 * 2; 81 | socketTcp.ReceiveTimeout = 1000 * 2; 82 | socketTcp.Connect(new IPEndPoint(IPAddress.Parse(txt_tcpip.Text?.Trim()), int.Parse(txt_tcpport.Text?.Trim()))); 83 | AppendText("打开连接成功"); 84 | but_tcpopen.Enabled = false; 85 | but_tcpclose.Enabled = true; 86 | but_tcpsend.Enabled = true; 87 | } 88 | catch (Exception ex) 89 | { 90 | } 91 | } 92 | 93 | private void but_tcpClose_Click(object sender, EventArgs e) 94 | { 95 | socketTcp?.Close(); 96 | AppendText("关闭连接成功"); 97 | but_tcpopen.Enabled = true; 98 | } 99 | 100 | private void but_tcpSend_Click(object sender, EventArgs e) 101 | { 102 | try 103 | { 104 | var command = DataConvert.StringToByteArray(txt_tcpmsg.Text, false); 105 | socketTcp.Send(command); 106 | var msg = SocketRead(socketTcp, 4096); 107 | AppendText(msg.ByteArrayToString()); 108 | } 109 | catch (Exception ex) 110 | { 111 | MessageBox.Show(ex.Message); 112 | //重新连接 113 | socketTcp?.Close(); 114 | socketTcp.Connect(new IPEndPoint(IPAddress.Parse(txt_tcpip.Text?.Trim()), int.Parse(txt_tcpport.Text?.Trim()))); 115 | } 116 | } 117 | 118 | 119 | protected byte[] SocketRead(Socket socket, int receiveCount) 120 | { 121 | byte[] receiveBytes = new byte[receiveCount]; 122 | int receiveFinish = 0; 123 | var readLeng = socket.Receive(receiveBytes, receiveFinish, receiveCount, SocketFlags.None); 124 | if (readLeng == 0) 125 | { 126 | socket?.SafeClose(); 127 | throw new Exception("连接已断开"); 128 | } 129 | return receiveBytes.Take(readLeng).ToArray(); 130 | } 131 | 132 | private void but_udpOpen_Click(object sender, EventArgs e) 133 | { 134 | if (string.IsNullOrWhiteSpace(txt_tcpip.Text) || string.IsNullOrWhiteSpace(txt_tcpport.Text)) 135 | { 136 | MessageBox.Show("请传入有效的IP和端口"); 137 | return; 138 | } 139 | 140 | try 141 | { 142 | udpClient = new UdpClient(); 143 | udpClient.Connect(new IPEndPoint(IPAddress.Parse(txt_udpip.Text?.Trim()), int.Parse(txt_udpport.Text?.Trim()))); 144 | AppendText("打开连接成功"); 145 | but_udpopen.Enabled = false; 146 | but_udpclose.Enabled = true; 147 | but_udpsend.Enabled = true; 148 | } 149 | catch (Exception ex) 150 | { 151 | AppendText("打开连接失败" + ex.Message); 152 | } 153 | } 154 | 155 | private void but_udpSend_Click(object sender, EventArgs e) 156 | { 157 | try 158 | { 159 | var command = DataConvert.StringToByteArray(txt_udpmsg.Text, false); 160 | udpClient.Send(command, command.Length); 161 | 162 | var ep = new IPEndPoint(IPAddress.Any, 0); 163 | var msg = udpClient.Receive(ref ep); 164 | AppendText(msg.ByteArrayToString()); 165 | } 166 | catch (Exception ex) 167 | { 168 | MessageBox.Show(ex.Message); 169 | udpClient?.Close(); 170 | udpClient.Connect(new IPEndPoint(IPAddress.Parse(txt_udpip.Text?.Trim()), int.Parse(txt_udpport.Text?.Trim()))); 171 | } 172 | } 173 | 174 | private void but_udpClose_Click(object sender, EventArgs e) 175 | { 176 | udpClient?.Close(); 177 | AppendText("关闭连接成功"); 178 | but_udpopen.Enabled = true; 179 | but_udpclose.Enabled = false; 180 | but_udpsend.Enabled = false; 181 | } 182 | 183 | private void groupBox4_Enter(object sender, EventArgs e) 184 | { 185 | 186 | } 187 | private RedisManager redis; 188 | private void redisOpen_Click(object sender, EventArgs e) 189 | { 190 | var address = txt_address.Text?.Trim().Split(':'); 191 | var ip = address[0]; 192 | var port = address.Length >= 2 ? address[1] : "6379"; 193 | var dbindex = address.Length >= 3 ? address[2] : "1"; 194 | var config = $"{ip}:{port},allowAdmin=true,password=,syncTimeout=15000,defaultdatabase={dbindex}"; 195 | var initialTime = DateTime.Now; 196 | redis = new RedisManager(config, int.Parse(dbindex)); 197 | var timeConsuming = (DateTime.Now - initialTime).TotalMilliseconds; 198 | AppendText($"连接成功\t\t\t\t耗时:{timeConsuming}ms"); 199 | } 200 | 201 | private void redisRead_Click(object sender, EventArgs e) 202 | { 203 | if (redis == null) 204 | { 205 | MessageBox.Show("请先打开连接"); 206 | return; 207 | } 208 | var key = txt_redisKey.Text?.Trim(); 209 | var initialTime = DateTime.Now; 210 | var value = redis.GetString(key); 211 | var timeConsuming = (DateTime.Now - initialTime).TotalMilliseconds; 212 | AppendText($"[读取 {key} 成功]:{value}\t\t耗时:{timeConsuming}ms"); 213 | } 214 | 215 | private void redisSet_Click(object sender, EventArgs e) 216 | { 217 | if (redis == null) 218 | { 219 | MessageBox.Show("请先打开连接"); 220 | return; 221 | } 222 | var key = txt_redisKey.Text?.Trim(); 223 | var value = txt_redisValue.Text?.Trim(); 224 | var initialTime = DateTime.Now; 225 | var isOK = redis.Set(key, value); 226 | var timeConsuming = (DateTime.Now - initialTime).TotalMilliseconds; 227 | if (isOK) 228 | AppendText($"[写入 {key} 成功]:{value}\t\t耗时:{timeConsuming}ms"); 229 | else 230 | AppendText($"[写入 {key} 失败]:{value}\t\t耗时:{timeConsuming}ms"); 231 | } 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/OtherControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/PortsControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using System.IO.Ports; 11 | 12 | namespace IoTClient.Tool.Controls 13 | { 14 | public partial class PortsControl : UserControl 15 | { 16 | /// 17 | /// 串行端口对象 18 | /// 19 | private SerialPort serialPort; 20 | int[] BaudRateArr = new int[] { 9600, 4800, 2400, 1200, 300, 110 }; 21 | int[] DataBitArr = new int[] { 8, 7, 6 }; 22 | float[] StopBitArr = new float[] { 1, 1.5f, 2 }; 23 | string[] Encodings = new string[] { "ASCII", "UTF8", "UTF32", "UTF7", "Unicode" }; 24 | object[] CheckBitArr = new object[] { "None", "Odd", "Even", "Mark", "Space" }; 25 | Encoding encoding = Encoding.ASCII; 26 | public PortsControl() 27 | { 28 | InitializeComponent(); 29 | Size = new Size(880, 450); 30 | 31 | cb_portNameSend.DataSource = SerialPort.GetPortNames(); 32 | cb_baudRate.DataSource = BaudRateArr; 33 | cb_dataBit.DataSource = DataBitArr; 34 | cb_stopBit.DataSource = StopBitArr; 35 | cb_parity.DataSource = CheckBitArr; 36 | cb_encoding.DataSource = Encodings; 37 | 38 | cb_portNameSend.DropDownStyle = ComboBoxStyle.DropDownList; 39 | cb_encoding.DropDownStyle = ComboBoxStyle.DropDownList; 40 | cb_stopBit.DropDownStyle = ComboBoxStyle.DropDownList; 41 | cb_parity.DropDownStyle = ComboBoxStyle.DropDownList; 42 | cb_dataBit.DropDownStyle = ComboBoxStyle.DropDownList; 43 | 44 | SetEncoding(); 45 | serialPort = new SerialPort(); 46 | serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived); 47 | } 48 | 49 | /// 50 | /// 更新串口名 51 | /// 52 | public void UpdatePortNames() 53 | { 54 | cb_portNameSend.DataSource = SerialPort.GetPortNames(); 55 | } 56 | 57 | private void butopen_Click(object sender, EventArgs e) 58 | { 59 | try 60 | { 61 | var parity = cb_parity.SelectedIndex == 0 ? Parity.None : (cb_parity.SelectedIndex == 1 ? Parity.Odd : Parity.Even); 62 | serialPort.PortName = cb_portNameSend.Text.ToString(); 63 | serialPort.BaudRate = int.Parse(cb_baudRate.Text.ToString()); 64 | serialPort.DataBits = int.Parse(cb_dataBit.Text.ToString()); 65 | serialPort.StopBits = cb_stopBit.Text == "1.5" ? StopBits.OnePointFive : (StopBits)int.Parse(cb_stopBit.Text.ToString()); 66 | serialPort.Parity = parity; 67 | serialPort.ReadTimeout = 1000;//1秒 68 | serialPort.Open(); 69 | but_close.Enabled = true; 70 | but_open.Enabled = false; 71 | cb_baudRate.Enabled = false; 72 | cb_dataBit.Enabled = false; 73 | cb_stopBit.Enabled = false; 74 | cb_parity.Enabled = false; 75 | cb_portNameSend.Enabled = false; 76 | UpdatePortNames(); 77 | AppendText("打开连接"); 78 | } 79 | catch (Exception ex) 80 | { 81 | MessageBox.Show(ex.Message); 82 | } 83 | } 84 | 85 | private void butwrite_Click(object sender, EventArgs e) 86 | { 87 | try 88 | { 89 | serialPort.Encoding = encoding; 90 | serialPort.Write(txt_msg.Text); 91 | AppendText($"[发送数据]{txt_msg.Text}"); 92 | } 93 | catch (Exception ex) 94 | { 95 | MessageBox.Show(ex.Message); 96 | } 97 | } 98 | 99 | private void butclose_Click(object sender, EventArgs e) 100 | { 101 | try 102 | { 103 | serialPort.Close(); 104 | but_open.Enabled = true; 105 | cb_baudRate.Enabled = true; 106 | cb_dataBit.Enabled = true; 107 | cb_stopBit.Enabled = true; 108 | cb_parity.Enabled = true; 109 | cb_portNameSend.Enabled = true; 110 | but_close.Enabled = false; 111 | UpdatePortNames(); 112 | AppendText("关闭连接"); 113 | } 114 | catch (Exception ex) 115 | { 116 | MessageBox.Show(ex.Message); 117 | } 118 | } 119 | 120 | /// 121 | /// 接收数据回调用 122 | /// 123 | /// 124 | /// 125 | private void DataReceived(object sender, SerialDataReceivedEventArgs e) 126 | { 127 | byte[] buffer = new byte[serialPort.BytesToRead]; 128 | serialPort.Read(buffer, 0, buffer.Length); 129 | string str = encoding.GetString(buffer); 130 | AppendText($"[接收数据]{str}"); 131 | } 132 | 133 | private void cb_encoding_SelectedValueChanged(object sender, EventArgs e) 134 | { 135 | SetEncoding(); 136 | } 137 | 138 | /// 139 | /// 设置编码 140 | /// 141 | /// 142 | private void SetEncoding() 143 | { 144 | switch (cb_encoding.SelectedValue) 145 | { 146 | case "ASCII": 147 | encoding = Encoding.ASCII; 148 | break; 149 | case "UTF8": 150 | encoding = Encoding.UTF8; 151 | break; 152 | case "UTF32": 153 | encoding = Encoding.UTF32; 154 | break; 155 | case "UTF7": 156 | encoding = Encoding.UTF7; 157 | break; 158 | case "Unicode": 159 | encoding = Encoding.Unicode; 160 | break; 161 | } 162 | } 163 | 164 | private void AppendText(string content) 165 | { 166 | txt_content.Invoke((Action)(() => 167 | { 168 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}]{content}\r\n"); 169 | })); 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/PortsControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/SiemensControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 3, -12 122 | 123 | 124 | 56 125 | 126 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/SiemensS7_300Control.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Controls/TextBoxEx.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Windows.Forms; 3 | 4 | namespace IoTClient.Tool.Controls 5 | { 6 | public class TextBoxEx : TextBox 7 | { 8 | public string PlaceHolder { get; set; } 9 | protected override void WndProc(ref Message m) 10 | { 11 | base.WndProc(ref m); 12 | if (m.Msg == 0xF || m.Msg == 0x133) 13 | { 14 | WmPaint(ref m); 15 | } 16 | } 17 | private void WmPaint(ref Message m) 18 | { 19 | Graphics g = Graphics.FromHwnd(Handle); 20 | if (!string.IsNullOrEmpty(PlaceHolder) && string.IsNullOrEmpty(Text)) 21 | g.DrawString(PlaceHolder, Font, new SolidBrush(Color.LightGray), 2, 2); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IoTClient.Tool/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /IoTClient.Tool/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks 13 | 14 | 15 | 16 | 17 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. 18 | 19 | 20 | 21 | 22 | A list of unmanaged 32 bit assembly names to include, delimited with line breaks. 23 | 24 | 25 | 26 | 27 | A list of unmanaged 64 bit assembly names to include, delimited with line breaks. 28 | 29 | 30 | 31 | 32 | The order of preloaded assemblies, delimited with line breaks. 33 | 34 | 35 | 36 | 37 | 38 | This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. 39 | 40 | 41 | 42 | 43 | Controls if .pdbs for reference assemblies are also embedded. 44 | 45 | 46 | 47 | 48 | Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. 49 | 50 | 51 | 52 | 53 | As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. 54 | 55 | 56 | 57 | 58 | Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. 59 | 60 | 61 | 62 | 63 | Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. 64 | 65 | 66 | 67 | 68 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | 69 | 70 | 71 | 72 | 73 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. 74 | 75 | 76 | 77 | 78 | A list of unmanaged 32 bit assembly names to include, delimited with |. 79 | 80 | 81 | 82 | 83 | A list of unmanaged 64 bit assembly names to include, delimited with |. 84 | 85 | 86 | 87 | 88 | The order of preloaded assemblies, delimited with |. 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 97 | 98 | 99 | 100 | 101 | A comma-separated list of error codes that can be safely ignored in assembly verification. 102 | 103 | 104 | 105 | 106 | 'false' to turn off automatic generation of the XML Schema file. 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /IoTClient.Tool/IoTClient.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaopeiym/IoTClient.Examples/e478e53dec790f0cffcdc1803f87df3bb2438d6c/IoTClient.Tool/IoTClient.ico -------------------------------------------------------------------------------- /IoTClient.Tool/ModBusTcpForm.cs: -------------------------------------------------------------------------------- 1 | using IoTClient.Clients.ModBus; 2 | using IoTServer.Servers.ModBus; 3 | using System; 4 | using System.Windows.Forms; 5 | 6 | namespace IoTClient.Demo 7 | { 8 | public partial class ModBusTcpForm : Form 9 | { 10 | ModBusTcpClient client; 11 | ModBusTcpServer server; 12 | public ModBusTcpForm() 13 | { 14 | InitializeComponent(); 15 | button3.Enabled = false; 16 | button4.Enabled = false; 17 | toolTip1.SetToolTip(button1, "开启本地ModBusTcp服务端仿真模拟服务"); 18 | toolTip1.SetToolTip(but_open, "点击打开连接"); 19 | } 20 | 21 | private void button1_Click(object sender, EventArgs e) 22 | { 23 | if (server == null) 24 | { 25 | server = new ModBusTcpServer("127.0.0.1", 502); 26 | 27 | } 28 | if (button1.Text == "本地模拟服务") 29 | { 30 | server.Start(); 31 | button1.Text = "模拟服务已启动"; 32 | } 33 | else 34 | { 35 | server.Close(); 36 | button1.Text = "本地模拟服务"; 37 | } 38 | } 39 | 40 | private void button2_Click(object sender, EventArgs e) 41 | { 42 | if (but_open.Text == "连接") 43 | { 44 | client?.Close(); 45 | client = new ModBusTcpClient(txt_ip.Text?.Trim(), int.Parse(txt_port.Text?.Trim())); 46 | if (client.Open()) 47 | { 48 | but_open.Text = "已连接"; 49 | button3.Enabled = true; 50 | button4.Enabled = true; 51 | toolTip1.SetToolTip(but_open, "点击关闭连接"); 52 | } 53 | else 54 | { 55 | MessageBox.Show("连接失败"); 56 | } 57 | } 58 | else 59 | { 60 | client?.Close(); 61 | but_open.Text = "连接"; 62 | toolTip1.SetToolTip(but_open, "点击打开连接"); 63 | } 64 | } 65 | 66 | private void button3_Click(object sender, EventArgs e) 67 | { 68 | byte.TryParse(txt_stationNumber.Text?.Trim(), out byte stationNumber); 69 | if (string.IsNullOrWhiteSpace(txt_address.Text)) 70 | { 71 | MessageBox.Show("请输入地址"); 72 | return; 73 | } 74 | try 75 | { 76 | dynamic result = null; 77 | if (rd_bit.Checked) 78 | { 79 | result = client.ReadCoil(txt_address.Text, stationNumber); 80 | } 81 | else if (rd_short.Checked) 82 | { 83 | result = client.ReadInt16(txt_address.Text, stationNumber); 84 | } 85 | else if (rd_ushort.Checked) 86 | { 87 | result = client.ReadUInt16(txt_address.Text, stationNumber); 88 | } 89 | else if (rd_int.Checked) 90 | { 91 | result = client.ReadInt32(txt_address.Text, stationNumber); 92 | } 93 | else if (rd_uint.Checked) 94 | { 95 | result = client.ReadUInt32(txt_address.Text, stationNumber); 96 | } 97 | else if (rd_long.Checked) 98 | { 99 | result = client.ReadInt64(txt_address.Text, stationNumber); 100 | } 101 | else if (rd_ulong.Checked) 102 | { 103 | result = client.ReadUInt64(txt_address.Text, stationNumber); 104 | } 105 | else if (rd_float.Checked) 106 | { 107 | result = client.ReadFloat(txt_address.Text, stationNumber); 108 | } 109 | else if (rd_double.Checked) 110 | { 111 | result = client.ReadDouble(txt_address.Text, stationNumber); 112 | } 113 | 114 | if (result.IsSucceed) 115 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}][读取 {txt_address.Text?.Trim()} 成功]:{result.Value}\r\n"); 116 | else 117 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}][读取 {txt_address.Text?.Trim()} 失败]:{result.Err}\r\n"); 118 | if (checkBox1.Checked) 119 | { 120 | txt_content.AppendText($"[请求报文-读]{result.Requst}\r\n"); 121 | txt_content.AppendText($"[响应报文-读]{result.Response}\r\n"); 122 | } 123 | } 124 | catch (Exception ex) 125 | { 126 | MessageBox.Show(ex.Message); 127 | } 128 | } 129 | 130 | private void button4_Click(object sender, EventArgs e) 131 | { 132 | byte.TryParse(txt_stationNumber.Text?.Trim(), out byte stationNumber); 133 | if (string.IsNullOrWhiteSpace(txt_address.Text)) 134 | { 135 | MessageBox.Show("请输入地址"); 136 | return; 137 | } 138 | if (string.IsNullOrWhiteSpace(txt_value.Text)) 139 | { 140 | MessageBox.Show("请输入值"); 141 | return; 142 | } 143 | try 144 | { 145 | 146 | dynamic result = null; 147 | if (rd_bit.Checked) 148 | { 149 | if (!bool.TryParse(txt_value.Text?.Trim(), out bool coil)) 150 | { 151 | if (txt_value.Text?.Trim() == "0") 152 | coil = false; 153 | else if (txt_value.Text?.Trim() == "1") 154 | coil = true; 155 | else 156 | { 157 | MessageBox.Show("请输入 True 或 False"); 158 | return; 159 | } 160 | } 161 | result = client.Write(txt_address.Text, coil, stationNumber); 162 | } 163 | else if (rd_short.Checked) 164 | { 165 | result = client.Write(txt_address.Text, short.Parse(txt_value.Text?.Trim()), stationNumber); 166 | } 167 | else if (rd_ushort.Checked) 168 | { 169 | result = client.Write(txt_address.Text, ushort.Parse(txt_value.Text?.Trim()), stationNumber); 170 | } 171 | else if (rd_int.Checked) 172 | { 173 | result = client.Write(txt_address.Text, int.Parse(txt_value.Text?.Trim()), stationNumber); 174 | } 175 | else if (rd_uint.Checked) 176 | { 177 | result = client.Write(txt_address.Text, uint.Parse(txt_value.Text?.Trim()), stationNumber); 178 | } 179 | else if (rd_long.Checked) 180 | { 181 | result = client.Write(txt_address.Text, long.Parse(txt_value.Text?.Trim()), stationNumber); 182 | } 183 | else if (rd_ulong.Checked) 184 | { 185 | result = client.Write(txt_address.Text, ulong.Parse(txt_value.Text?.Trim()), stationNumber); 186 | } 187 | else if (rd_float.Checked) 188 | { 189 | result = client.Write(txt_address.Text, float.Parse(txt_value.Text?.Trim()), stationNumber); 190 | } 191 | else if (rd_double.Checked) 192 | { 193 | result = client.Write(txt_address.Text, double.Parse(txt_value.Text?.Trim()), stationNumber); 194 | } 195 | 196 | 197 | if (result.IsSucceed) 198 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}][写入 {txt_address.Text?.Trim()} 成功]:{txt_value.Text?.Trim()} OK\r\n"); 199 | else 200 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}][写入 {txt_address.Text?.Trim()} 失败]:{result.Err}\r\n"); 201 | if (checkBox1.Checked) 202 | { 203 | txt_content.AppendText($"[请求报文-写]{result.Requst}\r\n"); 204 | txt_content.AppendText($"[响应报文-写]{result.Response}\r\n"); 205 | } 206 | } 207 | catch (Exception ex) 208 | { 209 | MessageBox.Show(ex.Message); 210 | } 211 | } 212 | 213 | private void ModBusTcp_Load(object sender, EventArgs e) 214 | { 215 | 216 | } 217 | 218 | private void ModBusTcpForm_FormClosed(object sender, FormClosedEventArgs e) 219 | { 220 | //new IndexForm().Show(); 221 | } 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /IoTClient.Tool/ModBusTcpForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/Model/BacNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO.BACnet; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace IoTClient.Tool 9 | { 10 | public class BacNode 11 | { 12 | public BacnetAddress Address; 13 | public uint DeviceId; 14 | 15 | public List Properties = new List(); 16 | 17 | public BacNode(BacnetAddress adr, uint deviceId) 18 | { 19 | this.Address = adr; 20 | this.DeviceId = deviceId; 21 | } 22 | 23 | public BacnetAddress GetAdd(uint deviceId) 24 | { 25 | if (this.DeviceId == deviceId) 26 | return Address; 27 | else 28 | return null; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /IoTClient.Tool/Model/BacProperty.cs: -------------------------------------------------------------------------------- 1 | using IoTClient.Enums; 2 | using System.IO.BACnet; 3 | 4 | namespace IoTClient.Tool 5 | { 6 | public class BacProperty 7 | { 8 | public BacnetObjectId ObjectId { get; set; } 9 | /// 10 | /// 点名 11 | /// 12 | public string Prop_Object_Name { get; set; } 13 | /// 14 | /// 值 15 | /// 16 | public object Prop_Present_Value { get; set; } 17 | /// 18 | /// 值类型 19 | /// 20 | public DataTypeEnum Prop_DataType { get; set; } 21 | /// 22 | /// 描述 23 | /// 24 | public string Prop_Description { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IoTClient.Tool/Model/BacnetPropertyInfo.cs: -------------------------------------------------------------------------------- 1 | using Talk.NPOI; 2 | 3 | namespace IoTClient.Tool.Model 4 | { 5 | public class BacnetPropertyInfo 6 | { 7 | [Alias("设备地址")] 8 | public string IpAddress { get; set; } 9 | 10 | [Alias("地址")] 11 | public string Address { get; set; } 12 | 13 | [Alias("数据类型")] 14 | public string DataType { get; set; } 15 | 16 | [Alias("值")] 17 | public string Value { get; set; } 18 | 19 | //[Alias("读写")]//暂不导出 20 | public string ReadWrite { get; set; } 21 | 22 | [Alias("点名")] 23 | public string PropName { get; set; } 24 | 25 | [Alias("描述")] 26 | public string Describe { get; set; } 27 | 28 | [Alias("ObjectType")] 29 | public string ObjectType { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /IoTClient.Tool/Model/ResultBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace IoTClient.Tool.Model 5 | { 6 | public class ResultBase 7 | { 8 | // 9 | // 摘要: 10 | // 请求是否成功 11 | public bool IsSuccess { get; } 12 | // 13 | // 摘要: 14 | // 请求结果code 15 | public int Code { get; set; } 16 | // 17 | // 摘要: 18 | // 异常消息 19 | public string ErrorMsg { get; set; } 20 | public List ErrorList { get; set; } 21 | // 22 | // 摘要: 23 | // 请求结果 24 | public T Data { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IoTClient.Tool/Model/VersionCheckInput.cs: -------------------------------------------------------------------------------- 1 | namespace IoTClient.Tool.Model 2 | { 3 | public class VersionCheckInput 4 | { 5 | /// 6 | /// 当前版本 7 | /// 8 | public float CurrentVersion { get; set; } = 1.10f; 9 | 10 | /// 11 | /// 忽略版本 12 | /// 13 | public float? IgnoreVersion { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IoTClient.Tool/Model/VersionCheckOutput.cs: -------------------------------------------------------------------------------- 1 | namespace IoTClient.Tool.Model 2 | { 3 | public class VersionCheckOutput 4 | { 5 | /// 6 | /// 更新Code 7 | /// 8 | public int Code { get; set; } 9 | 10 | /// 11 | /// 文件大小 12 | /// 13 | public int FileSize { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IoTClient.Tool/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace IoTClient.Tool 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 应用程序的主入口点。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new IndexForm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IoTClient.Tool/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("IoTClient.Tool")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("IoTClient.Tool")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("b1c73ee0-6f67-4db0-bbaf-efafd62457cd")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IoTClient.Tool/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace IoTClient.Tool.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IoTClient.Tool.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 重写当前线程的 CurrentUICulture 属性,对 51 | /// 使用此强类型资源类的所有资源查找执行重写。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /IoTClient.Tool/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /IoTClient.Tool/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace IoTClient.Tool.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IoTClient.Tool/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /IoTClient.Tool/SiemensForm.cs: -------------------------------------------------------------------------------- 1 | using IoTClient.Clients.PLC; 2 | using IoTClient.Common.Enums; 3 | using IoTServer.Servers.PLC; 4 | using System; 5 | using System.Windows.Forms; 6 | 7 | namespace IoTClient.Demo 8 | { 9 | public partial class SiemensForm : Form 10 | { 11 | SiemensClient client; 12 | SiemensServer server; 13 | public SiemensForm() 14 | { 15 | InitializeComponent(); 16 | but_read.Enabled = false; 17 | but_write.Enabled = false; 18 | } 19 | 20 | private void SiemensForm_Load(object sender, EventArgs e) 21 | { 22 | //but_server.Enabled = false; 23 | } 24 | 25 | private void but_open_Click(object sender, EventArgs e) 26 | { 27 | client?.Close(); 28 | if (but_open.Text == "连接") 29 | { 30 | client = new SiemensClient(SiemensVersion.S7_200Smart, txt_ip.Text?.Trim(), int.Parse(txt_port.Text.Trim())); 31 | if (!client.Open()) 32 | MessageBox.Show("连接失败"); 33 | else 34 | { 35 | but_open.Text = "已连接"; 36 | but_read.Enabled = true; 37 | but_write.Enabled = true; 38 | } 39 | } 40 | else 41 | { 42 | but_open.Text = "连接"; 43 | client?.Close(); 44 | } 45 | } 46 | 47 | /// 48 | /// 读取 49 | /// 50 | /// 51 | /// 52 | private void button3_Click(object sender, EventArgs e) 53 | { 54 | try 55 | { 56 | if (string.IsNullOrWhiteSpace(txt_address.Text)) 57 | { 58 | MessageBox.Show("请输入地址"); 59 | return; 60 | } 61 | dynamic result = null; 62 | if (rd_bit.Checked) 63 | { 64 | result = client.ReadBoolean(txt_address.Text); 65 | } 66 | else if (rd_short.Checked) 67 | { 68 | result = client.ReadInt16(txt_address.Text); 69 | } 70 | else if (rd_ushort.Checked) 71 | { 72 | result = client.ReadUInt16(txt_address.Text); 73 | } 74 | else if (rd_int.Checked) 75 | { 76 | result = client.ReadInt32(txt_address.Text); 77 | } 78 | else if (rd_uint.Checked) 79 | { 80 | result = client.ReadUInt32(txt_address.Text); 81 | } 82 | else if (rd_long.Checked) 83 | { 84 | result = client.ReadInt64(txt_address.Text); 85 | } 86 | else if (rd_ulong.Checked) 87 | { 88 | result = client.ReadUInt64(txt_address.Text); 89 | } 90 | else if (rd_float.Checked) 91 | { 92 | result = client.ReadFloat(txt_address.Text); 93 | } 94 | else if (rd_double.Checked) 95 | { 96 | result = client.ReadDouble(txt_address.Text); 97 | } 98 | 99 | if (result.IsSucceed) 100 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}][读取 {txt_address.Text?.Trim()} 成功]:{result.Value}\r\n"); 101 | else 102 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}][读取 {txt_address.Text?.Trim()} 失败]:{result.Err}\r\n"); 103 | if (checkBox1.Checked) 104 | { 105 | txt_content.AppendText($"[请求报文-读]{result.Requst}\r\n"); 106 | txt_content.AppendText($"[响应报文-读]{result.Response}\r\n"); 107 | } 108 | } 109 | catch (Exception ex) 110 | { 111 | //client?.Close(); 112 | MessageBox.Show(ex.Message); 113 | } 114 | } 115 | 116 | /// 117 | /// 写入 118 | /// 119 | /// 120 | /// 121 | private void button4_Click(object sender, EventArgs e) 122 | { 123 | if (string.IsNullOrWhiteSpace(txt_address.Text)) 124 | { 125 | MessageBox.Show("请输入地址"); 126 | return; 127 | } 128 | if (string.IsNullOrWhiteSpace(txt_value.Text)) 129 | { 130 | MessageBox.Show("请输入值"); 131 | return; 132 | } 133 | 134 | try 135 | { 136 | dynamic result = null; 137 | if (rd_bit.Checked) 138 | { 139 | if (!bool.TryParse(txt_value.Text?.Trim(), out bool coil)) 140 | { 141 | if (txt_value.Text?.Trim() == "0") 142 | coil = false; 143 | else if (txt_value.Text?.Trim() == "1") 144 | coil = true; 145 | else 146 | { 147 | MessageBox.Show("请输入 True 或 False"); 148 | return; 149 | } 150 | } 151 | result = client.Write(txt_address.Text, coil); 152 | } 153 | else if (rd_short.Checked) 154 | { 155 | result = client.Write(txt_address.Text, short.Parse(txt_value.Text?.Trim())); 156 | } 157 | else if (rd_ushort.Checked) 158 | { 159 | result = client.Write(txt_address.Text, ushort.Parse(txt_value.Text?.Trim())); 160 | } 161 | else if (rd_int.Checked) 162 | { 163 | result = client.Write(txt_address.Text, int.Parse(txt_value.Text?.Trim())); 164 | } 165 | else if (rd_uint.Checked) 166 | { 167 | result = client.Write(txt_address.Text, uint.Parse(txt_value.Text?.Trim())); 168 | } 169 | else if (rd_long.Checked) 170 | { 171 | result = client.Write(txt_address.Text, long.Parse(txt_value.Text?.Trim())); 172 | } 173 | else if (rd_ulong.Checked) 174 | { 175 | result = client.Write(txt_address.Text, ulong.Parse(txt_value.Text?.Trim())); 176 | } 177 | else if (rd_float.Checked) 178 | { 179 | result = client.Write(txt_address.Text, float.Parse(txt_value.Text?.Trim())); 180 | } 181 | else if (rd_double.Checked) 182 | { 183 | result = client.Write(txt_address.Text, double.Parse(txt_value.Text?.Trim())); 184 | } 185 | 186 | 187 | if (result.IsSucceed) 188 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}][写入 {txt_address.Text?.Trim()} 成功]:{txt_value.Text?.Trim()} OK\r\n"); 189 | else 190 | txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}][写入 {txt_address.Text?.Trim()} 失败]:{result.Err}\r\n"); 191 | if (checkBox1.Checked) 192 | { 193 | txt_content.AppendText($"[请求报文-写]{result.Requst}\r\n"); 194 | txt_content.AppendText($"[响应报文-写]{result.Response}\r\n"); 195 | } 196 | } 197 | catch (Exception ex) 198 | { 199 | MessageBox.Show(ex.Message); 200 | } 201 | } 202 | 203 | private void but_server_Click(object sender, EventArgs e) 204 | { 205 | if (but_server.Text == "本地模拟服务") 206 | { 207 | but_server.Text = "已开启服务"; 208 | server = new SiemensServer(txt_ip.Text?.Trim(), int.Parse(txt_port.Text.Trim())); 209 | server.Start(); 210 | } 211 | else 212 | { 213 | but_server.Text = "本地模拟服务"; 214 | server?.Close(); 215 | } 216 | } 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /IoTClient.Tool/SiemensForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | -42, 16 122 | 123 | -------------------------------------------------------------------------------- /IoTClient.Tool/UpdateLog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace IoTClient.Tool 2 | { 3 | partial class UpdateLog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UpdateLog)); 32 | this.textBox1 = new System.Windows.Forms.TextBox(); 33 | this.button1 = new System.Windows.Forms.Button(); 34 | this.linkLabel1 = new System.Windows.Forms.LinkLabel(); 35 | this.linkLabel2 = new System.Windows.Forms.LinkLabel(); 36 | this.SuspendLayout(); 37 | // 38 | // textBox1 39 | // 40 | this.textBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 41 | this.textBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 42 | this.textBox1.Location = new System.Drawing.Point(12, 12); 43 | this.textBox1.Multiline = true; 44 | this.textBox1.Name = "textBox1"; 45 | this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 46 | this.textBox1.Size = new System.Drawing.Size(394, 374); 47 | this.textBox1.TabIndex = 2; 48 | // 49 | // button1 50 | // 51 | this.button1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 52 | this.button1.Location = new System.Drawing.Point(126, 401); 53 | this.button1.Name = "button1"; 54 | this.button1.Size = new System.Drawing.Size(170, 37); 55 | this.button1.TabIndex = 0; 56 | this.button1.Text = "自动更新"; 57 | this.button1.UseVisualStyleBackColor = true; 58 | this.button1.Click += new System.EventHandler(this.button1_Click); 59 | // 60 | // linkLabel1 61 | // 62 | this.linkLabel1.AutoSize = true; 63 | this.linkLabel1.LinkColor = System.Drawing.Color.Gray; 64 | this.linkLabel1.Location = new System.Drawing.Point(352, 420); 65 | this.linkLabel1.Name = "linkLabel1"; 66 | this.linkLabel1.Size = new System.Drawing.Size(53, 12); 67 | this.linkLabel1.TabIndex = 1; 68 | this.linkLabel1.TabStop = true; 69 | this.linkLabel1.Text = "暂不更新"; 70 | this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); 71 | // 72 | // linkLabel2 73 | // 74 | this.linkLabel2.AutoSize = true; 75 | this.linkLabel2.LinkColor = System.Drawing.Color.Gray; 76 | this.linkLabel2.Location = new System.Drawing.Point(12, 420); 77 | this.linkLabel2.Name = "linkLabel2"; 78 | this.linkLabel2.Size = new System.Drawing.Size(53, 12); 79 | this.linkLabel2.TabIndex = 3; 80 | this.linkLabel2.TabStop = true; 81 | this.linkLabel2.Text = "其他版本"; 82 | this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked); 83 | // 84 | // UpdateLog 85 | // 86 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 87 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 88 | this.ClientSize = new System.Drawing.Size(417, 450); 89 | this.Controls.Add(this.linkLabel2); 90 | this.Controls.Add(this.linkLabel1); 91 | this.Controls.Add(this.button1); 92 | this.Controls.Add(this.textBox1); 93 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 94 | this.MaximizeBox = false; 95 | this.MinimizeBox = false; 96 | this.Name = "UpdateLog"; 97 | this.Text = "自动更新"; 98 | this.ResumeLayout(false); 99 | this.PerformLayout(); 100 | 101 | } 102 | 103 | #endregion 104 | 105 | private System.Windows.Forms.TextBox textBox1; 106 | private System.Windows.Forms.Button button1; 107 | private System.Windows.Forms.LinkLabel linkLabel1; 108 | private System.Windows.Forms.LinkLabel linkLabel2; 109 | } 110 | } -------------------------------------------------------------------------------- /IoTClient.Tool/UpdateLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Windows.Forms; 5 | 6 | namespace IoTClient.Tool 7 | { 8 | public partial class UpdateLog : Form 9 | { 10 | public UpdateLog(bool hasNew) 11 | { 12 | InitializeComponent(); 13 | StartPosition = FormStartPosition.CenterScreen; 14 | FormBorderStyle = FormBorderStyle.FixedSingle; 15 | var logs = new List(); 16 | logs.Add("日志记录"); 17 | logs.Add("\r\n版本:[0.4.0]"); 18 | logs.Add($"时间:2020-09-11"); 19 | logs.Add("内容"); 20 | logs.Add("1.西门子PLC批量读写,大幅提高读写性能"); 21 | logs.Add("2.手动检查更新"); 22 | logs.Add("3.显示历史更新日志"); 23 | 24 | logs.Add("\r\n版本:[0.4.1]"); 25 | logs.Add($"时间:2021-01-19"); 26 | logs.Add("内容"); 27 | logs.Add("1.西门子PLC批量写,服务端模拟的实现"); 28 | logs.Add("2.西门子PLC批量写Byte类型bug修复"); 29 | logs.Add("3.ModbusTcp批量读取"); 30 | logs.Add("4.ModbusTcp线程安全读取"); 31 | 32 | logs.Add("\r\n版本:[0.4.2]"); 33 | logs.Add($"时间:2021-03-10"); 34 | logs.Add("内容"); 35 | logs.Add("1.修复相关bug"); 36 | 37 | logs.Add("\r\n版本:[0.4.4]"); 38 | logs.Add($"时间:2021-03-21"); 39 | logs.Add("内容"); 40 | logs.Add("1.Modbus 大小端设置"); 41 | 42 | logs.Add("\r\n版本:[0.4.5]"); 43 | logs.Add($"时间:2021-04-14"); 44 | logs.Add("内容"); 45 | logs.Add("1.三菱MC_Qna-3E帧客户端实现"); 46 | logs.Add("2.三菱MC_A-1E帧客户端实现"); 47 | logs.Add("3.三菱MC_Qna-3E帧模拟服务端实现"); 48 | logs.Add("4.三菱MC_A-1E帧模拟服务端实现"); 49 | 50 | logs.Add("\r\n版本:[0.4.6]"); 51 | logs.Add($"时间:2021-04-25"); 52 | logs.Add("内容"); 53 | logs.Add("1.欧姆龙客户端实现"); 54 | logs.Add("2.欧姆龙模拟服务端实现"); 55 | 56 | logs.Add("\r\n版本:[0.4.7]"); 57 | logs.Add($"时间:2021-05-04"); 58 | logs.Add("内容"); 59 | logs.Add("1.罗克韦尔AB Plc客户端实现"); 60 | logs.Add("2.罗克韦尔AB Plc模拟服务端实现"); 61 | logs.Add("3.界面参数保存"); 62 | 63 | logs.Add("\r\n版本:[0.4.8]"); 64 | logs.Add($"时间:2021-05-06"); 65 | logs.Add("内容"); 66 | logs.Add("1.折线图显示"); 67 | 68 | logs.Add("\r\n版本:[0.4.9]"); 69 | logs.Add($"时间:2021-05-23"); 70 | logs.Add("内容"); 71 | logs.Add("1.西门子插槽和机架号的配置"); 72 | 73 | logs.Add("\r\n版本:[0.5.0]"); 74 | logs.Add($"时间:2021-07-07"); 75 | logs.Add("内容"); 76 | logs.Add("1.西门子读写结果验证,友好提示plc中不存在点位"); 77 | logs.Add("2.AllenBradley、OmronFinsTcp发送报文"); 78 | logs.Add("3.ModbusRtu低波特率读写异常修复"); 79 | logs.Add("4.OmronFins读写"); 80 | logs.Add("5.IoTClient可域名连接"); 81 | 82 | logs.Add("\r\n版本:[1.0.3]"); 83 | logs.Add($"时间:2022-07-08"); 84 | logs.Add("内容"); 85 | logs.Add("1.Socket连接操作设置"); 86 | logs.Add("2.BACnet切换网卡扫描"); 87 | logs.Add("3.BACnet导出Excel扫描结果"); 88 | 89 | logs.Add("\r\n版本:[1.0.8]"); 90 | logs.Add($"时间:2022-07-22"); 91 | logs.Add("内容"); 92 | logs.Add("1.BACnet释放优先级的值"); 93 | 94 | logs.Add("\r\n版本:[1.1.0]"); 95 | logs.Add($"时间:2022-10-14"); 96 | logs.Add("内容"); 97 | logs.Add("1.Modbus按位读取如:1.11"); 98 | logs.Add("2.Modbus异常码提示"); 99 | 100 | textBox1.Text = string.Join("\r\n", logs); 101 | if (hasNew) 102 | { 103 | button1.Enabled = true; 104 | button1.Text = "自动更新"; 105 | } 106 | else 107 | { 108 | button1.Enabled = false; 109 | button1.Text = "已是最新版本"; 110 | } 111 | } 112 | 113 | private void button1_Click(object sender, EventArgs e) 114 | { 115 | DialogResult = DialogResult.OK; 116 | } 117 | 118 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 119 | { 120 | Close(); 121 | } 122 | 123 | private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 124 | { 125 | try 126 | { 127 | Process.Start("https://github.com/zhaopeiym/IoTClient.Examples/releases"); 128 | } 129 | catch (Exception) { } 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /IoTClient.Tool/UpdateLog.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | 123 | AAABAAEAFRgAAAEAIABoCAAAFgAAACgAAAAVAAAAMAAAAAEAIAAAAAAA4AcAAGDqAABg6gAAAAAAAAAA 124 | AAA7RUIAPEJFAD1CRQA9QUYAPkBJAEE5VAAThgAAOkc9ATxDQwI8QkQCPEJEAT1DRgA8Q0MAPENDADxD 125 | QwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6REIBPEJEGTo/QzU4PkI5OT9COzk/Qjw5P0I9O0FDNTxD 126 | QyA8Q0MdPENDGzxDQxg8Q0MTPENDBjxDQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACOh30AUlRUdIN+ 127 | de2NhnzqjIV76oyFe+qOh3zsa2llyzc+QTA8Q0MWPENDFjxDQxM8Q0MOPENDBDxDQwAAAAAAAAAAAAAA 128 | AAAAAAAAAAAAAAAAAABVV1YAS05PJ2JiX7CLh3z/qqKS/6GajP9ycGvoWFpYZAAAAALBvrcA3dnPAH+B 129 | fwBLUFIAOkBDAD1DRQA8QUUAAAAAAAAAAAAAAAAAAAAAAAAAAAA5P0MAAQ0cCoF+dbPbzrX/7N3B/+zd 130 | wf+spJTyR0tNcWFkZWVxc3KHdHZ1imttbXNPVFZCJCw0Dk1QUQATHSgAPEFFAAAAAAAAAAAAAAAAAAAA 131 | AAA9QkYAMjg+Jqqklufu38P/6du//8K4o/+hnpT/tLKs/NjUy//n4tj/3NjO/66tp/93eHX1V1lYu0NH 132 | SjxtbWkAMzk9AAAAAAAAAAAAAAAAAAAAAAA9QkUAJSwzGp+ck9ju483/squc/7Syqv/u6d7//vjr//nz 133 | 6P/Lx7//pKCW/7evnf/Sxq//0cWt/4yJf9AwNz0bP0NHAAAAAAAAAAAAAAAAAAAAAAA8QEUAAAAAAGZo 134 | Z3GXlY72vLqz//nz6P/99ur/7une/62ro/+vqJj/39G3/+3ewf/t3cH/8OHE/7qzpPRDR0s5REhMAAAA 135 | AAAAAAAAAAAAAAAAAAA8QUUAOT5DACkvNSKTlJLf9vDk//z26v/n4tj/k5KN/7+1of/s3cH/7N3B/+vc 136 | wP/r3MD/8ePK/6+qoOc1O0AoQERIAAAAAAAAAAAAAAAAAAAAAAA4REcAgYWHAGFlaWjW1ND+/vjr/+nk 137 | 2v+npqH/raul/7Kqmv/q27//69zA/+vcwP/t3sP/6uDM/4aFgLMAAAMIO0BEAAAAAAAAAAAAAAAAAAAA 138 | AAA8QUUAAAAABIiLjq3z8e3/9O7j/6Cel/+VlI3/6OTZ/7i1rf+7sp//7N3B/+vdwf/06NH/wLuv91JV 139 | V1NkZmUAPEFFAAAAAAAAAAAAAAAAAAAAAAA8QUUADhUaEqGjpdD+/Pj/u7ix/7mwnf/Nwqv/o6CW/9nV 140 | zP+tqqL/x72o//Toz//h2cj/e3t3pQAFEQk0Oj8APEFFAAAAAAAAAAAAAAAAAAAAAAA8QUUAICYqGqyu 141 | sNvm5ub/o5+U/+fYvf/t3sL/1smx/6OflP/Fwrv/p6Wd/9PMvf+Zlo/QNjtAJkZKTQA9QkYAAAAAAAAA 142 | AAAAAAAAAAAAAAAAAAA8QUUAFhwhFaaoqtW2t7b/yb6o/+3ewf/r3MD/7N3B/+DTuv+sqJ7/srCq/4aG 143 | g/Y/Q0db////ACAnLQA8QUUAAAAAAAAAAAAAAAAAAAAAAAAAAAA8QUUAAAAAB3+DhrefnZb/5da7/+vc 144 | wP/s3sL/8OPK//jt2P/j2sr/gIB86Xx9fO6Li4nZbW9vewADDASZghwA2a4AANmuAADZrgAA2a4AANmu 145 | AAA8QUUAY2dqAEVKT3SWk4z/9ejS//Pn0f/37Nf/9+3a/9fQwf+NjIbEPUFEPnZ5eq7k4dv/l5iX1BEZ 146 | IhP3wwAG2a4AA9muAAjZrgAC2a4AB9muAAQ8QUUAOT5CACQrMR59fXnO4trK/+3k0v/Z0cL/qqad5Wtt 147 | a4coLzUZZGdpAFhdYEWDhoizZmptaAAAAADZrgBR2a4AHNmuAFTZrgAO2a4AStmuACMAAAAAPEFFAFpd 148 | XQBJTU80d3d0mYGBfKdmaGd3Oj9DLQAAAAE9QkYAAAAAAJqcngAAAAAFj2EAA9uvACvZrgBr2a4AGdmu 149 | AGvZrgAI2a4AZNmuAB0AAAAAPEFFAAAAAABTVlcAAAAAAAAAAAKgnZUARElMADQ6PwA8QUUAPEFFALaW 150 | DwD/ygAB2a4ASNmuAGbZrgAb2a4AUNmuAEXZrgAT2a4AaNmuAAYAAAAAAAAAADxBRQA8QUUAPEFFADxB 151 | RQA8QUUAPEFFAAUFBQAAAAAAAAAAANmuAADZrgAA2a4AEtmuAB7ZrgBV2a4AXtmuAATZrgBV2a4APdmu 152 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANmuAADZrgAC2a4ASNmu 153 | AGbZrgA72a4ABNmuAEDZrgBi2a4ABdmuAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 154 | AAAAAAAAAAAAANmuAADZrgAA2a4ABtmuAAjZrgAc2a4AW9muAGDZrgAM2a4AANmuAAAAAAAAAAAAAAAA 155 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANmuAADZrgAC2a4ARdmuAGrZrgBk2a4ANdmu 156 | AAPZrgAA2a4AANuqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANmu 157 | AADZrgAA2a4AENmuABDZrgAB2a4AANmuAADZrgAAAAAAAAAAAAAAAfgAAAH4AAAB+AAAAPgAAAB4AAAA 158 | eAAAAHgAAAB4AAAAeAAAAHgAAAB4AAAAeAAAAPgAAAD4AAAAAAAAAAAAAAAAAIAAAACAAAAAwGAAAP/g 159 | AAD/4AAA/+AAAP/gGAA= 160 | 161 | 162 | -------------------------------------------------------------------------------- /IoTClient.Tool/UpgradeForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace IoTClient.Tool 2 | { 3 | partial class UpgradeForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UpgradeForm)); 32 | this.progressBar1 = new System.Windows.Forms.ProgressBar(); 33 | this.SuspendLayout(); 34 | // 35 | // progressBar1 36 | // 37 | this.progressBar1.Location = new System.Drawing.Point(12, 15); 38 | this.progressBar1.Name = "progressBar1"; 39 | this.progressBar1.Size = new System.Drawing.Size(571, 23); 40 | this.progressBar1.TabIndex = 0; 41 | // 42 | // UpgradeForm 43 | // 44 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 45 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 46 | this.ClientSize = new System.Drawing.Size(595, 52); 47 | this.Controls.Add(this.progressBar1); 48 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 49 | this.MaximizeBox = false; 50 | this.Name = "UpgradeForm"; 51 | this.Text = "升级中..."; 52 | this.ResumeLayout(false); 53 | 54 | } 55 | 56 | #endregion 57 | 58 | private System.Windows.Forms.ProgressBar progressBar1; 59 | } 60 | } -------------------------------------------------------------------------------- /IoTClient.Tool/UpgradeForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Net.Http; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace IoTClient.Tool 8 | { 9 | public partial class UpgradeForm : Form 10 | { 11 | public UpgradeForm() 12 | { 13 | InitializeComponent(); 14 | TopMost = true; 15 | StartPosition = FormStartPosition.CenterScreen; 16 | FormBorderStyle = FormBorderStyle.FixedSingle; 17 | CheckForIllegalCrossThreadCalls = false; 18 | Task.Run(async () => 19 | { 20 | await DownloadAsync(); 21 | DialogResult = DialogResult.OK; 22 | Close(); 23 | }); 24 | } 25 | 26 | public async Task DownloadAsync() 27 | { 28 | long downloadSize = 0;//已经下载大小 29 | long downloadSpeed = 0;//下载速度 30 | using (HttpClient http = new HttpClient()) 31 | { 32 | var httpResponseMessage = await http.GetAsync("https://download.haojima.net/api/IoTClient/Download", HttpCompletionOption.ResponseHeadersRead);//发送请求 33 | var contentLength = httpResponseMessage.Content.Headers.ContentLength; //文件大小 34 | if (contentLength == null) 35 | { 36 | MessageBox.Show("服务器忙,请稍后再试。"); 37 | return; 38 | } 39 | using (var stream = await httpResponseMessage.Content.ReadAsStreamAsync()) 40 | { 41 | var readLength = 102400;//100K 42 | byte[] bytes = new byte[readLength]; 43 | int writeLength; 44 | var beginSecond = DateTime.Now.Second;//当前时间秒 45 | //使用追加方式打开一个文件流 46 | var filePath = Application.StartupPath + @"\temp." + Path.GetFileName(Application.ExecutablePath); 47 | using (FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.Write)) 48 | { 49 | while ((writeLength = stream.Read(bytes, 0, readLength)) > 0) 50 | { 51 | fs.Write(bytes, 0, writeLength); 52 | downloadSize += writeLength; 53 | downloadSpeed += writeLength; 54 | progressBar1.Invoke((Action)(() => 55 | { 56 | var endSecond = DateTime.Now.Second; 57 | if (beginSecond != endSecond)//计算速度 58 | { 59 | downloadSpeed = downloadSpeed / (endSecond - beginSecond); 60 | Text = "下载速度" + downloadSpeed / 1024 + "KB/S"; 61 | beginSecond = DateTime.Now.Second; 62 | downloadSpeed = 0;//清空 63 | } 64 | progressBar1.Value = Math.Max((int)(downloadSize * 100 / contentLength), 1); 65 | })); 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /IoTClient.Tool/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaopeiym/IoTClient.Examples/e478e53dec790f0cffcdc1803f87df3bb2438d6c/IoTClient.Tool/favicon.ico -------------------------------------------------------------------------------- /IoTClient.Tool/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 农码一生 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # IoTClient Tool 3 | ![image](https://img.shields.io/github/license/alienwow/SnowLeopard.svg) 4 | - IoTClient Tool是[IoTClient](https://github.com/zhaopeiym/IoTClient)库的桌面程序工具。 5 | - IoTClient Tool主要作用:1、可用来测试Plc和相关协议的通信 2、可作为[IoTClient](https://github.com/zhaopeiym/IoTClient)库使用例子。 6 | - 开发工具:Visual Studio 2019 7 | - QQ交流群:[700324594](https://jq.qq.com/?_wv=1027&k=tIRmmGbt) 8 | - IoTClient Tool [下载1](https://github.com/zhaopeiym/IoTClient.Examples/releases/download/1.0.3/IoTClient.exe) [下载2](https://download.haojima.net/api/IoTClient/Download) 9 | 10 | # IoTClient Tool效果图 11 | ![image](https://user-images.githubusercontent.com/5820324/115138587-b7bebc80-a05f-11eb-9f7c-720a88bdca6e.png) 12 | 13 | ![image](https://user-images.githubusercontent.com/5820324/115138592-bbeada00-a05f-11eb-9fc4-4b15a426cdb3.png) 14 | 15 | ![image](https://user-images.githubusercontent.com/5820324/115138594-bd1c0700-a05f-11eb-8d4b-34a567669e3d.png) 16 | 17 | ![image](https://user-images.githubusercontent.com/5820324/115138596-bee5ca80-a05f-11eb-9878-9b05a4cfbc0b.png) 18 | 19 | ![image](https://user-images.githubusercontent.com/5820324/115138597-c016f780-a05f-11eb-9d09-298a54f55266.png) 20 | 21 | ![image](https://user-images.githubusercontent.com/5820324/115138600-c2795180-a05f-11eb-92b0-1a1d278c20c8.png) 22 | 23 | ![image](https://user-images.githubusercontent.com/5820324/115138602-c3aa7e80-a05f-11eb-9cd7-be876735a26f.png) 24 | 25 | ![image](https://user-images.githubusercontent.com/5820324/115138603-c5744200-a05f-11eb-9cdb-a222aa9b7b25.png) 26 | 27 | ![image](https://user-images.githubusercontent.com/5820324/115138606-c73e0580-a05f-11eb-9ca1-5ece1bae8e71.png) 28 | 29 | ![image](https://user-images.githubusercontent.com/5820324/115138607-c86f3280-a05f-11eb-83f1-d1706331406a.png) 30 | --------------------------------------------------------------------------------