Summary of the invention
In view of this, the embodiment of the invention provides a kind of method of data processing and terminal device, to solve existing skill
The agreement based on IEC104 is developed in art every time to require respectively to realize a set of acquisition, resolution logic, and the coupling of service logic
Conjunction leads to not be multiplexed and extend and message parsing method does not carry out regular, design, causes to be easy when packet parsing
Mistake, and the problem of checking is not easy after malfunctioning.
The first aspect of the embodiment of the present invention provides a kind of method of data processing, comprising:
Receive message;
According to preset packet parsing chain, piecewise analytic is carried out to the message, the data after being parsed;
The data are subjected to data grouping and are stored.
In one embodiment, the preset packet parsing chain includes at least one analytic thread subclass, and the basis is default
Packet parsing chain, piecewise analytic, data after being parsed are carried out to the message, comprising:
A, byte to be resolved in the corresponding message of analytic thread subclass is determined;
B, according to the analytic thread subclass, corresponding byte to be resolved is parsed;
Circulation executes step A and B, until completing to the packet parsing, the data after being parsed.
It is in one embodiment, described that the data are subjected to data grouping and are stored, comprising:
According to the data after parsing, long-range number transmitted in the Iec104 agreement that the data use is obtained;
The data are stored with corresponding long-range number for index.
It is in one embodiment, described that the data are subjected to data grouping and are stored, comprising:
According to the data after parsing, inquiry obtains the service attribute of the data in the service attribute table prestored
, at least a pair of of data and corresponding service attribute name are saved in the service attribute table;
The data are stored with the entitled index of the service attribute.
In one embodiment, it is described will the data carry out data grouping and store after, further includes:
According to the service attribute name of the data, the corresponding data of the data are inquired in the service attribute table
Value, is arranged the data value of the data, and at least a pair of of service attribute name and corresponding data value are saved in the service attribute table.
In one embodiment, after the data value of the setting data, further includes:
According to the data value of the data, the data are handled according to corresponding service logic.
In one embodiment, the data after parsing correspond to different points, and each point binds an analyzer;
It is described that the data are handled according to corresponding service logic, comprising:
The corresponding all analyzers of data that storage is arranged are binary tree structure;
Each analyzer in the binary tree structure is traversed by the way of inorder traversal.
The second aspect of the embodiment of the present invention provides a kind of device of data processing, comprising:
Receiving module, for receiving message;
Parsing module, for piecewise analytic being carried out to the message, after being parsed according to preset packet parsing chain
Data;
Memory module, for the data to be carried out data grouping and are stored.
The third aspect of the embodiment of the present invention provides a kind of terminal device, comprising: memory, processor and is stored in
In the memory and the computer program that can run on the processor, when the processor executes the computer program
It realizes such as the step of above-mentioned data processing the method.
The fourth aspect of the embodiment of the present invention provides a kind of computer readable storage medium, comprising: the computer can
It reads storage medium and is stored with computer program, which is characterized in that realize when the computer program is executed by processor as above-mentioned
The step of data processing the method.
Existing beneficial effect is the embodiment of the present invention compared with prior art: by receiving message;According to preset report
Literary analytic thread carries out piecewise analytic to the message, the data after being parsed;The data are subjected to data grouping and are deposited
Storage provides the good design of a set of message acquisition based on IEC104 agreement, packet parsing, data processing and data storage,
Allow by IEC104 acquisition message, analytic message and data processing carry out good decoupling, be more convenient for multiplexing, extension and
Maintenance.
Specific embodiment
In being described below, for illustration and not for limitation, the tool of such as particular system structure, technology etc is proposed
Body details, to understand thoroughly the embodiment of the present invention.However, it will be clear to one skilled in the art that there is no these specific
The present invention also may be implemented in the other embodiments of details.In other situations, it omits to well-known system, device, electricity
The detailed description of road and method, in case unnecessary details interferes description of the invention.
In order to illustrate technical solutions according to the invention, the following is a description of specific embodiments.
The embodiment of the present invention provides a kind of method of data processing, as shown in Figure 1, method includes the following steps:
Step 101, message is received.
Optionally, the IEC-104 agreement main website based on asynchronous non-obstruction is constructed in the present embodiment, and complete set is provided
Implementation method.It is asynchronous with synchronize be relative concept, synchronize be issue a call instruction when, before not obtaining result, should
The result of calling would not return, and return once calling, just obtain return value.And it is asynchronous, it is on the contrary, call instruction is being sent out
After out, this calling is just directly returned, so not returning the result, i.e., after an asynchronous procedure call issues, is called
Person will not be instantly obtained as a result, but after calling and issuing, callee is notified caller, or is passed through by state, notice
Call back function handles this calling.After call result obtains, result can be sent by way of readjustment.Non- obstruction with obstruction is
Relative concept, obstruction and non-obstruction are concerned with state of the program when waiting call result (message or return value).Obstruction is adjusted
With before referring to that call result returns, current thread can be suspended, and call thread that can just return only after obtaining result.It is non-
Obstruction, which calls, to be referred to before result is not immediately available, which will not block current thread.
Optionally, client object receives message, and client object can be IEC-104Client.IEC-104Client
Realize the start and stop of the IEC-104 agreement main website program based on asynchronous non-obstruction, the beginning of all behaviors of program.
Step 102, according to preset packet parsing chain, piecewise analytic is carried out to the message, the data after being parsed.
Optionally, packet parsing chain is designed using chain-of-responsibilpattern pattern, several solutions for constituting packet parsing chain may be implemented
Analyse chain subclass, be used for piecewise analytic message, as shown in Fig. 2, packet parsing chain include: Chain01_Start starting symbol,
The subsequent length of Chain02_Length, Chain03_Ctrl control domain, Chain03b_Package_SS frame, Chain03c_
The variable knot of Package_UU frame, Chain03a_Package_II frame, Chain04_Type type, Chain05_Changeable
Structure determiner, Chain06_Reason transmit reason, the site Chain07_FTUAddressFTU, Chain08_DataParse number
According to the analytic threads subclass such as body.
Optionally, each analytic thread subclass in packet parsing chain can parse several bytes in message.To message
Parsed the following steps are included:
A, byte to be resolved in the corresponding message of analytic thread subclass is determined;
B, according to the analytic thread subclass, corresponding byte to be resolved is parsed;
Circulation executes step A and B, until completing to the packet parsing, the data after being parsed.
Optionally, such as according to first analytic thread subclass of packet parsing chain, first analytic thread subclass is determined
N to be resolved in the corresponding message1A byte, the N1More than or equal to 1;According to first analytic thread subclass, parsing
The N1A byte;
For another example, according to the second of packet parsing chain analytic thread subclass, determine that second analytic thread subclass is corresponding
N to be resolved in the message2A byte, the N2More than or equal to 1;According to first analytic thread subclass, the N is parsed2
A byte;According to all analytic thread subclasses of packet parsing chain, all bytes of the message are successively parsed, after being parsed
Data.
The process of packet parsing is exemplified below.The message received uses hexadecimal representation, can be with are as follows: 68 1c
00 00 00 00 01 8f 14 00 33 00 01 02 00;01 00 01 00 01 00 01 00 01 00 01 00 01
00 01。
Chain01_Start parsing starting 1 byte of symbol, that is, parse 68, and perform the next step automatically.
Chain02_length parses subsequent length, i.e. parsing 1c, and it is 28 that 1c, which is converted to the decimal system, indicates parsing subsequent 28
A byte, and perform the next step automatically.
Chain03_Ctrl parses 4 bytes, that is, parses 00 00 00 00.Judge the data frame whether I frame, if the number
It is I frame according to frame, then is performed the next step automatically according to I frame trend.
Optionally, I frame is information frame, is used for user data transmission, includes information field.S frame is supervisory frame, for monitoring
With control data link, functions, the S frames such as the reception of completion I frame confirms, retransmits request, pause transmission is requested do not have information field.
U frame is unnumbered frames, can be issued at the time of any need for the control of data link without number, without influencing band
The exchange sequence of the information frame of number.
Chain04_Type parses a byte, that is, parses 01, indicates that type of message is single-point telemetering, then automatic to execute
In next step.
Chain05_Changeable parses a byte, i.e. parsing 8f, and being scaled binary system is 10001111, the company of expression
Continue 15 telemetries.
Chain06_Reason parses 2 bytes, that is, parses 14 00, and being scaled the decimal system is 20, indicates that message transmission is former
Because respective stations are called.
Chain07_FTUAddress parses 2 bytes, that is, parses 33 00, and being scaled the decimal system is 51, indicates the station FTU
Location is 51.
Chain07_DataParse parses 3 bytes, that is, parses 01 02 00, indicates data volume initial address: 0201H.
01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 indicate Information element Data, i.e., 15 distant
The value of letter data.15 remote signalling datas obtained after parsing are as follows:
Index=0201H, value=01H&0x01=1;
Index=0202H, value=00H&0x01=0;
……
Index=020dH, value=01H&0x01=1;
Index=020eH, value=00H&0x01=0;
Index=020fH, value=01H&0x01=1.
The present embodiment designs the parsing for realizing message by using chain-of-responsibilpattern pattern, so that packet parsing process is apparent,
Do not allow error-prone.
Step 103, the data are subjected to data grouping and stored.
As an embodiment, this step may include: and obtain according to the data after parsing and transmit the number
According to long-range number in the Iec104 agreement of use;The data are stored with corresponding long-range number for index.After parsing
Data flow enters point, and point, that is, Iec104Pointer assists the data in point according to the Iec104 that the data use is transmitted
Long-range number deposit point table in view, i.e. point table are a set with the point that long-range number is index.By data according to long-range number
Grouping, the data after grouping enter Iec104Table group point table " interface.
The unique ability and characteristic of point include: reference and the index for holding affiliated Iec104Entity;It saves and obtains
Data value;Obtain a data value;Each point, which binds an analyzer, can execute binding after data value is swept in point acquisition
Analyzer.
As another embodiment, this step may include: according to the data after parsing, in the business category
Property table in inquire the corresponding data value of the data, at least a pair of of data and corresponding business category are saved in the service attribute table
Property name.
Data are grouped according to service attribute name, the data after grouping enter Iec104Entity, entity " interface.
The unique ability and characteristic of Iec104Entity, entity " interface include: to inherit Map interface, are a dynamic object interfaces;It holds
Have one with " service attribute name " be index point set;Data value is obtained according to attribute-name, data are obtained according to attribute-name
Value.
Further, it after this step can also include: the service attribute name according to the data, will enter
Iec104Entity is into entity " data of interface inquire the data value for obtaining the data in service attribute table;And according to
The service attribute name of the data, is arranged the data value of the data.At least one is saved in the service attribute table
To service attribute name and corresponding data value.It should be understood that saved in service attribute table several pairs of data, service attribute name and
Corresponding record as data value.
Optionally, when needing to be implemented business, data value is arranged in data, then according to data value by data according to data
It is worth corresponding service logic and business processing is carried out to data.
Optionally, after data have data value, so that it may execute the analyzer of binding, i.e. execution Iec104Parse is to divide
Parser " interface, Iec104Parse is with analyzer " unique ability of interface and characteristic include: that analyzer is set as binary tree knot
Structure is executed with the sequence of inorder traversal;Preposition analyzer and postposition analyzer are set;Obtain first analysis in inorder traversal sequence
Device leaf node;Obtain end analyzer leaf node in inorder traversal sequence;Most common abstract base class is
BaseIec104Parse。
Optionally, according to Iec104Parsea analyzer " characteristic of interface, according to the data value of the data, to described
Data are handled according to corresponding service logic.
It optionally, can also include: that the corresponding all analyzers of data stored are arranged to be after this step
Binary tree structure;Each analyzer in the binary tree structure is traversed by the way of inorder traversal.
Optionally, analyzer is also used to decouple the system business logic unrelated with acquisition.When data acquisition return after and industry
Business is decoupling, and data can carry out different parsings by analyzer, it is also assumed that being the analyzer of data configuration, in this way
Same data can produce different data parsing and polymerization by different analyzers, realize desired business demand.It is right
System business logic has the irrelevant logic depending in analyzer.
The mode and data flow link design, data for present embodiments providing data storage are returned from packet parsing to data
Collection, storage all provide external calling interface, so that the development and application of IEC104 agreement main website is more regular, stability is strong.
The embodiment of the present invention provides a kind of method of data processing, including receives message;According to preset packet parsing chain,
Piecewise analytic is carried out to the message, the data after being parsed;The data are subjected to data grouping and are stored, provide one
The good design that message acquisition, packet parsing, data processing and data based on IEC104 agreement store is covered, so that by IEC104
Message, analytic message and the data processing of acquisition carry out good decoupling, are more convenient for being multiplexed and extend.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process
Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit
It is fixed.
The embodiment of the present invention provides a kind of device of data processing, as shown in figure 3, the device includes: receiving module 301,
Parsing module 302, memory module 303.
Receiving module 301, for receiving message.
Parsing module 302, for carrying out piecewise analytic to the message, being parsed according to preset packet parsing chain
Data afterwards.
Optionally, the parsing module 302 for A, determines word to be resolved in the corresponding message of analytic thread subclass
Section;B, according to the analytic thread subclass, corresponding byte to be resolved is parsed;Circulation executes step A and B, until to the report
Text is parsed, the data after being parsed.
Memory module 303, for the data to be carried out data grouping and are stored.
Optionally, the memory module 303 transmits the data use for obtaining according to the data after parsing
Iec104 agreement in long-range number;The data are stored with corresponding long-range number for index.
Optionally, the memory module 303, for according to the data after parsing, in the service attribute table prestored
Inquiry obtains the service attribute name of the data, and at least a pair of of data and corresponding service attribute are saved in the service attribute table
Name;The data are stored with the entitled index of the service attribute.
Further, after storing to data, described device is also used to the business category according to the data
Property name, the corresponding data value of the data is inquired in the service attribute table, the data value of the data, the business is arranged
At least a pair of of service attribute name and corresponding data value are saved in attribute list.And the data value according to the data, to described
Data are handled according to corresponding service logic
Optionally, the data after parsing correspond to different points, and each point binds an analyzer;The dress
It sets, the corresponding all analyzers of data for storage to be arranged are binary tree structure;By the way of inorder traversal time
Go through each analyzer in the binary tree structure.
The embodiment of the present invention provides a kind of device of data processing, including receiving module for receiving message;According to default
Packet parsing chain, parsing module carries out piecewise analytic, data after being parsed to the message;Memory module is by the number
According to data grouping and store, the message acquisition that the embodiment of the invention provides a set of based on IEC104 agreement, packet parsing,
The good design of data processing and data storage, so that the message, analytic message and data processing of IEC104 acquisition are carried out good
Good decoupling is more convenient for being multiplexed and be extended.
Fig. 4 is the schematic diagram for the terminal device that one embodiment of the invention provides.As shown in figure 4, the terminal of the embodiment is set
Standby 4 include: processor 401, memory 402 and are stored in the memory 402 and can run on the processor 401
Computer program 403, such as the detection program of transformer core D.C. magnetic biasing.The processor 401 executes the computer
Realize the step in the embodiment of the method for above-mentioned data processing when program 403, such as step 101 shown in FIG. 1 is to 103.It is described
Processor 401 realizes the function of each module in above-mentioned each Installation practice, such as Fig. 3 institute when executing the computer program 403
Show the function of module 301 to 303.
Illustratively, the computer program 403 can be divided into one or more modules, one or more of
Module is stored in the memory 402, and is executed by the processor 401, to complete the present invention.It is one or more of
Module can be the series of computation machine program instruction section that can complete specific function, and the instruction segment is for describing the computer
Implementation procedure of the program 403 in the device or terminal device 4 of the data processing.For example, the computer program 403 can
To be divided into receiving module 301, parsing module 302, memory module 303, each module concrete function is as shown in figure 3, herein not
It repeats one by one again.
The terminal device 4 can be the calculating such as desktop PC, notebook, palm PC and cloud server and set
It is standby.The terminal device may include, but be not limited only to, processor 401, memory 402.It will be understood by those skilled in the art that
Fig. 4 is only the example of terminal device 4, does not constitute the restriction to terminal device 4, may include more more or fewer than illustrating
Component, perhaps combines certain components or different components, for example, the terminal device can also include input-output equipment,
Network access equipment, bus etc..
Alleged processor 401 can be central processing unit (Central Processing Unit, CPU), can also be
Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit
(Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-
Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor
Deng.
The memory 402 can be the internal storage unit of the terminal device 4, for example, terminal device 4 hard disk or
Memory.The memory 402 is also possible to the External memory equipment of the terminal device 4, such as is equipped on the terminal device 4
Plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card,
Flash card (Flash Card) etc..Further, the memory 402 can also have been deposited both the inside including the terminal device 4
Storage unit also includes External memory equipment.The memory 402 is for storing the computer program and the terminal device 4
Other required programs and data.The memory 402, which can be also used for temporarily storing, have been exported or will export
Data.
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each function
Can unit, module division progress for example, in practical application, can according to need and by above-mentioned function distribution by different
Functional unit, module are completed, i.e., the internal structure of described device is divided into different functional unit or module, more than completing
The all or part of function of description.Each functional unit in embodiment, module can integrate in one processing unit, can also
To be that each unit physically exists alone, can also be integrated in one unit with two or more units, it is above-mentioned integrated
Unit both can take the form of hardware realization, can also realize in the form of software functional units.In addition, each function list
Member, the specific name of module are also only for convenience of distinguishing each other, the protection scope being not intended to limit this application.Above system
The specific work process of middle unit, module, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, is not described in detail or remembers in some embodiment
The part of load may refer to the associated description of other embodiments.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure
Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually
It is implemented in hardware or software, the specific application and design constraint depending on technical solution.Professional technician
Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed
The scope of the present invention.
In embodiment provided by the present invention, it should be understood that disclosed device/terminal device and method, it can be with
It realizes by another way.For example, device described above/terminal device embodiment is only schematical, for example, institute
The division of module or unit is stated, only a kind of logical function partition, there may be another division manner in actual implementation, such as
Multiple units or components can be combined or can be integrated into another system, or some features can be ignored or not executed.Separately
A bit, shown or discussed mutual coupling or direct-coupling or communication connection can be through some interfaces, device
Or the INDIRECT COUPLING or communication connection of unit, it can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated module/unit be realized in the form of SFU software functional unit and as independent product sale or
In use, can store in a computer readable storage medium.Based on this understanding, the present invention realizes above-mentioned implementation
All or part of the process in example method, can also instruct relevant hardware to complete, the meter by computer program
Calculation machine program can be stored in a computer readable storage medium, the computer program when being executed by processor, it can be achieved that on
The step of stating each embodiment of the method.Wherein, the computer program includes computer program code, the computer program
Code can be source code form, object identification code form, executable file or certain intermediate forms etc..Computer-readable Jie
Matter may include: can carry the computer program code any entity or device, recording medium, USB flash disk, mobile hard disk,
Magnetic disk, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory (RAM,
Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that described
The content that computer-readable medium includes can carry out increasing appropriate according to the requirement made laws in jurisdiction with patent practice
Subtract, such as does not include electric carrier signal and electricity according to legislation and patent practice, computer-readable medium in certain jurisdictions
Believe signal.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although referring to aforementioned reality
Applying example, invention is explained in detail, those skilled in the art should understand that: it still can be to aforementioned each
Technical solution documented by embodiment is modified or equivalent replacement of some of the technical features;And these are modified
Or replacement, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution should all
It is included within protection scope of the present invention.