CN112596918A - Method for sharing variable between programs in system and storage device - Google Patents
Method for sharing variable between programs in system and storage device Download PDFInfo
- Publication number
- CN112596918A CN112596918A CN202011414290.6A CN202011414290A CN112596918A CN 112596918 A CN112596918 A CN 112596918A CN 202011414290 A CN202011414290 A CN 202011414290A CN 112596918 A CN112596918 A CN 112596918A
- Authority
- CN
- China
- Prior art keywords
- data
- address
- variable
- database
- main program
- 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
- 238000000034 method Methods 0.000 title claims abstract description 28
- 238000013507 mapping Methods 0.000 claims abstract description 43
- 238000012423 maintenance Methods 0.000 abstract description 8
- 230000007246 mechanism Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 230000009471 action Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000011022 operating instruction Methods 0.000 description 2
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention provides a method for sharing variables among programs in a system, which is characterized in that a main program, a plurality of auxiliary programs and a database are stored in the system; the method for sharing the variables among the programs in the system comprises the following steps: the main program reads the data address in the database; the main program generates an address-variable mapping file according to the data address and the variable data in the database; reading the address-variable mapping file when the auxiliary program runs to acquire the corresponding relation between the data address and the variable data; the auxiliary program calls the data in the corresponding data address in the database. The method for sharing the variable among the programs in the system has the advantages of high data calling speed, strong stability and convenience in maintenance.
Description
Technical Field
The invention relates to the technical field of AGV device control, in particular to a method for sharing variables among programs in a system and a storage device.
Background
A plurality of control programs are stored in the AGV control mechanism, wherein the AGV control mechanism comprises a main program and an auxiliary program, the main program comprises a core control function, the running data volume is large, the running speed is stable, the read-write limiting level is high, the main program is rarely modified in practical application, the auxiliary program runs independently relative to the main program, the auxiliary program needs to be modified in the practical application according to needs, and the auxiliary program shares data with the main program in the running process so as to reduce the stored data volume.
The traditional shared data between programs is realized by information interaction between two programs, the real-time performance is low, a large amount of CPU resources of a control mechanism are occupied, the efficiency is low, in order to overcome the problems, the prior shared memory technology provides a first address of a shared variable library to an auxiliary program through a main program, the auxiliary program calculates an address by taking the first address as a basis and combining the type of a variable, and then obtains a shared variable mapped by a corresponding address, but the method is only suitable for the condition that the data volume of the shared variable library is relatively fixed, for the condition that a new variable needs to be added into the shared variable library, because the corresponding relation between the address and the variable data is changed after the new variable is inserted, if the auxiliary program keeps searching the variable data by taking the first address as a basis, the correct variable data can not be obtained due to wrong mapping, and therefore the auxiliary program needs to be updated, the new variable interface is redefined, and for a control mechanism provided with a plurality of auxiliary programs, the plurality of auxiliary programs need to be updated, so that the maintenance difficulty is high, and the maintenance cost is high.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a method for sharing variables among programs in a system, which has the advantages of high data calling speed, strong stability and convenience in maintenance.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method for sharing variables among programs in a system, wherein a main program, a plurality of auxiliary programs and a database are stored in the system;
the method for sharing the variables among the programs in the system comprises the following steps:
(1) the main program reads the data address in the database;
(2) the main program generates an address-variable mapping file according to the data address and the variable data in the database;
(3) reading the address-variable mapping file when the auxiliary program runs to acquire the corresponding relation between the data address and the variable data;
(4) the auxiliary program calls the data in the corresponding data address in the database.
Compared with the prior art, the method for sharing the variables among the programs in the system comprises the steps of setting a main program to calculate the address of each variable to be shared according to a data address and variable data when the main program is started each time, writing the corresponding relation of the variables and the addresses into a file output address-variable mapping file for an auxiliary program to read, enabling the auxiliary program to read the address-variable mapping file when the auxiliary program is started each time, obtaining the data address corresponding to each variable, then de-mapping a database to obtain the variable data, namely realizing the same operable memory segment of the main program and the auxiliary program by establishing the corresponding relation of the address (memory address) and the variable in real time, ensuring that the main program is independently upgraded (the variable data is added), and the auxiliary program can also obtain the data after the address is changed according to the address-variable mapping file after the variable address is changed on one hand, therefore, the trouble of updating and maintaining the auxiliary program is saved, the maintenance difficulty and the maintenance cost of the system are reduced, and on the other hand, after the main program is independently updated (variable data is added), the auxiliary program can be normally used even if the variable address is changed, so that the downward compatibility and the communication efficiency are good.
Preferably, the address-variable mapping file is stored on an operating platform where the main program and the auxiliary program are located.
The setting mode can save the trouble that the main program stores the address-variable mapping file into the database, thereby being convenient for the main program to produce or modify the address-variable mapping file.
Preferably, step (1) to step (4) are performed once every time the system is turned on.
The system start is used as a trigger action of the main program for generating the address-variable mapping file and the auxiliary program for reading the address-variable mapping file, so that the increase of program operation amount and operation load caused by the frequent generation of the address-variable mapping file by the main program and the frequent reading of the address-variable mapping file by the auxiliary program are avoided.
Preferably, a plurality of variable data are recorded into the database through the main program, and the newly recorded variable data are sequentially stored into a plurality of continuous data addresses.
Because the data addresses corresponding to the input variable data are continuous, the setting mode can facilitate the main program to generate an address-variable mapping file according to the data addresses and the variable data, and the operation amount of the main program is reduced.
Preferably, in step (2), the main program calculates a data address corresponding to the variable data according to the data head address and the input variable type, and generates an address-variable mapping file.
Another object of the present invention is to provide a storage device, which stores the operating instructions of the method for sharing variables among programs in the above system, the instructions being suitable for a processor of a computer to load and execute the following operations:
(A1) loading instructions for the main program and the auxiliary program;
(A2) the main program reads the data address in the database;
(A3) the main program generates an address-variable mapping file according to the data address and the variable data in the database;
(A4) reading the address-variable mapping file when the auxiliary program runs to acquire the corresponding relation between the data address and the variable data;
(A5) the auxiliary program calls the data in the corresponding data address in the database.
Compared with the prior art, the storage device stores the running instruction of the method for sharing the variable among the programs in the system, and the running instruction is suitable for being loaded and executed by the processor of the computer, so that the method for sharing the variable among the programs in the system is convenient to popularize and use.
Drawings
FIG. 1 is a schematic view of the present invention;
fig. 2 is a flow chart of the present invention.
Detailed Description
Embodiments of the present invention are described below with reference to the accompanying drawings:
example one
Referring to fig. 1 to 2, in the method for sharing variables among programs in the system according to the present embodiment, a main program, a plurality of auxiliary programs, and a database are stored in the system, an entity structure related to the system includes an operation module and a memory, the operation module is in communication with the memory, an operation platform is stored in the operation module, the main program and the auxiliary programs are operated on the operation platform, the database is stored in the memory, and a shared variable list including data addresses and variable data is stored in the database.
The method for sharing the variables among the programs in the system comprises the following steps:
(1) the main program reads the data address in the database;
(2) the main program generates an address-variable mapping file according to the data address and the variable data in the database;
(3) reading the address-variable mapping file when the auxiliary program runs to acquire the corresponding relation between the data address and the variable data;
(4) the auxiliary program calls the data in the corresponding data address in the database.
And the address-variable mapping file is stored on the running platform where the main program and the auxiliary program are located.
The setting mode can save the trouble that the main program stores the address-variable mapping file into the database, thereby being convenient for the main program to produce or modify the address-variable mapping file.
And (4) executing the steps (1) to (4) once when the system is started every time.
The system start is used as a trigger action of the main program for generating the address-variable mapping file and the auxiliary program for reading the address-variable mapping file, so that the increase of program operation amount and operation load caused by the frequent generation of the address-variable mapping file by the main program and the frequent reading of the address-variable mapping file by the auxiliary program are avoided.
And inputting a plurality of variable data into the database through the main program, and sequentially storing the newly input variable data into a plurality of continuous data addresses.
Because the data addresses corresponding to the input variable data are continuous, the setting mode can facilitate the main program to generate an address-variable mapping file according to the data addresses and the variable data, and the operation amount of the main program is reduced.
In the step (2), the main program calculates a data address corresponding to the variable data according to the data head address and the input variable type, and generates an address-variable mapping file.
In this embodiment, the auxiliary program may not only call the data in the database, but also modify the data in the database, that is, the main program and the auxiliary program can both read and write the memory segment from and into the database.
Compared with the prior art, the method for sharing the variables among the programs in the system comprises the steps of setting a main program to calculate the address of each variable to be shared according to a data address and variable data when the main program is started each time, writing the corresponding relation of the variables and the addresses into a file output address-variable mapping file for an auxiliary program to read, enabling the auxiliary program to read the address-variable mapping file when the auxiliary program is started each time, obtaining the data address corresponding to each variable, then de-mapping a database to obtain the variable data, namely realizing the same operable memory segment of the main program and the auxiliary program by establishing the corresponding relation of the address (memory address) and the variable in real time, ensuring that the main program is independently upgraded (the variable data is added), and the auxiliary program can also obtain the data after the address is changed according to the address-variable mapping file after the variable address is changed on one hand, therefore, the trouble of updating and maintaining the auxiliary program is saved, the maintenance difficulty and the maintenance cost of the system are reduced, and on the other hand, after the main program is independently updated (variable data is added), the auxiliary program can be normally used even if the variable address is changed, so that the downward compatibility and the communication efficiency are good.
Example two
Another object of the present invention is to provide a storage device, which stores the operating instructions of the method for sharing variables among programs in the above system, the instructions being suitable for a processor of a computer to load and execute the following operations:
(A1) loading instructions for the main program and the auxiliary program;
(A2) the main program reads the data address in the database;
(A3) the main program generates an address-variable mapping file according to the data address and the variable data in the database;
(A4) reading the address-variable mapping file when the auxiliary program runs to acquire the corresponding relation between the data address and the variable data;
(A5) the auxiliary program calls the data in the corresponding data address in the database.
Compared with the prior art, the storage device stores the running instruction of the method for sharing the variable among the programs in the system, and the running instruction is suitable for being loaded and executed by the processor of the computer, so that the method for sharing the variable among the programs in the system is convenient to popularize and use.
Variations and modifications to the above-described embodiments may occur to those skilled in the art, which fall within the scope and spirit of the above description. Therefore, the present invention is not limited to the specific embodiments disclosed and described above, and some modifications and variations of the present invention should fall within the scope of the claims of the present invention. Furthermore, although specific terms are employed herein, they are used in a generic and descriptive sense only and not for purposes of limitation.
Claims (6)
1. The method for sharing variables among programs in the system is characterized in that a main program, a plurality of auxiliary programs and a database are stored in the system;
the method for sharing the variables among the programs in the system comprises the following steps:
(1) the main program reads the data address in the database;
(2) the main program generates an address-variable mapping file according to the data address and the variable data in the database;
(3) reading the address-variable mapping file when the auxiliary program runs to acquire the corresponding relation between the data address and the variable data;
(4) the auxiliary program calls the data in the corresponding data address in the database.
2. The method of claim 1, wherein the address-to-variable mapping file is stored on a running platform where the main program and the auxiliary program are located.
3. The method of claim 1, wherein the steps (1) to (4) are performed each time the system is turned on.
4. A method for sharing variables between programs in a system according to any one of claims 1 to 3, wherein a plurality of variable data are entered into the database by the main program, and the newly entered plurality of variable data are sequentially stored in a plurality of consecutive data addresses.
5. The method of claim 4, wherein in step (2), the main program calculates a data address corresponding to the variable data according to the data head address and the input variable type, and generates an address-to-variable mapping file.
6. Storage means storing instructions for the execution of a method for sharing variables between programs in a system according to any one of claims 1 to 5, said instructions being adapted to be loaded by a processor of a computer and to perform the following operations:
(A1) loading instructions for the main program and the auxiliary program;
(A2) the main program reads the data address in the database;
(A3) the main program generates an address-variable mapping file according to the data address and the variable data in the database;
(A4) reading the address-variable mapping file when the auxiliary program runs to acquire the corresponding relation between the data address and the variable data;
(A5) the auxiliary program calls the data in the corresponding data address in the database.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011414290.6A CN112596918B (en) | 2020-12-04 | 2020-12-04 | Method and memory device for sharing variable among programs in system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011414290.6A CN112596918B (en) | 2020-12-04 | 2020-12-04 | Method and memory device for sharing variable among programs in system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112596918A true CN112596918A (en) | 2021-04-02 |
CN112596918B CN112596918B (en) | 2024-08-09 |
Family
ID=75188508
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011414290.6A Active CN112596918B (en) | 2020-12-04 | 2020-12-04 | Method and memory device for sharing variable among programs in system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112596918B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113848815A (en) * | 2021-08-27 | 2021-12-28 | 苏州谷夫道自动化科技有限公司 | Method and system for sharing PLC (programmable logic controller) program of multi-channel numerical control system |
WO2023039763A1 (en) * | 2021-09-15 | 2023-03-23 | Abb Schweiz Ag | Configuration of automated guided vehicles |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH06243106A (en) * | 1993-02-16 | 1994-09-02 | Yokogawa Electric Corp | Computer device |
CN104881330A (en) * | 2015-05-22 | 2015-09-02 | 大唐移动通信设备有限公司 | Multi-process data sharing method and device |
CN110249274A (en) * | 2017-04-27 | 2019-09-17 | 株式会社日立产机系统 | The data sharing method of industrial controller and industrial controller |
CN111679590A (en) * | 2020-05-14 | 2020-09-18 | 华北电力大学 | Semi-physical simulation platform and method suitable for industrial control safety test |
-
2020
- 2020-12-04 CN CN202011414290.6A patent/CN112596918B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH06243106A (en) * | 1993-02-16 | 1994-09-02 | Yokogawa Electric Corp | Computer device |
CN104881330A (en) * | 2015-05-22 | 2015-09-02 | 大唐移动通信设备有限公司 | Multi-process data sharing method and device |
CN110249274A (en) * | 2017-04-27 | 2019-09-17 | 株式会社日立产机系统 | The data sharing method of industrial controller and industrial controller |
CN111679590A (en) * | 2020-05-14 | 2020-09-18 | 华北电力大学 | Semi-physical simulation platform and method suitable for industrial control safety test |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113848815A (en) * | 2021-08-27 | 2021-12-28 | 苏州谷夫道自动化科技有限公司 | Method and system for sharing PLC (programmable logic controller) program of multi-channel numerical control system |
WO2023039763A1 (en) * | 2021-09-15 | 2023-03-23 | Abb Schweiz Ag | Configuration of automated guided vehicles |
Also Published As
Publication number | Publication date |
---|---|
CN112596918B (en) | 2024-08-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112596918A (en) | Method for sharing variable between programs in system and storage device | |
CN110941395A (en) | Dynamic random access memory, memory management method, system and storage medium | |
CN102567033B (en) | Based on kind loading method in advance and the device of embedded real-time Java virtual machine | |
CN111267111B (en) | Robot control method, device and system | |
CN112650539A (en) | Dynamic link operation supporting method for heterogeneous many-core processor | |
CN111291022B (en) | Data storage system based on block chain | |
CN103513956A (en) | Data processing method and device of processor | |
CN114416031A (en) | Operating system for supporting RISC-V processor facing AIoT scene | |
CN116775507B (en) | Hardware acceleration block selection method and device in garbage collection of solid state disk controller | |
CN100472469C (en) | Operation logbook obtaining method | |
CN113608925A (en) | Data backup method and system based on continuous data protection CDP protocol | |
CN113064895A (en) | Incremental updating method, device and system for map | |
CN116483643A (en) | GPU debugging method, device, equipment and storage medium | |
US20180321932A1 (en) | Method, device and related system for dynamically repairing application | |
CN117149209A (en) | Code increment compiling method and device, computer equipment and storage medium | |
CN111309740A (en) | Data processing method, device, equipment and storage medium | |
CN110750579A (en) | Efficient memory distribution method and system for cloud database Redis | |
CN114968307A (en) | Control program updating method, terminal device and storage medium | |
CN112035380B (en) | Data processing method, device and equipment and readable storage medium | |
CN100492299C (en) | Embedded software developing method and system | |
JPH10240546A (en) | Execution time program translation method | |
CN113805854A (en) | Method, system and device for realizing Hook of application layer based on Linux system and storage medium | |
JP2003022182A (en) | Controller | |
CN114003491B (en) | Test equipment parameter modification method and device, electronic equipment and storage medium | |
CN112860301B (en) | Method for using bootloader interrupt function by app and single chip microcomputer |
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 |