Microkernel architecture method, cross-platform system based on microkernel and measuring instrument

By adopting the microkernel architecture method in the measurement instrument software, the kernel module is built to provide basic functions and unified management of module loading, which solves the problems of high code complexity, poor scalability and difficulty in collaboration caused by the single-body architecture, and achieves the simplification of the system, scalability and collaboration efficiency improvement.

CN119806489AActive Publication Date: 2025-04-11成都玖锦科技有限公司
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411857970.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-04-11
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

Due to the design of the existing measuring instrument software systems, the code complexity is high, the scalability is poor, and the collaboration is difficult.

Method used

Using the microkernel architecture method, the kernel module is built to provide basic functions such as module management, module communication and interface management, and the initiator uniformly manages the loading of kernel modules and user modules.

Benefits of technology

Reduces system complexity, improves scalability and collaborative development efficiency, makes system functions clearer, and is easier to develop, maintain and test.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806489A_ABST
    Figure CN119806489A_ABST
Patent Text Reader

Abstract

The invention discloses a microkernel architecture method, a cross-platform system based on a microkernel and a measuring instrument.The method comprises the steps that a kernel module is constructed, the kernel module is used for providing basic functions, and the basic functions comprise module management and module communication; the module management comprises module life cycle management, module loading, module unloading, module service and interface management; the module communication comprises a module message and a notification service; a starter is constructed, the starter is used for starting a kernel module and a user module, and the user module is a user-defined module for a user to achieve a preset service function based on a standard interface provided by the kernel module. The technical problems that in an existing single software architecture, code complexity is high, expansibility is poor, and cooperation is difficult are solved, and through the microkernel architecture and modular design, the technical effects that a software system is high in cohesion, low in coupling, easy to expand and maintain and good in cross-platform characteristic are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of measuring instruments, and in particular to a microkernel architecture method, a microkernel-based cross-platform system and a measuring instrument. Background Art

[0002] At present, the software system of measuring instruments generally adopts a monolithic architecture design, that is, all functional modules such as data acquisition, signal processing, and user interface are integrated into one application. As the functions of measuring instruments continue to increase, monolithic applications become more and more complex, and the codes of various modules are intertwined, making system development, maintenance, and testing difficult. For example, in digital oscilloscope software, multiple functional modules such as acquisition control, waveform display, and measurement analysis are all in the same application, with a huge amount of code. Modifying the function of one module may affect the normal operation of other modules.

[0003] In addition, the scalability of measurement instrument software is limited. When a new measurement function or analysis algorithm needs to be added, the entire application usually needs to be redeployed. Even if it is just to add a simple measurement parameter, it may be necessary to recompile, link and deploy the entire application code, which is not only time-consuming, but may also affect the stability of the system and is not conducive to the rapid iteration and update of instrument functions.

[0004] In terms of development collaboration, single applications of measuring instruments often lack unified interface standards. During the development process, due to the lack of unified interface specifications, it is difficult to standardize the code architecture of modules such as data acquisition and signal processing by different developers. When other developers write code later, they may need to spend more time to sort out its logic and structure, which increases the difficulty and cost of development. At the same time, since the codes of all modules are intertwined, when multiple developers develop different functions at the same time, the problems of code conflicts and repeated development will become more serious. Summary of the invention

[0005] The main purpose of this application is to provide a microkernel architecture method, a cross-platform system based on a microkernel, and a measuring instrument, aiming to solve the technical problems of high code complexity, poor scalability, and difficulty in collaboration in the existing monolithic software architecture.

[0006] To achieve the above-mentioned purpose, the present application provides a microkernel architecture method, comprising: constructing a kernel module, wherein the kernel module is used to provide basic functions, and the basic functions include module management and module communication; the module management includes module life cycle management, module loading, module unloading, module service and interface management; the module communication includes module messages and notification services, the module messages are used to transmit control information between modules, and the notification service implements event notification between modules based on a subscription-publishing mode; constructing a launcher, wherein the launcher is used to start the kernel module and the user module, and the user module is a custom module for the user to implement preset business functions based on the standard interface provided by the kernel module.

[0007] Optionally, the kernel module provides a module interface and a module core base class for implementing the basic functions.

[0008] Optionally, the construction of the kernel module includes: constructing a module lifecycle management interface and a module core base class to implement the module lifecycle management and interface management in the module management, wherein the module core base class inherits the module lifecycle management interface; constructing a module service interface, a kernel module service class and a user module service class to implement the module service in the module management, wherein the kernel module service class and the user module service class are used to inherit the module service interface; constructing a module manager interface to implement unified management of modules, wherein the unified management includes module loading and module unloading; constructing a module communication interface to implement the module message; and constructing a notification service interface to implement the notification service.

[0009] Optionally, the construction of the module lifecycle management interface and the module core base class includes: constructing an increase reference count function, a decrease reference count function and an acquisition reference count function in the module lifecycle management interface to implement the module lifecycle management, wherein the increase reference count function is used to increase the reference count of the module, and the decrease reference count function is used to decrease the reference count of the module; the acquisition reference count function is used to obtain the current reference count of the module; and constructing a module core base class, wherein the module core base class inherits the functions of each function in the module lifecycle management interface.

[0010] Optionally, the building module core base class also includes: in the building module core base class, constructing an initialization function to realize the module loading, wherein the initialization function is used for the module initialization operation; constructing a deinitialization function to realize the module unloading, wherein the deinitialization function is used for the module deinitialization operation; constructing an interface query function, an interface registration function and an interface deregistration function to realize the interface management, wherein the interface query function is used to query the registered interface in the module, the interface registration function is used to register the interface, and the interface deregistration function is used to deregister the interface; constructing a module information access function and a module information query function to realize the module service, wherein the module information access function is used to set and obtain module information, and the module information query function is used to query module information, and the module information includes a globally unique identifier, module name, developer, version information, description information, copyright license and module directory.

[0011] Optionally, the basic functions of the kernel module also include module interface quick access, and the module interface quick access can obtain any interface of any module, which is implemented through an interface access class.

[0012] Optionally, the basic function of the kernel module also includes logging, which is used to record log information during system operation.

[0013] Optionally, a module creation wizard tool is constructed, wherein the module creation wizard tool automatically generates project source files and engineering configurations by configuring module information so that users can quickly create new modules.

[0014] In addition, to achieve the above-mentioned purpose, the present application also provides a cross-platform system based on a microkernel, including: a system layer, the system layer is the underlying operating environment provided by the operating system; a microkernel platform layer, the microkernel platform layer is constructed based on the microkernel architecture method; an application layer, the application layer includes multiple application modules, the multiple application modules are user modules pre-designed according to different application fields, and are constructed based on interfaces, base classes and classes provided by the kernel modules in the microkernel platform layer.

[0015] In addition, the present application also provides a measuring instrument, characterized in that it is built based on the microkernel-based cross-platform system and applied to the measuring instrument; wherein the application module of the application layer includes: a data model module, used to provide caching and acquisition of control parameters; a UI module, used to provide a functional interface and parameter control; a command control module, used to provide command cancellation and restoration; a command parsing module, used to parse SCPI instructions; a command processing module, used to process the parsed instructions; a remote service module, used to manage remote interfaces; a measurement and analysis module, used to process collected data; a hardware control module, used to implement hardware control and data acquisition.

[0016] This application provides basic functions such as module management, module communication, and interface management in the kernel module, and the launcher uniformly manages the loading of the kernel module and the user module. On the one hand, it separates the basic functions from the business functions, reducing the complexity of the system; on the other hand, it standardizes the code implementation of different developers through the standard interface provided by the kernel module, improving the efficiency of collaborative development. At the same time, custom modules can be developed based on the interface provided by the kernel module to implement preset business functions, thereby improving the scalability of the system. Specifically, this application has the following beneficial effects:

[0017] By building kernel modules, providing basic functions such as module management, module communication, and interface management, the basic functions are separated from the business functions, so that the kernel module only needs to maintain the basic functions, and the user module focuses on realizing the preset business functions. This functional separation design significantly reduces the complexity of the system, the functions of each module are clearer, the code structure is clearer, and the development, maintenance, and testing of the system become easier.

[0018] The standard interface provided by the kernel module standardizes the code implementation methods of different developers. Developers must follow the unified interface specifications when developing user modules, so that modules developed by different developers have a unified implementation standard, the code style is more unified and standardized, and the interface calls between modules are clearer and more specific, which significantly improves the efficiency of collaborative development.

[0019] Users can develop custom modules based on the standard interface provided by the kernel module to implement preset business functions. The launcher manages the loading of kernel modules and user modules in a unified manner, so that when adding or modifying functions, only the relevant user modules need to be developed or modified, without changing other modules, which greatly improves the scalability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 A schematic diagram of the structure of a microkernel architecture provided for the first embodiment of the present application;

[0021] Figure 2 A schematic diagram of the process of starting the kernel module and the user module provided for this application;

[0022] Figure 3 The inheritance relationship class diagram of the module interface and module core base class provided for this application;

[0023] Figure 4 The module service interface class diagram provided for this application;

[0024] Figure 5 The kernel module class diagram provided for this application;

[0025] Figure 6 The module manager class diagram provided for this application;

[0026] Figure 7 Schematic diagram of module messages provided for this application;

[0027] Figure 8 Class diagram of the module notification service provided for this application;

[0028] Fig. 9 Diagram of the notification service provided for this application;

[0029] Fig.10 A schematic diagram of program initialization provided for this application;

[0030] Fig.11 The interface access class diagram provided for this application;

[0031] Fig.12 A schematic diagram of the reference problem when uninstalling the module provided by this application;

[0032] Fig.13 A diagram showing the module wizard tool provided for this application;

[0033] Fig.14 A schematic diagram of the structure of a microkernel-based cross-platform software architecture provided for the second embodiment of the present application;

[0034] Fig.15 A schematic diagram of the structure of a measuring instrument software architecture provided in the third embodiment of the present application.

[0035] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0037] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain preset posture (as shown in the accompanying drawings). If the preset posture changes, the directional indication will also change accordingly.

[0038] In the present invention, unless otherwise clearly specified and limited, the terms "connection", "fixation", etc. should be understood in a broad sense. For example, "fixation" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0039] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the meaning of "and / or" appearing in the full text includes three parallel schemes. Taking "A and / or B" as an example, it includes scheme A, or scheme B, or a scheme that satisfies both A and B. In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the ability of ordinary technicians in the field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0040] Reference Figure 1 The first embodiment of the present application provides a microkernel architecture method, including:

[0041] S1. Build a kernel module, wherein the kernel module is used to provide basic functions, including module management and module communication; the module management includes module life cycle management, module loading, module unloading, module service and interface management; the module communication includes module message and notification service, the module message is used to transmit control information between modules, and the notification service implements event notification between modules based on the subscription-publishing mode;

[0042] S2. Construct a launcher, wherein the launcher is used to start a kernel module and a user module, wherein the user module is a user-defined module that implements a preset business function based on a standard interface provided by the kernel module.

[0043] In this embodiment, a kernel module is constructed to provide basic functions, including module management and module communication. Among them, module management includes module life cycle management, module loading, module unloading, module service and interface management. Module life cycle management is used to manage the life cycle of the module, and to increase, decrease and obtain the module reference count; module loading and module unloading are used to load and safely unload kernel modules and user modules respectively; module service is used to provide a static description of the module; interface management is used to implement the registration, query and deregistration of module interfaces.

[0044] Module communication includes module messages and notification services. Among them, module messages are used to realize point-to-point communication between modules. When sending, the destination module ID needs to be specified to transmit control information between modules. Notification services are implemented based on the subscription-publishing mode and are used for event notifications between modules. Modules can publish notifications, and other modules can receive notifications of specified types by subscribing.

[0045] Build a launcher as a program entry to start the kernel module and user module. The user module refers to a custom module developed by the user based on the standard interface provided by the kernel module to implement the preset business functions. Figure 2 As shown, the launcher first obtains the instance pointer of the kernel module service, and calls the interface of the kernel module service through the pointer to load the kernel module. After the kernel module is loaded, the kernel module reads the user module configuration, generates a user module service instance according to the configuration, and then loads the corresponding user module according to the module path configuration in the user module service.

[0046] By separating basic functions from business functions, the kernel module only needs to maintain basic functions, and the user module focuses on implementing preset business functions, which significantly reduces the complexity of the system. At the same time, the standard interface provided by the kernel module standardizes the code implementation methods of different developers and improves the efficiency of collaborative development. In addition, users can easily develop custom modules based on the standard interface provided by the kernel module, which greatly improves the scalability of the system.

[0047] As an optional implementation, the kernel module provides a module interface and a module core base class for implementing the basic functions.

[0048] Specifically, the kernel module provides a module interface and a module core base class to implement basic functions. The module interface defines the standard interface specification of the function, while the module core base class provides specific function implementation by inheriting and implementing these interfaces.

[0049] In terms of interface definition, abstract classes and pure virtual functions of C++ language can be used to simulate interfaces. In C++ language, interface and class are two core concepts of object-oriented programming. C++ does not provide keywords for interface description like Java or C#, but the definition of interface can be simulated through abstract classes and pure virtual functions.

[0050] For example, refer to Figure 3 , taking the system information acquisition interface IsystemInfo as an example, the interface definition rules are explained. The system information acquisition interface is a standard interface that obtains information such as company name, model, serial number, etc. through pure virtual function definition. At the same time, the unique identifier (IID) of the interface is generated by macro definition for subsequent interface registration and query.

[0051] First, the interface is declared in a separate header file as follows:

[0052] #ifndef ISystemInfo_H

[0053] #define ISystemInfo_H

[0054] #include "JJFrame / JJDef.h"

[0055] #include <qstring>

[0056] / / Define a class called ISystemInfo to simulate the interface

[0057] class ISystemInfo{

[0058] / / Macro call, after expansion, provides two static functions

[0059] JJ_DEFINE_IID(ISystemInfo)

[0060] / / company

[0061] virtual QString CompanyName()=0;

[0062] virtual QString CompanyNameShort()=0;

[0063] / / model

[0064] virtual QString ModelNumber()=0;

[0065] / / Serial number

[0066] virtual QString SerialNumber()=0;

[0067] };

[0068] #endif

[0069] In the above code, the system information acquisition interface is defined. The interface name is ISystemInfo, which contains pure virtual functions, which means that any class that inherits from ISystemInfo must implement these functions, such as Figure 3 JJModuleInfo. At the same time, the interface for obtaining system information is defined, and the return value is of QString type, which is used to obtain information such as company name (full name and abbreviation), model and serial number.

[0070] The JJ_DEFINE_IID macro that appears in the system information acquisition interface expands to the following content:

[0071] #define JJ_DEFINE_IID(_Interface)

[0072] public:

[0073] static const char*GetInterfaceName(){return#_Interface;}

[0074] static JJ::IID GetIID(){static JJ::IID iid=JJ::_hashkey(#_Interface);

[0075] return iid;}

[0076] It can be seen that the JJ_DEFINE_IID macro provides two static functions. The GetInterfaceName function provides the function of accessing the interface name. For example, in the system information acquisition interface, the function returns the name of the interface as ISystemInfo. The GetIID function generates a unique ID value corresponding to the interface name using a hash algorithm through the interface name. This ID value is defined as IID, that is, the interface identifier, which is used as the identifier for subsequent interface registration and interface query.

[0077] Then, based on the above interface definition rules, the module interface and module core base class can be defined. The module core base class (JJModuleCore) implements the corresponding functional interface and provides the specific implementation of basic functions such as module life cycle management, interface management and module information management. Figure 3 As shown, a schematic diagram of the inheritance relationship class diagram of the module interface and the module core base class is shown. Among them, taking into account the management of the module life cycle, a module life cycle management interface is constructed, namely IJJModuleLife shown in the figure, including functions for module life cycle management, such as increasing the reference count, decreasing the reference count, and obtaining the current reference count value, etc., and the module life cycle management interface is implemented by the module core base class, namely JJModuleCore shown in the figure, so as to realize the management of the module life cycle. Based on the module life cycle interface, the module core base class JJModuleCore of all modules is defined. For example, the module core base class may include: implementation of the module life cycle management interface; definition of initialization and deinitialization virtual functions; definition of interface management related functions; module information access and query functions. The following is an example of a module core base class:

[0078] class JJModuleCore{

[0079] / / Implementation of the base class lifecycle management interface

[0080] virtual bool AddRef();

[0081] virtual bool DeRef();

[0082] virtual int RefCount();

[0083] / / Define initialization and deinitialization virtual functions

[0084] virtual JJReturnInitialize();

[0085] virtual JJReturn Uninitialize();

[0086] / / Interface management related functions

[0087] virtual int QueryInterface(IID id,void**pInterface)const;

[0088] virtual JJReturn RegisterInterface(IID id,void*pInterface);

[0089] virtual JJReturn UnregisterInterface(IID id);

[0090] / / Module information access and query function

[0091] virtual void SetModuleInfo(UJModuleInfo*pModuleInfo);

[0092] virtual UJModuleInfo*ModuleInfo()const;

[0093] };

[0094] Through the design of module interface and module core base class, a unified module development specification is formed. The interface definition standardizes the interaction between modules and ensures the consistency of the interface; the base class implementation provides complete basic function support and avoids repeated development. When developing a new user module, developers only need to inherit the module core base class and implement or rewrite the corresponding functions as needed, such as Figure 3 CustomModule1 and CustomModule2 in , thereby improving development efficiency and code maintainability.

[0095] As an optional implementation, step S1 may specifically include:

[0096] S11, constructing a module lifecycle management interface and a module core base class to implement module lifecycle management and interface management in the module management, wherein the module core base class inherits the module lifecycle management interface;

[0097] S12, constructing a module service interface, a kernel module service class and a user module service class to implement the module service in the module management, wherein the kernel module service class and the user module service class are used to inherit the module service interface;

[0098] S13, constructing a module manager interface to implement unified management of modules, wherein the unified management includes loading and unloading the modules;

[0099] S14. Construct a module communication interface to implement the module message; construct a notification service interface to implement the notification service.

[0100] Specifically, when building a kernel module, the basic functions of the kernel module are implemented by building a series of interfaces and classes, including the specific implementation of various aspects such as module lifecycle management, module services, module management, module communication and notification services.

[0101] Reference Figure 3 , build the module life cycle management interface IJJModuleLife, which is inherited by the module core base class JJModuleCore and implements the functions in the interface. The life cycle management interface IJJModuleLife defines three functions: AddRef(), DeRef(), and RefCount(), which are used to increase the reference count, decrease the reference count, and obtain the current reference count value, respectively, to manage the module life cycle.

[0102] Reference Figure 4 , construct the module service interface IJJModuleService, and implement it by JJKernelService (kernel module service class) and JJmoduleService (user module service class). These classes provide management functions such as module startup mode, directory path, detailed information, etc. through functions such as StartupMode(), ModuleDir(), and ModuleInfo(), and realize module loading and unloading through Startup() and Shutdown() functions.

[0103] The following is an example of JJKernelService (kernel module service class):

[0104] class JJKernelService{

[0105] int m_startupMode;

[0106] QString m_ModuleDir;

[0107] UJModuleInfo*m_pModuleInfo;

[0108] UJModule*m_pModule;

[0109] virtual int StartupMode()const;

[0110] virtual JJReturn Startup();

[0111] virtual JJReturn Shutdown();

[0112] virtual bool IsStartup()const;

[0113] virtual QString ModuleDir()const;

[0114] virtual UJModuleInfo*ModuleInfo()const;

[0115] virtual UJModule*Module()const;

[0116] };

[0117] Among them, a series of key properties and functions are defined in the kernel module service class. In terms of properties, m_startupMode is used to record the startup mode of the module. The possible values ​​include DoNotRun (not loaded), RunAtAppSatrtup (loaded at initialization), RunAtFirstUsingTime (loaded at the first use), etc., which are obtained through the StartupMode() function; m_ModuleDir stores the directory path where the module is located, which is obtained through the ModuleDir() function; m_pModuleInfo points to the pointer of the module information structure, which is used to obtain detailed information of the module, which is obtained through the ModuleInfo() function; m_pModule points to the pointer of the module instance, which is obtained through the Module() function.

[0118] In terms of function implementation, the StartupMode() function is used to return the startup mode of the module; the Startup() function executes the startup operation of the module, including loading the module and initializing resources, etc., and returns a JJReturn type value to represent the startup result; the Shutdown() function executes the shutdown operation of the module, releases resources, etc., and also returns a JJReturn type value to represent the shutdown result; the IsStartup() function is used to determine whether the module has been started; the ModuleDir(), ModuleInfo() and Module() functions are used to obtain the module's directory path, detailed information and instance pointer respectively.

[0119] Through these properties and functions, the kernel module service class can manage the entire life cycle of the module, including module configuration information management, startup control, and status monitoring.

[0120] The following is an example of JJmoduleService (user module service class):

[0121] class JJModuleService{

[0122] int m_startupMode;

[0123] QString m_ModuleDir;

[0124] UJModuleInfo*m_pModuleInfo;

[0125] UJModule*m_pModule;

[0126] virtual int StartupMode()const;

[0127] virtual JJReturn Startup();

[0128] virtual JJReturn Shutdown();

[0129] virtual bool IsStartup()const;

[0130] virtual QString ModuleDir()const;

[0131] virtual UJModuleInfo*ModuleInfo()const;

[0132] virtual UJModule*Module()const;

[0133] };

[0134] Therefore, module loading includes two processes: kernel module loading and user module loading. Figure 2 , firstly, a kernel module service instance is constructed as a static and unique instance in the system. The launcher, as the program entry, obtains the pointer of the kernel module service instance. Through this pointer, the launcher can call the interface provided by the kernel module service instance to load the kernel module. After the kernel module is loaded, the module manager in the kernel module reads the user module configuration information. According to the configuration information, the module manager generates a user module service instance. Then, according to the module path configuration recorded in the user module service instance, the corresponding user module is loaded. Among them, both the kernel module service instance and the user module service instance realize their respective module loading and unloading functions by rewriting the module service interface. This design enables the system to uniformly manage the loading and unloading processes of different types of modules while maintaining good scalability. Through this module loading mechanism, the orderly loading of kernel modules and user modules is realized, ensuring the reliability and controllability of the system initialization process. At the same time, the user module is managed through the configuration file, which provides good flexibility and facilitates the system to adjust the module configuration.

[0135] Reference Figure 5 , build three key interfaces in the kernel module, namely the module manager interface IJJModuleManager, the module communication interface IJJModuleComm and the notification service interface IJJNotifyService.

[0136] Reference Figure 6 As shown in the module management class diagram, the module manager interface IJJModuleManager is used to implement unified management of modules. The kernel module reads the user module configuration through module management, generates a module service instance, and loads and unloads the module according to the module path configuration information in the module service, thus implementing standardized management of the module loading and unloading process, ensuring that the module can be correctly loaded and safely unloaded in the system.

[0137] The constructed module communication interface IJJModuleComm is used to implement the message transmission function between modules. Figure 7 As shown in the figure, module messages implement point-to-point message transmission. When sending a message, you need to specify the destination module ID to achieve direct communication between modules. Unlike notification services, module messages determine the receiving module at the sending end and are used for direct control information transmission between modules. Figure 8 The module notification service class diagram shown in the figure builds a notification service interface to implement the event notification mechanism between modules. Fig. 9 As shown in the figure, the notification service adopts a subscription-publishing mode. Modules can publish notifications, and other modules interested in this type of notifications receive notifications by subscribing. This mechanism decouples event sources from event processing and provides a more flexible way of communication between modules. Unlike the point-to-point communication of module messages, the notification service supports a module to send the same notification to multiple subscribed modules. Among them, for notification messages and module messages, an asynchronous message mechanism based on the Qt event system will be used to encapsulate events (QEvnt) in Qt.

[0138] At the same time, in the module core base class JJModuleCore, interface management functions such as QueryInterface(), RegisterInterface() and UnregisterInterface() are constructed, which are used for interface query, registration and unregistration respectively, providing a unified management mechanism for interface access between modules and realizing interface management.

[0139] Through the above interface and class system design, a complete module management and communication framework is established, which not only realizes the basic functions in the kernel module, but also makes the system have good scalability and maintainability through interface definition and class implementation. Module life cycle management ensures the stability of module operation, module service provides a unified module management mechanism, and module communication and notification services realize flexible interaction between modules.

[0140] As an optional implementation, the above step S11 may specifically include:

[0141] S111, constructing an increase reference count function, a decrease reference count function and an acquisition reference count function in the module life cycle management interface to implement the module life cycle management, wherein the increase reference count function is used to increase the reference count of the module, the decrease reference count function is used to decrease the reference count of the module; and the acquisition reference count function is used to obtain the current reference count of the module;

[0142] S112. Construct a module core base class, wherein the module core base class inherits the functions of each function in the module lifecycle management interface.

[0143] Specifically, a series of functions are built in the module lifecycle management interface and the module core base class to implement module management functions.

[0144] In the module lifecycle management interface, three functions are defined based on the reference counting mechanism, namely AddRef(), DeRef() and RefCount(). Among them, the AddRef() function is used to increase the reference count of the module and is called when other modules need to use the target module; the DeRef() function is used to reduce the reference count of the module and is called when other modules no longer use the target module; the RefCount() function is used to obtain the current reference count value of the module. When the reference count drops to zero, it means that no other module is using the target module, and the module can be safely uninstalled. At the same time, in the module core base class JJModuleCore, all functions of the above module lifecycle management interface are implemented to ensure that the module lifecycle is properly managed.

[0145] As an optional implementation, the above step S111 may specifically include:

[0146] In the building module core base class, construct an initialization function to implement the module loading, wherein the initialization function is used for the initialization operation of the module;

[0147] Constructing a deinitialization function to realize the module uninstallation, wherein the deinitialization function is used for the deinitialization operation of the module;

[0148] Constructing an interface query function, an interface registration function and an interface deregistration function to implement the interface management, wherein the interface query function is used to query the registered interface in the module, the interface registration function is used to register the interface, and the interface deregistration function is used to deregister the interface;

[0149] Construct module information access function and module information query function to implement the module service, wherein the module information access function is used to set and obtain module information, and the module information query function is used to query module information, and the module information includes a globally unique identifier, module name, developer, version information, description information, copyright license and module directory.

[0150] Specifically, the constructed module core base class, in addition to implementing all functions of the module lifecycle management interface, also constructs the initialization function Initialize() and the deinitialization function Uninitialize(), which are used for module initialization and deinitialization operations respectively. Fig.10 In the program initialization process shown in the figure, the launcher is used as the program entry point. It first creates an event loop based on Qt, and then calls the kernel module service to start the kernel module. After the kernel module is started, the initialization function Initialize() will be automatically called for initialization. Since the initialization function Initialize() and the uninitialization function Uninitialize() are defined as virtual functions, subclasses can override these functions to implement custom initialization and cleanup processes. Specifically, the initialization function Initialize() is used to perform the initialization work required by the module; and the uninitialization function Uninitialize() is called before the module is unloaded to perform cleanup operations such as resource release. This design ensures that the module can be initialized after the Qt event loop is created, ensuring the correct execution order of module initialization.

[0151] In addition, the module core base class constructs a set of interface management functions, including the interface query function QueryInterface(), the interface registration function RegisterInterface(), and the interface unregistering function UnregisterInterface(), to implement interface management in the module. Among them, the interface query function QueryInterface() is used to query the registered interface in the module, and the query is performed through IID (unique identifier of the interface). The function receives two parameters: id parameter and pInterface parameter. Among them, the id parameter represents the unique identifier (IID) of the interface to be queried; the pInterface parameter is a pointer to a pointer, which is used to store the queried interface pointer. The interface query function QueryInterface() returns a value of type int, which is used to indicate the status of the query result (such as success or failure). The interface registration function RegisterInterface() is used to register the interface, associate the interface pointer with its IID and add it to the system's interface registry; the interface unregistering function UnregisterInterface() is used to unregister the interface and remove the specified interface from the system's interface registry. These functions save and manage interface pointers through a hash table, where the key is IID and the value is the interface pointer.

[0152] At the same time, the module information access function SetModuleInfo() and the module information query function ModuleInfo() are constructed in the module core base class for accessing and querying module information. Among them, the module information contains a complete description of the module, including: GUID (module global unique identifier, used to uniquely identify the module), module name, developer information, version information, description information, copyright license information, and the directory path where the module is located, etc., to provide support for module management and maintenance.

[0153] Through the above functions, the stability and reliability of module operation can be ensured, while providing flexible interface management and information query functions.

[0154] As an optional implementation, the basic functions of the kernel module also include module interface quick access, and the module interface quick access can obtain any interface of any module, which is implemented through an interface access class.

[0155] Specifically, the microkernel architecture will have extensive use of interfaces, so frequent access to interfaces is inevitable. For this reason, an interface access class is designed to quickly access the module interface with minimal code. Fig.11 , providing an interface access class in the kernel module to implement quick access. The interface access class requires two key parameters: module ID and interface ID. The module ID is passed in through the constructor parameters, while the interface ID obtains the unique identifier of the interface type through the GetIID() static function. Based on these two parameters, first obtain the pointer instance of the kernel module, and then obtain the pointer instance of the target interface through the kernel module's QueryInterface interface query function.

[0156] By overloading the pointer operator '->', the interface access class can implement the function of calling the interface in pointer mode. The code is as follows:

[0157] JJ::JJInterface <jiujin::isysteminfo>pSysInfo("pluginGeneral");

[0158] if(pSysInfo){

[0159] QString companyName=pSysInfo->CompanyName();

[0160] };

[0161] However, when the program exits or the module is uninstalled, it is necessary to detect whether other modules are referencing its own interface, otherwise direct uninstallation will cause errors in the referenced module. Therefore, in order to ensure the security of interface access, such as Fig.12 As shown, the module reference management mechanism is implemented in the interface access class. Specifically, the reference count of the target module is increased in the constructor and copy function of the interface access class, and the reference count is released in the destructor and clear function. When the referenced module needs to be uninstalled, the system will check whether the reference count is zero. The uninstallation operation can only be performed when it is ensured that no other module is using the module. Otherwise, the Qt event loop mechanism will be blocked and waited, thereby effectively preventing the problem of the module being incorrectly uninstalled when it is referenced by other modules.

[0162] As an optional implementation, the basic function of the kernel module also includes logging, which is used to record log information during system operation.

[0163] Specifically, the basic functions of the kernel module may also include a logging function for recording log information during system operation.

[0164] For example, based on log4cpp, the log printing function in a configurable format is implemented, and the encapsulation implements the log printing in a configurable format, including carriage return and line feed, timestamp, priority, printing interval, thread name, and processor time.

[0165] At the same time, variable parameter macros are used to implement a variable parameter printing method similar to printf(), making log recording more flexible and convenient. For example:

[0166] #define logDebugEx(category,fmt,...)\

[0167] {JJ::JJLog(category).debug(fmt"%s%d%s",##__VA_ARGS__,__FILE__,__LINE__,__FUNCTION__);}

[0168] Through this design, a complete record of the system's operating status can be achieved, providing important support for system debugging and maintenance.

[0169] As an optional implementation, the microkernel architecture method may further include:

[0170] A module creation wizard tool is constructed, wherein the module creation wizard tool automatically generates project source files and engineering configurations by configuring module information so that users can quickly create new modules.

[0171] Specifically, according to the development requirements of the microkernel architecture, a module creation wizard tool is designed. Fig.13 The tool uses a visual configuration interface for developers to input basic information of the module, including project name, module class name, module directory and other configuration items. After the developer completes the configuration, click the Generate Project button, and the tool will automatically generate the source files and project configuration of the project. The generated project files can be directly added to the existing project for compilation.

[0172] This design greatly reduces the workload of developers when creating new modules, allowing them to focus more on developing application functions, thereby improving development efficiency.

[0173] The second embodiment of the present application provides a cross-platform system based on a microkernel, and the cross-platform system based on a microkernel may include: a system layer, a microkernel platform layer and an application layer, wherein:

[0174] The system layer is the underlying operating environment provided by the operating system; the microkernel platform layer is constructed based on the microkernel architecture method described in any of the above embodiments; the application layer includes multiple application modules, which are user modules pre-designed according to different application fields, and are constructed based on interfaces, base classes and classes provided by the kernel module in the microkernel platform layer.

[0175] Specifically, refer to Fig.14 The cross-platform system based on the microkernel adopts a layered design, which includes: system layer, microkernel platform layer and application layer from bottom to top.

[0176] Among them, the system layer is the underlying operating environment provided by the operating system, and provides basic system services for the upper layer. The microkernel platform layer is constructed based on the microkernel architecture method described in the first embodiment, and provides basic functional support such as module management and module communication. The application layer includes multiple application modules, which are user modules pre-designed according to the needs of different application fields, and are constructed by inheriting and implementing the interfaces, base classes and classes provided by the kernel modules in the microkernel platform layer.

[0177] Through the layered architecture design, the system functions are reasonably divided, so that each layer has clear responsibilities. The system layer provides underlying support, the microkernel platform layer provides unified basic functions, and the application layer focuses on the implementation of specific business functions, thereby improving the maintainability and scalability of the system. In particular, because the microkernel platform layer shields the differences in the underlying operating system and provides a unified interface for upper-level applications, the software system developed based on this architecture can be easily ported to different operating system platforms and has good cross-platform characteristics.

[0178] The third embodiment of the present application provides a measuring instrument, which is built on the cross-platform system based on the microkernel of the second embodiment and applied to the measuring instrument; wherein the application module of the application layer may include: a data model module, a UI module, a command control module, a command parsing module, a command processing module, a remote service module, a measurement analysis module and a hardware control module, wherein,

[0179] The data model module is used to provide caching and acquisition of control parameters; the UI module is used to provide functional interface and parameter control; the command control module is used to provide command cancellation and restoration; the command parsing module is used to parse SCPI instructions; the command processing module is used to process the parsed instructions; the remote service module is used to manage the remote interface; the measurement and analysis module is used to process the collected data; the hardware control module is used to implement hardware control and data acquisition.

[0180] Specifically, the third embodiment of the present application provides a measuring instrument software architecture, which is constructed based on the microkernel-based cross-platform software architecture described in the second embodiment and is applied to a measuring instrument.

[0181] Reference Fig.15 ,This embodiment designs eight functional modules at the application layer, namely a data model module, a UI module, a command control module, a command parsing module, a command processing module, a remote service module, a measurement and analysis module and a hardware control module, to be suitable for the application scenarios of the measuring instrument.

[0182] Among them, the data model module is used to provide the caching and acquisition functions of control parameters without performing complex data processing operations; the UI module is used to provide the functional interface and parameter control functions; the command control module realizes the command cancellation and restoration functions; the command parsing module is specifically used to parse SCPI instructions; the command processing module is responsible for processing the parsed instructions; the remote service module manages remote interfaces such as USB interface, LAN interface or GPIB interface; the measurement and analysis module is used to process the collected data; the hardware control module realizes the hardware control and data acquisition functions.

[0183] Through modular design, the functions of the measuring instrument software are clearly divided, and each module has clear responsibilities. At the same time, all modules are developed based on the standard interfaces provided by the microkernel architecture, ensuring the independence of modules and the maintainability of the system. This design makes the functions of the measuring instrument software easy to expand and has good cross-platform characteristics.

[0184] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.< / jiujin::isysteminfo> < / qstring>

Claims

1. A microkernel architecture method, characterized in that: include: Constructing a kernel module, wherein the kernel module is used to provide basic functions, the basic functions including module management and module communication; the module management includes module life cycle management, module loading, module unloading, module service and interface management; the module communication includes module messages and notification services, the module messages are used to transmit control information between modules, and the notification service implements event notification between modules based on a subscription-publishing mode; A launcher is constructed, wherein the launcher is used to launch a kernel module and a user module, wherein the user module is a user-defined module that implements a preset business function based on a standard interface provided by the kernel module.

2. The microkernel architecture method according to claim 1, characterized in that: The kernel module provides a module interface and a module core base class for implementing the basic functions.

3. The microkernel architecture method according to claim 2, characterized in that: The construction of the kernel module includes: Constructing a module lifecycle management interface and a module core base class to implement module lifecycle management and interface management in the module management, wherein the module core base class inherits the module lifecycle management interface; Constructing a module service interface, a kernel module service class and a user module service class to implement the module service in the module management, wherein the kernel module service class and the user module service class are used to inherit the module service interface; Constructing a module manager interface to implement unified management of modules, wherein the unified management includes loading the modules and unloading the modules; Constructing a module communication interface to implement the module message; A notification service interface is constructed to implement the notification service.

4. The microkernel architecture method according to claim 3, characterized in that: The module lifecycle management interface and module core base class are constructed, including: In the module life cycle management interface, an increase reference count function, a decrease reference count function and an acquisition reference count function are constructed to implement the module life cycle management, wherein the increase reference count function is used to increase the reference count of the module, the decrease reference count function is used to decrease the reference count of the module; the acquisition reference count function is used to obtain the current reference count of the module; A module core base class is constructed, wherein the module core base class inherits the functions of each function in the module lifecycle management interface.

5. The microkernel architecture method according to claim 4, characterized in that: The building block core base class also includes: In the building module core base class, construct an initialization function to implement the module loading, wherein the initialization function is used for the initialization operation of the module; Constructing a deinitialization function to realize the module uninstallation, wherein the deinitialization function is used for the deinitialization operation of the module; Constructing an interface query function, an interface registration function and an interface deregistration function to implement the interface management, wherein the interface query function is used to query the registered interface in the module, the interface registration function is used to register the interface, and the interface deregistration function is used to deregister the interface; Construct module information access function and module information query function to implement the module service, wherein the module information access function is used to set and obtain module information, and the module information query function is used to query module information, and the module information includes a globally unique identifier, module name, developer, version information, description information, copyright license and module directory.

6. The microkernel architecture method according to claim 1, characterized in that: The basic functions of the kernel module also include module interface quick access, which can obtain any interface of any module and is implemented through an interface access class.

7. The microkernel architecture method according to claim 1, characterized in that: The basic functions of the kernel module also include logging, which is used to record log information during system operation.

8. The microkernel architecture method according to claim 1, characterized in that: The method further comprises: A module creation wizard tool is constructed, wherein the module creation wizard tool automatically generates project source files and engineering configurations by configuring module information so that users can quickly create new modules.

9. A cross-platform system based on a microkernel, characterized in that: include: System layer, which is the underlying operating environment provided by the operating system; A microkernel platform layer, wherein the microkernel platform layer is constructed based on the microkernel architecture method according to any one of claims 1 to 8; The application layer includes a plurality of application modules, which are user modules pre-designed according to different application fields and are constructed based on interfaces, base classes and classes provided by the kernel module in the microkernel platform layer.

10. A measuring instrument, characterized in that: A cross-platform system based on a microkernel as described in claim 9, applied to a measuring instrument; The application modules of the application layer include: Data model module, used to provide caching and acquisition of control parameters; UI module, used to provide functional interface and parameter control; The command control module is used to provide command cancellation and restoration; Command parsing module, used to parse SCPI commands; Command processing module, used to process parsed instructions; Remote service module, used to manage remote interfaces; Measurement and analysis module, used to process the collected data; Hardware control module, used to realize hardware control and data acquisition.

Citation Information

Patent Citations

  • Application server starting method and application server starting system

    CN104104691A

  • Method for hot loading of component-based development integration based on microkernel

    CN105677424A

  • Software architecture method based on microkernel and plug-in

    CN111596969A

  • Web rear-end development framework and construction method thereof

    CN111930355A

  • Microkernel component integration method based on description specifications

    CN114047982A