Sensing equipment control method and device, electronic equipment and storage medium
By using pre-set modeling tools and industrial control programming languages on the perception device, the device model code and logical code of the target programming language are generated, and the problem that OPC UA modeling cannot achieve precise control is solved, and precise control of the perception device is achieved.
Patent Information
- Application Number
- CN202411625464.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-03-07
AI Technical Summary
In the prior art, using OPC UA to model perception equipment can only implement basic control logic, and precise control of perception equipment cannot be carried out.
The device model is established for the perception device through pre-set modeling tools, and the device model code corresponding to the target programming language is generated based on the device model; the control logic algorithm corresponding to the industrial control programming language for the perception device is obtained, and the control logic algorithm is converted into the logical code corresponding to the target programming language; the control logic code is generated based on the device model code and logic code, and the control logic code is generated for controlling the perception device.
Accurate control of perception devices is achieved, avoiding the problem that using OPC UA for perception device modeling can only implement basic control logic.
Smart Images

Figure CN119575845A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of device control technology, and in particular to a sensing device control method, device, electronic device and storage medium. Background Art
[0002] Perception devices are devices used to identify objects and collect information in the Internet of Things. Perception devices include but are not limited to sensors, cameras, and global positioning systems (GPS). Taking a camera as an example, its main parameters include pixels, resolution, field of view, focal length, etc. Different parameter selections will affect the quality of the collected image.
[0003] OPC UA (Open Platform Communications Unified Architecture) is a communication protocol and architecture used to implement data exchange and communication between devices in industrial automation systems. In related technologies, OPC UA is used to implement data exchange and communication between sensor devices in industrial automation systems, thereby achieving control over sensor devices. However, using OPC UA to model sensor devices can only implement basic control logic, and cannot accurately control sensor devices. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a perception device control method, apparatus, electronic device and storage medium to solve the problem in the prior art that OPC UA is used to model perception devices, which can only implement basic control logic but cannot accurately control the perception devices.
[0005] According to a first aspect of an embodiment of the present application, a method for controlling a perception device is provided, the method comprising: establishing a device model for the perception device through a pre-set modeling tool, and generating a device model code corresponding to a target programming language based on the device model; obtaining a control logic algorithm corresponding to an industrial control programming language for the perception device, and converting the control logic algorithm into a logic code corresponding to the target programming language; generating a control logic code based on the device model code and the logic code, and the control logic code is used to control the perception device.
[0006] According to a second aspect of an embodiment of the present application, a perception device control apparatus is provided, the apparatus comprising: a modeling module, configured to establish a device model for the perception device through a pre-set modeling tool, and generate a device model code corresponding to a target programming language according to the device model; a logic module, configured to obtain a control logic algorithm corresponding to an industrial control programming language for the perception device, and convert the control logic algorithm into a logic code corresponding to the target programming language; and a control module, configured to generate a control logic code according to the device model code and the logic code, and the control logic code is used to control the perception device.
[0007] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0008] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0009] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiment method of the present application establishes a device model for the perception device through a pre-set modeling tool, and generates a device model code corresponding to the target programming language according to the device model; obtains a control logic algorithm corresponding to the industrial control programming language for the perception device, and converts the control logic algorithm into a logic code corresponding to the target programming language; generates a control logic code according to the device model code and the logic code, and the method converts both the device model constructed by the modeling tool and the control logic algorithm corresponding to the industrial control programming language into a code corresponding to the target programming language, so that the device model code corresponding to the device model and the logic code corresponding to the control logic algorithm can be integrated to generate a control logic code, and then when the device model is used to control the perception device, the perception device can be accurately controlled based on the control logic algorithm contained in the control logic code, avoiding the problem in the related art that OPC UA is used to model the perception device, which can only realize basic control logic and cannot accurately control the perception device. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1It is a flowchart of a sensing device control method provided in an embodiment of the present application;
[0012] Figure 2 It is a basic flow chart of a sensing device control method provided in an embodiment of the present application;
[0013] Figure 3 It is a flowchart of another sensing device control method provided in an embodiment of the present application;
[0014] Figure 4 It is a flowchart of another sensing device control method provided in an embodiment of the present application;
[0015] Figure 5 It is a flowchart of another sensing device control method provided in an embodiment of the present application;
[0016] Figure 6 It is a flowchart of another sensing device control method provided in an embodiment of the present application;
[0017] Figure 7 It is a basic schematic diagram of a control logic to target programming language provided by an embodiment of the present application;
[0018] Figure 8 is a flowchart of another optional sensing device control method provided in an embodiment of the present application;
[0019] Fig. 9 is a flowchart of another optional sensing device control method provided in an embodiment of the present application;
[0020] Fig.10 is a structural schematic diagram of a sensing device control device provided in an embodiment of the present application;
[0021] Fig.11 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0023] A method and apparatus for controlling a sensing device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0024] Figure 1A sensing device control method provided by an embodiment of the present application is as follows: Figure 1 As shown, the method includes:
[0025] S101, establishing a device model for the sensing device using a pre-set modeling tool, and generating a device model code corresponding to a target programming language according to the device model;
[0026] S102, obtaining a control logic algorithm corresponding to an industrial control programming language for a sensing device, and converting the control logic algorithm into a logic code corresponding to a target programming language;
[0027] S103. Generate a control logic code according to the device model code and the logic code, where the control logic code is used to control the sensing device.
[0028] It can be understood that the perception device control method provided in the present application is applied to a terminal and / or a server, that is, the perception device control method can be executed by a terminal or a server alone, or the perception device control method can be executed jointly by a terminal and a server, wherein the above-mentioned terminal includes but is not limited to mobile phones, tablet computers, desktop computers and other devices.
[0029] In some examples, the present application first establishes a device model for the perception device through a pre-set modeling tool, wherein the modeling tool is a modeling tool corresponding to OPC UA, and the modeling tool can establish a device model for the perception device; it can be understood that the present application does not limit the type of modeling tool. Exemplarily, the modeling tool can be a self-developed model configuration tool, UAmodeler, opcua-modeler, SiOME, etc.
[0030] After the device model is generated by the modeling tool, the present application will also generate device model code corresponding to the target programming language based on the device model, wherein the target programming language includes but is not limited to one of C language and C++ language.
[0031] Exemplarily, taking the target programming language as C language as an example, after the device model is generated by the modeling tool, the present application will export the storage file corresponding to the device model (the format of the storage file is determined by the modeling tool, and exemplarily, the format of the storage file is XML format), and then convert the storage file into the device model code corresponding to the C language through the conversion tool (exemplarily, the conversion tool is open62541).
[0032] It is understandable that constructing control logic algorithms through industrial control programming languages can achieve precise operation of sensing devices. However, the control logic algorithms corresponding to the industrial control programming languages cannot be directly added to the device models corresponding to OPC UA, resulting in the use of OPC UA for sensing device modeling, which can only implement basic control logic and cannot accurately control sensing devices. It is understandable that the above-mentioned industrial control programming languages include but are not limited to programming languages such as ladder diagrams (LAD), function block diagrams (FBD), sequential function charts (SFC), structured text (ST), instruction lists (IL) and the like that comply with IEC61131-3.
[0033] In order to solve the above problems, this application will obtain the control logic algorithm corresponding to the industrial control programming language for the sensing device, and convert the control logic algorithm into the logic code corresponding to the target programming language. At this time, the logic code and the device model code are both built based on the target programming language, so the logic code and the device model code can be integrated.
[0034] Continuing from the above example, this application will merge the logic code and the device model code to generate a control logic code, which is used to control the sensing device.
[0035] According to the technical solution provided in the embodiment of the present application, a device model is established for the perception device through a pre-set modeling tool, and a device model code corresponding to the target programming language is generated according to the device model; a control logic algorithm corresponding to the industrial control programming language for the perception device is obtained, and the control logic algorithm is converted into a logic code corresponding to the target programming language; a control logic code is generated according to the device model code and the logic code. This method converts both the device model constructed by the modeling tool and the control logic algorithm corresponding to the industrial control programming language into codes corresponding to the target programming language, so that the device model code corresponding to the device model and the logic code corresponding to the control logic algorithm can be integrated to generate a control logic code. When the device model is used to control the perception device, the perception device can be accurately controlled based on the control logic algorithm contained in the control logic code, thereby avoiding the problem in the related art that OPC UA is used to model the perception device, which can only realize basic control logic and cannot accurately control the perception device.
[0036] In some embodiments, Figure 2 As shown, a device model is established for the sensing device through a pre-set modeling tool, and a device model code corresponding to the target programming language is generated according to the device model, including:
[0037] S201, generating an initial model through a modeling tool;
[0038] S202: Acquire parameter attributes corresponding to the sensing device, and instantiate an initial model according to the parameter attributes to obtain a device model.
[0039] It can be understood that the present application first creates an initial model corresponding to the perception device through an OPC UA modeling tool (for example, a self-developed model configuration tool or UAmodeler, opcua-modeler, SiOME and other tools).
[0040] Then, the present application will obtain the parameter attributes corresponding to the sensing device, which are used to characterize the capabilities of the sensing device; for example, taking the sensing device as a camera, the types of parameter attributes obtained include but are not limited to pixels, resolution, field of view, and focal length. It can be understood that the types of parameter attributes that need to be obtained for each sensing device are pre-set.
[0041] In some examples, after obtaining parameter attributes corresponding to the sensing device, the present application instantiates an initial model according to the parameter attributes, and uses the instantiated initial model as the device model.
[0042] According to the technical solution provided in the embodiment of the present application, an initial model is generated through a modeling tool; parameter attributes corresponding to the perception device are obtained, and the initial model is instantiated according to the parameter attributes to obtain a device model. This method obtains the parameter attributes corresponding to the perception device and instantiates the initial model according to the parameter attributes, thereby accurately obtaining the device model corresponding to the perception device.
[0043] In some embodiments, Figure 3 As shown, the initial model is instantiated according to the parameter attributes to obtain the device model, including:
[0044] S301, instantiate the initial model according to parameter attributes to obtain a model to be tested;
[0045] S302: Perform a model test on the model to be tested. If the model test result is that the test passes, the model to be tested is used as a device model.
[0046] Specifically, in order to avoid the problem that the device model obtained by instantiating the initial model cannot accurately match the perception device, resulting in the subsequent inability to control the perception device through the device model, this application will use the instantiated initial model as the model to be tested, and then perform model testing on the model to be tested.
[0047] If the model test result corresponding to the model to be tested is a passed test, the model to be tested is used as the device model, thereby ensuring that the obtained device model can be successfully matched with the perception device. If the model test result corresponding to the model to be tested is a failed test, the initial model is regenerated through the modeling tool, and the re-obtained initial model is instantiated based on the parameter attributes corresponding to the perception device to obtain a new model to be tested, and then the model test is re-performed on the model to be tested until the model test result is a passed test, and the model to be tested that has passed the test is used as the device model.
[0048] According to the technical solution provided in the embodiment of the present application, the initial model is instantiated according to the parameter attributes to obtain the model to be tested; the model to be tested is subjected to model testing, and when the model test result is that the test passes, the model to be tested is used as the device model. The present application tests the model to be tested, thereby ensuring that the device model can match the perception device, and the perception device can be subsequently controlled by the control logic code generated by the device model.
[0049] In some embodiments, Figure 4 As shown, the model to be tested is tested, including:
[0050] S401, generating a code of the model to be tested corresponding to the target programming language according to the model to be tested;
[0051] S402: Acquire a test server, and add the code of the model to be tested to the test server, so as to test the model to be tested through the test server.
[0052] It can be understood that in order to implement the testing of the model to be tested, the present application first converts the model to be tested into the model code to be tested corresponding to the target programming language; specifically, the present application will export the storage file corresponding to the model to be tested (the format of the storage file is determined by the modeling tool, and exemplarily, the format of the storage file is XML format), and then convert the storage file corresponding to the model to be tested into the model code to be tested corresponding to the target programming language through a conversion tool (exemplarily, the conversion tool is open62541).
[0053] In some examples, the present application will also obtain a test server, and then add the code of the model to be tested to the test server, and then test the model to be tested through the test server. If the model test result corresponding to the model to be tested is a test pass, the model to be tested is used as the device model, thereby ensuring that the obtained device model and the perception device can be successfully matched. In the case where the model test result corresponding to the model to be tested is a test failure, the initial model is regenerated through the modeling tool, and the initial model is re-instantiated according to the parameter attributes corresponding to the perception device to obtain a new model to be tested, and then the model test is re-performed on the model to be tested until the model test result is a test pass, and the model to be tested that passes the test is used as the device model.
[0054] In order to better understand the above method, this application provides a more specific example for illustration, taking the target programming language as C language as an example, Figure 5 As shown, this application first uses the self-developed model configuration tool corresponding to OPC UA or UAmodeler, opcua-modeler, SiOME and other tools to establish an initial model for the perception device, and then extracts the parameter attributes corresponding to the perception device, and instantiates the initial model according to the extracted parameter attributes to obtain the model to be tested.
[0055] Then, this application will export the XML file corresponding to the model to be tested, and use the open62541 tool to convert the XML file into C code to obtain the model code to be tested. Then obtain the OPC UA Server (test server), add the model code to be tested to the code of the OPC UA Server, and use the UaExpert tool to connect to the OPC UA Server to perform model testing on the model code to be tested.
[0056] When the model test result is that the test passes, the model to be tested is used as the device model. When the model test result corresponding to the model to be tested is that the test fails, the initial model is re-generated through the modeling tool, and the initial model is re-instantiated according to the parameter attributes corresponding to the perception device to obtain a new model to be tested. The model test is then re-performed on the model to be tested until the model test result is that the test passes, and the model to be tested that passes the test is used as the device model.
[0057] According to the technical solution provided in the embodiment of the present application, the code of the model to be tested corresponding to the target programming language is generated according to the model to be tested; a test server is obtained, and the code of the model to be tested is added to the test server, so that the model to be tested is tested through the test server. The present application realizes accurate testing of the model to be tested through the test server, so that the obtained device model can be accurately matched with the perception device.
[0058] In some embodiments, Figure 6 As shown, the control logic algorithm is converted into the logic code corresponding to the target programming language, including:
[0059] S601, performing syntax recognition on the control logic algorithm, and constructing a syntax tree corresponding to the control logic algorithm based on the syntax recognition result;
[0060] S602: Generate logic code corresponding to the target programming language according to the syntax tree.
[0061] Specifically, the present application will perform grammar recognition on the control logic algorithm and construct a grammar tree corresponding to the control logic algorithm based on the grammar recognition structure.
[0062] For example, an industrial control programming language is a programming language that complies with the IEC61131-3 standard. The control logic algorithm of the programming language of the IEC61131-3 standard is encapsulated in functions and function blocks. The function is similar to the function in the target programming language (such as C language or C++ language), and the function block is similar to the class defined in C++, which needs to be instantiated before it can be used. There is no concept of type for object member attributes in C++, only the concept of access rights (PUBLIC\PROTECTED\PRIVATE). In IEC61131-3, function and function block pins (i.e., properties) have both types and access rights.
[0063] For example, the function pin description of the programming language that complies with the IEC61131-3 standard is as follows:
[0064] VAR type pin: no parameter transfer is required, the function is initialized each time it runs, and cannot be accessed externally;
[0065] VAR_INPUT type pin: requires parameter transmission. The parameters are passed in from the outside each time the function is run and cannot be accessed from the outside.
[0066] VAR_OUTPUT type pin: No parameters are required, the function is initialized each time it runs, and cannot be accessed externally;
[0067] VAR_IN_OUT type pin: requires parameter transmission. The parameters are passed in from the outside each time the function is run and cannot be accessed from the outside.
[0068] VAR_STAT type pin: does not require parameter transmission, is initialized once when the program is running, and cannot be accessed externally.
[0069] For example, the function block pinouts of a programming language that complies with the IEC61131-3 standard are described as follows:
[0070] VAR type pin: no parameter transfer is required, instance initialization, external read-only;
[0071] VAR_INPUT type pin: can pass parameters, instance initialization, external readable and writable;
[0072] VAR_OUTPUT type pin: can pass parameters, instance initialization, external read-only;
[0073] VAR_IN_OUT type pin: requires parameter transmission. When the instance is called, the parameters are passed in from the outside and cannot be accessed from the outside.
[0074] VAR_STAT type pin: does not require parameter transmission, is initialized once when the program is running, and is externally readable and writable;
[0075] VAR_TEMP type pin: no parameter passing is required, the instance is initialized, and cannot be accessed externally.
[0076] From the above examples, we can see that different types of pins of function blocks are used in different ways. Therefore, different ways of calling the IEC61131-3 control algorithm directly in the OPC UA modeling process will lead to inconsistent calculation results. Function calls are not affected.
[0077] Therefore, the present application will perform syntax recognition on the control logic algorithm, and construct a syntax tree corresponding to the control logic algorithm based on the syntax recognition structure, and then generate logic code corresponding to the target programming language according to the syntax tree.
[0078] In this application, the control logic algorithm is converted into the data management method of the target programming language, and the data and code logic are separated. Data refers to the global variables and function block instances used in the control logic algorithm, and code logic refers to the logic code in the control logic algorithm. The data used are all defined in the same header file (exemplarily, the header file is a .h file). The data is the address of the lower computer RTS when it is running. Each data has its own address and size. During the RTS running stage, the data will be relocated to specify the actual address. All logic codes read and write data addresses in the form of pointers, such as Figure 7 As shown, this also provides feasibility for OPC UA compatibility.
[0079] It is understandable that different industrial control industries have different ways of converting function block pins to target programming languages. For example, the function block pins of the distributed control system (DCS) industry are discrete (the pins are not arranged continuously in the memory), and the function block pins of the programmable logic controller (PLC) industry are non-discrete (the pins are arranged continuously in the memory). Taking PLC implementation as an example, and the target programming language is C language, and the industrial control programming language is a programming language that complies with the IEC61131-3 standard, the control logic algorithm is used as follows after conversion to C:
[0080] uint32_t*pBaseAddress=0x00000000;
[0081] uint32_t*fb_instance_address=pBaseAddress+H_FB_INSTANCE_DEFINE;
[0082] FB_POU(fb_instance_address);
[0083] Among them, pBaseAddress is the data base address, the starting address (fixed address) agreed with RTS during the compilation phase, H_FB_INSTANCE_DEFINE is a macro definition, representing the relative address of the function block instance data, H_FB_INSTANCE_DEFINE relocates the specified relative address when RTS is running, fb_instance_addres = starting address + relative address, which is the real absolute address of the function block instance. FB_POU call is the execution of the IEC61131-3 control logic algorithm. After the real function block instance address is passed in, the function block pin can be read and written internally by accessing the structure member in a pointer-like manner like C language (fb_instance_address->member).
[0084] After converting the IEC61131-3 control logic algorithm to C, it can be directly called in the OPC UA code logic through the above calling method (calling a function similar to FB_POU(fb_instance_address)) to achieve the purpose of encapsulating the IEC61131-3 control logic in the OPC UA modeling process.
[0085] According to the technical solution provided in the embodiment of the present application, syntax recognition is performed on the control logic algorithm, and a syntax tree corresponding to the control logic algorithm is constructed based on the syntax recognition result; and logic code corresponding to the target programming language is generated according to the syntax tree.
[0086] In some examples, such as Figure 8 As shown, after generating the control logic code according to the device model code and the logic code, the method further includes:
[0087] S801, compile the control logic code to obtain an executable file;
[0088] S802: Send the executable file to the lower computer, so that the lower computer controls the sensing device according to the executable file.
[0089] Specifically, in order to enable the lower computer to control the sensing device through the control logic code, the present application will also be compiled with the control logic code to obtain an executable file, wherein the content of the executable file is binary code, so that the lower computer can control the sensing device according to the executable file.
[0090] In order to better understand the present method, this embodiment provides a more specific example for illustration. Fig. 9 As shown, the present application establishes an initial model for the sensing device through a pre-set modeling tool, obtains the parameter attributes corresponding to the sensing device, and instantiates the initial model according to the parameter attributes to obtain the device model. Export the XML file of the OPC UA device model and generate the device model code corresponding to C or C++. The present application also performs syntax recognition on the control logic algorithm, and constructs a syntax tree corresponding to the control logic algorithm based on the syntax recognition result, generates the logic code corresponding to the target programming language according to the syntax tree, and then generates the control logic code according to the device model code and the logic code.
[0091] According to the technical solution provided in the embodiment of the present application, the control logic code is compiled to obtain an executable file; the executable file is sent to the lower computer, so that the lower computer controls the sensing device according to the executable file, avoiding the problem in the related art that the lower computer cannot accurately control the sensing device.
[0092] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0093] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0094] This embodiment also provides a sensing device control device, such as Fig.10 As shown, the device comprises:
[0095] The modeling module 1001 is configured to establish a device model for the sensing device by using a preset modeling tool, and generate a device model code corresponding to a target programming language according to the device model;
[0096] The logic module 1002 is configured to obtain a control logic algorithm corresponding to the industrial control programming language for the sensing device, and convert the control logic algorithm into a logic code corresponding to the target programming language;
[0097] The control module 1003 is configured to generate a control logic code according to the device model code and the logic code, and the control logic code is used to control the sensing device.
[0098] In some examples, the modeling module 1001 is further configured to generate an initial model through a modeling tool; obtain parameter attributes corresponding to the sensing device, and instantiate the initial model according to the parameter attributes to obtain a device model.
[0099] In some examples, the modeling module 1001 is further configured to instantiate an initial model according to parameter attributes to obtain a model to be tested; perform a model test on the model to be tested, and when the model test result is that the test passes, use the model to be tested as a device model.
[0100] In some examples, the modeling module 1001 is also configured to generate a model code to be tested corresponding to a target programming language according to the model to be tested; obtain a test server, add the model code to be tested to the test server, and test the model to be tested through the test server.
[0101] In some examples, the logic module 1002 is further configured to perform syntax recognition on the control logic algorithm, and construct a syntax tree corresponding to the control logic algorithm based on the syntax recognition result; and generate logic code corresponding to the target programming language according to the syntax tree.
[0102] In some examples, the control module 1003 is further configured to compile the control logic code to obtain an executable file; send the executable file to the lower computer, so that the lower computer controls the sensing device according to the executable file.
[0103] According to the technical solution provided in the embodiment of the present application, the perception device control apparatus provided in the embodiment establishes a device model for the perception device through a pre-set modeling tool, and generates a device model code corresponding to the target programming language according to the device model; obtains a control logic algorithm corresponding to the industrial control programming language for the perception device, and converts the control logic algorithm into a logic code corresponding to the target programming language; generates a control logic code according to the device model code and the logic code. This method converts both the device model constructed by the modeling tool and the control logic algorithm corresponding to the industrial control programming language into a code corresponding to the target programming language, so that the device model code corresponding to the device model and the logic code corresponding to the control logic algorithm can be integrated to generate a control logic code. When the device model is used to control the perception device, the perception device can be precisely controlled based on the control logic algorithm contained in the control logic code, thereby avoiding the problem in the related art that OPC UA is used to model the perception device, but only basic control logic can be implemented, and the perception device cannot be precisely controlled.
[0104] Fig.11 Schematic diagram of an electronic device 11 provided in an embodiment of the present application. Fig.11 As shown, the electronic device 11 of this embodiment includes: a processor 1101, a memory 1102, and a computer program 1103 stored in the memory 1102 and executable on the processor 1101. When the processor 1101 executes the computer program 1103, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1101 executes the computer program 1103, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0105] The electronic device 11 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 11 may include, but is not limited to, a processor 1101 and a memory 1102. Those skilled in the art will appreciate that Fig.11 The electronic device 11 is merely an example and does not limit the electronic device 11 , and may include more or less components than those shown in the figure, or different components.
[0106] Processor 1101 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0107] The memory 1102 may be an internal storage unit of the electronic device 11, for example, a hard disk or memory of the electronic device 11. The memory 1102 may also be an external storage device of the electronic device 11, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (FlashCard), etc. equipped on the electronic device 11. The memory 1102 may also include both an internal storage unit of the electronic device 11 and an external storage device. The memory 1102 is used to store computer programs and other programs and data required by the electronic device.
[0108] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0109] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of regional requirements and patent practice. For example, in some areas, according to regional requirements and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0110] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A sensing device control method, characterized in that: The method comprises: Establishing a device model for the sensing device by using a pre-set modeling tool, and generating a device model code corresponding to a target programming language according to the device model; Acquire a control logic algorithm corresponding to the industrial control programming language for the sensing device, and convert the control logic algorithm into a logic code corresponding to the target programming language; A control logic code is generated according to the device model code and the logic code, and the control logic code is used to control the sensing device.
2. The method according to claim 1, characterized in that A device model is established for the sensing device through a pre-set modeling tool, and a device model code corresponding to a target programming language is generated according to the device model, including: generating an initial model by means of the modeling tool; Parameter attributes corresponding to the sensing device are acquired, and the initial model is instantiated according to the parameter attributes to obtain the device model.
3. The method according to claim 2, characterized in that Instantiating the initial model according to the parameter attributes to obtain the device model includes: Instantiate the initial model according to the parameter attributes to obtain a model to be tested; A model test is performed on the model to be tested, and when the model test result is that the test passes, the model to be tested is used as the device model.
4. The method according to claim 3, characterized in that Testing the model to be tested includes: Generate a code of the model to be tested corresponding to the target programming language according to the model to be tested; A test server is obtained, and the code of the model to be tested is added to the test server, so as to test the model to be tested through the test server.
5. The method according to claim 1, characterized in that Converting the control logic algorithm into logic code corresponding to the target programming language includes: Performing grammar recognition on the control logic algorithm, and constructing a grammar tree corresponding to the control logic algorithm based on the grammar recognition result; Generate logic code corresponding to the target programming language according to the syntax tree.
6. The method according to claim 1, characterized in that After generating a control logic code according to the device model code and the logic code, the method further includes: Compiling the control logic code to obtain an executable file; The executable file is sent to a lower computer, so that the lower computer controls the sensing device according to the executable file.
7. A sensing device control device, characterized in that: The device comprises: A modeling module is configured to establish a device model for the sensing device by using a preset modeling tool, and generate a device model code corresponding to a target programming language according to the device model; A logic module is configured to obtain a control logic algorithm corresponding to the industrial control programming language for the sensing device, and convert the control logic algorithm into a logic code corresponding to the target programming language; The control module is configured to generate a control logic code according to the device model code and the logic code, wherein the control logic code is used to control the sensing device.
8. The device according to claim 7, characterized in that The control module is also configured to compile the control logic code to obtain an executable file; and send the executable file to a lower computer so that the lower computer controls the sensing device according to the executable file.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.