17 Star 58 Fork 56

骑驴看世界 / HslCommunication

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

中文

             ///\      ///\             /////////\              ///\
            //\\/      //\/           //\\\\\\\\//\            //\\/
           //\/       //\/          //\\/       \\/           //\/
          //\/       //\/           \//\                     //\/
         /////////////\/             \//////\               //\/
        //\\\\\\\\\//\/               \\\\\//\             //\/
       //\/       //\/                     \//\           //\/
      //\/       //\/           ///\      //\\/          //\/       //\
     ///\      ///\/            \/////////\\/           /////////////\/
     \\\/      \\\/              \\\\\\\\\/             \\\\\\\\\\\\\/             Present by Richard.Hu

HslCommunication

HslCommnication.dll

Build status NuGet Status NuGet Download Gitter NetFramework Visual Studio License status copyright status

HslCommunication.jar

Build status License status NetFramework JDK status IDE status copyright status

HslCommunication.py

Build status License status NetFramework IDE status copyright status

CopyRight

(C) 2017 - 2019 Richard.Hu, All Rights Reserved

Official Website

Webside: http://www.hslcommunication.cn/

BBS: http://bbs.hslcommunication.cn/

API: http://api.hslcommunication.cn/

Gitter[talk with me]: https://gitter.im/HslCommunication/community

What is HSL

This is an industrial IoT based, computer communications architecture implementation, integrated with most of the basic functional implementation of industrial software development, such as Mitsubishi PLC Communications, Siemens PLC Communications, OMRON PLC Communications, Modbus Communications, All of these communications have been implemented in multiple languages, and of course, the feature integration of the main. NET Library is even more powerful, in 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, the realization of log function, flow number generation function, mail sending function, Fourier transform function, and so on, will integrate more common features of industrial environment in the future.

In order not to let the industry 4.0 stay on the slogan, the high-rise flat up, and the cornerstone is HSL.

What can HSL do

HSL can connect the equipment of the industrial production site to the free transmission of data at the bottom, whether active or passive, whatever your acquisition system (usually the acquisition system is a Windows computer, or an embedded system, or a Linux-based box), can 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, or B/S system, or C-B-S-A (Integrated desktop client, browser, Android) hybrid system, is a fast and low-cost implementation,

As long as you have the primary data of the industrial field, that is, can build a powerful real-time monitoring function of the software, production reports and automated scheduling software, a variety of process parameters history tracking software, data based on the experience of machine learning software, as well as full-featured MES system and so on.

By the way, the traditional industrial model is the procurement of off-the-shelf industrial software, including the host computer software and MES system, while ignoring their own system. For some industry-standard functional software, such as ERP systems, financial software, these can be purchased directly, However, for the host computer and MES system, the actual needs of each enterprise are very different, it is difficult to have a common scene, and 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, Based on HSL to develop enterprise-class MES system implementation, as the core Warehouse center of data, and business logic processing Center, for 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.

Install From NuGet

Description: NuGet for stable version, Support Online upgrade, the use of components is best downloaded from NuGet, the project published here is likely to have not yet compiled the beta version, NuGet installation is as follows:

Install-Package HslCommunication

Environment

  • IDE: Visual Studio 2019
  • java:Intellij Idea 2018.4
  • python: Visual Studio Code

Contact

Supported Model and price [welcome to complete]

Siemens

No. Class Model Price Remarks Contributor
1 pic pic   Richard Hu

Melsec

No. Class Model Price Remarks Contributor
1 pic pic   Richard Hu
2 pic pic   Richard Hu
3 pic pic   Richard Hu
4 pic pic   Richard Hu

AB plc

No. Class Model Price Remarks Contributor
1 pic pic    
1 pic pic    

Omron

No. Class Model Price Remarks Contributor
1 pic -    

Keyence

No. Class Model Price Remarks Contributor
1 pic -    

ModbusTcp

No. Class Model Price Remarks Contributor
1 pic pic   Richard Hu
4 pic pic   Richard Hu

Panasonic

No. Class Model Price Remarks Contributor
1 pic pic   镇江-Relax;

HslCommunication.dll Summary

When 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, and it only takes one or two lines of code to implement this feature. Like this

// Pseudo code
PLC plc = new PLC("192.168.0.11", 6000);

short value = plc.ReadInt16("D100");

But 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, may 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, So the final code becomes what it looks like (with Siemens PLC as an example)

SiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, " 192.168.1.110" );
OperateResult<short> read = siemens.ReadInt16("M100");

if(read.IsSuccess)
{
	// you get the right value
	short value = read.Content;
}
else
{
	// failed , but you still can know the failed detail
	Consolo.WriteLine(read.Message);
}

Of course, you can also write very concise, because the judgment of success is ignored, so the following operation is risky.

SiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, " 192.168.1.110" );
short value = siemens.ReadInt16("M100").Content;   // Look at this code, isn't it very succinct.

The above operation we have read the data, but is based on a short connection, when the reading of the data finished, automatically shut down the network, if you want to open a long connection, follow the following actions.

SiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, " 192.168.1.110" );
siemens.SetPersistentConnection( );
OperateResult<short> read = siemens.ReadInt16("M100");

if(read.IsSuccess)
{
	// you get the right value
	short value = read.Content;
}
else
{
	// failed , but you still can know the failed detail
	Consolo.WriteLine(read.Message);
}

// when you don't want read data, you should call close method
siemens.ConnectClose( );

So 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, redis Communications, EFT Robots, Kuka robots and so on, including its own support for the HSL protocol.

The 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, all you need to know is how the basic PLC address is represented, and you can read and write PLC data.

Called from Visual C++ project

cppProject -> Properties -> Configuration Properties -> General -> CLR Support

Add HslCommunication.dll(net35) reference

#include "pch.h"
#include <iostream>
using namespace HslCommunication;
using namespace ModBus;

int main()
{
    std::cout << "Hello World!\n";


	// This is the demo , called C# ModbusTcpNet
	System::String ^ipAddress = gcnew System::String("127.0.0.1");
	ModbusTcpNet ^modbus = gcnew ModbusTcpNet(ipAddress, 502, 1);

	System::String ^dataAddress = gcnew System::String("100");
	OperateResult<short> ^readValue = modbus->ReadInt16(dataAddress);
	if (readValue->IsSuccess) {
		short value = readValue->Content;
		printf("Read Value:%d \n", value);
	}
	else
	{
		printf("Read Failed");
	}
}

If you want to communication in your mobile phone application, you also can use C# code by xamarin, you can download HslAppDemo to test HslAppDemo.apk

Another feature of this project is support for cross-language communication support. You can build a C # background server that supports Windows desktop application and Web background, and Android phone-side, Python programs, Java programs to communicate. server side code:

class Program
{
    static void Main(string[] args)
    {
		NetSimplifyServer simplifyServer;
		try
		{
			simplifyServer = new NetSimplifyServer( );
			simplifyServer.ReceiveStringEvent += SimplifyServer_ReceiveStringEvent;
			simplifyServer.ServerStart( 12345 );
		}
		catch(Exception ex )
		{
			Console.WriteLine( "Create failed: " + ex.Message );
			Return;
		}

		Console.ReadLine();
	}

	private static void SimplifyServer_ReceiveStringEvent( AppSession session, NetHandle handle, string value )
	{
		if (handle == 1)
		{
			// Message to operate when a signal from the client is received 1
			simplifyServer.SendMessage( session, handle, "This is test single:" + value );
		}
		else
		{
			simplifyServer.SendMessage( session, handle, "not supported msg" );
		}
	
		// Show out, who sent it, what did it send?
		Console.WriteLine($"{session} [{handle}] {value}");
	}
}

C# Client Side (Also asp.net mvc, asp.net core mvc)

NetSimplifyClient simplifyClient = new NetSimplifyClient( "127.0.0.1", 12345 );
string value = simplifyClient.ReadFromServer( 1, "test" ).Content;

Java Client Side

NetSimplifyClient simplifyClient = new NetSimplifyClient( "127.0.0.1", 12345 );
string value = simplifyClient.ReadFromServer( 1, "test" ).Content;

Python Client Side

netSimplifyClient = NetSimplifyClient("127.0.0.1",12345)
value = netSimplifyClient.ReadFromServer(1,'123').Content

Note: In the source code, still contains a lot of Chinese annotation, in the future for a short period of time, will be used in English and Chinese double annotation, thank you for your understanding.

HslCommunicationDemo The features supported by this project can be roughly clear through the demo interface below: Picture

HslCommunication.jar Summary

This component provides the Java version, for the. NET version of the castration version, removed all the server function code, retained part of the client function code, convenient and plc, device data interaction, and C # program data interaction, this 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. Picture

HslCommunication.py Summary

This component provides a Python version, a castration version of the. NET version, removes all server function codes, retains some of the client function code, facilitates data interaction with PLC, devices, and data interaction with C # programs for cross-platform operation

Xamarin.Android Demo

Picture

Contribution

Warmly welcome suggestions for improvement of the Code of this project, you can launch pull Request.

Thanks

  • Hybrid locks and serializable exception classes, read and write locks, concurrent model parts code and ideas refer to "CLR Via C #", thanks to the author Jeffrey Richter

Cooperation Company

Picture Picture Picture Picture Picture Picture Picture Picture Picture

Controls

This library include some controls render upside picture. u can easily use them Picture

Mitsubishi PLC Communication

Using MC protocol, Qna 3E, Include binary and ascii Picture

Siemens PLC Communication

Using S7 protocol And Fetch/Write protocol Picture

Omron PLC Communication

Using Fins-tcp protocol Picture

AllenBradley PLC Communication

Picture

Modbus-tcp Communication

Client, using read/write coils and register, read discrete input , read register input Picture

Server, you can build your own modbus-tcp server easily Picture

Redis Client Communication

Picture

Simplify Net [ Based on Tcp/Ip ]

Communicaion with multi-computers , client can exchange data with server easily, include server side ,client side

Picture Picture

Udp Net [ Base on Udp/Ip ]

Communicaion with multi-computers , client can send a large of data to server, include server side ,client side

Picture Picture

File Net [ Base on Tcp/Ip ]

Communicaion with multi-computers , client can exchange File with server easily, include server side ,client side

Picture Picture

GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2017 - 2019 Richard.Hu <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

一个工业物联网底层架构框架,专注于底层技术通信和跨平台、跨语言通信功能,实现多种主流PLC数据读写,实现各种协议的Modbus读写等,支持工业上层的快速建设。计算机软件、组态软件、SCADA软件、工厂MES系统,帮助企业工业4.0起飞,实现智能制造、智能工厂的目标。主PLC包括西门子、三菱、欧姆龙、松下、Modbus、AB-PLC、Redis 展开 收起
C#
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/mengxw8/HslCommunication.git
git@gitee.com:mengxw8/HslCommunication.git
mengxw8
HslCommunication
HslCommunication
master

搜索帮助

14c37bed 8189591 565d56ea 8189591