Skip to content

Some code that can generate enumeration/constants to ease the human reading of code. Currently uses out of date XML that should be fixed.

License

BSD-2-Clause, Unknown licenses found

Licenses found

BSD-2-Clause
LICENSE
Unknown
license.txt
Notifications You must be signed in to change notification settings

kastork/DISEnumerations

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DIS Enumeration

This is older, essentially obsolete software, but the the product generated is still somewhat useful.

What happened was SISO did an initial description of DIS entities in siso-std-10.xml, which contains names and descriptions to accompany arbitrary numbers. The problem is that the format of the code here should be rewritten to match the new XML format used by SISO. But, in the end, it's kind of useful as is.

This is what tXML looked like for PDU types, for example:

 <enum length="8" id="2" cname="pduheader.pdutype" name="PDU Type" source="3.2">
    <enumrow id="0" description="Other"/>
    <enumrow id="1" description="Entity State"/>
    <enumrow id="2" description="Fire"/>
    <enumrow id="3" description="Detonation"/>
    <enumrow id="4" description="Collision"/>
    <enumrow id="5" description="Service Request"/>

That shows some English, "Entity State," associated with the number 1, meaning that all entity state PDUs should have an ID number of 1. It's the number that's actually included in the packet transmitted over the network or DIS code.

We want language constants that let us use english-like, but also code-friendly variable names that help us read code. This, for example, is not very readable:


if(aPdu.type == 1)
{
   doSomething();
}

What does 1 mean? The following is easier to read:

if(aPdu.type == PduType.ENTITY_STATE.value)
{
  doSomething();
}

It's easier to understand the purpose of the code in the second quotation.

An example Java enumeration file used for enumerataion values

public enum PduType 
{

    OTHER(0, "Other"),
    ENTITY_STATE(1, "Entity State"),
    FIRE(2, "Fire"),
    DETONATION(3, "Detonation"),
    COLLISION(4, "Collision"),
    SERVICE_REQUEST(5, "Service Request"),
    RESUPPLY_OFFER(6, "Resupply Offer"),
...  
    /** The enumerated value */
    public final int value;

    /** Text/english description of the enumerated value */
    public final String description;

And so on. In this case the XML includes the text "Entity State", including the space. That's translated into a Java-friendly variable name, entirely capitalized, with no spaces in the ENTITY_STATE name. Other examples of the text from the XML can include commas and such. The generating code translates it into language-firendly text. The constant name used, such as "ENTITY_STATE", is somewhat arbitrary.

Again, the XML format from SISO has changed some since this code has been written, so the code needs to be modified a bit.

Also, I've added a non-generated PduTypeDIS7 file manually, rather than generating it. DIS7 has some slightly different names for some PDUs, kind of, since the PDU names aren't exactly official. There's no XML to generated it, but it's still useful to have the PDU types enumeration for DIS7. So I just wrote a manual DIS7 class for that.

Also, there are some generated enumerations for C# and c++. Pretty primitive, though.

DMcG

About

Some code that can generate enumeration/constants to ease the human reading of code. Currently uses out of date XML that should be fixed.

Resources

License

BSD-2-Clause, Unknown licenses found

Licenses found

BSD-2-Clause
LICENSE
Unknown
license.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TSQL 51.8%
  • C++ 23.3%
  • Java 12.0%
  • C# 10.5%
  • XSLT 2.4%