Coding and decoding device and coding and decoding method
By introducing a universal codec module in the network management device, selecting appropriate codecs and decoders based on the configuration information of managed nodes, the complex system problems caused by differences in communication protocols between different nodes are solved, and a flexible codec scheme is realized, reducing the need for a lower level of time. System complexity.
Patent Information
- Application Number
- CN202210708236.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-21
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2042-06-21
AI Technical Summary
In the ship communication control management system, due to the differences in the service private protocols used by different managed nodes, network management equipment needs to set up codec devices for different nodes, resulting in an increase in system complexity.
Design a general codec module, by obtaining the configuration information of the managed node, selecting the corresponding pre-encoding converter, encoder, post-encoding converter and output device, streaming the service message, and processing the processed report The text is output to the managed nodes to implement the encoding and decoding of different nodes.
It reduces the system complexity and meets the encoding requirements of different communication protocols and encoding methods. There is no need to set up encoding modules for each managed node, which simplifies the design of network management equipment.
Smart Images

Figure CN115348330B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of coding technology, and in particular to a coding and decoding device and a coding and decoding method. Background Art
[0002] In the communication control and management system on board ships, the network management device communicates with the managed nodes (such as ship equipment) through business private protocols. Depending on the managed nodes, the customization of business private protocols usually varies. On the one hand, different business private protocols can use different underlying communication protocols, such as User Datagram Protocol (UDP), DDS, Web Service, etc. On the other hand, different business private protocols can use different information encoding methods, such as eXtensible Markup Language (XML), binary stream, JavaScript Object Notation (JSON), etc.
[0003] Due to the above situation, in order to ensure communication between the network management device and different managed nodes, the network management device needs to set up encoding and decoding devices for different managed nodes respectively, which makes the network management device system complicated. Summary of the invention
[0004] The embodiment of the present disclosure provides a coding and decoding device and a coding and decoding method, which can realize the message coding and decoding work for different managed nodes. The technical solution is as follows:
[0005] At least one embodiment of the present disclosure provides a coding and decoding device, the coding and decoding device comprising:
[0006] A general encoding and decoding module is used to obtain a first business message, where the first business message is a business message generated for a managed node; based on the first business message, obtain configuration information corresponding to the managed node, where the configuration information includes an encoding method and a transmission protocol; determine a pre-coding converter, an encoder, a post-coding converter and an external outputter corresponding to the configuration information; call the determined pre-coding converter, encoder and post-coding converter to perform stream processing on the first business message to obtain a second business message; call the determined external outputter to output the second business message to the managed node through a corresponding interface.
[0007] Optionally, the general encoding and decoding module is used to determine the pre-coding converter, encoder, post-coding converter and external outputter corresponding to the configuration information from the pre-coding converter cluster, encoder cluster, post-coding converter cluster and external outputter cluster respectively;
[0008] The pre-encoding converter cluster includes at least one of the following pre-encoding converters: XML2Binary, used to convert XML format into binary format; XML2XML, used to convert XML format into XML format;
[0009] The encoder cluster includes at least one of the following encoders: BinaryCodec, calling a binary encoder for encoding; XMLCodec, calling an XML encoder for encoding;
[0010] The post-encoding converter cluster includes at least one of the following post-encoding converters: Binary2File, used to convert binary format into file format; Binary2Udp, used to convert binary format into UDP message format; XML2Dds, used to convert XML format into DDS message format; XML2File, used to convert XML format into file format; XML2Udp, used to convert XML format into UDP message format;
[0011] The external output device cluster includes at least one of the following external output devices: DdsOutput, used for transmission using the DDS protocol; UdpOutput, used for transmission using the UDP protocol; StringFileOutput, used for transmission using the StringFile protocol; BinaryFileOutput, used for transmission using the BinaryFile protocol; FtpOutput, used for transmission using the FTP protocol; DdsTimerOutput, used for transmission using the timed DDS protocol; UdpTimerOutput, used for transmission using the timed UDP protocol.
[0012] Optionally, the general encoding and decoding module is further used to obtain information content and an identifier from the first service message before performing stream processing on the first service message; and encapsulate the information content and the identifier into a standard data structure.
[0013] Optionally, the general encoding and decoding module is also used to receive a third business message sent by the managed node; obtain configuration information corresponding to the managed node based on the third business message, the configuration information including a decoding method; determine a pre-decoding converter, a decoder, a post-decoding converter and an internal outputter corresponding to the configuration information; call the determined pre-decoding converter, the decoder and the post-decoding converter to perform stream processing on the third business message to obtain a fourth business message; call the determined internal outputter to output the fourth business message through a corresponding interface.
[0014] Optionally, the general encoding and decoding module is used to determine the pre-decoding converter, the decoder, the post-decoding converter and the internal outputter corresponding to the configuration information from the pre-decoding converter cluster, the decoder cluster, the post-decoding converter cluster and the internal outputter cluster respectively;
[0015] The pre-decoding converter cluster includes at least one of the following pre-decoding converters: Bytes2Binary, used to convert a byte stream into a binary format; Bytes2XML, used to convert a byte stream into an XML format; Passthrough, used to allow data to pass directly; XML2XML, used to convert XML format into XML format;
[0016] The decoder cluster includes at least one of the following decoders: BinaryCodec, calling a binary decoder for decoding; XMLCodec, calling an XML decoder for decoding;
[0017] The post-decoding converter cluster includes at least one of the following post-decoding converters: Binary2Dds, used to convert binary format into DDS message format; XML2Dds, used to convert XML format into DDS message format;
[0018] The internal output device cluster includes at least one of the following internal output devices: DdsOutput, which is used for transmission using the DDS protocol.
[0019] Optionally, the general encoding and decoding module is further used to obtain information content and an identifier from the third service message before performing stream processing on the third service message; and encapsulate the information content and the identifier into a standard data structure.
[0020] At least one embodiment of the present disclosure provides a coding and decoding method, the coding and decoding method comprising:
[0021] Acquire a first service message, where the first service message is a service message generated for a managed node;
[0022] Acquire configuration information corresponding to the managed node based on the first service message, where the configuration information includes an encoding method and a transmission protocol;
[0023] Determine a pre-encoding converter, an encoder, a post-encoding converter, and an external outputter corresponding to the configuration information;
[0024] Calling the determined pre-encoding converter, encoder, and post-encoding converter to perform stream processing on the first service message to obtain a second service message;
[0025] The determined external exporter is called to output the second service message to the managed node through a corresponding interface.
[0026] Optionally, the method further comprises:
[0027] Receiving a third service message sent by the managed node;
[0028] Acquire configuration information corresponding to the managed node based on the third service message, where the configuration information includes a decoding method;
[0029] Determining a pre-decoding converter, a decoder, a post-decoding converter, and an internal outputter corresponding to the configuration information;
[0030] Calling the determined pre-decoding converter, decoder, and post-decoding converter to perform stream processing on the third service message to obtain a fourth service message;
[0031] The determined internal output device is called to output the fourth service message through a corresponding interface.
[0032] At least one embodiment of the present disclosure provides a coding and decoding device, which includes a processor and a memory. The memory stores at least one program code, and the program code is loaded and executed by the processor to implement the coding and decoding method as described above.
[0033] At least one embodiment of the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores at least one program code, and the program code is loaded and executed by a processor to implement the encoding and decoding method as described in any of the preceding items.
[0034] The technical solution provided by the embodiments of the present disclosure has the following beneficial effects:
[0035] In the disclosed embodiment, a universal encoding and decoding module is set in the encoding and decoding device, and the configuration information corresponding to the managed node is determined by generating a first service message for the managed node, and the pre-encoding converter cluster, encoder cluster, and post-encoding converter cluster required for encoding are selected based on the configuration information corresponding to the managed node. Then, these clusters are used to perform stream processing of the first service message to achieve encoding, and finally, the external output device cluster selection interface selected by the configuration information corresponding to the managed node is output and sent to the managed node. In the above implementation, by setting a universal encoding and decoding module, it is sufficient to set corresponding clusters for encoding schemes with different encoding requirements, which can meet the encoding requirements of different communication protocols and encoding methods, and there is no need to set encoding modules for different managed nodes respectively, thereby reducing the complexity of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0037] Figure 1 is a structural diagram of a communication control management system provided by an embodiment of the present disclosure;
[0038] Figure 2 It is a structural diagram of a network management device in the related art;
[0039] Figure 3 is a structural diagram of a coding and decoding device provided by an embodiment of the present disclosure;
[0040] Figure 4 is a schematic diagram of the encoding process provided by an embodiment of the present disclosure;
[0041] Figure 5 is a schematic diagram of a decoding process provided by an embodiment of the present disclosure;
[0042] Figure 6 is a flowchart of a coding and decoding method provided by at least one embodiment of the present disclosure;
[0043] Figure 7 It is a structural block diagram of a coding and decoding device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0044] In order to make the objectives, technical solutions and advantages of the present disclosure more clear, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.
[0045] Unless otherwise defined, the technical or scientific terms used herein shall have the usual meanings understood by persons of ordinary skill in the field to which the present disclosure belongs. The words "first", "second", "third" and similar words used in the patent application specification and claims of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "one" or "one" do not indicate a quantitative limitation, but rather indicate the presence of at least one. Words such as "include" or "comprise" and similar words mean that the elements or objects appearing before "include" or "comprises" cover the elements or objects listed after "include" or "comprises" and their equivalents, and do not exclude other elements or objects.
[0046] Figure 1 Schematic diagram of a communication control management system provided by an embodiment of the present disclosure. Figure 1The communication control and management system includes: a network management device 100 and a plurality of managed nodes 200 (eg, shipborne devices).
[0047] The network management device 100 is connected to a plurality of managed nodes 200 respectively.
[0048] In the related art, the network management device 100 mainly includes a network management device, and the structure of the network management device is as follows: Figure 2 As shown, in the network management device, the network management device can generate different service messages for different services, and encode different managed nodes 200 by considering the corresponding communication protocol and encoding method during encoding, and then send them out through the corresponding interface, so as to form the following Figure 2 As shown in the relationship diagram, each service is sent to a different interface of the managed node 200 .
[0049] In the related art, the network management device needs to set up codec modules for different managed nodes, that is, each interface corresponds to a codec module ( Figure 2 Omitted), making the system complex.
[0050] In the disclosed embodiment, a coding and decoding device is provided in the network management device, which is responsible for coding and decoding the messages of each managed node.
[0051] Figure 3 is a schematic diagram of the structure of a coding and decoding device provided by an embodiment of the present disclosure. Figure 3 , the encoding and decoding device includes: a general encoding and decoding module 101.
[0052] The general encoding and decoding module 101 is used to obtain a first business message, which is a business message generated for a managed node; based on the first business message, obtain configuration information corresponding to the managed node, the configuration information includes an encoding method and a transmission protocol; determine a pre-coding converter, an encoder, a post-coding converter and an external outputter corresponding to the configuration information; call the determined pre-coding converter, encoder and post-coding converter to perform stream processing on the first business message to obtain a second business message; call the determined external outputter to output the second business message to the managed node through a corresponding interface.
[0053] Here, the network management device of the network management apparatus 100 can generate different service messages for different managed nodes, and the encoding and decoding device can encode and decode messages for different service messages.
[0054] In the disclosed embodiment, a universal encoding and decoding module is set in the encoding and decoding device, and the configuration information corresponding to the managed node is determined by generating a first service message for the managed node, and the pre-encoding converter cluster, encoder cluster, and post-encoding converter cluster required for encoding are selected based on the configuration information corresponding to the managed node. Then, these clusters are used to perform stream processing of the first service message to achieve encoding, and finally, the external output device cluster selection interface selected by the configuration information corresponding to the managed node is output and sent to the managed node. In the above implementation, by setting a universal encoding and decoding module, it is sufficient to set corresponding clusters for encoding schemes with different encoding requirements, which can meet the encoding requirements of different communication protocols and encoding methods, and there is no need to set encoding modules for different managed nodes respectively, thereby reducing the complexity of the system.
[0055] In the embodiment of the present disclosure, the first service message is a management message generated by the encoding and decoding device for the managed node (different services correspond to different types of management), such as resetting a device with an ID of 123.
[0056] Before encoding, the universal encoding and decoding module 101 may determine an identifier according to the subject of the first service message, for example, by obtaining the identifier from the message, or calculating the identifier according to relevant fields in the message, or searching for the corresponding identifier according to the subject of the message, etc. If the aforementioned 123 is used as the identifier, the configuration information corresponding to the managed node is determined using the identifier.
[0057] In the embodiment of the present disclosure, the configuration information corresponding to each managed node may be pre-stored in the encoding and decoding device.
[0058] In the embodiments of the present disclosure, the encoding method in the configuration information refers to information encoding methods such as binary, XML, and JSON. The transmission protocol in the configuration information refers to transmission protocols such as UDP and DDS. Of course, the above encoding methods and transmission protocols are only examples, and the encoding methods and transmission protocols that can be used by the encoding and decoding device provided in the embodiments of the present disclosure are not limited to these.
[0059] In an embodiment of the present disclosure, the general codec module is used to determine the pre-coding converter, encoder, post-coding converter and external outputter corresponding to the configuration information from the pre-coding converter cluster, encoder cluster, post-coding converter cluster and external outputter cluster respectively.
[0060] The pre-encoding converter and the post-encoding converter are used to convert the encoding format. The encoder is used to encode various formats. The external output device is used to transmit messages using the protocol interface.
[0061] Exemplarily, the pre-encoding converter cluster includes at least one of the following pre-encoding converters: XML2Binary, for converting XML format into binary format; XML2XML, for converting XML format into XML format;
[0062] The encoder cluster includes at least one of the following encoders: BinaryCodec, calling a binary encoder for encoding; XMLCodec, calling an XML encoder for encoding;
[0063] The post-encoding converter cluster includes at least one of the following post-encoding converters: Binary2File, used to convert binary format into file format; Binary2Udp, used to convert binary format into UDP message format; XML2Dds, used to convert XML format into DDS message format; XML2File, used to convert XML format into file format; XML2Udp, used to convert XML format into UDP message format;
[0064] The external output device cluster includes at least one of the following external output devices: DdsOutput, used for transmission using the DDS protocol; UdpOutput, used for transmission using the UDP protocol; StringFileOutput, used for transmission using the StringFile protocol; BinaryFileOutput, used for transmission using the BinaryFile protocol; FtpOutput, used for transmission using the FTP protocol; DdsTimerOutput, used for transmission using the timed DDS protocol; UdpTimerOutput, used for transmission using the timed UDP protocol.
[0065] Of course, the above-mentioned clusters are only examples, and the present disclosure is not limited thereto.
[0066] The pre-encoding converter, encoder, post-encoding converter and external outputter provided by the embodiments of the present disclosure realize parameter conversion from a standard input type to an encoder, and parameter conversion from an encoder output to an external outputter.
[0067] The following is an example of parameter conversion from encoder output to external output:
[0068] For example, there are two types of encoder Codec, one is XmlCodec and the other is BinaryCodec. The former can complete XML encoding, and the latter can achieve binary encoding. For the XML encoder, its output is a structure, which contains a string with XML content / a keyword, identifying the ID of the encoding rule; for the Binary encoder, its output is a structure, which contains a byte array / a keyword, identifying the ID of the encoding rule. Both encoders can be output through an external output device such as UDP. The parameter input received by the UDP external output device is a structure, whose content contains a byte array of the data packet content and an IP address of the sending target.
[0069] When the UDP external exporter outputs the encoding result of the Binary encoder, that is, a byte array, it can directly send the byte array to a specific IP, where the target IP is obtained by querying the encoding rule ID. Then the conversion from the Binary encoder to the UDP external exporter is to complete this parameter conversion.
[0070] When the UDP external outputter outputs the encoding result of the XML encoder, it needs to serialize the XML string into a byte array according to the protocol requirements, then add the packet header according to the protocol requirements, and finally query the output IP based on the keyword, and hand over the converted parameters to the UDP external outputter for output.
[0071] Optionally, the general encoding and decoding module 101 is further configured to obtain information content and an identifier from the first service message before performing stream processing on the first service message; and encapsulate the information content and the identifier into a standard data structure.
[0072] Figure 4 Schematic diagram of the encoding process provided by the embodiment of the present disclosure. Figure 4 As shown, the general codec module 101 uses the encoding preprocessing cluster Formatter to preprocess the first service message, obtains a standard data structure, and stores it in the container content of the stream processing component flow; the stream processing component flow determines the pre-encoding converter, encoder, post-encoding converter and external output device corresponding to the configuration information from the pre-encoding converter cluster BEGear (BeforeEncodeGear), the encoder cluster Codec, the post-encoding converter cluster AEGear (AfterEncodeGear) and the external output device cluster Output according to the configuration information in the standard data structure. The determined pre-encoding converter, encoder, post-encoding converter and external output device are called to encode and output the information content.
[0073] In addition, the codec device is also configured with a coding interface tool cluster Util, which includes various interface tools and configuration tool classes required for coding. The interface tools include interface tools related to communication protocols, such as the DDS tool class DdsUtil, the UDP tool class UdpUtil, etc. Taking DdsUtil as an example, DdsUtil can realize the initialization, message reception, and message sending of DDS messages. The configuration tool class ConfigTool can identify and read configuration information and provide it to other modules for use. For example, the device configuration tool class can read the configuration information corresponding to the managed node. There are multiple implementations corresponding to each tool cluster to adapt to different protocol requirements. When the codec device is working, it finds the configuration information according to the identifier, takes out the appropriate instance from each tool cluster, and matches it with the codec general flow processing component Flow to realize the encoding and decoding of a unified process.
[0074] In the embodiment of the present disclosure, when the stream processing component flow is working, it can call and instantiate various converters and encoders, and then call them in sequence according to the encoding process (for example, pre-encoding conversion, encoding, and post-encoding conversion in sequence) to achieve encoding.
[0075] In the disclosed embodiment, instantiation may be implemented using the Spring tripartite framework, and corresponding classes (converters and encoders, etc.) may be instantiated by reading an XML configuration file.
[0076] For example, the network management device sends the first business message "Reset the device with ID 123". Assuming that the device is on different ships, the encoding method and communication protocol used are different. For example, on ship A, the message encoding method is XML and is sent using DDS; on ship B, the message encoding method is binary and is sent via UDP; on ship C, the message encoding method is XML and is sent via UDP. The network management device and the general encoding and decoding module communicate through DDS. In the general interface of the general encoding and decoding module, the configuration file (FormatterContext.xml) records the mapping relationship between the subject and identifier (code) of the first business message. Flow uses code to find the encoding method and communication protocol in the configuration file (ProtocolConfig.xml) to determine the corresponding encoder and converter. Taking ship A as an example, the Code is configured in the ProtocolConfig.xml file of ship A to encode in XML mode, and then sent using DDS. Flow calls XmlCodec to encode the XML file and sends the encoding result using DdsOutput.
[0077] Optionally, the general encoding and decoding module 101 is also used to receive a third business message sent by the managed node; obtain configuration information corresponding to the managed node based on the third business message, the configuration information including a decoding method; determine a pre-decoding converter, a decoder, a post-decoding converter and an internal outputter corresponding to the configuration information; call the determined pre-decoding converter, the decoder and the post-decoding converter to perform stream processing on the third business message to obtain a fourth business message; call the determined internal outputter to output the fourth business message through a corresponding interface, for example, to a network management device.
[0078] exist Figure 3 In the network management device shown, the unified internal interface in the network management device and the universal codec module 101 may be a DDS interface to implement message transmission between the two devices.
[0079] In an embodiment of the present disclosure, the general encoding and decoding module is used to determine the pre-decoding converter, decoder, post-decoding converter and internal outputter corresponding to the configuration information from the pre-decoding converter cluster, decoder cluster, post-decoding converter cluster and internal outputter cluster respectively.
[0080] The pre-decoding converter and the post-decoding converter are used to convert the decoding format. The decoder is used to decode various formats. The internal output device is used to transmit messages using the protocol interface.
[0081] Exemplarily, the pre-decoding converter cluster includes at least one of the following pre-decoding converters: Bytes2Binary, used to convert a byte stream into a binary format; Bytes2XML, used to convert a byte stream into an XML format; Passthrough, used to allow data to pass directly; XML2XML, used to convert XML format into XML format;
[0082] The decoder cluster includes at least one of the following decoders: BinaryCodec, calling a binary decoder for decoding; XMLCodec, calling an XML decoder for decoding;
[0083] The post-decoding converter cluster includes at least one of the following post-decoding converters: Binary2Dds, used to convert binary format into DDS message format; XML2Dds, used to convert XML format into DDS message format;
[0084] The internal output device cluster includes at least one of the following internal output devices: DdsOutput, which is used for transmission using the DDS protocol.
[0085] Of course, the above-mentioned clusters are only examples, and the present disclosure is not limited thereto.
[0086] Optionally, the general encoding and decoding module 101 is further used to obtain information content and an identifier from the third service message before performing stream processing on the third service message; and encapsulate the information content and the identifier into a standard data structure.
[0087] Figure 5 Schematic diagram of the decoding process provided by the embodiment of the present disclosure. Figure 5 As shown, the general codec module 101 uses the decoding preprocessing cluster Formatter to preprocess the third service message, obtains a standard data structure, and stores it in the container content of the stream processing component flow; the stream processing component flow determines the pre-decoding converter, decoder, post-decoding converter and internal output device corresponding to the configuration information from the pre-decoding converter cluster BDGear (BeforeDecodeGear), the decoder cluster Codec, the post-decoding converter cluster ADGear (AfterDecodeGear) and the internal output device cluster InnerOutput according to the configuration information in the standard data structure. The determined pre-decoding converter, decoder, post-decoding converter and internal output device are called to encode and output the information content.
[0088] During the decoding process, the decoding preprocessing cluster Formatter can include UdpFormatter and DdsFormatter. The communication protocol server of the general codec module receives messages of various types of protocols reported by the managed node, and hands them over to various corresponding decoding preprocessing cluster Formatters according to the different underlying communication protocols. For example, data from the Udp server is handed over to UdpFormatter, and data from the DDS server is handed over to DdsFormatter.
[0089] During the decoding process, multithreading can be implemented through a thread pool to ensure that the general encoding and decoding module can utilize the CPU multi-core / multi-thread capabilities to achieve parallel work.
[0090] For example, suppose a decoding message is transmitted via UDP. After receiving the message, the UDP tool class instance directly hands it over to the UdpFormatter instance for preprocessing. The UdpFormatter instance parses the specific fields of the received message and identifies the unique identifier of the message as DEF. It also learns from the configuration tool class instance that the protocol content type of the DEF protocol is byte stream, the decoder type is XML, and the decoding result is output to the network management device in the form of DDS. The UdpFormatter instance packages the above information into a standard structure and calls the flow instance for processing. After receiving the standard structure, the flow instance finds the decoding thread pool through the message unique identifier recorded in the structure and hands the standard structure to the thread pool for processing. The thread pool reads the protocol content type and decoder type of the message, takes out the byte stream to XML decoding pre-converter instance, and completes the conversion of parameters before decoding. The thread pool reads the decoder type and takes out the XML codec instance to complete the decoding of the protocol. The thread pool reads the internal output type and takes out the DDS internal outputter instance, and finally completes the transmission of the processed information to the network management device.
[0091] In another possible implementation, the thread pool is not divided based on the unique identifier of the protocol, but based on the source of the message, such as the peer IP in the UDP protocol and the message subject in the DDS protocol. In this way, the messages from the same source use the same thread pool, which can ensure that the first-come, first-served is processed. Similarly, other strategies can be used to divide the thread pool.
[0092] The encoding and decoding device provided by the embodiment of the present disclosure enhances the reusability of the network management device by using a universal encoding and decoding module, so that network management devices of different ship types can be reused at the module or code level. Without using the universal encoding and decoding module, the business components in the network management device need to process the information of different encoding formats and communication protocols reported by various interfaces, which easily causes confusion in business logic. The introduction of the universal encoding and decoding module solves this problem well.
[0093] The encoding and decoding device provided by the embodiment of the present disclosure decouples the underlying communication protocol and the private protocol encoding method in the general encoding and decoding module, so that both the underlying transmission protocol and the codec can be horizontally expanded, and the modification of each other will not affect the other. In addition, when performing encoding and decoding, general functions such as decoding thread division and message queue can also be used, which can be compatible with different underlying transmission protocols and codecs.
[0094] Figure 6 is a flowchart of a coding and decoding method provided by at least one embodiment of the present disclosure. The method is executed by the aforementioned coding and decoding device, and the coding and decoding method includes:
[0095] 301: Obtain a first service message, where the first service message is a service message generated for a managed node.
[0096] 302: Acquire configuration information corresponding to the managed node based on the first service message, where the configuration information includes an encoding mode and a transmission protocol.
[0097] 303: Determine a pre-encoding converter, an encoder, a post-encoding converter, and an external outputter corresponding to the configuration information.
[0098] 304: Call the determined pre-encoding converter, encoder, and post-encoding converter to perform stream processing on the first service message to obtain a second service message.
[0099] 305: Call the determined external exporter to output the second service message to the managed node through the corresponding interface.
[0100] In the disclosed embodiment, a universal encoding and decoding module is set in the encoding and decoding device, and the configuration information corresponding to the managed node is determined by generating a first service message for the managed node, and the pre-encoding converter cluster, encoder cluster, and post-encoding converter cluster required for encoding are selected based on the configuration information corresponding to the managed node. Then, these clusters are used to perform stream processing of the first service message to achieve encoding, and finally, the external output device cluster selection interface selected by the configuration information corresponding to the managed node is output and sent to the managed node. In the above implementation, by setting a universal encoding and decoding module, it is sufficient to set corresponding clusters for encoding schemes with different encoding requirements, which can meet the encoding requirements of different communication protocols and encoding methods, and there is no need to set encoding modules for different managed nodes respectively, thereby reducing the complexity of the system.
[0101] Optionally, the determining the pre-coding converter, encoder, post-coding converter and external outputter corresponding to the configuration information comprises: determining the pre-coding converter, encoder, post-coding converter and external outputter corresponding to the configuration information from a pre-coding converter cluster, an encoder cluster, a post-coding converter cluster and an external outputter cluster, respectively;
[0102] The pre-encoding converter cluster includes at least one of the following pre-encoding converters: XML2Binary, used to convert XML format into binary format; XML2XML, used to convert XML format into XML format;
[0103] The encoder cluster includes at least one of the following encoders: BinaryCodec, calling a binary encoder for encoding; XMLCodec, calling an XML encoder for encoding;
[0104] The post-encoding converter cluster includes at least one of the following post-encoding converters: Binary2File, used to convert binary format into file format; Binary2Udp, used to convert binary format into UDP message format; XML2Dds, used to convert XML format into DDS message format; XML2File, used to convert XML format into file format; XML2Udp, used to convert XML format into UDP message format;
[0105] The external output device cluster includes at least one of the following external output devices: DdsOutput, used for transmission using the DDS protocol; UdpOutput, used for transmission using the UDP protocol; StringFileOutput, used for transmission using the StringFile protocol; BinaryFileOutput, used for transmission using the BinaryFile protocol; FtpOutput, used for transmission using the FTP protocol; DdsTimerOutput, used for transmission using the timed DDS protocol; UdpTimerOutput, used for transmission using the timed UDP protocol.
[0106] Optionally, the method further includes: before performing stream processing on the first service message, obtaining information content and an identifier from the first service message; and encapsulating the information content and the identifier into a standard data structure.
[0107] Optionally, the method further comprises:
[0108] Receiving a third service message sent by the managed node;
[0109] Acquire configuration information corresponding to the managed node based on the third service message, where the configuration information includes a decoding method;
[0110] Determining a pre-decoding converter, a decoder, a post-decoding converter, and an internal outputter corresponding to the configuration information;
[0111] Calling the determined pre-decoding converter, decoder, and post-decoding converter to perform stream processing on the third service message to obtain a fourth service message;
[0112] The determined internal output device is called to output the fourth service message through a corresponding interface.
[0113] Optionally, the determining the pre-decoding converter, the decoder, the post-decoding converter and the internal outputter corresponding to the configuration information comprises: determining the pre-decoding converter, the decoder, the post-decoding converter and the internal outputter corresponding to the configuration information from the pre-decoding converter cluster, the decoder cluster, the post-decoding converter cluster and the internal outputter cluster respectively;
[0114] The pre-decoding converter cluster includes at least one of the following pre-decoding converters: Bytes2Binary, used to convert a byte stream into a binary format; Bytes2XML, used to convert a byte stream into an XML format; Passthrough, used to allow data to pass directly; XML2XML, used to convert XML format into XML format;
[0115] The decoder cluster includes at least one of the following decoders: BinaryCodec, calling a binary decoder for decoding; XMLCodec, calling an XML decoder for decoding;
[0116] The post-decoding converter cluster includes at least one of the following post-decoding converters: Binary2Dds, used to convert binary format into DDS message format; XML2Dds, used to convert XML format into DDS message format;
[0117] The internal output device cluster includes at least one of the following internal output devices: DdsOutput, which is used for transmission using the DDS protocol.
[0118] Optionally, the method further includes: before performing stream processing on the third service message, obtaining information content and an identifier from the third service message; and encapsulating the information content and the identifier into a standard data structure.
[0119] Figure 7 601 and 602. The embodiment of the present disclosure provides a structural block diagram of a coding and decoding device. Generally, the coding and decoding device includes: a processor 601 and a memory 602.
[0120] The processor 601 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 601 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state.
[0121] The memory 602 may include one or more computer-readable storage media, which may be non-transitory. The memory 602 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 602 is used to store at least one instruction, which is used to be executed by the processor 601 to implement the encoding and decoding method performed by the encoding and decoding device provided in the method embodiment of the present application.
[0122] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0123] The above description is only an optional embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A coding and decoding device, characterized in that: The encoding and decoding device is located in the network management device and is responsible for encoding and decoding the messages of each managed node; The network management device is connected to each of the managed nodes, and the managed nodes are shipborne devices; The encoding and decoding device comprises: A general encoding and decoding module, used for obtaining a first business message, wherein the first business message is a business message generated for a managed node; obtaining configuration information corresponding to the managed node based on the first business message, wherein the configuration information includes an encoding method and a transmission protocol; determining a pre-encoding converter, an encoder, a post-encoding converter and an external outputter corresponding to the configuration information; calling the determined pre-encoding converter, encoder and post-encoding converter to perform stream processing on the first business message to obtain a second business message; calling the determined external outputter to output the second business message to the managed node through a corresponding interface; the role of the pre-encoding converter and the post-encoding converter is to perform encoding format conversion; the role of the encoder is to perform encoding in various formats; the role of the external outputter is to use a protocol interface for message transmission; The general encoding and decoding module is used to determine the pre-coding converter, encoder, post-coding converter and external outputter corresponding to the configuration information from the pre-coding converter cluster, encoder cluster, post-coding converter cluster and external outputter cluster respectively; The pre-encoding converter cluster includes at least one of the following pre-encoding converters: XML2Binary, used to convert XML format into binary format; XML2XML, used to convert XML format into XML format; The encoder cluster includes at least one of the following encoders: BinaryCodec, calling a binary encoder for encoding; XMLCodec, calling an XML encoder for encoding; The post-encoding converter cluster includes at least one of the following post-encoding converters: Binary2File, used to convert binary format into file format; Binary2Udp, used to convert binary format into UDP message format; XML2Dds, used to convert XML format into DDS message format; XML2File, used to convert XML format into file format; XML2Udp, used to convert XML format into UDP message format; The external output device cluster includes at least one of the following external output devices: DdsOutput, used for transmission using the DDS protocol; UdpOutput, used for transmission using the UDP protocol; StringFileOutput, used for transmission using the StringFile protocol; BinaryFileOutput, used for transmission using the BinaryFile protocol; FtpOutput, used for transmission using the FTP protocol; DdsTimerOutput, used for transmission using the timed DDS protocol; UdpTimerOutput, used for transmission using the timed UDP protocol; The general encoding and decoding module is also used to obtain information content and identification from the first service message before performing flow processing on the first service message; use the encoding preprocessing cluster Formatter to encapsulate the information content and the identification into a standard data structure, and store it in the container content of the flow processing component flow; The encoding and decoding device is also configured with an encoding interface tool cluster Util, which includes various interface tools and configuration tool classes required for encoding, and the interface tools include interface tools related to the communication protocol; when the encoding and decoding device is working, it finds the configuration information according to the identifier, takes out suitable instances from each of the encoding interface tool clusters, and cooperates with the stream processing component flow to perform encoding and decoding of a unified process.
2. The encoding and decoding device according to claim 1, characterized in that: The general encoding and decoding module is also used to receive a third business message sent by the managed node; obtain configuration information corresponding to the managed node based on the third business message, and the configuration information includes a decoding method; determine a pre-decoding converter, a decoder, a post-decoding converter and an internal outputter corresponding to the configuration information; call the determined pre-decoding converter, the decoder and the post-decoding converter to perform stream processing on the third business message to obtain a fourth business message; call the determined internal outputter to output the fourth business message through a corresponding interface.
3. The encoding and decoding device according to claim 2, characterized in that: The general encoding and decoding module is used to determine the pre-decoding converter, the decoder, the post-decoding converter and the internal outputter corresponding to the configuration information from the pre-decoding converter cluster, the decoder cluster, the post-decoding converter cluster and the internal outputter cluster respectively; The pre-decoding converter cluster includes at least one of the following pre-decoding converters: Bytes2Binary, used to convert a byte stream into a binary format; Bytes2XML, used to convert a byte stream into an XML format; Passthrough, used to allow data to pass directly; XML2XML, used to convert XML format into XML format; The decoder cluster includes at least one of the following decoders: BinaryCodec, calling a binary decoder for decoding; XMLCodec, calling an XML decoder for decoding; The post-decoding converter cluster includes at least one of the following post-decoding converters: Binary2Dds, used to convert binary format into DDS message format; XML2Dds, used to convert XML format into DDS message format; The internal output device cluster includes at least one of the following internal output devices: DdsOutput, which is used for transmission using the DDS protocol.
4. The encoding and decoding device according to claim 2, characterized in that: The general encoding and decoding module is further used to obtain information content and an identifier from the third service message before performing stream processing on the third service message; and encapsulate the information content and the identifier into a standard data structure.
5. A coding and decoding method, characterized in that: The encoding and decoding method is applied to an encoding and decoding device, which is located in a network management device and is responsible for encoding and decoding messages of each managed node; The network management device is connected to each managed node, and the managed node is a shipborne device; the encoding and decoding method includes: Acquire a first service message, where the first service message is a service message generated for a managed node; Acquire configuration information corresponding to the managed node based on the first service message, where the configuration information includes an encoding method and a transmission protocol; Determine a pre-coding converter, an encoder, a post-coding converter and an external outputter corresponding to the configuration information; the pre-coding converter and the post-coding converter are used to convert the coding format; the encoder is used to encode various formats; the external outputter is used to transmit messages using a protocol interface; Calling the determined pre-encoding converter, encoder, and post-encoding converter to perform stream processing on the first service message to obtain a second service message; Calling the determined external exporter to output the second service message to the managed node through a corresponding interface; The determining of a pre-encoding converter, an encoder, a post-encoding converter, and an external outputter corresponding to the configuration information comprises: Determine, from the pre-encoding converter cluster, the encoder cluster, the post-encoding converter cluster, and the external outputter cluster, respectively, the pre-encoding converter, the encoder, the post-encoding converter, and the external outputter cluster corresponding to the configuration information; The pre-encoding converter cluster includes at least one of the following pre-encoding converters: XML2Binary, used to convert XML format into binary format; XML2XML, used to convert XML format into XML format; The encoder cluster includes at least one of the following encoders: BinaryCodec, calling a binary encoder for encoding; XMLCodec, calling an XML encoder for encoding; The post-encoding converter cluster includes at least one of the following post-encoding converters: Binary2File, used to convert binary format into file format; Binary2Udp, used to convert binary format into UDP message format; XML2Dds, used to convert XML format into DDS message format; XML2File, used to convert XML format into file format; XML2Udp, used to convert XML format into UDP message format; The external output device cluster includes at least one of the following external output devices: DdsOutput, used for transmission using the DDS protocol; UdpOutput, used for transmission using the UDP protocol; StringFileOutput, used for transmission using the StringFile protocol; BinaryFileOutput, used for transmission using the BinaryFile protocol; FtpOutput, used for transmission using the FTP protocol; DdsTimerOutput, used for transmission using the timed DDS protocol; UdpTimerOutput, used for transmission using the timed UDP protocol; The method further comprises: Before performing flow processing on the first service message, obtain information content and identification from the first service message; use the encoding preprocessing cluster Formatter to encapsulate the information content and the identification into a standard data structure, and store it in the container content of the flow processing component flow; The encoding and decoding device is also configured with an encoding interface tool cluster Util, which includes various interface tools and configuration tool classes required for encoding, and the interface tools include interface tools related to the communication protocol; when the encoding and decoding device is working, it finds the configuration information according to the identifier, takes out suitable instances from each of the encoding interface tool clusters, and cooperates with the stream processing component flow to perform encoding and decoding of a unified process.
6. The method according to claim 5, characterized in that The method further comprises: Receiving a third service message sent by the managed node; Acquire configuration information corresponding to the managed node based on the third service message, where the configuration information includes a decoding method; Determining a pre-decoding converter, a decoder, a post-decoding converter, and an internal outputter corresponding to the configuration information; Calling the determined pre-decoding converter, decoder, and post-decoding converter to perform stream processing on the third service message to obtain a fourth service message; The determined internal output device is called to output the fourth service message through a corresponding interface.
7. A coding and decoding device, characterized in that: The encoding and decoding device includes a processor and a memory, the memory stores at least one program code, and the program code is loaded and executed by the processor to implement the encoding and decoding method as claimed in claim 5 or 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one program code, and the program code is loaded and executed by a processor to implement the encoding and decoding method according to claim 5 or 6.
