nasa / TrickHLA

TrickHLA: An IEEE 1516 High Level Architecture (HLA) Simulation Interoperability Standard Implementation for Trick Base Simulations
Other
38 stars 15 forks source link

Allow object instances to be associated to threads in the input file #124

Closed dandexter closed 1 year ago

dandexter commented 1 year ago

TrickHLA supports Trick child threads and currently requires the HLA object instances associated with each thread to be specified at compile time and not run time. Allow object instances to be associated to Trick child threads in the input file.

dandexter commented 1 year ago

Object instances can now only be associated to Trick child threads by setting the configuration in the input file only. Support for associating object instances in the S_define file is no longer supported.

1) Associate Trick child threads in the S_define file by including the TrickHLAThread.sm sim-module and either creating THLAThreadSimObject instance or extending THLAThreadSimObject for your simulation-object.

#include "THLAThread.sm"
THLAThreadSimObject THLAThread1( THLA.federate,
                                 THLA_DATA_CYCLE_TIME,  // Data cycle time for this thread.
                                 1 );                    // Trick child thread 1 (i.e. C1).

OR

#include "THLAThread.sm"
class SpaceFOMRefFrameSimObject : public THLAThreadSimObject {
  public:
   SpaceFOMRefFrameSimObject( RefFrameData & frame_data_ptr,
                              TrickHLA::Federate & thla_fed,
                              double data_cycle,
                              unsigned short _THREAD_ID,
                              unsigned short _INIT = 59  )
      : THLAThreadSimObject( thla_fed, data_cycle, _THREAD_ID )
   {
   ...
   }

2) Configure the HLA Object Instances that are associated with the Trick child thread in the input file. The 'thread_ids' are a comma separated string of Trick child thread ID's.

# TrickHLA Example 
THLA.manager.objects[0].FOM_name            = 'Test'
THLA.manager.objects[0].name                = 'A-side-Federate.Test'
THLA.manager.objects[0].create_HLA_instance = True
THLA.manager.objects[0].thread_ids          = "1, 2" # Trick Child Threads 1 and 2
# SpaceFOM Example using TrickHLAObjectConfig.py Modified-data file
# located in the Modified_data directory of TrickHLA.
from Modified_data.TrickHLA.TrickHLAObjectConfigimport *

root_frame = Modified_data.TrickHLA.TrickHLAObjectConfigimport( 
   True,
   'Object_Instance_Name',
   'FOM_name',
   None,   # frame_lag_comp
   None,    # frame_ownership
   None,   # frame_S_define_instance
   None,    # frame_thla_manager_object
   '1, 2'  )  # Trick child threads 1 and 2
)

3) For a debug level of 4 or higher, a summary of the object instances and associated threads will be printed to the console.

TrickThreadCoordinator::verify_trick_child_thread_associations():500 Summary of object instance and thread associations from the input file:
ThreadID  Cycle  Object-Instances
0     0.25   
1     0.25   'RootFrame' 
2     0.25   'FrameA' 
Object-Instance   ThreadIDs
'RootFrame'   1
'FrameA'      2