# EC-Master startup The EC-Master stack has to be initialized once when the application is starting. After this one-time initialization one or more clients may register with the EC-Master. Finally, after all clients are registered the MainDevice can be started. Starting the MainDevice means that all SubDevices will be set into the operational state. Every time the state of the MainDevice has changed the clients are notified about this state-change. ## Asynchronous (deferred) startup - Application calls [`emInitMaster()`](api_general_functions.html.md#_CPPv412emInitMaster10EC_T_DWORDPK22EC_T_INIT_MASTER_PARMS) (…) - Application creates Job Task. See [EC-Master lifecycle](software-integration_example-application.html.md#ec-master-lifecycle) - Application calls `emConfigureMaster()` (…) - Application calls [`emConfigureNetwork()`](api_general_functions.html.md#_CPPv418emConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD) (…) (See “1” ) - Application calls [`emSetMasterStateReq()`](api_general_functions.html.md#_CPPv419emSetMasterStateReq10EC_T_DWORD10EC_T_DWORD10EC_T_STATE) (…) with an appropriate timeout value (See “2” ) - Function [`emSetMasterStateReq()`](api_general_functions.html.md#_CPPv419emSetMasterStateReq10EC_T_DWORD10EC_T_DWORD10EC_T_STATE) (…) returns immediately (See “3” ) - [`emSetMasterStateReq()`](api_general_functions.html.md#_CPPv419emSetMasterStateReq10EC_T_DWORD10EC_T_DWORD10EC_T_STATE) (…) initiated the MainDevice startup procedure (See “4” ) - The MainDevice initializes all SubDevices until all SubDevices reach OPERATIONAL state - After every state change the application will be notified (See “5” ) - After reaching the OPERATIONAL state the system is ready (See “6” ) ## Synchronous startup - Application calls [`emInitMaster()`](api_general_functions.html.md#_CPPv412emInitMaster10EC_T_DWORDPK22EC_T_INIT_MASTER_PARMS) (…) - Application creates Job Task. See [EC-Master lifecycle](software-integration_example-application.html.md#ec-master-lifecycle). - Application calls [`emConfigureNetwork()`](api_general_functions.html.md#_CPPv418emConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD) (…) - Application calls [`emRegisterClient()`](api_general_functions.html.md#_CPPv416emRegisterClient10EC_T_DWORD12EC_PF_NOTIFYP9EC_T_VOIDP20EC_T_REGISTERRESULTS) (…) (See “1” ) - Application calls [`emSetMasterState()`](api_general_functions.html.md#_CPPv416emSetMasterState10EC_T_DWORD10EC_T_DWORD10EC_T_STATE) (…) with an appropriate timeout value (See “2” ) - Inside [`emSetMasterState()`](api_general_functions.html.md#_CPPv416emSetMasterState10EC_T_DWORD10EC_T_DWORD10EC_T_STATE) (…) the MainDevice startup procedure will be initiated (See “3” ) - The application is blocked until the whole startup has finished (See “7” ) - The MainDevice initializes all SubDevices until all SubDevices reach OPERATIONAL state (See “3-6” ) - After reaching the OPERATIONAL state the system is ready (See “6” ) - [`emSetMasterState()`](api_general_functions.html.md#_CPPv416emSetMasterState10EC_T_DWORD10EC_T_DWORD10EC_T_STATE) (…) returns (See “7” ) \\newpage