A microkernel architecture method, a microkernel-based cross-platform system and a measuring instrument
By using a microkernel architecture approach, kernel modules are built to provide module management and communication interfaces, which solves the problems of high code complexity and poor scalability in the monolithic software architecture of measuring instruments, and realizes system simplification and rapid iteration.
Patent Information
- Application Number
- CN202411857970.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2044-12-17
AI Technical Summary
The monolithic software architecture of existing measuring instruments results in high code complexity, poor scalability, difficulty in collaboration, and challenges in rapid iteration and maintenance.
It adopts a microkernel architecture approach, builds kernel modules to provide module management, module communication and interface management, and manages kernel modules and user modules in a unified manner through the launcher, providing standard interface specifications for developers' code implementation.
It reduces system complexity, improves collaborative development efficiency and system scalability, and simplifies function iteration and maintenance processes.
Smart Images

Figure CN119806489B_ABST
Abstract
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
[0002] Currently, the software systems of measuring instruments generally adopt monolithic architecture design, that is, all functional modules such as data acquisition, signal processing and user interface are integrated in one application program. With the continuous enrichment of the functions of measuring instruments, the monolithic application program becomes more and more complex, and the codes of various modules are intertwined, which makes the development, maintenance and testing of the system difficult. For example, in the software of a digital oscilloscope, multiple functional modules such as acquisition control, waveform display and measurement analysis are in the same application program, and the code amount is huge, and modifying the function of one module may affect the normal work of other modules.
[0003] In addition, the extensibility of the software of measuring instruments is limited. When new measurement functions or analysis algorithms need to be added, the entire application usually needs to be redeployed. Even if only a simple measurement parameter is added, the code may need to be recompiled, linked and deployed, which not only consumes time but also may affect the stability of the system, which is not conducive to the rapid iteration and update of instrument functions.
[0004] In terms of development collaboration, the monolithic application of measuring instruments often lacks unified interface standards. During development, it is difficult to standardize the code architecture of different developers for data acquisition, signal processing and other modules due to the lack of unified interface specifications. When other developers write code later, they may need to spend more time to sort out the logic and structure, increasing the development difficulty and cost. 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 be more serious. SUMMARY
[0005] The main purpose of the present application is to provide a microkernel architecture method, a microkernel-based cross-platform system and a measuring instrument, aiming to solve the technical problems of high code complexity, poor extensibility and difficult collaboration in the existing monolithic software architecture.
[0006] To achieve the above object, the application provides a microkernel architecture method, comprising: 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 including module life cycle management, module loading, module unloading, module service and interface management; the module communication including module message and notification service, the module message being used to transfer control information between modules, the notification service being used to realize event notification between modules based on a subscription-published mode; and constructing a launcher, wherein the launcher is used to start the kernel module and a user module, the user module being a custom module for realizing preset service functions of a user based on standard interfaces provided by the kernel module.
[0007] Optionally, the kernel module provides a module interface and a module core base class, which are used to realize the basic functions.
[0008] Optionally, the construction of the kernel module comprises: constructing a module life cycle management interface and a module core base class to realize module life cycle management and interface management in the module management, wherein the module core base class inherits the module life cycle management interface; constructing a module service interface, a kernel module service class and a user module service class to realize 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 realize unified management of modules, wherein the unified management includes the module loading and the module unloading; constructing a module communication interface to realize the module message; and constructing a notification service interface to realize the notification service.
[0009] Optionally, the construction of the module life cycle management interface and the module core base class comprises: constructing an increase reference count function, a decrease reference count function and an obtain reference count function in the module life cycle management interface to realize the module life cycle management, wherein the increase reference count function is used to increase the reference count of a module, the decrease reference count function is used to decrease the reference count of a module, and the obtain reference count function is used to obtain the current reference count of a module; and constructing a module core base class, wherein the module core base class inherits the functions of each function in the module life cycle management interface.
[0010] Optionally, the build module core base class further comprises: in the build module core base class, a build initialization function is constructed to implement the module loading, wherein the initialization function is used for the initialization operation of the module; a build reverse initialization function is constructed to implement the module uninstalling, wherein the reverse initialization function is used for the reverse initialization operation of the module; an interface query function, an interface registration function and an interface reverse registration function are constructed to implement the interface management, wherein the interface query function is used for querying the registered interface in the module, the interface registration function is used for registering the interface, and the interface reverse registration function is used for reverse registering the interface; a module information access function and a module information query function are constructed to implement the module service, wherein the module information access function is used for setting and obtaining the module information, and the module information query function is used for querying the module information, and the module information includes a globally unique identifier, a module name, a developer, version information, description information, a copyright license and a module directory.
[0011] Optionally, the basic function of the kernel module further comprises a module interface shortcut access, and the module interface shortcut access can obtain any interface of any module and is implemented through an interface access class.
[0012] Optionally, the basic function of the kernel module further comprises a log record, which is used for recording log information in system running.
[0013] Optionally, a module creation wizard tool is constructed, wherein the module creation wizard tool automatically generates project source files and engineering configurations through configuration of module information to enable a user to quickly create a new module.
[0014] In addition, to achieve the above object, the application further provides a microkernel-based cross-platform system, comprising: a system layer, which is a bottom running environment provided by an operating system; a microkernel platform layer, which is constructed based on the microkernel architecture method; and an application layer, which comprises a plurality of application modules, the plurality of application modules being user modules pre-designed according to different application fields and constructed based on interfaces, base classes and classes provided by the kernel modules in the microkernel platform layer.
[0015] In addition, the application further provides a measuring instrument, characterized by being constructed based on the microkernel-based cross-platform system and applied to the measuring instrument; wherein the application modules of the application layer comprise: a data model module, which is used for providing cache and acquisition of control parameters; a UI module, which is used for providing a functional interface and parameter control; a command control module, which is used for providing undo and restore of commands; a command analysis module, which is used for analyzing SCPI instructions; a command processing module, which is used for processing the analyzed instructions; a remote service module, which is used for managing remote interfaces; a measurement analysis module, which is used for processing collected data; and a hardware control module, which is used for implementing hardware control and data collection.
[0016] The present application provides basic functions such as module management, module communication and interface management in the kernel module, and uniformly manages the loading of the kernel module and the user module by the launcher. On the one hand, the basic functions are separated from the business functions, reducing the complexity of the system. On the other hand, the code implementation of different developers is standardized 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, improving the extensibility of the system. Specifically, the present application has the following beneficial effects:
[0017] By constructing the kernel module, providing basic functions such as module management, module communication and interface management, separating the basic functions from the business functions, the kernel module only needs to maintain the basic functions, and the user module focuses on implementing the preset business functions. This function separation design significantly reduces the complexity of the system, the functions of each module are more clear, the code structure is more clear, and the development, maintenance and testing of the system become easier.
[0018] Through the standard interface provided by the kernel module, the code implementation of different developers is standardized. The developers must follow the uniform interface specification when developing the user module, so that the modules developed by different developers have a uniform implementation standard, the code style is more uniform and standardized, and the interface calling between the modules is more clear and explicit, thereby significantly improving 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 loading of the kernel module and the user module is uniformly managed by the launcher, so that when adding or modifying functions, only the related user module needs to be developed or modified, without changing other modules, greatly improving the extensibility of the system. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 A structure diagram of a microkernel architecture provided by the first embodiment of the present application;
[0021] Figure 2 A flowchart of starting the kernel module and the user module provided by the present application;
[0022] Figure 3 An inheritance relationship class diagram of the module interface and the module core base class provided by the present application;
[0023] Figure 4 A module service interface class diagram provided by the present application;
[0024] Figure 5 A kernel module class diagram provided by the present application;
[0025] Figure 6 A module manager class diagram provided by the present application;
[0026] Figure 7 a module message diagram provided for the present application;
[0027] Figure 8 a module notification service class diagram provided for the present application;
[0028] Figure 9 a notification service diagram provided for the present application;
[0029] Figure 10 a program initialization diagram provided for the present application;
[0030] Figure 11 an interface access class diagram provided for the present application;
[0031] Figure 12 a module uninstallation time reference problem diagram provided for the present application;
[0032] Figure 13 a module wizard tool display diagram provided for the present application;
[0033] Figure 14 a structure diagram of a microkernel-based cross-platform software architecture provided for the second embodiment of the present application;
[0034] Figure 15 a structure diagram of a measuring instrument software architecture provided for the third embodiment of the present application.
[0035] The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0036] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative work under the premise that the present application falls within the scope of protection.
[0037] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present application are only used to explain the relative positional relationship, movement condition, etc. between components in a certain preset posture (as shown in the drawings), and if the preset posture changes, the directional indications will also change accordingly.
[0038] In the present application, unless otherwise explicitly specified and limited, the terms "connection", "fixing", and the like should be understood in a broad sense, for example, "fixing" can be fixed connection, or detachable connection, or integral; can be mechanical connection, or electrical connection; can be direct connection, or indirect connection through an intermediate medium, can be internal connection of two elements or interaction relationship between two elements, unless otherwise explicitly limited. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.
[0039] In addition, if the present application embodiments involve descriptions such as "first", "second", etc., the descriptions of "first", "second", etc. are only for the purpose of description, and cannot be understood as indicating or implying the relative importance of the indicated technical features or implicitly indicating the number of the indicated technical features. Therefore, the features limited by "first", "second" can explicitly or implicitly include at least one of the features. In addition, the meaning of "and / or" appearing throughout the text includes three parallel schemes. For example, "A and / or B" includes A scheme, or B scheme, or A and B simultaneously satisfy the scheme. In addition, the technical solutions of each embodiment can be combined with each other, but it must be based on the realization of ordinary skilled in the art, when the combination of technical solutions appears contradictory or unachievable, it should be considered that the combination of technical solutions does not exist, nor within the scope of protection claimed by the present application.
[0040] Referring to Figure 1 The first embodiment of the present application provides a microkernel architecture method, comprising:
[0041] S1, 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 including module life cycle management, module loading, module unloading, module service and interface management; the module communication including module message and notification service, the module message being used to transfer control information between modules, and the notification service realizing event notification between modules based on a subscription-published mode;
[0042] S2, constructing a launcher, wherein the launcher is used to start the kernel module and a user module, the user module being a custom module for realizing preset service functions of users based on standard interfaces provided by the kernel module.
[0043] In the embodiment, a kernel module is constructed to provide basic functions, including module management and module communication. The module management includes module lifecycle management, module loading, module unloading, module service and interface management. The module lifecycle management is used to manage the lifecycle of the module, to increase, decrease and obtain the reference count of the module; the module loading and the module unloading are respectively used to load and safely unload the kernel module and the user module; the module service is used to provide the static description of the module; and the interface management is used to register, query and unregister the module interface.
[0044] The module communication includes module message and notification service. The module message is used to realize the point-to-point communication between the modules, and needs to specify the destination module ID when sending, and is used to transmit the control information between the modules. The notification service is realized based on the subscription-published mode, and is used to realize the event notification between the modules. The module can publish the notification, and other modules can receive the notification of the specified type by subscription.
[0045] The launcher is constructed as a program entry, and is used to start the kernel module and the user module. The user module is a custom module developed by the user based on the standard interface provided by the kernel module, and is used to realize the preset business function. Specifically, as shown in the following table, the launcher first obtains the instance pointer of the kernel module service, calls the interface of the kernel module service through the pointer to load the kernel module, reads the user module configuration after the kernel module is loaded, generates the 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. Figure 2
[0046] By separating the basic function from the business function, the kernel module only needs to maintain the basic function, and the user module focuses on realizing the preset business function, so that the complexity of the system is significantly reduced. Meanwhile, the standard interface provided by the kernel module standardizes the code implementation mode of different developers, and improves the efficiency of the collaborative development. In addition, the user can conveniently develop the custom module based on the standard interface provided by the kernel module, and the expansibility of the system is greatly improved.
[0047] As an optional implementation, the kernel module provides a module interface and a module core base class, and is used to realize the basic function.
[0048] Specifically, the kernel module provides a module interface and a module core base class, and is used to realize the basic function. The standard interface specification of the function is defined through the module interface, and the module core base class provides the specific function implementation by inheriting and implementing the interfaces.
[0049] In the interface definition, the abstract class and pure virtual function of C++ language can be used to simulate the interface. In C++ language, interface and class are two core concepts of object-oriented, C++ does not provide the keyword for interface description as Java or C#, but the definition of interface can be simulated by abstract class and pure virtual function.
[0050] For example, refer to Figure 3 The definition rule of interface is described by taking the system information acquisition interface IsystemInfo as an example. The system information acquisition interface is a standard interface for acquiring company name, model number, serial number and other information through pure virtual function. At the same time, the macro definition is used to generate the unique identifier (IID) of the interface, which is used for subsequent registration and query of the interface.
[0051] Firstly, 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 named ISystemInfo to simulate an interface
[0057] class ISystemInfo{
[0058] / / Macro call, expanded to provide 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 as ISystemInfo, which is a pure virtual function, meaning that any class that inherits from ISystemInfo must implement these functions, such as JJModuleInfo in Figure 3 . At the same time, the system information acquisition interface is defined, with a return value of QString type, used to obtain company name (full name and short name), model number, and serial number, etc.
[0070] The JJ_DEFINE_IID macro in the system information acquisition interface is expanded as follows:
[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 access to the interface name, as in the system information acquisition interface, the function returns the name of the interface as ISystemInfo. And the GetIID function generates an ID value corresponding to the interface name and unique by Hash algorithm, this ID value is defined as IID, that is, interface identification, as the identification of subsequent interface registration interface and query interface.
[0077] Subsequently, based on the above interface definition rules, the definition of module interface and module core base class can be implemented. The module core base class (JJModuleCore) implements the corresponding functional interface, and provides specific implementation of basic functions such as module life cycle management, interface management and module information management. As shown in Figure 3 , a schematic diagram of the inheritance relationship class diagram of the module interface and the module core base class is shown. Considering the management of the module life cycle, the module life cycle management interface is constructed, that is, IJJModuleLife shown in the figure, including functions for module life cycle management, such as increasing reference count, decreasing reference count and obtaining current reference count value, and the module core base class JJModuleCore implements the module life cycle management interface, that is, JJModuleCore shown in the figure, thereby realizing the management of the module life cycle. Based on the module life cycle interface, define the module core base class JJModuleCore of all modules, for example, the module core base class can include: implementation of the management interface of the module life cycle; define initialization and deinitialization virtual functions; define interface management related functions; module information access, query functions. The following is an example of the module core base class:
[0078] class JJModuleCore{
[0079] / / Implementation of base class life cycle management interface
[0080] virtual bool AddRef();
[0081] virtual bool DeRef();
[0082] virtual int RefCount();
[0083] / / Define initialization and deinitialization virtual functions
[0084] virtual JJReturn Initialize();
[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] / / Access and query functions for module information
[0091] virtual void SetModuleInfo(UJModuleInfo* pModuleInfo);
[0092] virtual UJModuleInfo* ModuleInfo() const;
[0093] };
[0094] Through the design of the module interface and the module core base class, a unified module development specification is formed. The interface definition specifies the interaction mode between modules, ensuring the consistency of the interface; the base class implementation provides complete basic function support, avoiding repeated development. When developing a new user module, the developer only needs to inherit the module core base class and implement or override the corresponding functions as needed, such as CustomModule1 and CustomModule2 in Figure 3 , thereby improving development efficiency and code maintainability.
[0095] As an optional implementation, step S1 can specifically include:
[0096] S11, constructing a module life cycle management interface and a module core base class to implement module life cycle management and interface management in the module management, wherein the module core base class inherits the module life cycle 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 the unified management of the module, wherein the unified management includes the module loading and the module unloading;
[0099] S14, constructing a module communication interface to implement the module message, and constructing a notification service interface to implement the notification service.
[0100] Specifically, in the construction of the kernel module, a series of interfaces and classes are constructed to implement the basic functions of the kernel module, including the specific implementation of the module life cycle management, the module service, the module management, the module communication and the notification service and other aspects.
[0101] Referring to Figure 3 , a module life cycle management interface IJJModuleLife is constructed, which is inherited by a module core base class JJModuleCore and implements functions in the interface. The life cycle management interface IJJModuleLife defines three functions of AddRef(), DeRef() and RefCount(), which are respectively used to increase the reference count, decrease the reference count and obtain the current reference count value, to implement the management of the module life cycle.
[0102] Referring to Figure 4 , a module service interface IJJModuleService is constructed, and JJKernelService (kernel module service class) and JJmoduleService (user module service class) implement the interface respectively. These classes provide the management functions of the startup mode, the directory path and the detailed information of the module through functions such as StartupMode(), ModuleDir(), ModuleInfo(), and implement the loading and unloading of the module 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 attributes and functions are defined in the kernel module service class. In terms of attributes, m_startupMode is used to record the startup mode of the module, which can take values including DoNotRun (not loaded), RunAtAppSatrtup (loaded at initialization), RunAtFirstUsingTime (loaded at first use), etc., which is 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 is a pointer to the module information structure, which is used to obtain detailed information of the module, which is obtained through the ModuleInfo() function; m_pModule is a pointer to 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 performs the startup operation of the module, including loading the module and initializing resources, etc., and returns a JJReturn type value indicating the startup result; the Shutdown() function performs the closing operation of the module, including resource release, etc., and also returns a JJReturn type value indicating the closing 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 directory path, detailed information, and instance pointer of the module, respectively.
[0119] Through these properties and functions, the kernel module service class can implement the management of the complete life cycle of the module, including the configuration information management, startup control, and state monitoring of the module, etc.
[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 of kernel module loading and user module loading. Referring to Figure 2 , first, a kernel module service instance is constructed as a static unique instance in the system. The launcher obtains a pointer of the kernel module service instance as a program entry. Through the pointer, the launcher can call the interfaces provided by the kernel module service instance, thereby realizing loading of the kernel module. After the kernel module is loaded, a module manager in the kernel module reads 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. The kernel module service instance and the user module service instance both 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 ordered loading of the kernel module and the user module is realized, ensuring the reliability and controllability of the system initialization process. At the same time, by managing the user module through the configuration file, good flexibility is provided, facilitating the adjustment of module configuration of the system.
[0135] Referring to Figure 5 , three key interfaces are constructed in the kernel module. They are the module manager interface IJJModuleManager, the module communication interface IJJModuleComm, and the notification service interface IJJNotifyService.
[0136] Referring to Figure 6 , the module manager interface IJJModuleManager is used to realize the unified management of modules. The kernel module reads user module configuration through the module manager, generates a module service instance, and realizes loading and unloading of the module according to the module path configuration information in the module service, thereby realizing standardized management of the module loading and unloading process and ensuring that the module can be correctly loaded and safely unloaded in the system.
[0137] The constructed module communication interface IJJModuleComm is used to realize the message transmission function between modules. As Figure 7 indicated, the module message realizes point-to-point message sending, and the destination module ID needs to be specified when sending the message, thereby realizing direct communication between modules. Unlike the notification service, the module message determines the receiving module at the sending end, and is used for direct control information transmission between modules. Referring to Figure 8 The shown module notification service class diagram builds a notification service interface for implementing the event notification mechanism between modules. As shown in Figure 9 The notification service adopts a subscription-publishing mode, as shown. A module can publish a notification, and other modules interested in this type of notification can receive the notification by subscribing. This mechanism decouples the event source and the event handler, and provides a more flexible inter-module communication mode. Unlike the point-to-point communication of module messages, the notification service supports a module sending the same notification to multiple subscribing modules. For both notification messages and module messages, an asynchronous message mechanism based on the Qt event system is adopted, and an event (QEvent) in Qt is encapsulated.
[0138] Meanwhile, in the module core base class JJModuleCore, interface management functions such as QueryInterface(), RegisterInterface(), and UnregisterInterface() are built, which are respectively used for interface query, registration, and deregistration, to provide a unified management mechanism for inter-module interface access, and implement interface management.
[0139] Through the above interface and class system design, a complete module management and communication framework is established, which not only implements various basic functions in the kernel module, but also, through interface definition and class implementation, makes the system have good extensibility and maintainability. The module life cycle management ensures the stability of the module running, the module service provides a unified module management mechanism, and the module communication and notification service implements flexible inter-module interaction.
[0140] As an optional implementation, the above step S11 can specifically include:
[0141] S111, building an increase reference count function, a decrease reference count function, and a get 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 a module, the decrease reference count function is used to decrease the reference count of a module, and the get reference count function is used to get the current reference count of a module;
[0142] S112, building a module core base class, wherein the module core base class inherits the functions of the functions in the module life cycle management interface.
[0143] Specifically, a series of functions are built in the module life cycle management interface and the module core base class to implement the module management function.
[0144] In the module life cycle management interface, three functions are defined based on the reference counting mechanism, which are AddRef() function, DeRef() function and RefCount() function. 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 decreases to zero, it indicates that there is no other module using the target module, at which time the module can safely perform the uninstall operation. At the same time, in the module core base class JJModuleCore, all functions of the above module life cycle management interface are implemented to ensure that the life cycle of the module is correctly managed.
[0145] As an optional implementation, the above step S111 can specifically include:
[0146] In the module core base class, an initialization function is constructed to implement the module loading, wherein the initialization function is used for the initialization operation of the module;
[0147] An anti-initialization function is constructed to implement the module uninstallation, wherein the anti-initialization function is used for the anti-initialization operation of the module;
[0148] An interface query function, an interface registration function and an interface anti-registration function are constructed to implement the interface management, wherein the interface query function is used to query the registered interfaces in the module, the interface registration function is used to register the interfaces, and the interface anti-registration function is used to anti-register the interfaces;
[0149] A module information access function and a module information query function are constructed to implement the module service, wherein the module information access function is used to set and obtain the module information, and the module information query function is used to query the module information, and the module information includes a globally unique identifier, a module name, a developer, version information, description information, copyright license and a module directory.
[0150] Specifically, in addition to implementing all functions of the module life cycle management interface, the constructed module core base class also constructs an initialization function Initialize() and an anti-initialization function Uninitialize(), which are respectively used for the initialization and anti-initialization operations of the module. Referring to Figure 10 The shown program initialization flow, launcher as program entry, first create based on Qt event loop, and then call kernel module service to start kernel module. After the kernel module is started, the initialization function Initialize() is automatically called for initialization. Since the initialization function Initialize() and the anti-initialization function Uninitialize() are defined as virtual functions, subclasses can override these functions to implement custom initialization and cleaning processes. Specifically, the initialization function Initialize() is used to perform the initialization work required by the module; and the anti-initialization function Uninitialize(), which is called before the module is unloaded, is used to perform resource release and other cleaning operations. 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 builds a set of interface management functions, including the interface query function QueryInterface(), the interface registration function RegisterInterface(), and the interface deregistration function UnregisterInterface(), to implement interface management in the module. Among them, the interface query function QueryInterface() is used to query the registered interfaces in the module, and is queried through IID (Interface Identifier). This function receives two parameters: id parameter and pInterface parameter. The id parameter represents the unique identifier (IID) of the interface to be queried; the pInterface parameter is a pointer to a pointer, used to store the queried interface pointer. The interface query function QueryInterface() returns an int type value, indicating 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 interface registry; the interface deregistration function UnregisterInterface() is used to deregister the interface, remove the specified interface from the system 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 built in the module core base class, which are used for module information access and query. Among them, the module information contains the 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., providing support for module management and maintenance.
[0153] Through the above function, stability and reliability of the module running can be ensured, and flexible interface management and information query function are provided.
[0154] As an optional implementation, the basic function of the kernel module further includes module interface shortcut access, which can obtain any interface of any module and is implemented through an interface access class.
[0155] Specifically, the microkernel architecture has extensive use of interfaces, and thus frequent access to the interfaces is inevitable. Therefore, an interface access class is designed to access the interfaces of the module quickly and with a small amount of code. Referring to Figure 11 The interface access class is provided in the kernel module to implement the shortcut access function. The interface access class needs two key parameters: module ID and interface ID. Among them, the module ID is passed in through the constructor parameter, and the interface ID is obtained through the GetIID() static function to obtain the unique identifier of the interface type. Based on the two parameters, the pointer instance of the kernel module is first obtained, and then the pointer instance of the target interface is obtained through the QueryInterface interface query function of the kernel module.
[0156] By overloading the pointer operator '->', the interface access class can implement the function of calling the interface in the form of a pointer, and 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 unloaded, it is necessary to perceive whether there is another module that is referencing the interface of the self module, otherwise, directly unloading will cause errors in the module being referenced. Therefore, in order to ensure the safety of interface access, as shown in the following formula, a 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 empty function. When the module being referenced needs to be unloaded, the system checks whether the reference count is zero, and only when it is ensured that no other module is using the module, the unloading operation can be performed, otherwise, it will be blocked and waited through the Qt event loop mechanism, thereby effectively preventing the problem that the module is incorrectly unloaded when being referenced by other modules. Figure 12
[0162] As an optional implementation, the basic function of the kernel module further includes log recording, for recording log information in system running.
[0163] Specifically, the basic function of the kernel module can further include a log recording function for recording log information in system running.
[0164] For example, based on log4cpp, a configurable format log printing function is implemented, and a configurable format log printing is encapsulated, including carriage return, line feed, timestamp, priority, print interval, thread name, and processor time.
[0165] At the same time, by using a variable parameter macro, a variable parameter printing mode similar to printf() is implemented, making the 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, complete recording of the system running state can be realized, thereby providing important support for debugging and maintenance of the system.
[0169] As an optional implementation, the micro-kernel architecture method can further include:
[0170] A module creation wizard tool is constructed, wherein the module creation wizard tool automatically generates project source files and project configurations by configuring module information to enable a user to quickly create a new module.
[0171] Specifically, according to the development requirement of the micro-kernel architecture, a module creation wizard tool is designed. Referring to Figure 13 The tool provides a visual configuration interface for a developer to input basic information of the module, including configuration items such as project name, module class name, module directory, and the like. After the developer completes the configuration, the developer clicks a generate project button, and the tool automatically generates source files and project configurations of the project. The generated project files can be directly added to an existing project for compilation.
[0172] Through this design, the workload of the developer when creating a new module is greatly reduced, and the developer can focus more energy on development of application functions, thereby improving development efficiency.
[0173] The second embodiment of the present application provides a micro-kernel-based cross-platform system, which can include a system layer, a micro-kernel platform layer, and an application layer, wherein
[0174] The system layer provides a bottom running environment for an operating system; the micro-kernel platform layer is constructed based on the micro-kernel architecture method of any of the above embodiments; and the application layer includes a plurality of application modules, which are user modules pre-designed according to different application fields and constructed based on interfaces, base classes, and classes provided by kernel modules in the micro-kernel platform layer.
[0175] Specifically, referring to Figure 14 The micro-kernel-based cross-platform system adopts a layered design and sequentially includes, from bottom to top, the system layer, the micro-kernel platform layer, and the application layer.
[0176] The system layer provides a bottom running environment for an operating system and provides basic system services for the upper layer. The micro-kernel platform layer is constructed based on the micro-kernel architecture method of the first embodiment and provides basic function support such as module management and module communication. The application layer includes a plurality of application modules, which are user modules pre-designed according to requirements of different application fields and constructed by inheriting and implementing interfaces, base classes, and classes provided by kernel modules in the micro-kernel platform layer.
[0177] By means of the layered architecture design, the rational division of system functions is realized, so that each layer has a clear responsibility. The system layer provides bottom support, the micro-kernel 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, since the micro-kernel platform layer shields the differences of the underlying operating system and provides a unified interface for the upper-layer application, the software system developed based on the architecture can be conveniently transplanted to different operating system platforms for running, and has good cross-platform characteristics.
[0178] The third embodiment of the present application provides a measuring instrument, which is constructed based on the micro-kernel-based cross-platform system of the second embodiment and applied to the measuring instrument; wherein the application modules of the application layer can include a data model module, a UI module, a command control module, a command analysis 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 the caching and acquisition of control parameters; the UI module is used to provide the function interface and parameter control; the command control module is used to provide the undo and restore of commands; the command analysis module is used to analyze SCPI instructions; the command processing module is used to process the analyzed instructions; the remote service module is used to manage remote interfaces; the measurement analysis module is used to process collected data; and the hardware control module is used to implement hardware control and data collection.
[0180] Specifically, the third embodiment of the present application provides a software architecture of a measuring instrument, which is constructed based on the micro-kernel-based cross-platform software architecture of the second embodiment and applied to the measuring instrument.
[0181] With reference to Figure 15 In the application layer, eight functional modules are designed, which are a data model module, a UI module, a command control module, a command analysis module, a command processing module, a remote service module, a measurement analysis module and a hardware control module, to adapt to the application scenarios of the measuring instrument.
[0182] The data model module is used to provide the caching and acquisition of control parameters without performing complex data processing operations; the UI module is used to provide the function interface and parameter control functions; the command control module implements the undo and restore functions of commands; the command analysis module is specially used to analyze SCPI instructions; the command processing module is responsible for processing the analyzed instructions; the remote service module manages remote interfaces such as USB interfaces, LAN interfaces or GPIB interfaces; the measurement analysis module is used to process collected data; and the hardware control module implements the control of hardware and the function of data collection.
[0183] Through the modular design, the clear division of each function of the measurement instrument software is realized, and each module has a clear responsibility. Meanwhile, all the modules are developed based on the standard interface provided by the microkernel architecture, which guarantees the independence between the modules and the maintainability of the system. This design makes the functions of the measurement instrument software easy to extend and has good cross-platform characteristics.
[0184] The above merely describes the preferred embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation using the content of the specification and drawings, or direct or indirect application in other related technical fields, is also included in the patent protection scope of the present application.< / jiujin::isysteminfo> < / qstring>
Claims
1. A microkernel architecture method, characterized in that, include: A kernel module is constructed, which provides basic functionalities, including module management and module communication. Module management includes module lifecycle management, module loading, module unloading, module services, and interface management. A series of functions are constructed within the module management module to implement these functionalities. Module communication includes module messaging and notification services. Module messaging is used to transmit control information between modules, and the notification service implements event notifications between modules based on a publish-subscribe pattern. The basic functionalities of the kernel module also include quick access to module interfaces, which allows access to any interface of any module, implemented through an interface access class. The module management includes implementing module lifecycle management by constructing a module lifecycle management interface IJJModuleLife and a module core base class JJModuleCore that inherits from this interface. The module lifecycle management interface is implemented through a reference counting mechanism, including constructing functions for increasing the reference count, decreasing the reference count, and obtaining the reference count. The function for increasing the reference count is used to increase the reference count of the module, the function for decreasing the reference count is used to decrease the reference count of the module, and the function for obtaining the reference count is used to obtain the current reference count of the module. The module management also includes implementing module services by constructing a module service interface IJJModuleService, a kernel module service class JJKernelService, and a user module service class JJModuleService. The kernel module service class and the user module service class implement the module service interface and include startup mode, module directory, module information pointer and module instance pointer attributes, as well as a startup function for module loading and a shutdown function for module unloading. The module management also includes unified management of modules by building the module manager interface IJJModuleManager, including dynamically loading and unloading user modules based on user module configuration information; The module management also includes interface management through interface query functions, interface registration functions, and interface unregistration functions built in the module core base class JJModuleCore; wherein, the interface registration function and interface unregistration function dynamically manage the registration and removal of interfaces through a hash table with the unique identifier of the interface as the key and the interface pointer as the value; The module communication includes: the constructed module communication interface IJJModuleComm is used to implement the message passing function between modules. The module message realizes point-to-point message sending. When sending a message, the destination module ID needs to be specified to realize direct communication between modules. The notification service is implemented by building the notification service interface IJJNotifyService. It uses a publish-subscribe pattern to notify modules of events and supports a module to send notifications asynchronously to multiple modules that subscribe to the same event type. The module message and notification services are both encapsulated based on the Qt event system and use an asynchronous message passing mechanism. Construct a launcher, wherein the launcher is used for: First, obtain the instance pointer of the kernel module service, and then use the pointer to call the interface of the kernel module service to load the kernel module. After the kernel module is loaded, the module manager in the kernel module reads the user module configuration and generates a user module service instance based on the configuration, and then loads the corresponding user module. The user module is a custom module that allows users to implement preset business functions based on the core base class and standard interfaces provided by the kernel module.
2. The microkernel architecture method according to claim 1, characterized in that, The core base class of the building module also includes: In the core base class of the building module, an initialization function is constructed to implement the module loading, wherein the initialization function is used for the initialization operation of the module; Construct an uninitialization function to unload the module, wherein the uninitialization function is used for the uninitialization operation of the module; An interface query function, an interface registration function, and an interface unregistration function are constructed to implement the interface management. The interface query function is used to query the registered interfaces in the module, the interface registration function is used to register interfaces, and the interface unregistration function is used to unregister interfaces. Construct module information access functions and module information query functions to implement the module service. The module information access functions are used to set and retrieve module information, and the module information query functions are used to query module information. The module information includes a globally unique identifier, module name, developer, version information, description information, copyright license, and module directory.
3. The microkernel architecture method according to claim 1, characterized in that, The basic functionality of the kernel module also includes logging, which records log information during system operation.
4. The microkernel architecture method according to claim 1, characterized in that, The method further includes: A module creation wizard tool is provided, wherein the module creation wizard tool automatically generates project source files and project configuration by configuring module information so that users can quickly create new modules.
5. A microkernel-based cross-platform system, characterized in that, include: The system layer 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-4; The application layer includes multiple application modules, which are user modules pre-designed according to different application domains and are constructed based on the interfaces, base classes and classes provided by the kernel modules in the microkernel platform layer.
6. A measuring instrument, characterized in that, Based on the microkernel-based cross-platform system construction described in claim 5, it is applied to measuring instruments; The application modules of the application layer include: The data model module is used to provide caching and retrieval of control parameters; The UI module is used to provide a functional interface and parameter control. The command control module provides command cancellation and redo functionality; The command parsing module is used to parse SCPI commands; The command processing module is used to process the parsed instructions; The remote service module is used to manage remote interfaces; 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.
Citation Information
Patent Citations
Microkernel component integration method based on description specifications
CN114047982A
Method for building communication terminal test instrumentation control platform based on microkernel
CN1829127A