Message bus based ship communication method and system
By using a message bus-based communication method and system, the problem of low data processing efficiency in existing technologies is solved, adaptive protocol identification and configuration are realized, data communication efficiency and system compatibility are improved, and the flexibility and maintainability of ship communication systems are enhanced.
Patent Information
- Application Number
- CN202411860688.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2044-12-17
AI Technical Summary
Existing ship communication systems suffer from low data processing efficiency and difficulty in effectively processing data from multiple communication methods and protocols because they are fixed to specific communication protocols and processing algorithms.
A message bus-based communication method is adopted to realize data interaction between the main application and external systems and internal modules through software drivers. Adaptive protocol identification and configuration are achieved by combining manual configuration and pattern recognition. A communication protocol class library is designed to adapt to device drivers of different operating systems, and the message bus mechanism is used to realize data interaction between internal modules.
It improves data communication and processing efficiency, enhances system compatibility and flexibility, allows adding or removing software drivers without restarting the system, simplifies maintenance, and enables collaborative work between different components.
Smart Images

Figure CN119814819B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of ship communication, in particular to a ship communication method and system based on a message bus. BACKGROUND
[0002] In the field of industrial automation, the front end displays the data from the back end through the control display, shows the process data and state information, displays the abnormal situation in time, and realizes the process monitoring. The front end data source is based on the back end business logic layer processing, and the back end needs to communicate with a plurality of external devices, and these devices select different communication modes and customize different communication protocols.
[0003] With the development of industrial automation technology, a plurality of communication modes and communication protocols coexist, which has become the norm. How to uniformly process and display the data of these different protocols to the user has become a challenge. However, the existing data processing framework usually fixedly supports a specific set of communication protocols and data processing algorithms, resulting in low data processing efficiency. SUMMARY
[0004] The purpose of the present application is to overcome the technical problem of low data processing efficiency caused by the fact that the prior art only fixedly supports a specific communication protocol and processing algorithm. Another purpose of the embodiments of the present application is to provide a ship communication system based on a message bus.
[0005] Technical scheme: The ship communication method based on a message bus provided by the embodiments of the present application is applied to a ship communication system, and the method comprises:
[0006] setting a software driver, wherein the software driver is independent of a main application program of the ship communication system;
[0007] realizing data interaction between the main application program and an external system through the software driver;
[0008] realizing data interaction between the main application program and each software module inside the ship communication system based on a message bus mechanism;
[0009] adaptively identifying an external communication protocol through a manual configuration mode and / or a mode recognition mode;
[0010] and configuring the protocol after identifying the external communication protocol.
[0011] In some embodiments, the data interaction between the main application program and the external system through the software driver comprises:
[0012] defining a communication protocol class library;
[0013] Interact with the external system through the communication protocol library.
[0014] In some embodiments, the data interaction between the communication protocol library and the external system includes:
[0015] Defining communication methods and communication protocols;
[0016] Designing a communication protocol library Lib;
[0017] Setting up an adapter and converting device drivers under different operating systems into a universal interface in the communication protocol library Lib through the adapter.
[0018] In some embodiments, the design of the communication protocol library Lib includes:
[0019] Defining communication identifiers, communication protocol base classes, custom communication protocols, device module base classes, device module derived classes, and communication devices;
[0020] Sending and receiving data packets through the device module base class;
[0021] Storing relevant information about communication through the communication identifier;
[0022] Serializing and deserializing data packets through the communication protocol base class;
[0023] Through the custom communication protocol, the specific serialization and deserialization rules of the custom protocol are implemented to achieve encapsulation and parsing;
[0024] Using a device module library through the device module derived class to handle the communication device.
[0025] In some embodiments, the communication device and the device module base class are in a composition relationship;
[0026] The communication device and the communication identifier are in a composition relationship;
[0027] The communication identifier and the communication protocol base class are in a dependency relationship;
[0028] The custom communication protocol and the communication protocol base class are in an inheritance relationship;
[0029] The device module derived class and the module base class are in an inheritance relationship.
[0030] In some embodiments, the message bus mechanism is used to realize data interaction between the main application and various software modules inside the ship communication system, including:
[0031] The main application program realizes bidirectional data interaction with each software module inside the ship communication system; each software module is divided according to functional requirements and exchanges information with the main application program by subscribing and publishing messages of preset topics. In this process, the main application program and each software module can act as a producer or a consumer in the message bus according to specific application scenarios.
[0032] In some embodiments, the application scenarios of the external communication protocol include a field-determined protocol and a dynamically changing protocol.
[0033] The adaptive protocol identification of the external communication protocol through the manual configuration mode and / or the mode recognition mode includes:
[0034] The field-determined protocol adopts the manual configuration mode.
[0035] The dynamically changing protocol adopts the mode recognition mode; wherein the mode recognition mode includes defining a protocol data packet format, judging a special field of a data frame, matching a preset protocol library, analyzing content of a data area, establishing an extended protocol library, and updating the preset protocol library.
[0036] In some embodiments, the types of the external communication protocol at least include an Ethernet communication protocol, a CAN communication protocol, and a serial port communication protocol.
[0037] In some embodiments, when the type of the external communication protocol is the Ethernet communication protocol, the field-determined protocol adopts the manual configuration mode, including manually configuring start, length, and address data items; automatically generating data items of a measurement point name, a measurement point type, a station ID, a module ID, a point number, and a database ID after completing point selection; and respectively identifying start bits, bit lengths, and register addresses in a Modbus TCP / IP protocol by start, length, and address.
[0038] The dynamically changing protocol adopts the mode recognition mode, including identifying the dynamically changing protocol by defining a protocol data packet format; wherein the data packet format includes a data packet frame header, an information unit frame header, an information unit body, and an information coding rule.
[0039] In some embodiments, when the type of the external communication protocol is the CAN communication protocol, the field-determined protocol adopts the manual configuration mode, including manually selecting associated measurement points in the protocol; automatically generating data items of a measurement point name, a type, a station ID, a module ID, a point number, and a database ID after completing point selection; manually configuring address, length, and frame ID content; and respectively identifying start bits, bit lengths, and frame IDs in the CAN protocol by start, length, and frame ID.
[0040] The pattern recognition method used for the dynamically changing protocol includes: combining frame ID and data body to define data packet format and data frame type to identify the dynamically changing protocol.
[0041] In some embodiments, when the type of the external communication protocol is a serial communication protocol, the protocol determined by the field adopts the manual configuration method, including: manually configuring the address and data type; the measurement point type, station ID, module ID, point number, and database ID are automatically generated after the point selection is completed; and the start bit, length, and register address in the Modbus RTU protocol are identified respectively.
[0042] The pattern recognition method used for the dynamically changing protocol includes: identifying the dynamically changing protocol by defining frame headers and verification rules.
[0043] Accordingly, the ship communication system based on a message bus described in this application includes:
[0044] The configuration module is used to configure the software driver; wherein the software driver is independent of the main application program of the ship communication system.
[0045] The first data interaction module is used to realize data interaction between the main application and external systems through the software driver;
[0046] The second data interaction module is used to realize data interaction between the main application and various software modules inside the ship communication system based on the message bus mechanism;
[0047] The protocol identification module is used to adaptively identify external communication protocols through manual configuration and / or pattern recognition.
[0048] The protocol configuration module is used to configure the protocol after identifying the external communication protocol.
[0049] Beneficial effects: compared with the prior art, the ship communication method and system based on a message bus provided in the embodiments of the present application, the ship communication method based on a message bus comprises: setting a software driver; wherein the software driver is independent of a main application program of a ship communication system; data interaction between the main application program and an external system is realized through the software driver; data interaction between the main application program and various software modules inside the ship communication system is realized based on a message bus mechanism; adaptive protocol recognition of an external communication protocol is performed through a manual configuration mode and / or a mode recognition mode; and protocol configuration is performed after the external communication protocol is recognized. By introducing the concept of a software driver, the present application realizes data interaction between the main application program and the external system, and the software driver can be added or removed without restarting the system, which does not affect the application of the main application program, thereby improving the efficiency of data communication and data processing. And through the message bus mechanism, data interaction inside the ship communication system is realized, and the collaborative work between different components is realized. And through the manual configuration mode and / or the mode recognition mode, adaptive protocol conversion and recognition of the external communication protocol is performed, which is converted into a unified format, enhancing the compatibility and flexibility of the software and improving the efficiency of data processing. BRIEF DESCRIPTION OF DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0051] Figure 1 is a flowchart of a ship communication method based on a message bus provided in the embodiments of the present application;
[0052] Figure 2 is a UML diagram of a communication protocol library provided in the embodiments of the present application;
[0053] Figure 3 is a flowchart of data interaction between a main application program and various software modules provided in the embodiments of the present application;
[0054] Figure 4 is another flowchart of data interaction between a main application program and various software modules provided in the embodiments of the present application;
[0055] Figure 5 is a mode recognition flowchart provided in the embodiments of the present application;
[0056] Figure 6 is a mode recognition timing diagram provided in the embodiments of the present application;
[0057] Figure 7 is a schematic diagram of manual configuration of Modbus TCP / IP protocol provided in embodiments of the present application;
[0058] Figure 8 is a schematic diagram of manual configuration of CAN communication protocol provided in embodiments of the present application;
[0059] Figure 9 is a schematic diagram of manual configuration of Modbus RTU serial communication protocol provided in embodiments of the present application;
[0060] Figure 10 is a schematic diagram of principle structure of a ship communication system based on message bus provided in embodiments of the present application.
[0061] Reference signs:
[0062] 10 - setting module; 20 - first data interaction module; 30 - second data interaction module; 40 - protocol identification module; 50 - protocol configuration module; 100 - ship communication system based on message bus. DETAILED DESCRIPTION
[0063] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0064] It should be understood that although the terms first, second, etc. can be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another component. Therefore, the first component discussed below can be called the second component without departing from the teachings of the present application. As used herein, the term "and / or" includes any combination of the associated listed items and one or more of the items.
[0065] Those skilled in the art can understand that the drawings are only schematic diagrams of example embodiments and can not be to scale. The modules or flows in the drawings are not necessarily essential for implementing the present application, and therefore cannot be used to limit the scope of protection of the present application.
[0066] Figure 1 is a flowchart of a ship communication method based on message bus provided in embodiments of the present application. The method can be applied to the process of efficiently processing data of various communication protocols in a ship management system. The method can be executed by a ship communication system based on message bus, which can be implemented by software and / or hardware, and can be configured in a processor of a ship management platform. Please refer toFigure 1 The method comprises the following steps:
[0067] Step 110, setting a software driver; wherein the software driver is independent of a main application program of the ship communication system.
[0068] The software driver is similar to the hot plug function of the hardware driver, and the software driver can be added or removed without restarting the system.
[0069] Step 120, realizing data interaction between the main application program and an external system through the software driver.
[0070] The external system is a database, a third-party service, a hardware device, or the like.
[0071] Specifically, there is interaction between the ship communication system and the external system, and the business logic of this part is abstracted into a "software driver" similar to a hardware driver program. The "software driver" interacts with the external system in terms of "data".
[0072] The "data" can be a data packet of communication or a signal stream collected.
[0073] Because there are differences between device components (such as API calls, file formats, device drivers, and the like) of different operating systems or platforms, the adapter function (which can also be defined as a "software driver") is used to convert the customized interface into a unified interface. When the application scene is increased or the third-party device is added, the core code of the main application program does not need to be modified. Therefore, the application can run on different operating systems, adapt to multiple third-party hardware devices, improve the compatibility and portability of the software, and developers do not need to write specific codes for each operating system, thereby reducing the development and maintenance workload.
[0074] The "software driver" can run independently of the main application program, allowing hardware or software to be dynamically added or removed without affecting the service of the main application program. Therefore, the part interacting with the external system is abstracted and designed in a form that is easy to replace and upgrade, and the adapter ensures that these interaction modules can be compatible with different environments, thereby not only enhancing the flexibility and expansibility of the system, but also simplifying the maintenance work.
[0075] Step 130, realizing data interaction between the main application program and each software module inside the ship communication system based on a message bus mechanism.
[0076] The each software module inside the ship communication system can include various business logics.
[0077] Specifically, the main application (MainApp) program and business logic (logic1Lib, logic2Lib), between each business logic (logic1Lib, logic2Lib) through the message bus (msgBus) to achieve data interaction.
[0078] According to different functional requirements, the main application program and business logic define topics (topic), each topic corresponds to a type of message. For example, the communication event is defined as communicateTopic, and the data acquisition event is defined as acquisitionTopic.
[0079] Among them, the message bus as a communication hub, each software module (such as MainApp, logic1Lib, logic2Lib) through the subscription-published topic and send / receive messages to carry out data transmission, reduces the absolute dependence between modules, makes the system flexible, easy to maintain.
[0080] Step 140, the external communication protocol is adaptively identified by manual configuration mode and / or pattern recognition mode.
[0081] Among them, the external communication protocol mainly contains three types of Ethernet communication, CAN communication and serial communication. Although the three types are based on different hardware devices, but the protocol identification can be based on data load (data frame structure and field).
[0082] Among them, the protocol identification includes two ways: manual configuration mode and pattern recognition mode.
[0083] Step 150, after identifying the external communication protocol, the protocol configuration is carried out.
[0084] Specifically, after identifying the external communication protocol, the data serialization method is used for protocol configuration.
[0085] Among them, data serialization refers to the process of converting data structure or object state into continuous byte stream. Byte stream can be visualized through configuration tools. For example, taking CAN communication protocol as an example, the CAN communication protocol visualized data stream structure is as follows: field definition, start bit, length (unit bit), frame ID.
[0086] The technical scheme of the embodiment of the application realizes the communication of the ship through the following aspects: first, a software driver is arranged to realize an independent driving architecture, and a software driver layer independent of the main application program is designed and realized, which directly interacts with the hardware interface as a middleware. This architecture allows dynamic loading or unloading of hardware drivers without interfering with the main application program, improving the flexibility and stability of the system. Second, data interaction is realized, and the external system is connected. By using the above software driver, a stable and efficient communication link from the main application program to the external system is established. This includes but is not limited to network connection, serial, CAN communication, etc. Third, message bus mechanism, publish / subscribe model: a publish / subscribe (Pub / Sub) message delivery mode is adopted, so that each software module in the ship communication system can send and receive information through the message bus. This way decouples the direct dependency relationship between different components, enhancing the scalability and maintainability of the system. Asynchronous processing: all data transmitted through the message bus adopts an asynchronous processing mechanism, ensuring that even in the case of a long processing time of a module, the operation of other modules will not be blocked, thereby improving the overall performance. Fourth, adaptive cooperative identification, pre-defined rule library: a rule library containing the characteristics of multiple common communication protocols is constructed as the basis for pattern recognition. Whenever a new external protocol is encountered, the system will try to match the entries in this rule library to quickly identify it. Machine learning enhancement: for unknown or non-standard protocols, machine learning algorithms are integrated to help automatically infer the protocol structure, and the rule library is continuously updated to adapt to new situations that may occur in the future. Fifth, protocol configuration, automatic configuration process: once the external communication protocol is successfully identified, the system will automatically complete the necessary configuration work according to the preset strategy, such as setting default parameter values, creating mapping tables, etc. User-friendly configuration: provide an intuitive graphical user interface (GUI) to allow administrators to easily complete manual configuration of external communication protocols, including setting important parameters such as addresses, data types, etc. Configuration file generation: generate standardized XML format configuration files for future review, modification and backup. At the same time, these configurations can also be exported to other similar environments for use.
[0087] In the technical scheme of the embodiment, the working principle of the ship communication method based on the message bus is as follows: Figure 1Firstly, a software driver is set, wherein the software driver is independent of a main application program of the ship communication system. Then, data interaction between the main application program and an external system is realized through the software driver. Secondly, based on a message bus mechanism, data interaction between the main application program and various software modules inside the ship communication system is realized. Adaptive protocol conversion and identification of the external communication protocol are realized through a manual configuration mode and / or a mode identification mode. Finally, protocol configuration is performed after the external communication protocol is identified. Therefore, by introducing the software driver concept, the data interaction between the main application program and the external system is realized, the software driver can be added or removed without restarting the system, and the application of the main application program is not affected, so that the efficiency of data communication and data processing can be improved. And the data interaction inside the ship communication system is realized through the message bus mechanism, and the collaborative work between different components is realized. And adaptive protocol conversion and identification of the external communication protocol are realized through the manual configuration mode and / or the mode identification mode, which is converted into a unified format, enhancing the compatibility and flexibility of the software and improving the efficiency of data processing.
[0088] In some embodiments, the data interaction between the main application program and the external system is realized through the software driver, including: defining a communication protocol class library; and realizing data interaction with the external system through the communication protocol class library.
[0089] Specifically, the communication protocol class library Lib is defined, and the main application program realizes data interaction with the external system through the library Lib without concerning the specific implementation of the communication business logic. Therefore, when the application scenario is increased or the third-party device is added, the core code of the main application program does not need to be modified, the compatibility and portability of the software are improved, and the development and maintenance workload is reduced.
[0090] In some embodiments, the data interaction with the external system through the communication protocol class library includes: defining a communication mode and a communication protocol; designing the communication protocol class library Lib; setting an adapter, and converting device drivers under different operating systems into a general interface in the communication protocol class library Lib through the adapter.
[0091] Specifically, the communication protocol class library Lib is defined, and the main application program realizes data interaction with the external system through the library Lib without concerning the specific implementation of the communication business logic. The communication includes a communication mode and a communication protocol. The communication mode is composed of a communication type and a communication mode, wherein the communication type is related to the operating system and the hardware interface. The communication protocol is used to describe the text structure of the data frame. The adapter converts the device drivers under different operating systems into the general interface in the library Lib, so that different types of components can work collaboratively.
[0092] In some embodiments, a communication protocol class library Lib is designed, including: defining a communication identifier, a communication protocol base class, a custom communication protocol, a device module base class, a device module derived class, and a communication device; sending and receiving data packets through the device module base class; storing relevant information of the communication through the communication identifier; serializing and deserializing data packets through the communication protocol base class; through the custom communication protocol, implementing encapsulation and parsing according to specific serialization and deserialization rules of the custom protocol; and through the device module derived class, using the device module library to process the communication device.
[0093] In some embodiments, the device module derived class can be a Zhou Ligong CAN module. For example, the Zhou Ligong CAN module is used to process CAN communication through the Zhou Ligong CAN library.
[0094] In some embodiments, the communication identifier is a class CommunicationInfo, the communication protocol base class is an abstract DataPacketStrategy interface, the custom communication protocol is a custom class customDataPacketStrategy, the device module base class is an abstract base class DevModule, the Zhou Ligong CAN module is a derived class ZLGCanModule, and the communication device is a class DevCommunication.
[0095] Figure 2 In some embodiments, a standardized Unified Modeling Language (UML) diagram of a communication protocol class library libProtocolDatastructure is provided. For example, the class CommunicationInfo, the abstract DataPacketStrategy interface, the custom class customDataPacketStrategy, the abstract base class DevModule, the derived class ZLGCanModule, and the class DevCommunication are defined as shown in FIG. 1. Figure 2
[0096] In some embodiments, the class CommunicationInfo is defined, and the attributes and methods are as shown in Table 1. The strategy pattern is used, and different instances of CommunicationInfo select matching encapsulation and parsing strategies.
[0097] Table 1: Class CommunicationInfo
[0098]
[0099] Wherein, define an abstract DataPacketStrategy interface, create corresponding strategy classes based on different communication protocols, and implement the DataPacketStrategy interface. The parameters of the abstract DataPacketStrategy interface are shown in Table 2.
[0100] Table 2 Parameters of the abstract DataPacketStrategy interface
[0101]
[0102]
[0103] Wherein, the custom class customDataPacketStrategy is used to implement specific encapsulation and parsing rules. The parameters of the custom class customDataPacketStrategy are shown in Table 3.
[0104] Table 3 Parameters of the custom class customDataPacketStrategy
[0105] Field Name Type Meaning serialize() QByteArray Serialization protocol serializeQlist() QList <qbytearray> < / qbytearray> Serialization protocol parseQVector(const QByteArray&) QVector <datapoint> < / datapoint> Parsing protocol queryProtocols Bool Protocol identification
[0106] Wherein, define an abstract base class DevModule. Create specific subclasses based on device drivers under different operating systems, and create derived classes. Take the ZLG CAN device driver as an example, create the ZLGCanModule derived class, and add adapter functions to complete the interface conversion between third-party libraries and abstract base classes. The parameters of the abstract base class DevModule are shown in Table 4.
[0107] Table 4 Parameters of the abstract base class DevModule
[0108] Field Name Type Meaning DevOpen() virtual int Device opening DevClose() virtual int Device closing DevInit() virtual int Device initialization DevStart() virtual int Device starting DevReset() virtual int Device resetting DevSend() virtual int Data sending DevReceive() virtual int Data receiving DevRMClearRecBuf() virtual int Buffer clearing DevReadErrInfo() virtual int Error information retrieval
[0109] Wherein, the parameters of the derived class ZLGCanModule are shown in Table 5.
[0110] Table 5 Parameters of the derived class ZLGCanModule
[0111]
[0112]
[0113] Wherein, the parameters of the class DevCommunication are shown in Table 6.
[0114] Table 6 Parameters of the class DevCommunication
[0115] Field Name Type Meaning module DevModule Communication device info CommunicationInfo Communication information send() void Sending data packet receive() void Receiving data packet processSendData() void Serialization data processReceivedData() void Processing data
[0116] In some embodiments, the communication device and the device module base class are in a composition relationship; the communication device and the communication identification are in a composition relationship; the communication identification and the communication protocol base class are in a dependency relationship; the custom communication protocol and the communication protocol base class are in an inheritance relationship; the device module derived class and the module base class are in an inheritance relationship.
[0117] For example, the device module derived class is a ZLG CAN module, and the ZLG CAN module and the device module base class are in an inheritance relationship.
[0118] For example, the class DevCommunication and the abstract base class DevModule are in a composition relationship; the class DevCommunication and the class CommunicationInfo are in a composition relationship; the class CommunicationInfo and the abstract DataPacketStrategy interface are in a dependency relationship; the custom class customDataPacketStrategy and the abstract DataPacketStrategy interface are in an inheritance relationship; the derived class ZLGCanModule and the abstract base class DevModule are in an inheritance relationship.
[0119] In which, the class DevCommunication and the abstract base class DevModule are in a composition relationship. The class DevCommunication contains an instance of the abstract base class DevModule, and uses it to send and receive data packets.
[0120] In which, the class DevCommunication and the class CommunicationInfo are in a composition relationship. The class DevCommunication contains an instance of the class CommunicationInfo, which is used to store the relevant information of the communication; contains a pointer to the abstract DataPacketStrategy interface, which is used to serialize and deserialize data packets.
[0121] The class CommunicationInfo is dependent on the abstract DataPacketStrategy interface. The class CommunicationInfo uses the abstract DataPacketStrategy interface to send and receive. The DataPacketStrategy is a communication protocol base class, and according to the content of the communication protocol, the software module will derive a class. For example, modbusDataPacketStrategy is used to process the modbus communication protocol, and receives and sends data as the master station or slave station of the communication party. For example, the project defines a can interface-based industry standard protocol, and derives a canHBDataPacketStrategy, which is used to process the HB communication protocol and receive uplink data and send downlink data.
[0122] The custom class CustomDataPacketStrategy inherits from the abstract DataPacketStrategy interface. The custom class CustomDataPacketStrategy provides specific serialization and deserialization rules for custom protocols, and realizes encapsulation and parsing.
[0123] The derived class ZLGCanModule inherits from the abstract base class DevModule. The derived class ZLGCanModule provides a specific CAN module implementation provided by the Window operating system, and uses the ZLG CAN library to process CAN communication.
[0124] In some embodiments, based on the message bus mechanism, the data interaction between the main application and each software module in the ship communication system is realized, including: the main application and each software module in the ship communication system realize bidirectional data interaction; each software module is divided according to the functional requirements, and exchanges information with the main application by subscribing and publishing messages of a preset topic. In this process, the main application and each software module can act as a producer or a consumer in the message bus according to the specific application scenario.
[0125] The preset topic can be a specific topic, which can be set according to actual conditions and is not limited here.
[0126] The main application program and each software module in the ship communication system realize bidirectional data interaction. Each software module is divided according to the functional requirements, and exchanges information with the main application program by subscribing and publishing messages of specific topics. In this process, the main application program and each software module can act as a producer (publishing messages) or a consumer (subscribing messages) in the message bus according to the specific application scenario. The messages of different topics determine the role conversion of each software module, ensuring the effective transmission and processing of information in the system.
[0127] Since the main application program and the software module are bidirectional data / message interaction, the roles of the main application program and the software module in the bus are different according to the messages of different topics. Specifically, there are two cases.
[0128] First, the main application is the consumer, and the software module is the producer. The producer is each software module, which is responsible for interacting with external devices, publishing messages in the message queue, including data communication and data acquisition, and the data communication is taken as an example in the embodiment of the application. The message queue: as middleware, buffers asynchronous messages of multiple producers. Based on CAN, Ethernet, and serial communication interface, data is received, and it is ensured that these messages can be reliably transmitted to the consumer. The consumer is the main application program, which is responsible for the front-end application, realizes data display and user interaction, subscribes messages in the message queue, and updates the interface or responds to user operations according to the received data. Callback function: when a specific event occurs (such as new data arrival), the producer calls the pre-registered callback function to notify the consumer that there is new data to be processed.
[0129] Second, the main application program is the producer, and the software module is the consumer. The producer is the main application program, which is responsible for the front-end application, realizes user interaction, and publishes messages in the message queue. The message queue: as middleware, distinguishes different topics, transmits user control instructions or query instructions, and ensures that the messages can be transmitted to the corresponding consumer. The consumer is each software module, which is responsible for interacting with external devices, subscribing messages in the message queue, and transmitting user control instructions or query instructions to external devices based on CAN, Ethernet, and serial communication interface. Callback function: when a specific event occurs (such as instruction sending is completed), the producer calls the pre-registered callback function to notify the consumer that there is new data to be processed.
[0130] Specifically, the specific work flow of the two cases is as follows:
[0131] Figure 3 is a flowchart of data interaction between the main application program and each software module provided in the embodiment of the application. When the main application program is the consumer, and the software module is the producer, please refer to Figure 3The specific workflow is as follows: a) initialization, the main application is started, initialization configuration parameters, set UI components, etc., complete initialization. Each software module reads the protocol configuration, completes the initialization work, and establishes a connection with the external device. Set up the message queue, define the message topic, and ensure that each message topic can receive messages from different categories of producers. b) producer work, each producer module continuously monitors the communication state of the corresponding external device: CAN, Ethernet, serial port. After receiving the data and completing the protocol identification, the producer packs the data into a message format and sends it to the message queue. c) message delivery, after the message enters the queue, it is sorted according to the queue strategy (such as FIFO, priority, exemplary, the embodiment of the application adopts FIFO). The message queue manager is responsible for distributing messages to subscribed consumers and the main application. d) consumer processing, the main application as a consumer, obtains the latest data update from the message queue. According to the received message content, update the corresponding chart, table or other visual elements on the UI. e) callback mechanism, when the producer completes the task and expects to know the result, register a callback function. The consumer completes the processing of the message (such as updating the UI), triggers the callback function, and informs the producer that the message has been successfully processed or has encountered a problem. f) user interaction, the user can view the status information through the interface provided by the main application.
[0132] Figure 4 is another process diagram of data interaction between the main application and each software module provided in the embodiment of the application. When the main application is a producer and the software module is a consumer, please refer to Figure 4The specific workflow is as follows: a) initialization, the main application program is started, initialization configuration parameters, set UI components, and the like, and initialization is completed. Each software module reads the protocol configuration, completes the initialization work, and establishes a connection with an external device. The message queue is set, the message topic is defined, and it is ensured that each message topic can be sent to different categories of consumers. b) user interaction, the user can send control and query instructions through the interface provided by the main application program, and the user input is converted into a message and placed in the queue. c) producer work, the producer module packs the control and query instructions into a message format and sends them to the message queue. d) message delivery, after the message enters the queue, it is sorted according to the queue strategy (such as FIFO, priority, exemplary, and the FIFO is adopted in the embodiment of the application). The message queue manager is responsible for distributing the messages to the subscribed consumers and software modules according to the topic. e) consumer processing, each software module obtains the latest message from the message queue, judges whether the received message content is a query instruction or a control instruction, and transmits it to the external device based on the CAN, Ethernet, and serial communication interface. f) callback mechanism, when the producer completes the task and expects to know the result, a callback function is registered. The consumer completes the processing of the message (such as sending an instruction), triggers the callback function, and informs the producer that the message has been successfully processed or has encountered a problem.
[0133] The specific implementation steps of the message queue and message processing include: adding an enumeration type identifier (type) to the message to distinguish the message category; the message sender encapsulates the message and sends the encapsulated message to the message processing thread; the message processing thread delivers the message to the message receiver according to the message type (type) and the receiver (recverId); and the message receiver parses the message content. The key-value pair (Key-ValuePair) data structure is constructed as the message data (msgData), the key is a system unique identifier, the value associated with the key is an object, and the object includes the attributes of value, alarm, limit, and the like. The parameters of the message Message structure are defined as shown in Table 7.
[0134] Table 7 Parameters of the message Message structure
[0135] Field Name Type Meaning type enum Identifying the category or purpose of the message senderId QString Identifying the sender of the message recverId QString Identifying the receiver of the message msgData QVariant Carried message content
[0136] In some embodiments, the application scenarios of the external communication protocol include a field-determined protocol and a dynamically changed protocol; the adaptive protocol identification of the external communication protocol is performed in a manual configuration manner and / or a mode recognition manner, including: the field-determined protocol is identified in the manual configuration manner; the dynamically changed protocol is identified in the mode recognition manner; wherein the mode recognition manner includes: defining a protocol data packet format, judging a special field of a data frame, matching a preset protocol library according to a feature, analyzing a data area content, establishing an extended protocol library, and updating the preset protocol library.
[0137] The manual configuration manner is suitable for a scenario in which a data frame field is explicit. The mode recognition manner (or the mode matching manner) is suitable for a scenario in which a data frame field changes. When the definition is determined, the protocol is configured through a protocol configuration tool. Generally, a protocol clearly defines a protocol data packet format, including the meaning, position, length, and check rule of each field. The mode recognition manner defines a field (such as a frame header, a protocol number, and an end symbol) with a specific meaning as a feature field, and determines the protocol to which a flow belongs by matching the feature field with a field in data load.
[0138] The manual configuration manner is suitable for a scenario in which a data frame field is explicit. The mode recognition manner (or the mode matching manner) is suitable for a scenario in which a data frame field changes. When the definition is determined, the protocol is configured through a protocol configuration tool. Generally, a protocol clearly defines a protocol data packet format, including the meaning, position, length, and check rule of each field. The mode recognition manner defines a field (such as a frame header, a protocol number, and an end symbol) with a specific meaning as a feature field, and determines the protocol to which a flow belongs by matching the feature field with a field in data load.
[0139] Table 8 enumeration value
[0140]
[0141] Figure 5 FIG. 1 is a schematic diagram of a mode recognition process provided in an embodiment of the present application, Figure 6 FIG. 2 is a timing diagram of mode recognition provided in an embodiment of the present application. Please refer to Figure 5 and Figure 6The specific implementation process of the mode recognition is as follows: first, defining a protocol data packet format: the data processing module first defines a data packet frame header, an information unit frame header, an information unit body, and an information coding rule, which is the basis for analyzing data. Then, judging the special field of the data frame: according to the defined protocol data packet format, the module checks whether the multiple special fields of the data frame meet the coding specifications to determine the data exchange protocol followed by the message. Secondly, matching the preset protocol library: the module extracts the features of the data frame according to the protocol features set in the preset protocol library, and judges whether the extracted features match the protocol features set in the preset protocol library. If yes, parsing the data area content: if the feature matching is successful, the module will parse the data area content according to the matched protocol, complete the data analysis and processing. If not, establishing an extended protocol library: if the feature matching fails, the module will establish an extended protocol library according to the extracted features, and add it to the preset protocol library to update, so as to support more types of data exchange protocols. And updating the preset protocol library: adding the new extended protocol library to the preset protocol library, so that the module can identify and process more protocol types.
[0142] In some embodiments, the types of external communication protocols include at least an Ethernet communication protocol, a CAN communication protocol, and a serial communication protocol.
[0143] It should be noted that the types of external communication protocols can also be other communication protocols, which are not specifically limited.
[0144] In some embodiments, when the type of the external communication protocol is the Ethernet communication protocol, the protocol determined by the field adopts a manual configuration mode, including: manually configuring the start, length and address data items; the measurement point name, measurement point type, station ID, module ID, point number and database ID data items are automatically generated after the selection of points is completed; the start, length and address respectively identify the start bit, bit length and register address in the Modbus protocol; the dynamically changing protocol adopts a mode recognition mode, including: defining a protocol data packet format to recognize the dynamically changing protocol; wherein the data packet format includes: a data packet frame header, an information unit frame header, an information unit body, and an information coding rule.
[0145] For example, the protocol determined by the field can be a standard Modbus protocol.
[0146] Specifically, for the type of external communication protocol is Ethernet communication protocol, the identification principle of Ethernet communication protocol is: according to whether the data text field is fixed, the identification method is divided into manual configuration and pattern recognition, for the protocol with fixed data text field, manual configuration is used, and for the protocol with dynamic data text, pattern recognition is used. The specific process is: after communication is established, it is firstly judged whether the data text matches the manually configured protocol, if yes, the manually configured method is used for processing; if no, it is judged whether it matches the pattern in the protocol library, if no, the protocol library is updated.
[0147] Figure 7 is a schematic diagram of manual configuration of Modbus TCP / IP protocol provided in the embodiment of the application. Specifically, for the protocol with fixed field, such as standard Modbus TCP / IP protocol, manual configuration is as shown in Figure 7 . The manual configuration principle of Ethernet communication protocol is: for the protocol with fixed data text field, such as standard Modbus TCP / IP protocol, when Ethernet is used as the communication medium, manual configuration can be used. The manual configuration process includes: a) configuration, the configuration tool selects the related measuring point, and the measuring point name, measuring point type, station ID, module ID, point number and database id data items are automatically generated after the selection of the point is completed; the start, length and address data items need to be manually configured. The start, length and address data items respectively identify the start bit, bit length and register address in the Modbus protocol. b) initialization, the software module reads the protocol configuration, and completes the basic configuration, such as device IP address, port number, and establishes network connection. c) protocol identification, according to the configuration rule, the Ethernet data of the external device is parsed.
[0148] The mode recognition principle of the Ethernet communication protocol is that a protocol with fixed specific fields and dynamic data text adopts mode recognition. The specific fields are a data packet frame header, an information unit frame header, an information unit text, and an information coding rule. The mode recognition process includes: a) a protocol library, the data packet frame header, the information unit frame header, the information unit rule, and the information coding rule are input into the protocol library; b) initialization, a software module reads the protocol library and completes basic configuration, such as device IP address, port number, and network connection establishment; c) protocol recognition, the module checks whether a plurality of special fields of a data frame match the coding specification; according to the preset protocol characteristics of the protocol library, the module extracts the characteristics of the data frame and judges whether the extracted characteristics match the preset protocol characteristics of the protocol library. If the characteristics match successfully, the module parses the data area content according to the matched protocol, and completes data parsing and processing. If the characteristics do not match successfully, the module establishes an extended protocol library according to the extracted characteristics, and adds the extended protocol library to the preset protocol library for updating, so as to support more types of data exchange protocols. The new extended protocol library is added to the preset protocol library, so that the module can recognize and process more protocol types.
[0149] An example of a specific implementation code of the Ethernet communication protocol for implementing protocol recognition is as follows:
[0150]
[0151]
[0152] In some embodiments, when the type of the external communication protocol is a CAN communication protocol, a protocol with determined fields adopts a manual configuration mode, including: manually selecting associated measuring points in the protocol; automatically generating measuring point name, type, station ID, module ID, point number, and database id data items after the selection of the points is completed; manually configuring address, length, and frame ID content; respectively identifying start bit, bit length, and frame ID in the CAN protocol; and a dynamically changing protocol adopts the mode recognition mode, including: defining data packet format and data frame type in combination with frame ID and data text to recognize the dynamically changing protocol.
[0153] Specifically, when the type of the external communication protocol is a CAN communication protocol, the recognition principle of the CAN communication protocol is that, according to whether the data text field is fixed, the recognition method is divided into manual configuration and mode recognition. A protocol with a determined data text field adopts manual configuration, and a protocol with dynamically changing data text adopts mode recognition. The specific process is as follows: after communication is established, it is first judged whether the data text matches the manually configured protocol. If it matches, the manual configuration mode is adopted for processing. If it does not match, it is judged whether it matches the mode in the protocol library. If it does not match either, the protocol library is updated.
[0154] Figure 8This is a schematic diagram illustrating the manual configuration of a CAN communication protocol provided in an embodiment of this application. For example, for protocols with defined fields, the manual configuration is as follows: Figure 8 As shown. The principle of manual configuration for the CAN communication protocol is as follows: For protocols with defined data text fields, such as the industry-standard CAN protocol, the data frame ID, text field, and measurement point mapping relationship are determined. When using CAN as the communication medium, manual configuration is possible. The manual configuration process includes: a) Configuration: The configuration tool selects relevant measurement points. The measurement point name, measurement point type, station ID, module ID, point number, and database ID data items are automatically generated after point selection. The start, length, and frame ID need to be manually configured. The start, length, and address data items respectively identify the start bit, bit length, and frame ID in the CAN protocol. b) Initialization: The software module reads the protocol configuration, completes basic configuration such as the CAN baud rate, and establishes the CAN connection. c) Protocol recognition: Based on the configuration rules, the CAN data from the external device is parsed.
[0155] The pattern recognition principle for the CAN communication protocol is as follows: For protocols where the mapping relationship between text fields and measurement points is uncertain, but the text encoding rules are certain, pattern recognition is used. Specific fields include the frame ID and encoding rules. The pattern recognition process includes: a) Protocol library: The mapping relationship between frame IDs and encoding rules is entered into the protocol library. b) Initialization: The software module reads the protocol library, completes basic configurations such as the CAN baud rate, and establishes a CAN connection. c) Protocol recognition: The module checks whether multiple special fields of the data frame conform to the encoding specifications; based on the protocol features set in the preset protocol library, it extracts features from the data frame and determines whether the extracted features match the protocol features set in the preset protocol library. If the feature match is successful, the module will parse the data area content according to the matched protocol, completing data parsing and processing. If the feature match fails, the module will build an extended protocol library based on the extracted features and add it to the preset protocol library to update it, supporting more types of data exchange protocols. Adding the new extended protocol library to the preset protocol library allows the module to recognize and process more protocol types.
[0156] For example, the specific implementation code for CAN communication protocol identification is as follows:
[0157]
[0158] Figure 9is a manual configuration diagram of the Modbus RTU serial port communication protocol provided in the embodiments of the present application. In some embodiments, when the type of the external communication protocol is a serial port communication protocol, the protocol determined by the field adopts a manual configuration mode, which includes: manually configuring the address and data type; the measurement point type, station ID, module ID, point number, and database id are automatically generated after the selection of points is completed; the start bit, length, and register address in the Modbus RTU protocol are identified respectively; the protocol that dynamically changes adopts a pattern recognition mode, which includes: identifying the dynamically changing protocol by defining the frame header and the verification rule.
[0159] Specifically, for the type of the external communication protocol being a serial port communication protocol, the identification principle of the serial port communication protocol is: according to whether the data text field is fixed, the identification method is divided into manual configuration and pattern recognition. For the protocol with a fixed data text field, manual configuration is used, and for the protocol with a dynamically changing data text field, pattern recognition is used. The specific process is: after the communication is established, it is first judged whether the data text matches the protocol configured manually. If it matches, the manual configuration mode is used for processing. If it does not match, it is judged whether it matches the pattern in the protocol library. If it does not match either, the protocol library is updated.
[0160] When the type of the external communication protocol is a serial port communication protocol, for the protocol with a fixed field, such as the standard Modbus RTU protocol, the manual configuration is as shown in Figure 9 The manual configuration principle of the serial port communication protocol is: for the protocol with a fixed data text field, such as the standard Modbus RTU protocol, when the serial port is used as the communication medium, the manual configuration mode can be used. The manual configuration process of the serial port communication protocol includes: a) configuration, the configuration tool selects the relevant measurement points, and the measurement point name, measurement point type, station ID, module ID, point number, and database id data items are automatically generated after the selection of points is completed; the start, length, and address data items need to be manually configured. The start, length, and address data items identify the start bit, bit length, and register address in the Modbus RTU protocol respectively. b) initialization, the software module reads the protocol configuration and completes the basic configuration, such as the serial port baud rate, data bits, stop bits, and check bits, and establishes a serial port connection. c) protocol identification, according to the configuration rule, the serial port data of the external device is parsed.
[0161] The mode recognition principle of the serial communication protocol is that the specific field is fixed and the data body dynamically changes. The specific field is the data packet frame header, the check rule such as CRC, and the like. The mode recognition process of the serial communication protocol includes: a) protocol library, data packet frame header, check rule such as CRC, and data body coding rule are input into the protocol library; b) initialization, the software module reads the protocol library and completes the basic configuration such as serial port baud rate, data bit, stop bit, check bit, and establishes the serial port connection; c) protocol recognition, the module checks whether the multiple special fields of the data frame meet the coding specification; according to the preset protocol library set protocol characteristics, the characteristics of the data frame are extracted, and it is judged whether the extracted characteristics match the preset protocol library set protocol characteristics. If the characteristics match successfully, the module will parse the data area content according to the matched protocol, and complete the data analysis and processing. If the characteristics do not match, the module will establish an extended protocol library according to the extracted characteristics, and add it to the preset protocol library to update, so as to support more types of data exchange protocols. The new extended protocol library is added to the preset protocol library, so that the module can recognize and process more protocol types.
[0162] Finally, after identifying the communication protocol, the protocol configuration is performed. Data encapsulation and analysis are the core tasks of communication, and serialization is a very important mechanism in communication. A good serialization method can directly affect the performance of data transmission, and can convert structured data into data stream form and improve the reliability of information transmission.
[0163] Among them, the common data serialization method is JASON, XML and Protobuf, and the code related to the programming framework needs to be written by the user, which is poor in readability and requires high requirements for the developer. The application defines a structure, and the above-mentioned properties are configured through visualization to help users without programming experience to easily process data serialization and deserialization.
[0164] Compared with the prior art, the application has the following advantages: first, it supports fast inheritance of new protocols, solves the problems of difficult protocol upgrade and limited application range, etc. Second, using a message bus as a medium between modules, it realizes decoupling between the library and the main application, between the library and the library, ensures the independence of the modules, adds and unloads the modules without affecting the integrity of the system, makes the system engineering more flexible, and easily expands to support more business logic libraries. Third, according to the specific application scenario, the most suitable protocol identification method is selected. Combining pattern matching and manual configuration, the protocol can be identified, which not only improves the robustness and reliability of the system, but also reduces the maintenance cost. Fourth, the data flow visualization and the serialization process configuration not only improve the reliability of data transmission, but also improve the development efficiency. The application embodiment introduces the concept of "software driver", and designs the business logic of the external system. The "unloading" or "installing" of the new "software driver" will not affect the use of the main application program. Based on the message bus mechanism, the coupling degree between the main application program and the library is reduced, and the scalability and maintainability of the system are improved. In view of the difference of the device driver of different operating systems, the abstract base class and the adaptability function are combined to enhance the compatibility and flexibility of the software. The proposed protocol configuration method not only meets the data stream serialization requirements, but also helps users without programming experience to easily handle data serialization and deserialization, greatly improves the development efficiency, and reduces the burden of developers. The ship communication system provided by the application can be widely applied in the fields of computer network technology, software development technology and communication protocol technology.
[0165] Figure 10 is a principle structure block diagram of a ship communication system based on a message bus provided in the application embodiment. Correspondingly, the application embodiment also provides a ship communication system based on a message bus, please refer to Figure 10 The ship communication system based on a message bus 100 includes a setting module 10 for setting a software driver; wherein the software driver is independent of the main application program of the ship communication system; a first data interaction module 20 for realizing data interaction between the main application program and the external system through the software driver; a second data interaction module 30 for realizing data interaction between the main application program and each software module in the ship communication system based on the message bus mechanism; a protocol identification module 40 for adaptively identifying the external communication protocol through a manual configuration method and / or a pattern recognition method; and a protocol configuration module 50 for protocol configuration after identifying the external communication protocol.
[0166] The technical scheme of the embodiment of the application provides a ship communication system based on a message bus, which comprises: a setting module configured to set a software driver; wherein the software driver is independent of a main application program of the ship communication system; a first data interaction module configured to realize data interaction between the main application program and an external system through the software driver; a second data interaction module configured to realize data interaction between the main application program and each software module in the ship communication system based on a message bus mechanism; a protocol identification module configured to perform adaptive protocol identification on an external communication protocol through a manual configuration mode and / or a mode identification mode; and a protocol configuration module configured to perform protocol configuration after identifying the external communication protocol. The software driver concept is introduced to realize data interaction between the main application program and the external system, and the software driver can be added or removed without restarting the system, which does not affect the application of the main application program, thereby improving the efficiency of data communication and data processing. The message bus mechanism is used to realize data interaction in the ship communication system and collaborative work between different components. The manual configuration mode and / or the mode identification mode are used to perform adaptive protocol conversion and identification on the external communication protocol, and the external communication protocol is converted into a unified format, which enhances the compatibility and flexibility of the software and improves the efficiency of data processing.
[0167] In some embodiments, the first data interaction module is further configured to: define a communication protocol class library; and perform data interaction with the external system through the communication protocol class library.
[0168] In some embodiments, the first data interaction module is further configured to: define a communication mode and a communication protocol; design a communication protocol class library Lib; set an adapter, and convert device drivers under different operating systems into a general interface in the communication protocol class library Lib through the adapter.
[0169] In some embodiments, the design of the communication protocol class library Lib comprises:
[0170] defining a communication identifier, a communication protocol base class, a custom communication protocol, a device module base class, a device module derived class, and a communication device;
[0171] sending and receiving data packets through the device module base class;
[0172] storing relevant information of communication through the communication identifier;
[0173] serializing and deserializing data packets through the communication protocol base class;
[0174] implementing encapsulation and analysis according to specific serialization and deserialization rules of the custom communication protocol through the custom communication protocol;
[0175] The device module base class is used by the device module derived class to handle the communication device using the device module library.
[0176] In some embodiments, the communication device and the device module base class are in a composition relationship;
[0177] The communication device and the communication identification are in a composition relationship;
[0178] The communication identification and the communication protocol base class are in a dependency relationship;
[0179] The custom communication protocol and the device module base class are in an inheritance relationship;
[0180] The device module derived class and the module base class are in an inheritance relationship.
[0181] In some embodiments, the second data interaction module is further configured to: implement bidirectional data interaction between the main application program and each software module inside the ship communication system; each software module is divided according to functional requirements, and exchanges information with the main application program by subscribing and publishing messages of a preset topic. In this process, the main application program and each software module can act as a producer or a consumer in the message bus according to a specific application scenario.
[0182] In some embodiments, the application scenarios of the external communication protocol include a field-determined protocol and a dynamically changing protocol; the protocol identification module is configured to: adopt a manual configuration mode for the field-determined protocol; and adopt a pattern recognition mode for the dynamically changing protocol; wherein the pattern recognition mode includes: defining a protocol data packet format, judging a special field of a data frame, matching a preset protocol library, analyzing a data area content, establishing an extended protocol library, and updating the preset protocol library.
[0183] In some embodiments, the types of the external communication protocol include at least an Ethernet communication protocol, a CAN communication protocol, and a serial communication protocol.
[0184] In some embodiments, the protocol identification module is further configured to: manually configure an address and a data type; automatically generate a measurement point type, a station ID, a module ID, a point number, and a database ID after point selection is completed; and respectively identify a start bit, a length, and a register address in a Modbus TCP / IP protocol.
[0185] The pattern recognition mode for the dynamically changing protocol includes: identifying the dynamically changing protocol by defining a protocol data packet format; wherein the data packet format includes: a data packet frame header, an information unit frame header, and an information unit body.
[0186] In some embodiments, the protocol conversion and identification module is further configured to: manually select a correlation measuring point in a protocol; automatically generate a type, a station ID, a module ID, a point number and a database ID after the selected point is completed; manually configure an address, a bit and a data type content; and respectively identify a start bit, a length and a frame ID in the CAN protocol.
[0187] The mode recognition method is applied to the dynamically changed protocol, including defining a data packet format and a data frame type to identify the dynamically changed protocol in combination with a frame ID.
[0188] In some embodiments, the protocol identification module is further configured to: manually configure an address and a data type; automatically generate a measuring point type, a station ID, a module ID, a point number and a database ID after the selected point is completed; and respectively identify a start bit, a length and a register address in the Modbus RTU protocol.
[0189] The mode recognition method is applied to the dynamically changed protocol, including defining a frame header and a verification rule to identify the dynamically changed protocol.
[0190] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0191] The ship communication method and system based on a message bus provided by the embodiments of the present application are described in detail above, and the principle and implementation manner of the present application are described by applying specific examples; the above embodiment descriptions are only used to help understand the technical solutions and core ideas of the present application; those skilled in the art should understand that the technical solutions recorded in the above embodiments can be modified, or some technical features can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A message bus based ship communication method, characterized in that, The method is applied to a ship communication system, and comprises the following steps: setting a software driver, wherein the software driver is independent of a main application program of the ship communication system; realizing data interaction between the main application program and an external system through the software driver; realizing data interaction between the main application program and each software module inside the ship communication system based on a message bus mechanism; performing adaptive protocol identification on an external communication protocol through a manual configuration mode and / or a mode recognition mode; performing protocol configuration after identifying the external communication protocol; wherein the step of realizing data interaction between the main application program and the external system through the software driver comprises the following steps:
2. The message bus based ship communication method according to claim 1, characterized in that, defining a communication protocol class library; defining a communication mode and a communication protocol; designing the communication protocol class library Lib; setting an adapter, and converting device drivers under different operating systems into a general interface in the communication protocol class library Lib through the adapter. The step of designing the communication protocol class library Lib comprises the following steps: defining a communication identifier, a communication protocol base class, a custom communication protocol, a device module base class, a device module derived class, and a communication device; sending and receiving data packets through the device module base class; 3. The message bus based ship communication method according to claim 2, characterized in that, storing relevant information of communication through the communication identifier; serializing and deserializing data packets through the communication protocol base class; implementing encapsulation and analysis according to specific serialization and deserialization rules of the custom communication protocol through the custom communication protocol; processing the communication device using a device module library through the device module derived class. The communication device and the device module base class are in a combination relationship; 4. The message bus based ship communication method according to claim 1, characterized in that, the communication device and the communication identifier are in a combination relationship; the communication identifier and the communication protocol base class are in a dependency relationship; 5. The message bus based ship communication method according to claim 1, characterized in that, the custom communication protocol and the communication protocol base class are in an inheritance relationship; the device module derived class and the device module base class are in an inheritance relationship. The step of realizing data interaction between the main application program and each software module inside the ship communication system based on the message bus mechanism comprises the following steps: the main application program and each software module inside the ship communication system realize bidirectional data interaction; each software module is divided according to functional requirements, and exchanges information with the main application program by subscribing and publishing messages of a preset topic; in this process, the main application program and each software module can act as a producer or a consumer in the message bus according to a specific application scenario.
6. The message bus based ship communication method according to claim 5, characterized in that, Application scenarios of the external communication protocol include a field-determined protocol and a dynamically changing protocol; The step of performing adaptive protocol identification on the external communication protocol through the manual configuration mode and / or the mode recognition mode comprises the following steps: adopting the manual configuration mode for the field-determined protocol; adopting the mode recognition mode for the dynamically changing protocol; wherein the mode recognition mode comprises the following steps: defining a protocol data packet format; judging a special field of a data frame; characteristic matching a preset protocol library; analyzing content of a data area; establishing an extended protocol library; and updating the preset protocol library. Types of the external communication protocol at least include an Ethernet communication protocol, a CAN communication protocol, and a serial communication protocol.
7. The message bus based ship communication method according to claim 6, characterized in that, When the type of the external communication protocol is an Ethernet communication protocol, the protocol determined according to the fields adopts the manual configuration mode, including: manually configuring start, length and address data items; automatically generating data items of measurement point name, measurement point type, station ID, module ID, point number and database ID after completion of point selection; and respectively identifying start bit, bit length and register address in Modbus TCP / IP protocol. The dynamic change protocol adopts the mode recognition mode, including: recognizing the dynamic change protocol by defining a data packet format; wherein the data packet format includes: a data packet frame header, an information unit frame header, an information unit body and an information coding rule.
8. The message bus based ship communication method according to claim 6, characterized in that, When the type of the external communication protocol is a CAN communication protocol, the protocol determined according to the fields adopts the manual configuration mode, including: manually selecting associated measurement points in the protocol; automatically generating data items of measurement point name, type, station ID, module ID, point number, database ID after completion of point selection; manually configuring address, length and frame ID content; and respectively identifying start bit, bit length and frame ID in the CAN protocol. The dynamic change protocol adopts the mode recognition mode, including: defining a data packet format and a data frame type to recognize the dynamic change protocol in combination with frame ID and data body.
9. The message bus based ship communication method according to claim 6, characterized in that, When the type of the external communication protocol is a serial port communication protocol, the protocol determined according to the fields adopts the manual configuration mode, including: manually configuring address and data type; automatically generating measurement point type, station ID, module ID, point number and database ID after completion of point selection; and respectively identifying start bit, length and register address in Modbus RTU protocol. The dynamic change protocol adopts the mode recognition mode, including: recognizing the dynamic change protocol by defining a frame header and a check rule.
10. A message bus based ship communication system, characterized in that, The method comprises: a setting module, configured to set a software driver; wherein the software driver is independent of a main application program of the ship communication system; a first data interaction module, configured to realize data interaction between the main application program and an external system through the software driver; a second data interaction module, configured to realize data interaction between the main application program and each software module inside the ship communication system based on a message bus mechanism; a protocol recognition module, configured to perform adaptive protocol recognition on an external communication protocol through a manual configuration mode and / or a mode recognition mode; a protocol configuration module, configured to perform protocol configuration after recognizing the external communication protocol; and the first data interaction module is further configured to: define a communication protocol class library; define a communication mode and a communication protocol; design a communication protocol class library Lib; set an adapter, and convert device drivers under different operating systems into a general interface in the communication protocol class library Lib through the adapter.
Citation Information
Patent Citations
Ship remote technical support system based on cloud computing
CN112101589A
Implementation method for bank core system interface to support multiple access modes
CN118101797A