Disclosure of Invention
The method aims to overcome the defects that the priority of the same type of data under different conditions is not considered, whether a receiver is ready to receive the data is not considered, and the like in the existing transmission method. The invention provides a connected prioritized data transmission method based on a GIS (geographic information system), which not only improves the data transmission efficiency, but also ensures the accuracy of data transmission.
The technical scheme adopted by the invention for solving the technical problems is as follows:
the data transmission method with the variable priority based on the GIS system and the connection comprises the following steps:
1) initializing parameters:
1.1) setting a timeout count to be 0, the maximum allowed timeout number sum, and a timeout time to be 2 count;
1.2) setting the number datanumber to be 1 and the total number dataSum to be 0;
1.3) setting a threshold value of each type of data;
2) encapsulating the transmission data packet, and the process is as follows:
2.1) encapsulating the data request packet, wherein the packet format of the data request packet is as follows:
1
|
2
|
1
|
RDI
|
type
|
verification |
The RDI represents a data request packet identifier, occupies one byte and has a value of 0x 01; the type represents the type of the data packet requested by the request packet, occupies two bytes, takes the value of hexadecimal number in the interval from 0x0000 to 0x00FF and represents different types of data; the check occupies one byte, and is the exclusive or operation sum of all bytes from the RDI to before the check;
2.2) encapsulating the request to start sending data packets, wherein the packet format of the request to start sending data packets is as follows:
1
|
2
|
4
|
4
|
4
|
1
|
1
|
RST
|
type
|
size
|
datasum
|
datalength
|
datastatus
|
verification |
Wherein, RST represents that the request starts to send the packet identifier, occupies one byte, and has a value of 0x 02; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x0000 to 0x00FF and represents different types of data; size indicates the size of the transmission data, and occupies 4 bytes; datasum represents the total number of transmitted data blocks, and occupies 4 bytes; datalength represents the length of each data packet, and occupies 4 bytes; data status represents a data state, and occupies 1 byte, and if the data exceeds a threshold value, the value is 0x02, otherwise, the value is 0x 01; the check occupies one byte, and is the exclusive or operation sum of all bytes from RST to before the check;
2.3) encapsulating the data packet for starting to send, wherein the packet format for starting to send the data packet is as follows:
1
|
2
|
1
|
STA
|
type
|
verification |
Wherein, the STA indicates that the data packet identifier starts to be sent, occupies one byte, and has a value of 0x 03; the type represents the type of the data packet requested by the request packet, occupies two bytes, takes the value of hexadecimal number in the interval from 0x0000 to 0x00FF and represents different types of data; the check occupies one byte, and is the exclusive or operation sum of all bytes from the beginning of the STA to before the check;
2.4) encapsulating the data packet, wherein the packet format of the data packet is as follows:
1
|
2
|
1
|
4
|
—
|
1
|
DPI
|
type
|
priority
|
datanum
|
data
|
verification |
Wherein, the DPI represents a packet identifier, occupies two bytes, and has a value of 0x 04; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x0000 to 0x00FF and represents different types of data; the priority is used for identifying the priority of the current data packet in the whole transmission process, occupies one byte, and has a value depending on the data status, if the data status is 0x01, the priority is 1, otherwise, the priority is 2; dataum represents the number of the data block; the data represents transmitted data, and the occupied length is determined by the data length; the check occupies one byte, and is the exclusive or operation sum of all bytes from the DPI to before the check;
2.5) encapsulating the next data packet, wherein the packet format of the next data packet is as follows:
1
|
2
|
4
|
1
|
RTN
|
type
|
datanum
|
verification |
Wherein, RTN represents the identifier of the next data packet, occupies one byte, and has the value of 0x 05; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x0000 to 0x00FF and represents different types of data; datanum represents the number of the packet; the check occupies one byte, and is the exclusive or operation sum of all bytes from the RTN to before the check;
2.6) encapsulating the data end packet, wherein the packet format of the data end packet is as follows:
1
|
2
|
1
|
4
|
1
|
STO
|
type
|
priority
|
datacount
|
verification |
Wherein, STO represents the packet identifier of the data end packet, occupies one byte, and has a value of 0x 06; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x0000 to 0x00FF and represents different types of data; the priority is used for identifying the priority of the current data packet in the whole transmission process; the datacount represents the number of packets actually transmitted; the check occupies one byte, and is the exclusive or operation sum of all bytes from STO to before the check;
2.7) encapsulating the data packet which is cancelled and sent, wherein the packet format of the data packet which is cancelled and sent is as follows:
1
|
2
|
1
|
CAN
|
type
|
verification |
Wherein, CAN represents the cancellation of sending data packet identification, occupies one byte, and has a value of 0x 07; the type represents the type of a data packet which is cancelled to be sent, occupies two bytes, takes the value of hexadecimal number in the interval from 0x0000 to 0x00FF and represents different types of data; the check occupies one byte, and is the exclusive or operation sum of all bytes from the CAN to before the check;
3) the data transmission process comprises the following steps:
3.1) blocking and waiting for client access, if the client access exists, establishing a data interaction channel with the client, and entering step 3.2);
3.2) starting a monitoring event;
3.3) monitoring whether the client receives a new character, if so, entering a step 3.4), otherwise, turning to a step 3.14);
3.4) analyzing the packet identification of the received character, and if the packet identification is RDI, entering the step 3.5); if the packet is the STA start packet, turning to step 3.6); if the next data packet RTN is requested, go to step 3.7); if the CAN is available, turning to the step 3.8);
3.5) receiving the RDI, analyzing the request packet, packaging data according to the request packet, sending the request data to the client, and starting to send a response RST;
3.6) receiving the STA, putting the data into the data buffer data, and turning to the step 3.9);
3.7) receiving the next data packet, analyzing the request packet, and turning to the step 3.9);
3.8) receiving the data packet for canceling the transmission, canceling the transmission;
3.9) judging whether the data block label number dataumber is smaller than the total number dataSum of the data blocks, if so, entering the step 3.10), otherwise, turning to the step 3.13);
3.10) judging whether the data packet with priority of 2 in the data buffer area data is empty, if so, going to step 3.11), otherwise, going to step 3.12);
3.11) sending a data packet with a data block label of dataumber, and turning to the step 3.3);
3.12) sending a data packet with priority of 2 in the data, and going to step 3.10);
3.13) sending a data block end packet, sending the data block end packet, and turning to the step 3.3);
3.14) judging whether the waiting time is overtime, if not, turning to the step 3.4), otherwise, turning to the step 3.15);
3.15) judging whether the timeout counter count is less than the maximum allowed timeout number sum, if so, sending a resending request to the server, otherwise, transmitting an error, and closing a data channel;
4) the data receiving process comprises the following steps:
4.1) blocking and waiting for client access, if the client access exists, establishing a data interaction channel with the client, and entering the step 4.2);
4.2) sending request data response RDI to the client, starting a monitoring event, and entering the step 4.3);
4.3) monitoring whether the client receives a new character, if so, entering the step 4.4), otherwise, turning to the step 4.10);
4.4) analyzing the packet identifier of the received character, and if the packet identifier is RST, entering the step 4.5); if the DPI is the DPI, the step 4.6) is carried out; if STO, go to step 4.7);
4.5) receiving the RST, analyzing the request to start sending a data packet, sending a start packet to the client when the total number of data blocks dataSum is equal to dataSum, and turning to step 4.3);
4.6) judging whether the data packet is correct, if so, turning to the step 4.8), otherwise, turning to the step 4.9);
4.7) stopping receiving data;
4.8) sending RTN;
4.9) the data packet label number 1, sending RTN;
4.10) judging whether the waiting time is overtime, if not, turning to the step 4.4), otherwise, continuing the step 4.11);
4.11) judging whether the timeout counter count is less than the maximum allowed timeout number sum, if so, sending a resending request to the server, otherwise, transmitting an error, and closing the data channel.
The invention has the following beneficial effects: the invention considers the priority of the same type of data under different conditions, sets a threshold value for each type of data, sets the priority of data transmission by taking the threshold value as a standard, and ensures that the data can be sent out preferentially when the data exceeds the threshold value. In addition, before the sender sends data to the requester, a connection process is firstly carried out, the sender sends a request to the requester to start sending a data packet, the requester receives the data packet and is ready to receive the data, and then the sender sends a request to start sending, so that the requester can receive the data in time. By applying the data transmission method with the variable priority based on the GIS system, the data transmission efficiency is improved, and the accuracy of data transmission is ensured.
Detailed Description
The invention is further described below with reference to the accompanying drawings.
Referring to fig. 1 and 2, a method for transmitting data with variable priority based on a GIS system and having a connection includes the steps of:
1) initializing parameters:
1.1) setting a timeout count to be 0, the maximum allowed timeout number sum, and a timeout time to be 2 count;
1.2) setting the number datanumber to be 1 and the total number dataSum to be 0;
1.3) setting a threshold value of each type of data;
2) encapsulating the transmission data packet, and the process is as follows:
2.1) encapsulating the data request packet, wherein the packet format of the data request packet is as follows:
the RDI represents a data request packet identifier, occupies one byte and has a value of 0x 01; the type represents the type of the data packet requested by the request packet, occupies two bytes, takes the value of hexadecimal number in the interval from 0x0000 to 0x00FF and represents different types of data; the check occupies one byte, and is the exclusive or operation sum of all bytes from the RDI to before the check;
2.2) encapsulating the request to start sending data packets, wherein the packet format of the request to start sending data packets is as follows:
1
|
2
|
4
|
4
|
4
|
1
|
1
|
RST
|
type
|
size
|
datasum
|
datalength
|
datastatus
|
verification |
Wherein, RST represents that the request starts to send the packet identifier, occupies one byte, and has a value of 0x 02; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x0000 to 0x00FF and represents different types of data; size indicates the size of the transmission data, and occupies 4 bytes; datasum represents the total number of transmitted data blocks, and occupies 4 bytes; datalength represents the length of each data packet, and occupies 4 bytes; data status represents a data state, and occupies 1 byte, and if the data exceeds a threshold value, the value is 0x02, otherwise, the value is 0x 01; the check occupies one byte, and is the exclusive or operation sum of all bytes from RST to before the check;
2.3) encapsulating the data packet for starting to send, wherein the packet format for starting to send the data packet is as follows:
1
|
2
|
1
|
STA
|
type
|
verification |
Wherein, the STA indicates that the data packet identifier starts to be sent, occupies one byte, and has a value of 0x 03; the type represents the type of the data packet requested by the request packet, occupies two bytes, takes the value of hexadecimal number in the interval from 0x0000 to 0x00FF and represents different types of data; the check occupies one byte, and is the exclusive or operation sum of all bytes from the beginning of the STA to before the check;
2.4) encapsulating the data packet, wherein the packet format of the data packet is as follows:
1
|
2
|
1
|
4
|
—
|
1
|
DPI
|
type
|
priority
|
datanum
|
data
|
verification |
Wherein, the DPI represents a packet identifier, occupies two bytes, and has a value of 0x 04; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x0000 to 0x00FF and represents different types of data; the priority is used for identifying the priority of the current data packet in the whole transmission process, occupies one byte, and has a value depending on the data status, if the data status is 0x01, the priority is 1, otherwise, the priority is 2; dataum represents the number of the data block; the data represents transmitted data, and the occupied length is determined by the data length; the check occupies one byte, and is the exclusive or operation sum of all bytes from the DPI to before the check;
2.5) encapsulating the next data packet, wherein the packet format of the next data packet is as follows:
1
|
2
|
4
|
1
|
RTN
|
type
|
datanum
|
verification |
Wherein, RTN represents the identifier of the next data packet, occupies one byte, and has the value of 0x 05; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x0000 to 0x00FF and represents different types of data; datanum represents the number of the packet; the check occupies one byte, and is the exclusive or operation sum of all bytes from the RTN to before the check;
2.6) encapsulating the data end packet, wherein the packet format of the data end packet is as follows:
1
|
2
|
1
|
4
|
1
|
STO
|
type
|
priority
|
datacount
|
verification |
Wherein, STO represents the packet identifier of the data end packet, occupies one byte, and has a value of 0x 06; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x0000 to 0x00FF and represents different types of data; the priority is used for identifying the priority of the current data packet in the whole transmission process; the datacount represents the number of packets actually transmitted; the check occupies one byte, and is the exclusive or operation sum of all bytes from STO to before the check;
2.7) encapsulating the data packet which is cancelled and sent, wherein the packet format of the data packet which is cancelled and sent is as follows:
1
|
2
|
1
|
CAN
|
type
|
verification |
Wherein, CAN represents the cancellation of sending data packet identification, occupies one byte, and has a value of 0x 07; the type represents the type of a data packet which is cancelled to be sent, occupies two bytes, and takes the value from 0x0000 to 0x00FF to the exclusive or operation sum of all bytes before verification;
3) the data transmission process comprises the following steps:
3.1) blocking and waiting for client access, if the client access exists, establishing a data interaction channel with the client, and entering step 3.2);
3.2) starting a monitoring event;
3.3) monitoring whether the client receives a new character, if so, entering a step 3.4), otherwise, turning to a step 3.14);
3.4) analyzing the packet identification of the received character, and if the packet identification is RDI, entering the step 3.5); if the packet is the STA start packet, turning to step 3.6); if the next data packet RTN is requested, go to step 3.7); if the CAN is available, turning to the step 3.8);
3.5) receiving the RDI, analyzing the request packet, packaging data according to the request packet, sending the request data to the client, and starting to send a response RST;
3.6) receiving the STA, putting the data into the data buffer data, and turning to the step 3.9);
3.7) receiving the next data packet, analyzing the request packet, and turning to the step 3.9);
3.8) receiving the data packet for canceling the transmission, canceling the transmission;
3.9) judging whether the data block label number dataumber is smaller than the total number dataSum of the data blocks, if so, entering the step 3.10), otherwise, turning to the step 3.13);
3.10) judging whether the data packet with priority of 2 in the data buffer area data is empty, if so, going to step 3.11), otherwise, going to step 3.12);
3.11) sending a data packet with a data block label of dataumber, and turning to the step 3.3);
3.12) sending a data packet with priority of 2 in the data, and going to step 3.10);
3.13) sending a data block end packet, sending the data block end packet, and turning to the step 3.3);
3.14) judging whether the waiting time is overtime, if not, turning to the step 3.4), otherwise, turning to the step 3.15);
3.15) judging whether the timeout counter count is less than the maximum allowed timeout number sum, if so, sending a resending request to the server, otherwise, transmitting an error, and closing a data channel;
4) the data receiving process comprises the following steps:
4.1) blocking and waiting for client access, if the client access exists, establishing a data interaction channel with the client, and entering the step 4.2);
4.2) sending request data response RDI to the client, starting a monitoring event, and entering the step 4.3);
4.3) monitoring whether the client receives a new character, if so, entering the step 4.4), otherwise, turning to the step 4.10);
4.4) analyzing the packet identifier of the received character, and if the packet identifier is RST, entering the step 4.5); if the DPI is the DPI, the step 4.6) is carried out; if STO, go to step 4.7);
4.5) receiving the RST, analyzing the request to start sending a data packet, sending a start packet to the client when the total number of data blocks dataSum is equal to dataSum, and turning to step 4.3);
4.6) judging whether the data packet is correct, if so, turning to the step 4.8), otherwise, turning to the step 4.9);
4.7) stopping receiving data;
4.8) sending RTN;
4.9) the data packet label number 1, sending RTN;
4.10) judging whether the waiting time is overtime, if not, turning to the step 4.4), otherwise, continuing the step 4.11);
4.11) judging whether the timeout counter count is less than the maximum allowed timeout number sum, if so, sending a resending request to the server, otherwise, transmitting an error, and closing the data channel.
In this embodiment, a data transmission method with variable priority connected based on a GIS system, which uses location information transmission as an embodiment, includes the following steps:
1) initializing parameters:
1.1) setting a timeout count to be 0, the maximum allowed timeout number sum, and a timeout time to be 2 count;
1.2) setting the number datanumber to be 1 and the total number dataSum to be 0;
1.3) setting a threshold value of each type of data;
2) encapsulating the transmission data packet, and the process is as follows:
2.1) encapsulating the data request packet, wherein the packet format of the data request packet is as follows:
1
|
2
|
1
|
RDI
|
type
|
verification |
The RDI represents a data request packet identifier, occupies one byte and has a value of 0x 01; the type represents the type of a data packet requested by a request packet, occupies two bytes, takes the value of hexadecimal number in the interval from 0x00 to 0xFF, and represents different types of data; the check occupies one byte, and is the exclusive or operation sum of all bytes from the RDI to before the check;
2.2) encapsulating the request to start sending data packets, wherein the packet format of the request to start sending data packets is as follows:
1
|
2
|
4
|
4
|
4
|
1
|
1
|
RST
|
type
|
size
|
datasum
|
datalength
|
datastatus
|
verification |
Wherein, RST represents that the request starts to send the packet identifier, occupies one byte, and has a value of 0x 02; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x00 to 0xFF, and represents different types of data; size indicates the size of the transmission data, and occupies 4 bytes; datasum represents the total number of transmitted data blocks, and occupies 4 bytes; datalength represents the length of each data packet, and occupies 4 bytes; data status represents a data state, and occupies 1 byte, and if the data exceeds a threshold value, the value is 0x02, otherwise, the value is 0x 01; the check occupies one byte, and is the exclusive or operation sum of all bytes from RST to before the check;
2.3) encapsulating the data packet for starting to send, wherein the packet format for starting to send the data packet is as follows:
1
|
2
|
1
|
STA
|
type
|
verification |
Wherein, the STA indicates that the data packet identifier starts to be sent, occupies one byte, and has a value of 0x 03; the type represents the type of a data packet requested by a request packet, occupies two bytes, takes the value of hexadecimal number in the interval from 0x00 to 0xFF, and represents different types of data; the check occupies one byte, and is the exclusive or operation sum of all bytes from the beginning of the STA to before the check;
2.4) encapsulating the data packet, wherein the packet format of the data packet is as follows:
1
|
2
|
1
|
4
|
—
|
1
|
DPI
|
type
|
priority
|
datanum
|
data
|
verification |
Wherein, the DPI represents a packet identifier, occupies two bytes, and has a value of 0x 04; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x00 to 0xFF, and represents different types of data; the priority is used for identifying the priority of the current data packet in the whole transmission process, occupies one byte, and has a value depending on the data status, if the data status is 0x01, the priority is 1, otherwise, the priority is 2; dataum represents the number of the data block; the data represents transmitted data, and the occupied length is determined by the data length; the check occupies one byte, and is the exclusive or operation sum of all bytes from the DPI to before the check;
2.5) encapsulating the next data packet, wherein the packet format of the next data packet is as follows:
1
|
2
|
4
|
1
|
RTN
|
type
|
datanum
|
verification |
Wherein, RTN represents the identifier of the next data packet, occupies one byte, and has the value of 0x 05; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x00 to 0xFF, and represents different types of data; datanum represents the number of the packet; the check occupies one byte, and is the exclusive or operation sum of all bytes from the RTN to before the check;
2.6) encapsulating the data end packet, wherein the packet format of the data end packet is as follows:
1
|
2
|
1
|
4
|
1
|
STO
|
type
|
priority
|
datacount
|
verification |
Wherein, STO represents the packet identifier of the data end packet, occupies one byte, and has a value of 0x 06; type represents a data packet type, occupies two bytes, takes a value of hexadecimal number in an interval from 0x00 to 0xFF, and represents different types of data; the priority is used for identifying the priority of the current data packet in the whole transmission process; the datacount represents the number of packets actually transmitted; the check occupies one byte, and is the exclusive or operation sum of all bytes from STO to before the check;
2.7) encapsulating the data packet which is cancelled and sent, wherein the packet format of the data packet which is cancelled and sent is as follows:
1
|
2
|
1
|
CAN
|
type
|
verification |
Wherein, CAN represents the cancellation of sending data packet identification, occupies one byte, and has a value of 0x 07; the type represents the type of a data packet which is cancelled to be sent, occupies two bytes, takes the value of hexadecimal number in the interval from 0x00 to 0xFF, and represents different types of data; the check occupies one byte, and is the exclusive or operation sum of all bytes from the CAN to before the check;
3) the data transmission process comprises the following steps:
3.1) blocking and waiting for client access, if the client access exists, establishing a data interaction channel with the client, and entering step 3.2);
3.2) starting a monitoring event;
3.3) monitoring whether the client receives a new character, if so, entering a step 3.4), otherwise, turning to a step 3.14);
3.4) analyzing the packet identification of the received character, and if the packet identification is RDI, entering the step 3.5); if the packet is the STA start packet, turning to step 3.6); if the next data packet RTN is requested, go to step 3.7); if the CAN is available, turning to the step 3.8);
3.5) receiving the RDI, analyzing the request packet, packaging data according to the request packet, sending the request data to the client, and starting to send a response RST;
3.6) receiving the STA, putting the data into the data buffer data, and turning to the step 3.9);
3.7) receiving the next data packet, analyzing the request packet, and turning to the step 3.9);
3.8) receiving the data packet for canceling the transmission, canceling the transmission;
3.9) judging whether the data block label number dataumber is smaller than the total number dataSum of the data blocks, if so, entering the step 3.10), otherwise, turning to the step 3.13);
3.10) judging whether the data packet with priority of 2 in the data buffer area data is empty, if so, going to step 3.11), otherwise, going to step 3.12);
3.11) sending a data packet with a data block label of dataumber, and turning to the step 3.3);
3.12) sending a data packet with priority of 2 in the data, and going to step 3.10);
3.13) sending a data block end packet, sending the data block end packet, and turning to the step 3.3);
3.14) judging whether the waiting time is overtime, if not, turning to the step 3.4), otherwise, turning to the step 3.15);
3.15) judging whether the timeout counter count is less than the maximum allowed timeout number sum, if so, sending a resending request to the server, otherwise, transmitting an error, and closing a data channel;
4) the data receiving process comprises the following steps:
4.1) blocking and waiting for client access, if the client access exists, establishing a data interaction channel with the client, and entering the step 4.2);
4.2) sending request data response RDI to the client, starting a monitoring event, and entering the step 4.3);
4.3) monitoring whether the client receives a new character, if so, entering the step 4.4), otherwise, turning to the step 4.10);
4.4) analyzing the packet identifier of the received character, and if the packet identifier is RST, entering the step 4.5); if the DPI is the DPI, the step 4.6) is carried out; if STO, go to step 4.7);
4.5) receiving the RST, analyzing the request to start sending a data packet, sending a start packet to the client when the total number of data blocks dataSum is equal to dataSum, and turning to step 4.3);
4.6) judging whether the data packet is correct, if so, turning to the step 4.8), otherwise, turning to the step 4.9);
4.7) stopping receiving data;
4.8) sending RTN;
4.9) the data packet label number 1, sending RTN;
4.10) judging whether the waiting time is overtime, if not, turning to the step 4.4), otherwise, continuing the step 4.11);
4.11) judging whether the timeout counter count is less than the maximum allowed timeout number sum, if so, sending a resending request to the server, otherwise, transmitting an error, and closing the data channel.
While the foregoing has described the preferred embodiments of the present invention, it will be apparent that the invention is not limited to the embodiments described, but can be practiced with modification without departing from the basic spirit of the invention and without departing from the spirit of the invention.