The content of the invention
In view of this, it is an object of the invention to provide a kind of upper layer module generation method and system, realize according to fixation
Mechanism the port of each submodule is arranged, automatically generate upper layer module, avoid the process of manual compiling.
To achieve the above object, the present invention has following technical scheme:
A kind of upper layer module generation method, the described method comprises the following steps:
Upper layer module title is preset, submodule list is formulated, letter is carried out to submodule according to the submodule list
Breath is read, and obtains input port set, output port set, sub-module name set submodule port corresponding with each submodule
Set;The input port set includes the input port in each submodule, and the output port set includes each submodule
Output port in block, submodule port set corresponding to the submodule include the input port in the submodule and output
Port;
The port in input port set and output port set is compareed, there will be the input port of matching relationship and output
Port is added in common port set, and remaining input port is added into upper strata input port set, by remaining output end
Mouth adds upper strata output port set;
By upper layer module title, sub-module name set, the set of common port, upper strata input port set, upper strata output end
The set of submodule port is generated as upper layer module corresponding to mouth set and each submodule.
Methods described also includes:Particular port set is pre-established, is specified in the particular port set non-matching defeated
Inbound port is connected with output port;
Then the port in the control input port set and output port set also includes, in advance by particular port set
In the input port specified excluded with output port;
Then being generated as upper layer module is;By upper layer module title, sub-module name set, particular port set, common port
Set, upper strata input port set, upper strata output port set and submodule port set corresponding to each submodule are generated as
Upper layer module.
It is described that information reading is carried out to submodule, obtain input port set, output port set and sub-module name set
Specially:
The submodule in submodule list is chosen one by one, travels through the information in submodule;
When reading sub-module name information from submodule block message, then sub-module name information is added into sub-module name set;
When reading input port from submodule block message, then input port collection is added to by the input port is unduplicated
In conjunction;And the input port is added in submodule port set corresponding to the submodule;
When reading output port from submodule block message, then output port collection is added to by the output port is unduplicated
In conjunction;And the output port is added in submodule port set corresponding to the submodule.
It is described to be added to the input/output end port is unduplicated in input/output end port set, be specially:
When reading input/output end port, then it is defeated to judge whether current input/output end port set has included this
Enter/output port, added if not including;Otherwise give up.
It is described that there will be specially in the input port of matching relationship and the common port set of output port addition:
An input port is read from input port set, and whether is inquired about in output port set including matching
Output port, if there is then the input port and output port are added in common port set;
Or an output port is read from output port set, and inquire about in input port set whether include with
Matching input port, if there is then the input port and output port are added in common port set.
A kind of upper layer module generates system, and the system specifically includes:
Collection module, for according to the submodule list to submodule carry out information reading, obtain input port set,
Output port set, sub-module name set submodule port set corresponding with each submodule;The input port set bag
The input port in each submodule is included, the output port set includes the output port in each submodule, the submodule
The set of submodule port includes the input port and output port in the submodule corresponding to block;
Module is integrated, for compareing the port in input port set and output port set, there will be matching relationship
Input port is added in common port set with output port, and remaining input port is added into upper strata input port set,
Remaining output port is added into upper strata output port set;
Generation module, for presetting upper layer module title, formulate submodule list, and by upper layer module title, son
It is sub corresponding to module name set, the set of common port, upper strata input port set, upper strata output port set and each submodule
Module port set is generated as upper layer module.
The system also includes:
Designated module, for pre-establishing particular port set, so that assembly module is by the particular port collection of component
Among upper layer module;Non-matching input port is specified to be connected with output port in the particular port set;
Then the generation module is used for, by upper layer module title, sub-module name set, particular port set, common port
Set, upper strata input port set, upper strata output port set and submodule port set corresponding to each submodule are generated as
Upper layer module.
The integration module includes:
Rejected unit, in input port set and output port set, excluding particular port set middle finger in advance
Fixed input port and output port;
Common port integral unit, for reading an input port from input port set, and inquires about output port
Whether include matching output port in set, if there is the input port and output port then are added into common end
In mouth set;Or an output port is read from output port set, and inquire about in input port set whether include with
Matching input port, if there is then the input port and output port are added in common port set;
Input port integral unit, for the input port for not adding particular port set and the set of common port to be added
Upper strata input port set;
Output port integral unit, for the output port for not adding particular port set and the set of common port to be added
Upper strata output port set.
The collection module specifically includes:
Reading unit, for choosing the submodule in submodule list one by one, travel through the information in submodule and reading;
Name cell, for when reading sub-module name information from submodule block message, sub-module name information to be added
Sub-module name set;
Aggregation units are inputted, for when reading input port from submodule block message, the input port not to be repeated
Be added in input port set;
Output set unit, for when reading output port from submodule block message, the output port not to be repeated
Be added in output port set;
Submodule aggregation units, for the input port and output port that will be read from submodule block message, it is added to
In submodule port set corresponding to the submodule.
As seen through the above technical solutions, beneficial effect existing for the present invention is:Extract and divide by specific flow
Upper layer module information needed is built, and then realizes automatically generating for upper layer module;Avoid the mistake of manual compiling upper layer module
Journey, the work load of programming personnel is alleviated, improves efficiency and accuracy rate.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
Part of the embodiment of the present invention, rather than whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art
The every other embodiment obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.
So-called upper layer module in the present invention, its function is mainly that the communication to submodule is managed, that is, remains each
Communication between individual submodule, and further communicated with other upper layer modules.It may also be said that the upper layer module master
If a functional module to being integrated for the input/output end port of communication.In the present invention, methods described will be according to spy
Fixed flow reads input/output end port from each submodule, is arranged and is divided in the effect according to each port, and generation is each
The common upper layer module of submodule.
A specific embodiment shown in Figure 1 for the method for the invention, in the present embodiment, methods described includes
Following steps:
Step 101, upper layer module title is preset, submodule list is formulated, according to the submodule list to submodule
Block enters row information reading, obtains input port set, output port set, sub-module name set son corresponding with each submodule
Module port set;The input port set includes the input port in each submodule, and the output port set includes
Output port in each submodule, submodule port set corresponding to the submodule include the input in the submodule
Mouth and output port.
In the submodule list, include all submodules that the upper layer module to be generated is managed.Pass through the son
Module list can find each submodule, and the reading that information is carried out to submodule one by one.This step will read submodule
All submodules that block list includes, specific reading of content have sub-module name, input port and output port.After reading,
All sub-module names are added to sub-module name set, all input ports are added to input port set, will be all
Output port be added to output port set, and for each submodule establish corresponding to the set of submodule port, by the submodule
Input port and output port in block are added in corresponding submodule port set.So far this step is realized each submodule
/ output port concentration is fully entered involved by block, so as to follow-up further arrangement.
It should be noted that input port often is added into input port set, or output port is added to defeated
Port set is unduplicated addition.Identical input/output is included it is, working as in two or more submodules
Port, only added once in corresponding set.
Port in step 102, control input port set and output port set, there will be the input of matching relationship
Mouth is added in common port set with output port, and remaining input port is added into upper strata input port set, by residue
Output port add upper strata output port set.
The purpose of this step is, the port that will uniformly be put together in step 101, is arranged and is drawn according to effect
Point, obtain the real part of the upper layer module.
The so-called input port and output port that matching relationship be present, it is that same port had both been present in input port set
In, it is present in again in output port set, has natural matching opposite joining relation therebetween, then it is assumed that two in communication process
Person must need to be connected.In the present embodiment, the port screen of These characteristics is will be provided with present input/output end port set
Elect, be added in common port set.Common port set is for realizing the direct communication between submodule.
After screening obtains common port set, by now remaining input port is added to upper strata in input port set
Input port set, by now remaining output port is added to upper strata output port set in output port set.Upper strata is defeated
Inbound port set and upper strata output port set be equivalent to be upper layer module input port and output port, for realizing this
Communication between upper layer module and other upper layer modules.
In this step, input port set and output port set are further subdivided into common port set, upper strata input
Port is gathered and upper strata output port set.Common port set, upper strata input port set and upper strata output port set three
Person can turn into the real part of the upper layer module.
Step 103, by upper layer module title, sub-module name set, the set of common port, upper strata input port set, on
The set of submodule port is generated as upper layer module corresponding to layer output port set and each submodule.
In the present embodiment, it is believed that five kinds of set above contain all necessary key elements in upper layer module, so reading
Five kinds of the above is taken to gather all information included, you can component turns into upper layer module.
As seen through the above technical solutions, beneficial effect existing for the present embodiment is:Extract and draw by specific flow
Divide structure upper layer module information needed, and then realize automatically generating for upper layer module;Avoid manual compiling upper layer module
Process, the work load of programming personnel is alleviated, improves efficiency and accuracy rate.
It is shown in Figure 2, it is another specific embodiment of the method for the invention., will be in Fig. 1 institutes in the present embodiment
On the basis for showing embodiment methods described, further optimization and expansion have been carried out.For purposes of illustration only, by institute in the present embodiment
The method of stating is placed in application scenarios in detail below:
To be that tri- submodules of A, B, C generate upper layer module according to methods described;
Submodule A has input port x, y, u;Output port m1, n;
Submodule B has input port x, p, r;Output port m2, q;
Submodule C has input port y, z;Output port m3, p, k.
Method specifically includes following steps described in the present embodiment:
Step 201, upper layer module title is preset, formulate submodule list.
This step is the preparation process of method described in the present embodiment.In the present embodiment, submodule list also for
Show submodule that the upper layer module to be generated connects and manage include it is specific which, submodule list described in the present embodiment
Include submodule A, submodule B, submodule C.Further, the identification for the ease of upper layer module and it is in communication with each other, this reality
Apply and upper layer module name is set in example, in the present embodiment, set the entitled ABC_TOP of upper layer module.
Step 202, pre-establish particular port set, specified in the particular port set non-matching input port with
Output port connects.
Among practical application, in addition to it the input port of matching relationship be present and be necessarily connected with output port;May be used also
Taking human as the non-matching a certain input port of formulation be connected with a certain output port, in the present embodiment by this annexation into
Connected for particular port.Particular port set is the port a being manually set set, also using as the composition portion of upper layer module
/ mono-.Particular port connection is for being in communication with each other between submodule.
In the present embodiment, you can specify the input port u in submodule A to be connected with the output port k in submodule C, and
Set the entitled u-k of the connection;Specify the input port r in submodule B to be connected with the output port n in submodule A, set
The entitled r-n of the connection.That is particular port collection is combined into { u-k, r-n } in the present embodiment.
Step 203, the one by one submodule in selection submodule list, travel through the information in submodule;Obtain input port
Set, output port set submodule port set corresponding with each submodule with sub-module name set.
In the present embodiment, traveling through in all submodules by way of all information, input port set, output end are obtained
Mouth set and sub-module name set.
Specifically it can be described as:When reading sub-module name information from submodule block message, then sub-module name information is added
Sub-module name set;When reading input port from submodule block message, then input is added to by the input port is unduplicated
In the set of port, and the input port is added in submodule port set corresponding to the submodule;When from submodule block message
In read output port, then be added to the output port is unduplicated in output port set, and the output port is added
Enter into submodule port set corresponding to the submodule.
It is described to be added to the input/output end port is unduplicated in input/output end port set, that is, when reading
Input/output end port, then judge whether current input/output end port set has included the input/output end port, if
Do not include then adding;Otherwise give up.
If for example, tri- submodules of reading A, B, C successively, then after submodule A reading is completed, input
It will include tri- input ports of x, y, u in mouth set;Then in the input port x in reading submodule B, it finds that identical
Input port x existed in input port set, what is be now not repeated is added to input port collection by input port x
Close, but give up.
In the present embodiment, it is sequentially completed after the reading of three submodules, input port collection is combined into { x, y, u, p, r, z },
Output port collection is combined into { m1, n, m2, q, m3, p, k }, and sub-module name collection is combined into { A, B, C }, submodule end corresponding to submodule A
Mouth collection is combined into { x, y, u, m1, n }, and submodule port collection is combined into { x, p, r, m2, q } corresponding to submodule B, corresponding to submodule C
Submodule port collection is combined into { y, z, m3, p, k }.
Step 204, the input port and output port specified in particular port set are excluded in advance.
Because the certain port in input port set and output port set has been assigned with, effect is clear and definite, and
It is already present among particular port set, has just been completed before equivalent to the arrangement for this section ports and division.So
In arranging and divide in follow-up further port, this section ports will be no longer participate in.
In the present embodiment, input port u and input port r are excluded from input port set, by output port k and defeated
Exit port n excludes from output port set.
It also should be noted that the particular port connection in particular port set, substantially for a certain submodule
What certain Single port under block was specified, if also including identical port in other submodules, it is not included in specified
In the range of.For example, if the input port x in submodule A is specified in particular port connection, that is simultaneously not equal in submodule B
Input port x is also designated;So in this case, it is impossible to exclude input port x from input port set.
Step 205, there will be in the input port of matching relationship and the common port set of output port addition.
In the present embodiment, it can be found that in input port set and output port set, including port p.Namely
Say that input port p and output port p there is so-called matching relationship.Then port p is added in common port set.The present embodiment
In common port set be { p }.
In the present embodiment, want to find the input port and output port that matching relationship be present, then need to compare input
Port in mouth set and output port set.Specific mode is following two nothing more than:
Whether one kind is, an input port is read from input port set, and inquire about in output port set and include
Matching output port, if there is then the input port and output port are added in common port set;
Another kind is an output port to be read from output port set, and inquire about in input port set and whether wrap
Matching input port is included, if there is then the input port and output port are added in common port set.
Step 206, by remaining input port add upper strata input port set, by remaining output port add upper strata
Output port set.
After step 204~step 205 is completed, also include { x, y, z } in input port set, output port set
In also include { m1, m2, q, m3 }.Three input ports of x, y, z are then added into upper strata input port set;By m1, m2, q, m3 tetra-
Individual output port adds upper strata output port set.
Obtain upper strata input port collection to be combined into { x, y, z }, upper strata output port collection is combined into { m1, m2, q, m3 }.
Step 207, by sub-module name set, particular port set, the set of common port, upper strata input port set, on
The set of submodule port and default upper layer module title are generated as upper strata mould corresponding to the set of layer output port, each submodule
Block.
In the present embodiment, obtained by above-mentioned steps, the entitled ABC_TOP of upper layer module, sub-module name collection is combined into
{ A, B, C }, particular port collection are combined into { u-k, r-n }, and common port set is { p }, and upper strata input port collection is combined into { x, y, z },
Upper strata output port collection is combined into { m1, m2, q, m3 }, and submodule port collection is combined into { x, y, u, m1, n }, submodule corresponding to submodule A
Submodule port collection is combined into { x, p, r, m2, q } corresponding to block B, submodule port collection corresponding to submodule C be combined into y, z, m3, p,
k}.Thus whole key elements needed for upper layer module are generated and arrange completion, the upper layer module is generated according to the above set.
As seen through the above technical solutions, beneficial effect existing for the present embodiment is:Method described in the present embodiment is overall
Technical scheme is more complete, open more abundant.
Shown in reference picture 3, the specific embodiment of system is generated for upper layer module of the present invention, it is described in the present embodiment
Method described in the illustrated embodiment of system corresponding diagram 1~2, the technical scheme of the system are substantially real with two above method
Apply that example is identical, the associated description in above example is equally applicable in the present embodiment.The system specifically includes:
Collection module, for according to the submodule list to submodule carry out information reading, obtain input port set,
Output port set, sub-module name set submodule port set corresponding with each submodule;The input port set bag
The input port in each submodule is included, the output port set includes the output port in each submodule, the submodule
The set of submodule port includes the input port and output port in the submodule corresponding to block.
The collection module includes:
Reading unit, for choosing the submodule in submodule list one by one, travel through the information in submodule and reading;
Name cell, for when reading sub-module name information from submodule block message, sub-module name information to be added
Sub-module name set;
Aggregation units are inputted, for when reading input port from submodule block message, the input port not to be repeated
Be added in input port set;
Output set unit, for when reading output port from submodule block message, the output port not to be repeated
Be added in output port set;
Submodule aggregation units, for the input port and output port that will be read from submodule block message, it is added to
In submodule port set corresponding to the submodule.
Designated module, for pre-establishing particular port set, so that assembly module is by the particular port collection of component
Among upper layer module;Non-matching input port is specified to be connected with output port in the particular port set.
Module is integrated, for compareing the port in input port set and output port set, there will be matching relationship
Input port is added in common port set with output port, and remaining input port is added into upper strata input port set,
Remaining output port is added into upper strata output port set.
The integration module includes:
Rejected unit, in input port set and output port set, excluding particular port set middle finger in advance
Fixed input port and output port;
Common port integral unit, for reading an input port from input port set, and inquires about output port
Whether include matching output port in set, if there is the input port and output port then are added into common end
In mouth set;Or an output port is read from output port set, and inquire about in input port set whether include with
Matching input port, if there is then the input port and output port are added in common port set;
Input port integral unit, for the input port for not adding particular port set and the set of common port to be added
Upper strata input port set;
Output port integral unit, for the output port for not adding particular port set and the set of common port to be added
Upper strata output port set.
Generation module, for presetting upper layer module title, submodule list is formulated, by upper layer module title, submodule
The set of block name, particular port set, the set of common port, upper strata input port set, upper strata output port set and each height
The set of submodule port is generated as upper layer module corresponding to module.
In the present embodiment, beneficial effect existing for the system is:Structure upper strata is extracted and divided by specific flow
Module information needed, and then realize automatically generating for upper layer module;The process of manual compiling upper layer module is avoided, is alleviated
The work load of programming personnel, improves efficiency and accuracy rate.
Described above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For member, under the premise without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications also should
It is considered as protection scope of the present invention.