openlvc / disco

Java library for Distributed Interactive Simulation
11 stars 3 forks source link

Add a custom PDU requires adding a value to the PduType enum #57

Closed dlutz2 closed 6 months ago

dlutz2 commented 2 years ago

To integrate a new custom PDU into disco, it is necessary to add a value to the PduType enumeration which requires a fork of the whole codebase and results in a distro which is not compatible with the original disco. If the PduType was a e.g. a Map, it would be possible to extend disco using disco.jar directly. Since this issue will also occur with any enum based on the SISO enums (latest version just out with a bunch of new entities), it would seem to be a good idea there as well. thanks

BTW, we convert all SISO data to JSON and load them at runtime to avoid the above. We would like to do the same with PDUs.

michaelrfraser commented 6 months ago

Hi dlutz2, this should now have been addressed in https://github.com/openlvc/disco/pull/64

We've removed all custom PDUs out of the codebase, and provided a way for 3rd parties to register custom PDU types and HLA mappers decoratively.

To register a custom PDU:

  1. Create a Custom PDU class that extends PDU. In the constructor, call the super constructor with one of the custom slot values declared in the PduType enum
  2. Register the Custom PDU with disco at runtime via DisConfiguration.registerCustomPdu()

Registering HLA mappers for custom PDUs/HLA Objects is a similar process:

  1. Include FOMs where custom objects are declared bu calling RprConfiguration.registerExtensionModules()
  2. Create a Customer mapper class that extends AbstractMapper to map between custom HLA object and PDU
  3. Register mappers with disco at runtime via RprConfiguration.registerExtensionMapper()