CN111078420B - Method for calling structure body function in dynamic link library based on LabVIEW - Google Patents
Method for calling structure body function in dynamic link library based on LabVIEW Download PDFInfo
- Publication number
- CN111078420B CN111078420B CN201910970976.4A CN201910970976A CN111078420B CN 111078420 B CN111078420 B CN 111078420B CN 201910970976 A CN201910970976 A CN 201910970976A CN 111078420 B CN111078420 B CN 111078420B
- Authority
- CN
- China
- Prior art keywords
- array
- function
- labview
- structure body
- variable
- 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.)
- Active
Links
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
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/02—Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]
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 relates to the technical field of LabVIEW function call, and particularly discloses a method for calling a function of a structural body in a dynamic link library based on LabVIEW, wherein when the LabVIEW calls the function with the structural body or a structural body pointer in the dynamic link library, whether an array exists in a corresponding structural body variable is further judged, if so, data types outside the array are defined according to a function prototype, then the array meeting decomposition conditions is decomposed and then converted into a corresponding cluster, and other arrays are directly converted into clusters; the defined data types are further bound into a cluster variable in sequence, finally, the parameter types of the cluster variable are set as 'matching to type', the data format is set as 'processing according to values', and the call is ended.
Description
Technical Field
The invention relates to the technical field of LabVIEW function call, in particular to a method for calling a structure function in a dynamic link library based on LabVIEW.
Background
LabVIEW (Laboratory Virtual instrument Engineering Workbench) is a graphical programming language development environment that is widely accepted by industry, academia, and research laboratories as a standard data acquisition and instrumentation control software.
In order to facilitate the combination of external codes, controls for calling a dynamic link library (. Dll.) function are integrated in the LabVIEW, and functions packaged by the external codes can be conveniently used to interact with the external codes and external devices more simply, so that the expandability and usability of LabVIEW programming are remarkably improved.
When using the dynamic link library generated by the C language, since the functions in the C language use concepts such as pointers and structures more frequently, and the corresponding LabVIEW language does not involve functions created by pointers and structures, how to interact with dll of the parameters generated by the C language with functions of pointers or structures is a key and not described in detail in the LabVIEW help file. If the structure parameters contain arrays, the array variables in the LabVIEW environment are directly used as the structure elements to be input, and function execution errors can occur, so that a correct result can not be obtained.
Disclosure of Invention
The invention provides a method for calling a structure function in a dynamic link library based on LabVIEW, which solves the technical problems that LabVIEW language cannot interact with a dynamic link library of a function with a pointer or a structure, wherein parameters of the function are generated by C language; when the structure parameter contains an array, the array variable in the LabVIEW environment is directly used as the structure element to be input, and a function execution error can also occur.
In order to solve the technical problems, the invention provides a method for calling a structure function in a dynamic link library based on LabVIEW, which comprises the following steps:
s1, judging that a function variable contains a structural body or a pointer of the structural body to enter the next step;
s2, judging whether the variable of the structural body contains an array, if so, defining the data types of the structural body except the array one by one according to the function prototype, and entering the next step, otherwise, defining the data types of the structural body one by one according to the function prototype;
s3, judging whether the array accords with a decomposition condition, if so, decomposing the array and then converting the array into a corresponding cluster, and if not, directly converting the array into the cluster.
Further, after the step S3, the method further includes the steps of:
s4, sequentially binding the data types defined in the step S2 into a cluster variable.
Further, after the step S4, the method further includes the steps of:
s5, setting the parameter type of the cluster variable as 'matching to type', setting the data format as 'processing according to the value', and ending the call.
Further, before the step S1, the method further includes the steps of:
s01, labVIEW calls a dynamic link library function;
s02, judging whether the function variable contains a structure body or a structure body pointer.
Further, in the step S1, if it is determined that the function variable does not contain a structure or a pointer to a structure, a parameter type is assigned to each variable in the function, and the call is ended.
Specifically, in the step S3, the decomposition condition is: the array is a multi-dimensional array or a one-dimensional array with a length greater than 256.
Specifically, when the array is a multi-dimensional array, in the step S3, the specific process of decomposing the array is as follows: the multi-dimensional array is decomposed into a plurality of one-dimensional arrays by dimension.
Specifically, when the array is a one-dimensional array with a length greater than 256, in the step S3, the specific process of decomposing the array is as follows: the one-dimensional array with the length larger than 256 is decomposed into a plurality of one-dimensional arrays with the size of 256.
The invention provides a method for calling a structure function in a dynamic link library based on LabVIEW, which is characterized in that when the LabVIEW calls a function with a structure or a structure pointer in the dynamic link library, whether an array exists in a corresponding structure variable is further judged, if so, the data types outside the array are defined according to a function prototype, then the array meeting the decomposition condition is decomposed and then converted into a corresponding cluster, and other arrays are directly converted into clusters; the defined data types are further bound into a cluster variable in sequence, finally, the parameter types of the cluster variable are set as 'matching to type', the data format is set as 'processing according to values', and the call is ended. The LabVIEW language can interact with the dynamic link library of the function with the pointer or the structure body in the parameters generated by the C language, when the parameters of the structure body contain arrays, the arrays are further converted into clusters and the corresponding data types are bound into a cluster variable, and finally, the function call is realized by setting the parameter type of the cluster variable as 'matching to the type' and setting the data format as 'processing according to the value'.
Drawings
FIG. 1 is a flow chart of steps of a method for invoking a structure function in a dynamic link library based on LabVIEW according to an embodiment of the present invention;
FIG. 2 is a workflow diagram of a method for invoking a structure function in a dynamic link library based on LabVIEW, according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a configuration or configuration pointer corresponding to a data type setup in LabVIEW according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a configuration of "match to type" of a structure or structure pointer in a LabVIEW call library function control provided by an embodiment of the present invention;
FIG. 5 is a schematic diagram of a "per-value" configuration of a structure or structure pointer in a LabVIEW call library function control provided by an embodiment of the present invention;
FIG. 6 is a diagram illustrating a processing procedure when an array is included in a structure according to an embodiment of the present invention.
Detailed Description
The following examples are given for the purpose of illustration only and are not to be construed as limiting the invention, including the drawings for reference and description only, and are not to be construed as limiting the scope of the invention as many variations thereof are possible without departing from the spirit and scope of the invention.
The embodiment of the invention provides a method for calling a structure body function in a dynamic link library based on LabVIEW, which is shown in a step flow chart in FIG. 1 and a work flow chart in FIG. 2, and in the embodiment, the method comprises the following steps:
s1, judging that a function variable contains a structural body or a pointer of the structural body to enter the next step;
s2, judging whether the variable of the structural body contains an array, if so, defining the data types of the structural body except the array one by one according to the function prototype, and entering the next step, otherwise, defining the data types of the structural body one by one according to the function prototype;
s3, judging whether the array accords with a decomposition condition, if so, decomposing the array and then converting the array into a corresponding cluster, and if not, directly converting the array into the cluster.
Further, after the step S3, the method further includes the steps of:
s4, sequentially binding the data types defined in the step S2 into a cluster variable.
Further, after the step S4, the method further includes the steps of:
s5, setting the parameter type of the cluster variable as 'matching to type', setting the data format as 'processing according to the value', and ending the call.
Further, before the step S1, the method further includes the steps of:
s01, labVIEW calls a dynamic link library function;
s02, judging whether the function variable contains a structure body or a structure body pointer.
Further, in the step S1, if it is determined that the function variable does not contain a structure or a pointer to a structure, a parameter type is assigned to each variable in the function, and the call is ended.
Specifically, in the step S3, the decomposition condition is: the array is a multi-dimensional array or a one-dimensional array with a length greater than 256.
Specifically, when the array is a multi-dimensional array, in the step S3, the specific process of decomposing the array is as follows: the multi-dimensional array is decomposed into a plurality of one-dimensional arrays by dimension.
Specifically, when the array is a one-dimensional array with a length greater than 256, in the step S3, the specific process of decomposing the array is as follows: the one-dimensional array with the length larger than 256 is decomposed into a plurality of one-dimensional arrays with the size of 256.
Also to be specified are:
1. the structure or structure pointer corresponds to the data type in LabVIEW
When the input parameter is a structure, the corresponding data type is a "cluster" type in LabVIEW. As shown in fig. 3, branch a is a corresponding type of structure constant, and branch b may be bundled into a corresponding type of structure variable by different element variables.
2. Configuration of structures or structure pointers in LabVIEW call library function controls
The parameters of the calling library function are values, arrays, character strings and other basic types, and the corresponding types can be found in a type drop-down list in a parameter page of a LabVIEW calling library function control. And when the parameter type is a structure body or a structure body pointer, the type matching to the type identified in the box of fig. 4 should be selected in the type drop-down list, and the type processing by value identified in the box of fig. 5 should be selected in the data format drop-down list.
3. Processing when array is contained in structure
When the structure contains an array, the array cannot be directly input as a cluster element, and as shown in fig. 6, the array must be converted into a cluster and then input as a cluster element. When the array size exceeds 256 or the array is a non-one-dimensional array, the array must be converted into a plurality of clusters and then input as cluster elements.
According to the method for calling the structure function in the dynamic link library based on the LabVIEW, when the LabVIEW calls the function with the structure or the pointer of the structure in the dynamic link library, whether an array exists in the corresponding structure variables is further judged, if yes, data types except the array are defined according to a function prototype, then the array meeting the decomposition condition is decomposed and then converted into a corresponding cluster, and other arrays are directly converted into clusters; the defined data types are further bound into a cluster variable in sequence, finally, the parameter types of the cluster variable are set as 'matching to type', the data format is set as 'processing according to values', and the call is ended. The LabVIEW language can interact with the dynamic link library of the function with the pointer or the structure body in the parameters generated by the C language, when the parameters of the structure body contain arrays, the arrays are further converted into clusters and the corresponding data types are bound into a cluster variable, and finally, the function call is realized by setting the parameter type of the cluster variable as 'matching to the type' and setting the data format as 'processing according to the value'.
The above examples are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above examples, and any other changes, modifications, substitutions, combinations, and simplifications that do not depart from the spirit and principle of the present invention should be made in the equivalent manner, and the embodiments are included in the protection scope of the present invention.
Claims (3)
1. A method for calling a structure function in a dynamic link library based on LabVIEW is characterized by comprising the following steps:
s1, labVIEW calls a dynamic link library function, judges whether a function variable contains a structure body or a structure body pointer, enters the next step if the function variable contains the structure body or the structure body pointer, and distributes a parameter type for each variable in the function if the function variable does not contain the structure body or the structure body pointer, and the call is ended;
s2, judging whether the structure body contains an array, if so, defining the data types of the structure body except the array one by one according to the function prototype, and entering the next step, otherwise, defining the data types of the structure body one by one according to the function prototype;
s3, judging whether the array accords with a decomposition condition, if so, decomposing the array and then converting the array into a corresponding cluster, and if not, directly converting the array into the cluster;
s4, sequentially binding the data types defined in the step S2 into a cluster variable;
s5, setting the parameter type of the cluster variable as 'matching to type', setting the data format as 'processing according to value', and ending the call;
wherein, in the step S3, the decomposition conditions are: the array is a multi-dimensional array or a one-dimensional array with a length greater than 256.
2. The method for invoking a structure function in a dynamic link library based on LabVIEW according to claim 1, wherein when the array is a multidimensional array, in the step S3, the specific process of decomposing the array is as follows: the multi-dimensional array is decomposed into a plurality of one-dimensional arrays by dimension.
3. The method for invoking a structure function in a dynamic link library according to claim 1, wherein when the array is a one-dimensional array with a length greater than 256, in the step S3, the specific process of decomposing the array is as follows: decomposing the one-dimensional array with the length larger than 256 into a plurality of one-dimensional arrays with the length of 256.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910970976.4A CN111078420B (en) | 2019-10-14 | 2019-10-14 | Method for calling structure body function in dynamic link library based on LabVIEW |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910970976.4A CN111078420B (en) | 2019-10-14 | 2019-10-14 | Method for calling structure body function in dynamic link library based on LabVIEW |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111078420A CN111078420A (en) | 2020-04-28 |
CN111078420B true CN111078420B (en) | 2023-06-27 |
Family
ID=70310288
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910970976.4A Active CN111078420B (en) | 2019-10-14 | 2019-10-14 | Method for calling structure body function in dynamic link library based on LabVIEW |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111078420B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6874148B1 (en) * | 2000-06-14 | 2005-03-29 | National Instruments Corporation | System and method for exporting a graphical program to a shared library |
CN107479875A (en) * | 2017-07-19 | 2017-12-15 | 广州慧睿思通信息科技有限公司 | A kind of Java calls DLL convenient method |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8713540B2 (en) * | 2010-07-29 | 2014-04-29 | National Instruments Corporation | Generating and modifying textual code interfaces from graphical programs |
CN102611836B (en) * | 2012-02-06 | 2014-04-16 | 上海理工大学 | High-speed image collecting method based on Labview |
US9081583B2 (en) * | 2012-08-23 | 2015-07-14 | National Instruments Corporation | Compile time execution |
US9329849B2 (en) * | 2013-08-26 | 2016-05-03 | Facebook, Inc. | Systems and methods for converting typed code |
CN103984665B (en) * | 2014-06-05 | 2017-06-20 | 哈尔滨工业大学 | Serial communication device and method based on LabVIEW |
CN104536812B (en) * | 2014-12-30 | 2018-04-03 | 北京无线电计量测试研究所 | A kind of call method of the dynamic link library based on LabVIEW |
-
2019
- 2019-10-14 CN CN201910970976.4A patent/CN111078420B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6874148B1 (en) * | 2000-06-14 | 2005-03-29 | National Instruments Corporation | System and method for exporting a graphical program to a shared library |
CN107479875A (en) * | 2017-07-19 | 2017-12-15 | 广州慧睿思通信息科技有限公司 | A kind of Java calls DLL convenient method |
Non-Patent Citations (1)
Title |
---|
C#调用VC++动态链接库的研究;李伟;;测控技术(第05期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN111078420A (en) | 2020-04-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110244936B (en) | Method and device for supporting VISIO flow chart to automatically import DCS algorithm configuration software | |
US20060130015A1 (en) | Defining expressions in a meta-object model of an application | |
CN113704706B (en) | Code reinforcement method and device | |
CN107153535A (en) | A kind of operation ElasticSearch method and device | |
CN111985055A (en) | Model packaging method and device and electronic equipment | |
CN109976751B (en) | Model operation method, related device and computer readable storage medium | |
CN105893052A (en) | War packet analyzer | |
CN111078420B (en) | Method for calling structure body function in dynamic link library based on LabVIEW | |
CN110554857B (en) | JavaBean generation method, device and system and readable storage medium | |
US7174539B2 (en) | Program coupling method | |
CN111209326A (en) | Data query method and device, electronic equipment and storage medium | |
CN111026670A (en) | Test case generation method, test case generation device, and storage medium | |
CN106569868B (en) | Gradle-based compiling optimization method and device | |
US5799192A (en) | Tool encapsulating method and apparatus thereof | |
CN109408577B (en) | ORACLE database JSON analysis method, system, device and storable medium | |
CN115576603B (en) | Method and device for acquiring variable values in code segment | |
CN116450194A (en) | Method and device for generating python installation package, electronic equipment and readable storage medium | |
CN113568678B (en) | Method and device for dynamically loading resources and electronic equipment | |
CN109284128B (en) | Method, device, storage medium and mobile terminal for converting data | |
US20040194022A1 (en) | Kernel configuration tool | |
CN108334621B (en) | Database operation method, device, equipment and computer readable storage medium | |
US20040046793A1 (en) | Program generation method | |
US20030014435A1 (en) | Generic method of routing through an object tree to invoke a specific method for certain objects of said tree | |
CN115470576B (en) | Airplane test flight method, device, equipment and medium | |
CN117687682A (en) | JavaScript-based object conversion method and system |
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 |