CN110471862A - A kind of the address of variable distribution system and method for programmable controller - Google Patents

A kind of the address of variable distribution system and method for programmable controller Download PDF

Info

Publication number
CN110471862A
CN110471862A CN201910639664.5A CN201910639664A CN110471862A CN 110471862 A CN110471862 A CN 110471862A CN 201910639664 A CN201910639664 A CN 201910639664A CN 110471862 A CN110471862 A CN 110471862A
Authority
CN
China
Prior art keywords
variable
memory
address
queue
memory fragmentation
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.)
Pending
Application number
CN201910639664.5A
Other languages
Chinese (zh)
Inventor
邬惠峰
严义
陈佰平
赵建勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Dianzi University
Hangzhou Electronic Science and Technology University
Original Assignee
Hangzhou Electronic Science and Technology University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hangzhou Electronic Science and Technology University filed Critical Hangzhou Electronic Science and Technology University
Priority to CN201910639664.5A priority Critical patent/CN110471862A/en
Publication of CN110471862A publication Critical patent/CN110471862A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • G06F12/0261Garbage collection, i.e. reclamation of unreferenced memory using reference counting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0844Multiple simultaneous or quasi-simultaneous cache accessing
    • G06F12/0846Cache with multiple tag or data arrays being simultaneously accessible

Abstract

The present invention provides the address of variable distribution systems and method of a kind of programmable controller, are related to field of automation technology.Zoning unit, for carrying out subregion to the region of memory of programmable controller, each subregion at least corresponds to a kind of storage class according to storage class;Memory Allocation unit is used for according to types of variables, to the direct storage allocation address of the variable of known fixed address;It to the variable of unknown address according to committed memory size, is ranked up from big to small, variable queue is created according to the result of sequence;Meanwhile all memory fragmentation spaces being ranked up from small to large according to amount of capacity;Cephalomere point variable is chosen from variable queue;Memory fragmentation space is ranked up according to amount of capacity, one is successively selected from all memory fragmentation spaces from small to large, the memory fragmentation space size of selection places cephalomere point variable enough, and in all memory fragmentation spaces that can place the cephalomere point variable, the memory fragmentation space size of the selection is minimum.

Description

A kind of the address of variable distribution system and method for programmable controller
Technical field
The present invention relates to field of automation technology, in particular to the address of variable distribution system of a kind of programmable controller and Method.
Background technique
Programmable controller (PLC) is widely applied in world's automatic field.As more and more PLC manufacturers occur, The demand for cooperating, mutually transplanting is needed significantly to increase between the PLC of each manufacturer, a PLC programming language clearly standardized It is very important for speech standard.IEC61131-3 standard is to formulate 61131 standard of IEC by International Electrotechnical Commission (IEC) Third portion, the programming language specification for specification PLC.So that the PLC program between each manufacturer is easier transplanting mutually, mutually It is mutually compatible.
Input, output or memory in the variable and equipment of programmable controller is interrelated, by variable expression, Its position mapped in memory space can be calculated, this is the variable and conventional programming language variable of programmable controller Maximum difference.So the variable of programmable controller can not be as conventional compiler, by system automatically global static Distribute address in area, heap area or stack area, but will according in variable expression data type and direct expression quantity calculate its Address in memory, and variable name and memory address are mapped.But IEC61131-3 standard criterion variable expression Definition format, it is specified that describe position of the variable in memory address using direct expression quantity, but how to be reflected without description variable It is mapped to the memory address of programmable controller, and the pass of this mapping relations exactly IEC61131-3 standard related software research and development One of key point and difficult point.
A kind of configuration mode of PLC address of variable is described in the patent of Patent No. CN201510559212.8.Its skill Art scheme, which specifically includes that, sets timing bench, for the configuration variables address in allocation list, forms the address a PLC configuration, In, which is stored in relational database;Open source Driver Library, for establishing connection with PLC, and according to the variable in allocation list Plc data is read by byte in address;Component when operation, for passing through Driver Library of increasing income according to the configuration for setting timing bench formation Plc data is obtained from PLC, and is stored into database.Invention uses the default port of SIEMENS PLC, is assisted by TCP/IP View is established SCOKET with PLC and is connect, and user need to only configure the data of reading, and system can define phase in the database automatically Table or label are closed, and is stored the data in database, installation third party software is not needed.
But in the technical solution of patent description, still not addressing how will be in variable mappings to programmable controller Deposit address.
Summary of the invention
The present invention provides the address of variable distribution system and method for a kind of programmable controller, to establish PLC technology Mapping ruler between the variable and region of memory of device, meanwhile, propose that a kind of improved memory allocation algorithm is used for programmable control The Memory Allocation of device variable processed.Adaptable wide and high memory usage advantage.
To achieve the goals above, technical solution used in the embodiment of the present invention is as follows:
A kind of address of variable distribution system of programmable controller, the system comprises:
Zoning unit, for carrying out subregion to the region of memory of programmable controller, each subregion is extremely according to types of variables A kind of types of variables is corresponded to less;
Memory Allocation unit is used for according to types of variables, to the direct storage allocation address of the variable of known fixed address;It is right The variable of unknown address is ranked up from big to small according to committed memory size, creates variable queue according to the result of sequence;Together When, by all memory fragmentation spaces according to amount of capacity, it is ranked up from small to large;Head node is chosen from variable queue to become Amount;Memory fragmentation space is ranked up according to amount of capacity, is successively selected from all memory fragmentation spaces from small to large One, the memory fragmentation space size of selection places cephalomere point variable enough, and can place all of the cephalomere point variable In memory fragmentation space, the memory fragmentation space size of the selection is minimum.
Further, the Memory Allocation unit includes: variables reordering unit, for by the variable of unknown address according to accounting for It with memory size, is ranked up from big to small, while variable queue is created according to the result of sequence;Memory fragmentation spatial classification list Member, for being ranked up according to amount of capacity to memory fragmentation space, from small to large successively from all memory fragmentation spaces Selection one, the memory fragmentation space size of selection places cephalomere point variable enough, and can place the cephalomere point variable In all memory fragmentation spaces, the memory fragmentation space size of the selection is minimum;
First judging unit, for judging in all memory fragmentation spaces, if can find and place the head node The memory fragmentation space of variable;If the memory fragmentation space that can place the cephalomere point variable can not be found, memory is recorded Insufficient error message terminates address of variable distribution;If finding the memory fragmentation space that can place the cephalomere point variable, From the variable queue of creation, cephalomere point variable is removed;
Whether second judgment unit, judgment variable queue are empty;If variable queue is sky, terminate address of variable point Match;If variable queue is not sky, sends a command to variables reordering unit and re-start inclined address of variable distribution.
Further, the region of memory of programmable controller is divided into following subregion: input area by the zoning unit, The interface variables of outer signals are received for storing associate device;Output area, for storing associate device output signal variable;It is auxiliary Area is helped, for storing the cached variable during programmable controller carries out programming;Digital block: it can be compiled for storing storage Various numeric type variables in range controller program;Counter area is used for memory counter variable;Timer area, it is fixed for storing When device variable.
Further, the mapping ruler between variable and the subregion of region of memory is specific as follows: being for data type The variable of BOOL type, if defining direct expression quantity, according to its address prefix Choose for user to input area, output area or auxiliary Area is helped, if being mapped to auxiliary region without direct expression quantity;For numeric type variable, if defining direct expression quantity, According to its address prefix Choose for user to input area, output area or auxiliary region;If being mapped to data without direct expression quantity Area;Data type is that the variable counted is mapped to counter area regardless of whether defining direct expression quantity;Data type is fixed When device variable be mapped to timer area regardless of whether there is direct expression quantity.
A kind of address of variable distribution method of programmable controller, which comprises
Step 1: according to types of variables, subregion being carried out to the region of memory of programmable controller, each subregion is at least corresponding A kind of types of variables;
Step 2: by the variable of unknown address according to committed memory size, being ranked up from big to small, while according to sequence Result create variable queue;
Step 3: by the variable storage allocation address of known fixed address;All memory fragmentation spaces is big according to capacity It is small, it is ranked up from small to large;Cephalomere point variable is chosen from variable queue;
Step 4: according to step 3 according to amount of capacity to the ranking results in memory fragmentation space, from small to large successively from institute One is selected in some memory fragmentation spaces, the memory fragmentation space size of selection places cephalomere point variable enough, and can It places in all memory fragmentation spaces of the cephalomere point variable, the memory fragmentation space size of the selection is minimum;
Step 5: judging in all memory fragmentation spaces, if can find place the cephalomere point variable memory it is broken Piece space;If the memory fragmentation space that can place the cephalomere point variable can not be found, 6 are thened follow the steps;If finding energy The memory fragmentation space for enough placing the cephalomere point variable then jumps and executes step 7;
Step 6: recording the error message of low memory, jump and execute step 9;
Step 7: from the variable queue created in step 2, removing cephalomere point variable;
Step 8: whether judgment variable queue is empty;If variable queue is sky, 9 are thened follow the steps;If variable queue It is not sky, then jumps to step 2;
Step 9: terminating address of variable distribution.
Further, the method also includes: after having carried out step 1, construct the preferential distribution queue of variable, due to each Variable assigning process between region of memory is mutually indepedent, and variable is grouped according to region of memory.Each region of memory Variable is divided into following 3 class according to the content of direct expression quantity: the first class variable has direct expression quantity, and specifies specific Address offset amount preferentially distributes the first class variable;Second class variable has direct expression quantity, but does not specify specific address Offset, but part has been used to determine address character;Third class variable does not have direct expression quantity;It is individually created for the first class variable First queue, the variable in queue do not have to sequence;Second class variable and third class variable after it confirmed region of memory, they Between it is no longer distinct, so for they create second queues, by variable by its in memory occupied space length from greatly to It is small to be inserted into queue.
Further, the method also includes: after constructing the preferential distribution queue of variable, construct memory management chained list, In Before variable storage allocation, each region of memory is divided into according to current device memory and initializes one by its memory length Chained list;The node elements of chained list are a binary variable groups, are respectively the first variable and the second variable comprising two variables;First Variable indicates location index of the memory address in this region of memory of node on behalf;Second variable represents current memory node quilt Which program organization unit occupies, and the initial value of the first variable, which is set as -1, -1, indicates that the memory node is also not used by.
The address of variable distribution system and method for a kind of programmable controller provided in an embodiment of the present invention have with following Beneficial effect: can be adapted for variable without using direct expression quantity, or has used direct expression quantity but do not specified address inclined The case where shifting amount;Meanwhile the optimal adaptation algorithm based on Priority Queues is devised for storage allocation address, use Priority Queues The variable of not direct specified memory offset address is sorted by EMS memory occupation size, the big change in priority processing committed memory space Amount makes each allocation result reach really best.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification It obtains it is clear that understand through the implementation of the invention.The objectives and other advantages of the invention can be by written explanation Specifically noted structure is achieved and obtained in book, claims and attached drawing.
Below by drawings and examples, technical scheme of the present invention will be described in further detail.
Detailed description of the invention
Attached drawing is used to provide further understanding of the present invention, and constitutes part of specification, with reality of the invention It applies example to be used to explain the present invention together, not be construed as limiting the invention.In the accompanying drawings:
Fig. 1 is the method flow schematic diagram of the address of variable distribution method of programmable controller in the embodiment of the present invention.
Fig. 2 is direct expression quantity character definition schematic diagram in the embodiment of the present invention.
Fig. 3 is variable and region of memory mapping table in the embodiment of the present invention.
Between optimal adaptation algorithm of the Fig. 4 for optimal adaptation algorithm traditional in the embodiment of the present invention and based on Priority Queues Contrast schematic diagram.
Fig. 5 is the schematic diagram in fixing address variable storage allocation space in the embodiment of the present invention.
Fig. 6 is the schematic diagram in unknown address variable storage allocation space in the embodiment of the present invention.
Specific embodiment
Hereinafter, preferred embodiments of the present invention will be described with reference to the accompanying drawings, it should be understood that preferred reality described herein Apply example only for the purpose of illustrating and explaining the present invention and is not intended to limit the present invention.
The embodiment of the invention provides a kind of address of variable distribution system of programmable controller, the system comprises:
Zoning unit, for carrying out subregion to the region of memory of programmable controller, each subregion is extremely according to storage class A kind of storage class is corresponded to less;
Memory Allocation unit is used for according to types of variables, to the direct storage allocation address of the variable of known fixed address;It is right The variable of unknown address is ranked up from big to small according to committed memory size, creates variable queue according to the result of sequence;Together When, by all memory fragmentation spaces according to amount of capacity, it is ranked up from small to large;Head node is chosen from variable queue to become Amount;Memory fragmentation space is ranked up according to amount of capacity, is successively selected from all memory fragmentation spaces from small to large One, the memory fragmentation space size of selection places cephalomere point variable enough, and can place all of the cephalomere point variable In memory fragmentation space, the memory fragmentation space size of the selection is minimum.
The working principle of above-mentioned technical proposal are as follows: according to the direct expression quantity for describing address of variable part in standard, to can Programmable controller device memory is divided, and is formulated variable to the mapping ruler of memory, is divided for unaddressed Variational Design address With algorithm.
Above-mentioned technical proposal has the beneficial effect that in computer field, and Memory Allocation mode is divided into direct specific mode, quiet State Memory Allocation mode and dynamic memory distribution mode.The variable method of salary distribution of PLC belongs to direct specific mode, i.e. program is being compiled The capacity of memory and the allocation rule of memory have been known before translating, when programming or program compile, variable uses It is physical memory address.IEC61131-3 standard advises user when for variable specified memory address, is come using direct expression quantity The address of variable is described.But standard also allows variable without using direct expression quantity, or has used direct expression quantity but not There is specified address offset amount, these variables can not directly predict its true address.The variable of these unknown address cannot be by tradition Computer variable is assigned to static memory area by the static memory method of salary distribution like that, can not distribute by dynamic memory distribution mode Into heap or stack, but need to design a memory address allocation rule, In by the thinking of Dynamic Memory Allocating Arithmetic for them A specified memory address is distributed for them before compiling, so the Memory Allocation mode of programmable controller variable is to combine The direct specific mode of memory allocation algorithm.Therefore address allocation system and method for the invention can be adapted for directly predicting The case where variable of its true address.
In one embodiment, the Memory Allocation unit includes: variables reordering unit, for by the variable of unknown address It according to committed memory size, is ranked up from big to small, while variable queue is created according to the result of sequence;Memory fragmentation space Sequencing unit, for being ranked up according to amount of capacity to memory fragmentation space, from small to large successively from all memory fragmentations One is selected in space, the memory fragmentation space size of selection places cephalomere point variable enough, and can place the head node In all memory fragmentation spaces of variable, the memory fragmentation space size of the selection is minimum;
First judging unit, for judging in all memory fragmentation spaces, if can find and place the head node The memory fragmentation space of variable;If the memory fragmentation space that can place the cephalomere point variable can not be found, memory is recorded Insufficient error message terminates address of variable distribution;If finding the memory fragmentation space that can place the cephalomere point variable, From the variable queue of creation, cephalomere point variable is removed;
Whether second judgment unit, judgment variable queue are empty;If variable queue is sky, terminate address of variable point Match;If variable queue is not sky, sends a command to variables reordering unit and re-start inclined address of variable distribution.
The working principle of above-mentioned technical proposal are as follows: variable is assigned to memory fragmentation space.
Having the beneficial effect that for above-mentioned technical proposal can guarantee that the utilization rate of memory maximizes.
In one embodiment, the region of memory of programmable controller is divided into following subregion by the zoning unit: Input area receives the interface variables of outer signals for storing associate device;Output area, for storing associate device output signal Variable;Auxiliary region, for storing the cached variable during programmable controller carries out programming;Digital block: for storing Store various numeric type variables in programmable controller program;Counter area is used for memory counter variable;Timer area uses In storage timer variable.
The working principle of above-mentioned technical proposal are as follows: according to the difference of variable storage type, distribute different regions and deposited Storage.
Having the beneficial effect that for above-mentioned technical proposal improves the efficiency of distribution variable.
In one embodiment, the mapping ruler between variable and the subregion of region of memory is specific as follows: for data class Type is the variable of BOOL type, if defining direct expression quantity, according to its address prefix Choose for user to input area, output area Or auxiliary region, if being mapped to auxiliary region without direct expression quantity;For numeric type variable, if defining direct expression Amount, then according to its address prefix Choose for user to input area, output area or auxiliary region;If mapped without direct expression quantity To data field;Data type is that the variable counted is mapped to counter area regardless of whether defining direct expression quantity;Data class Type is the variable of timer, regardless of whether there is direct expression quantity, is mapped to timer area.
The working principle of above-mentioned technical proposal are as follows: establish mapping ruler, guarantee that the distribution of variable meets established rule.
Above-mentioned technical proposal has the beneficial effect that the case where being not in variable assignment error.
The embodiment of the invention also provides a kind of address of variable distribution methods of programmable controller, which comprises
Step 1: according to types of variables, subregion being carried out to the region of memory of programmable controller, each subregion is at least corresponding A kind of types of variables;
Step 2: by the variable of unknown address according to committed memory size, being ranked up from big to small, while according to sequence Result create variable queue;
Step 3: by the variable storage allocation address of known fixed address;All memory fragmentation spaces is big according to capacity It is small, it is ranked up from small to large;Cephalomere point variable is chosen from variable queue;
Step 4: according to step 3 according to amount of capacity to the ranking results in memory fragmentation space, from small to large successively from institute One is selected in some memory fragmentation spaces, the memory fragmentation space size of selection places cephalomere point variable enough, and can It places in all memory fragmentation spaces of the cephalomere point variable, the memory fragmentation space size of the selection is minimum;
Step 5: judging in all memory fragmentation spaces, if can find place the cephalomere point variable memory it is broken Piece space;If the memory fragmentation space that can place the cephalomere point variable can not be found, 6 are thened follow the steps;If finding energy The memory fragmentation space for enough placing the cephalomere point variable then jumps and executes step 7;
Step 6: recording the error message of low memory, jump and execute step 9;
Step 7: from the variable queue created in step 2, removing cephalomere point variable;
Step 8: whether judgment variable queue is empty;If variable queue is sky, 9 are thened follow the steps;If variable queue It is not sky, then jumps to step 2;
Step 9: terminating address of variable distribution.
The working principle of above-mentioned technical proposal are as follows: improved on the basis of classical optimal adaptation algorithm, devise base It is used to storage allocation address in the optimal adaptation algorithm of Priority Queues, it will be without direct specified memory offset ground using Priority Queues The variable of location sorts by EMS memory occupation size, and the big variable in priority processing committed memory space makes each allocation result reach true Positive is best.It is preferably to occupy the maximum change of length using the optimal adaptation algorithm based on Priority Queues shown on the right of Fig. 3 C storage allocation address 0~3 is measured, variable B and A are then reprocessed.
Above-mentioned technical proposal has the beneficial effect that the Memory Allocation effect being optimal.
In a upper embodiment, the method also includes: after having carried out step 1, the preferential distribution queue of variable is constructed, by Variable assigning process between each region of memory is mutually indepedent, and variable is grouped according to region of memory.Each memory The variable in region is divided into following 3 class according to the content of direct expression quantity: the first class variable has direct expression quantity, and specifies Specific address offset amount, preferentially distributes the first class variable;Second class variable has direct expression quantity, but without specified specific Address offset amount, but used part determine address character;Third class variable does not have direct expression quantity;For the first class variable list First queue is built in original creation, and the variable in queue does not have to sequence;Second class variable and third class variable confirmed region of memory it Afterwards, no longer distinct between them, so creating second queue for them, variable is pressed into its occupied space length in memory It is inserted into queue from big to small.
The working principle of above-mentioned technical proposal are as follows: variable distribution is guaranteed accurately and quickly by grouping.
Having the beneficial effect that for above-mentioned technical proposal improves the efficiency of variable distribution.
In a upper embodiment, the method also includes: after constructing the preferential distribution queue of variable, construct memory management chain Table is divided into each region of memory according to current device memory and initializes by its memory length before for variable storage allocation One chained list;The node elements of chained list are a binary variable groups, are respectively that the first variable and second become comprising two variables Amount;First variable indicates location index of the memory address in this region of memory of node on behalf;Second variable represents currently interior Which deposit node to be occupied by program organization unit, the initial value of the first variable, which is set as -1, -1, indicates that the memory node is not made also With.
The working principle of above-mentioned technical proposal are as follows: because chained list can by be inserted into, delete at high speed, split, merge come Change the length of itself, this advantage is well suited for handling the memory fragmentation generated during Memory Allocation.In for variable distribution Before depositing, each region of memory is divided by the initialization of its memory length one chained list according to current device memory.Chained list Node elements are a binary group<index, value>, index indicates the memory address of node on behalf in the position of this region of memory Set index;Value represents current memory node and is occupied by which POU (program organization unit), and the initial value of value is set as- 1, -1 indicates that the memory node is also not used by.
Above-mentioned technical proposal has the beneficial effect that allocative efficiency is promoted.
The input area of 24 bit length as shown in Figure 5, is indicated with list structure, is first variables A, B, C distribute ground Location, so the 3rd node and node 8~15 are assigned 3 in chained list, produces 3 pieces since current POU ID is 3 later Space junk is node 0~3,5~7 and 16~23 respectively.Memory management linked list array is established for this 3 space junks MemoryLists successively stores memoryList2, memoryList1 for indicating fragment space after sequence inside array And memoryList3.
There are the variable H and BOOL type variables D of SINT type, E, F, G to be directed to the input memory in unallocated variable queue Region, and there is no address offset amount.By the sequence in queue, available space address first is addressed for variable H, in memory fragmentation sky Between in list memoryLists only memoryList3 it is eligible, so variable H is assigned to this space;Later most BOOL type variables D, E and F are sequentially allocated in small space junk memoryList2;Variable G is finally assigned to memory headroom team In the remaining memoryList1 that column only remain, final result is as shown in Figure 6.
In several embodiments provided herein, it should be understood that disclosed device and method can also pass through Other modes are realized.The apparatus embodiments described above are merely exemplary, for example, flow chart and block diagram in attached drawing Show the device of multiple embodiments according to the present invention, the architectural framework in the cards of method and computer program product, Function and operation.In this regard, each box in flowchart or block diagram can represent the one of a unit, program segment or code Part, a part of the unit, program segment or code, which includes that one or more is for implementing the specified logical function, to be held Row instruction.It should also be noted that function marked in the box can also be to be different from some implementations as replacement The sequence marked in attached drawing occurs.For example, two continuous boxes can actually be basically executed in parallel, they are sometimes It can execute in the opposite order, this depends on the function involved.It is also noted that every in block diagram and or flow chart The combination of box in a box and block diagram and or flow chart can use the dedicated base for executing defined function or movement It realizes, or can realize using a combination of dedicated hardware and computer instructions in the system of hardware.
In addition, each functional unit in each embodiment of the present invention can integrate one independent portion of formation together Point, it is also possible to each unit individualism, an independent part can also be integrated to form with two or more units.
It, can be with if the function is realized in the form of SFU software functional unit and when sold or used as an independent product It is stored in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially in other words The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention. And storage medium above-mentioned includes: that USB flash disk, mobile hard disk, read-only memory (ROM, Read-Onl8 Memor8), arbitrary access are deposited The various media that can store program code such as reservoir (RAM, Random Access Memor8), magnetic or disk.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that There is also other identical elements in process, method, article or equipment including the element.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field For art personnel, the invention may be variously modified and varied.All within the spirits and principles of the present invention, made any to repair Change, equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.It should also be noted that similar label and letter exist Similar terms are indicated in following attached drawing, therefore, once being defined in a certain Xiang Yi attached drawing, are then not required in subsequent attached drawing It is further defined and explained.

Claims (7)

1. a kind of address of variable distribution system of programmable controller, which is characterized in that the system comprises:
Zoning unit, for carrying out subregion to the region of memory of programmable controller, each subregion is at least right according to storage class Answer a kind of storage class;
Memory Allocation unit is used for according to types of variables, to the direct storage allocation address of the variable of known fixed address;To unknown The variable of address is ranked up from big to small according to committed memory size, creates variable queue according to the result of sequence;Meanwhile By all memory fragmentation spaces according to amount of capacity, it is ranked up from small to large;Cephalomere point variable is chosen from variable queue; Memory fragmentation space is ranked up according to amount of capacity, successively selects one from all memory fragmentation spaces from small to large A, the memory fragmentation space size of selection places cephalomere point variable enough, and can place all interior of the cephalomere point variable It deposits in fragment space, the memory fragmentation space size of the selection is minimum.
2. the address of variable distribution system of programmable controller as described in claim 1, which is characterized in that the Memory Allocation Unit includes:
Variables reordering unit, for the variable of unknown address according to committed memory size, to be ranked up, while root from big to small Variable queue is created according to the result of sequence;
Memory fragmentation spatial classification unit, for being ranked up according to amount of capacity to memory fragmentation space, from small to large successively One is selected from all memory fragmentation spaces, the memory fragmentation space size of selection places cephalomere point variable enough, and It can place in all memory fragmentation spaces of the cephalomere point variable, the memory fragmentation space size of the selection is minimum;
First judging unit, for judging in all memory fragmentation spaces, if can find and place the cephalomere point variable Memory fragmentation space;If the memory fragmentation space that can place the cephalomere point variable can not be found, low memory is recorded Error message, terminate address of variable distribution;If the memory fragmentation space that can place the cephalomere point variable is found, from wound In the variable queue built, cephalomere point variable is removed;
Whether second judgment unit, judgment variable queue are empty;If variable queue is sky, terminate address of variable distribution;Such as The queue of fruit variable is not sky, then sends a command to variables reordering unit and re-start address of variable distribution.
3. the address of variable distribution system of programmable controller as claimed in claim 2, which is characterized in that the zoning unit The region of memory of programmable controller is divided into following subregion: input area, receives outer signals for storing associate device Interface variables;Output area, for storing associate device output signal variable;Auxiliary region, for store programmable controller into Cached variable in line program programming process;Digital block: become for storing various numeric types in storage programmable controller program Amount;Counter area is used for memory counter variable;Timer area, for storing timer variable.
4. the address of variable distribution system of programmable controller as claimed in claim 3, which is characterized in that variable and memory field Mapping ruler between the subregion in domain is specific as follows: being the variable of BOOL type for data type, if defining direct expression Formula, then according to its address prefix Choose for user to input area, output area or auxiliary region, if mapped without direct expression quantity To auxiliary region;For numeric type variable, if defining direct expression quantity, according to its address prefix Choose for user to input Area, output area or auxiliary region;If being mapped to data field without direct expression quantity;Data type is the variable counted no matter Direct expression quantity whether is defined, counter area is mapped to;Data type is the variable of timer, regardless of whether there is direct expression Amount, is mapped to timer area.
5. a kind of method of the address of variable distribution system of the programmable controller based on one of Claims 1-4, feature exist In, which comprises
Step 1: according to storage class, subregion being carried out to the region of memory of programmable controller, each subregion is at least corresponding a kind of Storage class;
Step 2: by the variable of unknown address according to committed memory size, being ranked up from big to small, while according to the knot of sequence Fruit creates variable queue;
Step 3: by the variable storage allocation address of known fixed address;By all memory fragmentation spaces according to amount of capacity, It is ranked up from small to large;Cephalomere point variable is chosen from variable queue;
Step 4: according to step 3 according to amount of capacity to the ranking results in memory fragmentation space, from small to large successively from all One is selected in memory fragmentation space, the memory fragmentation space size of selection places cephalomere point variable enough, and can place In all memory fragmentation spaces of the cephalomere point variable, the memory fragmentation space size of the selection is minimum;
Step 5: judging in all memory fragmentation spaces, if the memory fragmentation sky for placing the cephalomere point variable can be found Between;If the memory fragmentation space that can place the cephalomere point variable can not be found, 6 are thened follow the steps;If finding can put The memory fragmentation space for setting the cephalomere point variable then jumps and executes step 7;
Step 6: recording the error message of low memory, jump and execute step 9;
Step 7: from the variable queue created in step 2, removing cephalomere point variable;
Step 8: whether judgment variable queue is empty;If variable queue is sky, 9 are thened follow the steps;If variable queue is not Sky then jumps to step 2;
Step 9: terminating address of variable distribution.
6. the address of variable distribution method of programmable controller as claimed in claim 5, which is characterized in that the method is also wrapped It includes: after having carried out step 1, the preferential distribution queue of variable is constructed, due to the variable assigning process phase between each region of memory It is mutually independent, variable is grouped according to region of memory.The variable of each region of memory is divided into according to the content of direct expression quantity 3 class below: the first class variable has direct expression quantity, and specifies specific address offset amount, preferential to the first class variable Distribution;Second class variable has direct expression quantity, but does not specify specific address offset amount, but has used part definitely Location symbol;Third class variable does not have direct expression quantity;First queue is individually created for the first class variable, the variable in queue does not have to row Sequence;Second class variable and third class variable are no longer distinct between them after it confirmed region of memory, so being them Second queue is created, occupied space length is inserted into queue from big to small in memory by it by variable.
7. the address of variable distribution method of programmable controller as claimed in claim 6, which is characterized in that the method is also wrapped It includes: after constructing the preferential distribution queue of variable, memory management chained list is constructed, before for variable storage allocation, according to currently setting Standby memory is divided into the chained list that each region of memory is initialized one by its memory length;The node elements of chained list are a binary Set of variables is respectively the first variable and the second variable comprising two variables;First variable indicates that the memory address of node on behalf exists The location index of this region of memory;Second variable represents current memory node and is occupied by which program organization unit, and first becomes The initial value of amount, which is set as -1, -1, indicates that the memory node is also not used by.
CN201910639664.5A 2019-07-16 2019-07-16 A kind of the address of variable distribution system and method for programmable controller Pending CN110471862A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910639664.5A CN110471862A (en) 2019-07-16 2019-07-16 A kind of the address of variable distribution system and method for programmable controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910639664.5A CN110471862A (en) 2019-07-16 2019-07-16 A kind of the address of variable distribution system and method for programmable controller

Publications (1)

Publication Number Publication Date
CN110471862A true CN110471862A (en) 2019-11-19

Family

ID=68508652

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910639664.5A Pending CN110471862A (en) 2019-07-16 2019-07-16 A kind of the address of variable distribution system and method for programmable controller

Country Status (1)

Country Link
CN (1) CN110471862A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112069198A (en) * 2020-07-16 2020-12-11 中科驭数(北京)科技有限公司 SQL analysis optimization method and device
CN113791596A (en) * 2021-11-15 2021-12-14 西安热工研究院有限公司 Memory hour mean value calculation method, system, equipment and medium based on dynamic application
CN114827143A (en) * 2022-04-11 2022-07-29 广东省离散智造科技创新有限公司 Discrete data acquisition method and system, cloud server and edge computing terminal

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001016657A1 (en) * 1999-08-31 2001-03-08 Digital Electronics Corporation Editor device and recorded medium on which editor program is recorded
CN101853210A (en) * 2010-05-25 2010-10-06 惠州华阳通用电子有限公司 Memory management method and device
CN102043659A (en) * 2010-12-08 2011-05-04 上海交通大学 Compiling device for eliminating memory access conflict and implementation method thereof
CN107368371A (en) * 2017-07-05 2017-11-21 杭州电子科技大学 The programming resource distribution method of Embedded PLC
CN109614040A (en) * 2018-11-26 2019-04-12 武汉烽火信息集成技术有限公司 Storage method, storage medium, electronic equipment and system with more storage pools

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001016657A1 (en) * 1999-08-31 2001-03-08 Digital Electronics Corporation Editor device and recorded medium on which editor program is recorded
CN101853210A (en) * 2010-05-25 2010-10-06 惠州华阳通用电子有限公司 Memory management method and device
CN102043659A (en) * 2010-12-08 2011-05-04 上海交通大学 Compiling device for eliminating memory access conflict and implementation method thereof
CN107368371A (en) * 2017-07-05 2017-11-21 杭州电子科技大学 The programming resource distribution method of Embedded PLC
CN109614040A (en) * 2018-11-26 2019-04-12 武汉烽火信息集成技术有限公司 Storage method, storage medium, electronic equipment and system with more storage pools

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
吴海列: "基于映射模型的风机控制器异构数据解析", 《华电技术》 *
李伟华: "基于IEC61131-3标准的PLC底层开发", 《中国优秀硕士学位论文全文数据库信息科技辑》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112069198A (en) * 2020-07-16 2020-12-11 中科驭数(北京)科技有限公司 SQL analysis optimization method and device
CN113791596A (en) * 2021-11-15 2021-12-14 西安热工研究院有限公司 Memory hour mean value calculation method, system, equipment and medium based on dynamic application
CN114827143A (en) * 2022-04-11 2022-07-29 广东省离散智造科技创新有限公司 Discrete data acquisition method and system, cloud server and edge computing terminal
CN114827143B (en) * 2022-04-11 2023-12-12 广东省离散智造科技创新有限公司 Discrete data acquisition method, system, cloud server and edge computing terminal

Similar Documents

Publication Publication Date Title
CN110471862A (en) A kind of the address of variable distribution system and method for programmable controller
US7526769B2 (en) Message translation and parsing of data structures in a distributed component architecture
CN100468402C (en) Sort data storage and split catalog inquiry method based on catalog tree
CN102541521B (en) Automatic operating instruction generating device based on structured query language and method
CN107547432B (en) A kind of flow control methods and device
CN104035754A (en) XML (Extensible Markup Language)-based custom code generation method and generator
CN105677683A (en) Batch data query method and device
JP6805832B2 (en) Generate multiple worksheet exports
CN105677904B (en) Small documents storage method and device based on distributed file system
CN112817538B (en) Data processing method, device, equipment and storage medium
CN103365786A (en) Data storage method, device and system
CN110515894A (en) A kind of conversion method of data format, device, equipment and readable storage medium storing program for executing
CN102073743A (en) Large-capacity simulation result file storage and access method
CN105389128B (en) A kind of solid state hard disk date storage method and storage control
CN110018794A (en) A kind of rubbish recovering method, device, storage system and readable storage medium storing program for executing
CN104281529A (en) High-capacity RFID (radio frequency identification device) electronic tag dynamic partitioning method as well as electronic tag and application
CN106598548A (en) Solution method and device for read-write conflict of storage unit
CN116662019B (en) Request distribution method and device, storage medium and electronic device
CN103377135A (en) Addressing method, device and system
CN208444289U (en) OTP controller based on piece FLASH memory
CA2731799C (en) Process for representing and handling multigraphs based on the use of bitmaps
US7447555B2 (en) Method for engineering a control system
CN113343045B (en) Data caching method and network equipment
CN104077282A (en) Method and device for processing data
CN112835986B (en) Data processing method, device, equipment and storage medium

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20191119