Initialization

TODO - Approval item - SPECIFICATION REVIEW NEEDED

S1

Creation order Prior to Hassayampa (Version 3.0) objects shall be initialized in the order in which they are created. As of Hassayampa (Version 3.0) objects shall be initialized in the order in which they are created only when the init_sequence global variable is set to CREATION. If any object init() returns 0, the entire model initialization sequence shall be regarding as having failed and the simulation shall not start. If all object init() functions return 1, the initialization shall be regarded as successful and the simulation shall proceed with the main event loop. Any other return value is considered an error. (R1).

S2

Deferred initialization As of Hassayampa (Version 3.0), when init_sequence is set to DEFERRED objects shall be initialized in the order in which they are created, provided that when init() call returns the value 2 indicating that deferred initialization is desired, the initialization sequence shall call init() again after all other object init() calls are done. This process shall be repeated for all deferred objects until all object init() calls return the value 1. This process shall be repeated no more than init_max_defer times for any given object (R2).

S3

Rank initialization As of Hassayampa (Version 3.0), when init_sequence is set to BOTTOMUP or TOPDOWN, objects shall be initialized in the bottom-up or top-down rank order, respectively, with consideration given to deferred return values from init() as described in S2 (R3)

S4

Object locking As of Hassayampa (Version 3.0), while init() is running, the object shall be locked and the OF_LOCKED flags shall be set (R4).

S5

Deferred flag As of Hassayampa (Version 3.0), when the object initialization is deferred, the object flag OF_DEFERRED shall be set (R5).

S6

Automatic deferral As of Hassayampa (Version 3.0), when init_sequence is set to AUTO automatic object deferral shall be enabled (R6).

S7

Automatic deferral class override As of Hassayampa (Version 3.0), the flag PC_NODEFERRAL shall be used in the class_register() call to indicate that objects of the class should not be included in any automatic deferral determination (R7).

Automatic deferral object override As of Hassayampa (Version 3.0), the flag PF_DEFER shall be used in the property_register() call to indicate that objects of the class should be included in any automatic deferral determination when PC_NODEFERRAL is specified, or should not be included when PC_NODEFERRAL is not specified (R7).

S8

Initialization time As of Hassayampa (Version 3.0), the global clock and all object clocks shall be set to the starttime immediately after the objects are created and before the GLM values are set (R8).

S9

Initialization state As of Hassayampa (Version 3.0), all objects will have the OF_INIT flag set until after initialization is successfully completed (R9).

Approval item: TECHNICAL MANUAL

Before Hassayampa

The following initialization process is implemented in exec.c/init_all():

set all clock to TS_INIT 
if initialize all instances fails return error
if initialize all loadshapes fails return error
for each object
  if initialize object fails return error
  if object must be named and is not named return error
end for

The following initialization process is implemented in object.c/object_init():

if initialize the object fails, then return error

Note

The object clock remains set to the initial clock value 0 until the first call to sync, at which time sync uses the object clock value to determine whether any late initialization will take place.

As of Hassayampa (Version 3.0)

Object creation set the OF_INIT flag.

The following initialization process is implemented in exec.c/init_all():

set the global clock to the start time
if initialize all instances fails, then return error
if initialize all loadshapes fails, then return error
if initialize all objects fails, then return error
return ok

The process to initialize all objects is implemented in object.c/object_initall():

when initialization sequence is creation
  for each object
    if initialize object fails, then return error
or when initialization sequence is deferred or auto
  add all objects to initialization list
  do until initialization list empty
    for each object in initialization list
      if initialize object fails, then return error
      else if initialize object ok, then remove object from initialization list
    end for
  end do
or when initialization sequence is topdown or bottom up
  add all objects to initialization list
  do until initialization list empty
    for each rank in initialization sequence
      for each object in initialization list
        if initialize object fails, then return error
        else if initialize object ok, then remove object from initialization list
      end for
    end for
  end do
end when

The process to initialize an object is implemented in object.c/object_init():

lock the object
set the object clock to start time
if the object is not named but the class requires it be named, then return error
if initialization sequence is creation or auto, then
  if the object's parent clock is not set and the PC_NODEFERRAL flag is not set, then return deferred
  if any of the object's properties are objects that are not initialized and the property's PF_DEFER is the same as the class's PC_NODEFERRAL flag, then return deferred
if initialize the object fails, then return error
clear the OF_INIT flag
unlock the object
return success

Note

The object clock value is set to the start time during object initialization. As a result, synchronization functions may no longer implement late initialization. The requirement for late initialization is preempted by the use of deferred initialization and all objects that employed late initialization prior to Hassayampa (Version 3.0) should be upgraded to use deferred initialization instead.

  • Initialization
    • Requirements
    • Specification
    • Technical manuals