{"id":15037390,"url":"https://github.com/dathlin/hslcommunication","last_synced_at":"2025-10-21T06:53:07.277Z","repository":{"id":37334335,"uuid":"203891962","full_name":"dathlin/HslCommunication","owner":"dathlin","description":"A very popular industrial Internet of Things communication plug-in. Using this dll can be very convenient, stable, and fast to obtain data from PLC equipment of multiple brands, and also supports redis, mqtt, websocket, etc., which can let your data on the network Free transmission, reducing enterprise development costs.","archived":false,"fork":false,"pushed_at":"2025-05-09T00:59:20.000Z","size":44971,"stargazers_count":1759,"open_issues_count":44,"forks_count":654,"subscribers_count":65,"default_branch":"master","last_synced_at":"2025-05-09T01:37:11.251Z","etag":null,"topics":["allen-bradley","hslcommunication","melsec","modbus","omron","panasonic","redis","siemens"],"latest_commit_sha":null,"homepage":"http://www.hslcommunication.cn","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dathlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-23T00:07:08.000Z","updated_at":"2025-05-09T01:09:11.000Z","dependencies_parsed_at":"2023-01-31T08:01:11.444Z","dependency_job_id":"f936d1a2-9eb6-464c-9a86-9b691470df5b","html_url":"https://github.com/dathlin/HslCommunication","commit_stats":{"total_commits":96,"total_committers":2,"mean_commits":48.0,"dds":0.01041666666666663,"last_synced_commit":"3d98e595362876f600c33ac965ebc56143aec62c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dathlin%2FHslCommunication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dathlin%2FHslCommunication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dathlin%2FHslCommunication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dathlin%2FHslCommunication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dathlin","download_url":"https://codeload.github.com/dathlin/HslCommunication/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254042341,"owners_count":22004901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["allen-bradley","hslcommunication","melsec","modbus","omron","panasonic","redis","siemens"],"created_at":"2024-09-24T20:34:30.643Z","updated_at":"2025-10-21T06:53:07.251Z","avatar_url":"https://github.com/dathlin.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cpre\u003e\n             ///\\      ///\\             /////////\\              ///\\\n            //\\\\/      //\\/           //\\\\\\\\\\\\\\\\//\\            //\\\\/\n           //\\/       //\\/          //\\\\/       \\\\/           //\\/\n          //\\/       //\\/           \\//\\                     //\\/\n         /////////////\\/             \\//////\\               //\\/\n        //\\\\\\\\\\\\\\\\\\//\\/               \\\\\\\\\\//\\             //\\/\n       //\\/       //\\/                     \\//\\           //\\/\n      //\\/       //\\/           ///\\      //\\\\/          //\\/       //\\\n     ///\\      ///\\/            \\/////////\\\\/           /////////////\\/\n     \\\\\\/      \\\\\\/              \\\\\\\\\\\\\\\\\\/             \\\\\\\\\\\\\\\\\\\\\\\\\\/             Present by Richard.Hu\n\u003c/pre\u003e\n\n# HslCommunication\n\n![Build status](https://img.shields.io/badge/Build-Success-green.svg) [![NuGet Status](https://img.shields.io/nuget/v/HslCommunication.svg)](https://www.nuget.org/packages/HslCommunication/) ![NuGet Download](https://img.shields.io/nuget/dt/HslCommunication.svg) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/HslCommunication/community) [![NetFramework](https://img.shields.io/badge/Language-C%23%207.0-orange.svg)](https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/) [![Visual Studio](https://img.shields.io/badge/Visual%20Studio-2019-red.svg)](https://www.visualstudio.com/zh-hans/) ![copyright status](https://img.shields.io/badge/CopyRight-Richard.Hu-brightgreen.svg) \n\n[HslCommunication.jar](https://github.com/dathlin/HslCommunicationJavaDemo)\n\n![Build status](https://img.shields.io/badge/Build-Success-green.svg) ![NetFramework](https://img.shields.io/badge/Language-java-orange.svg) ![version](https://img.shields.io/maven-central/v/com.github.dathlin/HslCommunication) ![JDK status](https://img.shields.io/badge/JDK-1.8.0-green.svg) ![IDE status](https://img.shields.io/badge/Intellij%20Idea-2018.4-red.svg) ![copyright status](https://img.shields.io/badge/CopyRight-Richard.Hu-brightgreen.svg) \n\n[HslCommunication.py](https://github.com/dathlin/HslCommunicationPython)\n\n![Build status](https://img.shields.io/badge/Build-Success-green.svg) ![NetFramework](https://img.shields.io/badge/python-3.6-orange.svg) ![version](https://img.shields.io/pypi/v/HslCommunication) ![download](https://img.shields.io/pypi/dm/HslCommunication) ![IDE status](https://img.shields.io/badge/Visual%20Studio-Code-red.svg) ![copyright status](https://img.shields.io/badge/CopyRight-Richard.Hu-brightgreen.svg) \n\n## CopyRight\n(C) 2017 - 2023 Richard.Hu, All Rights Reserved\n\n## Authorization(授权)\n具体可以参照 http://www.hsltechnology.cn/Home/Licence?area=HslCommunication\n\n试用授权： 加入 **技术支持VIP群** 即可以获得激活码，支持长时间测试使用。企业用户可以联系微信:13516702732 申请试用的证书\n```\n        /// \u003csummary\u003e\n        /// 应用程序的主入口点。\n        /// \u003c/summary\u003e\n        [STAThread]\n        static void Main( )\n        {\n            // 授权示例   调用一次即可  call only once\n            if(!HslCommunication.Authorization.SetAuthorizationCode( \"你的激活码\" ))\n            {\n                MessageBox.Show( \"授权失败！当前程序只能使用8小时！\" );\n                return;\n            }\n\n\n            Application.EnableVisualStyles( );\n            Application.SetCompatibleTextRenderingDefault( false );\n            Application.Run( new Form1( ) );\n        }\n```\n\n商用授权（赠送源代码）: \n   1. 公对公签订合同。\n   2. 公对公打款，开具增值税发票。\n   3. 获取专用的软件，账户，来下载最新的源代码，激活码\n   4. 企业专业培训额外付费，1000元人民币1小时，培训控件使用，控件开发。\n\n## Official Website\nWebside: [http://www.hsltechnology.cn/](http://www.hsltechnology.cn/)\n\nAPI: [http://api.hslcommunication.cn/](http://api.hslcommunication.cn/)\n\nGitter[talk with me]: [https://gitter.im/HslCommunication/community](https://gitter.im/HslCommunication/community)\n\n## What is HSL\nThis is an industrial IoT based, computer communications architecture implementation, integrated with most of the basic functional implementation of industrial software development, \nsuch as Mitsubishi PLC Communications, Siemens PLC Communications, OMRON PLC Communications, Modbus Communications,\nAll of these communications have been implemented in multiple languages, and of course, the feature integration of the main. NET Library is even more powerful, \nin addition to the implementation of cross-program, cross-language, cross-platform communication, so that you are no longer obsessed with the use of Windows or Linux system, \nthe realization of log function, flow number generation function, mail sending function, Fourier transform function, and so on, \nwill integrate more common features of industrial environment in the future.\n\nIn order not to let the industry 4.0 stay on the slogan, the high-rise flat up, and the cornerstone is HSL.\n\n## What can HSL do\nHSL can connect the equipment of the industrial production site to the free transmission of data at the bottom, whether active or passive, \nwhatever your acquisition system (usually the acquisition system is a Windows computer, or an embedded system, or a Linux-based box),\ncan achieve the random transmission of data, convenient and fast to achieve a strong, real-time, high-response robust system, whether you are building a C/S system, \nor B/S system, or C-B-S-A (Integrated desktop client, browser, Android) hybrid system, is a fast and low-cost implementation,\n\nAs long as you have the primary data of the industrial field, that is, can build a powerful real-time monitoring function of the software,\nproduction reports and automated scheduling software, a variety of process parameters history tracking software, data based on the experience of machine learning software, \nas well as full-featured MES system and so on. \n\n**By the way**, the traditional industrial model is the procurement of off-the-shelf industrial software, \nincluding the host computer software and MES system, while ignoring their own system.\nFor some industry-standard functional software, such as ERP systems, financial software, these can be purchased directly,\nHowever, for the host computer and MES system, the actual needs of each enterprise are very different, it is difficult to have a common scene, \nand the current situation is to spend a lot of money to do small things, so here, give a future-oriented model to achieve: for the production enterprise, \nBased on HSL to develop enterprise-class MES system implementation, as the core Warehouse center of data, and business logic processing Center, \nfor equipment suppliers, based on HSL to develop the host computer software system, fast and convenient distribution of data to the customer's MES system, work together.\n\n## Install From NuGet\nDescription: NuGet for stable version, Support Online upgrade, the use of components is best downloaded from NuGet, \nthe project published here is likely to have not yet compiled the beta version, NuGet installation is as follows:\n```\nInstall-Package HslCommunication\n```\n\n## HslCommunication.dll Summary \nWhen I started working on this project, I had an idea of how to easily and quickly read and write PLC data. Our code logic should be very simple, \nand it only takes one or two lines of code to implement this feature. Like this\n```\n// Pseudo code\nPLC plc = new PLC(\"192.168.0.11\", 6000);\n\nshort value = plc.ReadInt16(\"D100\");\n```\nBut after a long period of development and attempt, found that the return of PLC is likely to be abnormal, this anomaly may come from the network failure, \nmay also come from you entered the wrong address, or the PLC itself is not allowed to operate, so in this project added a class **Operateresult**, \nSo the final code becomes what it looks like (with Siemens PLC as an example)\n```\nSiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, \" 192.168.1.110\" );\nOperateResult\u003cshort\u003e read = siemens.ReadInt16(\"M100\");\n\nif(read.IsSuccess)\n{\n\t// you get the right value\n\tshort value = read.Content;\n}\nelse\n{\n\t// failed , but you still can know the failed detail\n\tConsolo.WriteLine(read.Message);\n}\n```\nOf course, you can also write very concise, because the judgment of success is ignored, so the following operation is risky.\n```\nSiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, \" 192.168.1.110\" );\nshort value = siemens.ReadInt16(\"M100\").Content;   // Look at this code, isn't it very succinct.\n```\nWhen use .Net4.5 or higher plateform. we can use like this\n```\nSiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, \" 192.168.1.110\" );\nshort value = (await siemens.ReadInt16Async(\"M100\")).Content;   // Look at this code, isn't it very succinct.\n```\n\nThe above operation we have read the data, but is based on a short connection, \nwhen the reading of the data finished, automatically shut down the network, \nif you want to open a long connection, follow the following actions.\n\n```\nSiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, \" 192.168.1.110\" );\nsiemens.SetPersistentConnection( );\nOperateResult\u003cshort\u003e read = siemens.ReadInt16(\"M100\");\n\nif(read.IsSuccess)\n{\n\t// you get the right value\n\tshort value = read.Content;\n}\nelse\n{\n\t// failed , but you still can know the failed detail\n\tConsolo.WriteLine(read.Message);\n}\n\n// when you don't want read data, you should call close method\nsiemens.ConnectClose( );\n\n```\nWhen use .Net4.5 or higher plateform. we can use like this\n```\nSiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, \" 192.168.1.110\" );\nsiemens.SetPersistentConnection( );\nOperateResult\u003cshort\u003e read = await siemens.ReadInt16Async(\"M100\");\n\nif(read.IsSuccess)\n{\n\t// you get the right value\n\tshort value = read.Content;\n}\nelse\n{\n\t// failed , but you still can know the failed detail\n\tConsolo.WriteLine(read.Message);\n}\n\n// when you don't want read data, you should call close method\nsiemens.ConnectClose( );\n\n```\n\nSo we can see that all the other modes of communication are similar to this, including Mitsubishi PLC, Siemens PLC,AB PLC, OMRON PLC, Keane plc, Panasonic Plc,\nredis Communications, EFT Robots, Kuka robots and so on, including its own support for the HSL protocol.\n\nThe goal is to reduce the cost of learning for developers, and usually you have to learn how to use several different libraries and learn the basics of PLC. Now, \nall you need to know is how the basic PLC address is represented, and you can read and write PLC data.\n\n\nCalled from Visual C++ project\n\ncppProject -\u003e Properties -\u003e Configuration Properties -\u003e General -\u003e CLR Support\n\nAdd HslCommunication.dll(net35) reference\n```\n#include \"pch.h\"\n#include \u003ciostream\u003e\nusing namespace HslCommunication;\nusing namespace ModBus;\n\nint main()\n{\n    std::cout \u003c\u003c \"Hello World!\\n\";\n\n\n\t// This is the demo , called C# ModbusTcpNet\n\tSystem::String ^ipAddress = gcnew System::String(\"127.0.0.1\");\n\tModbusTcpNet ^modbus = gcnew ModbusTcpNet(ipAddress, 502, 1);\n\n\tSystem::String ^dataAddress = gcnew System::String(\"100\");\n\tOperateResult\u003cshort\u003e ^readValue = modbus-\u003eReadInt16(dataAddress);\n\tif (readValue-\u003eIsSuccess) {\n\t\tshort value = readValue-\u003eContent;\n\t\tprintf(\"Read Value：%d \\n\", value);\n\t}\n\telse\n\t{\n\t\tprintf(\"Read Failed\");\n\t}\n}\n```\n\nIf you want to communication in your mobile phone application, you also can use C# code by xamarin, you can download HslAppDemo to test\n[HslAppDemo.apk](https://github.com/dathlin/HslCommunication/raw/master/Download/com.companyname.HslAppDemo-Signed.apk)\n\n\nAnother feature of this project is support for cross-language communication support. You can build a C # background server that supports Windows desktop application \nand Web background, and Android phone-side, Python programs, Java programs to communicate. server side code:\n```\nclass Program\n{\n    static void Main(string[] args)\n    {\n\t\tNetSimplifyServer simplifyServer;\n\t\ttry\n\t\t{\n\t\t\tsimplifyServer = new NetSimplifyServer( );\n\t\t\tsimplifyServer.ReceiveStringEvent += SimplifyServer_ReceiveStringEvent;\n\t\t\tsimplifyServer.ServerStart( 12345 );\n\t\t}\n\t\tcatch(Exception ex )\n\t\t{\n\t\t\tConsole.WriteLine( \"Create failed: \" + ex.Message );\n\t\t\tReturn;\n\t\t}\n\n\t\tConsole.ReadLine();\n\t}\n\n\tprivate static void SimplifyServer_ReceiveStringEvent( AppSession session, NetHandle handle, string value )\n\t{\n\t\tif (handle == 1)\n\t\t{\n\t\t\t// Message to operate when a signal from the client is received 1\n\t\t\tsimplifyServer.SendMessage( session, handle, \"This is test single：\" + value );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsimplifyServer.SendMessage( session, handle, \"not supported msg\" );\n\t\t}\n\t\n\t\t// Show out, who sent it, what did it send?\n\t\tConsole.WriteLine($\"{session} [{handle}] {value}\");\n\t}\n}\n```\nC# Client Side (Also asp.net mvc, asp.net core mvc)\n```\nNetSimplifyClient simplifyClient = new NetSimplifyClient( \"127.0.0.1\", 12345 );\nstring value = simplifyClient.ReadFromServer( 1, \"test\" ).Content;\n```\nJava Client Side\n```\nNetSimplifyClient simplifyClient = new NetSimplifyClient( \"127.0.0.1\", 12345 );\nstring value = simplifyClient.ReadFromServer( 1, \"test\" ).Content;\n```\nPython Client Side\n```\nnetSimplifyClient = NetSimplifyClient(\"127.0.0.1\",12345)\nvalue = netSimplifyClient.ReadFromServer(1,'123').Content\n```\n\n**Note**: In the source code, still contains a lot of Chinese annotation, in the future for a short period of time, \nwill be used in English and Chinese double annotation, thank you for your understanding.\n\n**HslCommunicationDemo** The features supported by this project can be roughly clear through the demo interface below:\n![Picture](https://raw.githubusercontent.com/dathlin/HslCommunication/master/imgs/demo.png)\n\n\n## HslCommunication.jar Summary \nThis component provides the Java version, for the. NET version of the castration version, removed all the server function code, \nretained part of the client function code, convenient and plc, device data interaction, and C # program data interaction, \nthis jar component is suitable for the development of Android, easy to build a. NET Server + Windows Client + asp.net client + J2EE client + Java Client + Android client.\n![Picture](https://raw.githubusercontent.com/dathlin/HslCommunication/master/imgs/java_demo.png)\n\n## HslCommunication.py Summary \nThis component provides a Python version, a castration version of the. NET version, removes all server function codes, retains some of the client function code, \nfacilitates data interaction with PLC, devices, and data interaction with C # programs for cross-platform operation\n![Picture](https://raw.githubusercontent.com/dathlin/HslCommunication/master/imgs/python_demo.png)\n\n## Xamarin.Android Demo\n![Picture](https://raw.githubusercontent.com/dathlin/HslCommunication/master/imgs/appDemo.png)\n\n## Where is the Source code?\nNot free open source. you can refer to webside: http://www.hslcommunication.cn/Cooperation\n\n## How to sponsor author?\n\n[PayPal](https://www.PayPal.Me/hslcommunication)\n\n![Alipay](https://raw.githubusercontent.com/dathlin/HslCommunication/master/imgs/support.png)\n\nThank you for your understanding \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdathlin%2Fhslcommunication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdathlin%2Fhslcommunication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdathlin%2Fhslcommunication/lists"}