CN109067775B - A communication data compression and decompression method, device and system - Google Patents
A communication data compression and decompression method, device and system Download PDFInfo
- Publication number
- CN109067775B CN109067775B CN201811057233.XA CN201811057233A CN109067775B CN 109067775 B CN109067775 B CN 109067775B CN 201811057233 A CN201811057233 A CN 201811057233A CN 109067775 B CN109067775 B CN 109067775B
- Authority
- CN
- China
- Prior art keywords
- data
- compression
- data frame
- frame
- value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/04—Protocols for data compression, e.g. ROHC
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/565—Conversion or adaptation of application format or content
- H04L67/5651—Reducing the amount or size of exchanged application data
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Mobile Radio Communication Systems (AREA)
- Compression, Expansion, Code Conversion, And Decoders (AREA)
Abstract
本发明公开了一种通信数据压缩、解压方法、装置及系统,方法包括:接收配置帧,数据帧;将数据帧分割数据帧集合,判断是否为本轮压缩的第一帧数据;若是,将当前帧的SYNC字段的数值改为预设字段,将当前帧的下一帧作为当前帧;若否,对当前帧进行变量压缩得到变量段ΔDATA_Frame;根据压缩计数字Count_byte判断所压缩的数据帧是否达到压缩上限;判断压缩耗时是否大于或等于预设时限T;将DATA_Frame1,压缩计数字Count_byte以及变量段ΔDATA_Frame的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站。应用本发明实施例,可以提高信息的发送效率。
The invention discloses a communication data compression and decompression method, device and system. The method comprises: receiving a configuration frame and a data frame; dividing the data frame into a set of data frames to determine whether it is the first frame data of this round of compression; The value of the SYNC field of the current frame is changed to the preset field, and the next frame of the current frame is taken as the current frame; if not, the variable segment ΔDATA_Frame is obtained by variable compression of the current frame; according to the compression count number Count_byte, it is judged whether the compressed data frame is not Reach the upper limit of compression; judge whether the compression time is greater than or equal to the preset time limit T; send the combination of DATA_Frame1, the compression count Count_byte and the variable segment ΔDATA_Frame as the compressed data to the WAMS system for receiving the data sent by the data sending device 's main site. By applying the embodiments of the present invention, the transmission efficiency of information can be improved.
Description
技术领域technical field
本发明涉及一种通信数据压缩及解压方法,更具体涉及一种通信数据压缩、解压方法、装置及系统。The present invention relates to a communication data compression and decompression method, and more particularly to a communication data compression and decompression method, device and system.
背景技术Background technique
配电网WAMS(Wide Area Measuremen tSystem,广域监测系统)是应用于配电网的广域监测系统,采用同步相量测量技术,通过在各配电线路出线首端布置配电线路PDC(Phasor Data Concentrator,相量数据集中器),在配电线路各段布置配电线路PMU(Phasor Measurement Unit,同步相量测量单元),实现对配电线路同步相量及配电网主要数据的实时高速率采集。配电网WAMS系统包括用于数据采集的PMU设备,用于数据压缩及发送的PDC设备或者NIC(Network Interface Controller,通信适配器)设备;然后PMU将采集的数据发送给PDC或者NIC,PDC或者NIC,将PMU采集的数据进行压缩后发送给配电网WAMS系统中的WAMS主站。通常情况下,配电网WAMS采用的通信规约为:GBT 26865.2-2011电力系统实时动态监测系统第2部分:数据传输协议。配电网WAMS的通信系统具有以下特点:通信网络结构复杂,通信终端节点数量众多;通信距离较短;通信数据量大。为了满足配电网WAMS的建设中对通信系统的要求,多种电力系统通信方式需要配合使用。Distribution network WAMS (Wide Area Measurement System, wide area monitoring system) is a wide area monitoring system applied to the distribution network, using synchrophasor measurement technology, by arranging the distribution line PDC (Phasor Data Concentrator, phasor data concentrator), arrange distribution line PMU (Phasor Measurement Unit, synchrophasor measurement unit) in each section of the distribution line to achieve real-time high-speed data on the synchrophasor of the distribution line and the main data of the distribution network. rate collection. The distribution network WAMS system includes PMU equipment for data collection, PDC equipment or NIC (Network Interface Controller, communication adapter) equipment for data compression and transmission; then PMU sends the collected data to PDC or NIC, PDC or NIC , compress the data collected by the PMU and send it to the WAMS master station in the distribution network WAMS system. Usually, the communication protocol adopted by the distribution network WAMS is: GBT 26865.2-2011 Power System Real-time Dynamic Monitoring System Part 2: Data Transmission Protocol. The communication system of the distribution network WAMS has the following characteristics: the structure of the communication network is complex, the number of communication terminal nodes is large, the communication distance is short, and the amount of communication data is large. In order to meet the requirements of the communication system in the construction of the distribution network WAMS, a variety of power system communication methods need to be used together.
但是,由于PDC或者NIC是通过光纤与PMU连接,通信频率可以达到每秒100帧,但是,PDC或者NIC向WAMS主站发送数据的无线网络系统的传输速率低于每秒100帧,因此,会导致PDC或者NIC在传输的单位容量的数据中所包含的信息量过少,进而导致信息传送效率较低。However, since the PDC or NIC is connected to the PMU through optical fiber, the communication frequency can reach 100 frames per second. However, the transmission rate of the wireless network system in which the PDC or NIC sends data to the WAMS master station is lower than 100 frames per second. As a result, the amount of information contained in the data per unit capacity transmitted by the PDC or NIC is too small, which in turn leads to low information transmission efficiency.
发明内容SUMMARY OF THE INVENTION
本发明所要解决的技术问题在于提供了一种通信数据压缩、解压方法、装置及系统,以提高信息传送效率。The technical problem to be solved by the present invention is to provide a communication data compression and decompression method, device and system to improve the information transmission efficiency.
本发明是通过以下技术方案解决上述技术问题的:The present invention solves the above-mentioned technical problems through the following technical solutions:
第一方面,本发明实施例提供了一种通信数据压缩方法,应用于配电网WAMS系统中向主站发送数据的数据发送设备,所述方法包括:In a first aspect, an embodiment of the present invention provides a communication data compression method, which is applied to a data sending device that sends data to a master station in a WAMS system of a distribution network, and the method includes:
A:接收WAMS系统中的WAMS主站发送的配置帧,接收各个PMU单元发送的数据帧;将所述数据帧分割成至少两个数据帧集合;A: Receive the configuration frame sent by the WAMS master station in the WAMS system, and receive the data frame sent by each PMU unit; divide the data frame into at least two data frame sets;
B:针对每一个数据帧集合,将所述数据帧集合中的第一个数据帧作为当前数据帧,判断当前数据帧是否为本轮压缩的第一帧数据;B: For each data frame set, the first data frame in the data frame set is used as the current data frame, and it is judged whether the current data frame is the first frame data of this round of compression;
C:若是,将所述当前数据帧的SYNC字段的数值改为预设字段,并将压缩计数字Count_byte的值设置为0;将所述当前数据帧存储到缓存数组TEMP首端的DATA_Frame1段,判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,执行步骤F,若本轮压缩的压缩耗时小于预设时限T,将所述当前数据帧的下一帧作为当前数据帧,并返回执行所述B步骤;C: If yes, change the numerical value of the SYNC field of the current data frame to a preset field, and set the value of the compression count number Count_byte to 0; store the current data frame in the DATA_Frame1 segment at the head end of the cache array TEMP, and judge Whether the compression time of this round of compression is greater than or equal to the preset time limit T; if the compression time of this round of compression is greater than or equal to the preset time limit T, perform step F, if the compression time of this round of compression is less than the preset time limit T, Taking the next frame of the current data frame as the current data frame, and returning to execute the B step;
D:若否,将压缩计数字Count_byte的当前值与预设步长之和作为所述压缩计数字的当前值;根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩得到变量段ΔDATA_Frame;D: If not, take the sum of the current value of the compression count number Count_byte and the preset step size as the current value of the compression count number; according to the phasor of the current data frame and the previous data frame of the current data frame Corresponding to the difference of the phasors, the variable segment ΔDATA_Frame is obtained by performing variable compression on the current data frame;
E:根据所述压缩计数字Count_byte判断本轮压缩所压缩的数据帧是否达到压缩上限;若本轮压缩所压缩的数据帧达到压缩上限,执行步骤F;若本轮压缩所压缩的数据帧未达到压缩上限,判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,执行步骤F,若本轮压缩的压缩耗时小于预设时限T,将所述当前数据帧的下一帧作为当前数据帧,返回执行所述步骤B;E: According to the compression count number Count_byte, determine whether the data frame compressed in this round of compression reaches the upper limit of compression; if the data frame compressed in this round of compression reaches the upper limit of compression, perform step F; if the data frame compressed in this round of compression does not When the upper limit of compression is reached, determine whether the compression time of this round of compression is greater than or equal to the preset time limit T; if the compression time of this round of compression is greater than or equal to the preset time limit T, perform step F, if the compression time of this round of compression is less than or equal to the preset time limit T Preset time limit T, take the next frame of the current data frame as the current data frame, and return to execute the step B;
F:在所述当前数据帧为本轮压缩的第一帧,且本轮压缩的压缩耗时大于或等于预设时限T时,将所述DATA_Frame1,所述压缩计数字Count_byte的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站;在除所述当前数据帧为本轮压缩的第一帧,且本轮压缩的压缩耗时大于或等于预设时限T时以外的情况下,将所述DATA_Frame1,所述压缩计数字Count_byte以及所述变量段ΔDATA_Frame的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站。F: When the current data frame is the first frame of this round of compression, and the compression time of this round of compression is greater than or equal to the preset time limit T, the combination of the DATA_Frame1 and the compression count number Count_byte is used as the compressed The data is sent to the master station in the WAMS system for receiving the data sent by the data sending device; except that the current data frame is the first frame of this round of compression, and the compression time of this round of compression is greater than or equal to the preset In cases other than the time limit T, the combination of the DATA_Frame1, the compression count number Count_byte and the variable segment ΔDATA_Frame is sent as compressed data to the master station in the WAMS system for receiving the data sent by the data sending device .
可选的,所述数据发送设备至少包括:PDC单元和NIC单元中的一种。Optionally, the data sending device includes at least one of a PDC unit and a NIC unit.
可选的,所述步骤A,包括:Optionally, the step A includes:
接收各个PMU单元发送的,依据配置帧将自身采集的线路数据生成的数据帧。Receive a data frame sent by each PMU unit and generate the line data collected by itself according to the configuration frame.
可选的,所述根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩得到变量段ΔDATA_Frame,包括:Optionally, according to the difference between the phasor of the current data frame and the corresponding phasor of the previous data frame of the current data frame, perform variable compression on the current data frame to obtain a variable segment ΔDATA_Frame, including:
D1:将当前数据帧中包含的相量数目n除以j,得到a组相量,和余数b个相量,且b小于j;D1: Divide the number n of phasors contained in the current data frame by j to obtain a group of phasors, and the remainder b phasors, and b is less than j;
D2:从a组相量中的第一组相量开始,将所述第一组向量作为当前组向量,针对当前组相量中的每一个相量,将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第一幅值变化量;将所述当前数据帧的每一个相量的角度与所述当前数据帧的前一数据帧的每一个对应相量的角度进行比较,得到第一角度变化量,根据所述第一幅值变化量和所述第一角度变化量生成第一变量标识;将所述第一幅值变化量和所述第一角度变化量合成为第一变量;D2: Starting from the first group of phasors in the a group of phasors, take the first group of vectors as the current group vector, and for each phasor in the current group of phasors, compare the amplitude of the phasor with the The amplitude of the corresponding phasor of the previous data frame of the current data frame is compared to obtain the first amplitude variation; the angle of each phasor of the current data frame is compared with the previous data of the current data frame. Comparing the angles of each corresponding phasor of the frame to obtain a first angle change, and generating a first variable identifier according to the first amplitude change and the first angle change; changing the first amplitude The amount and the first angle change amount are combined into a first variable;
D3:将所述当前组相量对应的第一变量标识存储到标识数组flag中;将所述第一变量存储到变量数组data中;然后将当前组相量的下一组相量作为当前组相量,并返回执行所述D2步骤,直至a组相量都被处理;D3: store the first variable flag corresponding to the current group of phasors in the flag array flag; store the first variable in the variable array data; then use the next group of phasors of the current group of phasors as the current group phasors, and return to perform the D2 step until the a group of phasors are processed;
D4:针对b个相量中的每一个相量,将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第二幅值变化量;将所述相量的角度与所述当前数据帧的前一数据帧的对应相量的角度进行比较,得到第二角度变化量;根据所述第二幅值变化量和所述第二角度变化量生成第二变量标识,将所述第二变量标识存储到标识数组flag中;将所述第二幅值变化量和所述第二角度变化量合成为第二变量;将所述第二变量存储到变量数组data中;D4: For each phasor in the b phasors, compare the amplitude of the phasor with the amplitude of the corresponding phasor of the previous data frame of the current data frame to obtain a second amplitude variation ; Compare the angle of the phasor with the angle of the corresponding phasor of the previous data frame of the current data frame to obtain a second angle change; According to the second amplitude change and the second angle The variation generates a second variable identification, and stores the second variable identification in the identification array flag; synthesizes the second amplitude variation and the second angle variation into a second variable; The variable is stored in the variable array data;
D5将所述标识数组flag和所述变量数组data组成变量段ΔDATA_Frame。D5 composes the flag array flag and the variable array data into a variable segment ΔDATA_Frame.
可选的,所述将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第一幅值变化量;将所述当前数据帧的每一个相量的角度与所述当前数据帧的前一数据帧的每一个对应相量的角度进行比较,得到第一角度变化量,根据所述第一幅值变化量和所述第一角度变化量生成第一变量标识,包括:Optionally, comparing the amplitude of the phasor with the amplitude of the corresponding phasor of the previous data frame of the current data frame to obtain a first amplitude change; The angle of each phasor is compared with the angle of each corresponding phasor in the previous data frame of the current data frame to obtain a first angle change. According to the first amplitude change and the first angle The delta generates a first variable identifier, including:
1)、设k为计数,初值为0,判断k是否小于j:1), let k be the count, the initial value is 0, and judge whether k is less than j:
2)、若是,将当前数据帧的每一个相量的幅值r1与所述当前数据帧的前一数据帧的每一个对应相量的幅值p1的差值H1作为第一幅值变化量;将当前数据帧的每一个相量的角度r2与所述当前数据帧的前一数据帧的每一个对应相量的角度p2的差值H2作为第一角度变化量;并判断H1和H2的绝对值是否均小于8;2) If yes, take the difference H1 between the amplitude r1 of each phasor of the current data frame and the amplitude p1 of each corresponding phasor of the previous data frame of the current data frame as the first amplitude variation ; The difference H2 of the angle r2 of each phasor of the current data frame and the angle p2 of each corresponding phasor of the previous data frame of the current data frame is used as the first angle variation; And judge H1 and H2 Whether the absolute value is less than 8;
3)、若H1和H2的绝对值均小于8,为H1和H2各分配0.5个字节的存储空间,更新第一变量标识sign[k]为0x00;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与8之和,并判断H2的值是否为负;若H1的值为正,判断H2的值是否为负,若H2的值为负,将H2的值更新为H2与8之和;将H1和H2存储到缓存数组one中;3) If the absolute values of H1 and H2 are both less than 8, allocate 0.5 bytes of storage space for each of H1 and H2, update the first variable sign [k] to 0x00; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 8, and determine whether the value of H2 is negative; if the value of H1 is positive, determine whether the value of H2 is negative, if the value of H2 is negative, change the value of H2 The value of is updated to the sum of H2 and 8; H1 and H2 are stored in the cache array one;
4)、若H1和H2的绝对值不是均小于8,判断H1和H2的绝对值是否均小于128;4) If the absolute values of H1 and H2 are not both less than 8, judge whether the absolute values of H1 and H2 are both less than 128;
5)、若H1和H2的绝对值均小于128,为H1和H2各分配1个字节的存储空间,更新第一变量标识sign[k]为0x01;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与128之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤,若H2的值为负,将H2的值更新为H2与128之和;将H1和H2存储到缓存数组two中;5) If the absolute values of H1 and H2 are both less than 128, allocate 1 byte of storage space for each of H1 and H2, update the first variable sign [k] to 0x01; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 128, and judge whether the value of H2 is negative; if the value of H1 is positive, execute the step of judging whether the value of H2 is negative, if the value of H2 is negative If it is negative, update the value of H2 to the sum of H2 and 128; store H1 and H2 into the cache array two;
6)、若H1和H2的绝对值不是均小于128,判断H1和H2的绝对值是否均小于2048;6) If the absolute values of H1 and H2 are not both less than 128, judge whether the absolute values of H1 and H2 are both less than 2048;
7)、若H1和H2的绝对值均小于2048,为H1和H2各分配1.5个字节的存储空间,更新第一变量标识sign[k]为0x02;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与2048之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤;若H2的值为负,将H2的值更新为H2与2048之和;将H1和H2存储到缓存数组three中;7), if the absolute values of H1 and H2 are both less than 2048, allocate 1.5 bytes of storage space for H1 and H2, update the first variable sign [k] to 0x02; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 2048, and judge whether the value of H2 is negative; if the value of H1 is positive, execute the step of judging whether the value of H2 is negative; if the value of H2 is negative If it is negative, update the value of H2 to the sum of H2 and 2048; store H1 and H2 into the cache array three;
8)、若H1和H2的绝对值不是均小于2048,更新第一变量标识sign[k]为=0x03,然后将r1,r2存储到缓存数组four中;8), if the absolute values of H1 and H2 are not both less than 2048, update the first variable sign sign[k] to = 0x03, and then store r1, r2 in the cache array four;
9)、将k的值更新为k+1,并返回执行所述步骤1);直至所述当前组向量中的每一个向量都被处理;9), update the value of k to k+1, and return to execute the step 1); until each vector in the current group of vectors is processed;
10)、当k的值大于或等于j时,执行所述D3步骤。10) When the value of k is greater than or equal to j, execute the step D3.
可选的,所述将所述当前组相量对应的第一变量标识存储到标识数组flag中,包括:Optionally, the first variable identifier corresponding to the current group of phasors is stored in the identifier array flag, including:
将当前组相量中的每一个相量对应的第一变量标识存储到临时标识数组sign中,然后将当前组的各个相量对应的第一变量标识的集合存储到标识数组flag中。The first variable identifier corresponding to each phasor in the current group of phasors is stored in the temporary identifier array sign, and then the set of first variable identifiers corresponding to each phasor in the current group is stored in the identifier array flag.
可选的,所述预设步长为1。Optionally, the preset step size is 1.
可选的,所述预设字段为:0xAA63。Optionally, the preset field is: 0xAA63.
本发明实施例还提供了一种通信数据解压方法,应用于WAMS系统中接收数据发送设备所发送数据的主站,所述方法包括:The embodiment of the present invention also provides a communication data decompression method, which is applied to a master station in a WAMS system that receives data sent by a data sending device, and the method includes:
G:接收所述数据发送设备发送的与所述数据帧集合对应的压缩后的数据帧;G: Receive the compressed data frame corresponding to the data frame set sent by the data sending device;
H:判断所述数据帧的SYNC字段是否为预设字段,若否,返回执行所述G步骤;若是,执行I步骤;H: judge whether the SYNC field of the data frame is a preset field, if not, return to execute the G step; if so, execute the I step;
I:将压缩计数字Count_byte之后的L个字节的数据,顺序放入标识数组flag,将L个字节之后的数据放入变量数组data;I: Put the L bytes of data after the compression count number Count_byte into the flag array flag in sequence, and put the data after L bytes into the variable array data;
J:从所述标识数组flag中顺序取出j个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data;J: Sequentially take out j identifiers from the identifier array flag and put them in the array sign, and then sequentially read the data of the corresponding length in the variable array data according to the sign content, and according to the data corresponding to the variable array data The phasor of the previous data frame of the frame is restored to the original phasor corresponding to the data read according to the sign content, and the original phasor is sequentially stored in the array Full_data;
K:从所述标识数组flag中顺序取出b个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data;K: Sequentially take out b identifiers from the identifier array flag and put them into the array sign, and then sequentially read the data of the corresponding length in the variable array data according to the contents of the sign, and according to the data corresponding to the variable array data The phasor of the previous data frame of the frame is restored to the original phasor corresponding to the data read according to the sign content, and the original phasor is sequentially stored in the array Full_data;
L:根据配置帧和第一帧数据帧生成除相量以外的其他字段,将所生成的其他字段与数组Full_data中的数据组合生成完整数据帧。L: Generate other fields except phasors according to the configuration frame and the first frame data frame, and combine the generated other fields with the data in the array Full_data to generate a complete data frame.
可选的,所述方法还包括:Optionally, the method further includes:
判断得到的解压后的数据帧是否有错误或者漏发,如果是,向所述数据发送设备发送补发命令,以使所述数据发送设备调取相应错误或者漏发数据帧。Determine whether the obtained decompressed data frame has errors or missed sending, and if so, send a re-send command to the data sending device, so that the data sending device can retrieve the corresponding error or missed sending of the data frame.
本发明实施例还提供了一种通信数据压缩装置,应用于配电网WAMS系统中向主站发送数据的数据发送设备,所述装置包括:An embodiment of the present invention also provides a communication data compression device, which is applied to a data sending device for sending data to a master station in a WAMS system of a power distribution network, and the device includes:
第一接收模块,用于接收WAMS系统中的WAMS主站发送的配置帧,接收各个PMU单元发送的数据帧;将所述数据帧分割成至少两个数据帧集合,其中,所述配置帧中包含数据a和b;The first receiving module is used for receiving the configuration frame sent by the WAMS master station in the WAMS system, and receiving the data frame sent by each PMU unit; dividing the data frame into at least two data frame sets, wherein, in the configuration frame contains data a and b;
第一判断模块,用于针对每一个数据帧集合,将所述数据帧集合中的第一个数据帧作为当前数据帧,判断当前数据帧是否为本轮压缩的第一帧数据;The first judgment module is used to, for each data frame set, take the first data frame in the data frame set as the current data frame, and judge whether the current data frame is the first frame data of this round of compression;
第一设置模块,用于在所述第一判断模块的判断结果为是的情况下,将所述当前数据帧的SYNC字段的数值改为预设字段,并将压缩计数字Count_byte的值设置为0;将所述当前数据帧存储到缓存数组TEMP首端的DATA_Frame1段,判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,触发第二设置模块,若本轮压缩的压缩耗时小于预设时限T,将所述当前数据帧的下一帧作为当前数据帧,并触发第一判断模块;The first setting module is used to change the value of the SYNC field of the current data frame to a preset field when the judgment result of the first judgment module is yes, and set the value of the compression count number Count_byte as 0; store the current data frame in the DATA_Frame1 segment at the head end of the cache array TEMP, and judge whether the compression time of this round of compression is greater than or equal to the preset time limit T; if the compression time of this round of compression is greater than or equal to the preset time limit T , trigger the second setting module, if the compression time of the current round of compression is less than the preset time limit T, take the next frame of the current data frame as the current data frame, and trigger the first judgment module;
压缩模块,用于在所述第一判断模块的判断结果为否的情况下,将压缩计数字Count_byte的当前值与预设步长之和作为所述压缩计数字的当前值;根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩得到变量段ΔDATA_Frame;a compression module, configured to use the sum of the current value of the compression count number Count_byte and the preset step size as the current value of the compression count number when the judgment result of the first judgment module is no; according to the current The difference between the phasor of the data frame and the corresponding phasor of the previous data frame of the current data frame, the variable segment ΔDATA_Frame is obtained by performing variable compression on the current data frame;
第二判断模块,用于根据所述压缩计数字Count_byte判断本轮压缩所压缩的数据帧是否达到压缩上限;若本轮压缩所压缩的数据帧达到压缩上限,执行步骤F;若本轮压缩所压缩的数据帧未达到压缩上限,判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,触发第二设置模块,若本轮压缩的压缩耗时小于预设时限T,将所述当前数据帧的下一帧作为当前数据帧,触发所述第一判断模块;The second judgment module is used for judging whether the data frame compressed in this round of compression reaches the upper limit of compression according to the compression count number Count_byte; if the data frame compressed in this round of compression reaches the upper limit of compression, perform step F; The compressed data frame does not reach the upper limit of compression, and judge whether the compression time of this round of compression is greater than or equal to the preset time limit T; if the compression time of this round of compression is greater than or equal to the preset time limit T, trigger the second setting module, if this The compression time of round compression is less than the preset time limit T, and the next frame of the current data frame is used as the current data frame, and the first judgment module is triggered;
第二设置模块,用于在所述当前数据帧为本轮压缩的第一帧,且本轮压缩的压缩耗时大于或等于预设时限T时,将所述DATA_Frame1,所述压缩计数字Count_byte的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站;在除所述当前数据帧为本轮压缩的第一帧,且本轮压缩的压缩耗时大于或等于预设时限T时以外的情况下,将所述DATA_Frame1,所述压缩计数字Count_byte以及所述变量段ΔDATA_Frame的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站。The second setting module is configured to set the DATA_Frame1, the compression count number Count_byte when the current data frame is the first frame of this round of compression, and the compression time of the current round of compression is greater than or equal to the preset time limit T The combination is sent as compressed data to the master station in the WAMS system for receiving the data sent by the data transmission device; except that the current data frame is the first frame of this round of compression, and the compression time of this round of compression If it is greater than or equal to the preset time limit T, the combination of the DATA_Frame1, the compression count number Count_byte and the variable segment ΔDATA_Frame is sent to the WAMS system as the compressed data for receiving the data sent by the sending device. data master.
可选的,所述数据发送设备至少包括:PDC单元和NIC单元中的一种。Optionally, the data sending device includes at least one of a PDC unit and a NIC unit.
可选的,所述第一接收模块,还用于:Optionally, the first receiving module is further configured to:
接收各个PMU单元发送的,依据配置帧将自身采集的线路数据生成的数据帧。Receive a data frame sent by each PMU unit and generate the line data collected by itself according to the configuration frame.
可选的,所述压缩模块,还用于:Optionally, the compression module is further used for:
D1:将当前数据帧中包含的相量数目n除以j,得到a组相量,和余数b个相量,且b小于j;D1: Divide the number n of phasors contained in the current data frame by j to obtain a group of phasors, and the remainder b phasors, and b is less than j;
D2:从a组相量中的第一组相量开始,将所述第一组向量作为当前组向量,针对当前组相量中的每一个相量,将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第一幅值变化量;将所述当前数据帧的每一个相量的角度与所述当前数据帧的前一数据帧的每一个对应相量的角度进行比较,得到第一角度变化量,根据所述第一幅值变化量和所述第一角度变化量生成第一变量标识;将所述第一幅值变化量和所述第一角度变化量合成为第一变量;D2: Starting from the first group of phasors in the a group of phasors, take the first group of vectors as the current group vector, and for each phasor in the current group of phasors, compare the amplitude of the phasor with the The amplitude of the corresponding phasor of the previous data frame of the current data frame is compared to obtain the first amplitude variation; the angle of each phasor of the current data frame is compared with the previous data of the current data frame. Comparing the angles of each corresponding phasor of the frame to obtain a first angle change, and generating a first variable identifier according to the first amplitude change and the first angle change; changing the first amplitude The amount and the first angle change amount are combined into a first variable;
D3:将所述当前组相量对应的第一变量标识存储到标识数组flag中;将所述第一变量存储到变量数组data中;然后将当前组相量的下一组相量作为当前组相量,并返回执行所述D2步骤,直至a组相量都被处理;D3: store the first variable flag corresponding to the current group of phasors in the flag array flag; store the first variable in the variable array data; then use the next group of phasors of the current group of phasors as the current group phasors, and return to perform the D2 step until the a group of phasors are processed;
D4:针对b个相量中的每一个相量,将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第二幅值变化量;将所述相量的角度与所述当前数据帧的前一数据帧的对应相量的角度进行比较,得到第二角度变化量;根据所述第二幅值变化量和所述第二角度变化量生成第二变量标识,将所述第二变量标识存储到标识数组flag中;将所述第二幅值变化量和所述第二角度变化量合成为第二变量;将所述第二变量存储到变量数组data中;D4: For each phasor in the b phasors, compare the amplitude of the phasor with the amplitude of the corresponding phasor of the previous data frame of the current data frame to obtain a second amplitude variation ; Compare the angle of the phasor with the angle of the corresponding phasor of the previous data frame of the current data frame to obtain a second angle change; According to the second amplitude change and the second angle The variation generates a second variable identification, and stores the second variable identification in the identification array flag; synthesizes the second amplitude variation and the second angle variation into a second variable; The variable is stored in the variable array data;
D5:将所述标识数组flag和所述变量数组data组成变量段ΔDATA_Frame。D5: Form the flag array flag and the variable array data into a variable segment ΔDATA_Frame.
可选的,压缩模块,还用于:Optionally, the compression module is also used to:
1)、设k为计数,初值为0,判断k是否小于j:1), let k be the count, the initial value is 0, and judge whether k is less than j:
2)、若是,将当前数据帧的每一个相量的幅值r1与所述当前数据帧的前一数据帧的每一个对应相量的幅值p1的差值H1作为第一幅值变化量;将当前数据帧的每一个相量的角度r2与所述当前数据帧的前一数据帧的每一个对应相量的角度p2的差值H2作为第一角度变化量;并判断H1和H2的绝对值是否均小于8;2) If yes, take the difference H1 between the amplitude r1 of each phasor of the current data frame and the amplitude p1 of each corresponding phasor of the previous data frame of the current data frame as the first amplitude variation ; The difference H2 of the angle r2 of each phasor of the current data frame and the angle p2 of each corresponding phasor of the previous data frame of the current data frame is used as the first angle variation; And judge H1 and H2 Whether the absolute value is less than 8;
3)、若H1和H2的绝对值均小于8,为H1和H2各分配0.5个字节的存储空间,更新第一变量标识sign[k]为0x00;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与8之和,并判断H2的值是否为负;若H1的值为正,判断H2的值是否为负,若H2的值为负,将H2的值更新为H2与8之和;将H1和H2存储到缓存数组one中;3) If the absolute values of H1 and H2 are both less than 8, allocate 0.5 bytes of storage space for each of H1 and H2, update the first variable sign [k] to 0x00; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 8, and determine whether the value of H2 is negative; if the value of H1 is positive, determine whether the value of H2 is negative, if the value of H2 is negative, change the value of H2 The value of is updated to the sum of H2 and 8; H1 and H2 are stored in the cache array one;
4)、若H1和H2的绝对值不是均小于8,判断H1和H2的绝对值是否均小于128;4) If the absolute values of H1 and H2 are not both less than 8, judge whether the absolute values of H1 and H2 are both less than 128;
5)、若H1和H2的绝对值均小于128,为H1和H2各分配1个字节的存储空间,更新第一变量标识sign[k]为0x01;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与128之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤,若H2的值为负,将H2的值更新为H2与128之和;将H1和H2存储到缓存数组two中;5) If the absolute values of H1 and H2 are both less than 128, allocate 1 byte of storage space for each of H1 and H2, update the first variable sign [k] to 0x01; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 128, and judge whether the value of H2 is negative; if the value of H1 is positive, execute the step of judging whether the value of H2 is negative, if the value of H2 is negative If it is negative, update the value of H2 to the sum of H2 and 128; store H1 and H2 into the cache array two;
6)、若H1和H2的绝对值不是均小于128,判断H1和H2的绝对值是否均小于2048;6) If the absolute values of H1 and H2 are not both less than 128, judge whether the absolute values of H1 and H2 are both less than 2048;
7)、若H1和H2的绝对值均小于2048,为H1和H2各分配1.5个字节的存储空间,更新第一变量标识sign[k]为0x02;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与2048之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤;若H2的值为负,将H2的值更新为H2与2048之和;将H1和H2存储到缓存数组three中;7), if the absolute values of H1 and H2 are both less than 2048, allocate 1.5 bytes of storage space for H1 and H2, update the first variable sign [k] to 0x02; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 2048, and judge whether the value of H2 is negative; if the value of H1 is positive, execute the step of judging whether the value of H2 is negative; if the value of H2 is negative If it is negative, update the value of H2 to the sum of H2 and 2048; store H1 and H2 into the cache array three;
8)、若H1和H2的绝对值不是均小于2048,更新第一变量标识sign[k]为=0x03,然后将r1,r2存储到缓存数组four中;8), if the absolute values of H1 and H2 are not both less than 2048, update the first variable sign sign[k] to = 0x03, and then store r1, r2 in the cache array four;
9)、将k的值更新为k+1,并返回执行所述步骤1);直至所述当前组向量中的每一个向量都被处理;9), update the value of k to k+1, and return to execute the step 1); until each vector in the current group of vectors is processed;
10)、当k的值大于或等于j时,执行所述D3步骤。10) When the value of k is greater than or equal to j, execute the step D3.
可选的,压缩模块,还用于:Optionally, the compression module is also used to:
将当前组相量中的每一个相量对应的第一变量标识存储到临时标识数组sign中,然后将当前组的各个相量对应的第一变量标识的集合存储到标识数组flag中。The first variable identifier corresponding to each phasor in the current group of phasors is stored in the temporary identifier array sign, and then the set of first variable identifiers corresponding to each phasor in the current group is stored in the identifier array flag.
可选的,所述预设步长为1。Optionally, the preset step size is 1.
可选的,所述预设字段为:0xAA63。Optionally, the preset field is: 0xAA63.
本发明实施例还提供了一种通信数据解压装置,应用于WAMS系统中接收数据发送设备所发送数据的主站,所述装置包括:An embodiment of the present invention also provides a communication data decompression device, which is applied to a master station in a WAMS system that receives data sent by a data sending device, and the device includes:
第二接收模块,用于接收所述数据发送设备发送的与所述数据帧集合对应的压缩后的数据帧;a second receiving module, configured to receive the compressed data frame corresponding to the data frame set sent by the data sending device;
第三判断模块,用于判断所述数据帧的SYNC字段是否为预设字段,若否,触发所述第二接收模块;若是,触发存储模块;a third judging module for judging whether the SYNC field of the data frame is a preset field, if not, triggering the second receiving module; if so, triggering a storage module;
存储模块,用于将压缩计数字Count_byte之后的L个字节的数据,顺序放入标识数组flag,将L个字节之后的数据放入变量数组data;The storage module is used to sequentially place the L bytes of data after the compression count number Count_byte into the flag array flag, and the data after the L bytes into the variable array data;
从所述标识数组flag中顺序取出j个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data;Sequentially take out j identifiers from the identifier array flag and put them into the array sign, and then sequentially read the data of the corresponding length in the variable array data according to the content of sign, and according to the data frame corresponding to the variable array data The phasor of the previous data frame is restored to the original phasor corresponding to the data read according to the sign content, and the original phasor is sequentially stored in the array Full_data;
解压模块,用于从所述标识数组flag中顺序取出b个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data;The decompression module is used to sequentially take out b identifiers from the identifier array flag and put them into the array sign, and then sequentially read the data of the corresponding length in the variable array data according to the content of the sign, and according to the variable array data The phasor of the previous data frame of the corresponding data frame restores the original phasor corresponding to the data read according to the sign content, and stores the original phasor in the array Full_data in sequence;
组合模块,用于根据配置帧和第一帧数据帧生成除相量以外的其他字段,将所生成的其他字段与数组Full_data中的数据组合生成完整数据帧。The combination module is used to generate other fields except phasors according to the configuration frame and the first frame data frame, and combine the generated other fields with the data in the array Full_data to generate a complete data frame.
可选的,所述装置还包括:第四判断模块,用于:Optionally, the device further includes: a fourth judgment module for:
判断得到的解压后的数据帧是否有错误或者漏发,如果是,向所述数据发送设备发送补发命令,以使所述数据发送设备调取相应错误或者漏发数据帧。Determine whether the obtained decompressed data frame has errors or missed sending, and if so, send a re-send command to the data sending device, so that the data sending device can retrieve the corresponding error or missed sending of the data frame.
本发明实施例还提供了一种通信数据压缩及解压系统,所述系统包括:The embodiment of the present invention also provides a communication data compression and decompression system, the system includes:
基于上述任一项所述的通信数据压缩装置,和基于上述任一项所述的通信数据解压装置。Based on the communication data compression device according to any one of the above, and based on the communication data decompression device according to any one of the above.
本发明相比现有技术具有以下优点:Compared with the prior art, the present invention has the following advantages:
应用本发明实施例,根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩,仅保留每一轮压缩中的第一帧数据帧,然后根据第一帧数据帧之后的数据帧中的相量的区别,进行数据压缩,相量之间的区别所占用的存储空间小于相量所占用的存储空间,因此可以减少数据帧对应的数据量,提高了单位容量的数据中含有的信息量,提高了信息发送效率。Applying the embodiment of the present invention, according to the difference between the phasor of the current data frame and the corresponding phasor of the previous data frame of the current data frame, variable compression is performed on the current data frame, and only the phasors in each round of compression are retained. The first frame of data frame, and then data compression is performed according to the difference between the phasors in the data frames after the first frame of data frame, and the storage space occupied by the difference between the phasors is smaller than that of the phasors, so The amount of data corresponding to the data frame is reduced, the amount of information contained in the data per unit capacity is increased, and the efficiency of information transmission is improved.
附图说明Description of drawings
图1为本发明实施例提供的一种通信数据压缩方法的流程示意图;1 is a schematic flowchart of a communication data compression method according to an embodiment of the present invention;
图2为本发明实施例提供的一种配电网WAMS系统的结构示意图;2 is a schematic structural diagram of a distribution network WAMS system provided by an embodiment of the present invention;
图3为本发明实施例提供的一种配电网WAMS系统的数据交换示意图;3 is a schematic diagram of data exchange of a WAMS system of a distribution network provided by an embodiment of the present invention;
图4为本发明实施例提供的一种通信数据压缩方法的原理示意图;FIG. 4 is a schematic diagram of the principle of a communication data compression method provided by an embodiment of the present invention;
图5为本发明实施例提供的一种通信数据压缩方法中变量标识的生成原理示意图;5 is a schematic diagram of a generation principle of a variable identifier in a communication data compression method provided by an embodiment of the present invention;
图6为本发明实施例提供的一种通信数据压缩方法所压缩后的数据的结构示意图;6 is a schematic structural diagram of data compressed by a communication data compression method according to an embodiment of the present invention;
图7为本发明实施例提供的一种通信数据解压方法的流程示意图;7 is a schematic flowchart of a method for decompressing communication data according to an embodiment of the present invention;
图8为本发明实施例提供的一种通信数据解压方法的原理示意图;FIG. 8 is a schematic diagram of the principle of a communication data decompression method provided by an embodiment of the present invention;
图9为本发明实施例提供的一种通信数据压缩装置的结构示意图;FIG. 9 is a schematic structural diagram of a communication data compression apparatus provided by an embodiment of the present invention;
图10为本发明实施例提供的一种通信数据解压装置的结构示意图;10 is a schematic structural diagram of a communication data decompression apparatus provided by an embodiment of the present invention;
图11为本发明实施例提供的一种通信数据压缩及解压系统的结构示意图。FIG. 11 is a schematic structural diagram of a communication data compression and decompression system according to an embodiment of the present invention.
具体实施方式Detailed ways
下面对本发明的实施例作详细说明,本实施例在以本发明技术方案为前提下进行实施,给出了详细的实施方式和具体的操作过程,但本发明的保护范围不限于下述的实施例。The embodiments of the present invention are described in detail below. This embodiment is implemented on the premise of the technical solution of the present invention, and provides a detailed implementation manner and a specific operation process, but the protection scope of the present invention is not limited to the following implementation. example.
为解决现有技术问题,本发明实施例提供了一种通信数据压缩、解压方法、装置及系统。In order to solve the problems of the prior art, the embodiments of the present invention provide a communication data compression and decompression method, device and system.
第一方面,下面首先就本发明实施例提供的一种通信数据压缩方法进行介绍。In the first aspect, the following first introduces a communication data compression method provided by an embodiment of the present invention.
首先说明的是,本发明实施例提供的一种通信数据压缩方法,优选适用于应用于配电网WAMS系统中向主站发送数据的数据发送设备,且所述数据发送设备至少包括:PDC单元和NIC单元中的一种。First of all, it should be noted that the communication data compression method provided by the embodiment of the present invention is preferably applicable to a data sending device that sends data to a master station in a WAMS system of a power distribution network, and the data sending device at least includes: a PDC unit and one of the NIC units.
图1为本发明实施例提供的一种通信数据压缩方法的流程示意图,如图1所示,所述方法包括:FIG. 1 is a schematic flowchart of a communication data compression method according to an embodiment of the present invention. As shown in FIG. 1 , the method includes:
S101:接收WAMS系统中的WAMS主站发送的配置帧,接收各个PMU单元发送的数据帧;将所述数据帧分割成至少两个数据帧集合,其中,所述配置帧中包含数据a和b。S101: Receive a configuration frame sent by a WAMS master station in a WAMS system, and receive a data frame sent by each PMU unit; divide the data frame into at least two data frame sets, wherein the configuration frame includes data a and b .
具体的,可以接收各个PMU单元发送的,依据配置帧将自身采集的线路数据生成的数据帧。Specifically, a data frame sent by each PMU unit and generated from line data collected by itself according to the configuration frame can be received.
示例性的,图2为本发明实施例提供的一种配电网WAMS系统的结构示意图;图3为本发明实施例提供的一种配电网WAMS系统的数据交换示意图;如图2-3所示,PDC设备通过以太网从PMU设备中获取数据帧,然后将数据帧压缩后,通过无线网络中的专用VPN将压缩后的数据帧发送至WAMS系统主站。在另外一种应用场景中,NIC设备从PMU设备中获取数据帧,然后将数据帧压缩后,通过无线网络中的专用VPN将压缩后的数据帧发送至WAMS系统主站。数据帧的具体传输步骤如图3所示,PMU设备每隔Jms向PDC设备或者NIC设备发送一次数据帧DATA,PDC设备或者NIC每隔N*Jms将N*Jms内接收的N个数据帧压缩后发送至WAMS系统主站,通常情况下,可将PDC设备或者NIC设备将N*Jms内接收的N个数据帧压缩的过程称为一轮压缩。Exemplarily, FIG. 2 is a schematic structural diagram of a distribution network WAMS system provided by an embodiment of the present invention; FIG. 3 is a data exchange schematic diagram of a distribution network WAMS system provided by an embodiment of the present invention; FIG. 2-3 As shown, the PDC device obtains the data frame from the PMU device through the Ethernet, and then compresses the data frame, and sends the compressed data frame to the WAMS system master station through the dedicated VPN in the wireless network. In another application scenario, the NIC device obtains the data frame from the PMU device, then compresses the data frame, and sends the compressed data frame to the WAMS system master station through the dedicated VPN in the wireless network. The specific transmission steps of the data frame are shown in Figure 3. The PMU device sends a data frame DATA to the PDC device or NIC device every Jms, and the PDC device or NIC compresses the N data frames received in N*Jms every N*Jms. Then, it is sent to the main station of the WAMS system. Usually, the process of compressing the N data frames received within N*Jms by the PDC device or the NIC device is called a round of compression.
示例性的,WAMS系统中的WAMS主站会将预先设置好的配置帧发送至各个数据发送设备,其中配置帧中包括每一数据帧中的每一个相量分组中包含的相量的数量a,以及该数据帧中未被分组的相量的数量b。例如,一个数据帧中包含了18个相量,a的值为4,即将每四个相量分成一组,然后得到四组相量。还剩余两个相量,这两个相量即为未被分组的b个相量。Exemplarily, the WAMS master station in the WAMS system will send a preset configuration frame to each data sending device, wherein the configuration frame includes the number a of phasors included in each phasor group in each data frame. , and the number b of ungrouped phasors in this data frame. For example, a data frame contains 18 phasors, the value of a is 4, that is, every four phasors are divided into one group, and then four groups of phasors are obtained. There are still two phasors remaining, which are the b phasors that are not grouped.
如果本步骤得到了3个数据帧集合,数据帧集合-1中包含的数据帧为帧-1-1、帧-1-2、帧-1-3、帧-1-4、帧-1-5、帧-1-6;数据帧集合-2中包含的数据帧为帧-2-1、帧-2-2、帧-2-3、帧-2-4、帧-2-5、帧-2-6;数据帧集合-3中包含的数据帧为帧-3-1、帧-3-2、帧-3-3、帧-3-4、帧-3-5、帧-3-6。If three data frame sets are obtained in this step, the data frames contained in data frame set-1 are frame-1-1, frame-1-2, frame-1-3, frame-1-4, frame-1- 5. Frame-1-6; the data frames included in the data frame set-2 are frame-2-1, frame-2-2, frame-2-3, frame-2-4, frame-2-5, frame -2-6; The data frames contained in the data frame set-3 are frame-3-1, frame-3-2, frame-3-3, frame-3-4, frame-3-5, frame-3- 6.
S102:针对每一个数据帧集合,将所述数据帧集合中的第一个数据帧作为当前数据帧,判断当前数据帧是否为本轮压缩的第一帧数据;若是,执行S103步骤;若否,执行S104步骤;S102: For each data frame set, use the first data frame in the data frame set as the current data frame, and determine whether the current data frame is the first frame data of this round of compression; if so, perform step S103; if not , and execute step S104;
由S101步骤可知,PDC设备或者NIC每隔N*Jms将N*Jms内接收的N个数据帧压缩后发送至WAMS系统主站,因此,需要判断PDC设备或者NIC设备所接收的当前帧,帧-1-1,是否为本轮压缩的第一帧数据,如果是第一帧数据,开始本轮压缩,执行S103步骤;如果不是本轮压缩的第一帧数据,执行S104步骤。It can be seen from step S101 that the PDC device or the NIC compresses the N data frames received in N*Jms every N*Jms and sends them to the WAMS system master station. Therefore, it is necessary to judge the current frame received by the PDC device or the NIC device. -1-1, whether it is the first frame of data compressed in this round, if it is the first frame of data, start this round of compression, and execute step S103; if it is not the first frame of data compressed in this round, execute step S104.
S103:将所述当前数据帧的SYNC字段的数值改为预设字段,并将压缩计数字Count_byte的值设置为0;将所述当前数据帧存储到缓存数组TEMP首端的DATA_Frame1段,判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,执行步骤S106,若本轮压缩的压缩耗时小于预设时限T,将所述当前数据帧的下一帧作为当前数据帧,并返回执行所述S102步骤。S103: Change the value of the SYNC field of the current data frame to a preset field, and set the value of the compression count number Count_byte to 0; store the current data frame in the DATA_Frame1 segment at the head end of the cache array TEMP, and determine the current round Whether the compression time of compression is greater than or equal to the preset time limit T; if the compression time of this round of compression is greater than or equal to the preset time limit T, perform step S106, if the compression time of this round of compression is less than the preset time limit T, all The next frame of the current data frame is regarded as the current data frame, and the step S102 is returned to be executed.
具体的,所述预设字段可以为:0xAA63。Specifically, the preset field may be: 0xAA63.
示例性的,以针对数据帧集合-1的压缩作为第一轮压缩。在现有的WAMS系统中,数据帧的字段数值是按照GBT26865.2-2011的规定执行,数据帧的SYNC字段数值为0xAA03,在本发明实施例中将每轮压缩通信的第一帧数据帧的SYNC改为0xAA63加以区分;同时,将本轮压缩的压缩计数字Count_byte的值设置为0,再将当前帧得到内容,帧-1-1,存储到缓存数组TEMP首端的DATA_Frame1段中。然后,将数据压缩单价从开始接收数据帧集合-1的时刻开始到当前时刻之间的时长作为本轮压缩的压缩耗时,然后判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,执行步骤S106,若本轮压缩的压缩耗时小于预设时限T,将0所述当前数据帧的下一帧,,帧-1-2,作为当前数据帧,并返回执行所述S102步骤。Exemplarily, the compression for data frame set-1 is taken as the first round of compression. In the existing WAMS system, the field value of the data frame is implemented in accordance with the provisions of GBT26865.2-2011, and the value of the SYNC field of the data frame is 0xAA03. In the embodiment of the present invention, the first frame of data frame of each round of compressed communication is SYNC is changed to 0xAA63 to distinguish it; at the same time, the value of the compression count number Count_byte of this round of compression is set to 0, and then the content of the current frame, frame-1-1, is stored in the DATA_Frame1 segment at the head of the cache array TEMP. Then, the duration of the unit price of data compression from the moment when the data frame set-1 is received to the current moment is taken as the compression time of this round of compression, and then it is judged whether the compression time of this round of compression is greater than or equal to the preset time limit T If the compression time-consuming of this round of compression is greater than or equal to the preset time limit T, step S106 is executed, if the compression time-consuming of this round of compression is less than the preset time limit T, the next frame of the current data frame described in 0, frame- 1-2, as the current data frame, and return to execute the step S102.
需要说明的是,SYNC字段也可以被称为同步字段。It should be noted that the SYNC field may also be referred to as a synchronization field.
S104:将压缩计数字Count_byte的当前值与预设步长之和作为所述压缩计数字的当前值;根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩得到变量段ΔDATA_Frame;S104: Use the sum of the current value of the compression count number Count_byte and the preset step size as the current value of the compression count number; according to the phasor of the current data frame and the corresponding phasor of the previous data frame of the current data frame The difference is that the variable segment ΔDATA_Frame is obtained by performing variable compression on the current data frame;
具体的,根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩得到变量段ΔDATA_Frame可以包括:D1:将当前数据帧中包含的相量数目n除以j,得到a组相量,和余数b个相量,且b小于j;D2:从a组相量中的第一组相量开始,针对当前组相量中的每一个相量,将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第一幅值变化量;将所述当前数据帧的每一个相量的角度与所述当前数据帧的前一数据帧的每一个对应相量的角度进行比较,得到第一角度变化量;D3:将所述当前组相量对应的第一变量标识存储到标识数组flag中;将所述第一变量存储到变量数组data中;然后将当前组相量的下一组相量作为当前组相量,并返回执行所述D2步骤,直至a组相量都被处理;D4:针对b个相量中的每一个相量,将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第二幅值变化量;将所述相量的角度与所述当前数据帧的前一数据帧的对应相量的角度进行比较,得到第二角度变化量;根据所述第二幅值变化量和所述第二角度变化量生成第二变量标识,将所述第二变量标识存储到标识数组flag中;将所述第二幅值变化量和所述第二角度变化量合成为第二变量;将所述第二变量存储到变量数组data中;D5将所述标识数组flag和所述变量数组data组成变量段ΔDATA_Frame。Specifically, according to the difference between the phasor of the current data frame and the corresponding phasor of the previous data frame of the current data frame, performing variable compression on the current data frame to obtain a variable segment ΔDATA_Frame may include: D1: compressing the current data frame The number of phasors contained in the frame is divided by j to obtain a group of phasors, and the remainder b phasors, and b is less than j; D2: Starting from the first group of phasors in the a group of phasors, for the current group of phasors For each phasor in the quantity, compare the magnitude of the phasor with the magnitude of the corresponding phasor of the previous data frame of the current data frame to obtain a first magnitude change; The angle of each phasor of the frame is compared with the angle of each corresponding phasor of the previous data frame of the current data frame to obtain the first angle change; D3: the first angle corresponding to the current group of phasors is compared. The variable identification is stored in the identification array flag; the first variable is stored in the variable array data; then the next group of phasors of the current group of phasors are used as the current group of phasors, and return to execute the D2 step, until a All groups of phasors are processed; D4: for each of the b phasors, compare the magnitude of the phasor with the magnitude of the corresponding phasor of the previous data frame of the current data frame, Obtain a second amplitude change; compare the angle of the phasor with the angle of the corresponding phasor of the previous data frame of the current data frame to obtain a second angle change; change according to the second amplitude The amount and the second angle change amount generate a second variable identification, and the second variable identification is stored in the identification array flag; the second amplitude change amount and the second angle change amount are synthesized into a second variable; store the second variable in the variable array data; D5 forms the variable segment ΔDATA_Frame with the flag array flag and the variable array data.
具体的,所述将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第一幅值变化量;将所述当前数据帧的每一个相量的角度与所述当前数据帧的前一数据帧的每一个对应相量的角度进行比较,得到第一角度变化量,根据所述第一幅值变化量和所述第一角度变化量生成第一变量标识,可以包括:1)、设k为计数,初值为0,判断k是否小于j:2)、若是,将当前数据帧的每一个相量的幅值r1与所述当前数据帧的前一数据帧的每一个对应相量的幅值p1的差值H1作为第一幅值变化量;将当前数据帧的每一个相量的角度r2与所述当前数据帧的前一数据帧的每一个对应相量的角度p2的差值H2作为第一角度变化量;并判断H1和H2的绝对值是否均小于8;3)、若H1和H2的绝对值均小于8,为H1和H2各分配0.5个字节的存储空间,更新第一变量标识sign[k]为0x00;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与8之和,并判断H2的值是否为负;若H1的值为正,判断H2的值是否为负,若H2的值为负,将H2的值更新为H2与8之和;将H1和H2存储到缓存数组one中;4)、若H1和H2的绝对值不是均小于8,判断H1和H2的绝对值是否均小于128;5)、若H1和H2的绝对值均小于128,为H1和H2各分配1个字节的存储空间,更新第一变量标识sign[k]为0x01;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与128之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤,若H2的值为负,将H2的值更新为H2与128之和;将H1和H2存储到缓存数组two中;6)、若H1和H2的绝对值不是均小于128,判断H1和H2的绝对值是否均小于2048;7)、若H1和H2的绝对值均小于2048,为H1和H2各分配1.5个字节的存储空间,更新第一变量标识sign[k]为0x02;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与2048之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤;若H2的值为负,将H2的值更新为H2与2048之和;将H1和H2存储到缓存数组three中;8)、若H1和H2的绝对值不是均小于2048,更新第一变量标识sign[k]为=0x03,然后将r1,r2存储到缓存数组four中;9)、将k的值更新为k+1,并返回执行所述步骤1);直至所述当前组向量中的每一个向量都被处理;10)、当k的值大于或等于j时,执行所述D3步骤。Specifically, comparing the amplitude of the phasor with the amplitude of the corresponding phasor of the previous data frame of the current data frame to obtain a first amplitude change; The angle of a phasor is compared with the angle of each corresponding phasor in the previous data frame of the current data frame to obtain a first angle change, according to the first amplitude change and the first angle change Quantity generates the first variable identification, which can include: 1), set k as a count, the initial value is 0, and determine whether k is less than j: 2), if so, compare the amplitude r1 of each phasor of the current data frame with the described The difference H1 of the amplitude p1 of each corresponding phasor of the previous data frame of the current data frame is taken as the first amplitude variation; the angle r2 of each phasor of the current data frame and the The difference H2 of the angle p2 of each corresponding phasor of a data frame is used as the first angle change; and it is judged whether the absolute values of H1 and H2 are both less than 8; 3), if the absolute values of H1 and H2 are both less than 8, Allocate 0.5 bytes of storage space for H1 and H2, update the first variable sign sign[k] to 0x00; determine whether the value of H1 is negative, if the value of H1 is negative, update the value of H1 to H1 and 8 sum, and judge whether the value of H2 is negative; if the value of H1 is positive, judge whether the value of H2 is negative, if the value of H2 is negative, update the value of H2 to the sum of H2 and 8; change the value of H1 and H2 Store it in the cache array one; 4) If the absolute values of H1 and H2 are not both less than 8, judge whether the absolute values of H1 and H2 are both less than 128; 5) If the absolute values of H1 and H2 are both less than 128, it is H1 and H2 each allocate 1 byte of storage space, update the first variable sign sign[k] to 0x01; judge whether the value of H1 is negative, if the value of H1 is negative, update the value of H1 to the sum of H1 and 128 , and judge whether the value of H2 is negative; if the value of H1 is positive, execute the step of judging whether the value of H2 is negative, if the value of H2 is negative, update the value of H2 to the sum of H2 and 128; H1 and H2 are stored in the cache array two; 6), if the absolute values of H1 and H2 are not both less than 128, judge whether the absolute values of H1 and H2 are both less than 2048; 7), if the absolute values of H1 and H2 are both less than 2048 , allocate 1.5 bytes of storage space for H1 and H2, update the first variable sign sign[k] to 0x02; judge whether the value of H1 is negative, if the value of H1 is negative, update the value of H1 to H1 and 2048, and judge whether the value of H2 is negative; if the value of H1 is positive, execute the step of judging whether the value of H2 is negative; if the value of H2 is negative, update the value of H2 to the value between H2 and 2048 and; store H1 and H2 in the cache array three; 8), if the absolute values of H1 and H2 are not both less than 2048, update the first variable sign sign[k] = 0x03, and then store r1, r2 in the cache array four; 9), update the value of k to k+1, and Return to execute the step 1); until each vector in the current group of vectors is processed; 10), when the value of k is greater than or equal to j, execute the D3 step.
具体的,可以所述将所述当前组相量对应的第一变量标识存储到标识数组flag中,可以包括:将当前组相量中的每一个相量对应的第一变量标识存储到临时标识数组sign中,然后将当前组的各个相量对应的第一变量标识的集合存储到标识数组flag中。Specifically, storing the first variable identifier corresponding to the current group of phasors in the flag array flag may include: storing the first variable identifier corresponding to each phasor in the current group of phasors in a temporary identifier In the array sign, the set of first variable identifiers corresponding to each phasor of the current group is then stored in the identifier array flag.
图4为本发明实施例提供的一种通信数据压缩方法的原理示意图,如图4所示,如果当前数据帧中包括的相量的数量为18,且a为4,b为2,则将当前数据帧中包含的18个相量按照顺序分为4组。设i为计数量,代表已经处理了多少组的相量,例如i=0时,开始对第一组相量中的四个相量进行变量压缩,然后在进行每一组相量的压缩时,设j为计数量,j代表已经处理的当前组相量中的多少个相量。FIG. 4 is a schematic diagram of the principle of a communication data compression method provided by an embodiment of the present invention. As shown in FIG. 4 , if the number of phasors included in the current data frame is 18, and a is 4 and b is 2, then The 18 phasors contained in the current data frame are divided into 4 groups in order. Let i be the number of counts, representing how many groups of phasors have been processed. For example, when i=0, start to perform variable compression on the four phasors in the first group of phasors, and then compress each group of phasors. , let j be the number of counts, and j represents how many phasors in the current group of phasors have been processed.
第一组中的各个相量的编号为相量-1-1、相量-1-2、相量-1-3、相量-1-4;类似的,第二组中的各个相量的编号为相量-2-1、相量-2-2、相量-2-3、相量-2-4;第三组中的各个相量的编号为相量-3-1、相量-3-2、相量-3-3、相量-3-4;第四组中的各个相量的编号为相量-4-1、相量-4-2、相量-4-3、相量-4-4;剩余的两个相量可以为相量-b-1、相量-b-2。Each phasor in the first group is numbered phasor-1-1, phasor-1-2, phasor-1-3, phasor-1-4; similarly, each phasor in the second group The numbers of the phasors are phasor-2-1, phasor-2-2, phasor-2-3, phasor-2-4; the numbers of each phasor in the third group are phasor-3-1, phasor-2-4 Quantity-3-2, phasor-3-3, phasor-3-4; the number of each phasor in the fourth group is phasor-4-1, phasor-4-2, phasor-4- 3. Phasor-4-4; the remaining two phasors can be phasor-b-1 and phasor-b-2.
先对第一组相量中的第一个相量进行变量压缩,将相量-1-1的幅值与,帧-1-1对应位置的幅值进行比较,例如可以求差得出帧-1-2的第一组相量中的相量-1-1,与帧-1-1的第一组相量中的相量-1-1之间的幅值的差,将该差作为第一幅值变化量;然后,将相量-1-1的角度与,帧-1-1对应位置的角度进行比较,例如可以求差得出帧-1-2的第一组相量中的相量-1-1,与帧-1-1的第一组相量中的相量-1-1之间的角度的差,将该差作为第一角度变化量。First, perform variable compression on the first phasor in the first group of phasors, and compare the amplitude of phasor-1-1 with the amplitude of the corresponding position of frame-1-1. For example, the difference can be calculated to obtain the frame. The difference in magnitude between the phasor -1-1 in the first set of phasors of -1-2, and the phasor -1-1 in the first set of phasors of frame -1-1, the difference As the first amplitude change; then, compare the angle of the phasor-1-1 with the angle of the corresponding position of the frame-1-1, for example, the first group of phasors of the frame-1-2 can be obtained by calculating the difference The angle difference between the phasor-1-1 in the frame-1-1 and the phasor-1-1 in the first group of phasors of the frame-1-1 is taken as the first angle change amount.
然后将数据帧-1-2的第一组向量中的向量-1-1作为当前相量,根据当前相量的第一角度变化量和第一幅值变化量生成第一变量标识。Then, the vector-1-1 in the first set of vectors of the data frame-1-2 is used as the current phasor, and the first variable identifier is generated according to the first angle change and the first amplitude change of the current phasor.
图5为本发明实施例提供的一种通信数据压缩方法中变量标识的生成原理示意图,如图5所示,过程可以为:设k为计数量,k的值小于j,即小于4。首先判断k是否小于4,若不小于4,说明在对第一组的各个向量进行第一变量标识的生成过程已经结束,需要将第一组中的各个相量的第一变量标识组合起来,进而进行存储。当k的值大于或等于j时,根据第一幅值变化量和所述第一角度变化量生成第一变量标识,将第一变量标识存储到标识数组flag中;将第一幅值变化量和所述第一角度变化量合成为第一变量;将第一变量存储到变量数组data中;将标识数组flag和所述变量数组data组成变量段ΔDATA_Frame。5 is a schematic diagram of the generation principle of a variable identifier in a communication data compression method provided by an embodiment of the present invention, as shown in FIG. First, judge whether k is less than 4. If it is not less than 4, it means that the process of generating the first variable identification for each vector of the first group has ended, and it is necessary to combine the first variable identification of each phasor in the first group. to be stored. When the value of k is greater than or equal to j, a first variable identifier is generated according to the first amplitude variation and the first angle variation, and the first variable identifier is stored in the identifier array flag; the first amplitude variation is and the first angle change amount is combined into a first variable; the first variable is stored in the variable array data; the flag array flag and the variable array data are formed into a variable segment ΔDATA_Frame.
当k小于4时,说明需要生成第一组中的相量的第一变量标识。例如,将数据帧-1-2的相量-1-1的幅值r1与所述数据帧-1-2的数据帧-1-1的对应相量,相量-1-1的幅值p1的差值H1作为幅值变化量;将数据帧-1-2的相量-1-1的角度r2与所述数据帧-1-2的数据帧-1-1的对应相量,相量-1-1的角度p2的差值H2作为角度变化量;并判断H1和H2的绝对值是否均小于8。When k is less than 4, it indicates that the first variable identifier of the phasor in the first group needs to be generated. For example, compare the magnitude r1 of the phasor-1-1 of the data frame-1-2 with the corresponding phasor of the data frame-1-1 of the data frame-1-2, the magnitude of the phasor-1-1 The difference H1 of p1 is used as the magnitude change; the angle r2 of the phasor-1-1 of the data frame-1-2 and the corresponding phasor of the data frame-1-1 of the data frame-1-2 are compared with each other. The difference H2 of the angle p2 of the quantity -1-1 is used as the angle change amount; and it is judged whether the absolute values of H1 and H2 are both less than 8.
若H1和H2的绝对值均小于8,为H1和H2各分配0.5个字节的存储空间,更新第一变量标识sign[k]为0x00;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与8之和,并判断H2的值是否为负;若H1的值为正,判断H2的值是否为负,若H2的值为负,将H2的值更新为H2与8之和;将H1和H2存储到缓存数组one中。If the absolute values of H1 and H2 are both less than 8, allocate 0.5 bytes of storage space for each of H1 and H2, update the first variable sign sign[k] to 0x00; judge whether the value of H1 is negative, if the value of H1 is Negative, update the value of H1 to the sum of H1 and 8, and determine whether the value of H2 is negative; if the value of H1 is positive, determine whether the value of H2 is negative, if the value of H2 is negative, update the value of H2 is the sum of H2 and 8; store H1 and H2 into the cache array one.
若H1和H2的绝对值不是均小于8,判断H1和H2的绝对值是否均小于128;若H1和H2的绝对值均小于128,为H1和H2各分配1个字节的存储空间,更新第一变量标识sign[k]为0x01;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与128之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤,若H2的值为负,将H2的值更新为H2与128之和;将H1和H2存储到缓存数组two中。If the absolute values of H1 and H2 are not both less than 8, judge whether the absolute values of H1 and H2 are both less than 128; if the absolute values of H1 and H2 are both less than 128, allocate 1 byte of storage space for each of H1 and H2, and update The first variable identifier sign[k] is 0x01; determine whether the value of H1 is negative, if the value of H1 is negative, update the value of H1 to the sum of H1 and 128, and determine whether the value of H2 is negative; if the value of H1 is negative If the value is positive, execute the step of judging whether the value of H2 is negative. If the value of H2 is negative, update the value of H2 to the sum of H2 and 128; store H1 and H2 in the cache array two.
若H1和H2的绝对值不是均小于128,判断H1和H2的绝对值是否均小于2048;若H1和H2的绝对值均小于2048,为H1和H2各分配1.5个字节的存储空间,更新第一变量标识sign[k]为0x02;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与2048之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤;若H2的值为负,将H2的值更新为H2与2048之和;将H1和H2存储到缓存数组three中。If the absolute values of H1 and H2 are not both less than 128, judge whether the absolute values of H1 and H2 are both less than 2048; if the absolute values of H1 and H2 are both less than 2048, allocate 1.5 bytes of storage space for each of H1 and H2, and update The first variable identifier sign[k] is 0x02; determine whether the value of H1 is negative, if the value of H1 is negative, update the value of H1 to the sum of H1 and 2048, and determine whether the value of H2 is negative; if the value of H1 is negative If the value is positive, execute the step of judging whether the value of H2 is negative; if the value of H2 is negative, update the value of H2 to the sum of H2 and 2048; store H1 and H2 in the cache array three.
若H1和H2的绝对值不是均小于2048,更新第一变量标识sign[k]为=0x03,然后将r1,r2存储到缓存数组four中;将k的值更新为k+1,并数据帧-1-2的第一组向量中的向量-1-2作为当前相量,进而生成当前相量对应的第一标识。同时,将向量-1-1的缓存数组one、或者缓存数组two、或者缓存数组three中的数据顺序存储到变量数组data中;将sign[k]存储到标识数组flag中。针对当前数据帧,数据帧-1-2中的第一组向量中的每一个向量进行上述处理,进而对,数据帧-1-2中的每一组向量进行上述处理,进而处理完a组相量。最后得到的标识数组flag中顺序存储,数据帧-1-2的第一组相量中的四个向量的第一变量标识、第二组相量中的四个向量的第一变量标识、第三组相量中的四个向量的第一变量标识、第四组相量中的四个向量的第一变量标识。变量数据data中的变量的存储顺序与标识数组flag中的第一变量标识的存储顺序相同,这里不再赘述。If the absolute values of H1 and H2 are not both less than 2048, update the first variable sign sign[k] to = 0x03, then store r1 and r2 in the cache array four; update the value of k to k+1, and the data frame The vector -1-2 in the first set of vectors of -1-2 is used as the current phasor, and then the first identifier corresponding to the current phasor is generated. At the same time, store the data in the cache array one of the vector-1-1, or the cache array two, or the cache array three in sequence into the variable array data; store sign[k] into the flag array flag. For the current data frame, each vector in the first group of vectors in the data frame-1-2 is subjected to the above processing, and further, the above processing is performed on each group of vectors in the data frame-1-2, and then the a group is processed. Phasor. The finally obtained identification array flag is sequentially stored, the first variable identification of the four vectors in the first group of phasors of the data frame-1-2, the first variable identification of the four vectors in the second group of phasors, the first variable identification of the four vectors in the second group of phasors The first variable identifiers of the four vectors in the three groups of phasors and the first variable identifiers of the four vectors in the fourth group of phasors. The storage order of the variables in the variable data data is the same as the storage order of the first variable identifier in the identifier array flag, which is not repeated here.
在处理完a组向量后,需要对剩余的2个向量进行处理,在处理过程中生成第二变量标识与生成a组向量中的第一变量标识的过程相同;在处理过程中生成第二变量的过程与生成a组向量中的第一变量的过程相同,这里不再赘述。After processing a group of vectors, the remaining 2 vectors need to be processed, and the process of generating the second variable identifier in the processing process is the same as the process of generating the first variable identifier in the a group vector; The process of is the same as the process of generating the first variable in the a group of vectors, and will not be repeated here.
然后将数据帧-1-2对应的变量数组data,和标识数组flag组合成数据帧-1-2的变量段ΔDATA_Frame2。Then, the variable array data corresponding to the data frame-1-2 and the flag array flag are combined into a variable segment ΔDATA_Frame2 of the data frame-1-2.
需要说明的是,在进行第一变量标识的存储时,以缓存数组one为例,在实际存储过程中,不存在半个字节的内容,为了节省空间,需要将缓存数组one的数据与其它的数据拼接在一起填满一个字节,因此,在本发明实施例中需要有一个字节缓存数组one的0.5个字节的数据,类似的,缓存数组three被分配了三个字节用于存储缓存数组的1.5个字节的数据,其对应的存储空间为three[0]、three[1]、three[2]。It should be noted that when storing the first variable identifier, taking the cache array one as an example, in the actual storage process, there is no half-byte content. In order to save space, the data of the cache array one needs to be compared with other The data are spliced together to fill one byte. Therefore, in this embodiment of the present invention, there needs to be 0.5 bytes of data in the byte cache array one. Similarly, the cache array three is allocated three bytes for Stores 1.5 bytes of data in the cache array, and its corresponding storage space is three[0], three[1], three[2].
S105:根据所述压缩计数字Count_byte判断本轮压缩所压缩的数据帧是否达到压缩上限;若本轮压缩所压缩的数据帧达到压缩上限,执行步骤S106;若本轮压缩所压缩的数据帧未达到压缩上限,判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,执行步骤S106,若本轮压缩的压缩耗时小于预设时限T,将所述当前数据帧的下一帧作为当前数据帧,返回执行所述步骤S102。S105: Determine whether the data frame compressed in this round of compression reaches the upper limit of compression according to the compression count number Count_byte; if the data frame compressed in this round of compression reaches the upper limit of compression, perform step S106; if the data frame compressed in this round of compression does not reach the upper limit of compression Reaching the upper limit of compression, determine whether the compression time of this round of compression is greater than or equal to the preset time limit T; if the compression time of this round of compression is greater than or equal to the preset time limit T, perform step S106, if the compression time of this round of compression is less than or equal to the preset time limit T Preset time limit T, take the next frame of the current data frame as the current data frame, and return to execute the step S102.
示例性的,在对数据帧-1-2进行变量压缩后,判断在对数据帧集合-1的压缩过程中所压缩的数据帧的数量是否达到了,可以压缩的数据帧的数量的上限,如果达到上限,停止压缩进程,然后执行S106步骤。Exemplarily, after the variable compression is performed on the data frame-1-2, it is determined whether the number of data frames compressed during the compression of the data frame set-1 has reached the upper limit of the number of data frames that can be compressed, If the upper limit is reached, the compression process is stopped, and then step S106 is performed.
若未达到上限,判断针对数据帧集合-1进行压缩对应的压缩耗时,是否达到了预设时限T,若达到了预设时限T,执行S106步骤;若未达到预设时限T,将数据帧集合-1中数据帧-1-2的下一个数据帧,数据帧-1-30作为当前帧,然后返回执行S102步骤,直至所有的数据帧集合中的数据帧都被压缩。If the upper limit is not reached, it is determined whether the compression time corresponding to the compression of the data frame set-1 has reached the preset time limit T, and if the preset time limit T is reached, step S106 is performed; if the preset time limit T is not reached, the data The next data frame of the data frame-1-2 in the frame set-1, the data frame-1-30 is regarded as the current frame, and then returns to step S102 until all the data frames in the data frame set are compressed.
S106:在所述当前数据帧为本轮压缩的第一帧,且本轮压缩的压缩耗时大于或等于预设时限T时,将所述DATA_Frame1,所述压缩计数字Count_byte的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站;在除所述当前数据帧为本轮压缩的第一帧,且本轮压缩的压缩耗时大于或等于预设时限T时以外的情况下,将所述DATA_Frame1,所述压缩计数字Count_byte以及所述变量段ΔDATA_Frame的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站。S106: When the current data frame is the first frame of this round of compression, and the compression time of the current round of compression is greater than or equal to the preset time limit T, use the combination of the DATA_Frame1 and the compression count number Count_byte as the compressed The data is sent to the master station in the WAMS system for receiving the data sent by the data sending device; except that the current data frame is the first frame of this round of compression, and the compression time of this round of compression is greater than or equal to the preset In cases other than the time limit T, the combination of the DATA_Frame1, the compression count number Count_byte and the variable segment ΔDATA_Frame is sent as compressed data to the master station in the WAMS system for receiving the data sent by the data sending device .
图6为本发明实施例提供的一种通信数据压缩方法所压缩后的数据的结构示意图;如图6所示,对于本轮压缩而言,DATA_Frame1用于存储本轮压缩的第一帧数据,即数据帧-1-1;FIG. 6 is a schematic structural diagram of data compressed by a communication data compression method according to an embodiment of the present invention; as shown in FIG. 6 , for the current round of compression, DATA_Frame1 is used to store the first frame data of the current round of compression, i.e. dataframe-1-1;
压缩计数字Count_byte,用于存储每一轮压缩中包含的数据帧的数量;ΔDATA_Frame2,用于存储本轮压缩过程中的数据帧-1-2的被压缩后的数据,即对应的第一变量以及第一变量标识;依次类推。Compression count number Count_byte, used to store the number of data frames included in each round of compression; ΔDATA_Frame2, used to store the compressed data of data frame-1-2 in the current round of compression, that is, the corresponding first variable and the first variable identifier; and so on.
需要说明的是,以ΔDATA_Frame2为例,在进行数据帧-1-2的变量段组合时,可以将数据帧-1-2的第一变量标识数组flag存储在ΔDATA_Frame2的前半部分,然后依次存储各个相量的第一变量:PHASORS1、PHASORS2、PHASORS3,依此类推。It should be noted that, taking ΔDATA_Frame2 as an example, when combining variable segments of data frame-1-2, the first variable identification array flag of data frame-1-2 can be stored in the first half of ΔDATA_Frame2, and then each The first variable of a phasor: PHASORS1, PHASORS2, PHASORS3, and so on.
应用本发明图1所示实施例,根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩,仅保留每一轮压缩中的第一帧数据帧,然后根据第一帧数据帧之后的数据帧中的相量的区别,进行数据压缩,相量之间的区别所占用的存储空间小于相量所占用的存储空间,提高了单位容量的数据中含有的信息量,提高了信息发送效率Applying the embodiment shown in FIG. 1 of the present invention, according to the difference between the phasor of the current data frame and the corresponding phasor of the previous data frame of the current data frame, variable compression is performed on the current data frame, and only each The first frame of data frame in round compression, and then data compression is performed according to the difference between the phasors in the data frames after the first frame of data frame, and the storage space occupied by the difference between the phasors is smaller than the storage space occupied by the phasors space, increase the amount of information contained in the data per unit capacity, and improve the efficiency of information transmission
另外,应用本发明图1所示实施例,还可以将数据及时的发送出去,避免数据的积压。In addition, by applying the embodiment shown in FIG. 1 of the present invention, data can also be sent out in time to avoid data backlog.
第二方面,与本发明图1所示实施例相对应,本发明实施例还提供了一种通信数据解压方法。In the second aspect, corresponding to the embodiment shown in FIG. 1 of the present invention, the embodiment of the present invention further provides a communication data decompression method.
需要说明的是,本发明实施例提供的一种通信数据解压方法,优选适用于应用于WAMS系统中接收数据发送设备所发送数据的主站。It should be noted that the communication data decompression method provided by the embodiment of the present invention is preferably applied to a master station in a WAMS system that receives data sent by a data sending device.
图7为本发明实施例提供的一种通信数据解压方法的流程示意图,图8为本发明实施例提供的一种通信数据解压方法的原理示意图;如图7和图8所示,所述方法包括:7 is a schematic flowchart of a communication data decompression method provided by an embodiment of the present invention, and FIG. 8 is a schematic schematic diagram of a principle of a communication data decompression method provided by an embodiment of the present invention; as shown in FIGS. 7 and 8 , the method include:
S701:接收所述数据发送设备发送的与所述数据帧集合对应的压缩后的数据帧。S701: Receive a compressed data frame corresponding to the data frame set sent by the data sending device.
示例性的,接收的压缩后的数据如图6所示。Exemplarily, the received compressed data is shown in FIG. 6 .
S702:判断所述数据帧的SYNC字段是否为预设字段,若否,返回执行所述S701步骤;若是,执行S703步骤。S702: Determine whether the SYNC field of the data frame is a preset field, and if not, return to performing the step S701; if so, perform the step S703.
判断接收的数据的SYNC字段是否为0xAA63,若是,说明接收的数据是按照本发明实施例所述方法进行压缩后的数据,执行S703步骤;若否,说明接收的数据不是按照本发明实施例所述方法进行压缩后的数据,跳出循环,进行下一轮数据的接收。Determine whether the SYNC field of the received data is 0xAA63, and if so, it indicates that the received data is data compressed according to the method described in the embodiment of the present invention, and executes step S703; if not, it indicates that the received data is not according to the embodiment of the present invention. The method described above performs the compressed data, jumps out of the loop, and receives the next round of data.
S703:将压缩计数字Count_byte之后的L个字节的数据,顺序放入标识数组flag,将L个字节之后的数据放入变量数组data;S703: Put the data of L bytes after the compression count number Count_byte into the flag array flag in sequence, and put the data after the L bytes into the variable array data;
示例性的,将接收的数据帧的Count_byte之后的L个字节的数据作为变量标识存储到标识数组flag中。该数据帧的后续的数据作为变量数据存储到变量数组data中。Exemplarily, data of L bytes after the Count_byte of the received data frame is stored as a variable flag in the flag array flag. The subsequent data of the data frame is stored in the variable array data as variable data.
可以理解的是,L的大小是系统预先设定的,其值可以为a+1。It can be understood that the size of L is preset by the system, and its value can be a+1.
S704:从所述标识数组flag中顺序取出j个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data。S704: sequentially take out j identifiers from the identifier array flag and put them in the array sign, then sequentially read the data of the corresponding length in the variable array data according to the content of sign, and according to the data corresponding to the variable array data From the phasor of the previous data frame of the frame, the original phasor corresponding to the data read according to the sign content is restored, and the original phasor is sequentially stored in the array Full_data.
示例性的,从标识数组flag中顺序取出4个标识放入数组sign中,然后顺序读取变量数组data中对应长度的数据。Exemplarily, 4 identifiers are sequentially taken from the identifier array flag and put into the array sign, and then the data of the corresponding length in the variable array data is sequentially read.
根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data。可以理解的是,还原原始相量的过程与本发明实施例中S104步骤的变量压缩过程为对偶过程,本发明实施例不再对其进行赘述。According to the phasor of the previous data frame of the data frame corresponding to the variable array data, the original phasor corresponding to the data read according to the content of sign is restored, and the original phasor is sequentially stored in the array Full_data. It can be understood that the process of restoring the original phasor and the variable compression process in step S104 in the embodiment of the present invention are dual processes, which are not repeated in the embodiment of the present invention.
S705:从所述标识数组flag中顺序取出b个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data。S705: Sequentially take out b identifiers from the identifier array flag and put them in the array sign, and then sequentially read the data of the corresponding length in the variable array data according to the contents of sign, and according to the data corresponding to the variable array data From the phasor of the previous data frame of the frame, the original phasor corresponding to the data read according to the sign content is restored, and the original phasor is sequentially stored in the array Full_data.
示例性的,从所述标识数组flag中顺序取出2个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data,即存放在S704步骤还原出的原始相量的后面。另外,可以理解的是,a、b的大小均为WAMS系统中的主站向数据发送设备发送的配置帧中包含的数据。Exemplarily, sequentially take out 2 signs from the sign array flag and put them in the array sign, then read the data of the corresponding length in the variable array data sequentially according to the sign content, and according to the corresponding length of the variable array data The phasor of the previous data frame of the data frame, restore the original phasor corresponding to the data read according to the content of sign, and store the original phasor into the array Full_data in sequence, that is, store the original phasor restored in the step S704 The back of the phasor. In addition, it can be understood that the sizes of a and b are both data included in the configuration frame sent by the master station in the WAMS system to the data sending device.
S706:根据配置帧和第一帧数据帧生成除相量以外的其他字段,将所生成的其他字段与数组Full_data中的数据组合生成完整数据帧。S706: Generate other fields except the phasor according to the configuration frame and the first frame data frame, and combine the generated other fields with the data in the array Full_data to generate a complete data frame.
需要强调的是,本步骤对应的过程为现有技术,本发明实施例不在对其进行赘述。It should be emphasized that the process corresponding to this step is in the prior art, which is not repeated in this embodiment of the present invention.
应用本发明图7所示实施例,可以对压缩后的数据进行解压。By applying the embodiment shown in FIG. 7 of the present invention, the compressed data can be decompressed.
在本发明实施例的一种具体实施方式中,所述方法还包括:In a specific implementation of the embodiment of the present invention, the method further includes:
S707(图中未示出):判断得到的解压后的数据帧是否有错误或者漏发,如果是,向所述数据发送设备发送补发命令,以使所述数据发送设备调取相应错误或者漏发数据帧。S707 (not shown in the figure): determine whether the obtained decompressed data frame has errors or is missing, and if so, send a reissue command to the data sending device, so that the data sending device calls the corresponding error or Missing data frame.
示例性的,WAMS主站判断解压后的数据帧是否有错误,例如,可以判断数据帧对应的值是否明显超出合理的范围,或者明显出现了未检测的数据项目,或者数据项目之间的数据发生了颠倒等;或者根据预设的数据帧的标识信息,判断接收的数据帧的数据是否与预设的标识信息相匹配,如果是,说明数据帧发生了漏发现象,然后,向数据发送设备发送补发命令,例如,可以根据发生错误的或者漏发的数据帧的标识信息,将补发指令发送给对应的数据发送设备。Exemplarily, the WAMS master station determines whether there is an error in the decompressed data frame, for example, it can determine whether the value corresponding to the data frame is obviously beyond a reasonable range, or there are obviously undetected data items, or data between data items. Reversal occurred, etc.; or according to the preset identification information of the data frame, determine whether the data of the received data frame matches the preset identification information, if so, it means that the data frame has been missed, and then send the data to the data frame. When the device sends a reissue command, for example, it can send a reissue instruction to the corresponding data sending device according to the identification information of the data frame that has an error or missed sending.
应用本发明上述实施例,可以避免数据错误或者漏发导致的数据报错。By applying the above embodiments of the present invention, data errors caused by data errors or missing transmissions can be avoided.
第三方面,与本发明实施例第一方面相对应,本发明实施例还提供了一种通信数据压缩装置,应用于配电网WAMS系统中向主站发送数据的数据发送设备。In the third aspect, corresponding to the first aspect of the embodiment of the present invention, the embodiment of the present invention further provides a communication data compression device, which is applied to a data sending device for sending data to a master station in a WAMS system of a power distribution network.
图9为本发明实施例提供的一种通信数据压缩装置的结构示意图,如图9所示,所述装置包括:FIG. 9 is a schematic structural diagram of a communication data compression apparatus according to an embodiment of the present invention. As shown in FIG. 9 , the apparatus includes:
第一接收模块901,用于接收WAMS系统中的WAMS主站发送的配置帧,接收各个PMU单元发送的数据帧;将所述数据帧分割成至少两个数据帧集合;The
第一判断模块902,用于针对每一个数据帧集合,将所述数据帧集合中的第一个数据帧作为当前数据帧,判断当前数据帧是否为本轮压缩的第一帧数据;The
第一设置模块903,用于在所述第一判断模块902的判断结果为是的情况下,将所述当前数据帧的SYNC字段的数值改为预设字段,并将压缩计数字Count_byte的值设置为0;将所述当前数据帧存储到缓存数组TEMP首端的DATA_Frame1段,判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,触发第二设置模块905,若本轮压缩的压缩耗时小于预设时限T,将所述当前数据帧的下一帧作为当前数据帧,并触发第一判断模块902;The
压缩模块904,用于在所述第一判断模块902的判断结果为否的情况下,将压缩计数字Count_byte的当前值与预设步长之和作为所述压缩计数字的当前值;根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩得到变量段ΔDATA_Frame;The
第二判断模块905,用于根据所述压缩计数字Count_byte判断本轮压缩所压缩的数据帧是否达到压缩上限;若本轮压缩所压缩的数据帧达到压缩上限,执行步骤F;若本轮压缩所压缩的数据帧未达到压缩上限,判断本轮压缩的压缩耗时是否大于或等于预设时限T;若本轮压缩的压缩耗时大于或等于预设时限T,触发第二设置模块,若本轮压缩的压缩耗时小于预设时限T,将所述当前数据帧的下一帧作为当前数据帧,触发所述第一判断模块902;The
第二设置模块906,用于在所述当前数据帧为本轮压缩的第一帧,且本轮压缩的压缩耗时大于或等于预设时限T时,将所述DATA_Frame1,所述压缩计数字Count_byte的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站;在除所述当前数据帧为本轮压缩的第一帧,且本轮压缩的压缩耗时大于或等于预设时限T时以外的情况下,将所述DATA_Frame1,所述压缩计数字Count_byte以及所述变量段ΔDATA_Frame的组合作为压缩后的数据发送至WAMS系统中用于接收数据发送设备所发送的数据的主站。The
应用本发明图9所示实施例,根据所述当前数据帧的相量与所述当前数据帧的前一数据帧对应相量的区别,对所述当前数据帧进行变量压缩,仅保留每一轮压缩中的第一帧数据帧,然后根据第一帧数据帧之后的数据帧中的相量的区别,进行数据压缩,相量之间的区别所占用的存储空间小于相量所占用的存储空间,提高了单位容量的数据中含有的信息量,提高了信息发送效率。Applying the embodiment shown in FIG. 9 of the present invention, according to the difference between the phasor of the current data frame and the corresponding phasor of the previous data frame of the current data frame, variable compression is performed on the current data frame, and only each The first frame of data frame in round compression, and then data compression is performed according to the difference between the phasors in the data frames after the first frame of data frame, and the storage space occupied by the difference between the phasors is smaller than the storage space occupied by the phasors space, increase the amount of information contained in the data per unit capacity, and improve the efficiency of information transmission.
在本发明实施例的一种具体实施方式中,所述数据发送设备至少包括:PDC单元和NIC单元中的一种。In a specific implementation manner of the embodiment of the present invention, the data sending device includes at least one of a PDC unit and a NIC unit.
在本发明实施例的一种具体实施方式中,所述第一接收模块901,还用于:In a specific implementation manner of the embodiment of the present invention, the
接收各个PMU单元发送的,依据配置帧将自身采集的线路数据生成的数据帧。Receive a data frame sent by each PMU unit and generate the line data collected by itself according to the configuration frame.
在本发明实施例的一种具体实施方式中,所述压缩模块904,还用于:In a specific implementation manner of the embodiment of the present invention, the
D1:将当前数据帧中包含的相量数目n除以j,得到a组相量,和余数b个相量,且b小于j;D1: Divide the number n of phasors contained in the current data frame by j to obtain a group of phasors, and the remainder b phasors, and b is less than j;
D2:从a组相量中的第一组相量开始,将所述第一组向量作为当前组向量,针对当前组相量中的每一个相量,将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第一幅值变化量;将所述当前数据帧的每一个相量的角度与所述当前数据帧的前一数据帧的每一个对应相量的角度进行比较,得到第一角度变化量;D2: Starting from the first group of phasors in the a group of phasors, take the first group of vectors as the current group vector, and for each phasor in the current group of phasors, compare the amplitude of the phasor with the The amplitude of the corresponding phasor of the previous data frame of the current data frame is compared to obtain the first amplitude variation; the angle of each phasor of the current data frame is compared with the previous data of the current data frame. The angles of each corresponding phasor of the frame are compared to obtain the first angle change;
D3:将所述当前组相量对应的第一变量标识存储到标识数组flag中;将所述第一变量存储到变量数组data中;然后将当前组相量的下一组相量作为当前组相量,并返回执行所述D2步骤,直至a组相量都被处理;D3: store the first variable flag corresponding to the current group of phasors in the flag array flag; store the first variable in the variable array data; then use the next group of phasors of the current group of phasors as the current group phasors, and return to perform the D2 step until the a group of phasors are processed;
D4:针对b个相量中的每一个相量,将所述相量的幅值与所述当前数据帧的前一数据帧的对应相量的幅值进行比较,得到第二幅值变化量;将所述相量的角度与所述当前数据帧的前一数据帧的对应相量的角度进行比较,得到第二角度变化量;根据所述第二幅值变化量和所述第二角度变化量生成第二变量标识,将所述第二变量标识存储到标识数组flag中;将所述第二幅值变化量和所述第二角度变化量合成为第二变量;将所述第二变量存储到变量数组data中;D4: For each phasor in the b phasors, compare the amplitude of the phasor with the amplitude of the corresponding phasor of the previous data frame of the current data frame to obtain a second amplitude variation ; Compare the angle of the phasor with the angle of the corresponding phasor of the previous data frame of the current data frame to obtain a second angle change; According to the second amplitude change and the second angle The variation generates a second variable identification, and stores the second variable identification in the identification array flag; synthesizes the second amplitude variation and the second angle variation into a second variable; The variable is stored in the variable array data;
D5将所述标识数组flag和所述变量数组data组成变量段ΔDATA_Frame。D5 composes the flag array flag and the variable array data into a variable segment ΔDATA_Frame.
在本发明实施例的一种具体实施方式中,压缩模块904,还用于:In a specific implementation manner of the embodiment of the present invention, the
1)、设k为计数,初值为0,判断k是否小于j:1), let k be the count, the initial value is 0, and judge whether k is less than j:
2)、若是,将当前数据帧的每一个相量的幅值r1与所述当前数据帧的前一数据帧的每一个对应相量的幅值p1的差值H1作为第一幅值变化量;将当前数据帧的每一个相量的角度r2与所述当前数据帧的前一数据帧的每一个对应相量的角度p2的差值H2作为第一角度变化量;并判断H1和H2的绝对值是否均小于8;2) If yes, take the difference H1 between the amplitude r1 of each phasor of the current data frame and the amplitude p1 of each corresponding phasor of the previous data frame of the current data frame as the first amplitude variation ; The difference H2 of the angle r2 of each phasor of the current data frame and the angle p2 of each corresponding phasor of the previous data frame of the current data frame is used as the first angle variation; And judge H1 and H2 Whether the absolute value is less than 8;
3)、若H1和H2的绝对值均小于8,为H1和H2各分配0.5个字节的存储空间,更新第一变量标识sign[k]为0x00;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与8之和,并判断H2的值是否为负;若H1的值为正,判断H2的值是否为负,若H2的值为负,将H2的值更新为H2与8之和;将H1和H2存储到缓存数组one中;3) If the absolute values of H1 and H2 are both less than 8, allocate 0.5 bytes of storage space for each of H1 and H2, update the first variable sign [k] to 0x00; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 8, and determine whether the value of H2 is negative; if the value of H1 is positive, determine whether the value of H2 is negative, if the value of H2 is negative, change the value of H2 The value of is updated to the sum of H2 and 8; H1 and H2 are stored in the cache array one;
4)、若H1和H2的绝对值不是均小于8,判断H1和H2的绝对值是否均小于128;4) If the absolute values of H1 and H2 are not both less than 8, judge whether the absolute values of H1 and H2 are both less than 128;
5)、若H1和H2的绝对值均小于128,为H1和H2各分配1个字节的存储空间,更新第一变量标识sign[k]为0x01;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与128之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤,若H2的值为负,将H2的值更新为H2与128之和;将H1和H2存储到缓存数组two中;5) If the absolute values of H1 and H2 are both less than 128, allocate 1 byte of storage space for each of H1 and H2, update the first variable sign [k] to 0x01; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 128, and judge whether the value of H2 is negative; if the value of H1 is positive, execute the step of judging whether the value of H2 is negative, if the value of H2 is negative If it is negative, update the value of H2 to the sum of H2 and 128; store H1 and H2 into the cache array two;
6)、若H1和H2的绝对值不是均小于128,判断H1和H2的绝对值是否均小于2048;6) If the absolute values of H1 and H2 are not both less than 128, judge whether the absolute values of H1 and H2 are both less than 2048;
7)、若H1和H2的绝对值均小于2048,为H1和H2各分配1.5个字节的存储空间,更新第一变量标识sign[k]为0x02;判断H1的值是否为负,若H1的值为负,将H1的值更新为H1与2048之和,并判断H2的值是否为负;若H1的值为正,执行所述判断H2的值是否为负的步骤;若H2的值为负,将H2的值更新为H2与2048之和;将H1和H2存储到缓存数组three中;7), if the absolute values of H1 and H2 are both less than 2048, allocate 1.5 bytes of storage space for H1 and H2, update the first variable sign [k] to 0x02; judge whether the value of H1 is negative, if H1 If the value of H1 is negative, update the value of H1 to the sum of H1 and 2048, and judge whether the value of H2 is negative; if the value of H1 is positive, execute the step of judging whether the value of H2 is negative; if the value of H2 is negative If it is negative, update the value of H2 to the sum of H2 and 2048; store H1 and H2 into the cache array three;
8)、若H1和H2的绝对值不是均小于2048,更新第一变量标识sign[k]为=0x03,然后将r1,r2存储到缓存数组four中;8), if the absolute values of H1 and H2 are not both less than 2048, update the first variable sign sign[k] to = 0x03, and then store r1, r2 in the cache array four;
9)、将k的值更新为k+1,并返回执行所述步骤1);直至所述当前组向量中的每一个向量都被处理;9), update the value of k to k+1, and return to execute the step 1); until each vector in the current group of vectors is processed;
10)、当k的值大于或等于j时,执行所述D3步骤。10) When the value of k is greater than or equal to j, execute the step D3.
在本发明实施例的一种具体实施方式中,压缩模块904,还用于:In a specific implementation manner of the embodiment of the present invention, the
将当前组相量中的每一个相量对应的第一变量标识存储到临时标识数组sign中,然后将当前组的各个相量对应的第一变量标识的集合存储到标识数组flag中。The first variable identifier corresponding to each phasor in the current group of phasors is stored in the temporary identifier array sign, and then the set of first variable identifiers corresponding to each phasor in the current group is stored in the identifier array flag.
在本发明实施例的一种具体实施方式中,所述预设步长为1。In a specific implementation manner of the embodiment of the present invention, the preset step size is 1.
在本发明实施例的一种具体实施方式中,所述预设字段为:0xAA63。In a specific implementation manner of the embodiment of the present invention, the preset field is: 0xAA63.
第四方面,与本发明实施例第二方面相对应,本发明实施例还提供了一种通信数据解压装置。In the fourth aspect, corresponding to the second aspect of the embodiment of the present invention, the embodiment of the present invention further provides a communication data decompression device.
需要说明的是,本发明实施例提供的一种通信数据解压装置,优选适用于WAMS系统中接收数据发送设备所发送数据的主站。It should be noted that the apparatus for decompressing communication data provided by the embodiment of the present invention is preferably applicable to a master station in a WAMS system that receives data sent by a data sending device.
图10为本发明实施例提供的一种通信数据解压装置的结构示意图,如图10所示,所述装置包括:FIG. 10 is a schematic structural diagram of an apparatus for decompressing communication data according to an embodiment of the present invention. As shown in FIG. 10 , the apparatus includes:
第二接收模块1001,用于接收所述数据发送设备发送的与所述数据帧集合对应的压缩后的数据帧;A
第三判断模块1002,用于判断所述数据帧的SYNC字段是否为预设字段,若否,触发所述第二接收模块1001;若是,触发存储模块1003;The
存储模块1003,用于将压缩计数字Count_byte之后的L个字节的数据,顺序放入标识数组flag,将L个字节之后的数据放入变量数组data;The
从所述标识数组flag中顺序取出j个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data;Sequentially take out j identifiers from the identifier array flag and put them into the array sign, and then sequentially read the data of the corresponding length in the variable array data according to the content of sign, and according to the data frame corresponding to the variable array data The phasor of the previous data frame is restored to the original phasor corresponding to the data read according to the sign content, and the original phasor is sequentially stored in the array Full_data;
解压模块1004,用于从所述标识数组flag中顺序取出b个标识放入数组sign中,然后依照sign内容,顺序读取所述变量数组data中对应长度的数据,并根据与所述变量数组data对应的数据帧的前一数据帧的相量,还原出与依照sign内容读取的数据所对应的原始相量,将所述原始相量顺序存放入数组Full_data;The
组合模块1005,用于根据配置帧和第一帧数据帧生成除相量以外的其他字段,将所生成的其他字段与数组Full_data中的数据组合生成完整数据帧。The
应用本发明图10所示实施例,可以对压缩后的数据进行解压。By applying the embodiment shown in FIG. 10 of the present invention, the compressed data can be decompressed.
在本发明实施例的一种具体实施方式中,在本发明图10所示实施例的基础上,本发明实施例还增加了:第四判断模块1006(图中未示出),用于:In a specific implementation of the embodiment of the present invention, on the basis of the embodiment shown in FIG. 10 of the present invention, the embodiment of the present invention further adds: a fourth judgment module 1006 (not shown in the figure), which is used for:
判断得到的解压后的数据帧是否有错误或者漏发,如果是,向所述数据发送设备发送补发命令,以使所述数据发送设备调取相应错误或者漏发数据帧。Determine whether the obtained decompressed data frame has errors or missed sending, and if so, send a re-send command to the data sending device, so that the data sending device can retrieve the corresponding error or missed sending of the data frame.
在本发明实施例的一种具体实施方式中,所述系统包括:In a specific implementation of the embodiment of the present invention, the system includes:
基于本发明实施例第三方面提供的通信数据压缩装置,和本发明第四方面提供的通信数据解压装置。Based on the communication data compression apparatus provided by the third aspect of the embodiments of the present invention, and the communication data decompression apparatus provided by the fourth aspect of the present invention.
应用本发明上述实施例,可以避免数据错误或者漏发导致的数据报错。By applying the above embodiments of the present invention, data errors caused by data errors or missing transmissions can be avoided.
第五方面,为解决现有技术问题,本发明实施例还提供了一种通信数据压缩及解压系统。In a fifth aspect, in order to solve the problem of the prior art, the embodiment of the present invention further provides a communication data compression and decompression system.
图11为本发明实施例提供的一种通信数据压缩及解压系统的结构示意图。,如图11所示,所述系统包括:FIG. 11 is a schematic structural diagram of a communication data compression and decompression system according to an embodiment of the present invention. , as shown in Figure 11, the system includes:
基于本发明实施例第三方面所述的通信数据压缩装置1101,和基于本发明实施例第四方面所述的通信数据解压装置1102。Based on the communication
应用本发明图11所示实施例,可以对通信数据进行压缩和解压。By applying the embodiment shown in FIG. 11 of the present invention, the communication data can be compressed and decompressed.
第六方面,为解决现有技术问题,与本发明实施例第五方面提供的一种通信数据压缩及解压系统相对应,本发明实施例还提供了一种通信方法,应用于WAMS系统,方法包括:In the sixth aspect, in order to solve the problem of the prior art, corresponding to the communication data compression and decompression system provided in the fifth aspect of the embodiment of the present invention, the embodiment of the present invention further provides a communication method, which is applied to the WAMS system. include:
应用本发明实施例第一方面所述的数据压缩方法进行数据压缩并将压缩后的数据发送出去;接收压缩后的数据,并应用本发明实施例第二方面所述的数据解压方法进行数据的解压。Apply the data compression method described in the first aspect of the embodiment of the present invention to perform data compression and send the compressed data; receive the compressed data, and apply the data decompression method described in the second aspect of the embodiment of the present invention to decompress the data. unzip.
应用本发明上述实施例,可以实现数据的压缩和解压。By applying the above embodiments of the present invention, data compression and decompression can be realized.
可以理解的是,压缩和解压共同构成整个通讯过程。It is understood that compression and decompression together constitute the entire communication process.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included in the protection of the present invention. within the range.
Claims (21)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811057233.XA CN109067775B (en) | 2018-09-11 | 2018-09-11 | A communication data compression and decompression method, device and system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811057233.XA CN109067775B (en) | 2018-09-11 | 2018-09-11 | A communication data compression and decompression method, device and system |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN109067775A CN109067775A (en) | 2018-12-21 |
| CN109067775B true CN109067775B (en) | 2020-12-08 |
Family
ID=64760111
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201811057233.XA Active CN109067775B (en) | 2018-09-11 | 2018-09-11 | A communication data compression and decompression method, device and system |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN109067775B (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109936373B (en) * | 2019-02-28 | 2023-05-02 | 北京交通大学 | A real-time data compression method for synchrophasor data measurement |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101178424A (en) * | 2007-12-12 | 2008-05-14 | 北京四方继保自动化股份有限公司 | Dynamic data compression storage method in electric network wide-area measuring systems (WAMS) |
| CN102811062A (en) * | 2010-01-19 | 2012-12-05 | 北京四方继保自动化股份有限公司 | Curve sparse processing method for high-density time sequence data in power system wide-area measurement system (WAMS) |
| CN102970340A (en) * | 2012-10-30 | 2013-03-13 | 清华大学 | Real-time data compression communication method applicable to wide area measurement system |
| WO2017070087A1 (en) * | 2015-10-21 | 2017-04-27 | GE Lighting Solutions, LLC | System and method for data compression over a communication network |
| CN108233344A (en) * | 2018-01-29 | 2018-06-29 | 合肥工业大学 | Power distribution network WAMS communications protections and feeder automation method based on multicast |
-
2018
- 2018-09-11 CN CN201811057233.XA patent/CN109067775B/en active Active
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101178424A (en) * | 2007-12-12 | 2008-05-14 | 北京四方继保自动化股份有限公司 | Dynamic data compression storage method in electric network wide-area measuring systems (WAMS) |
| CN102811062A (en) * | 2010-01-19 | 2012-12-05 | 北京四方继保自动化股份有限公司 | Curve sparse processing method for high-density time sequence data in power system wide-area measurement system (WAMS) |
| CN102970340A (en) * | 2012-10-30 | 2013-03-13 | 清华大学 | Real-time data compression communication method applicable to wide area measurement system |
| WO2017070087A1 (en) * | 2015-10-21 | 2017-04-27 | GE Lighting Solutions, LLC | System and method for data compression over a communication network |
| CN108141244A (en) * | 2015-10-21 | 2018-06-08 | 通用电气照明解决方案有限责任公司 | For passing through the system and method for the data compression of communication network |
| CN108233344A (en) * | 2018-01-29 | 2018-06-29 | 合肥工业大学 | Power distribution network WAMS communications protections and feeder automation method based on multicast |
Non-Patent Citations (2)
| Title |
|---|
| Application of a Real-Time Data Compression and Adapted Protocol Technique for WAMS;Fang Zhang等;《IEEE Transactions on Power Systems》;20140701;第30卷(第2期);全文 * |
| 广域测量系统数据在线无损压缩算法;齐文斌;《电网技术》;20080420;全文 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109067775A (en) | 2018-12-21 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN104065545B (en) | RS485 bus communication methods based on Modbus agreements and the power electronic system based on the means of communication | |
| CN105791431B (en) | An online distributed monitoring video processing task scheduling method and device | |
| CN102761540A (en) | Data compression method, device and system and server | |
| CN102520227B (en) | A Data Compression Method for Fault Recording Based on Disturbance Indicator | |
| CN108833058B (en) | A method for dynamic data compression and decompression in communication process of wide area measurement system | |
| CN101827302A (en) | Multi-service unified processing method and unified service platform | |
| CN104378439A (en) | System and method for achieving real-time transmission of transformer substation device information based on shared memory | |
| CN103633742B (en) | Realize the means of communication of synchronous on-line analysis during fault recorder data transmission | |
| CN109067775B (en) | A communication data compression and decompression method, device and system | |
| CN111669372B (en) | Internet of things protocol fusion method for electricity acquisition master station | |
| CN103545933B (en) | I0 interface communication method in intelligent substation on-line monitoring system station | |
| CN107526657A (en) | A kind of Online Database Backup method and system | |
| CN103457748A (en) | Data transmission method, system and device | |
| CN120017736A (en) | A power equipment data acquisition and processing system and method | |
| CN109525370A (en) | Data packet sending method based on zigbee | |
| CN202978988U (en) | Power failure alarm system and power failure alarm device | |
| CN114666406A (en) | Object model-based power internet of things data compression method and device | |
| CN102882926B (en) | Remote data transmission system and method for gas turbine sensor | |
| CN111447229B (en) | Large-scale data acquisition method and device based on compressed sensing theory | |
| CN112419698B (en) | Electric energy meter data transmission method, system and device based on distribution line message specification | |
| CN114885373A (en) | Node data uploading method, device, equipment and storage medium | |
| CN114401147A (en) | A new energy power station communication message comparison method and system based on digest algorithm | |
| CN106844574A (en) | A kind of synchronous method and apparatus of teledata | |
| CN114184890A (en) | A kind of multi-interval wave recording data transmission method, system, device and storage medium | |
| CN108805741B (en) | A method, device and system for fusion of power quality data |
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 |