CN112054985A - 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
CN112054985A
CN112054985A CN201910491996.3A CN201910491996A CN112054985A CN 112054985 A CN112054985 A CN 112054985A CN 201910491996 A CN201910491996 A CN 201910491996A CN 112054985 A CN112054985 A CN 112054985A
Authority
CN
China
Prior art keywords
mobile terminal
data
test equipment
android mobile
connection
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.)
Granted
Application number
CN201910491996.3A
Other languages
Chinese (zh)
Other versions
CN112054985B (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

Images

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 for a mobile terminal and field detection test equipment, wherein when data of the field detection test equipment is changed or data needs to be sent outwards according to instructions, the field detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals with socket long connection established in advance according to the data, and transmits the data in real time based on the socket long connection between 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 capability 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 measurement or detection, a handheld terminal such as a recorder or a mobile phone is usually connected with a field detection testing device such as a detector by sending http requests periodically or periodically to acquire data (especially detection data) from the field detection testing device. The data are, for example, voltage and current signals detected by the detector. The voltage and current signals may for example be indicative of a particular physical quantity or condition of the device, e.g. indicative of the load, power, etc. of the device being detected by the detector. The method is simple and easy to implement and is widely used.
However, in some application scenarios, the real-time performance of the data is very high, and the above-mentioned manner of periodically acquiring the data of the field test equipment by performing http connection through a simple timing request cannot meet the real-time performance requirement.
Disclosure of Invention
In order to solve the above problems, the present invention provides a data interaction method and system for a mobile terminal and a field test device, and the method for acquiring data from the field test device overcomes the defect of the prior art that the data of the field test device is acquired at regular time 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 capability and the like of the Android mobile terminal are reduced, and the portability of the Android mobile terminal is improved.
The purpose of the invention is realized by adopting the following technical scheme:
a data interaction method for field detection test equipment and a mobile terminal comprises the following steps:
when data of field detection test equipment are changed or data need to be sent outwards according to instructions, the field detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals with socket long connection established in advance according to the data, and transmits the data in real time based on the socket long connection between the field detection test equipment and the target Android mobile terminal.
Preferably, the establishing of the socket long connection between the field detection test equipment and the mobile terminal includes:
when the socket at the end of the on-site detection test equipment is in a waiting connection state, monitoring the network state in real time;
the method comprises the steps that a field detection test equipment end socket receives and responds to a connection request of an Android mobile terminal socket, a thread is established, description of the field detection test equipment end socket is sent to the Android mobile terminal, and once confirmation description information of the Android mobile terminal is received, connection is successful;
after the connection is successful, the on-site detection test equipment socket is in a monitoring state, continues to receive connection requests of other client sockets and always keeps socket connection with the Android mobile terminal;
if the connection is unsuccessful, the connection is carried out again;
the connection request comprises the description information of the address and the port number of the socket at the end of the field detection test equipment.
Preferably, the on-site testing equipment determines a target Android mobile terminal to be sent from Android mobile terminals with pre-established socket long connections according to the data, and transmits the data in real time based on the socket long connections between the on-site testing equipment and the target Android mobile terminal, and the method includes:
if the data is private data of the Android mobile terminal establishing socket long connection with the field detection test equipment, judging whether 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 shared resources, 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 equipment and the Android mobile terminal is normal or not includes:
after the field detection test equipment receives the detection packet sent by the Android mobile terminal, the field detection test equipment returns a response packet;
if the time of the receipt response packet does not exceed the overtime timer started by the Android mobile terminal at the detection packet sending time, indicating that the field detection test equipment is normal, and deleting the overtime timer started by the Android mobile terminal at the detection packet sending time;
and if the time of the receipt response packet exceeds an overtime timer, judging that the field detection test equipment fails or the connection fails, and reestablishing the connection.
Further, the receiving, by the field test equipment, the detection packet sent by the Android mobile terminal includes: the field detection test equipment carries out long connection test in a first heartbeat cycle; when the first heartbeat cycle can maintain long connection, multiplying the first heartbeat cycle by a set multiple A to increase the time length for long connection test, and acquiring a second heartbeat cycle capable of maintaining long connection; when the first heartbeat cycle cannot maintain long connection, performing long connection test by dividing the first heartbeat cycle by a set multiple A to reduce the time length on the basis of the first heartbeat cycle to obtain a second heartbeat cycle capable of maintaining long connection; maintaining a long connection with the second heartbeat cycle; wherein A is more than or equal to 1.05 and less than or equal to 1.15.
A data interaction method for a mobile terminal and field detection test equipment comprises the following steps:
the Android mobile terminal transmits data in real time through a socket long connection pre-established with field detection test equipment; wherein the data is: and when the data of the field detection test equipment is changed or the data needs to be sent outwards according to the instruction.
Preferably, the establishment of the long connection between the Android mobile terminal and the field test equipment socket comprises the following steps:
the method comprises the steps that a socket of an Android mobile terminal sends a connection request to a socket of a 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 method comprises the steps that description of on-site detection test equipment end sockets is sent to an Android mobile terminal, and once the Android mobile terminal confirms description information, connection is successful;
after the connection is successful, socket connection between the Android mobile terminal and the field detection test equipment is always kept;
if the connection is unsuccessful, the connection is reconnected.
Preferably, the establishment of the long connection between the Android mobile terminal and the field test equipment socket 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 chart displays data or charts related to real-time data and forms a main body part of the connection 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 field detection test equipment;
when the Android mobile terminal is not connected with the socket of the field detection test equipment, the network connection state icon is displayed in red; when the Android mobile terminal is successfully connected with the field detection test equipment socket, the network connection state icon is displayed to be green;
the starting/stopping button moves at the position where the user fingers stay, is displayed as a stopping icon according to the preset transparency in the state that the Android mobile terminal receives data from the field detection testing equipment, and is pressed in the state, the Android mobile terminal sends a stopping instruction to the field detection testing equipment and stops acquiring the data;
the method comprises the steps that when the Android mobile terminal is not in a state of receiving data from field detection test equipment, a start/stop button is displayed as a start icon, and in the state, the start/stop button is pressed down, and if socket long connection between the Android mobile terminal and the field detection test equipment is normal, the Android mobile terminal obtains 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 a user to start to acquire data after the connection is successful.
Further, the connection interface further comprises at least two field test equipment icons, and the field test equipment icons are arranged outside the data chart and used for selecting or replacing the connected field test equipment.
Further, the sending, by the socket of the Android mobile terminal, the connection request to the socket of the field test equipment terminal includes:
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 the connection is successful, acquiring an input stream from the socket, and reading data by the Android mobile terminal according to a format of real-time data transmission;
the predefined callback function is used for adjusting the designated port so as to acquire real-time data from different field detection test equipment.
Further, the Android mobile terminal reading data according to a format of real-time transmission data includes:
judging a data format transmitted to the Android mobile terminal by the field detection test equipment in real time; the data format comprises a packet header and a data area;
if the data format contains a packet header, judging the number of header data contained in the packet header; when the number of the head data is less than or equal to a set value, the data received from the field detection test equipment is considered to be data without head information, and a packet of return data is directly read out;
and if the data format does not contain the packet header, directly converting the data sent by the Android mobile terminal into a binary array from a character string, and sending the binary array to the field detection test equipment end by adopting a socket.
Further, the connection mode of the Android mobile terminal and the field detection test equipment comprises: and the wire mode plug connection or the wireless connection.
Further, whether the data belong to the shared resources or not is set by the Android mobile terminal according to a multicast command sent by a required end.
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-established with socket long connection according to data when the data of the field detection test equipment change or the data needs to be sent outwards according to instructions, and transmitting the data in real time based on the socket long connection with the Android mobile terminals.
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 the plug-in 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 data of the field detection test equipment are changed or data need to be sent outwards according to instructions, the field detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals with socket long connection established in advance according to the data, and transmits the data in real time based on the socket long connection between the field detection test equipment and the target Android mobile terminal. And data transmission is carried out between the Android mobile terminal and the field detection test equipment in a socket long connection mode, 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 capability 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 acquiring data from a field test device by an Android mobile terminal according to an embodiment of the present invention;
fig. 2 is an exemplary and schematic flowchart of an algorithm executed in an Android mobile terminal provided in the embodiment of the present invention.
Detailed Description
The following detailed description of embodiments of the invention refers to the accompanying drawings.
The invention provides a data interaction method for field detection test equipment and a mobile terminal, and the flow and logic of a method for acquiring data from the field detection test equipment by the mobile terminal are shown in figure 1. In the method, the Android mobile terminal and field detection test equipment establish socket long connection, and when 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 are changed or data need 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, data are transmitted in real time based on the long socket connection of the field detection test equipment and the target Android mobile terminal.
In step S101, establishing a socket long connection between the field test equipment and the mobile terminal includes:
when the socket at the end of the on-site detection test equipment is in a waiting connection state, monitoring the network state in real time;
the method comprises the steps that a field detection test equipment end socket receives and responds to a connection request of an Android mobile terminal socket, a thread is established, description of the field detection test equipment end socket is sent to the Android mobile terminal, and once confirmation description information of the Android mobile terminal is received, connection is successful;
after the connection is successful, the on-site detection test equipment socket is in a monitoring state, continues to receive connection requests of other client sockets and always keeps socket connection with the Android mobile terminal;
if the connection is unsuccessful, the connection is carried out again;
the connection request comprises the description information of the address and the port number of the socket at the end of the field detection test equipment.
In step S101, the determining, by the field test equipment, a target Android mobile terminal to be sent from Android mobile terminals that establish socket long connections in advance according to the data includes:
if the data is private data of the Android mobile terminal establishing socket long connection with the field detection test equipment, judging whether 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 shared resources, 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 belong to the shared resources or not is set by the Android mobile terminal according to a multicast command sent by a required end.
Wherein, judging whether the socket long connection between the field test equipment and the Android mobile terminal is normal comprises:
after the field detection test equipment receives the detection packet sent by the Android mobile terminal, the field detection test equipment returns a response packet;
if the time of the receipt response packet does not exceed the overtime timer started by the Android mobile terminal at the detection packet sending time, indicating that the field detection test equipment is normal, and deleting the overtime timer started by the Android mobile terminal at the detection packet sending time;
and if the time of the receipt response packet exceeds an overtime timer, judging that the field detection test equipment fails or the connection fails, and reestablishing the connection.
Further, the on-site detection test equipment receiving the detection packet sent by the Android mobile terminal comprises: the field detection test equipment carries out long connection test in a first heartbeat cycle; when the first heartbeat cycle can maintain long connection, multiplying the first heartbeat cycle by a set multiple A to increase the time length for long connection test, and acquiring a second heartbeat cycle capable of maintaining long connection; when the first heartbeat cycle cannot maintain long connection, performing long connection test by dividing the first heartbeat cycle by a set multiple A to reduce the time length on the basis of the first heartbeat cycle to obtain a second heartbeat cycle capable of maintaining long connection; maintaining a long connection with the second heartbeat cycle; wherein A is more than or equal to 1.05 and less than or equal to 1.15.
Based on the same technical concept, the invention also discloses 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 a socket long connection pre-established with field detection test equipment; wherein the data is: and when the data of the field detection test equipment is changed or the data needs to be sent outwards according to the instruction.
The establishment of the long connection between the Android mobile terminal and the socket of the field detection test equipment comprises the following steps:
the method comprises the steps that a socket of an Android mobile terminal sends a connection request to a socket of a 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 method comprises the steps that description of on-site detection test equipment end sockets is sent to an Android mobile terminal, and once the Android mobile terminal confirms description information, connection is successful;
after the connection is successful, socket connection between the Android mobile terminal and the field detection test equipment is always kept;
if the connection is unsuccessful, the connection is reconnected.
In addition, the establishment of the long connection between the Android mobile terminal and the field detection test equipment socket 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 chart displays data or charts related to real-time data and forms a main body part of the connection 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 field detection test equipment;
when the Android mobile terminal is not connected with the socket of the field detection test equipment, the network connection state icon is displayed in red; when the Android mobile terminal is successfully connected with the field detection test equipment socket, the network connection state icon is displayed to be green;
the starting/stopping button moves at the position where the user fingers stay, is displayed as a stopping icon according to the preset transparency in the state that the Android mobile terminal receives data from the field detection testing equipment, and is pressed in the state, the Android mobile terminal sends a stopping instruction to the field detection testing equipment and stops acquiring the data;
the method comprises the steps that when the Android mobile terminal is not in a state of receiving data from field detection test equipment, a start/stop button is displayed as a start icon, and in the state, the start/stop button is pressed down, and if socket long connection between the Android mobile terminal and the field detection test equipment is normal, the Android mobile terminal obtains 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 a user to start to acquire data after the connection is successful.
The connection interface further comprises at least two field detection test equipment icons, and the field detection test equipment icons are arranged outside the data chart and used for selecting or replacing the connected field detection test equipment.
The method for sending the connection request to the socket of the field 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 the connection is successful, acquiring an input stream from the socket, and reading data by the Android mobile terminal according to a format of real-time data transmission;
the predefined callback function is used for adjusting the designated port so as to acquire real-time data from different field detection test equipment.
The Android mobile terminal reads data according to a format of real-time transmission data, and the method comprises the following steps:
judging a data format transmitted to the Android mobile terminal by the field detection test equipment in real time; the data format comprises a packet header and a data area;
if the data format contains a packet header, judging the number of header data contained in the packet header; when the number of the head data is less than or equal to a set value, the data received from the field detection test equipment is considered to be data without head information, and a packet of return data is directly read out;
and if the data format does not contain the packet header, directly converting the data sent by the Android mobile terminal into a binary array from a character string, and sending the binary array to the field detection test equipment end 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: and the wire mode plug connection or the wireless connection.
Example 1:
in some detection scenarios, the detection condition of a detection instrument or a detection device needs to be acquired in real time to perform field test and acceptance on the corresponding device and system. For example, in a power grid operation field test, real-time detection data and operation data of a detection instrument need to be acquired, and the real-time detection data and the operation data include, for example: electrical performance, power metering, conducted charging interoperability, real-time charging curves, template functions, message detection data, and the like.
The information needs to be displayed in real time on a mobile phone and a wearable interactive handheld terminal (smart eyes, a smart watch, a PDA, a portable recorder and the like). The mobile phone, the wearable interactive handheld terminal and the like can be called as a client and an Android mobile terminal; the detection instrument or the detection equipment can be called as field detection test equipment or a server side. The client and the Android mobile terminal can be an intelligent detection data acquisition terminal embedded with Bluetooth/USB/wifi communication, and can perform reading, encoding, compressing, displaying and the like on received test data. The detection instrument or the detection equipment is, for example, a relay protection detection equipment, a field intelligent charging pile and other test detection instruments.
When the data acquisition device communicates with field detection test equipment (equipment needing to acquire real-time data), a simple timing request cannot be used for obtaining the data of the field detection test equipment, the obtained data has real-time performance, and the Android mobile terminal is used for passively acquiring the data, namely the Android mobile terminal does not actively require the data, but actively sends the data to the Android mobile terminal when the data of the field detection test equipment changes, and the ordinary http network request cannot meet the requirement.
Therefore, the invention provides a method for acquiring data from field detection test equipment by using an Android mobile terminal. That is, the invention can also provide a data interaction method between the wearable interactive handheld terminal and the detection instrument.
In the method, an Android mobile terminal and field detection test equipment establish socket long connection, when data of the field detection test equipment changes or needs to be sent out according to instructions, if the data is private data of the Android mobile terminal establishing 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 shared resources, the field detection test equipment sends the data 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.
For example, the basic data (e.g., a selected one of the most basic test data, such as the electric energy measurement of the detected power grid) detected by the field test equipment is used as the shared resource, the own parameters of the field test equipment, such as the power load, are used as the private data, and the other selected test data are used as the private data. Advantageously, the setting of the shared resources and the private data can be set on an interface of the Android mobile terminal.
More specifically, when the field detection test equipment detects that the data sending change of the field detection test equipment per se, data transmission is triggered, whether the data belong to private data corresponding to a specified Android mobile terminal or belong to shared resources is judged, the shared resources are sent in a multicast mode, the private data are sent to the corresponding specified Android mobile terminal in a socket long connection mode, and if the socket long connection between the field detection test equipment and the specified Android mobile terminal is disconnected, the field detection test equipment stops the private data transmission and does not actively establish the socket long connection between the field detection test equipment and the specified Android mobile terminal. Thus, the efficiency of data transmission is improved.
According to the Android mobile terminal and the data transmission method, a socket long connection mode is adopted for data transmission between the Android mobile terminal and the field detection test equipment, and when data of the field detection test equipment change, 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 capability and the like of the Android mobile terminal are favorably reduced, and the portability of the Android mobile terminal is favorably improved.
Sockets (sockets) are the cornerstones of communications, and are the basic units of operation for network communications that support the TCP/IP protocol. It is an abstract representation of an endpoint in the network communication process, and comprises five kinds of information necessary for network communication: the protocol used by the 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.
When the application layer communicates data through the transport layer, TCP suffers from the problem of providing concurrent services to multiple application processes simultaneously. Multiple TCP connections or multiple application processes may need to transmit data through the same TCP protocol port. To distinguish between different application processes and connections, many computer operating systems provide a Socket interface for applications to interact with the TCP/IP protocol. The application layer and the transmission layer can distinguish communication from different application program processes or network connection through a Socket interface, and concurrent service of data transmission is achieved.
At least one pair of sockets is required for establishing Socket connection, one of the sockets is operated at a client (Android mobile terminal, mobile terminal) and is called a ClientSocket, and the other Socket is operated at a server (field test equipment terminal, for example, a specific detector or test equipment) and is called a serverssocket.
The long connection refers to the whole communication process, the client and the server only use one Socket object for short connection, namely, one Socket is newly built for each request, the Socket is directly closed after one request is processed, and the whole communication process is carried out by using a plurality of sockets. Therefore, the long and short connections differ in that: the communication process of the whole 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 (e.g., TCP or UDP), and when connecting using the TCP protocol, the Socket connection is a TCP connection.
The method for establishing the socket long connection between the Android mobile terminal and the field detection test equipment comprises the following steps:
s1, monitoring by field detection test equipment: detecting the state of the test equipment end socket waiting for connection on site, and monitoring the network state in real time;
s2, android mobile terminal request: a connection request is made by a socket of the Android mobile terminal, and the target to be connected is the socket of the field detection test equipment end, 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 the port number of the socket of the field detection test equipment end;
s3, connection confirmation: when the on-site detection test equipment terminal socket receives a connection request of the Android mobile terminal socket, the on-site detection test equipment terminal socket responds to the Android mobile terminal socket request, a new thread is established, the description of the on-site detection test equipment terminal socket is sent to the Android mobile terminal, once the Android mobile terminal confirms the description, the connection is successful,
after the connection is successful, the server-side socket is continuously in a monitoring state and continuously receives connection requests of other client-side sockets; and the 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 establishing a socket long connection 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 a fault after the socket long connection is established, multiple reconnection attempts are performed, wherein reconnection is performed at intervals of corresponding time, and the interval time is exponential power rise.
The present invention will be described below with reference to several common scenarios, wherein the mechanism for determining network disconnection and the mechanism for reconnecting (network failure handling or connection failure handling) are described.
Scene one, a user uses the Android mobile terminal to be not connected with wifi, or the connected wifi is not connected with the wifi provided by the field detection test equipment. Under the condition, the Android mobile terminal cannot be in socket connection with the field detection test equipment because the Android mobile terminal is not in the same network segment. However, a user can switch wifi midway and connect to wifi of the field detection test equipment, at the moment, the reconnection attempting mechanism plays a role, reconnection is carried out when the next reconnection attempting time node is reached, if no network fault occurs in the process, the successful connection is prompted, and the step of manual connection when the user operates by mistake is omitted.
And in a second scenario, before the user is connected to wifi of the field detection test equipment before use, and before a command for starting to acquire data is not sent, the network fails. At this moment, the Android mobile terminal can firstly judge whether the Android mobile terminal is connected to the socket of the field detection test equipment, if the Android mobile terminal is not successfully connected, the Android mobile terminal can prompt the user that the connection is not successful, in this case, firstly, the user can manually click the connection icon to reconnect, but part of the users may not know how to manually connect. The reconnection mechanism of the invention plays a role, the Android mobile terminal can automatically reconnect only by waiting for the next reconnection time node, and the user is fed back whether the connection is successful or not.
And in the third scenario, the user has succeeded in connecting and has also sent a command to start data acquisition, and in the process of acquiring data, a network fault occurs. In this case, the Android mobile terminal cannot acquire corresponding real-time data, and the judgment mechanism and the reconnection mechanism operate and function as in the scenario two 2.
And fourthly, when the Android mobile terminal receives data, the oksocket frame has a corresponding callback to inform the Android interface of the current socket connection condition, the Android mobile terminal can control the interface display, for example, the socket is disconnected, the socket connection fails, the socket connection succeeds, the socket reads the response of the data from the field detection test equipment, and the socket sends the response of the data success. The connection failure can include that the initial socket long connection is not established successfully, and can also include that the long connection is disconnected due to a fault after the long connection is established (that is, some network events may happen currently to cause the connection failure), for example, the socket on the side of the field test equipment has bug, or the connection failure is caused by the internal fault of the field test equipment. The disconnection condition can also include that the Android mobile terminal is not in the same network segment with the field detection test equipment currently, or the Android mobile terminal does not open the network at all currently, or the Android mobile terminal does not find a connectable socket in the network segment of the field detection test equipment at all currently, or a user manually disconnects the network segment with the field detection test equipment, which are analyzable ranges and are not faults. That is, these disconnection means are not disconnection due to a failure. Thus, automatic reconnection is not typically performed for these analyzable network disconnections.
That is, in the present invention, when establishing a socket long connection between an Android mobile terminal and a field test device, if the connection is unsuccessful, or after establishing the socket long connection, the socket long connection is disconnected due to a fault, a plurality of reconnection attempts are made, wherein reconnection is performed at corresponding intervals, and the interval time is increased by an exponential power. That is, in the case where the connection fails or is disconnected due to a failure, the automatic reconnection is performed.
In other words, after the connection is successful, the network fails and the connection is retried; the first time the application has just been started, the field test equipment is not successfully connected and the connection is attempted again. The time to retry to connect to the field test equipment in both cases is raised exponentially, for example, the first attempted connection is unsuccessful and then attempted again after 2 seconds, if not, after 4 seconds, and then again, after 16 seconds, … …, and so on. If the network failure occurs again after the connection is successful, the time interval of the attempted connection is recorded again, for example, the failure occurs for the first time, the connection succeeds after several times of reconnection, the time interval of each reconnection is 2s, 4s and 16s, 256s reconnection is not needed when the failure occurs for the second time, the connection is recalculated, the connection interval is 2s, 4s and 16s …, namely the connection success which is more than one time of the power of the reconnection time is used as a mark, and the power is cleared.
Normally, a Socket connection is a TCP connection, so once the Socket connection is established, two communicating parties can start to send data contents to each other until the two parties are disconnected. However, in practical network applications, communication between a client and a server often needs to pass through multiple intermediate nodes, such as routers, gateways, firewalls, and the like, and most of firewalls default to closing a connection in an inactive state for a long time to cause a Socket connection to be disconnected, so that the network needs to be notified that the connection is in an active state through polling.
Correspondingly, the method further comprises a heartbeat detection step so as to diagnose and maintain the socket long connection between the Android mobile terminal and the field detection test equipment. The heartbeat detecting step comprises:
s41, the android mobile terminal generates a detection packet to the field detection test equipment every other heartbeat cycle;
s42, starting an overtime timer when the android mobile terminal sends a packet;
s43, the field detection test equipment end receives the detection packet and responds to a response packet;
s44, if the client receives the response packet of the field detection test equipment, the situation that the field detection test equipment is normal is indicated, and the overtime timer is deleted;
and S45, if the overtime timer of the Android mobile terminal is overtime and the response packet is still not received, judging that the field detection test equipment is invalid or the connection is invalid, and reestablishing the connection.
Advantageously, a longer heartbeat cycle is determined if allowed. In the present invention, it is preferred to iterate a number of times to determine the heart cycle in the following manner:
a long connection test is performed with a first heartbeat period T1; when the first heartbeat cycle T1 can maintain a long connection, multiplying the first heartbeat cycle T1 by a set multiple a to increase the time length to perform a long connection test, and obtaining a second heartbeat cycle T2 capable of maintaining the long connection; when the first heartbeat cycle T1 cannot maintain the long connection, performing a long connection test by dividing the first heartbeat cycle T1 by a set multiple A to reduce the time length to obtain a second heartbeat cycle T2 capable of maintaining the long connection; and maintaining long connection in 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, the duration values in a multiplier sequence are sequentially tried, and a maximum allowable value is selected from the multiplier sequence as a feasible final heartbeat cycle. For example, the time value numbers of the multiplication relations are 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 time value series are simplified in a rounding or truncation function, for example, in a rounding manner to 1s, 1.1s, 1.2s, 1.3s, 1.5s, 1.6s, 1.8s, 1.9s, 2.1s, 2.4s, 2.6s, 2.9s … …. It is further advantageous that the time value sequence is pre-stored in the Android mobile terminal.
To realize long connections, it is generally necessary to send an end marker to tell the client that a certain message has been sent by the server, otherwise, the client will block the read method all the time. Even if the server side calls the flush method to output and refresh, the client side cannot necessarily quit the action of the read, so the client side still blocks. Therefore, the exit action must be completed by the client program itself, a mark for writing the end symbol can be made before the server finishes sending a message and refreshing, and when the client analyzes the end symbol, the client can directly exit the read circular reading operation, thereby avoiding blocking all the time.
The Client end and the Server end establish communication connection firstly, the connection is not disconnected after being established, and then message sending and long connection maintenance are carried out, namely a Client end program sends a maintenance connection packet to a Server end program at regular time. If the keep-alive packet is not sent for a long time, the server program will disconnect. A client: by holding the Client Object, the Object can be sent to the server (using sendObject method) at any time. If no data is sent within keepaliveDelay milliseconds (2 seconds in the program), a KeepAlive object is automatically sent to the server for maintaining connection.
Since many different objects may be sent to the server, the server may also return different objects. Therefore, for the processing of returning an object, a specific ObjectAction implementation class is written for processing. Addition was performed by client. Thus, the program will call back processing.
Since the ue sends the connection maintaining information periodically (keep alive delay ms), the server has a detection mechanism. I.e. when the server receives no data within milliseconds (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, the data format transmitted from the field detection test equipment 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 equipment 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 packet header, when the number of returned header data received by the Android mobile terminal is less than or equal to a set value, the data received from the field detection test equipment is considered to be data without header information, a 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 include the packet header definition (namely only includes the data area), the character string sent by the Android mobile terminal is directly converted into a binary array and sent to the field detection test equipment end by using the socket.
In order to facilitate operation, a connection interface is arranged on the Android mobile terminal. The connection interface includes a data diagram, a network connection status icon, and a start/stop button.
The data graph displays data or graphs related to real-time data and constitutes a body portion of the connectivity interface. The data charts may take the form of various graphs, various tables, or various chart combinations; it may also be arranged in 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 a socket of field detection test equipment; when the Android mobile terminal is successfully connected with the field detection test equipment socket, the network connection state icon is displayed to be green; clicking the network connection state icon, and reestablishing socket long connection between the Android mobile terminal and the field detection test equipment.
The start/stop button is movable according to the user's finger rest position and is set to sixty percent to ninety percent transparency, such as eighty percent transparency. The Android mobile terminal displays a start/stop icon 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 Android mobile terminal sends a stop instruction to the field detection test equipment and stops acquiring the data when the start/stop button is pressed; the method comprises the steps that when the Android mobile terminal is not in a state of receiving data from field detection test equipment, a start/stop button is displayed as a start icon, and in the state, the start/stop button is pressed down, and if socket long connection between the Android mobile terminal and the field detection test equipment is normal, the Android mobile terminal obtains 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, the user is prompted to start to acquire data after the connection is successful.
More specifically, in order to obtain a main interface of real-time data of relevant equipment, the main interface comprises a plurality of charts (a fixed number of charts are determined according to requirements), the upper right corner is a network connection state, and when the main interface is not connected with a target socket, a red warning is displayed; when the connection is successful, a green icon is displayed. And when the connection is unsuccessful, clicking the area to reconnect the data, and displaying green after the connection is successful. Because each user habit is different, the start button can be moved randomly according to the stop position of the finger of the user, eighty percent of transparency is set, and the user can see chart data even if the related chart is shielded.
1. State when unconnected
When the upper right network icon displays the red state, the user is prompted to start the test after clicking the upper right network icon (namely, clicking the upper right network icon to be connected with the field detection test equipment)
If the network connection is unsuccessful, the reconnection is tried for many times, and at the moment, the system is in default to reconnect every corresponding time, and the time is increased by exponential power.
If the connection is successful, clicking a start button, and if a network fault occurs, prompting the user that the connection is still unsuccessful, and trying to start acquisition again. If the network status is always in a fault state, the system disconnects the associated field test equipment and attempts to reconnect.
2. Status of successful connection
And after the 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, receiving real-time data sent by the machine all the time by the Android mobile terminal and displaying the real-time data in a corresponding chart according to a specified rule.
When a user does not need to be connected with the machine or manually clicks a stop button, the Android mobile terminal sends a stop instruction to the machine (note that after the stop instruction is sent, the Android mobile terminal can directly click to start acquiring data, and the Android mobile terminal does not need to manually click the upper right icon to be connected with the on-site detection test equipment again except for network faults)
For example, after a modular tester test is started, some voltage and current are changed in the process, the data can be read only by the modular tester, the Android mobile terminal cannot detect real-time change of the voltage and the current, a corresponding program is arranged on the bottom layer of the modular tester, the change of the voltage and the current can be detected through the program on the bottom layer of the modular tester, the changed data are transmitted to the Android mobile terminal by the bottom layer, 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, the Android mobile terminal acquires the real-time data by interacting with a bottom layer program in the modular tester, and the Android mobile terminal acquires the real-time data from the modular tester.
Because the data requires real-time performance and the data has uncertainty, the real-time data interaction is carried out in a way of socket long connection. The data change in the instrument is usually not fixed time change and has uncertainty, the Android mobile terminal is unknown about the time change of the instrument, long connection is adopted in the condition, the instrument can be guaranteed to actively send data to the Android mobile terminal, the uncertainty is solved, and real-time data display is achieved, namely the Android mobile terminal can rapidly display the data change of the user as soon as the data change, and the change of the instrument can be displayed more intuitively in a corresponding chart.
When the socket is used in a long-time connection mode, when a network fault occurs and the Android mobile terminal is connected with the field detection test equipment end, the Android mobile terminal tries to be connected with the field detection test equipment again, the connection time rises exponentially, frequent connection is avoided, and user experience is improved. When the next time point is not reached by the self-checking mechanism in a certain period of time, the field detection testing equipment is connected, a manual button is also provided, and a user can be connected with the field detection testing equipment manually.
In terms of specific algorithms, any suitable method can be adopted in the Android mobile terminal. In particular, any suitable algorithm may be used for control and implementation, in particular with the above interface. Preferably, the following algorithm is executed in the Android mobile terminal:
monitoring a designated port, and waiting for the connection success of the designated port, wherein the designated port corresponds to corresponding field detection test equipment;
and after the connection of the designated port is successful, acquiring an input stream from the socket, and establishing a buffer area for reading, wherein the algorithm further comprises a callback function for adjusting the designated port so as to acquire real-time data from different field detection test equipment, at least two field detection test equipment icons are arranged on the connection interface, and the field detection test equipment icons are arranged outside the data chart and used for selecting or replacing the connected field detection test equipment.
Example 2:
based on the same technical concept, 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 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-established with socket long connection according to data when the data of the field detection test equipment change or the data needs to be sent outwards according to instructions, and transmitting the data in real time based on the socket long connection with the Android mobile terminals.
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 the plug-in 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 optional embodiment, the Android mobile terminal integrates a third-party framework OkSocket with a large use amount in github. Fig. 2 is an exemplary and schematic flow chart of an algorithm executed in an Android mobile terminal. The schematic and exemplary algorithm of the internal implementation of the Android mobile terminal is briefly described below with reference to fig. 2.
Step 1: connection parameter (IP, port number) setting; the method specifically comprises the steps of determining an IP and a port number so as to correspond to a specific field detection test device, wherein the IP and the port number are unique identifiers of one socket connection and 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 can know which data is the device 1 and which data is the device 2. Even if there is only one device, it can be reserved to accommodate subsequent extensions. Accordingly, a corresponding button may be provided or reserved on the operation interface.
When the target device connected with the Android mobile terminal is only one, fixed connection parameters (IP, port number) can be adopted.
Step 2: and the Android mobile terminal calls Oksocket, opens the connected channel and takes the channel Manager (administrative right).
And step 3: and acquiring and adjusting parameter configuration. For example, it is determined whether the data format includes a header area and corresponding parameter configuration adjustments are made as needed. The data returned by the normal server should have a header. If the field detection test equipment acts as a server and the data volume is small, for example, data returned each time can be received by data within 3k, so that a header is not defined (it is not guaranteed that the data volume becomes large later, and the header and the data area format need to be defined together by the server and the client), and if the received data format is defined to be changed (i.e. the header is added), the okSocket needs to be configured.
Generally, data sent to the Android mobile terminal by the field test equipment (target equipment) each time is sent out one packet, and it is unclear how large the Android mobile terminal is specifically one packet. When the data amount is small, it is not necessary to set parameters such as a header, and a specific 2k packet may be used for reception. If the real-time data volume returned by the butted field detection test equipment is large, the size of the specific returned data needs to be known when the Android mobile terminal receives the data, so that the Android mobile terminal can know that the data is received in several packets.
This step may be performed only during an initialization phase, after which it is not performed again in subsequent connections. That is, an initialization step may be provided, and the above-described parameter configuration step is performed before connection is performed (performed before step 1).
And 4, step 4: a socket of the Android mobile terminal provides a connection request and confirms whether to establish socket connection;
and 5: after the connection of the appointed port is confirmed, the Android mobile terminal obtains an input stream from the socket and establishes a buffer area for reading.
Step 6: and the 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 socket-related frameworks in github, but the okSocket is the most extensive and stable in practical application because it has its own series of polling systems and determines various states, but for the interaction mode of some embodiments of this time, the definition between the relevant server and the client is not given, but the okSocket requires that the length of data must be returned for resolution, in this case, a part of source code needs to be changed to implement the relevant data transfer.
It is also noted that adaptation of the socket framework is often required to fit the actual data structure. For example, the read method is adapted. Related logic that header information must be analyzed in the source code is intercepted, and the advantages of judgment, connection stability and the like of the framework are reserved.
In order to improve the efficiency of data transmission and realize data sharing, the field detection test equipment sends the set shared resource to all Android mobile terminals in the same local area network in a multicast mode, and the Android mobile terminals send multicast commands when the Android mobile terminals need the shared resource.
In some application cases, some data (shared resources) of a target machine needs to be shared by all devices in the same network segment, and some data (private data) needs to be sent to only an Android device (Android mobile terminal) controlling the target machine. Such as: a certain charging device is taken as a target device, and three android devices are connected with the charging device. The android device 1 issues a start charging command to the charging device, and the charging device should only return the corresponding current charging status to the android device 1, including the status that occurred during charging, which is 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 during the charging process. Thus, socket long connections are combined with multicasting. 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 resources.
It will be appreciated that the distinction between shared resources and private data may be defined according to the needs of the actual situation.
As will be appreciated by one skilled in the art, 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 flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams 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 solutions of the present invention and not for limiting the same, and although the present invention is described in detail with reference to the above embodiments, those of ordinary skill in the art should understand that: modifications and equivalents may be made to the embodiments of the invention without departing from the spirit and scope of the invention, which is to be covered by the claims.

Claims (16)

1.A data interaction method for field detection test equipment and a mobile terminal is characterized by comprising the following steps:
when data of field detection test equipment are changed or data need to be sent outwards according to instructions, the field detection test equipment determines a target Android mobile terminal to be sent from Android mobile terminals with socket long connection established in advance according to the data, and transmits the data in real time based on the socket long connection between the field detection test equipment and the target Android mobile terminal.
2. The method of claim 1, wherein the establishing a socket long connection between the field test equipment and the mobile terminal comprises:
when the socket at the end of the on-site detection test equipment is in a waiting connection state, monitoring the network state in real time;
the method comprises the steps that a field detection test equipment end socket receives and responds to a connection request of an Android mobile terminal socket, a thread is established, description of the field detection test equipment end socket is sent to the Android mobile terminal, and once confirmation description information of the Android mobile terminal is received, connection is successful;
after the connection is successful, the on-site detection test equipment socket is in a monitoring state, continues to receive connection requests of other client sockets and always keeps socket connection with the Android mobile terminal;
if the connection is unsuccessful, the connection is carried out again;
the connection request comprises the description information of the address and the port number of the socket at the end of the field detection test equipment.
3. The method of claim 1, wherein the on-site testing equipment determines a target Android mobile terminal to be sent from Android mobile terminals with pre-established socket long connections according to the data, and transmits the data in real time based on the socket long connections between the on-site testing equipment and the target Android mobile terminal, and the method comprises the following steps:
if the data is private data of the Android mobile terminal establishing socket long connection with the field detection test equipment, judging whether 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 shared resources, the field detection test equipment sends the data to all Android mobile terminals in the same local area network in a multicast mode.
4. The method of claim 3, wherein the judging whether the socket long connection between the field test equipment and the Android mobile terminal is normal comprises:
after the field detection test equipment receives the detection packet sent by the Android mobile terminal, the field detection test equipment returns a response packet;
if the time of the receipt response packet does not exceed the overtime timer started by the Android mobile terminal at the detection packet sending time, indicating that the field detection test equipment is normal, and deleting the overtime timer started by the Android mobile terminal at the detection packet sending time;
and if the time of the receipt response packet exceeds an overtime timer, judging that the field detection test equipment fails or the connection fails, and reestablishing the connection.
5. The method of claim 4, wherein the receiving, by the field test equipment, the probe packet sent by the Android mobile terminal comprises: the field detection test equipment carries out long connection test in a first heartbeat cycle; when the first heartbeat cycle can maintain long connection, multiplying the first heartbeat cycle by a set multiple A to increase the time length for long connection test, and acquiring a second heartbeat cycle capable of maintaining long connection; when the first heartbeat cycle cannot maintain long connection, performing long connection test by dividing the first heartbeat cycle by a set multiple A to reduce the time length on the basis of the first heartbeat cycle to obtain a second heartbeat cycle capable of maintaining long connection; maintaining a long connection with the second heartbeat cycle; wherein A is more than or equal to 1.05 and less than or equal to 1.15.
6. A data interaction method of a mobile terminal and field detection test equipment is characterized by comprising the following steps:
the Android mobile terminal transmits data in real time through a socket long connection pre-established with field detection test equipment; wherein the data is: and when the data of the field detection test equipment is changed or the data needs to be sent outwards according to the instruction.
7. The method of claim 6, wherein the establishing of the long connection between the Android mobile terminal and the field test equipment socket comprises the following steps:
the method comprises the steps that a socket of an Android mobile terminal sends a connection request to a socket of a 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 method comprises the steps that description of on-site detection test equipment end sockets is sent to an Android mobile terminal, and once the Android mobile terminal confirms description information, connection is successful;
after the connection is successful, socket connection between the Android mobile terminal and the field detection test equipment is always kept;
if the connection is unsuccessful, the connection is reconnected.
8. The method of claim 6, wherein the establishing of the long connection between the Android mobile terminal and the field test equipment socket 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 chart displays data or charts related to real-time data and forms a main body part of the connection 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 field detection test equipment;
when the Android mobile terminal is not connected with the socket of the field detection test equipment, the network connection state icon is displayed in red; when the Android mobile terminal is successfully connected with the field detection test equipment socket, the network connection state icon is displayed to be green;
the starting/stopping button moves at the position where the user fingers stay, is displayed as a stopping icon according to the preset transparency in the state that the Android mobile terminal receives data from the field detection testing equipment, and is pressed in the state, the Android mobile terminal sends a stopping instruction to the field detection testing equipment and stops acquiring the data;
the method comprises the steps that when the Android mobile terminal is not in a state of receiving data from field detection test equipment, a start/stop button is displayed as a start icon, and in the state, the start/stop button is pressed down, and if socket long connection between the Android mobile terminal and the field detection test equipment is normal, the Android mobile terminal obtains 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 a user to start to acquire data after the connection is successful.
9. The method of claim 8, wherein the interface further comprises at least two field test equipment icons disposed outside of the data chart for selecting or replacing a connected field test equipment.
10. The method of claim 7, wherein the sending of the connection request by the socket of the Android mobile terminal to the socket of the field test equipment terminal 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 the connection is successful, acquiring an input stream from the socket, and reading data by the Android mobile terminal according to a format of real-time data transmission;
the predefined callback function is used for adjusting the designated port so as to acquire real-time data from different field detection test equipment.
11. The method of claim 10, wherein the Android mobile terminal performs data reading according to a format of real-time transmission data, and comprises:
judging a data format transmitted to the Android mobile terminal by the field detection test equipment in real time; the data format comprises a packet header and a data area;
if the data format contains a packet header, judging the number of header data contained in the packet header; when the number of the head data is less than or equal to a set value, the data received from the field detection test equipment is considered to be data without head information, and a packet of return data is directly read out;
and if the data format does not contain the packet header, directly converting the data sent by the Android mobile terminal into a binary array from a character string, and sending the binary array to the field detection test equipment end by adopting a socket.
12. The method of claim 7, wherein the connection mode of the Android mobile terminal and the field test equipment comprises: and the wire mode plug connection or the wireless connection.
13. The method of claim 7, 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.
14. A data interaction system of a mobile terminal and 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;
the field detection test equipment is used for determining a target Android mobile terminal to be sent from Android mobile terminals which are pre-established with socket long connection according to data when the data of the field detection test equipment change or the data needs to be sent outwards according to instructions, and transmitting the data in real time based on the socket long connection with the Android mobile terminals.
15. The system of claim 14, wherein the Android mobile terminal and the field 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 the plug-in 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.
16. The system of claim 15, 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 true CN112054985A (en) 2020-12-08
CN112054985B 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)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112737890A (en) * 2020-12-29 2021-04-30 上海微波技术研究所(中国电子科技集团公司第五十研究所) Method and system for preventing network tester from being interrupted due to network oscillation
CN113109643A (en) * 2021-03-10 2021-07-13 青岛海信智慧生活科技股份有限公司 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
CN115022384A (en) * 2022-05-05 2022-09-06 北京北方华创微电子装备有限公司 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

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112737890A (en) * 2020-12-29 2021-04-30 上海微波技术研究所(中国电子科技集团公司第五十研究所) Method and system for preventing network tester from being interrupted due to network oscillation
CN112737890B (en) * 2020-12-29 2022-09-13 上海微波技术研究所(中国电子科技集团公司第五十研究所) Method and system for preventing network tester from being interrupted due to network oscillation
CN113109643A (en) * 2021-03-10 2021-07-13 青岛海信智慧生活科技股份有限公司 Automatic testing method and device for intelligent door lock
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
CN115022384A (en) * 2022-05-05 2022-09-06 北京北方华创微电子装备有限公司 HSMS communication connection method and device
CN115022384B (en) * 2022-05-05 2023-10-13 北京北方华创微电子装备有限公司 HSMS communication connection method and device

Also Published As

Publication number Publication date
CN112054985B (en) 2024-01-19

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
CN105635248B (en) A kind of method for releasing and system of TCP connection resource
CN109873728A (en) A kind of terminal test method, device and storage medium
CN108111596B (en) Method for debugging power acquisition terminal based on remote login
CN108200170A (en) Message treatment method, device and readable storage medium storing program for executing
CN104205741A (en) Information processing device, information processing method, and program
WO2012075903A1 (en) Method and device for upgrading radio relay equipment
CN109040295A (en) Determination method and device, terminal and the storage medium of abnormal broken line
CN112468575A (en) Control method and device for industrial Internet of things platform, electronic device and medium
CN103490945A (en) Method for detecting maximum telnet user quantity
US10395547B2 (en) Supporting popularization of information and communications technology in the field of education
CN108650310B (en) Service discovery method
CN104079634B (en) A kind of method, equipment and the system at display device interface
EP3160212A1 (en) Method, apparatus and system for managing mobile hotspot
CN112423073A (en) Remote control method and system for screen projection equipment
CN102984145A (en) Method for communicating with communication terminal with plurality of extension sets and communication device
CN112788658B (en) Data sharing method of communication equipment, communication equipment and storage medium
CN113824612A (en) Network equipment compatibility testing method, terminal equipment and storage medium
CN110575667B (en) Control method, device, equipment and storage medium based on UI (user interface)
CN112118420A (en) Automatic configuration method and device for monitoring system
CN114765603A (en) Screen sharing method of mobile terminal, mobile terminal and storage medium
CN113438328B (en) Low-delay terminal synchronization system and method
CN114205888B (en) Equipment network distribution method and device, storage medium and electronic device
JP6061480B2 (en) Communication device control method and communication device

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