A kind of trapezoidal map generalization method of PLC based on generator set controller
Technical field
The present invention relates to a kind of trapezoidal map generalization method, specifically, relate to a kind of trapezoidal map generalization method of PLC based on generator set controller.
Background technology
PLC programmed method generally uses trapezoid figure language (LD), repertoire la nguage (IL), functional module language (FBD), order functional sequence graph-based language (SFC) and structured text language (ST) five kinds, wherein simple, directly perceived with trapezoid figure language (LD).But, there is shortcoming that is dumb, that easily make mistakes when ladder diagram editor in existing ladder Diagram Edit Software.
In order to solve above Problems existing, people are seeking a kind of desirable technical solution always.
Summary of the invention
The object of the invention is for the deficiencies in the prior art, thus a kind of flexible operation, simple is provided, the trapezoidal map generalization of the PLC based on the generator set controller method of logic node can be dragged arbitrarily with mouse.
To achieve these goals, the technical solution adopted in the present invention is: a kind of trapezoidal map generalization method of PLC based on generator set controller, is characterized in that: it comprises the following steps:
Step 1: the type of definition intermediary tree node, described intermediary tree node comprises leaf node X, series connection node S and sys node P, described leaf node X is logic node switching value in ladder diagram, and described series connection node S and sys node P is the father node of ladder diagram logic node; Definition logical node type, wherein, logic node represents the particular content of each node on ladder diagram;
Step 2: build intermediary tree, realized by following steps:
Step 2.1: drag a logic node on interface, if interface only has a logic node, the logic node X1 of the newly-built node that is that it doesn't matter, increases new logic node X(2);
If a is increased to described logic node X(1) before or below, the pass of two logic nodes is series connection, a newly-built series connection node S(1 again), described series connection node S(1) as the father node of two logic nodes, two logic nodes are increased in its sequence table in order;
If b is increased to described logic node X(1) below, the pass of two logic nodes is in parallel, a more newly-built sys node P(1), described sys node P(1) be the father node of two logic nodes;
Step 2.2: when at described logic node X(1) or described logic node X(2) a upper logic node X(3 in parallel) time, newly-built this logic node X(3) to described logic node X(1) or described logic node X(2) below, delete described logic node X(1) or described logic node X(2), a newly-built sys node P(2 again), described sys node P(2) father node point to described logic node X(1) or described logic node X(2) father node, described sys node P(2) replace described logic node X(1) or described logic node X(2) position, described logic node X(1) or described logic node X(2) together with described logic node X(3) be described sys node P(2) child node,
Step 2.3: repeat 2.1,2.2 steps, set up intermediary tree;
Step 3: generate ladder diagram
From the root node of above-mentioned intermediary tree, travel through whole tree, during traversal, record the coordinate position of each node, and the number of child node that each node comprises, if logic node is first child node of its father node, then inherit the position of its father node; Other child node, if be parallel relationship with father node, then X-coordinate inherits its father node, and Y-coordinate is that the coordinate of a node on it adds 1, if be series relationship with father node, then Y-coordinate inherits its father node, and X-coordinate is that the coordinate of a node on it adds 1; In like manner calculate the position coordinates of other nodes, according to Coordinate generation ladder diagram.
Hinge structure of the present invention has outstanding substantive distinguishing features and marked improvement, and specifically, the present invention is by building the method for intermediary tree, find the contact between each logic node, then by traversal intermediary tree, draw ladder diagram, there is flexible operation, simple advantage.
Accompanying drawing explanation
Fig. 1 is the intermediary tree structural drawing of a situation in step 2.1 of the present invention.
Fig. 2 is the intermediary tree structural drawing of b situation in step 2.1 of the present invention.
Fig. 3 is the intermediary tree structural drawing in step 2.2 of the present invention.
Fig. 4 is the intermediary tree structural drawing in step 2.3 of the present invention.
Embodiment
Below by embodiment, technical scheme of the present invention is described in further detail.
As shown in Figure 1,1, a kind of trapezoidal map generalization method of PLC based on generator set controller, it comprises the following steps:
Step 1: the type of definition intermediary tree node, described intermediary tree node comprises leaf node X, series connection node S and sys node P, described leaf node X is logic node switching value in ladder diagram, and described series connection node S and sys node P is the father node of logic node in ladder diagram; Definition logical node type, wherein, logic node represents the particular content of each node on ladder diagram;
Step 2: build intermediary tree, realized by following steps:
Step 2.1: drag a logic node on interface, if interface only has a logic node, the logic node X1 of the newly-built node that is that it doesn't matter, then increase new logic node X2;
If a is increased to before described logic node X1 or below, the pass of two logic nodes is series connection, a newly-built series connection node S1 again, described series connection node S1 is as the father node of two logic nodes, be increased in its sequence table in order by two logic nodes, now intermediary tree structure as shown in Figure 1;
If b is increased to the below of described logic node X1, the pass of two logic nodes is in parallel, more newly-built a sys node P1, described sys node P1 are the father node of two logic nodes, and now intermediary tree structure as shown in Figure 2;
Step 2.2: when on described logic node X2 during a logic node X3 in parallel, the below of newly-built this logic node X3 to described logic node X2, delete described logic node X2, a newly-built sys node P2 again, the father node of described sys node P2 points to the father node of described logic node X2, i.e. series connection node S1, described sys node P2 replaces the position of described logic node X2, described logic node X2 is the child node of described sys node P2 together with described logic node X3, and this time tree construction as shown in Figure 3;
Step 2.3: repeat 2.1,2.2 steps, set up intermediary tree, now intermediary tree structure as shown in Figure 4;
Step 3: generate ladder diagram
From the root node of above-mentioned intermediary tree, travel through whole tree, during traversal, record the coordinate position of each node, and the number of child node that each node comprises; Position coordinates as root node S1 is (0,0), if logic node is first child node of its father node, then inherits the position of its father node; , so P3 node inherits the position (0,0) of S1 node, X1 inherits the position (0,0) of P3; Other child node, as X2, X3, X4, X5, X6, if be parallel relationship with father node, then X-coordinate inherits its father node, Y-coordinate is that the coordinate of a node on it adds 1, if be series relationship with father node, then Y-coordinate inherits its father node, X-coordinate is that the coordinate of a node on it adds 1, that is, the coordinate position of X2 is (0,1), the coordinate position of X3 is (1,0), the coordinate position of X4 is (2,0), the coordinate position of X5 is (2,1), the coordinate position of X6 is (2,2), ladder diagram can be generated according to the coordinate position of record.
Finally should be noted that: above embodiment is only in order to illustrate that technical scheme of the present invention is not intended to limit; Although with reference to preferred embodiment to invention has been detailed description, those of ordinary skill in the field are to be understood that: still can modify to the specific embodiment of the present invention or carry out equivalent replacement to portion of techniques feature; And not departing from the spirit of technical solution of the present invention, it all should be encompassed in the middle of the technical scheme scope of request of the present invention protection.