CN112054985B - Data interaction method and system for mobile terminal and field detection test equipment - Google Patents

Data interaction method and system for mobile terminal and field detection test equipment Download PDF

Info

Publication number
CN112054985B
CN112054985B CN201910491996.3A CN201910491996A CN112054985B CN 112054985 B CN112054985 B CN 112054985B CN 201910491996 A CN201910491996 A CN 201910491996A CN 112054985 B CN112054985 B CN 112054985B
Authority
CN
China
Prior art keywords
mobile terminal
data
android mobile
test equipment
detection test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910491996.3A
Other languages
Chinese (zh)
Other versions
CN112054985A (en
Inventor
鲍兴川
彭林
林为民
韩海韵
王刚
徐敏
于海
王鹤
朱亮
侯战胜
张哲浩
何志敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Global Energy Interconnection Research Institute
Original Assignee
Global Energy Interconnection Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Global Energy Interconnection Research Institute filed Critical Global Energy Interconnection Research Institute
Priority to CN201910491996.3A priority Critical patent/CN112054985B/en
Publication of CN112054985A publication Critical patent/CN112054985A/en
Application granted granted Critical
Publication of CN112054985B publication Critical patent/CN112054985B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Security & Cryptography (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention relates to a data interaction method and a data interaction system of a mobile terminal and field detection test equipment, wherein the field detection test equipment determines a target Android mobile terminal to be transmitted from Android mobile terminals which are pre-connected with a socket according to data when the data of the field detection test equipment changes or the data is required to be transmitted outwards according to instructions, and transmits the data in real time based on the socket long connection of the field detection test equipment and the target Android mobile terminal. The data acquired by the Android mobile terminal are real-time data, and the Android mobile terminal can passively acquire the data, so that the requirements on the computing capacity and the like of the Android mobile terminal are reduced, and the portability of the Android mobile terminal is improved.

Description

Data interaction method and system for mobile terminal and field detection test equipment
Technical Field
The invention relates to the technical field of power grid operation field detection, in particular to a data interaction method and system of a mobile terminal and field detection test equipment.
Background
In the prior art, when performing measurements or testing, a handheld terminal, such as a recorder, a mobile phone, etc., typically establishes a connection with a field test device, such as a tester, by periodically or periodically sending http requests to obtain data (especially test data) from the field test device. Such as voltage, current signals detected by the detector. The voltage, current signals are, for example, indicative of a particular physical quantity or device state condition, for example indicative of the load, power, etc. of the device being sensed by the sensing device. The method is simple and easy to implement and can be widely used.
However, in some application scenarios, the requirement on real-time performance of data is very high, and the above-mentioned manner of performing http connection by a simple timing request to obtain the data of the field detection test device at regular time cannot meet the requirement on real-time performance.
Disclosure of Invention
In order to solve the problems, the invention provides a data interaction method and a data interaction system for a mobile terminal and field detection test equipment, and a method for acquiring data from the field detection test equipment overcomes the defect of real-time property of the field detection test equipment data acquired at fixed time in the prior art. The data acquired by the Android mobile terminal are real-time data, and the Android mobile terminal can passively acquire the data, so that requirements on the computing capacity and the like of the Android mobile terminal are reduced, and portability of the Android mobile terminal is improved.
The invention aims at adopting the following technical scheme:
a method of data interaction of a field test device with a mobile terminal, the method comprising:
when the data of the field detection test equipment changes or the data is required to be sent outwards according to an instruction, the field detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals which are pre-connected with a socket in advance according to the data, and the data is transmitted in real time based on the socket long connection between the field detection test equipment and the target Android mobile terminal.
Preferably, the step of establishing a socket long connection between the field detection test device and the mobile terminal includes:
when the socket at the site detection test equipment end is in a waiting connection state, monitoring the network state in real time;
the method comprises the steps that a socket at the site detection test equipment end receives and responds to a connection request of the socket of the Android mobile terminal, a thread is established, description of the socket at the site detection test equipment end is sent to the Android mobile terminal, and connection is successful once confirmation description information of the Android mobile terminal is received;
after the connection is successful, the socket at the site detection test equipment end is in a monitoring state, connection requests of other client sockets are continuously received, and socket connection with the Android mobile terminal is always kept;
if the connection is unsuccessful, reconnecting;
the connection request comprises the description information of the address and the port number of the socket at the site detection test equipment.
Preferably, the on-site detection test device determines a target Android mobile terminal to be sent from Android mobile terminals with socket long connections established in advance according to the data, and transmits the data in real time based on the socket long connections of the on-site detection test device and the target Android mobile terminal, and the on-site detection test device comprises:
If the data are private data of the Android mobile terminal which establishes socket long connection with the field detection test equipment, judging whether the socket long connection between the field detection test equipment and the Android mobile terminal is normal, and if so, transmitting the data to the Android mobile terminal in real time through the socket long connection; otherwise, not sending data;
and if the data belong to the shared resource, the field detection test equipment sends the data to all Android mobile terminals in the same local area network in a multicast mode.
Further, the judging whether the socket long connection between the field detection test device and the Android mobile terminal is normal includes:
after receiving the detection packet sent by the Android mobile terminal, the field detection test equipment returns a receipt response packet;
if the time of the receipt response packet does not exceed the timeout timer started by the Android mobile terminal at the sending moment of the detection packet, the normal detection test equipment is indicated, and the timeout timer started by the Android mobile terminal at the sending moment of the detection packet is deleted;
if the time of the receipt response packet exceeds the overtime timer, judging that the field detection test equipment fails or the connection fails, and reestablishing the connection.
Further, the receiving, by the field detection test device, the detection packet sent by the Android mobile terminal includes: the on-site detection test equipment performs long connection test in a first heartbeat period; when the first heartbeat period can maintain long connection, performing long connection test on the time length increased by multiplying the first heartbeat period by a set multiple A, and acquiring a second heartbeat period capable of maintaining long connection; when the first heartbeat period cannot maintain long connection, performing long connection test by dividing the first heartbeat period by a set multiple A to reduce the duration on the basis of the first heartbeat period, and obtaining a second heartbeat period capable of maintaining long connection; maintaining a long connection with the second heartbeat period; wherein A is more than or equal to 1.05 and less than or equal to 1.15.
A method of data interaction between a mobile terminal and field detection test equipment, the method comprising:
the Android mobile terminal transmits data in real time through socket long connection pre-established with field detection test equipment; wherein, the data is: and detecting data of the test equipment on site, or needing to send the data outwards according to the instruction when the data of the test equipment are changed.
Preferably, the establishing of the socket long connection between the Android mobile terminal and the field detection test equipment comprises the following steps:
The socket of the Android mobile terminal sends a connection request to the socket of the field detection test equipment end; the connection request comprises description information of an address and a port number of a socket at the end of the field detection test equipment;
the description of the socket of the field detection test equipment end is sent to the Android mobile terminal, and once the Android mobile terminal confirms the description information, the connection is successful;
after the connection is successful, socket connection between the Android mobile terminal and the field detection test equipment is always kept;
and if the connection is unsuccessful, reconnecting.
Preferably, the establishing of the socket long connection between the Android mobile terminal and the field detection test equipment further comprises:
setting a connection interface on the Android mobile terminal, wherein the connection interface comprises a data chart, a network connection state icon and a start/stop button;
the data graph displays data or graphs related to real-time data and forms a main body part of the connecting interface;
setting the network connection state icon outside the data chart, clicking the network connection state icon, and reestablishing socket long connection between the Android mobile terminal and the field detection test equipment;
when the Android mobile terminal is not connected with the socket of the field detection test equipment, displaying the network connection state icon as red; when the Android mobile terminal is successfully connected with the socket of the field detection test equipment, the network connection state icon is displayed as green;
The start/stop button moves at the stop position of the finger of the user, and according to the preset transparency, the start/stop button is displayed as a stop icon in a state that the Android mobile terminal receives data from the field detection test equipment, and in the state, the start/stop button is pressed, and the Android mobile terminal sends a stop instruction to the field detection test equipment and stops acquiring the data;
the method comprises the steps that in the state that the Android mobile terminal is not in a state of receiving data from field detection test equipment, the start/stop button is displayed as a start icon, in the state, the start/stop button is pressed, and if socket long connection between the Android mobile terminal and the field detection test equipment is normal, the Android mobile terminal acquires real-time data and updates a data chart; if the socket long connection between the Android mobile terminal and the field detection test equipment is abnormal, prompting the user to start acquiring data after the socket long connection is successful.
Further, the connection interface also includes at least two field test device icons disposed outside the data diagram for selecting or replacing the connected field test device.
Further, the step of sending the connection request to the socket at the site detection test equipment end by the socket of the Android mobile terminal comprises the following steps:
the Android mobile terminal monitors a designated port according to a predefined callback function and waits for a socket long connection to be established with the field detection test equipment;
after connection is successful, an input stream is obtained from a socket, and the Android mobile terminal reads data according to a format of real-time data transmission;
the predefined callback function is used for adjusting the designated port to acquire real-time data from different field detection test equipment.
Further, the Android mobile terminal reading data according to the format of real-time data transmission includes:
judging the data format of the field detection test equipment transmitted to the Android mobile terminal in real time; wherein, the data format comprises a packet head and a data area;
if the data format contains the packet header, judging the number of header data contained in the packet header; when the number of the header data is smaller than or equal to a set value, the data received from the field detection test equipment is considered to be the data without header information, and a packet of return data is directly read;
if the data format does not contain the packet header, the data sent by the Android mobile terminal is directly converted into a binary number group from the character string, and the binary number group is sent to the site detection test equipment by adopting a socket.
Further, the connection mode of the Android mobile terminal and the field detection test equipment comprises: wired plug connection or wireless connection.
Further, whether the data belongs to the shared resource is set by the Android mobile terminal according to a multicast command sent by the needed terminal.
A data interaction system of a mobile terminal and field detection test equipment comprises the field detection test equipment and an Android mobile terminal;
the Android mobile terminal is used for transmitting data in real time based on socket long connection pre-established with the field detection test equipment;
the field detection test equipment is used for determining a target Android mobile terminal to be sent from Android mobile terminals which are pre-connected with a socket according to data when self data change or data need to be sent outwards according to instructions, and transmitting the data in real time based on the socket long connection with the Android mobile terminal.
Preferably, the Android mobile terminal and the field detection test equipment both comprise UART serial ports; and/or the Android mobile terminal and the field detection test equipment comprise wireless communication modules;
the UART serial port is used for realizing plug connection of the Android mobile terminal and the field detection test equipment in a wired mode;
And the wireless communication module is used for realizing wireless connection between the Android mobile terminal and the field detection test equipment.
Further, the Android mobile terminal is a handheld terminal or a wearable interactive terminal.
Compared with the prior art, the invention has the beneficial effects that:
when the data of the field detection test equipment changes or the data is required to be sent outwards according to an instruction, the field detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals which are pre-connected with socket lengths according to the data, and the data is transmitted in real time based on the socket lengths of the field detection test equipment and the target Android mobile terminal. And the socket long connection mode is adopted to carry out data transmission between the Android mobile terminal and the field detection test equipment, and when the data of the field detection test equipment changes, the field detection test equipment transmits the data to the Android mobile terminal in real time. The data acquired by the Android mobile terminal are real-time data, and the Android mobile terminal can passively acquire the data, so that the requirements on the computing capacity and the like of the Android mobile terminal are reduced, and the portability of the Android mobile terminal is improved.
Drawings
FIG. 1 is a flowchart of a method for an Android mobile terminal to acquire data from field detection test equipment in a specific embodiment of the invention;
fig. 2 is an exemplary and schematic flowchart of an algorithm executed in an Android mobile terminal provided in an embodiment of the present invention.
Detailed Description
The following detailed description of specific embodiments of the invention refers to the accompanying drawings.
The invention provides a data interaction method of field detection test equipment and a mobile terminal, wherein the flow and logic of the method for acquiring data from the field detection test equipment by the mobile terminal are shown in figure 1. In the method, a socket long connection is established between an Android mobile terminal and field detection test equipment, and when the data of the field detection test equipment changes, the field detection test equipment transmits the data to the Android mobile terminal in real time. The method comprises the following specific steps:
s101, when data of field detection test equipment changes or the data is required to be sent outwards according to an instruction, the field detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals which are pre-established with socket long connection according to the data;
s102, transmitting data in real time based on socket long connection between the field detection test equipment and the target Android mobile terminal.
In step S101, the step of establishing a socket long connection between the field detection test device and the mobile terminal includes:
when the socket at the site detection test equipment end is in a waiting connection state, monitoring the network state in real time;
the method comprises the steps that a socket at the site detection test equipment end receives and responds to a connection request of the socket of the Android mobile terminal, a thread is established, description of the socket at the site detection test equipment end is sent to the Android mobile terminal, and connection is successful once confirmation description information of the Android mobile terminal is received;
after the connection is successful, the socket at the site detection test equipment end is in a monitoring state, connection requests of other client sockets are continuously received, and socket connection with the Android mobile terminal is always kept;
if the connection is unsuccessful, reconnecting;
the connection request comprises the description information of the address and the port number of the socket at the site detection test equipment.
In step S101, the determining, by the on-site detection test device, the target Android mobile terminal to be sent from among Android mobile terminals that have previously established a socket long connection according to the data includes:
if the data are private data of the Android mobile terminal which establishes socket long connection with the field detection test equipment, judging whether the socket long connection between the field detection test equipment and the Android mobile terminal is normal, and if so, transmitting the data to the Android mobile terminal in real time through the socket long connection; otherwise, not sending data;
And if the data belong to the shared resource, the field detection test equipment sends the data to all Android mobile terminals in the same local area network in a multicast mode.
And whether the data belongs to the shared resource is set by the Android mobile terminal according to a multicast command sent by the demand terminal.
Judging whether socket long connection between the field detection test equipment and the Android mobile terminal is normal or not comprises the following steps:
after receiving the detection packet sent by the Android mobile terminal, the field detection test equipment returns a receipt response packet;
if the time of the receipt response packet does not exceed the timeout timer started by the Android mobile terminal at the sending moment of the detection packet, the normal detection test equipment is indicated, and the timeout timer started by the Android mobile terminal at the sending moment of the detection packet is deleted;
if the time of the receipt response packet exceeds the overtime timer, judging that the field detection test equipment fails or the connection fails, and reestablishing the connection.
Further, the receiving, by the field detection test device, the detection packet sent by the Android mobile terminal includes: the on-site detection test equipment performs long connection test in a first heartbeat period; when the first heartbeat period can maintain long connection, performing long connection test on the time length increased by multiplying the first heartbeat period by a set multiple A, and acquiring a second heartbeat period capable of maintaining long connection; when the first heartbeat period cannot maintain long connection, performing long connection test by dividing the first heartbeat period by a set multiple A to reduce the duration on the basis of the first heartbeat period, and obtaining a second heartbeat period capable of maintaining long connection; maintaining a long connection with the second heartbeat period; wherein A is more than or equal to 1.05 and less than or equal to 1.15.
Based on the same technical conception, the invention also provides a data interaction method of the mobile terminal and the field detection test equipment, which comprises the following steps:
the Android mobile terminal transmits data in real time through socket long connection pre-established with field detection test equipment; wherein, the data is: and detecting data of the test equipment on site, or needing to send the data outwards according to the instruction when the data of the test equipment are changed.
The method for establishing the socket long connection between the Android mobile terminal and the field detection test equipment comprises the following steps:
the socket of the Android mobile terminal sends a connection request to the socket of the field detection test equipment end; the connection request comprises description information of an address and a port number of a socket at the end of the field detection test equipment;
the description of the socket of the field detection test equipment end is sent to the Android mobile terminal, and once the Android mobile terminal confirms the description information, the connection is successful;
after the connection is successful, socket connection between the Android mobile terminal and the field detection test equipment is always kept;
and if the connection is unsuccessful, reconnecting.
In addition, the establishment of the socket long connection between the Android mobile terminal and the field detection test equipment further comprises the following steps:
setting a connection interface on the Android mobile terminal, wherein the connection interface comprises a data chart, a network connection state icon and a start/stop button;
The data graph displays data or graphs related to real-time data and forms a main body part of the connecting interface;
setting the network connection state icon outside the data chart, clicking the network connection state icon, and reestablishing socket long connection between the Android mobile terminal and the field detection test equipment;
when the Android mobile terminal is not connected with the socket of the field detection test equipment, displaying the network connection state icon as red; when the Android mobile terminal is successfully connected with the socket of the field detection test equipment, the network connection state icon is displayed as green;
the start/stop button moves at the stop position of the finger of the user, and according to the preset transparency, the start/stop button is displayed as a stop icon in a state that the Android mobile terminal receives data from the field detection test equipment, and in the state, the start/stop button is pressed, and the Android mobile terminal sends a stop instruction to the field detection test equipment and stops acquiring the data;
the method comprises the steps that in the state that the Android mobile terminal is not in a state of receiving data from field detection test equipment, the start/stop button is displayed as a start icon, in the state, the start/stop button is pressed, and if socket long connection between the Android mobile terminal and the field detection test equipment is normal, the Android mobile terminal acquires real-time data and updates a data chart; if the socket long connection between the Android mobile terminal and the field detection test equipment is abnormal, prompting the user to start acquiring data after the socket long connection is successful.
The connection interface also includes at least two field test device icons disposed outside of the data diagram for selecting or replacing a connected field test device.
The step of sending a connection request to the socket of the site detection test equipment end by the socket of the Android mobile terminal comprises the following steps:
the Android mobile terminal monitors a designated port according to a predefined callback function and waits for a socket long connection to be established with the field detection test equipment;
after connection is successful, an input stream is obtained from a socket, and the Android mobile terminal reads data according to a format of real-time data transmission;
the predefined callback function is used for adjusting the designated port to acquire real-time data from different field detection test equipment.
The Android mobile terminal reads data according to a format of transmitting the data in real time, and the method comprises the following steps:
judging the data format of the field detection test equipment transmitted to the Android mobile terminal in real time; wherein, the data format comprises a packet head and a data area;
if the data format contains the packet header, judging the number of header data contained in the packet header; when the number of the header data is smaller than or equal to a set value, the data received from the field detection test equipment is considered to be the data without header information, and a packet of return data is directly read;
If the data format does not contain the packet header, the data sent by the Android mobile terminal is directly converted into a binary number group from the character string, and the binary number group is sent to the site detection test equipment by adopting a socket.
In the method, the connection mode of the Android mobile terminal and the field detection test equipment comprises the following steps: wired plug connection or wireless connection.
Example 1:
in some detection scenarios, it is necessary to acquire detection conditions of a detection instrument or detection device in real time, so as to perform field test and acceptance on the corresponding devices and systems. For example, in a power grid operation field test, real-time detection data and operation data of a detection instrument, for example, including: electrical performance, electrical energy metering, conduction charging interoperability, real-time charging curve, template function, message detection data and other information.
The information needs to be displayed in real time on a mobile phone, a wearable interaction handheld terminal (intelligent eye, intelligent watch, PDA, portable recorder and the like). The mobile phone, the wearable interaction handheld terminal and the like can be called a client and an Android mobile terminal; the detection instrument or detection device may be referred to as a field detection test device, server side. The client and the Android mobile terminal can be intelligent detection data acquisition terminals with Bluetooth/USB/wifi communication embedded, and can read, encode, compress, display and the like the received test data. The detection instrument or the detection equipment is a relay protection detection equipment, a field intelligent charging pile and other test detection instruments.
When the Android mobile terminal communicates with field detection test equipment (equipment needing to acquire real-time data), the data of the field detection test equipment cannot be acquired by using a simple timing request, and the acquired data has instantaneity, and the Android mobile terminal belongs to passive acquired data, namely, the Android mobile terminal actively transmits the data to the Android mobile terminal when the data of the field detection test equipment changes instead of the Android active request data, so that the common http network request can not meet the requirements.
Therefore, the invention provides a method for acquiring data from field detection test equipment by an Android mobile terminal. That is, the invention can also provide a data interaction method between the wearable interaction handheld terminal and the detection instrument.
According to the method, a socket long connection is established between the Android mobile terminal and the field detection test equipment, when the data of the field detection test equipment changes or the data is required to be sent outwards according to an instruction, if the data is private data of the Android mobile terminal which establishes the socket long connection with the field detection test equipment, the field detection test equipment actively transmits the data to the Android mobile terminal in real time through the socket long connection, if the data belongs to a shared resource, the field detection test equipment sends the data to all the Android mobile terminals in the same local area network in a multicast mode, and when the Android mobile terminal needs to share the resource, the Android mobile terminal sends a multicast command.
For example, basic data (e.g., selected one of the most basic test data, such as the power meter of the detected grid) of the field test equipment is taken as a shared resource, own parameters of the field test equipment, such as the power load, are taken as private data, and other selected test data are taken as private data. Advantageously, the setting of the shared resource and the private data can be set on the interface of the Android mobile terminal.
More specifically, when the field detection test device detects the data transmission change of the field detection test device, triggering data transmission, judging whether the data belongs to private data corresponding to the specified Android mobile terminal or to shared resources, transmitting the shared resources in a multicast mode, transmitting the private data to the corresponding specified Android mobile terminal in a socket long connection mode, and if the socket long connection between the field detection test device and the specified Android mobile terminal is disconnected, stopping the private data transmission by the field detection test device and not actively establishing the socket long connection between the field detection test device and the specified Android mobile terminal. Thereby, the efficiency of data transmission is improved.
According to the method, a socket long connection mode is adopted to conduct data transmission between the Android mobile terminal and the field detection test equipment, and when the data of the field detection test equipment changes, the field detection test equipment transmits the data to the Android mobile terminal in real time. Therefore, the data acquired by the Android mobile terminal are real-time data, and the Android mobile terminal can passively acquire the data, so that the requirements on the computing capacity and the like of the Android mobile terminal are reduced, and the portability of the Android mobile terminal is improved.
Sockets (sockets) are the basic operational unit for communication, which is the network communication supporting the TCP/IP protocol. It is an abstract representation of an endpoint in the network communication process, containing five pieces of information necessary for network communication: the protocol used for connection, the IP address of the local host, the protocol port of the local process, the IP address of the remote host and the protocol port of the remote process.
TCP suffers from the problem of providing concurrent services for multiple application processes simultaneously when the application layer communicates data through the transport layer. Multiple TCP connections or multiple application processes may need to transmit data over the same TCP protocol port. In order to distinguish between different application processes and connections, many computer operating systems provide Socket interfaces for applications to interact with the TCP/IP protocol. The application layer can distinguish communication from different application program processes or network connection through Socket interfaces with the transmission layer, and the concurrent service of data transmission is realized.
At least one pair of sockets is needed to establish Socket connection, one of which runs on a client (Android mobile terminal, mobile terminal) called a ClientSocket, and the other runs on a server (field detection test equipment end, for example, specifically a detector or a detection device) called a ServerSocket.
The long connection refers to the whole communication process, the client and the server use only one Socket object for short connection, namely, each time a request is made, one Socket is newly built, the Socket is directly closed after the request is processed, and the whole communication process is performed by using a plurality of sockets. Therefore, the difference between the long and short connections is: the whole communication process between the client and the server uses one Socket or a plurality of sockets.
When creating a Socket connection, the used transport layer protocol may be specified, and the Socket may support a different transport layer protocol (such as TCP or UDP), and when using the TCP protocol to make a connection, the Socket connection is a TCP connection.
The invention establishes socket long connection between the Android mobile terminal and the field detection test equipment by adopting the following method, and concretely establishes socket long connection between the Android mobile terminal and the field detection test equipment, and comprises the following steps:
S1, monitoring by field detection test equipment: detecting that the socket at the test equipment end is in a state of waiting for connection in the field, and monitoring the network state in real time;
s2, android mobile terminal requests: the socket of the Android mobile terminal is used for providing a connection request, and the socket of the field detection test equipment is used as a target to be connected, wherein the socket of the Android mobile terminal describes the socket of the field detection test equipment to be connected and indicates the address and port number of the socket of the field detection test equipment;
step S3, connection confirmation: when the on-site detection test equipment end socket receives the connection request of the Android mobile terminal socket, the on-site detection test equipment end socket responds to the request of the Android mobile terminal socket, establishes a new thread, sends the description of the on-site detection test equipment end socket to the Android mobile terminal, once the Android mobile terminal confirms the description, the connection is successful,
after the connection is successful, the server socket is in a monitoring state continuously, and connection requests of other client sockets are continuously received; and socket connection between the Android mobile terminal and the field detection test equipment is always kept.
In order to improve the connection quality and the data transmission quality, the invention correspondingly establishes a network fault processing or connection failure processing mechanism.
Specifically, when a socket long connection is established between the Android mobile terminal and the field detection test equipment, if the connection is unsuccessful or the socket long connection is disconnected due to faults after the socket long connection is established, multiple reconnections are tried, wherein reconnections are carried out at intervals of corresponding time, and the interval time is raised to an exponential power.
The judging mechanism and reconnecting mechanism (network fault handling or connection failure handling mechanism) of the network disconnection in the present invention will be described below with reference to several general scenarios.
In the first scene, the user does not connect wifi by using the Android mobile terminal, or the connected wifi is not the wifi connection provided by the field detection test equipment. In this case, the Android mobile terminal cannot perform socket connection with the field detection test equipment because the Android mobile terminal is not in the same network segment. However, the user can switch wifi halfway and connect wifi of the field detection test equipment, at the moment, the re-connection attempting mechanism plays a role, and when the next time node for attempting re-connection is reached, re-connection is performed, if no network fault occurs in the process, the connection is prompted to be successful, and the step of manual connection when the user operates by mistake is omitted.
Scene two, the user has connected to the wifi of on-the-spot detection test equipment before using, before not sending and begin to acquire the data command, the network breaks down. At this time, the Android mobile terminal will first determine whether to connect to the socket of the field detection test device, if the connection is not successful, the Android mobile terminal will prompt the user that the connection is not successful, in this case, the user may manually click the connection icon to reconnect, but some users may not know what to connect manually. The reconnection mechanism plays a role, and the Android mobile terminal can be automatically reconnected only by waiting for the next reconnection time node and feeds back whether the connection is successful or not to the user.
Scene three, the user has connected successfully, and has also sent and started to acquire the data command, in the course of acquiring data, network trouble has appeared. In this case, the Android mobile terminal cannot acquire corresponding real-time data, and the judging mechanism and the reconnection mechanism at this time operate and function as in scenario two 2.
And when the Android mobile terminal receives data, the frame of the socket has a corresponding callback to inform the Android interface of the current socket connection condition, and the Android mobile terminal can control the display of the interface, such as socket disconnection, socket connection failure, socket connection success, response after the socket reads data from the field detection test equipment, and response after the socket sends data success. Connection failure can include unsuccessful initial establishment of a socket long connection, and can also include disconnection of a long connection due to a fault after the long connection is established (i.e., some network event may occur at present to cause connection failure), such as a socket on the side of the field test device having a bug, or a connection failure caused by an internal fault of the field test device. The disconnection condition may also include that the Android mobile terminal is not currently in the same network segment as the field detection test equipment, or that the Android mobile terminal does not open the network at all, or that the Android mobile terminal does not find a connectable socket at all in the network segment of the field detection test equipment, or that the user manually disconnects the connection with the field detection test equipment, which are all analyzable ranges and are not faults. That is, these disconnection means are not disconnection due to a failure. Thus, typically no automatic reconnection is performed for these analyzable network disconnects.
That is, in the present invention, when a socket long connection is established between an Android mobile terminal and a field detection test device, if the connection is unsuccessful or the socket long connection is disconnected due to a fault after the socket long connection is established, reconnection is attempted multiple times, wherein reconnection is performed every corresponding time, and the interval time increases exponentially. That is, in the event of a connection failure or disconnection due to a failure, an automatic reconnection is performed.
In other words, after the connection is successful, the network fails and the connection is retried; the test equipment is not successfully detected when the first connection of the application program is just started, and connection is also tried again. The time to reattempt the connection of the field test device in both cases is raised exponentially, for example, if the first attempt is unsuccessful, then the connection is reattempted 2 seconds later, if it is unsuccessful, then the connection is reattempted 4 seconds later, then the connection is reattempted 16 seconds later, and so on. If the connection is successful, the network fault occurs again, the time interval of the connection attempt is recorded again, for example, the connection is successful after the fault occurs for the first time and the connection is repeated for several times, the time interval of each reconnection is 2s,4s and 16s, the fault does not need to be repeated for the second time, the connection is recalculated, the connection interval is 2s,4s and 16s …, namely, the connection success of more than the power of the reconnection time is taken as the mark, and the power is cleared.
In general, socket connection is a TCP connection, so once Socket connection is established, two communication parties can start to send data contents to each other until connection between the two parties is disconnected. However, in practical network applications, communication between a client and a server often needs to traverse multiple intermediate nodes, such as routers, gateways, firewalls, and most firewalls default to close a connection in an inactive state for a long time, so that a Socket connection is disconnected, and thus the network needs to be informed by polling that the connection is in an active state.
Correspondingly, the method of the invention further comprises a heartbeat detection step for diagnosing and maintaining the socket long connection between the Android mobile terminal and the field detection test equipment. The heartbeat detection step includes:
s41, the android mobile terminal generates a detection packet to the field detection test equipment every other heartbeat period;
s42, starting a timeout timer when the android mobile terminal sends a packet;
s43, receiving a detection packet by the field detection test equipment, and responding to a response packet;
s44, if the client receives a response packet of the field detection test equipment, the client indicates that the field detection test equipment is normal, and deletes the overtime timer;
S45, if the timeout timer of the Android mobile terminal is overtime and still does not receive the response packet, judging that the field detection test equipment fails or the connection fails, and reestablishing the connection.
Advantageously, a longer heart cycle is determined, if allowed. In the present invention, it is preferable to iterate a plurality of times to determine the heartbeat cycle in the following manner:
performing long connection test by using a first heartbeat period T1; when the first heartbeat period T1 can maintain long connection, performing long connection test on the time length of the increase of the multiplication by a set multiple A on the basis of the first heartbeat period T1, and obtaining a second heartbeat period T2 which can maintain long connection; when the first heartbeat period T1 cannot maintain long connection, performing long connection test by dividing by a set multiple A on the basis of the first heartbeat period T1 to reduce the duration, and obtaining a second heartbeat period T2 capable of maintaining long connection; and maintaining long connection by the second heartbeat period T2, wherein A is more than or equal to 1.05 and less than or equal to 1.15. For example, a=1.1.
That is, sequentially trying a time length value in a multiplier sequence, and selecting a maximum allowable value from the multiplier sequence as a feasible final heartbeat period. For example, the time value series of the multiplication relationship is 1s, 1.1s, 1.21s, 1.331s, 1.4641s, 1.6151s, 1.771561s, 1.9487171s, 2.14358881s, 2.357947691s, 2.59374246s, 2.853116706s … ….
Advantageously, the values in the above-mentioned series of time values are reduced in a rounding or truncating function, for example, to 1s, 1.1s, 1.2s, 1.3s, 1.5s, 1.6s, 1.8s, 1.9s, 2.1s, 2.4s, 2.6s, 2.9s … … in a rounding manner. More advantageously, the time value series is pre-stored in the Android mobile terminal.
To implement a long connection, an end marker symbol is typically sent to tell the client that a certain message has been sent by the server, otherwise the client may block the read method all the time. Even if the server side invokes the flush method to carry out output refreshing, the client side can not necessarily exit the read action, so that the client side is blocked. Therefore, the exit action must be completed by the client program itself, and a mark of writing the end symbol can be performed before the server end sends a message and refreshes each time, so that the client can directly exit the loop reading operation of the read when resolving the end symbol, and avoid blocking all the time.
The Client end and the Server end firstly establish communication connection, the connection is not disconnected after the establishment, then message transmission and maintenance of long connection are carried out, and a maintenance connection packet is transmitted to the Server end program at regular time by the Client end program. If the maintenance connection packet is not sent for a long time, the server program will disconnect. Client side: by holding the Client Object, the Object can be sent to the server at any time (using the sendObject method). If no data is sent within KeepAlive delay milliseconds (2 seconds in the procedure), a KeepAlive object is automatically sent to the server for maintaining the connection.
Since many different objects can be sent to the server, the server can also return different objects. Therefore, for the processing of the returned object, a specific ObjectAction implementation class is written for processing. The addition was performed by the client. Thus, the program will call back to the process.
Since the client sends the connection maintaining information at regular time (keep alive delay ms), the server needs to have a detection mechanism. I.e. when no data is received within a receiver timedelay millisecond (e.g. 3 seconds), the connection with the client is automatically disconnected.
The data format transmitted from the field test equipment to the Android mobile terminal may be in any suitable format. For example, a data format transmitted from the field test device to the Android mobile terminal may be set to include a packet header and a data area; or the data format transmitted from the field detection test device to the Android mobile terminal can be set to only comprise a data area. Under the condition that the data format is set to comprise a header, when the returned header data received by the Android mobile terminal is smaller than or equal to a set value, the data received from the field detection test equipment is considered to be data without header information, one packet of returned data is directly read out,
If the data sent from the Android mobile terminal to the field detection test equipment end does not comprise the packet header definition (namely only comprises the data area), the character string sent by the Android mobile terminal is directly converted into a binary group and is sent to the field detection test equipment end through the socket.
In order to facilitate operation, a connection interface is arranged on the Android mobile terminal. The connection interface includes a data chart, a network connection status icon, and a start/stop button.
The data diagram displays data or diagrams related to real-time data and constitutes a body portion of the connection interface. The data graphs may take the form of various graphs, various tables, or various graph combinations; it may also be provided as several partitions.
The network connection state icon is arranged outside the data chart, and is displayed in red when the Android mobile terminal is not connected with the socket of the field detection test equipment; when the Android mobile terminal is successfully connected with the socket of the field detection test equipment, the network connection state icon is displayed as green; clicking the network connection state icon to reestablish socket long connection between the Android mobile terminal and the field detection test equipment.
The start/stop button is movable according to a user finger rest position and is set to a transparency of sixty to ninety percent, for example, eighty percent. In a state that the Android mobile terminal receives data from the field detection test equipment, the start/stop button is displayed as a stop icon, and in the state, the Android mobile terminal sends a stop instruction to the field detection test equipment and stops acquiring the data by pressing the start/stop button; the method comprises the steps that in the state that the Android mobile terminal is not in a state of receiving data from field detection test equipment, the start/stop button is displayed as a start icon, in the state, the start/stop button is pressed, and if socket long connection between the Android mobile terminal and the field detection test equipment is normal, the Android mobile terminal acquires real-time data and updates a data chart; if the socket long connection between the Android mobile terminal and the field detection test equipment is abnormal, prompting the user that the data can be acquired after the connection is successful.
More specifically, in order to obtain the main interface of the real-time data of the related device, which includes a plurality of charts (the charts of a fixed number are needed to be determined according to the requirement), the upper right corner is in a network connection state, and when the main interface is not connected with the target socket, a red warning is displayed; when the connection is successful, a green icon is displayed. When the connection is unsuccessful, the area can be clicked to reconnect the data, and after the connection is successful, the green color is displayed. Because each user is different in habit, the start button can be moved randomly according to the stop position of the fingers of the user, and eighty percent transparency is set, so that the user can see chart data even if the related chart is blocked.
1. State when unconnected
When the upper right network icon shows a red state, the user is prompted to start clicking the upper right network icon, and then the user can start the test after successful connection (namely clicking the upper right network icon to connect with the field detection test equipment)
If the network connection is unsuccessful, multiple reconnections are tried, at the moment, the system defaults to reconnection every corresponding time, and the time length rises exponentially.
If the connection is successful, the start button is clicked, and if the network failure occurs, the user is prompted that the connection is still unsuccessful, and the acquisition is attempted to be started again. If the network state is in a fault state all the time, the system disconnects the relevant field test equipment and attempts to reconnect.
2. Status of successful connection
After socket connection is successful, clicking a start button, changing a yellow start button into a red stop button if a start command is successful, and at the moment, if the Android mobile terminal always receives real-time data sent by a machine, displaying the real-time data in a corresponding chart according to a specified rule.
When the user does not need to connect with the machine or manually click a stop button, the Android mobile terminal sends a stop instruction to the machine (note that after sending the stop instruction, the Android mobile terminal can directly click to start acquiring data, and besides network faults, the user does not need to manually click an icon on the upper right side to connect with the field detection test equipment again)
For example, after the test of the modularized tester starts, some voltage and current are changed in the process, only the modularized tester can read the data, the Android mobile terminal cannot detect the real-time change of the voltage and the current, the bottom layer of the modularized tester has a corresponding program, the change of the voltage and the current can be detected through the program of the bottom layer of the modularized tester, at the moment, the bottom layer transmits the changed data to the Android mobile terminal, and the Android mobile terminal can display the change of the voltage and the current. In the process, the voltage and the current are equivalent to real-time data, and the Android mobile terminal acquires the real-time data by interacting with a bottom program in the modularized tester, so to speak, the Android mobile terminal acquires the real-time data from the modularized tester.
Because data requires real-time and the data itself has uncertainty, real-time data interaction is performed in a socket long connection manner. The data change in the instrument is not usually fixed time change, the uncertainty exists, what time change the instrument is for the Android mobile terminal is unknown, long connection is adopted in the situation, the instrument can be guaranteed to actively send data to the Android mobile terminal, the uncertainty is solved, real-time data display is achieved, namely, as soon as the data change happens, the Android mobile terminal can rapidly display what data change is for a user, and the change of the instrument can be displayed more intuitively in a corresponding chart.
In socket long connection use, when network failure occurs, and the Android mobile terminal is connected with the field detection test equipment in an end-on manner, the Android mobile terminal can try to be connected with the field detection test equipment again, the connection time rises to the exponent power, frequent connection is not guaranteed, and user experience is improved. When the self-checking mechanism does not reach the next time point for connecting the field detection test equipment for a certain period of time, a manual button is also provided, and a user can manually connect with the field detection test equipment.
In terms of specific algorithms, any suitable method may be used in the Android mobile terminal. In particular, any suitable algorithm may be used to manage and implement, particularly in conjunction with the interfaces above. Preferably, the following algorithm is executed in the Android mobile terminal:
monitoring a designated port, and waiting for successful connection of the designated port, wherein the designated port corresponds to corresponding field detection test equipment;
after the connection of the designated ports is successful, an input stream is obtained from the socket, a buffer area is established for reading, the algorithm further comprises a callback function for adjusting the designated ports to obtain real-time data from different field detection test devices, at least two field detection test device icons are arranged on the connection interface, and the field detection test device icons are arranged outside the data chart and used for selecting or replacing the connected field detection test devices.
Example 2:
based on the same technical conception, the invention also provides a data interaction system of the mobile terminal and the field detection test equipment, wherein the system comprises the field detection test equipment and the Android mobile terminal;
the Android mobile terminal is used for transmitting data in real time based on socket long connection pre-established with the field detection test equipment;
the field detection test equipment is used for determining a target Android mobile terminal to be sent from Android mobile terminals which are pre-connected with a socket according to data when self data change or data need to be sent outwards according to instructions, and transmitting the data in real time based on the socket long connection with the Android mobile terminal.
The Android mobile terminal and the field detection test equipment comprise UART serial ports; and/or the Android mobile terminal and the field detection test equipment comprise wireless communication modules;
the UART serial port is used for realizing plug connection of the Android mobile terminal and the field detection test equipment in a wired mode;
and the wireless communication module is used for realizing wireless connection between the Android mobile terminal and the field detection test equipment.
The Android mobile terminal is a handheld terminal or a wearable interactive terminal.
Example 3:
in an alternative embodiment, the Android mobile terminal integrates a third party frame OkSocket with a large usage amount in the github. Fig. 2 is an exemplary and schematic flow chart of an algorithm executed in an Android mobile terminal. The following is a brief description of an exemplary algorithm and schematic of an internal implementation of an Android mobile terminal in connection with fig. 2.
Step 1: setting connection parameters (IP, port number); specifically, the method includes determining IP and port number to correspond to specific field detection test equipment, wherein (IP, port number) is a unique identifier of a socket connection, different connections, and at least one of two values in the parameters is different.
When more than one target device is connected with the Android mobile terminal, different interfaces can be expressed through different callback functions, so that a user knows which data is the device 1 and which data is the device 2. Even if there is only one device, reservation can be made to accommodate subsequent extensions. Accordingly, corresponding buttons may be set or reserved on the operation interface.
When only one target device is connected to the Android mobile terminal, fixed connection parameters (IP, port number) can be adopted.
Step 2: and the Android mobile terminal calls an OkSocket, opens a connected channel and takes a channel Manager.
Step 3: and acquiring and adjusting parameter configuration. For example, it is determined whether the data format includes a header field and corresponding parameter configuration adjustments are made as needed. The normal server returns data that should be header-backed. If the field test device plays a server role and the data volume is small, for example, data within 3k can be received, so that the packet header is not defined temporarily (the data volume is not guaranteed to become larger later, the server and the client need to define the packet header and the data area format together), and if the received data format is defined to be changed (i.e. the packet header is added), the configuration is needed by the cookie.
In general, data sent to an Android mobile terminal by a field detection test device (target device) each time is sent in a packet-by-packet manner, and it is unclear how large an Android mobile terminal is in a packet. In the case of small data volume, the parameters of the packet header do not need to be set, and the packet is received by a specific 2k packet. If the real-time data volume returned by the docked field detection test equipment is large, the Android mobile terminal needs to know the specific returned data size when receiving the data, so that the Android mobile terminal can receive the data in a plurality of packets.
This step may be performed only during the initialization phase, after which it is no longer performed in the subsequent connection. That is, an initialization step may be provided, which is performed before the connection is performed (before step 1).
Step 4: the socket of the Android mobile terminal makes a connection request and confirms whether socket connection is established;
step 5: after confirming that the designated ports are well connected, the Android mobile terminal acquires input streams from the socket, and establishes a buffer area for reading.
Step 6: socket connection between the Android mobile terminal and the field detection test equipment is always kept.
It should be noted that there are many open-source frameworks related to sockets in the github, but the okSocket is most widely and most stable in practical application, because it has its own series of polling systems and judges various states, but for the interaction mode of some embodiments of this time, no definition is given between the relevant server and the client, but the okSocket requires that the length of the data must be returned once to be resolved, in which case, part of the source codes need to be changed to implement the relevant data transfer.
It should also be noted that adaptation of the socket framework is typically required to fit the actual data structure. For example, the read method is adapted. The relevant logic of the header information which is needed to be analyzed in the source code is intercepted, and the advantages of judgment, stable connection and the like of the framework are maintained.
In order to improve the efficiency of data transmission and realize data sharing, the field detection test equipment sends set shared resources to all Android mobile terminals in the same local area network in a multicast mode, and when the Android mobile terminals need the shared resources, the Android mobile terminals send multicast commands.
In some application cases, some data (shared resource) of a target machine is needed to be shared to all devices of the same network segment, and other some data (private data) is needed to send real-time data only to Android devices (Android mobile terminals) controlling the target machine. Such as: and taking a certain charging device as a target machine, and simultaneously connecting three android devices. The android device 1 issues an on-charge command to the charging device, which should then return only to the android device 1 the corresponding current state of charge, including the state that occurs during charging, which belongs to a single wire connection, similar to a one-to-one mode. On the other hand, the charging device needs to share various peaks, frequencies and phases in the charging process to all android devices in the same network segment. That is, the device 1, the device 2, and the device 3 all need to receive the peak value, the frequency, and the phase change in the charging process. Thus, socket long connection and multicast are combined. Performing one-to-one interaction by socket long connection, and sending private data; and carrying out one-to-many interaction by multicast and sending the shared resource.
It will be appreciated that the distinction between shared resources and private data may be defined according to the needs of the actual situation.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical aspects of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the above embodiments, it should be understood by those of ordinary skill in the art that: modifications and equivalents may be made to the specific embodiments of the invention without departing from the spirit and scope of the invention, which is intended to be covered by the claims.

Claims (12)

1. A method for data interaction between field detection test equipment and a mobile terminal, the method comprising:
when the data of the field detection test equipment changes or the data is required to be sent outwards according to an instruction, the field detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals which are pre-established with socket long connections according to the data, and the data is transmitted in real time based on the socket long connections of the field detection test equipment and the target Android mobile terminals;
the on-site detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals which are pre-connected with a socket in advance according to the data, and transmits the data in real time based on the socket long connection between the on-site detection test equipment and the target Android mobile terminal, and the on-site detection test equipment comprises the following steps:
if the data are private data of the Android mobile terminal which establishes socket long connection with the field detection test equipment, judging whether the socket long connection between the field detection test equipment and the Android mobile terminal is normal, and if so, transmitting the data to the Android mobile terminal in real time through the socket long connection; otherwise, not sending data;
If the data belong to the shared resource, the field detection test equipment sends the data to all Android mobile terminals in the same local area network in a multicast mode;
judging whether socket long connection between the field detection test equipment and the Android mobile terminal is normal or not comprises:
after receiving the detection packet sent by the Android mobile terminal, the field detection test equipment returns a receipt response packet;
if the time of the receipt response packet does not exceed the timeout timer started by the Android mobile terminal at the sending moment of the detection packet, the normal detection test equipment is indicated, and the timeout timer started by the Android mobile terminal at the sending moment of the detection packet is deleted;
if the time of the receipt response packet exceeds the overtime timer, judging that the field detection test equipment fails or the connection fails, and reestablishing the connection;
the on-site detection test equipment receiving the detection packet sent by the Android mobile terminal comprises: the on-site detection test equipment performs long connection test in a first heartbeat period; when the first heartbeat period can maintain long connection, performing long connection test on the time length increased by multiplying the first heartbeat period by a set multiple A, and acquiring a second heartbeat period capable of maintaining long connection; when the first heartbeat period cannot maintain long connection, performing long connection test by dividing the first heartbeat period by a set multiple A to reduce the duration on the basis of the first heartbeat period, and obtaining a second heartbeat period capable of maintaining long connection; maintaining a long connection with the second heartbeat period; wherein A is more than or equal to 1.05 and less than or equal to 1.15.
2. The method of claim 1, wherein the field test device establishing a socket long connection with the mobile terminal comprises:
when the socket at the site detection test equipment end is in a waiting connection state, monitoring the network state in real time;
the method comprises the steps that a socket at the site detection test equipment end receives and responds to a connection request of the socket of the Android mobile terminal, a thread is established, description of the socket at the site detection test equipment end is sent to the Android mobile terminal, and connection is successful once confirmation description information of the Android mobile terminal is received;
after the connection is successful, the socket at the site detection test equipment end is in a monitoring state, connection requests of other client sockets are continuously received, and socket connection with the Android mobile terminal is always kept;
if the connection is unsuccessful, reconnecting;
the connection request comprises the description information of the address and the port number of the socket at the site detection test equipment.
3. A method for data interaction between a mobile terminal and field detection test equipment, the method comprising:
the Android mobile terminal transmits data in real time through socket long connection pre-established with field detection test equipment; wherein, the data is: when the data of the field detection test equipment changes or the data which is required to be sent outwards according to the instruction;
The Android mobile terminal transmits data in real time through socket long connection pre-established with field detection test equipment, and comprises the following components:
the Android mobile terminal sends a multicast command according to a required terminal to set the data to be private data or shared resources;
the establishment of the socket long connection between the Android mobile terminal and the field detection test equipment comprises the following steps:
the Android mobile terminal sends a detection packet to the field detection test equipment and receives a receipt response packet;
the Android mobile terminal starts a timeout timer at the moment of sending the detection packet, and if the time for receiving the response piece response packet does not exceed the timeout timer, the timeout timer started by the Android mobile terminal at the moment of sending the detection packet is deleted;
if the response piece response packet is not received after the timeout timer of the Android mobile terminal is overtime, establishing connection with the field detection test equipment again;
the Android mobile terminal sending a detection packet to the field detection test equipment comprises:
the detection packet is sent at first heart cycle intervals; when the first heartbeat period can maintain long connection, performing long connection test on the time length increased by multiplying the first heartbeat period by a set multiple A, and acquiring a second heartbeat period capable of maintaining long connection; when the first heartbeat period cannot maintain long connection, performing long connection test by dividing the first heartbeat period by a set multiple A to reduce the duration on the basis of the first heartbeat period, and obtaining a second heartbeat period capable of maintaining long connection; maintaining a long connection with the second heartbeat period; wherein A is more than or equal to 1.05 and less than or equal to 1.15;
The establishment of the socket long connection between the Android mobile terminal and the field detection test equipment further comprises the following steps:
setting a connection interface on the Android mobile terminal, wherein the connection interface comprises a data chart, a network connection state icon and a start/stop button;
the data graph displays data or graphs related to real-time data and forms a main body part of the connecting interface;
setting the network connection state icon outside the data chart, clicking the network connection state icon, and reestablishing socket long connection between the Android mobile terminal and the field detection test equipment;
when the Android mobile terminal is not connected with the socket of the field detection test equipment, displaying the network connection state icon as red; when the Android mobile terminal is successfully connected with the socket of the field detection test equipment, the network connection state icon is displayed as green;
the start/stop button moves at the stop position of the finger of the user, and according to the preset transparency, the start/stop button is displayed as a stop icon in a state that the Android mobile terminal receives data from the field detection test equipment, and in the state, the start/stop button is pressed, and the Android mobile terminal sends a stop instruction to the field detection test equipment and stops acquiring the data;
The method comprises the steps that in the state that the Android mobile terminal is not in a state of receiving data from field detection test equipment, the start/stop button is displayed as a start icon, in the state, the start/stop button is pressed, and if socket long connection between the Android mobile terminal and the field detection test equipment is normal, the Android mobile terminal acquires real-time data and updates a data chart; if the socket long connection between the Android mobile terminal and the field detection test equipment is abnormal, prompting the user to start acquiring data after the socket long connection is successful.
4. The method of claim 3, wherein the establishing of the Android mobile terminal with the field detection test equipment socket long connection comprises:
the socket of the Android mobile terminal sends a connection request to the socket of the field detection test equipment end; the connection request comprises description information of an address and a port number of a socket at the end of the field detection test equipment;
the description of the socket of the field detection test equipment end is sent to the Android mobile terminal, and once the Android mobile terminal confirms the description information, the connection is successful;
after the connection is successful, socket connection between the Android mobile terminal and the field detection test equipment is always kept;
And if the connection is unsuccessful, reconnecting.
5. The method of claim 3, wherein the connection interface further comprises at least two field test device icons disposed outside of the data diagram for selecting or replacing a connected field test device.
6. The method of claim 4, wherein the sending, by the socket of the Android mobile terminal, a connection request to the socket of the field detection test equipment end comprises:
the Android mobile terminal monitors a designated port according to a predefined callback function and waits for a socket long connection to be established with the field detection test equipment;
after connection is successful, an input stream is obtained from a socket, and the Android mobile terminal reads data according to a format of real-time data transmission;
the predefined callback function is used for adjusting the designated port to acquire real-time data from different field detection test equipment.
7. The method of claim 6, wherein the Android mobile terminal performing data reading according to a format of real-time data transmission comprises:
judging the data format of the field detection test equipment transmitted to the Android mobile terminal in real time; wherein, the data format comprises a packet head and a data area;
If the data format contains the packet header, judging the number of header data contained in the packet header; when the number of the header data is smaller than or equal to a set value, the data received from the field detection test equipment is considered to be the data without header information, and a packet of return data is directly read;
if the data format does not contain the packet header, the data sent by the Android mobile terminal is directly converted into a binary number group from the character string, and the binary number group is sent to the site detection test equipment by adopting a socket.
8. The method of claim 4, wherein the connecting mode of the Android mobile terminal and the field detection test equipment comprises: wired plug connection or wireless connection.
9. The method of claim 4, wherein whether the data belongs to the shared resource is set by the Android mobile terminal according to a multicast command sent by a required end.
10. The data interaction system of the mobile terminal and the field detection test equipment is characterized by comprising the field detection test equipment and an Android mobile terminal;
the Android mobile terminal is used for transmitting data in real time based on socket long connection pre-established with the field detection test equipment; wherein, the data is: when the data of the field detection test equipment changes or the data which is required to be sent outwards according to the instruction;
The Android mobile terminal transmits data in real time through socket long connection pre-established with field detection test equipment, and comprises the following components:
the Android mobile terminal sends a multicast command according to a required terminal to set the data to be private data or shared resources;
the establishment of the socket long connection between the Android mobile terminal and the field detection test equipment comprises the following steps:
the Android mobile terminal sends a detection packet to the field detection test equipment and receives a receipt response packet;
the Android mobile terminal starts a timeout timer at the moment of sending the detection packet, and if the time for receiving the response piece response packet does not exceed the timeout timer, the timeout timer started by the Android mobile terminal at the moment of sending the detection packet is deleted;
if the response piece response packet is not received after the timeout timer of the Android mobile terminal is overtime, establishing connection with the field detection test equipment again;
the Android mobile terminal sending a detection packet to the field detection test equipment comprises:
the detection packet is sent at first heart cycle intervals; when the first heartbeat period can maintain long connection, performing long connection test on the time length increased by multiplying the first heartbeat period by a set multiple A, and acquiring a second heartbeat period capable of maintaining long connection; when the first heartbeat period cannot maintain long connection, performing long connection test by dividing the first heartbeat period by a set multiple A to reduce the duration on the basis of the first heartbeat period, and obtaining a second heartbeat period capable of maintaining long connection; maintaining a long connection with the second heartbeat period; wherein A is more than or equal to 1.05 and less than or equal to 1.15;
The field detection test equipment is used for determining a target Android mobile terminal to be sent from Android mobile terminals which are pre-connected with a socket according to data when self data change or data need to be sent outwards according to an instruction, and transmitting the data in real time based on the socket long connection with the Android mobile terminal; the on-site detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals which are pre-connected with a socket in advance according to the data, and transmits the data in real time based on the socket long connection between the on-site detection test equipment and the target Android mobile terminal, and the on-site detection test equipment comprises the following steps:
if the data are private data of the Android mobile terminal which establishes socket long connection with the field detection test equipment, judging whether the socket long connection between the field detection test equipment and the Android mobile terminal is normal, and if so, transmitting the data to the Android mobile terminal in real time through the socket long connection; otherwise, not sending data;
if the data belong to the shared resource, the field detection test equipment sends the data to all Android mobile terminals in the same local area network in a multicast mode;
Judging whether socket long connection between the field detection test equipment and the Android mobile terminal is normal or not comprises:
after receiving the detection packet sent by the Android mobile terminal, the field detection test equipment returns a receipt response packet;
if the time of the receipt response packet does not exceed the timeout timer started by the Android mobile terminal at the sending moment of the detection packet, the normal detection test equipment is indicated, and the timeout timer started by the Android mobile terminal at the sending moment of the detection packet is deleted;
if the time of the receipt response packet exceeds the overtime timer, judging that the field detection test equipment fails or the connection fails, and reestablishing the connection;
the on-site detection test equipment receiving the detection packet sent by the Android mobile terminal comprises: the on-site detection test equipment performs long connection test in a first heartbeat period; when the first heartbeat period can maintain long connection, performing long connection test on the time length increased by multiplying the first heartbeat period by a set multiple A, and acquiring a second heartbeat period capable of maintaining long connection; when the first heartbeat period cannot maintain long connection, performing long connection test by dividing the first heartbeat period by a set multiple A to reduce the duration on the basis of the first heartbeat period, and obtaining a second heartbeat period capable of maintaining long connection; maintaining a long connection with the second heartbeat period; wherein A is more than or equal to 1.05 and less than or equal to 1.15.
11. The system of claim 10, wherein the Android mobile terminal and the field detection test equipment each comprise a UART serial port; and/or the Android mobile terminal and the field detection test equipment comprise wireless communication modules;
the UART serial port is used for realizing plug connection of the Android mobile terminal and the field detection test equipment in a wired mode;
and the wireless communication module is used for realizing wireless connection between the Android mobile terminal and the field detection test equipment.
12. The system of claim 11, wherein the Android mobile terminal is a handheld terminal or a wearable interactive terminal.
CN201910491996.3A 2019-06-06 2019-06-06 Data interaction method and system for mobile terminal and field detection test equipment Active CN112054985B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910491996.3A CN112054985B (en) 2019-06-06 2019-06-06 Data interaction method and system for mobile terminal and field detection test equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910491996.3A CN112054985B (en) 2019-06-06 2019-06-06 Data interaction method and system for mobile terminal and field detection test equipment

Publications (2)

Publication Number Publication Date
CN112054985A CN112054985A (en) 2020-12-08
CN112054985B true CN112054985B (en) 2024-01-19

Family

ID=73609251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910491996.3A Active CN112054985B (en) 2019-06-06 2019-06-06 Data interaction method and system for mobile terminal and field detection test equipment

Country Status (1)

Country Link
CN (1) CN112054985B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112737890B (en) * 2020-12-29 2022-09-13 上海微波技术研究所(中国电子科技集团公司第五十研究所) Method and system for preventing network tester from being interrupted due to network oscillation
CN113109643B (en) * 2021-03-10 2022-09-30 青岛海信智慧生活科技股份有限公司 Automatic testing method and device for intelligent door lock
CN113839993A (en) * 2021-09-03 2021-12-24 深圳市托奇科技有限公司 Instruction issuing system capable of supporting mass equipment
CN113873014A (en) * 2021-09-03 2021-12-31 深圳市托奇科技有限公司 Instruction processing method capable of supporting mass equipment, terminal and storage medium
CN115022384B (en) * 2022-05-05 2023-10-13 北京北方华创微电子装备有限公司 HSMS communication connection method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1672866A1 (en) * 2004-12-15 2006-06-21 Siemens S.p.A. Method and system to the instant transfer of multimedia files between mobile radio users within the scope of combinational services
CN102055814A (en) * 2010-11-25 2011-05-11 深圳市科陆电子科技股份有限公司 Method for realizing cross-network segment real-time collection
CN102215243A (en) * 2010-04-12 2011-10-12 华为技术有限公司 Event synchronization method, system, client and server
CN102761864A (en) * 2011-04-29 2012-10-31 ***通信集团公司 Data transmission method, system and device
CN103024050A (en) * 2012-12-17 2013-04-03 北京奇虎科技有限公司 Distributor and distributing method for multiple servers
CN106506601A (en) * 2016-10-12 2017-03-15 北京奇虎科技有限公司 The method and device of data transfer
CN108881487A (en) * 2018-08-01 2018-11-23 安克创新科技股份有限公司 The control method and its server and electronic equipment of terminal device base station

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1672866A1 (en) * 2004-12-15 2006-06-21 Siemens S.p.A. Method and system to the instant transfer of multimedia files between mobile radio users within the scope of combinational services
CN102215243A (en) * 2010-04-12 2011-10-12 华为技术有限公司 Event synchronization method, system, client and server
CN102055814A (en) * 2010-11-25 2011-05-11 深圳市科陆电子科技股份有限公司 Method for realizing cross-network segment real-time collection
CN102761864A (en) * 2011-04-29 2012-10-31 ***通信集团公司 Data transmission method, system and device
CN103024050A (en) * 2012-12-17 2013-04-03 北京奇虎科技有限公司 Distributor and distributing method for multiple servers
CN106506601A (en) * 2016-10-12 2017-03-15 北京奇虎科技有限公司 The method and device of data transfer
CN108881487A (en) * 2018-08-01 2018-11-23 安克创新科技股份有限公司 The control method and its server and electronic equipment of terminal device base station

Also Published As

Publication number Publication date
CN112054985A (en) 2020-12-08

Similar Documents

Publication Publication Date Title
CN112054985B (en) Data interaction method and system for mobile terminal and field detection test equipment
CN110417915B (en) Push message transmission method and device, storage medium and electronic equipment
TW201944236A (en) Task processing method, apparatus, and system
CN109873728B (en) Terminal testing method and device and storage medium
CN108430116A (en) Suspension reconnection method, medium, device and computing device
CN109905259A (en) Communicate to connect maintenance method, system and relevant device
WO2016152307A1 (en) Communication device, communication method and program
CN113490218A (en) Pairing method, pairing device, Bluetooth remote controller, intelligent device and storage medium
CN112671904B (en) Method and device for transmitting equipment state information, storage medium and electronic device
CN109286593A (en) Transmit method and device, computer equipment and the storage medium of reconnection
CN103634657A (en) Television and mobile terminal synchronous WIFI connection setup method and device
CN111654742A (en) Remote intelligent linkage screen projection method and system
CN109040295A (en) Determination method and device, terminal and the storage medium of abnormal broken line
WO2019041371A1 (en) Internet of things number-of-connections-based router switching method and device
CN107078920B (en) Cross-layer link failure warning
KR101287556B1 (en) Push client of mobile terminal and method for changing provider using thereof
CN108650310B (en) Service discovery method
CN104079634B (en) A kind of method, equipment and the system at display device interface
CN112333849B (en) Equipment connection disconnection processing method and device, mobile terminal and storage medium
EP3160212A1 (en) Method, apparatus and system for managing mobile hotspot
CN110351155B (en) Program-controlled network performance testing method and system of implantable medical equipment
CN102984145A (en) Method for communicating with communication terminal with plurality of extension sets and communication device
CN102014054A (en) Sending method and equipment for keep-alive messages
CN113438694B (en) Bandwidth switching method, device, equipment and readable storage medium
CN112020062A (en) Communication control method and system for household appliance

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant