Disclosure of Invention
The invention aims to provide an intelligent remote control shield machine and a method for simulating a 3D test bed, and solves the problems of inconvenient operation and poor hand feeling of the existing industrial personal computer remote control shield machine and splicing machine remote control 3D test bed.
The invention provides an intelligent remote control shield tunneling machine and a method for simulating a 3D test bed for solving the technical problems, wherein the method comprises the following steps:
1) selecting a remote control handle for remotely controlling the shield machine and the simulation 3D test bed, and writing a driving program of the remote control handle in a windows service mode;
2) carrying out associated configuration on the selected key of the remote control handle, the shield tunneling machine and the PLC point location information of the simulation 3D test stand to form a configuration file;
3) and acquiring an API function of the remote control handle, capturing the remote control handle according to the API function of the remote control handle, detecting whether a key is triggered, and if yes, performing read-write operation on the PLC point location information of the shield machine and the simulation 3D test bed according to the configuration file.
The method comprises the steps of carrying out association configuration on keys of a remote control handle, a shield tunneling machine and PLC point location information of a simulation 3D test bed to form a configuration file; and by capturing the remote control handle and detecting whether a key is triggered or not, if yes, reading and writing the PLC point location information of the shield tunneling machine and the simulation 3D test bed according to the configuration file. The invention can remotely control the shield machine and the simulation 3D test bed based on the existing game handle, and solves the defects of inconvenient operation, poor hand feeling and the like of the remote control 3D test bed of the shield machine and the splicing machine controlled by the industrial personal computer.
Further, when the digital key of the remote control handle is detected to be pressed down in the step 3), writing operation is performed on the PLC according to the PLC point location information bound by the key value in the configuration file; when the key of the remote control handle is detected to be lifted, restoring the point location information of the PLC to the original position; and when the simulated key of the remote control handle is detected to be pressed down, determining whether to write the PLC according to the interval duration and the variation range of the two previous detections.
Furthermore, the simulation button is a left rocker and a right rocker of the handle, the stopwatch mode is adopted to detect the triggered time of the left rocker and the right rocker of the handle, and when the interval time between the two times of detection is greater than the set time threshold value and the variation range of the left rocker and the right rocker of the two times of detection is greater than the set threshold value, corresponding writing operation is carried out on the PLC.
Further, the configuration file is in an XML format.
Further, when the configuration file is started to be loaded, the point location information of the PLC configured according to the configuration file is loaded into different formats and stored in the memory.
Further, when the handle key is triggered, different API functions in the Snap7 control are called according to different key values, and then reading and writing PLC operation is achieved.
Detailed Description
The following further describes embodiments of the present invention with reference to the drawings.
The invention provides a method for intelligently remotely controlling a shield machine and a 3D test bed by using a remote control handle, which aims to solve the defects of inconvenient operation, poor hand feeling and the like of a remote control 3D test bed of an industrial personal computer remote control shield machine and an assembling machine, and the method realizes the intelligent remote control of the remote control shield machine and the 3D test bed by using the remote control handle; then, carrying out associated configuration on the keys of the selected remote control handle and PLC point location information of the shield tunneling machine and the simulation 3D test stand to form a configuration file; and finally, by capturing the remote control handle, detecting whether a key is triggered or not, and if yes, performing read-write operation on the PLC point location information of the shield tunneling machine and the simulation 3D test bed according to the configuration file. The specific implementation flow of the method is shown in fig. 1, and the specific implementation process is as follows.
1. And selecting the type and manufacturer of the remote control handle according to actual requirements.
The existing remote control handle comprises a wired remote control handle and a wireless remote control handle, and can be used according to the actual project requirements; the popular game pad manufacturers in the market include north-pass, nintendo, microsoft, sony and other well-known manufacturers, and the manufacturers selected in this embodiment are north-pass, for example, north-pass wired bat game pads and north-pass wireless time game pads can be adopted.
2. And writing a driving program of the remote control handle in a windows service mode, and defining key values.
A game handle driving program is realized in a windows service program, the driving program is used for monitoring whether keys of a game handle are pressed down, and simultaneously, digital keys, simulation keys and different key values of the keys are required to be distinguished, wherein the simulation keys in the game handle only comprise a left rocker and a right rocker, and the keys of other game handles are digital keys.
The game handle keys can be automatically added with relevant drives after being inserted into a computer U port for the first time, and a windows service program codes the game handle keys according to relevant data provided by a game handle manufacturer, so that the simulation keys, the digital keys and the keys can be distinguished through different key values. The windows service does not support dialog box pop itself, and the dialog box pop adopted by the service is a functional module developed by combining c # with IntPtrStruct in Microsoft NET framework.
The game handle selected in the embodiment comprises two types of digital keys and simulation cases, and key values of the two types of keys are defined as follows. Wherein the key values defined by the number keys are as follows: none is 0x0, UP is 0x01, Down is 0x02, Left is 0x04, Right is 0x08, B1 is 0x10, B2 is 0x20, B3 is 0x40, B4 is 0x80, B5 is 0x100, B6 is 0x200, B7 is 0x400, B8 is 0x800, B9 is 0x1000, B10 is 0x 2000. The key values defined by the simulated keys are as follows: the central position of the rocker is 32768, the left side is 0 and the right side is 65535 when the rocker is shaken left and right; when the device is shaken up and down, the lower edge is 0, and the upper edge is 65535.
3. And carrying out associated configuration on key values of the remote control handle and PLC (programmable logic controller) point location information of the shield tunneling machine and the simulation 3D test bed to form a configuration file.
The shield machine and the 3D test bed of the invention use Siemens PLC, Siemens provide an open-source control Snap7 for reading and writing PLC; the blocks frequently used by Siemens PLC include DB blocks, M blocks and I blocks, and the common types include single-precision floating point type, BOOL type, unsigned short shaping, signed short shaping and byte array type, and the point location information of each PLC corresponds to the start address of a certain block, and the end address is obtained according to the field type shown.
According to the method, according to predefined function key descriptions, the PLC point location information of a handle key, a shield machine and a simulation 3D test bed is written into a configuration file in an xml format, and a windows service program loads the configuration file when being started; displaying the function keys of the game handle and the PLC point location information in a configuration file manner, wherein the function keys and the PLC point location information are mainly used for conveniently changing the function values of the function keys of the game handle; when the handle key function needs to be changed, only the configuration file needs to be modified, and the format of the configuration file is shown in fig. 2. when the windows service program starts to load the configuration file, the PLC point location information configured according to the configuration file is loaded into different formats and stored in the memory.
4. And capturing the remote control handle, detecting whether a key is triggered or not, and performing read-write operation on the PLC according to the triggered condition of the key.
The invention captures the game handle according to the API function related to the handle; if the game handle is captured, triggering a timer; the timer is used for detecting whether the handle is pressed down by a key, the default setting of the timing interval is 10ms, and the interval time can be configured. The method comprises the following steps that a person manually triggers a handle key for one time, generally, the time is at least more than 50ms, so that a windows service program can be set to 10ms enough to detect whether the handle key is pressed down or not; if the windows service program does not capture the game handle, prompting that the connection of the game handle fails and asking for reconnection; meanwhile, different abnormal conditions are prompted according to the obtained error codes. When the game handle key is triggered, different API functions in the Snap7 control are called according to different key values, and read-write PLC operation is achieved according to the configuration file.
Specifically, since the cases of the remote control handle in this embodiment include the digital keys and the analog cases, the detection of the triggering thereof is different. When the digital key is detected to be pressed down, the windows service program can write the PLC according to the PLC point location information bound by the key value in the configuration file; meanwhile, when the key is detected to be lifted, the service program can restore the point location information of the PLC to the original position; when the simulation key is detected to be pressed, namely the left rocker and the right rocker of the handle are triggered, the change range of the left rocker and the right rocker of the handle is between 0 and 65535, in order to meet the actual engineering requirements, corresponding processing needs to be carried out on the rocker value, a stopwatch mode is adopted in a windows service program, the mode is used for accurately calculating time and can be accurate to a nanosecond level, when the interval time between the two times before and after detection is larger than 10ms and the change range of the two times before and after detection is larger than 100, the PLC is written, and then the control over the shield tunneling machine and the simulation 3D test bed is realized.
The method can be realized by compiling the Windows service program, so that the Windows service program can monitor whether the keys of the game handle are pressed down and can read and write the PLC point location information according to different key values. The windows service program is also a process essentially, and after the service deployment is finished, the registration list can be modified to prevent the service from being abnormally finished, and the windows service can be automatically started after the windows service is finished by utilizing a trigger mechanism of the windows service; or a process can be independently written to monitor whether the windows service is running or not at regular time, if the windows service is running, nothing is done, and if the windows service is not running, the windows service is restarted.
Through the process, the shield machine and the simulation 3D test bed can be remotely controlled based on the existing game handle, the defects of inconvenient operation, poor hand feeling and the like of the shield machine remotely controlled by the industrial personal computer and the splicing machine remotely controlled 3D test bed are overcome, the user experience and satisfaction are improved, and the application prospect is good.