Method and system for controlling programmable device based on graphic block programming
1. A system for controlling programmable equipment based on graphic block programming is characterized by comprising upper computer programming software, programmable equipment program firmware and programmable equipment physical hardware, wherein the upper computer programming software is positioned in an upper computer, the upper computer is electrically connected with the programmable equipment physical hardware, the programmable equipment program firmware is installed on the programmable equipment physical hardware, and the programmable equipment physical hardware is electrically connected with controllable equipment;
the inside of host computer programming software is equipped with visual unit and procedure interpretation unit, visual unit includes visual operation interface and virtual image interface, visual operation interface includes a plurality of visual figure piece, procedure interpretation unit includes node module and operation control module, the node module includes a plurality of independent function, independent function and visual figure piece are in the functional one-to-one correspondence, the inside of virtual image interface is equipped with virtual image and presents the module.
2. A method for programming and controlling programmable equipment based on a graphic block is characterized by comprising the following steps:
the method comprises the following steps: the programmable device developer packages the functions which can be realized by the device into independent execution functions according to the functions and the characteristics of the device;
step two: the upper computer developer defines a corresponding graphic block and a conversion relation between the graphic block and a code according to a function packaged by the programmable device;
step three: the user executes specific actions on the graphic block to complete the execution logic wanted by the user;
step four: connecting the programmable equipment with an upper computer by a user, and clicking a burning button;
step five: the upper computer converts the graphic block dragged by the user into a corresponding code and burns the corresponding code into the programmable equipment;
step six: and the programmable device automatically executes the burnt codes after the burning process is finished, and controls the device to execute corresponding logic and action according to the specific action of the user.
3. The method according to claim 2, wherein the graphics blocks in the third step are graphics blocks defined by a combined basic graphics block and an upper computer developer, the basic graphics blocks refer to graphics blocks corresponding to a code basic syntax, such as definition and assignment of variables, text-related basic functions, number-related basic functions, program judgment code blocks, cyclic code blocks, and the like, the specific actions in the third step can be dragging graphics blocks, clicking graphics blocks, double clicking graphics blocks, and the like, and a plurality of the specific actions are defined by the developer to have different meanings.
4. The method according to claim 2, wherein the independently executable functions in the first step are functions that can independently perform a certain function, and the execution of any one function has no relation to other functions, and the function includes but is not limited to the execution of an action or the combination of actions.
5. The method according to claim 2, wherein the graphic blocks in the second step are required to be in one-to-one correspondence with the functions in the first step, the number and types of input parameters included in the graphic blocks are sorted, the types of return values must be consistent with the functions in the first step, and it is ensured that the code generated according to the conversion relationship can normally run in the programmable device.
6. The method according to claim 2, wherein the upper computer in step four is an upper computer having the capability of connecting the programmable device and burning codes, the codes converted by the upper computer are defined by an upper computer developer, including but not limited to Python, C and JavaScript, and the codes of the language that the programmable device itself can execute determine the codes of the specific generated language.
7. The method according to claim 2, wherein the programmable device in step six comprises at least an original firmware and a medium storing the firmware, and the firmware has the capability of implementing the independently executed function in step one.
8. The method of claim 2, wherein the controllable devices connected to the programmable device in the sixth step include, but are not limited to, various sensors, motors, steering engines, and LED lamps.
Background
The graphical programming is a program written with an interface, and the ordinary contact is generally an interface program, namely an interface with buttons and the like. A programming language is a means for a developer to control or communicate with a computer, and the developer tells the computer how to operate by writing the programming language. With this graphical programming environment, most children and beginners now have the opportunity to learn such programming.
By retrieving the Chinese invention patent CN 106775765B, a graphical programming system is disclosed, which comprises a visualization operation interface, wherein visual function components and visual line components can be added, each visual function component represents a function, the visual line components are used for establishing the connection relationship among the visual function components, and the visual line components have directionality; and the program interpretation unit can add node modules and side modules, each node module corresponds to one visual functional component and can realize the function represented by the visual functional component, and the side modules correspond to the visual line components and can transmit data among the node modules according to the direction of the visual line components. The method utilizes a pure graphical interface to operate and construct a program, does not need to write codes, does not need to compile, is simple and easy to use, but has the defects that the virtual image cannot be materialized, the realized capability is only a certain virtual scene in control software, the use scene is single, a user feels dull after using for a period of time, the manual capability of the user cannot be exercised at all, a real object created by the user cannot be shared with friends, the experience feeling is poor, and the popularization effect cannot be achieved.
It is therefore desirable to provide a method and system for controlling a programmable device based on graphic block programming.
Disclosure of Invention
In order to overcome the above defects in the prior art, embodiments of the present invention provide a method and a system for controlling a programmable device based on a graphic block programming, so as to solve the problems that the graphic programming in the prior art is realized by a virtual image, the virtual image cannot be materialized, and a user lacks experience and manual ability.
In order to solve the technical problems, the invention provides the following technical scheme: a system for controlling programmable equipment based on graphic block programming comprises upper computer programming software, programmable equipment programming firmware and programmable equipment physical hardware, wherein the upper computer programming software is located in an upper computer, the upper computer is electrically connected with the programmable equipment physical hardware, the programmable equipment programming firmware is installed on the programmable equipment physical hardware, and the programmable equipment physical hardware is electrically connected with controllable equipment.
The inside of host computer programming software is equipped with visual unit and procedure interpretation unit, visual unit includes visual operation interface and virtual image interface, visual operation interface includes a plurality of visual figure piece, procedure interpretation unit includes node module and operation control module, the node module includes a plurality of independent function, independent function and visual figure piece are in the functional one-to-one correspondence, the inside of virtual image interface is equipped with virtual image and presents the module.
A method for programming and controlling programmable equipment based on a graphic block comprises the following steps:
the method comprises the following steps: the programmable device developer packages the functions which can be realized by the device into independent execution functions according to the functions and the characteristics of the device;
step two: the upper computer developer defines a corresponding graphic block and a conversion relation between the graphic block and a code according to a function packaged by the programmable device;
step three: the user executes specific actions on the graphic block to complete the execution logic wanted by the user;
step four: connecting the programmable equipment with an upper computer by a user, and clicking a burning button;
step five: the upper computer converts the graphic block dragged by the user into a corresponding code and burns the corresponding code into the programmable equipment;
step six: and the programmable device automatically executes the burnt codes after the burning process is finished, and controls the device to execute corresponding logic and action according to the specific action of the user.
Preferably, the graphic blocks in the third step are graphic blocks defined by a combined basic graphic block and an upper computer developer, the basic graphic blocks refer to graphic blocks corresponding to a code basic syntax, such as definition and assignment of variables, text related basic functions, number related basic functions, program judgment code blocks, cyclic code blocks, and the like, the specific actions in the third step can be dragging graphic blocks, clicking graphic blocks, double clicking graphic blocks, and the like, and a plurality of the specific actions are defined by developers to have different meanings.
Preferably, the independently executable function in the first step refers to a function that can independently perform a certain function, and the execution of any one function has no relation with other functions, and the function includes, but is not limited to, the execution of one action or the combination of a plurality of actions.
Preferably, the graphic blocks in the second step and the functions in the first step need to be in one-to-one correspondence, the number and types of input parameters included in the graphic blocks are sorted, the types of return values need to be consistent with the functions in the first step, and it is ensured that the codes generated according to the conversion relationship can normally run in the programmable device.
Preferably, the upper computer in the fourth step is an upper computer having the capability of connecting the programmable device and burning codes, the codes converted by the upper computer are defined by an upper computer developer, including but not limited to Python, C and JavaScript, and the codes of the language can be executed by the programmable device to determine the codes of the specific generated language.
Preferably, the programmable device in the sixth step comprises at least an original firmware and a medium storing the firmware, and the firmware has the capability of implementing the independently executed function in the first step.
Preferably, the controllable devices connected with the programmable device in the sixth step include, but are not limited to, various sensors, motors, steering engines and LED lamps.
The technical scheme of the invention has the following beneficial effects:
in the scheme, the graphic block is subjected to specific action, the code is automatically generated by the upper computer and then burned into the programmable device, the purpose that a user can directly control the target device by using the programmable device according to own logic and idea is achieved, the user can create unique exclusive programmable device without knowing grammar knowledge of any programming language and programming knowledge of hardware devices, the device is simple to use, professional codes do not need to be written, compiling is not needed, the code required by the user can be automatically generated only by executing the specific action on the graphic block, virtual reality is achieved, the experience of the user is improved, the interestingness of the user is increased, and the device is worthy of popularization.
Drawings
FIG. 1 is a block diagram of a system for programming a programmable device based on graphic blocks in accordance with the present invention;
FIG. 2 is a flow chart of a system for programming a programmable device based on graphic blocks in accordance with the present invention;
FIG. 3 is a flow chart of a method for controlling a programmable device based on graphic block programming in accordance with the present invention;
FIG. 4 is a flowchart of an embodiment of a method for programming a programmable device based on a graphics block;
FIG. 5 is a logic diagram illustrating the implementation of a method for programming a programmable device based on graphic blocks in accordance with the present invention;
fig. 6 is a code block conversion diagram of a method for controlling a programmable device based on graphic block programming according to the present invention.
Detailed Description
In order to make the technical problems, technical solutions and advantages of the present invention more apparent, the following detailed description is given with reference to the accompanying drawings and specific embodiments.
As shown in fig. 1 to 2, an embodiment of the present invention provides a system for controlling a programmable device based on a graphic block programming, including an upper computer programming software, a programmable device programming firmware, and a programmable device physical hardware, where the upper computer programming software is located inside the upper computer, the upper computer is electrically connected to the programmable device physical hardware, the programmable device programming firmware is installed on the programmable device physical hardware, and the programmable device physical hardware is electrically connected to a controllable device; the inside of host computer programming software is equipped with visual unit and procedure interpretation unit, and visual unit includes visual operation interface and virtual image interface, and visual operation interface includes a plurality of visual figure piece, and procedure interpretation unit includes node module and operation control module, and the node module includes a plurality of independent function, and independent function and visual figure piece are in the one-to-one in the function, and the inside of virtual image interface is equipped with virtual image and presents the module.
Specifically, the upper computer programming software needs a user to download to the upper computer, the upper computer is a computer capable of directly sending out control commands, the programmable device program firmware can be manufactured into boxes with different sizes and installed on the programmable device, the upper computer burns codes onto the programmable device program firmware, and the programmable device starts to execute actions according to the codes.
Specifically, the visual operation interface and the virtual image interface respectively occupy half of the area of the whole interface, and after a user executes a specific action on the graphic block, the virtual image interface presents a corresponding simulation scene, so that the user can know whether the user just operates correctly or not and whether the user wants to execute the logic or the action embodied by the equipment.
Specifically, the program interpretation unit is provided with node modules, the node modules are function blocks defined by developers, each function block corresponds to a specific function which can be realized by the executable device, and the node modules correspond to the visual graph blocks one to one.
As shown in fig. 2 to 6, a method for programming and controlling a programmable device based on a graphic block includes the following steps:
the method comprises the following steps: the programmable device developer packages the functions which can be realized by the device into independent execution functions according to the functions and the characteristics of the device;
step two: the upper computer developer defines a corresponding graphic block and a conversion relation between the graphic block and a code according to a function packaged by the programmable device;
step three: the user executes specific actions on the graphic block to complete the execution logic wanted by the user;
step four: connecting the programmable equipment with an upper computer by a user, and clicking a burning button;
step five: the upper computer converts the graphic block dragged by the user into a corresponding code and burns the corresponding code into the programmable equipment;
step six: and the programmable device automatically executes the burnt codes after the burning process is finished, and controls the device to execute corresponding logic and action according to the specific action of the user.
The graphic blocks in the third step are graphic blocks defined by a combined basic graphic block and an upper computer developer, the basic graphic blocks refer to graphic blocks corresponding to code basic syntax, such as definition and assignment of variables, text related basic functions, number related basic functions, program judgment code blocks, cyclic code blocks and the like, specific actions in the third step can be dragging graphic blocks, clicking graphic blocks, double clicking graphic blocks and the like, and a plurality of specific actions are defined to have different meanings by the developer.
Specifically, the basic combined graph blocks are conventional, while other graph blocks are defined by a developer himself according to functions of the executable device, and meanings represented by specific actions can be defined by the developer himself, for example: the single machine corresponds to selection, double-click corresponds to deselection, the single machine is dragged out to correspond to selection, and dragging return corresponds to cancellation.
Specifically, the upper computer interface can be manufactured into a touch screen interface, so that the use is more convenient.
The independent executable function in the step one refers to a function that can independently complete a certain function, and the execution of any function has no relation with other functions, and the function includes but is not limited to the execution of one action or an action group formed by combining a plurality of actions.
The graph blocks in the second step and the functions in the first step need to be in one-to-one correspondence, the number and types of input parameters contained in the graph blocks are sequenced, the types of return values need to be consistent with the functions in the first step, and it is ensured that codes generated according to the conversion relation can normally run in the programmable device.
The upper computer in the fourth step is an upper computer with the capability of connecting the programmable device and burning codes, the codes converted by the upper computer are defined by upper computer developers and include but are not limited to Python, C and JavaScript, and the programmable device can execute the codes of the language to determine the codes of the specific generated language.
Specifically, the upper computer converts the code into a function, and the specific generated code in which language is determined by the programmable device itself.
The programmable device in the sixth step at least comprises an original firmware and a medium for storing the firmware, and the firmware has the capability of realizing the independent execution function in the first step, so that the converted code of the upper computer can normally run in the device without any error.
And the controllable equipment connected with the programmable equipment in the step six comprises but is not limited to various sensors, motors, steering engines and LED lamps.
As shown in fig. 4, specifically, taking a steering engine as an example:
a user wants to rotate a steering engine, firstly drag a code block on a visual operation interface of an upper computer, click a drop-down box, select S1 and clockwise, then input a parameter of 90 degrees, then respectively connect the steering engine with a programmable device, the programmable device is connected with an upper computer, at the moment, the user on a virtual image interface can see a virtual scene that the steering engine rotates 90 degrees along the clockwise direction, the scene can help the user to confirm whether the previous operation is the action wanted by the user, the upper computer converts the code into a recognizable code according to a code converter of the upper computer, stores the user code into a file and then burns the user code into a fixed directory of an executable device, when the steering engine is started again, the user code is executed when a user code file exists under the corresponding directory, the function is called, and the function exists in the device firmware, the firmware can control the steering engine to start restarting and execute the action of rotating 90 degrees clockwise, and the whole process is finished.
As shown in fig. 5, the execution logic of the programmable device is shown, when the controllable device is powered on and started, the start execution code defined in the firmware of the programmable device is immediately executed, which enables the controllable device to start two threads, thread 1 monitors whether a code burning request exists, if so, the code is received, after the reception, the controllable device is immediately restarted, and if not, thread 2 is started; and the thread 2 checks whether a user code file exists in the corresponding directory of the controllable equipment, if so, the thread 2 executes codes in the file, and if not, the thread 2 destroys the file, the controllable equipment is in a standby state, and the whole process is finished.
Referring to fig. 6, a code language translation is illustrated, with corresponding translation based on code recognizable by the executable device itself.
The working process of the invention is as follows:
when a user wants to execute actions on a target device, the user can execute specific actions on a graphic block, then the programmable device and the upper computer are connected, at the moment, the user on the virtual image interface can see a virtual scene in which the controllable device can make corresponding actions, the scene can help the user to confirm whether the previous operation is the action required by the user, then the upper computer starts to convert the operation into a code which can be identified by the programmable device, the code is burnt and then burnt on the programmable device, the programmable device identifies a request with the burnt code, starts to restart and executes logic and actions required by the user.
The system and the method realize the purpose that the user can directly control the target equipment according to the logic and the idea of the user, so that the user can create unique exclusive programmable equipment without knowing the grammar knowledge of any programming language and the programming knowledge of hardware equipment.
The points to be finally explained are: first, in the description of the present application, it should be noted that, unless otherwise specified and limited, the terms "mounted," "connected," and "connected" should be understood broadly, and may be a mechanical connection or an electrical connection, or a communication between two elements, and may be a direct connection, and "upper," "lower," "left," and "right" are only used to indicate a relative positional relationship, and when the absolute position of the object to be described is changed, the relative positional relationship may be changed;
secondly, the method comprises the following steps: in the drawings of the disclosed embodiments of the invention, only the structures related to the disclosed embodiments are referred to, other structures can refer to common designs, and the same embodiment and different embodiments of the invention can be combined with each other without conflict;
and finally: the above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that are within the spirit and principle of the present invention are intended to be included in the scope of the present invention.