Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, it is right below in conjunction with drawings and Examples
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
Embodiment provided in an embodiment of the present invention is as follows:
Fig. 1 to Fig. 4 is referred to, the embodiments of the invention provide a kind of communicator of cross-platform flexible bus, described device
Including:
Communication thread unit 101, two different connections for safeguarding double net identical services ports;
Thread pool container 102, for the management container as the communication thread unit;
Data queue's buffer unit 103, the data queue for caching the data queue received and transmission;
Processor 104 is connected, for pre-processing the data queue;
Service adapter 105, for sorting out two different connections of the described pair of net identical services port and when a network segment
Assisted network switches during Network Abnormal.
In the present embodiment, in communication thread unit 101, communication thread is divided into two major classes, three groups, i.e. TCP threads
With 2 major classes of UDP threads, TCP service roles, 3 groups of TCP Client role and UDP threads.Each thread is responsible for safeguarding double
Two different connections of net identical services port(TCP threads).
In the present embodiment, thread pool container 102 is used as the management container of all kinds communication thread, or thread management
Member.Thread pool container 102 be responsible for communication thread such as TCP threads and UDP threads are created, destroyed, is inquired about, is dispatched, is reused,
The management roles such as recovery.Thread pool container 102 is also interactive interface of the flexible bus with other software module, and other modules use soft
Interface that bus is opened to the outside world by thread pool container 102 is carried out.Thread pool container 102, thread pool is divided the work and made
Thread pool and caching two thread pools of thread pool;Worker thread pond carries out the thread container of communication work, caching thread
Pond is standby thread container;When there is new connection to set up, then its respective thread in the caching thread pond is dispatched to described
In worker thread pond, when there is connection to disconnect, then its respective thread in the worker thread is discharged, and the thread of release is reclaimed
For caching thread, it is dispatched in the caching thread pond.
In the present embodiment, data queue's buffer unit 103, as the data buffer storage pond that each connection is pending, for delaying
Deposit and receive data queue and send data queue, data queue's buffer unit 103 sends buffering with TCP and reception buffering is similar,
Data queue and transmission data queue are received by caching, it can be ensured that will not handle energy because of transient data when data peak
The not enough influence or loss data to data communication of power.
In the present embodiment, processor 104 is connected, specifically for the data prediction safeguarded, operated to data queue,
The namely direct manager of data queue.
In the present embodiment, data are divided into two kinds of types of service, when same third party system communicates, using without heading
Data type, internally uses the data type with heading in system.The data class with heading is internally used in system
Type contributes to the interference for preventing invalid data to system, it is ensured that the legitimacy of connection, will be disconnected when there is illegal connection.
In the present embodiment, service adapter 105 is set exclusively for double Network Communications are supported.
The communication thread unit uses ACE Overpassing Platform by Using technologies.
In the present embodiment, the communication thread unit 101 includes the XPCOM components for externally providing interface.
In the present embodiment, described device also includes:
Heartbeat detection unit, for sending self-defined heartbeat message, when not receiving response message or just in the given time
During normal communication data packet, then connection or handover network are re-established.
In the present embodiment, the communicator of cross-platform flexible bus is specially the logical of the cross-platform flexible bus under C/C++ language
T unit.
The communicator of the cross-platform flexible bus of the present embodiment, using ACE Overpassing Platform by Using technologies.It is cross-platform using ACE
Communication characteristic, it is more complicated for ACE mechanism, it is skilled grasp, using it is more difficult the characteristics of, it is sealed again using Object-oriented Technique
Dress, again reduction uses complexity.
The communicator of the cross-platform flexible bus of the present embodiment, using thread pool.ACE is not only to Overpassing Platform by Using socket
Programming is encapsulated, and also causes this concept of thread has been carried out on each platform abstract so that the programming of multithreading can be with non-
It is often simple.The multi-threaded code can be also run on the platform for not supporting thread.Management to socket connections is used
Thread pool mode manages communication thread unit 101 with the communication port between other modules, there is the pipe of thread pool container 102
Reason, socket networked communication resources with regard to that can be managed well, it is to avoid because error causes the phenomenon of the wasting of resources.
The communicator of the cross-platform flexible bus of the present embodiment, using the cross-platform component technologys of XPCOM.XPCOM is one
Cross-platform component model, its full name is Cross Platform Component Object Module.XPCOM realizes one
Individual framework(framework), in this framework, it allows developer to break single overall software project, and is decomposed into multiple
Smaller modularization fragment(pieces), these fragments namely component(components).XPCOM components externally provide interface,
For XPCOM interfaces, it is necessary to consider 2 factors:
(1), interface with according to contract (Contract) program:One interface reaches contract between component and CLIENT PROGRAM
About.Not any compulsory measure ensures to accept this contract, but it can be fatal to ignore it.In the programming based on component
In, component ensures that the interface that it is provided is constant.The component of different editions is offered to same access method.This just with
Reached a kind of contract for this angle using its CLIENT PROGRAM, the programming based on component also commonly referred to as according to
Contract is programmed.
(2)Interface and encapsulation:The abstract maintainability to software between module boundaries with reusability is most important
's.
The communicator of the cross-platform flexible bus of the present embodiment, using Object-oriented Technique, utilizes three of object-oriented
Essential characteristic(Encapsulation, inherit, it is polymorphic)The purpose for software can be made to realize easy care, high-quality, high efficiency, easily extending is become reconciled
Place.Simultaneously because the Object-oriented Technique that ACE and XPCOM are also used, so flexible bus can also using Object-oriented Technique
The condensate for making flexible bus be an Object-oriented Technique from general frame, realizes clear in structure, the clean and tidy effect of code.
The communicator of the cross-platform flexible bus of the present embodiment, supports double network technologies.Electric power software particularly monitoring software,
In order to ensure communication reliability, generally using double planar network architectures.Flexible bus supports double nets it is ensured that program module is in a network segment
The operation of another network segment is seamlessly switched in the case of paralysis, not lost data packets, so as to ensure communication reliability.
The communicator of the cross-platform flexible bus of the present embodiment, utilizes heartbeat detection unit.It can determine whether whether TCP connections are steady
It is fixed, self-defined heartbeat is sent in passage idle, other side replys heartbeat at once after receiving.If failing to receive within the defined period
To the heartbeat message or proper communication packet of other side, then judge that the connection is broken, connection is re-established automatically or is switched
The network segment.
The communicator of the cross-platform flexible bus of the present embodiment, using Double Data type-scheme.A kind of data type conduct
Internal system data, band internal data heading(Internally communication, supports double nets);Another data type is logical as same third party
Letter data form(Correspondence with foreign country, double nets are not supported), without data message head, this is determined after a connection setup.
The communicator of the cross-platform flexible bus of the present embodiment, can apply to following scene:Power network schedule automation system
Communication middleware between system each service module of main station system;It is logical between each service module of electrical power distribution automatization system main station system
Believe middleware;Communication middleware between each service module of electric substation automation system main station system;Concentrator station main station system is each
Communication middleware between service module;Communication middleware between each service module of other monitoring systems.
The communicator of the cross-platform flexible bus of the present embodiment, can be deployed to service together as dynamic base and system software
On device or PC, when system software needs to carry out network service, network connection is created to flexible bus request, i.e., into flexible bus
Thread management person asks scheduling thread and carries out corresponding connection processing.
The communicator for the cross-platform flexible bus that the present embodiment is provided, using component technology, blocking technology and towards right
As technology, developer and running environment are supplied to the form of dynamic base, so as to realize that solution electric power software unit melts hair
During for the cross-platform of communication function and reuse and require the purpose of problem.Cross Platform Technology ensures that software can be in mixing platform
Run under environment.
The communicator for the cross-platform flexible bus that the present embodiment is provided, user is only needed to using connecing that software is externally provided
Mouthful network programming just can be easily carried out, communication fault-tolerance is handled etc. into work gives flexible bus inter-process, it is ensured that no
Because of communicative reasons robustness can be caused to reduce.
The embodiment of the present invention additionally provides a kind of flexible bus, and the flexible bus includes above-mentioned device.
Fig. 5 illustrates deployed position of the flexible bus of the present embodiment offer in software architecture, and flexible bus is used as dynamic base
It is deployed to together on server or PC with system software, when system software needs to carry out network service, asks to create to flexible bus
Establishing network is connected, i.e., thread management person's request scheduling thread into flexible bus simultaneously carries out corresponding connection processing.
The communicator and flexible bus of the cross-platform flexible bus of the present invention, pass through communication thread unit, thread pool container, number
According to queue buffer unit, connection processor, service adapter, the unitized of communication mode is realized, it is easy to safeguard.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all essences in the present invention
Any modifications, equivalent substitutions and improvements made within refreshing and principle etc., should be included in the scope of the protection.