Other Application Considerations

Written by Kevin Cloutier on Oct 19, 2022 10:34 am

Watchdog

The concept of using a watchdog is to ensure that the application continues to run as expected.  JANOS provides a Watchdog class that has a couple of options.  A sample of how to use that class can be found here.

Single Instance

Most times we only want one instance of an application running at a given time.  Use the JANOS.registerProcess() method to check to make sure there is not another instance running. Here is an example of using the registerProcess() method.

String applicationName = "TestApp";
if (1 < JANOS.registerProcess(applicationName)) {
    JANOS.syslog("Another instance of " + applicationName + " is running");
    System.exit(-1);
}

Versioning

A great way to be certain that specific code is running is to implement versioning.  If the application is going to be released or there are going to be multiple releases then versioning is nearly a must.  Many times versioning takes the form of major.minor.build.  This is not always the case. Sometimes you will see version numbers that start with the year that it was released.  For example, Ubuntu uses year.month to get 22.04.  The format you use is completely up to you.

Model and I/O Count

One issue that your application can have is handling the different models of JNIORs and the differing input and output count.  The following code can help you with that.

    /**
     * @return the number of inputs based on the model of jnior
     */
    public static int getInputCount() {
        // if a 412 or 412 DMX then return 4.  If not then check if a 414 and return 12.  If not 
        // then return 8.
        String modelString = JANOS.getRegistryString("$Model", "");
        return (modelString.startsWith("412")) ? 4 : (modelString.equals("414")) ? 12 : 8;
    }



    /**
     * @return the number of outputs based on the model of jnior
     */
    public static int getOutputCount() {
        // if a 412 or 412 DMX then return 12.  If not then check if a 414 and return 4.  If not 
        // then return 8.
        String modelString = JANOS.getRegistryString("$Model", "");
        return (modelString.startsWith("412")) ? 12 : (modelString.equals("414")) ? 4 : 8;
    }
On this page