Remote information interaction method and device
The method and device for remote information interaction address the communication gap between LabVIEW and AnyLogic, optimizing data integration and reducing development costs by ensuring seamless data transfer and compatibility.
Patent Information
- Application Number
- CN202011140704.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-22
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2040-10-22
AI Technical Summary
Existing technologies are unable to facilitate communication between LabVIEW and AnyLogic, leading to challenges in data integration and simulation software development and maintenance costs.
A method and device for remote information interaction that enables data communication between LabVIEW and AnyLogic through a Socket server, utilizing storage units, writing and reading units, and data conversion processes to ensure data integrity and compatibility.
Facilitates seamless data interaction, reducing development time and costs for simulation and control software, enhancing user experience by ensuring data integrity and compatibility between LabVIEW and AnyLogic.
Smart Images

Figure CN112286700B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for remote information interaction. Background Art
[0002] LabVIEW (Laboratory Virtual Instrument Engineering Platform) is a program development environment, similar to the development environment of C language and BASIC language. The significant difference between LabVIEW and other computer languages is that other computer languages use text-based languages to generate codes, while LabVIEW uses the graphical editing language G to write programs. The programs it generates are in the form of block diagrams. Secondly, the limitations of software and hardware are relatively small, so it is relatively easy to connect with other instruments. Moreover, LabVIEW can be easily connected to the network, peripherals and other applications, and can also use the network for multi-user data sharing and use LabVIEW. At the same time, it is very convenient to compile various control programs. According to the actual needs of the project, users can use software programming or existing analysis software to perform various analyses and processes on test data in real time and directly. At the same time, the software-based architecture can greatly save development and maintenance costs, but in terms of simulation, LabVIEW has disadvantages such as programming difficulties and insufficient display. AnyLogic is a widely used tool for modeling and simulating discrete, system dynamics, multi-agent and hybrid systems. Compared with other simulation tools, AnyLogic is easy to learn and use. It is completely based on Java development and can support all Java applications. It has rich external resources. At the same time, the simulation results are clear and concise, and have a good display effect. If the two are combined, it can not only save the development time of simulation software and control software, but also the effect is very significant. In order to simulate the actual situation, the simulation software and the control software need to be distributed on different PCs (Personal Computers), which leads to the problem of communication between the two. In the prior art, it is impossible to realize the communication between LabVIEW and AnyLogic. Summary of the invention
[0003] The embodiments of the present invention provide a remote information interaction method and device, which realizes the communication between LabVIEW and AnyLogic.
[0004] In one aspect, an embodiment of the present invention provides a method for remote information interaction, comprising:
[0005] When a data interaction request sent by a predetermined client is monitored, storing the first interaction data in a first predetermined storage location;
[0006] The party to be interacted with reads the first interaction data stored in the first predetermined storage location, converts the read first interaction data into second interaction data, and writes the second interaction data into a second predetermined storage location;
[0007] When a data reading request sent by a predetermined client is received, the second interaction data in the second predetermined storage location is read.
[0008] Furthermore, before the step of storing the first interaction data in the first predetermined storage location when a data interaction request sent by a predetermined client is monitored, the method includes:
[0009] A Socket server is created, and an information processing interface and an information sending interface are created in the Socket server.
[0010] Furthermore, when a data interaction request sent by a predetermined client is monitored, storing the first interaction data in a first predetermined storage location includes:
[0011] When the Socket server monitors a data interaction request sent by a predetermined client, it determines whether the predetermined client is in a connected state;
[0012] If so, reading the first interaction data into a predetermined data object through the information processing interface;
[0013] The first interaction data stored in the predetermined data object is written into a first predetermined storage location.
[0014] Further, the method of reading the first interaction data stored in the first predetermined storage location by the party to be interacted with, converting the read first interaction data into second interaction data, and writing the second interaction data into the second predetermined storage location includes:
[0015] The party to be interacted reads the first interaction data from a first predetermined storage location based on a predetermined reading frequency;
[0016] storing the first interaction data in a predetermined data structure, and converting the first interaction data into second interaction data in a predetermined coding format based on the predetermined data structure;
[0017] Writing the second interaction data into a second predetermined storage location;
[0018] Before the step of storing the first interaction data in a predetermined data structure, the method further comprises:
[0019] A predetermined data structure for storing the first interaction data is pre-created.
[0020] Furthermore, before the step of storing the first interaction data in the first predetermined storage location when a data interaction request sent by a predetermined client is monitored, the method includes:
[0021] Create a switch button for sending and receiving data in the scheduled client.
[0022] Further, when receiving a data reading request sent by a predetermined client, reading the second interaction data in the second predetermined storage location includes:
[0023] When a data reading request sent by a predetermined client based on the switch button in a predetermined data transmission mode is received, the second interaction data in the second predetermined storage location is read.
[0024] Further, the reading the second interaction data in the second predetermined storage location includes:
[0025] Turn on the data connection by pressing the switch button;
[0026] Connecting the opening data with the reading data through the loop tunnel;
[0027] Based on the connection channel between the opening data and the reading data, the second interaction data in the second predetermined storage location is read.
[0028] On the other hand, an embodiment of the present invention provides a device for process information interaction, including:
[0029] A storage unit, configured to store the first interaction data in a first predetermined storage location when a data interaction request sent by a predetermined client is monitored;
[0030] a writing unit, configured to read the first interaction data stored in the first predetermined storage location through the party to be interacted with, convert the read first interaction data into second interaction data, and write the second interaction data into a second predetermined storage location;
[0031] The reading unit is configured to read the second interaction data in the second predetermined storage location when receiving a data reading request sent by a predetermined client.
[0032] Furthermore, it also includes:
[0033] The creation unit is used to create a Socket server, and to create an information processing interface and an information sending interface in the Socket server.
[0034] Furthermore, the storage unit is specifically used for:
[0035] When the Socket server monitors a data interaction request sent by a predetermined client, it determines whether the predetermined client is in a connected state;
[0036] If so, reading the first interaction data into a predetermined data object through the information processing interface;
[0037] The first interaction data stored in the predetermined data object is written into a first predetermined storage location.
[0038] The above technical solution has the following beneficial effects: through this solution, the party to be interacted reads the first interaction data in the first predetermined storage location, thereby realizing data communication between the server and the AnyLogic simulation machine. At the same time, the party to be interacted converts the first interaction data into the second interaction data and writes the second interaction data into the second predetermined storage location, thereby ensuring the integrity of the data and avoiding data loss. At the same time, it provides the necessary prerequisite for the subsequent LabVIEW client to read the second interaction data to be interacted by the party to be interacted. When a data reading request sent by a predetermined client is received, the second interaction data in the second predetermined storage location is read by the server, thereby realizing data interaction between the LabVIEW client and the AnyLogic simulation machine. Furthermore, the data interaction can obtain a better display effect, greatly saving the development time and development cost of the simulation software and the control software, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 A method flow chart of one embodiment of the present invention;
[0041] Figure 2 The figure is a schematic diagram of a device structure in one embodiment of the present invention. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] The above technical solution of the embodiment of the present invention has the following beneficial effects: through this solution, the party to be interacted reads the first interaction data in the first predetermined storage location, thereby realizing data communication between the server and the AnyLogic simulation machine. At the same time, the party to be interacted converts the first interaction data into the second interaction data and writes the second interaction data into the second predetermined storage location, thereby ensuring the integrity of the data and avoiding the loss of data. At the same time, it provides the necessary prerequisite for the subsequent LabVIEW client to read the second interaction data to be interacted by the party to be interacted. When a data reading request sent by a predetermined client is received, the server reads the second interaction data in the second predetermined storage location, thereby realizing data interaction between the LabVIEW client and the AnyLogic simulation machine. Furthermore, the data interaction can obtain a better display effect, greatly saving the development time and development cost of the simulation software and the control software, and improving the user experience.
[0044] The above technical solution of the embodiment of the present invention is described in detail below with reference to application examples:
[0045] In a possible implementation, in an information interaction system S, a Socket server is created based on Java, and an information processing interface and an information sending interface are created on the Socket server side; a data interaction request sent by a predetermined client is monitored by the Socket server, and when the Socket server monitors a data interaction request sent by a predetermined client, such as a LabVIEW client, first interaction data is stored in a first predetermined storage location, such as a folder 1 at a predetermined location; when the party to be interacted with, such as an AnyLogic simulation machine, starts to read data, the first interaction data stored in folder 1 is read into the AnyLogic simulation machine; the first interaction data is converted into second interaction data by the AnyLogic simulation machine, and the second interaction data is written into a second predetermined storage location, such as a folder 2 at a predetermined location; when the Socket server receives a data read request sent by the LabVIEW client, the second interaction data in folder 2 is read.
[0046] In a possible implementation, step 101 stores the first interaction data in a first predetermined storage location when a data interaction request sent by a predetermined client is monitored, including: when the Socket server monitors the data interaction request sent by the predetermined client, determining whether the predetermined client is in a connected state; if so, reading the first interaction data into a predetermined data object through the information processing interface; and writing the first interaction data stored in the predetermined data object into the first predetermined storage location.
[0047] For example, in the information interaction system S, when the Socket server listens to a data interaction request sent by a predetermined client, it prepares a predetermined data object of fixed bytes and a file to be stored through an information processing interface, and then determines whether the LabVIEW client is in a connected state. If so, the first interaction data is read in a loop into the predetermined data object; and the first interaction data stored in the predetermined data object is written into a first predetermined storage location, such as folder 1 at the predetermined location.
[0048] In a possible implementation, step 102 includes: the party to be interacted reads the first interaction data stored in the first predetermined storage location, converts the read first interaction data into second interaction data, and writes the second interaction data into a second predetermined storage location, including: the party to be interacted reads the first interaction data from the first predetermined storage location based on a predetermined reading frequency; stores the first interaction data in a predetermined data structure, and converts the first interaction data into second interaction data in a predetermined encoding format based on the predetermined data structure; and writes the second interaction data into the second predetermined storage location.
[0049] Before the step of storing the first interaction data in a predetermined data structure, the method includes: pre-creating a predetermined data structure for storing the first interaction data.
[0050] For example, in the information interaction system S, a predetermined data structure for storing first interaction data is pre-created; when the Socket server listens to a data interaction request sent by the LabVIEW client, the first interaction data is stored in a folder 1 at a predetermined location; when the AnyLogic simulator initiates a data read request, the AnyLogic simulator reads the first interaction data stored in the folder 1, and then the AnyLogic simulator reads the first interaction data from the first predetermined storage location based on a predetermined reading frequency; the first interaction data is stored in a predetermined data structure through an internal function of the AnyLogic simulator, and the first interaction data is converted into second interaction data in a predetermined encoding format based on the predetermined data structure, and then the second interaction data is written into a second predetermined storage location, such as a folder 2 at a predetermined location.
[0051] In a possible implementation, when a data interaction request sent by a predetermined client is monitored in step 101, before the step of storing the first interaction data in a first predetermined storage location, it includes: creating a switch button for sending and receiving data in the predetermined client.
[0052] Among them, step 103 reads the second interaction data in the second predetermined storage location when a data read request sent by a predetermined client is received, including: when a data read request sent by a predetermined client based on the switch button in a predetermined data transmission method is received, the second interaction data in the second predetermined storage location is read.
[0053] Among them, reading the second interactive data in the second predetermined storage location in step 103 includes: turning on the data connection through the switch button; connecting the turn-on data with the read data through the loop tunnel; and reading the second interactive data in the second predetermined storage location based on the connection channel between the turn-on data and the read data.
[0054] For example, in the information interaction system S, a switch button for sending and receiving data is created in the LabVIEW client. The LabVIEW client sends a data read request through the switch button in a predetermined data transmission mode, such as TCP (Transmission Control Protocol) transmission mode. When the Socket server receives the data read request sent by the LabVIEW client based on the switch button in the predetermined data transmission mode, it reads the second interaction data in folder 2.
[0055] In a specific application scenario, in an information interaction system S, a LabVIEW client is created to process sending and receiving information; a model of an AnyLogic simulator is created, and functions for reading and writing information are created in the AnyLogic simulator; two Socket servers with different threads are created based on Java, and different port numbers are defined respectively to monitor requests for receiving and sending information, and methods are created in the two threads for exception handling; an information processing interface and an information sending interface are created at the same time. Specifically, the information processing interface is created by defining global variables, such as Socket, creating methods for exception handling, obtaining monitored information through an input stream, preparing fixed-byte data objects and files to be stored, determining whether the client is connected in a loop, and looping through fixed-byte data objects to read information and write the information to files to be stored; the information sending interface is created by defining global variables, such as Socket, creating methods for exception handling, The output stream obtains the monitored information, prepares the file to be read, allocates a temporary memory space to store the file data, reads the file into memory, converts the data into a string, and sends the file to the LabVIEW client; creates a loop in the LabVIEW client block diagram, creates a constant at the loop condition, adds an event structure to the loop body, and creates a send data and receive data switch button, and adds a structure branch to the event structure, which is used to send and receive information respectively; creates an open TCP connection in the send information event structure, enters the port number, sets the timeout in milliseconds, if it is -1, changes the IP address to the IP of the server host, creates another loop, puts the write TCP data function into it, sets the timeout in milliseconds, if it is -1, and creates an input control to write the information to be sent, then connects the open TCP connection error output to the write TCP data error input, changes the loop tunnel to a shift register, and connects the write TCP data error output to the other end of the shift register. Repeat the above operations for the connection ID of the open TCP connection and the write TCP data. In the event structure of receiving information, create an open TCP connection, enter the port number, set the timeout in milliseconds, if it is -1, change the IP address to the IP of the server host, create a read TCP data function, specify the number of bytes to read each time, set the timeout in milliseconds, if it is -1, and create a display control to display the received data, then connect the open TCP connection error output to the read TCP data error input, and repeat the above operations for the connection ID. Drag the function into the intelligent agent type created in the AnyLogic simulation machine model, prepare the encoding format to be returned in the function body, initialize the file to be read, initialize the length of the file to be read, and create an object to receive the length of the read file.In one exception handling, the initialized file to be read is received through the IO (Input / Output) method, and then the file content is read into the previously created object, and the IO is closed. In another exception handling, the received information is returned in the form of UTF-8 (Universal Character Set / Unicode Transformation Format, a variable-length character encoding for Unicode); variable A is created to receive data, and an event is created to read the data. The mode is changed to a loop, and the read data is placed in variable A in the action; when writing information, a function is dragged into the agent type created in the AnyLogic simulation model, and the encoding format to be returned is prepared in the function body, the file to be written is instantiated and exception handling is performed, and then the file is written and the stream is closed; finally, the encoding format initialized above is returned; an event is created to specify the content to be written in the file write.
[0056] An embodiment of the present invention provides a device for remote information interaction, which can implement the method embodiment provided above. For specific function implementation, please refer to the description in the method embodiment, which will not be repeated here.
[0057] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process can be rearranged without departing from the scope of protection of the present disclosure. The attached method claims present the elements of the various steps in an exemplary order and are not intended to be limited to the specific order or hierarchy described.
[0058] In the above detailed description, various features are grouped together in a single embodiment to simplify the disclosure. This method of disclosure should not be interpreted as reflecting an intention that the embodiments of the claimed subject matter require more features than are clearly stated in each claim. On the contrary, as reflected in the appended claims, the invention is in a state of having less than all the features of the disclosed individual embodiments. Therefore, the appended claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
[0059] The disclosed embodiments are described above to enable any person skilled in the art to implement or use the present invention. Various modifications of these embodiments are obvious to those skilled in the art, and the general principles defined herein may also be applied to other embodiments without departing from the spirit and scope of the present disclosure. Therefore, the present disclosure is not limited to the embodiments given herein, but is consistent with the broadest scope of the principles and novel features disclosed in this application.
[0060] The above description includes examples of one or more embodiments. Of course, it is impossible to describe all possible combinations of components or methods for the purpose of describing the above embodiments, but it should be recognized by those skilled in the art that the various embodiments may be further combined and arranged. Therefore, the embodiments described herein are intended to cover all such changes, modifications and variations that fall within the scope of protection of the appended claims. In addition, with respect to the term "comprising" used in the specification or claims, the word is covered in a manner similar to the term "including", just as "including," is explained as a transitional word in the claims. In addition, any term "or" used in the specification of the claims is intended to mean "non-exclusive or".
[0061] Those skilled in the art may also understand that the various illustrative logical blocks, units, and steps listed in the embodiments of the present invention may be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly demonstrate the interchangeability of hardware and software, the various illustrative components, units, and steps described above have generally described their functions. Whether such functions are implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the described functions for each specific application, but such implementation should not be understood as exceeding the scope of protection of the embodiments of the present invention.
[0062] The various illustrative logic blocks or units described in the embodiments of the present invention can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of the above. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any conventional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a digital signal processor core, or any other similar configuration.
[0063] The steps of the method or algorithm described in the embodiments of the present invention can be directly embedded in hardware, a software module executed by a processor, or a combination of the two. The software module can be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM, or other storage media of any form in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Optionally, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC, and the ASIC can be arranged in a user terminal. Optionally, the processor and the storage medium can also be arranged in different components in the user terminal.
[0064] In one or more exemplary designs, the above functions described in the embodiments of the present invention can be implemented in hardware, software, firmware or any combination of the three. If implemented in software, these functions can be stored on a computer-readable medium, or transmitted in the form of one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media that facilitate the transfer of computer programs from one place to another. The storage medium can be any available medium that can be accessed by any general or special computer. For example, such computer-readable media can include but are not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program codes in the form of instructions or data structures and other forms that can be read by general or special computers, or general or special processors. In addition, any connection can be appropriately defined as a computer-readable medium, for example, if the software is transmitted from a website site, server or other remote resource through a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wirelessly, such as infrared, wireless and microwave, it is also included in the defined computer-readable medium. The disk and disc include compact disk, laser disk, optical disk, DVD, floppy disk and blue-ray disk. Disks usually copy data magnetically, while discs usually copy data optically with lasers. The above combination can also be included in computer readable media.
[0065] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for remote information interaction, It is characterized in that include: When a data interaction request sent by a predetermined client is monitored, storing the first interaction data in a first predetermined storage location; The party to be interacted with reads the first interaction data stored in the first predetermined storage location, converts the read first interaction data into second interaction data, and writes the second interaction data into a second predetermined storage location; When receiving a data reading request sent by a predetermined client, reading the second interaction data in the second predetermined storage location; Before the step of storing the first interaction data in the first predetermined storage location when a data interaction request sent by a predetermined client is monitored, the method includes: Create a Socket server, and create an information processing interface and an information sending interface in the Socket server; The method of reading the first interaction data stored in the first predetermined storage location by the party to be interacted with, converting the read first interaction data into second interaction data, and writing the second interaction data into the second predetermined storage location includes: The party to be interacted reads the first interaction data from a first predetermined storage location based on a predetermined reading frequency; storing the first interaction data in a predetermined data structure, and converting the first interaction data into second interaction data in a predetermined coding format based on the predetermined data structure; Writing the second interaction data into a second predetermined storage location; Before the step of storing the first interaction data in a predetermined data structure, the method further comprises: pre-creating a predetermined data structure for storing first interaction data; The reading the second interaction data in the second predetermined storage location includes: Turn on the data connection by pressing the switch button; Connect the open data with the read data through a loop tunnel; Based on the connection channel between the opening data and the reading data, reading the second interaction data in the second predetermined storage location; The party to be interacted is AnyLogic, and the client is LabVIEW.
2. The method according to claim 1, It is characterized in that When a data interaction request sent by a predetermined client is monitored, storing the first interaction data in a first predetermined storage location includes: When the Socket server monitors a data interaction request sent by a predetermined client, it determines whether the predetermined client is in a connected state; If so, reading the first interaction data into a predetermined data object through the information processing interface; The first interaction data stored in the predetermined data object is written into a first predetermined storage location.
3. The method according to any one of claims 1 to 2, It is characterized in that Before the step of storing the first interaction data in the first predetermined storage location when a data interaction request sent by a predetermined client is monitored, the method includes: Create a switch button for sending and receiving data in the scheduled client.
4. The method according to claim 3, It is characterized in that The step of reading the second interaction data in the second predetermined storage location when receiving a data reading request sent by a predetermined client includes: When a data reading request sent by a predetermined client based on the switch button in a predetermined data transmission mode is received, the second interaction data in the second predetermined storage location is read.
5. A device for remote information interaction, It is characterized in that include: A storage unit, configured to store the first interaction data in a first predetermined storage location when a data interaction request sent by a predetermined client is monitored; a writing unit, configured to read the first interaction data stored in the first predetermined storage location through the party to be interacted with, convert the read first interaction data into second interaction data, and write the second interaction data into a second predetermined storage location; a reading unit, configured to read the second interaction data in the second predetermined storage location when receiving a data reading request sent by a predetermined client; The reading unit is further used for: Create a Socket server, and create an information processing interface and an information sending interface in the Socket server; The writing unit is specifically used for: The party to be interacted reads the first interaction data from a first predetermined storage location based on a predetermined reading frequency; pre-creating a predetermined data structure for storing first interaction data; storing the first interaction data in a predetermined data structure, and converting the first interaction data into second interaction data in a predetermined coding format based on the predetermined data structure; Writing the second interaction data into a second predetermined storage location; The reading unit is specifically used for: Turn on the data connection by pressing the switch button; Connect the open data with the read data through a loop tunnel; Based on the connection channel between the opening data and the reading data, reading the second interaction data in the second predetermined storage location; The party to be interacted is AnyLogic, and the client is LabVIEW.
6. The device according to claim 5, It is characterized in that Also includes: The creation unit is used to create a Socket server, and to create an information processing interface and an information sending interface in the Socket server.
7. The device according to claim 6, It is characterized in that The storage unit is specifically used for: When the Socket server monitors a data interaction request sent by a predetermined client, it determines whether the predetermined client is in a connected state; If so, reading the first interaction data into a predetermined data object through the information processing interface; The first interaction data stored in the predetermined data object is written into a first predetermined storage location.
