Disclosure of Invention
Aiming at the problems in the prior art, the embodiment of the invention provides a method and a system for station terminal data interaction, which can fundamentally overcome the defects of high program coupling and high difficulty in system expansion and maintenance during station terminal data interaction.
The invention provides a method for data interaction of a station terminal, which comprises the following steps:
receiving a first subscription request sent by a target terminal, wherein the first subscription request is generated by the target terminal according to the current running state of a train;
responding to the first subscription request, and sending train operation data to the target terminal; the train operation data is issued by a train state data acquisition device.
According to the station terminal data interaction method provided by the invention, before responding to the first subscription request and sending train operation data to the target terminal, the method further comprises the following steps:
generating a plurality of second subscription requests according to the first subscription request based on a subscription list;
sending the second subscription request to a plurality of target data acquisition devices;
and receiving the train operation subdata issued by each target data acquisition device to acquire the train operation data.
According to the method for data interaction of the station terminal provided by the invention, after receiving the train operation subdata issued by each target data acquisition device, the method further comprises the following steps:
and converting the train operation sub data into data in a JSON format.
According to the station terminal data interaction method provided by the invention, the JSON format data consists of 4 parts, which are respectively: a control header portion, an encapsulation length portion, a variable header portion, and a message body portion;
the control head part comprises 1byte and is used for marking the type and the grouping type identification of the train operation subdata;
the packaging length part comprises 1-4 bytes and is used for marking the data size of the train operation subdata;
the variable head part comprises N bytes and a message identifier of the train operation subdata, wherein N is an integer greater than or equal to 0;
the message body part comprises X bytes and specific contents of the train operation sub data, wherein X is an integer greater than or equal to 0.
According to the method for data interaction of the station terminal provided by the invention, when the first subscription request contains the current state of the train, the step of responding to the first subscription request and sending the train operation data to the target terminal comprises the following steps:
if the current state of the train is inter-station operation, the first subscription request is responded, and at least one of the following information is sent to the target terminal: the train running direction, the next station information, the terminal station information, the time information of arriving at each station, the door opening direction information, and the advertisement or propaganda video information;
if the current state of the train is an upcoming station, the first subscription request is responded, and at least one of the following information is sent to the target terminal: station equipment information and export information of the target station.
The method for station terminal data interaction provided by the invention further comprises the following steps:
sending a third subscription request to the target terminal;
and acquiring the terminal operation data issued by the target terminal.
According to the station terminal data interaction method provided by the invention, the terminal operation data comprises at least one of the following information: and the equipment state information, the video information and the advice information of the target terminal.
The invention also provides a method for data interaction of the station terminal, which comprises the following steps:
sending a subscription request to an MQTT server according to the current running state of the train;
receiving train operation information sent by the MQTT server; the train operation information is issued by a train state data acquisition device;
and displaying the train operation data to passengers.
The invention also provides a system for station terminal data interaction, which comprises:
the system comprises a receiving module, a sending module and a receiving module, wherein the receiving module is used for receiving a first subscription request sent by a target terminal, and the first subscription request is generated by the target terminal according to the current running state of a train;
the sending module is used for responding to the first subscription request and sending train operation data to the target terminal;
and the operation module is used for determining the train operation data from the data issued by the train state data acquisition device.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor executes the program to realize the steps of any one of the above-mentioned station terminal data interaction methods.
The present invention also provides a non-transitory computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, implements the steps of the method for station terminal data interaction as described in any one of the above.
The station terminal data interaction method and the system provided by the invention adopt the decoupled MQTT framework of the publish-subscribe mode to provide one-to-many message publishing and release the coupling of each terminal device of the station aiming at the defects of diversity of station terminal devices, complicated data interface types and lack of specifications, thereby greatly improving the expandability and maintainability of the station devices and simultaneously improving the real-time property of system message transmission.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The method and the system for station terminal data interaction provided by the embodiment of the invention are described below with reference to fig. 1 to 7.
Fig. 1 is a schematic flow diagram of a method for station terminal data interaction provided by the present invention, as shown in fig. 1, including but not limited to the following steps:
step S1: receiving a first subscription request sent by a target terminal, wherein the first subscription request is generated by the target terminal according to the current running state of a train;
step S2: responding to the first subscription request, and sending train operation data to the target terminal; the train operation data is issued by a train state data acquisition device.
Before explaining the method for terminal data interaction of the station provided by the invention, a terminal data interaction mode commonly adopted by a target in the field of rail transit can be known firstly.
Fig. 2 is a schematic diagram of a software framework for data interaction of each station terminal in the prior art, and as shown in fig. 2, a multi-protocol interface architecture based on Mysql software is generally adopted in the prior art. The Mysql is a relational database management system, and the relational database stores the acquired data acquired by the train state data acquisition unit in the database in advance in different list modes, so that the data interaction speed can be increased to a certain extent.
The station terminal in the invention is mostly a real-time client, such as: smart watches, robots, comprehensive monitoring, display screens, OLEDs and the like, so the client has a high real-time requirement on data. When the existing data interaction mode shown in fig. 2 is adopted, the train state acquisition data is stored in the Mysql database, and then the required data is searched from the Mysql database based on the multi-protocol service, and then the required data is packaged and sent to the client of each station terminal. Because data interaction is realized between each station terminal and the Mysql database through each corresponding interface protocol (for example, common interface protocols comprise an http interface protocol, a tcp/udp interface protocol, a Mysql interface protocol, a soap interface protocol, an REST interface protocol and the like), when information to be received by the terminal display equipment is in various types, if a multi-protocol interface frame is adopted, the problems of large interface complexity and incompatible data organization modes are caused, and the problems of high coupling, high expansion and maintenance cost and the like of the multi-protocol interface frame are more prominent.
Fig. 3 is a schematic diagram of a software framework for performing data interaction, and as shown in fig. 3, the method for performing data interaction at a station terminal according to the present invention selects a Message Queue Telemetry Transport (MQTT) architecture based on a publish-subscribe architecture technology to implement real-time data interaction based on two aspects of real-time performance and decoupling performance, so as to effectively avoid the disadvantage of implementing data interaction through different interface protocols, and implement data interaction based on low-overhead, low-bandwidth, high-real-time performance, and low-coupling network transmission.
MQTT is a message protocol based on a publish/subscribe paradigm under the ISO standard (ISO/IEC PRF 20922), and has the following main characteristics:
1. providing one-to-many message publishing using a publish/subscribe message schema, decoupling applications;
2. message transmission for load content shielding;
3. providing a network connection using TCP/IP;
4. there are three message publishing quality of service:
5. small size transmission, small overhead (fixed length header is 2 bytes), minimized protocol exchange to reduce network traffic;
6. the Last wild and maintenance features are used to inform the mechanism about client aborts on various parties.
Specifically, the target terminal may be any one of clients such as a smart watch, a robot, a comprehensive monitor, a screen, and an OLED. The invention provides a method for data interaction of a station terminal, which comprises the following steps:
the target terminal subscribes train operation information to an MQTT server (MQTT Broker), and can generate a subscription request according to the current operation state of a train and send the subscription request to the MQTT Broker in real time in the train operation process. The current operation state of the train may be a train entering state or a state of being operated between stations, or may be a current mileage state, a speed state, or the like of the train, which is not specifically limited in the present invention.
After receiving a first subscription request of a train, the MQTT Broker acquires relevant operation data from a corresponding train state data acquisition device according to a request list of the first subscription request, integrates the operation data and then releases the integrated operation data to a target terminal.
And the target terminal displays the train operation data corresponding to the first subscription request to the passenger after receiving the train operation data which is sent by the MQTT Broke and corresponds to the first subscription request.
The station terminal data interaction method provided by the invention adopts the decoupled MQTT framework of the publishing and subscribing mode to provide one-to-many message publishing and release the coupling of each station terminal device, thereby greatly improving the expandability and maintainability of the station device and simultaneously improving the real-time performance of system message transmission aiming at the defects of diversity, complicated data interface types and lack of specifications of the station terminal devices.
Based on the content of the foregoing embodiment, as an optional embodiment, before sending the train operation data to the target terminal in response to the first subscription request, the method further includes:
generating a plurality of second subscription requests according to the first subscription request based on a subscription list;
sending the second subscription request to a plurality of target data acquisition devices;
and receiving the train operation subdata issued by each target data acquisition device to acquire the train operation data.
It should be noted that, in the method for data interaction of station terminals provided by the present invention, the train operation data required to be acquired by each different target terminal is generally different, and for example, the train operation information and the environment information in the train car may be sent to different station terminals. And the operation data required by the same target terminal also comprises data acquired and issued by a plurality of different target train state data acquisition devices.
For example: in the case that the request list of the first subscription request includes 3 different operation data, and the 3 different operation data need to be collected by A, B, C three different train state data collecting devices in real time, the subscription request can be sent to the A, B, C device through the MQTT Broker, respectively. A. B, C the device publishes the collected data to MQTT Broker according to the subscription request. And then the MQTT Broker packs and issues all data to the target terminal according to the request list.
Optionally, each target data acquisition device may publish train operation sub-data acquired by the target data acquisition device to the MQTT Broker in real time, and after the MQTT Broker receives the second subscription request, select data related to the request list from the operation sub-data published by all trains according to the request list of the second subscription request, and send the data to the target terminal.
According to the station terminal data interaction method, the release subscription architecture technology MQTT is selected as a basic framework of data interaction, the relevant train operation subdata can be obtained from all train state data acquisition devices in real time according to the subscription list of the target terminal, and the real-time requirement of data interaction can be effectively met.
Based on the content of the foregoing embodiment, as an optional embodiment, after the receiving the train operation sub-data issued by each target data acquisition device, the method further includes: and converting the train operation sub data into data in a JSON format.
JSON (JSON), also called Object Notation, is a lightweight data exchange format. It is based on a subset of ECMA Script (js specification by the european computer association) that stores and represents data in a text format completely independent of the programming language, and a compact and clear hierarchy makes JSON an ideal data exchange language.
In the current rail transit system, the data organization mode is mostly binary or XML, which causes the server and client codes to become abnormally complex and difficult to maintain, and the main reason is that: binary data lack readability, which is not beneficial to data expansion; although the data organization mode of XML has no readability problem, the format is complex, transmission occupies bandwidth, and both the server and the client need to spend a large amount of codes to analyze XML.
According to the station terminal data interaction method, through the adoption of the JSON data organization mode, the advantages of simple format, easiness in reading and writing, small occupied bandwidth and the like of JSON data are utilized, the network transmission efficiency can be effectively improved, the analysis is easy, the code development amount of a server side and a client side can be greatly simplified, and the maintenance and the expansion are easy.
Based on the content of the foregoing embodiment, as an optional embodiment, the data in the JSON format is composed of 4 parts, which are: a control header portion, an encapsulation length portion, a variable header portion, and a message body portion;
the control head part comprises 1byte and is used for marking the type and the grouping type identification of the train operation subdata;
the packaging length part comprises 1-4 bytes and is used for marking the data size of the train operation subdata;
the variable head part comprises N bytes and a message identifier of the train operation subdata, wherein N is an integer greater than or equal to 0;
the message body part comprises X bytes and specific contents of the train operation sub data, wherein X is an integer greater than or equal to 0.
Fig. 4 is a schematic diagram of a data structure of the MQTT provided by the present invention, and as shown in fig. 4, the data structure of the MQTT provided by the present invention adopts a JSON format, which mainly includes 4 parts, a Control Header part (Control Header), a packing Length part (packing Length), a Variable Header part (Variable Header), and a message body part (Payload). Wherein, the Control Header exists in all MQTT data packets, represents the type of the data packet and the grouping class identifier of the data packet, and the length thereof can be generally 1 byte; the Package Length is used for indicating the Length of the data packet; the Variable header exists in partial MQTT data packets, and the type of the data packet determines whether the Variable header exists and the specific content of the Variable header; payload exists in a partial MQTT data packet and represents specific content received by a client.
The station terminal data interaction method provided by the invention adopts a decoupled publish-subscribe network structure, the data organization adopts JSON format data easy to expand and maintain, the software architecture adopts an MQTT framework in a publish-subscribe mode, the program coupling is reduced from two levels of data and architecture, and the difficulty and cost of system expansion and maintenance are reduced.
Based on the content of the foregoing embodiment, as an optional embodiment, in a case that the first subscription request includes a current train state, the sending, in response to the first subscription request, train operation data to the target terminal includes:
if the current state of the train is inter-station operation, the first subscription request is responded, and at least one of the following information is sent to the target terminal: the train running direction, the next station information, the terminal station information, the time information of arriving at each station, the door opening direction information, and the advertisement or propaganda video information;
if the current state of the train is an upcoming station, the first subscription request is responded, and at least one of the following information is sent to the target terminal: station equipment information and export information of the target station.
The current state of the train can be classified into various situations, such as: running state between stations, coming-to-station state, stopping state in stations and the like. The different states can be further divided into a plurality of different conditions, such as a traction state, an inertia state, a braking state and the like under the inter-station operation state. In each state, the train needs to obtain different train operation data through different target terminals in different operation states so as to be displayed to passengers or related staff.
Optionally, in the station terminal data interaction method provided by the application, the target terminal subscribes train operation information from the MQTT server through the first subscription request, and the method includes: when the train runs between stations, the information of the running direction, the next station, the terminal station, the arrival time and the door opening direction of the train at each station can be obtained in real time; when the train is about to arrive at the station, the platform equipment information and the export information of the current station of the train can be acquired in real time.
Furthermore, during the operation of the train between stations, advertisements or propaganda video information and the like can be acquired in real time.
Different target terminals can subscribe different data according to requirements and display different information for passengers, so that the real-time requirement of the system is high, and the system is required to have good expandability. Therefore, the method for data interaction of the station terminal provided by the invention realizes the requirements of real-time performance and expansibility from two levels, namely, the expansibility of a data organization form is used for converting all data packets of the MQTT into data in a JOSN format for interaction; and the MQTT adopting the publish-subscribe architecture technical architecture is used as the whole system architecture. Therefore, the method for data interaction of the station terminal provided by the invention can effectively improve the real-time performance and the expansibility of data interaction.
Based on the content of the above embodiment, the method for station terminal data interaction provided by the present invention further includes: sending a third subscription request to the target terminal; and acquiring the terminal operation data issued by the target terminal.
In the station terminal data interaction method provided by the invention, on one hand, the target terminal can be used for displaying the relevant train operation information subscribed from the MQTT Broker to a user or a worker; on the other hand, the target terminal can be further used for collecting the terminal operation data so as to publish the collected terminal operation data to the MQTT Broker in real time according to a third subscription request sent by the MQTT Broker.
Optionally, the target terminal may also publish the terminal operation data collected by the target terminal itself in the MQTT Broker in real time.
The terminal operation data may be operation state information of the target terminal itself, such as a memory state, a temperature state, a total operation time, a called state, and the like, and the present invention is not particularly limited thereto.
Further, the MQTT Broker may publish terminal operation data related to each target terminal for a related server to call, so as to implement reasonable distribution of the data.
According to the station terminal data interaction method, the terminal operation data of each target terminal are obtained, so that the operation state of each target terminal can be counted conveniently, and the data can be reasonably released according to the operation state of the target terminal.
Based on the content of the foregoing embodiment, as an optional embodiment, the terminal operation data includes at least one of the following information: and the equipment state information, the video information and the advice information of the target terminal.
Optionally, the target terminal, such as a smart watch, a robot, a comprehensive monitor, a screen, an OLED, etc., may subscribe to the following centralized data: train operation information (/ t-ipss/local/to-client/all/train _ info), carriage congestion degree, and environment information (/ t-ipss/local/to-client/all/coach _ info). Further, each target terminal may also issue the following data, for example:
state information (/ t-ipss/local/to-server/tipss _ scanner _066_ 110/status);
video information (/ t-ipss/local/to-server/tipss _ controller _066_ 100/video);
a will order message (/ t-ipss/local/to-server/tipss _ controller _066_100/will _ msg), etc.
Fig. 5 is a second flowchart of the method for data interaction of the station terminal provided by the present invention, and as shown in fig. 5, the present invention provides a method for data interaction of the station terminal with a target terminal as an execution subject, which includes but is not limited to the following steps:
sending a subscription request to an MQTT server according to the current running state of the train;
receiving train operation information sent by the MQTT server; the train operation information is issued by a train state data acquisition device;
and displaying the train operation data to passengers.
Specifically, as shown in fig. 5, in the case that the MQTT software is started during the train operation, the target terminal establishes a communication connection with the MQTT Broker, and acquires the subscribed train operation information through the MQTT Broker according to the subscription list, where the subscribed train operation information may include at least one of the following information: the train running direction, the next station information, the terminal station information, the arrival time information of each station, the door opening direction information, the advertisement or the propaganda video information and the like. Meanwhile, the target terminal may also publish terminal operation data related to its own operation through MQTT Broke, which may include at least one of the following information: device state information, video information, and a testimonial message.
It should be noted that the target terminal may continue to perform multiple data interactions through MQTT Broke at different operation stages and different operation states in the whole driving process according to the subscription list, and may disconnect the communication link with MQTT Broke until the whole subscription list is completely executed.
The station terminal data interaction method provided by the invention adopts the decoupled MQTT framework of the publishing and subscribing mode to provide one-to-many message publishing and release the coupling of each station terminal device, thereby greatly improving the expandability and maintainability of the station device and simultaneously improving the real-time performance of system message transmission aiming at the defects of diversity, complicated data interface types and lack of specifications of the station terminal devices.
Fig. 6 is a schematic structural diagram of a station terminal data interaction system provided in the present invention, as shown in fig. 6, the system mainly includes a receiving module 1, a sending module 2, and an operation module 3, wherein:
the receiving module 1 is mainly used for receiving a first subscription request sent by a target terminal, wherein the first subscription request is generated by the target terminal according to the current running state of a train;
the sending module 2 is mainly used for responding to the first subscription request and sending train operation data to the target terminal;
the operation module 3 is mainly used for determining the train operation data from the data issued by the train state data acquisition device.
Specifically, the target terminal generates a subscription request according to the current running state of the train and sends the subscription request to the MQTT Broker in real time so as to subscribe the train running information to an MQTT server (MQTT Broker).
After receiving a first subscription request of a train, a receiving module 1 of the MQTT Broker acquires related operation data from a corresponding train state data acquisition device by using an operation module 3 according to a request list of the first subscription request, integrates the operation data, and then releases the integrated operation data to a target terminal by using a sending module 2.
And the target terminal displays the train operation data corresponding to the first subscription request to the passenger after receiving the train operation data which is sent by the MQTT Broke and corresponds to the first subscription request.
The station terminal data interaction system provided by the invention adopts the decoupled MQTT framework of the publishing and subscribing mode to provide one-to-many message publishing and release the coupling of each station terminal device aiming at the defects of diversity, complicated data interface types and lack of specifications of the station terminal devices, thereby greatly improving the expandability and maintainability of the station device and simultaneously improving the real-time property of system message transmission.
It should be noted that, when specifically executed, the station terminal data interaction system provided in the embodiment of the present invention may be implemented based on the station terminal data interaction method described in any of the above embodiments, and details of this embodiment are not described herein.
Fig. 7 is a schematic structural diagram of an electronic device provided in the present invention, and as shown in fig. 7, the electronic device may include: a processor (processor)710, a communication interface (communication interface)720, a memory (memory)730, and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other via the communication bus 740. The processor 710 may invoke logic instructions in the memory 730 to perform a method of vehicle station terminal data interaction, the method comprising: receiving a first subscription request sent by a target terminal, wherein the first subscription request is generated by the target terminal according to the current running state of a train; responding to the first subscription request, and sending train operation data to the target terminal; the train operation data is issued by a train state data acquisition device.
The processor 710 may also call logic instructions in the memory 730 to perform another method for data interaction of the station terminal, where the method includes: sending a subscription request to an MQTT server according to the current running state of the train; receiving train operation information sent by the MQTT server; the train operation information is issued by a train state data acquisition device; and displaying the train operation data to passengers.
In addition, the logic instructions in the memory 730 can be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In another aspect, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer, the computer being capable of executing the method for station terminal data interaction provided by the above methods, the method including: receiving a first subscription request sent by a target terminal, wherein the first subscription request is generated by the target terminal according to the current running state of a train; responding to the first subscription request, and sending train operation data to the target terminal; the train operation data is issued by a train state data acquisition device.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program being implemented by a processor to perform the method for station terminal data interaction provided in the above embodiments, the method including: receiving a first subscription request sent by a target terminal, wherein the first subscription request is generated by the target terminal according to the current running state of a train; responding to the first subscription request, and sending train operation data to the target terminal; the train operation data is issued by a train state data acquisition device.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.