Table of Contents

12 Starting DQMH Modules

Launching a module

There are two ways of launching a module:

Internally

Externally

The following sections discuss aspects and ways of launching modules externally.


Startup / Synchronization

The DQMH Framework helps developers write reliable and robust code by taking care of various aspects like reference lifetime and synchronization of actions. When starting a module, the module itself creates all required resources like event references to own them and dictate their lifetime.

To ensure that the code starting the module receives any resources only after they've been created, and to make sure that the code only continues execution once the module is ready to receive requests, the DQMH Framework provides the process described in this section.

Process

1. Start and Obtain Broadcasts

[A] Start Module.vi needs to wait until the broadcast event references have been created by the module.

2. Continue to MHL
3. Sync with Caller

[B] The module needs to wait until the calling code has registered for the broadcast events.

4. Register for Broadcasts
5. Sync with Main.vi

The caller is now finished with starting the child module

6. Sync with Caller
7. Module Did Init

The child module is now finished with starting

Child module startupChild module startupCalling codeModule codeSynchronize Module Events.viStart Module.viInit Module.viSynchronize Caller Events.viSynchronize Module Events.viStart Module.viCaller.viMain.viInit Module.viMHLSynchronize Caller Events.viSynchronize Module Events.viSynchronize Module Events.viStart Module.viStart Module.viCaller.viCaller.viMain.viMain.viInit Module.viInit Module.viMHLMHLSynchronize Caller Events.viSynchronize Caller Events.viSynchronize Module Events.viStart Module.viInit Module.viSynchronize Caller Events.viCall "Start Module.vi"Start asynchronous callWait on Module SyncCall "Init Module.vi"Returns events refsStart EHL/MHL/HLsExecute MHL's Initialize caseCall for synchronizationWait on Module SyncModule Sync DoneWait on Event SyncReturns broadcasts refsRegister for broadcastsCall for synchronizationWait on Event SyncEvent Sync DoneModule startedContinue Initialize caseSend Module Did Init broadcastReceive Module Did Init broadcastModule initialized

Implications

Any rendezvous functions mentioned above will wait for the module timeout defined in Module Timeout–constant.vi (default = 5s) before returning an error.

It becomes apparent that 2. Continue to MHL in the schema shown above is the critical path. If any code is placed before the MHL starts (i.e. before Synchronize Caller Events.vi inside the “Initialize” case) which takes longer to execute than the module timeout, the startup process of the module will fail.

Caveat

Be careful when adding code outside of the EHL/MHL/HLs, especially code that needs to execute before entering the EHL/MHL/HLs and might therefore delay entering the “Initialize” MHL case. If it takes too long to reach the “Initialize” case, the module synchronisation will time out and fail, and the Start Module.vi will throw error 403683 (“Module was unable to synchronise events”).


Starting Child Modules

Make sure to also browse our HSE Coding Conventions on Parent/Child Modules.

1. From a Simple VI


2. At Module Start


3. In the EHL


4.1 In the MHL - Variant 1


4.2 In the MHL - Variant 2


When to start

The concept of placing the code for starting modules inside EHL/MHL and having a request or Queue message trigger the starting of child modules gives control and flexibility over when and from where modules are actually (re)started. It does beg the question, though, of where and when to actually send the request or message triggering the start.


Better Practices

Our better practices section on Coding Conventions contains a page on DQMH®:
DQMH Coding Conventions