Serialization | Iot framework ServerSuperIO tutorial-3. Device Driver introduction, Iot framework

Source: Internet
Author: User

Serialization | Iot framework ServerSuperIO tutorial-3. Device Driver introduction, Iot framework

1. C # Introduction to cross-platform Iot communication framework ServerSuperIO (SSIO)

Serialization | Iot framework ServerSuperIO tutorial 1.4 communication modes and mechanisms.

Serialization | Iot framework ServerSuperIO tutorial 2. service instance configuration parameters

 

3.1 Overview

Positioning ServerSuperIO (SSIO) as the IOT communication framework is built with "devices" (drivers) as the core. "devices" refer to sensors, lower computers, PCs, and other data sources, data sources have their own communication protocols or data transmission formats. ServerSuperIO is not a framework built with IO channels as the core, but ServerSuperIO has good communication capabilities and can be deployed on the server, it also supports multiple service instances and can run in Linux.

3.2 Interface Definition

The unified interface of ServerSuperIO "device" is defined as IRunDevice, which is the only interface for running, scheduling, and collaboration with IO channels within the framework. The code is defined as follows:

Public interface IRunDevice: IServerProvider, IVirtualDevice {# region function interface // <summary> // initialize the device, the first thing to load a device driver is to Initialize the device // </summary> // <param name = "devid"> </param> void Initialize (string devid ); /// <summary> /// Save the original byte data /// </summary> /// <param name = "data"> </param> void SaveBytes (byte [] data, string desc); // <summary> // obtain the command for sending data. If no command is in the Command cache, call the function to obtain real-time data // </summary> /// <returns> </ret Urns> byte [] GetSendBytes (); // <summary> // if no command is available in the current command cache, this function is called. Generally, the real-time data command for the device is returned, /// </summary> /// <returns> </returns> byte [] GetConstantCommand (); /// <summary> /// interface for sending IO data /// </summary> /// <param name = "io"> </param> /// <param name = "senddata"> </param> int Send (IChannel io, byte [] senddata ); /// <summary> /// interface for reading IO data /// </summary> /// <param name = "io"> </param> /// <returns> </returns> byte [] Receive (IChannel io); // <summary> // receives data information, with filter /// </summary> /// <param name = "io"> </param> /// <param name = "receiveFilter"> </param>/ // <returns> </returns> IList <byte []> Receive (IChannel io, IReceiveFilter receiveFilter); // <summary> // synchronous running device (IO) /// </summary> /// <param name = "io"> I/O Instance Object </param> void Run (IChannel io ); /// <summary> /// synchronously run the device (byte []) /// </summary> /// <param name = "k Ey "> </param> /// <param name =" channel "> </param> // <param name =" revData "> received data </param> void Run (string key, IChannel channel, IRequestInfo ri); // <summary> // if the communication is normal, this function processes data /// </summary> /// <param name = "info"> </param> void Communicate (IRequestInfo info ); /// <summary> // communication interrupted. No data is received. /// </summary> void CommunicateInterrupt (IRequestInfo info ); /// <summary> // The communication data is incorrect or is disturbed /// </summar Y> void CommunicateError (IRequestInfo info); // <summary> // unknown communication, default status (generally not needed) /// </summary> void CommunicateNone (); /// <summary> /// check the communication status /// </summary> /// <param name = "revdata"> </param> /// <returns> </returns> CommunicateState CheckCommunicateState (byte [] revdata ); /// <summary> /// alarm interface function /// </summary> void Alert (); /// <summary> /// Save the parsed data /// </summary> void Save (); /// <summary> /// Display /// </summary> void Show (); /// <summary> // when the communication instance is NULL, call this function // </summary> void UnknownIO (); /// <summary> /// communication status change /// </summary> /// <param name = "comState"> changed status </param> void CommunicateStateChanged (CommunicateState comState ); /// <summary> /// channel status change /// </summary> /// <param name = "channelState"> </param> void ChannelStateChanged (ChannelState channelState); /// <summary> /// time when the software is disabled, Responds to the device Exit Operation // </summary> void Exit (); /// <summary> /// response interface function of the device to be deleted /// </summary> void Delete (); /// <summary> /// you can customize the returned data object, used to interact with other components /// </summary> /// <returns> </returns> object GetObject (); /// <summary> // device timer, response to the scheduled task // </summary> void OnRunTimer (); // <summary> // display the context menu /// </summary> void ShowContextMenu (); /// <summary> /// display the form of the IO monitor /// </summary> void ShowMonitorDialog ();/// <Summary> /// display byte [] data on the IO monitor /// </summary> /// <param name = "data"> </param> /// <param name = "desc"> </param> void ShowMonitorData (byte [] data, string desc); # endregion # region attribute interface // <summary> // default Assembly ID, used to store temporary objects // </summary> object Tag {set; get ;}/// <summary> /// synchronization object, used for IO mutual split // </summary> object SyncLock {get ;} /// <summary> /// real-time persistent data interface /// </summary> IDeviceDynamic DeviceDynamic {Get ;}/// <summary> /// persistent interface of the device parameter /// </summary> IDeviceParameter DeviceParameter {get ;} /// <summary> /// Protocol driver /// </summary> IProtocolDriver Protocol {get ;}/// <summary> /// whether to enable the clock, indicates whether to call the OnRunTimer interface function. /// </Summary> bool IsRunTimer {set; get ;}/// <summary> // time interval value, identifies the cycle of the function that calls the DeviceTimer interface regularly. // </summary> int RunTimerInterval {set; get ;} /// <summary> /// device type /// </summary> DeviceType {get ;} /// <summary> /// device No. /// </summary> string ModelNumber {get;} /// <summary> // The permission level for running the device, if the running level is high, data is sent and received first. /// </Summary> DevicePriority {get; set ;}/// <summary> // communication type of the device /// </summary> CommunicateType {get; set ;}//< summary> /// identifies whether the device is running. If it is false, the system returns the result directly when calling the device operation /// </summary> bool IsRunDevice {get; set ;}//< summary> /// whether to release resources /// </summary> bool IsDisposed {get ;} /// <summary> /// display view /// </summary> Control DeviceGraphics {get ;} # endregion # region event interface // <summary> // send data event // </summary> event SendDataHandler SendData; /// <summary> // send data events, encapsulate the SendDataHandler event /// </summary> /// <param name = "senddata"> </param> void OnSendData (byte [] senddata ); /// <summary> /// device log output event /// </summary> event DeviceRuningLogHandler DeviceRuningLog; /// <summary> // run the monitor to display log events, encapsulation of DeviceRuningLogHandler events /// </summary> void OnDeviceRuningLog (string statetext ); /// <summary> /// serial port parameter change event /// </summary> event ComParameterExchangeHandler ComParameterExchange; /// <summary> /// serial port parameter change event, encapsulate the COMParameterExchangeHandler event // </summary> void OnComParameterExchange (int oldcom, int oldbaud, int newcom, int newbaud ); /// <summary> // device data object change event // </summary> event DeviceObjectChangedHandler DeviceObjectChanged; // <summary> // data driver event, encapsulation of DeviceObjectChangedHandler events /// </summary> void OnDeviceObjectChanged (object obj ); ///// <summary> //// delete a device event // </summary>/event DeleteDeviceCompletedHandler DeleteDeviceCompleted; ///// <summary> //// Delete the device event, encapsulate the DeleteDeviceHandler event ///// </summary> // void OnDeleteDeviceCompleted (); # endregion}
3.3 secondary development, common interfaces

The RunDevice abstract class inherits from the IRunDevice interface. Essentially, secondary development only needs to inherit the RunDevice abstract class. RunDevice has completed the basic conditions of the device driver under the ServerSuperIO framework. When inheriting the RunDevice abstract class, the secondary development is very small. You only need to pay attention to the protocol and process the data service itself, the internal running mechanism of the framework can be configured and automatically processed by the scheduling mechanism.

Frequently Used interfaces for secondary development. The project diagram is as follows:

1. [serialization] C # communication (Serial Port and network) Framework Design and Implementation

2. [Open Source] C # cross-platform Iot communication framework ServerSuperIO (SSIO) Introduction

2. Overall system construction solution using SuperIO and open-source cross-platform Iot framework ServerSuperIO

3. C # technical route of industrial IoT and integrated system solutions (data sources, data collection, data upload and receiving, ActiveMQ, Mongodb, WebApi, and mobile App)

5. ServerSuperIO Open Source Address: https://github.com/wxzz/ServerSuperIO

Internet of Things & integrated technology (. NET) QQ Group:54256083

 

Next article: Develop device drivers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.