Thank you for sharing your comments.
Original address:
Http://www.cnblogs.com/lsjwq/
Contents
8. Singleton communication mode development and precautions... 2
8.1 overview... 2
8.2 communication mechanism description... 2
8.3 precautions for device driver development... 2
8.4 host program service instance configuration considerations... 3
8.5 running effect in singleton mode... 4
8. single-instance communication mode development and precautions 8.1 Overview
The Singleton communication mode is only applicable to network communication, and only one "device driver" can be added. Here, "device driver" is a logical concept that represents all devices or sensors, that is to say, all received data is distributed to the device driver ".
8.2 communication mechanism description
This control mode can be used only for network communication. A service instance can have only one device driver, which is equivalent to a device driver that corresponds to more than N hardware device terminals. It is more suitable for communication data protocols with fixed standards to process different data with command keywords. Suitable for highly concurrent hardware terminal devices to actively upload data. The server processes and returns the corresponding data based on the data information.
The communication structure is as follows:
8.3 precautions for device driver development
The development of device drivers in singleton mode is simpler. if the business is not complex, only initialization parameters, real-time data, protocols, and data processing logic are involved,More advanced applications will involve the ireceivefilter interface, iservice interface, and igraphicsshow interface, which will be introduced one by one in subsequent articles.
8.4 host program service instance configuration considerations
Sta
1234567891011121314151617181920212223242526272829303132333435 |
static void Main( string [] args) { //55 AA 00 61 43 7A 00 00 43 B4 15 0D DeviceSingletonDriver dev1 = new DeviceSingletonDriver(); dev1.DeviceParameter.DeviceName = "Network device" ; dev1.DeviceParameter.DeviceAddr = 0; dev1.DeviceParameter.DeviceID = "0" ; dev1.DeviceDynamic.DeviceID = "0" ; dev1.DeviceParameter.DeviceCode = "0" ; dev1.DeviceParameter.NET.RemoteIP = "127.0.0.1" ; dev1.DeviceParameter.NET.RemotePort = 9600; dev1.CommunicateType = CommunicateType.NET; dev1.Initialize( "0" ); IServer server = new ServerManager().CreateServer( new ServerConfig() { ServerName = "Singleton service" , NetReceiveBufferSize = 1024, ControlMode = ControlMode.Singleton, MaxConnects = 4000 }); server.AddDeviceCompleted += server_AddDeviceCompleted; server.DeleteDeviceCompleted += server_DeleteDeviceCompleted; server.SocketConnected+=server_SocketConnected; server.SocketClosed+=server_SocketClosed; server.Start(); server.AddDevice(dev1); while ( "exit" == Console.ReadLine()) { server.Stop(); } } |
ControlMode = ControlMode. Set Singleton to the unit mode.
8.5 running effect in singleton Mode
I ran 100 million concurrent connections on the local machine. The jmeter and jmeter used about 90% GB of memory and more than CPUs. I don't know why this is so resource-consuming, the notebook barely works.
Now we simulate 15 clients and send data once every 100 milliseconds. The effect is as follows:
- Image
Serialization | Iot framework serversuperio tutorial-8. single-instance communication mode development and precautions