CN109951465A - A kind of data communications method based on factory method pattern and dlm (dynamic loading module) - Google Patents
A kind of data communications method based on factory method pattern and dlm (dynamic loading module) Download PDFInfo
- Publication number
- CN109951465A CN109951465A CN201910173596.8A CN201910173596A CN109951465A CN 109951465 A CN109951465 A CN 109951465A CN 201910173596 A CN201910173596 A CN 201910173596A CN 109951465 A CN109951465 A CN 109951465A
- Authority
- CN
- China
- Prior art keywords
- communication protocol
- data
- module
- factory
- protocol information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Abstract
The invention discloses a kind of data communications method based on factory method pattern and dlm (dynamic loading module) includes the following steps: to obtain the first communication protocol information of data input pin and the second communication protocol information of data output end;Factory loads the dynamic link library of corresponding communication function module according to first communication protocol information and the selection of the second communication protocol information;The dynamic link library constructs input terminal communication module and the output end communication module corresponding to first communication protocol and the second communication protocol according to parameter point profile information, the first communication protocol information and the second communication protocol information read respectively;The background thread of activation processing data, the input terminal communication module is packaged from the real time data that the data input pin obtains, and the data after encapsulation are sent to destination address via the data output end by the data output end communication module.
Description
Technical field
The present invention relates to a kind of data communications methods, more particularly to one kind to be based on factory method pattern and dlm (dynamic loading module)
Data communications method.
Background technique
Factory method pattern, also known as factory mode, polymorphic factory mode and virtual builder mode are by defining factory
Parent is responsible for the common interface of definition creation object, and subclass is then responsible for generating specific object.
Factory method pattern is postponed till the creation of specific product in the subclass (specific factory) of factory class, at this time factory class
It is no longer responsible for the creation of all products, and is merely given as the interface that specific factory must realize.When adding new product, it is not necessarily to
Factory's logic of class is modified, but extends new factory's subclass.Maintaining the excellent of encapsulated object creation process in this way
While point, open closing principle is still conformed to.
For a long time, the demand in relation to data communication function is always the emphasis and pain spot of the industries such as electric power, the energy.
In current industry, for all kinds of international/domestic standard traffic specifications (agreement), it is no lack of mature and stable solution.
But still remain following two major defect:
1. a kind of or a few communication protocol can only be adapted to, can not extend.Once there is new communication protocol, it can only be right
Software product is reconstructed or even develops again.
2. matching different communication protocols using simple factory mode.The communication protocol number that this kind of products can be adapted to
Amount not can avoid the defect (do not meet open close principle) of simple factory mode itself perhaps not counting seldom, that is, occur
When new communication protocol, needs to modify factory's logic of class, need to change product code and recompilate.In this way, will be unable to
Guarantee the original performance of product and stability.
Summary of the invention
The present invention is directed to the drawbacks of prior art, provides a kind of data based on factory method pattern and dlm (dynamic loading module)
Communication means.
Data communications method of the present invention based on factory method pattern and dlm (dynamic loading module), holds in data input pin
The first communication protocol of row executes the second communication protocol in data output end, includes the following steps:
Step 1 obtains the first communication protocol information of data input pin and the second communication protocol letter of data output end
Breath;
Step 2, factory are corresponding logical according to first communication protocol information and the selection load of the second communication protocol information
The dynamic link library of telecommunication function module;
Step 3, the dynamic link library according to read parameter point profile information, the first communication protocol information
With the second communication protocol information, constructs communicated corresponding to the input terminal of first communication protocol and the second communication protocol respectively
Module and output end communication module;
Step 4, the background thread of activation processing data, by the input terminal communication module from the data input pin
The real time data of acquisition is packaged, and by the data output end communication module by the data after encapsulation via the data
Output end is sent to destination address.
In the step of data communications method of the present invention based on factory method pattern and dlm (dynamic loading module) one, lead to
Reading master configuration file is crossed to obtain the first communication protocol information and the second communication protocol information.
In the step of data communications method of the present invention based on factory method pattern and dlm (dynamic loading module) two, work
Factory is according to first communication protocol information and the second communication protocol information by preassigned path searching to existing, accordingly
Communication function module dynamic link library.
In the step of data communications method of the present invention based on factory method pattern and dlm (dynamic loading module) two, if
The dynamic link library of existing, corresponding communication function module is not present in preassigned path, then makes a reservation for according in factory
Specification and the first communication protocol information and the second communication protocol information and compile out new dynamic link library, and it is this is new
Dynamic link library by the preassigned path storage.
In the step of data communications method of the present invention based on factory method pattern and dlm (dynamic loading module) four, institute
It states background thread and real time data is obtained from the input terminal communication module with activly request or subscribing manner.
In the step of data communications method of the present invention based on factory method pattern and dlm (dynamic loading module) four, root
Determine whether to carry out secondary treatment to real time data according to the parameter information of the master configuration file.
In the step of data communications method of the present invention based on factory method pattern and dlm (dynamic loading module) four, root
Requirement according to the data output end communication module to data format is packaged real time data.
In data communications method of the present invention based on factory method pattern and dlm (dynamic loading module), it can be adapted to more
Class communication protocol simultaneously carries out data interaction, can solve to need to modify in the prior art in order to be adapted to new communication protocol and lay equal stress on
The defect of the scalability difference of newly compiled code.
Detailed description of the invention
Fig. 1 is that the process of the data communications method of the present invention based on factory method pattern and dlm (dynamic loading module) is illustrated
Figure;
Fig. 2 is that application is of the present invention to be incited somebody to action based on the data communications method of factory method pattern and dlm (dynamic loading module)
The flow diagram for the data write-in MySQL database that Modbus agreement is read;
Fig. 3 is to be realized newly using of the present invention based on the data communications method of factory method pattern and dlm (dynamic loading module)
The process for the data write-in oracle database for increasing Oracle functional module dynamic link library, and 104 agreements being read is illustrated
Figure.
Specific embodiment
Present invention will be described in further detail below with reference to the accompanying drawings, to enable those skilled in the art referring to specification text
Word can be implemented accordingly.
As shown in Figure 1, the data communications method of the present invention based on factory method pattern and dlm (dynamic loading module), is
Communication protocol in order to the cope with data input pin situation different from the communication protocol of data output end, i.e., hold in data input pin
The first communication protocol of row executes the second communication protocol in data output end.
Then, in order to be adapted to multiclass communication protocol and carry out data interaction, as shown in Figure 1, the present invention includes as follows
Step:
Step 101, the first communication protocol information of data input pin and the second communication protocol letter of data output end are obtained
Breath.
In this step 101, the first communication protocol information and the second communication protocols can be obtained by reading master configuration file
Discuss information.
It is main profile information structure in the following table 1, it is as can be seen from the table, right by specific field name institute therein
The meaning information answered may be implemented to obtain the first communication protocol information and the second communication protocol letter by reading master configuration file
Breath.
Table 1:
Field name | Meaning |
INPUT/BasePath | The sub-folder of the first communication protocol (multiple) configuration file |
IO/Output | The filename of second communication protocol type configuration file |
Step 102, factory is corresponding according to first communication protocol information and the selection load of the second communication protocol information
The dynamic link library of communication function module.
In this step, preassigned road is pressed according to first communication protocol information and the second communication protocol information by factory
Diameter finds the dynamic link library of existing, corresponding communication function module.If finding existing, the corresponding communication function mould
The dynamic link library of block, then loaded, in case subsequent step uses.Such dynamic link library if it does not exist can then provide phase
The prompt answered.But the present invention is in order to realize the data interaction between different communication protocol, then can rebuild corresponding new
Dynamic link library the dynamic link library of existing, corresponding communication function module is not present in even preassigned path, then
New dynamic chain is compiled out according to specification scheduled in factory and the first communication protocol information and the second communication protocol information
Library is connect, and the new dynamic link library is stored by the preassigned path.
That is, if there is still undeveloped communication protocol, it is only necessary to the specification arranged in foundation factory, for
The agreement carries out exploitation test, after be compiled into dynamic link library and carry out load calling, carry out normal data friendship later
Mutual and process flow.All operating procedures are not related to modification and compiling to existing product code, will not influence product original
Each class feature having.
Step 103, the dynamic link library according to read parameter point profile information, the first communication protocol information
With the second communication protocol information, constructs communicated corresponding to the input terminal of first communication protocol and the second communication protocol respectively
Module and output end communication module.
As shown in table 2 below, in parameter point configuration file structure, different column have corresponded to different information,
Table 2:
Arrange A | Parameter point index |
Arrange B | Address of the parameter point in the first communication protocol |
Arrange C | Address of the parameter point in the second communication protocol |
Arrange D | Parameter point description |
Arrange E | Parameter point multiplying power |
Arrange F | Parameter point offset |
Arrange G backward | Additional information is parsed by specific communication protocol |
In this step, the information list to be got parms a little by reading parameter point profile information is defeated for constructing
Use when entering to hold communication module and output end communication module.
(file path is from table by reading the information in the sub- configuration file of communication protocol for the aforementioned dynamic link library being loaded
Read in 1), in conjunction with the parameter point information read in, initialization constructs corresponding communication module.
Step 104, the background thread of activation processing data, by the input terminal communication module from the data input pin
The real time data of acquisition is packaged, and by the data output end communication module by the data after encapsulation via the data
Output end is sent to destination address.
In this step, the background thread is obtained with activly request or subscribing manner from the input terminal communication module real
When data.
In this step, whether secondary treatment is carried out as to real time data, for example whether carrying out multiplying power processing or offset
Amount processing, also needs to be determined according to the parameter information of the sub- configuration file of specific communication protocol.
In this step, encapsulation to real time data is to be wanted according to the data output end communication module to data format
It asks and carries out.
When using the data communications method of the present invention based on factory method pattern and dlm (dynamic loading module), for tool
The communication protocol being adapted to when running body is not write extremely in code, but is determined by master configuration file.If appearance is not yet developed
Communication protocol, it is only necessary to according to the specification arranged in factory, carry out exploitation test for the agreement, after be compiled into dynamic
Chained library loads for software platform and calls, carries out normal data interaction and process flow later.All operating procedures,
It is not related to the modification and compiling to existing product code, will not influence the original each class feature of product.Also, entire software platform
Configuration file use distributed implementation, main configuration, parameter point configuration, the independent storage of communication protocol configuration, Each performs its own functions, convenient
User modifies, safeguards, backs up, restores.
As shown in Fig. 2, to apply the data communication side of the present invention based on factory method pattern and dlm (dynamic loading module)
The flow diagram for the data write-in MySQL database that method reads Modbus agreement.
Specifically, by reading the information in master configuration file, input agreement Modbus and output protocol are obtained
MySQL;
The communication protocol information at both ends is passed into factory, factory is according to protocol information, in specified path searching
The dynamic link library (i.e. plug-in unit) of Modbus and MySQL communication function module is simultaneously loaded onto software platform (at this time, it is assumed that described dynamic
State chained library presence);
By reading the information in parameter point configuration file, the information list to get parms a little, for the communication protocol at both ends
Functional module uses;
Modbus and MySQL dynamic link library, by reading the information in the respective sub- configuration file of communication protocol, in conjunction with
The parameter point information of reading, initialization construct corresponding communication module;
Background thread is activated, Modbus module is periodically carried out and reads data, platform secondary treatment, encapsulation pass to
MySQL module, MySQL module write this series of process of data to destination address.
Fig. 3 is to be realized newly using of the present invention based on the data communications method of factory method pattern and dlm (dynamic loading module)
The process for the data write-in oracle database for increasing Oracle functional module dynamic link library, and 104 agreements being read is illustrated
Figure.
It is specific as follows:
By reading the information in master configuration file, input agreement 104, output protocol Oracle are obtained;
The communication protocol information at both ends is passed into factory, Oracle functional module is being searched according to protocol information by factory
When, this dynamic link library is not present in discovery;
Then, according to the reading data class interface specification of agreement, the corresponding function of code realization is write for the property of Oracle
Energy;
After exploitation is completed, it is compiled into dynamic link library, puts the path specified to software platform;
After software platform starting, specified path is gone to search, it is found that the dynamic link library of Oracle functional module is existing;
The dynamic link library (plug-in unit) of 104 and Oracle communication function module is loaded onto software platform again;
By reading the information in parameter point configuration file, the information list to get parms a little, for the communication protocol at both ends
Functional module uses;
104 and Oracle dynamic link library, by reading the information in the respective sub- configuration file of communication protocol, in conjunction with having read
The parameter point information entered, initialization construct corresponding communication module;
Finally, activation background thread, periodically carries out 104 modules and reads data, platform secondary treatment, encapsulation pass to
Oracle module, Oracle module write this series of process of data to destination address.
Although the embodiments of the present invention have been disclosed as above, but its is not only in the description and the implementation listed
With it can be fully applied to various fields suitable for the present invention, for those skilled in the art, can be easily
Realize other modification, therefore without departing from the general concept defined in the claims and the equivalent scope, the present invention is simultaneously unlimited
In specific details and legend shown and described herein.
Claims (7)
1. it is logical to execute first in data input pin for a kind of data communications method based on factory method pattern and dlm (dynamic loading module)
Believe agreement, execute the second communication protocol in data output end, which comprises the steps of:
Step 1 obtains the first communication protocol information of data input pin and the second communication protocol information of data output end;
Step 2, factory is according to first communication protocol information and the corresponding communication function of the second communication protocol information selection load
The dynamic link library of energy module;
Step 3, the dynamic link library according to read parameter point profile information, the first communication protocol information and
Two communication protocol informations construct the input terminal communication module corresponding to first communication protocol and the second communication protocol respectively
With output end communication module;
Step 4, the background thread of activation processing data, the input terminal communication module is obtained from the data input pin
Real time data be packaged, and the data after encapsulation are exported via the data by the data output end communication module
End is sent to destination address.
2. the data communications method based on factory method pattern and dlm (dynamic loading module), feature exist as described in claim 1
In obtaining the first communication protocol information and the second communication protocol information by reading master configuration file in the step 1.
3. the data communications method based on factory method pattern and dlm (dynamic loading module), feature exist as described in claim 1
In in the step 2, preassigned road is pressed according to first communication protocol information and the second communication protocol information by factory
Diameter finds the dynamic link library of existing, corresponding communication function module.
4. the data communications method based on factory method pattern and dlm (dynamic loading module), feature exist as claimed in claim 3
In in the step 2, if the dynamic link of existing, corresponding communication function module is not present in preassigned path
Library then compiles out new according to specification scheduled in factory and the first communication protocol information and the second communication protocol information
Dynamic link library, and the new dynamic link library is stored by the preassigned path.
5. the data communications method based on factory method pattern and dlm (dynamic loading module), feature exist as described in claim 1
In in the step 4, the background thread is obtained with activly request or subscribing manner from the input terminal communication module real
When data.
6. the data communications method based on factory method pattern and dlm (dynamic loading module), feature exist as claimed in claim 2
In, in the step 4, according to the parameter information of the master configuration file determine whether to real time data carry out secondary treatment.
7. the data communications method based on factory method pattern and dlm (dynamic loading module), feature exist as claimed in claim 2
In in the step 4, the requirement according to the data output end communication module to data format is packaged real time data.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910173596.8A CN109951465B (en) | 2019-03-08 | 2019-03-08 | Data communication method based on factory method mode and dynamic loading module |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910173596.8A CN109951465B (en) | 2019-03-08 | 2019-03-08 | Data communication method based on factory method mode and dynamic loading module |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109951465A true CN109951465A (en) | 2019-06-28 |
CN109951465B CN109951465B (en) | 2022-11-08 |
Family
ID=67009326
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910173596.8A Active CN109951465B (en) | 2019-03-08 | 2019-03-08 | Data communication method based on factory method mode and dynamic loading module |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109951465B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6601192B1 (en) * | 1999-08-31 | 2003-07-29 | Accenture Llp | Assertion component in environment services patterns |
US20130212569A1 (en) * | 2007-11-27 | 2013-08-15 | The Boeing Company | Aircraft software part library |
CN103607702A (en) * | 2013-11-15 | 2014-02-26 | 上海大汉三通通信股份有限公司 | A method and system for carrying out communication among different platforms in short message service |
CN107911642A (en) * | 2017-11-24 | 2018-04-13 | 沈阳理工大学 | A kind of cable television network management system |
CN107980124A (en) * | 2017-08-31 | 2018-05-01 | 深圳市元征科技股份有限公司 | A kind of collecting method and server |
-
2019
- 2019-03-08 CN CN201910173596.8A patent/CN109951465B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6601192B1 (en) * | 1999-08-31 | 2003-07-29 | Accenture Llp | Assertion component in environment services patterns |
US20130212569A1 (en) * | 2007-11-27 | 2013-08-15 | The Boeing Company | Aircraft software part library |
CN103607702A (en) * | 2013-11-15 | 2014-02-26 | 上海大汉三通通信股份有限公司 | A method and system for carrying out communication among different platforms in short message service |
CN107980124A (en) * | 2017-08-31 | 2018-05-01 | 深圳市元征科技股份有限公司 | A kind of collecting method and server |
CN107911642A (en) * | 2017-11-24 | 2018-04-13 | 沈阳理工大学 | A kind of cable television network management system |
Non-Patent Citations (1)
Title |
---|
金敏等: "车载设备嵌入式监控组态软件的研究与应用", 《电子测量与仪器学报》 * |
Also Published As
Publication number | Publication date |
---|---|
CN109951465B (en) | 2022-11-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107147704A (en) | A kind of generic service middleware system towards block chain | |
CN101699405B (en) | Method and device for interaction between host program and plug-in and interaction between plug-ins | |
CN109670951B (en) | Block chain intelligent contract debugging and publishing method and system | |
TWI476608B (en) | A distributed computing data merging method, system and device thereof | |
CN102118281B (en) | Method, device and network equipment for automatic testing | |
CN101996132A (en) | Method and device for automatically testing common object request broker architecture (CORBA) interfaces | |
CN102981882B (en) | Analytic method and device | |
CN104461649B (en) | chip compatible method and device | |
CN107171897A (en) | A kind of interface test method and data-interface test system | |
CN112379884A (en) | Spark and parallel memory computing-based process engine implementation method and system | |
CN113326026B (en) | Method and terminal for generating micro-service business process interface | |
CN101986282B (en) | Topology adaptation method and device | |
Dotti et al. | Specification of mobile code systems using graph grammars | |
CN107247695A (en) | Coding rule generation method, system and storage device | |
CN103425793B (en) | Method for utilizing database purchase layer to access data base in instant communicating system | |
CN103984540A (en) | Method and device for generating hardware interface running program | |
CN109951465A (en) | A kind of data communications method based on factory method pattern and dlm (dynamic loading module) | |
CN102004660A (en) | Realizing method and device of business flows | |
CN109783132B (en) | Method and device for realizing system singleization and distribution | |
CN104503735B (en) | A kind of network system standardized data Fabric Interface consistency desired result method | |
CN110457013A (en) | Program assembly configuration device and method | |
CN113987725B (en) | Automatic generation method for variable logic relationship of DCS transparent transmission network of nuclear power station | |
CN109753552A (en) | The appellation of family member determines method, system, computer equipment and storage medium | |
CN104574188A (en) | Transaction service system and transaction processing method | |
CN115759955B (en) | Business process execution engine based on blockchain |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |