The Location Code Node ID Assignment Mode can be used for setting the Node ID of an AEODRS CM based on the mount site ID or for using the look-up table method specified in IOP. For this option to be available in the Configuration Editor, you must select the IOP Configuration File Type.







When this mode is selected, the Component will combine the Static Node ID specified in the configuration file, with a Location Code such that Node ID = (StaticNodeID & 0xF0) | LocationCode. 


Since the details on how the LocationCode is obtained is implementation specific, we provide the ability to specify a custom LocatonCodeReader. If a custom LocatonCodeReader reader is not specified, the 

LocationCode will default to 0x0F.



To specify a custom LocationCodeReader


  1. Implement a new class that inherits from the openjaus::util::OjAbstractLocationCodeReader class which is in the org.openajsu.iop-v3.cpp project.
    1. The start() method is called when the LocationCodeReader is started. Any threads/timers that need to be started should be done here.
    2. The stop() method is called when the LocationCodeReader is stopped. Any threads/timer started in the start() method should be stopped here.
    3. When the locationCode is known, call the protected setLocationCode(uint8) method. This will automatically set the Node ID in the component(s) as necessary.
  2. In your main application, instantiate your custom LocationCodeReader class and set it as the LocationCodeReader using the static openjaus::util::LocationCodeReader::set() method.
    1. This should be done before any of the components are started.



Example:


MyCustomLocationCodeReader.h

#include <openjaus/util/OjAbstractLocationCodeReader.h>

...

class OPENJAUS_EXPORT MyCustomLocationCodeReader : public openjaus::util::OjAbstractLocationCodeReader
{
public:
    MyCustomLocationCodeReader ();
    virtual ~MyCustomLocationCodeReader ();

    virtual void start();
    virtual void stop();
};


MyCustomLocationCodeReader.cpp

MyCustomLocationCodeReader::MyCustomLocationCodeReader()
{
    // Initialize any class resources
}

MyCustomLocationCodeReader::~MyCustomLocationCodeReader()
{
    // Clean up any class resources
}

void MyCustomLocationCodeReader::start()
{
    // Start any threads or timers that might be needed to read the location code

    // When the location code is known, use the setLocationCode method to propagate the value 
    setLocationCode(0x05);
}

void MyCustomLocationCodeReader::stop()
{
    // Stop any threads or timers that were started in the start() method
}


main.cpp

int main()
{
    ...

    // Set the code that will read the CM location code (from the config lines)
    MyCustomLocationCodeReader reader;
    openjaus::util::LocationCodeReader::set(reader);

    // Create the JAUS Components and provide your Hardware Abstraction API and the HealthManager
    MyComponent component("MyComponent");

    ...
}