Knowledge Base

Some Series 3 are not up to date enough to appear in beacon, which can make it very confusing to update to a new version in the Support Tool. Here is how to update a JNIOR that isn’t showing in the Support Tool.

The first thing you’ll want to do is make sure that you have the support tool downloaded from INTEG’s website. Here is the link to download the support tool. You’ll also want the newest all-in-one update project for the Series 3, which will include the newest version of the OS inside of it. The Series 3 all-in-one is located here.

Once you have both of those downloaded, you’ll want to open the support tool and go to the update tab.

Once you are at the update tab, you want’ll to click the open project button and select the series 3 all-in-one update project you downloaded earlier and open it in the update tab.

Now that the all-in-one is uploaded to the update tab, we want to publish it to the JNIOR. Click the Publish button and a dialog will appear to select JNIOR’s from Beacon to update. The issue here would be that the JNIOR you need to update won’t appear since its version doesn’t have beacon. What to do instead is to type the IP of the JNIOR in the space provided.

Once you have typed the JNIOR’s IP into the IP space provided, click OK and the JNIOR should begin to update. Afterwards, it should now appear in beacon.

To update JANOS, the JNIOR Series 4 Operating System, you will need to do two things.

  1. Get the UPD file on the JNIOR in the /temp directory.
  2. Execute the jupdate command. To force the update to happen immediately upon entering this command we will type jrupdate -fup /temp/janos_filename.upd

The easierst way to update the unit remotely is using the DCP The DCP is most likely to be available on a remote JNIOR because it uses a single port for all of the features. Without the DCP you might need port 23 for telnet, port 21 for FTP commands and many other ports for FTP data.

If the DCP is available follow the this procedure.

  1. Once the DCP is open, navigate to the Console tab.
  2. Login to the command console.
  3. Drag and drop the JANOS .upd file into the console window. This automatically stores the file in the /temp directory.
  1. Issue the jrupdate command. Like above, t o force the update to happen immediately upon entering this command we will type jrupdate -fup /temp/janos_filename.upd

This post goes over how to handle needing more then 4 inputs, when there are only 4 on the JNIOR (This application creates three new inputs). Using multiple inputs being activated at the same time, we can count them as new inputs. This application will be able to send macros using these additional inputs we create.

Below is the code for the full application. Make sure to have properly setup the project before using this code, to learn how to setup a custom java application on the JNIOR, a link is here.

import com.integpg.system.IoEvent;
import com.integpg.system.Iolog;
import com.integpg.system.JANOS;
import java.io.DataOutputStream;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;

public class TestProject {

    //Used to get List of IO events
    public static Iolog _iolog = new Iolog();
    //Used to keep track of when to refresh Iolog
    public static long refresh_timestamp = 0;
    //Tracks commands that have the correct states to send a macro
    public static int timesCalled;
    //String Array for loading symbol
    public static String[] loadSymbol = {"|", "/", "-", "\\"};
    //loadSymbol's tracker
    public static int loadTracker = 0;

    public static long timeCheck = System.currentTimeMillis();
    
    public static ArrayList<IoEvent> ioevents = new ArrayList<>();

    public static ArrayList<EventInfo> ioEventClass = new ArrayList<>();

    public static class EventInfo {

        int macronumber;
        long timestamp;
        int mask;
        int inputstates;

        EventInfo(int macroNumber, long timeStamp, int Mask, int state) {
            // initialize the input variable from main 
            // function to the global variable of the class 
            macronumber = macroNumber;
            timestamp = timeStamp;
            mask = Mask;
            inputstates = state;
        }
        
        void setMacroNumber(int macroNumberChange) {
            
            if (macroNumberChange == 1) {
                macronumber = 1;
            } else if (macroNumberChange == 2) {
                macronumber = 2;
            } else if (macroNumberChange == 4) {
                macronumber = 3;
            } else if (macroNumberChange == 8) {
                macronumber = 4;
            } else if (macroNumberChange == 3) {
                macronumber = 5;
            } else if (macroNumberChange == 6) {
                macronumber = 6;
            } else if (macroNumberChange == 12) {
                macronumber = 7;
            }
            

            
        }



    }

    public static void createConnectionAndSendMacro(String address, int port) throws InterruptedException {

        String macro = "";
        byte[] macroToBytes;

        try {
            Socket socket = new Socket(address, port);
            DataOutputStream out = new DataOutputStream(socket.getOutputStream());
            System.out.print("Connected " + new Date() + " ");

            for (int index = 0; ioEventClass.size() > index;) {
                
                System.out.println("timeCheck: " + timeCheck + " - Event timestampe " + ioEventClass.get(index).timestamp + " = " + (ioEventClass.get(index).timestamp -  timeCheck));

                if ((ioEventClass.get(index).timestamp -  timeCheck) >= 50) {
                    
                    timeCheck = System.currentTimeMillis();

                    if (ioEventClass.get(index).macronumber > 0 && ioEventClass.get(index).macronumber < 8) {
                        macro = "run Input " + ioEventClass.get(index).macronumber;
                        System.out.println(" " + macro);
                        macroToBytes = macro.getBytes();
                        out.write(macroToBytes);
                        ioEventClass.remove(index);
                        ioevents.remove(index);
                    } else {
                        System.out.println("Macro number invalid, no execution");
                        ioEventClass.remove(index);
                        ioevents.remove(index);
                    }
                } else {

                    System.out.println("Macro is too new, holding info in ioEventClass to get complete macro.");
                    break;
                    
                }
            }

            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static void getEventInfo() {

        _iolog.refresh(refresh_timestamp);
        IoEvent[] ioEvents = _iolog.getInputEvents();

        //loop to send macros if their states match correct input states
        for (int index = ioEvents.length - 1; index >= 0; index--) {

            IoEvent ioEvent = ioEvents[index];

            if (ioEvent.states >= 0 && ioEvent.states < 13) {
                int statesTurnedHigh = ioEvent.states & ioEvent.mask;

                if (0 != statesTurnedHigh) {

                    System.out.println("statesTurnedHigh; " + statesTurnedHigh);
                    if (0 < ioevents.size()) {
                        System.out.println("path 1");
                        IoEvent lastIoEvent = ioevents.get(ioevents.size() - 1);
                        long elapsedtime = ioEvent.timestamp - lastIoEvent.timestamp;
                        System.out.println("elapsedtime; " + elapsedtime);
                        if (elapsedtime >= 20) {
                            System.out.println("path 1-1");
                            ioevents.add(ioEvent);
                            addEventInfoToList(ioevents.get(ioevents.size() - 1));
                        } else {
                            System.out.println("path 1-2");
                            lastIoEvent.states |= statesTurnedHigh;
                            ioEventClass.get(0).setMacroNumber(lastIoEvent.states | statesTurnedHigh);
                        }
                    } else {
                        System.out.println("path 2");
                        ioevents.add(ioEvent);
                        addEventInfoToList(ioevents.get(ioevents.size() - 1));
                    }
                }

                refresh_timestamp = ioEvents[0].timestamp;

            }
        }

        if (!ioevents.isEmpty()) {

            System.out.println("ioevents; " + ioevents.size());
            for (int increment = 0; increment < ioevents.size(); increment++) {
                System.out.println("ioevents info " + ioevents.get(increment).states + " " + ioevents.get(increment).timestamp);
            }

        }

    }

    public static void addEventInfoToList(IoEvent iologEvent) {
        int macroNumber = 0;

        if (iologEvent.states == 1) {
            macroNumber = 1;
        } else if (iologEvent.states == 2) {
            macroNumber = 2;
        } else if (iologEvent.states == 4) {
            macroNumber = 3;
        } else if (iologEvent.states == 8) {
            macroNumber = 4;
        } else if (iologEvent.states == 3) {
            macroNumber = 5;
        } else if (iologEvent.states == 6) {
            macroNumber = 6;
        } else if (iologEvent.states == 12) {
            macroNumber = 7;
        } else {
            System.out.println("Macro number not correct");
        }

        EventInfo eventInfoPlaceholder = new EventInfo(macroNumber, iologEvent.timestamp, iologEvent.mask, iologEvent.states);
        ioEventClass.add(eventInfoPlaceholder);

    }

    public static void main(String[] args) throws InterruptedException {

        //Making sure all lists are cleared of previous information
        _iolog.refresh();
        ioevents.clear();
        ioevents.clear();
        
        //Making sure that Registry keys are set to make socket connection
        String IP = JANOS.getRegistryString("IpConfig/IPAddress", "Went to default");
        int portNumber = JANOS.getRegistryInt("AppData/Cinema/CinemaServerClient/TcpPort", 5000);
        if (portNumber == -1) {
            System.out.println("TcpPort number not set properly, closing application.");
            System.exit(0);
        }
        System.out.println(IP);
        System.out.println(portNumber + "\n");

        while (true) {

            System.out.print("\r                                                                                                            ");
            if (loadTracker > 3) {
                loadTracker = 0;
            }
            System.out.print("\r" + loadSymbol[loadTracker]);
            loadTracker++;
            System.out.print(" [" + timesCalled + "] ");
            timesCalled++;

            Thread.sleep(300);
            getEventInfo();
            if (ioevents.isEmpty() == false) {
                createConnectionAndSendMacro(IP, portNumber);
            }

        }

    }

}

After setting up the project, the first part of the project is calling the right imports and setting the global variables. The _iolog is where to get our list of IOevents to see what inputs are being selected at any time. The refresh_timestamp is so that when we call the _iolog, its only getting the list from the last time we called the _iolog and not the entire list every time its called. The timesCalled is to track how many successful macros have been sent. The loadSymbol is used to create a a loading symbol as the JNIOR waits for inputs to be triggered. Lastly, the loadTracker is to show when the end of the loadSymbol list has been reached to rest it.

import com.integpg.system.IoEvent;
import com.integpg.system.Iolog;
import com.integpg.system.JANOS;
import java.io.DataOutputStream;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;

public class TestProject {

    //Used to get List of IO events
    public static Iolog _iolog = new Iolog();
    //Used to keep track of when to refresh Iolog
    public static long refresh_timestamp = 0;
    //Tracks commands that have the correct states to send a macro
    public static int timesCalled;
    //String Array for loading symbol
    public static String[] loadSymbol = {"|", "/", "-", "\\"};
    //loadSymbol's tracker
    public static int loadTracker = 0;

    public static long timeCheck = System.currentTimeMillis();
    
    public static ArrayList<IoEvent> ioevents = new ArrayList<>();

    public static ArrayList<EventInfo> ioEventClass = new ArrayList<>();

Moving on we have multiple functions, starting with EventInfo.

The EventInfo constructor grabs all the _iolog information along with the states of the inputs being converted from 1 to 7 . The function setMacroNumber grabs the current state of the inputs on the JNIOR and converts it to the input number 1 – 7

        EventInfo(int macroNumber, long timeStamp, int Mask, int state) {
            // initialize the input variable from main 
            // function to the global variable of the class 
            macronumber = macroNumber;
            timestamp = timeStamp;
            mask = Mask;
            inputstates = state;
        }

        void setMacroNumber(int macroNumberChange) {
            
            if (macroNumberChange == 1) {
                macronumber = 1;
            } else if (macroNumberChange == 2) {
                macronumber = 2;
            } else if (macroNumberChange == 4) {
                macronumber = 3;
            } else if (macroNumberChange == 8) {
                macronumber = 4;
            } else if (macroNumberChange == 3) {
                macronumber = 5;
            } else if (macroNumberChange == 6) {
                macronumber = 6;
            } else if (macroNumberChange == 12) {
                macronumber = 7;
            }
                        
        }

The next function is createConnectionAndSendMacro. This function takes the address and port number you specify and create a tcp connection on it. This will be connected to the Cinema application to create the macros from the inputs triggered. This function goes through the list of IOevents and sends through the tcp connection any of the 1 – 7 states its looking for. Then it closes the connection.

 public static void createConnectionAndSendMacro(String address, int port) throws InterruptedException {

        String macro = "";
        byte[] macroToBytes;

        try {
            Socket socket = new Socket(address, port);
            DataOutputStream out = new DataOutputStream(socket.getOutputStream());
            System.out.print("Connected " + new Date() + " ");

            for (int index = 0; ioEventClass.size() > index;) {
                
                System.out.println("timeCheck: " + timeCheck + " - Event timestampe " + ioEventClass.get(index).timestamp + " = " + (ioEventClass.get(index).timestamp -  timeCheck));

                if ((ioEventClass.get(index).timestamp -  timeCheck) >= 50) {
                    
                    timeCheck = System.currentTimeMillis();

                    if (ioEventClass.get(index).macronumber > 0 && ioEventClass.get(index).macronumber < 8) {
                        macro = "run Input " + ioEventClass.get(index).macronumber;
                        System.out.println(" " + macro);
                        macroToBytes = macro.getBytes();
                        out.write(macroToBytes);
                        ioEventClass.remove(index);
                        ioevents.remove(index);
                    } else {
                        System.out.println("Macro number invalid, no execution");
                        ioEventClass.remove(index);
                        ioevents.remove(index);
                    }
                } else {

                    System.out.println("Macro is too new, holding info in ioEventClass to get complete macro.");
                    break;
                    
                }
            }

            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

Next is the getEventInfo function. This function creates a list of IOevents from the _iolog. Then by going through the list and seeing which values are not within 20 milliseconds of each other and depending on where they are in the list, grab those values from the IOevent and use them in other functions to determine which macro to run.

    public static void getEventInfo2() {

        _iolog.refresh(refresh_timestamp);
        IoEvent[] ioEvents = _iolog.getInputEvents();

        //loop to send macros if their states match correct input states
        for (int index = ioEvents.length - 1; index >= 0; index--) {

            IoEvent ioEvent = ioEvents[index];

            if (ioEvent.states >= 0 && ioEvent.states < 13) {
                int statesTurnedHigh = ioEvent.states & ioEvent.mask;

                if (0 != statesTurnedHigh) {

                    System.out.println("statesTurnedHigh; " + statesTurnedHigh);
                    if (0 < ioevents.size()) {
                        System.out.println("path 1");
                        IoEvent lastIoEvent = ioevents.get(ioevents.size() - 1);
                        long elapsedtime = ioEvent.timestamp - lastIoEvent.timestamp;
                        System.out.println("elapsedtime; " + elapsedtime);
                        if (elapsedtime >= 20) {
                            System.out.println("path 1-1");
                            ioevents.add(ioEvent);
                            addEventInfoToList(ioevents.get(ioevents.size() - 1));
                        } else {
                            System.out.println("path 1-2");
                            lastIoEvent.states |= statesTurnedHigh;
                            ioEventClass.get(0).setMacroNumber(lastIoEvent.states | statesTurnedHigh);
                        }
                    } else {
                        System.out.println("path 2");
                        ioevents.add(ioEvent);
                        addEventInfoToList(ioevents.get(ioevents.size() - 1));
                    }
                }

                refresh_timestamp = ioEvents[0].timestamp;

            }
        }

        if (!ioevents.isEmpty()) {

            System.out.println("ioevents; " + ioevents.size());
            for (int increment = 0; increment < ioevents.size(); increment++) {
                System.out.println("ioevents info " + ioevents.get(increment).states + " " + ioevents.get(increment).timestamp);
            }

        }

    }

The addEventInfoList converts the current input states to an input number 1 – 7 similar to setMacroNumber, but returning all the IOevent information unlike setMacroNumber does.

public static void addEventInfoToList(IoEvent iologEvent) {
        int macroNumber = 0;

        if (iologEvent.states == 1) {
            macroNumber = 1;
        } else if (iologEvent.states == 2) {
            macroNumber = 2;
        } else if (iologEvent.states == 4) {
            macroNumber = 3;
        } else if (iologEvent.states == 8) {
            macroNumber = 4;
        } else if (iologEvent.states == 3) {
            macroNumber = 5;
        } else if (iologEvent.states == 6) {
            macroNumber = 6;
        } else if (iologEvent.states == 12) {
            macroNumber = 7;
        } else {
            System.out.println("Macro number not correct");
        }

        EventInfo eventInfoPlaceholder = new EventInfo(macroNumber, iologEvent.timestamp, iologEvent.mask, iologEvent.states);
        ioEventClass.add(eventInfoPlaceholder);

    }

Lastly, the main function of the program starts by choosing which IP and tcp port number need to be connected to, by having it set in the registry. Then after the loadingSymbol is setup, the functions getEventInfo and createConnectionAndSendMacro get called.

 public static void main(String[] args) throws InterruptedException {

        //Making sure all lists are cleared of previous information
        _iolog.refresh();
        ioevents.clear();
        ioevents.clear();
        
        //Making sure that Registry keys are set to make socket connection
        String IP = JANOS.getRegistryString("IpConfig/IPAddress", "Went to default");
        int portNumber = JANOS.getRegistryInt("AppData/Cinema/CinemaServerClient/TcpPort", 5000);
        if (portNumber == -1) {
            System.out.println("TcpPort number not set properly, closing application.");
            System.exit(0);
        }
        System.out.println(IP);
        System.out.println(portNumber + "\n");

        while (true) {

            System.out.print("\r                                                                                                            ");
            if (loadTracker > 3) {
                loadTracker = 0;
            }
            System.out.print("\r" + loadSymbol[loadTracker]);
            loadTracker++;
            System.out.print(" [" + timesCalled + "] ");
            timesCalled++;

            Thread.sleep(300);
            getEventInfo2();
            if (ioevents.isEmpty() == false) {
                createConnectionAndSendMacro(IP, portNumber);
            }

        }

    }

When using protocols with a JNIOR, you can disable the login to not be prompted when using those protocols through the DCP. This is NOT RECOMMENDED because its makes the JNIOR unsecured.

To disable the login requirement for the JANOS Management Protocol or the JNIOR Protocol you will use the DCP. Once the web page is opened click on the Configuration tab. Then click on the Protocol section near the bottom of the column on the left. Now make your login selections using the checkboxes under the appropriate protocol.

Once you un-check that box, the login will no longer be needed for ANY connection to that port.

This post explains how to send and receive messages from a System Message Pump. There is a previous post showing how to create a System Message Pump. This example uses the additional applications the previous example did and should be included when the project for this application is created. That post can be accessed here. Please look over that post first as this one uses code from and references that post. 

package mqttmessagepump;

import com.integpg.system.JANOS;
import com.integpg.system.MessagePump;
import com.integpg.system.SystemMsg;
import java.util.Json;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MQTTMessagePump implements Runnable {

    private static final MQTTMessagePump THIS = new MQTTMessagePump();
    private static final MessagePump MESSAGE_PUMP = new MessagePump();
    private static final Vector LISTENERS = new Vector<>();

    private static Thread _thread;

    /**
     * Singleton constructor
     */
    private MQTTMessagePump() {
    }

    /**
     * adds a listener that will be alerted of all received messages. The
     * listener will be responsible for determining if the message has meaning
     * to them
     *
     * @param listener
     */
    public static void addListener(MessagePumpListener listener) {
        synchronized (LISTENERS) {
            LISTENERS.addElement(listener);
        }
    }

    /**
     * starts our message pump engine.
     */
    static void start() {
        if (null == _thread) {
            _thread = new Thread(THIS);
            _thread.setName("message-pump-engine");
            _thread.setDaemon(true);
            _thread.start();
        }
    }
    
    //completes the message 1600 after being sent from the MQTT application
    
    public static void completeMessage1600 (String recievedJsonInfo) {
        
        Json holdinginfo = new Json(recievedJsonInfo);
        String[] arrayofkeys = holdinginfo.keyarray();
        String subscribecheck = holdinginfo.getString(arrayofkeys[0]);
        String topicscheck = holdinginfo.getString(arrayofkeys[1]);
        String infocheck = holdinginfo.getString(arrayofkeys[2]);
        System.out.println(arrayofkeys[0] + ": " + subscribecheck + ", " + arrayofkeys[1] + ": " + topicscheck + ", " + arrayofkeys[2] + ": " + infocheck);
 
    }
    
    //creates the message that will be sent to the other program to complete
    
    public static SystemMsg createMessage (int messageType, byte [] messageInfo) {
        
        SystemMsg returnMsg = new SystemMsg();
        returnMsg.type = messageType;
        returnMsg.msg = messageInfo;
        
        System.out.println(returnMsg);
        return returnMsg;
        
    }
    
    //adds a value to the Json object that we be sent as part of the message to the other program
    
    public static Json addToJson(Json Jsonadd, String valuename, Object jsonvalue) {
    
        Jsonadd.put(valuename, jsonvalue);
        return Jsonadd;
        
    }
    
    @Override
    public void run() {
        System.out.println("open the message pump and start monitoring.\r\n");
        MESSAGE_PUMP.open();

        for (;;) {
            // read all messages from the message pump
            SystemMsg systemMsg = MESSAGE_PUMP.getMessage();

            // we must repost as fast as we can
            MESSAGE_PUMP.postMessage(systemMsg);

            // notify all of our listeners

            if (systemMsg.type == 1600) {

                System.out.println();
                System.out.println("Recieved command 1600.\n");
                String jsoninfo = new String(systemMsg.msg);
                completeMessage1600(jsoninfo);           

            }
            
             Json thirdjson = new Json();
             addToJson(thirdjson, "Message", "publish"); 
             addToJson(thirdjson, "Topic", "jnior/(Your JNIOR's Serial Number)/set/digital/outputs/1/state");
             addToJson(thirdjson, "Payload", "true");
             SystemMsg returnMsg = createMessage(1600, thirdjson.toString().getBytes());
             MESSAGE_PUMP.postMessage(returnMsg);    
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(MQTTMessagePump.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

    }

    /**
     * Exposes the postMesssage method of the System MessagePump
     *
     * @param msg the message the will be sent to the system message pump
     */
    public static void postMessage(SystemMsg msg) {
        MESSAGE_PUMP.postMessage(msg);
    }

}

To start, before we can create an application to talk with the MQTT application, we need to configure the MQTT application to hook up with a broker. To download the update project for the MQTT application, click here. An online broker is needed in order to use the MQTT protocol. Free ones can be found online, but for this example the free hivemq broker is being used, which can be found here. This broker is public and if you want to use MQTT protocols outside this example, a secure one should be used. The only information you need to have in the MQTT application is the host URL and the port number. Then click connect and make sure the MQTT application is running on the JNIOR.

Once the MQTT application is properly configured, the MQTT coding can be made. After creating a Message Pump program that could send messages to and from another application, the next step is to create and receive messages between the message pump and the MQTT application using the MQTT protocol. To start, we can create a new program that will interact with the MQTT application. We’ll call this program our MQTTMessage program. This sample program will only send a message to toggle an output, but could be edited to do more.

For this example, only the application containing the message pump from the previous example is needed. In the previous example, the message being sent between the applications we Json Objects. The message that needs to be created is formatted as this:

{
"Message" : "publish",
"Topic" : STRING,
"Payload" : STRING
}

The MQTT application also uses Json Objects to communicate through the messages. Looking at the for loop when creating the message to send, The message has to be “publish”, because when you are sending a message to the MQTT application, you are publishing information on a specified topic. The topic is the keyword that other devices are subscribed to. If a device is subscribed to that topic, then the device will receive the payload of the message. The payload is the actual data of the message that any device subscribed to the related topic will receive.

The run function in the previous example’s MessagePumpEngine application is replaced with a new for loop. When creating the message, it needs to be reformatted to match the Json message the MQTT application needs to receive. The message ID number has to be 1600, since that is the message ID the MQTT application is listening to. In this example, the Json object is created as:

{
  "Message" : "publish",
  "Topic" :jnior/"Your JNIOR's IP"/set/digital/outputs/1/state,
  "Payload" : true
}

The topic is to specify the JNIOR, what channel you want to toggle, and if its opened or closed. The payload sets that channels state to true, closing that output.

for (;;) {
            // read all messages from the message pump
            SystemMsg systemMsg = MESSAGE_PUMP.getMessage();

            // we must repost as fast as we can
            MESSAGE_PUMP.postMessage(systemMsg);

            // notify all of our listeners

            if (systemMsg.type == 1600) {

                System.out.println();
                System.out.println("Recieved command 1600.\n");
                String jsoninfo = new String(systemMsg.msg);
                completeMessage1600(jsoninfo);           

            }
            
             Json thirdjson = new Json();
             addToJson(thirdjson, "Message", "publish"); 
             addToJson(thirdjson, "Topic", "jnior/(Your JNIOR's Serial Number)/set/digital/outputs/1/state");
             addToJson(thirdjson, "Payload", "true");
             SystemMsg returnMsg = createMessage(1600, thirdjson.toString().getBytes());
             MESSAGE_PUMP.postMessage(returnMsg);    
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(MQTTMessagePump.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

The if statement checking the (systemMsg.type == 1600) is there because the JNIOR being used to publish the message is also listening the for messages on the message pump too, and those messages will have the same message ID 1600.

if (systemMsg.type == 1600) {

                System.out.println();
                System.out.println("Recieved command 1600.\n");
                String jsoninfo = new String(systemMsg.msg);
                completeMessage1600(jsoninfo);           

            }

Inside that if statement is a call to the completeMessage1600() function. That function will grab the data out of the Json object from the message and print it out for you to see.

public static void completeMessage1600 (String recievedJsonInfo) {
        
        Json holdinginfo = new Json(recievedJsonInfo);
        String[] arrayofkeys = holdinginfo.keyarray();
        String subscribecheck = holdinginfo.getString(arrayofkeys[0]);
        String topicscheck = holdinginfo.getString(arrayofkeys[1]);
        String infocheck = holdinginfo.getString(arrayofkeys[2]);
        System.out.println(arrayofkeys[0] + ": " + subscribecheck + ", " + arrayofkeys[1] + ": " + topicscheck + ", " + arrayofkeys[2] + ": " + infocheck);
 
    }

With these changes to the previous message pump application and MQTT application configuration, after running this example program you should be able to create and send messages through the MQTT application using the MQTT protocol.

At some point you may want your JNIOR to always have an output close or pulse, and when you reboot a JNIOR, they get reset. This post will show you how to have your JNIOR automatically close outputs from startup. If you’re looking for different information on the DCP, or don’t know how to access it, you can look here.

To start, make sure you are able to access the DCP (Dynamic Configuration Page) of your JNIOR. Then you’ll want to go to the Configuration tab of the DCP. Here we will be accessing the outputs section.

Here is where you can close or pulse outputs on startup. Simply add a zero to the Initial Action section for whichever channel you wish to close, and it will now always close that input on startup. To pulse the output on startup, simply add any positive value and it will pulse for that many milliseconds instead.

The help command can be used in the console to show help for whatever commands you can give in the console.

To use the help command, you type help (command name). You can also type help * to see the help description for every command available, in alphabetical order.

The PS command allows you to view all application running and a process number next to it. This is useful to view if applications are running on start up, or if you have to manual start them. You can also type ps -v to get more detailed information on the processes running.

The KILL Command allows you to terminate a program running from your list of processes. To kill a process on your JNIOR, you’ll type kill (process number) or kill(process name). This is useful to stop program from running on your JNIOR, without rebooting. The example below stops analog presets from running because its process number is 3.

The Extern Command is used to help you see and/or remove modules that you have setup to use with your JNIOR.

Typing Extern into the Console on the JNIOR Web Page will display all currently configured modules on your JNIOR, as shown below.

You can also use the extern -r command to remove whatever modules you currently have connected to your JNIOR, as shown below. The first line returned from the extern command is what you get when a module is plugged in. The second line from the extern command is what you see when its not plugged in, notice that the configuration has not been removed even though the module has been unplugged. The last line after the extern -r command removes the configuration that was still there, letting you replug the same module or a different one.

If you receive this error after establishing a serial connection, its because the operating system detected an error in the flash file system on boot. The flash was not mounted to protect the file system from any further damage.

To resolve this issue we need to reformat the flash. You can follow the steps below to reformat the flash and reload the unit. If you need to save any files out of flash we can temporarily mount it. If you don’t then you can skip to step 3.

1. jrflash -z

This will force the operating system to mount the flash temporarily so that you can recover any needed files. The macro and devices files should also be in RAM at the root of the filesystem.

2. FTP

You can use FTP to recover any files from the flash file system. Applications will be loaded using the update packages from the website. Files may or may not be available depending on where the corruption is in the filesystem structure.

3. jrflash -f

This will reformat the flash filesystem. Everything will be lost.

4. Run the 1.8 All In One

This will reload all of the files that are loaded when we ship the unit.

5. Run any additional update projects to get the applications running that you depend on.

6. FTP

Use FTP to restore any files that you saved in step 2.

The procedure above will get the unit running again. If you need any additional help or questions, just let us know!

Analog Presets is an application that lets you control and automate expansion modules such as 4-20ma Module, the 10v Module, or the 3 channel LED module. To get started, you’ll want to download the analog presets application from the all downloads page on integpg.com. After updating your JNIOR with the application, you’ll want to go to the URL containing the IP of your JNIOR with /analogpresets after it to access the application on your JNIOR. Here you can add levels containing different commands you want to create for your modules. You can name the command, what you want it to do, how long it should last, and if you want other commands to start once it starts or finishes. You can also use these as macros by defining a port number and termination string on the general tab.

To send a macro to the analog presets application, first we’ll configure the analog presets application. Here is an example using the 3 Channel LED Dimmer. We’ll start by adding a new level at the bottom middle of the first tab in analog presets, and giving it a name. (For this example we named ours MacroTest) Once that is added, we’ll want to go to setting level and add the brightness of each output we want set. For this example, since the 3 Channel LED Dimmer has 3 outputs, we’ll set each of them to 100 by typing in the field 100,100,100. We’ll also want to go the 3 Channel LED Output Channel field and type 1,2,3 to represent the channels we want to set the brightness of. If in the setting level field we set the brightness to 50,75,100, and the 3 Channel LED Output Channel was still 1,2,3, then channel 1’s brightness would 50, 2’s would be 75, and 3’s would be 100. For this example though, we’ll set them all to 100. If you have the 3 Channel LED Dimmer plugged into your JNIOR and the 3 Channel LED Output Channel field is still grayed out, then reboot your JNIOR and it then should be configurable.

We’ll then click on the General tab of the Analog Presets application. Here we can set the TCP port that the macro will send to. (In this example we have 9700) Make sure the Termination string is \r\n.

After that you’ll need the cinema application. You’ll download the Cinema.jar application and using the update tab in the support tool load it onto your JNIOR. Once its on your JNIOR, we’ll want to go to the support tool and create a device in the device tab. We need to do this so that the macro will know what information to send. At the bottom of the Device tab, click add Device. From there, we’ll want to name our device (You can name it anything), set the device type to RAW ETHERNET, set the IP Address to the JNIOR you are using, and the port number to the one you set above in the analog presets application. (Mine for this example is 9700).

Once you have set this up, you’ll want to click “publish to JNIOR” and it will prompt you to save the device configuration as a file. Once this is done, select the JNIOR you are using as the one to publish to. Once its published, you’ll then go to the Macro tab. The first thing we’ll do here is click “link devices”, and select the device file we previously created. After this we will go to the Action view and add a new action. Here you’ll name your action (It can have any name), the device we’ll set the to the one we previously created, the action should be send, and the data should be formatted as follows:

trigger “Name of level from analog presets application”\r\n.

Once this is done, we will then add a Macro in the Macro view. First we name the macro and then we can add the action to this macro, by selecting the Macro we created, the action we created, and then clicking <- button.

Once you have done this, you’ll want to click “publish to JNIOR” like we did previously for the device tab, and create a macro file. Once that is created select the JNIOR you are using as the one to publish to. Now to test this, we’ll want to go to the tools tab of the support tool and click command line.

Once the command line is open, we need to configure the command line to create the right connection, at the bottom of the command line we’ll set the values to our IP and then the TcpPort value in our JNIOR’s Registry. You’d find this by opening the JNIOR’s web page in beacon, and then after going to the registry tab look for the path: AppData/Cinema/CinemaServerClient/TcpPort

Make sure that the value is not -1 like it is above. If it is, change that registry key. (An example value to change it to is 5000). Once you find this value, set it as the port number next to the IP address at the bottom your command line. The IP address should be the one your JNIOR has.

Also, go the options drop down list and check each option.

Now all you should have to do is click the connect button at the bottom right and type:

run “Name of macro from support tool”

This will run the macro you wanted to send to the 3 Channel LED Dimmer!

To monitor the environment you will need 3 things. First, a sensor that provides the environmental condition you are looking to monitor. Second, an application that will read that sensor and log the values. Third, a way to view that data.

INTEG resells an environmental sensor from Embedded Data Systems. The sensor itself wont work directly with the JNIOR until it is wired. They have several different models that provide different environmental metrics. Temperature and humidity have been the consistent requests. INTEG also sells a rugged external sensor that tracks just temperature.

Set Up

To start, you’ll want to connect the Temp & Humidity Sensor to the JNIOR through the sensor port. After that, you’ll use the grapher application to monitor the sensor. You’ll also want the SNAP application. Here is a link to both:

You’ll want to do an update project one at a time, publishing these to the JNIOR you have the sensor connected to. After that, to get to the Grapher application, you’ll type (JNIOR’s IP)/Grapher into the URL and it will take you to the application. There you can create the graph to monitor your Temperature. 

Once on the Grapher application page, you’ll want to enter settings to create a graph. To start, you can go down to the Graphs section and add a graph.

Here at the top you can create the chart name, and then set the range of the chart and also the time range being charted. Below that you can create the lines that go into the graph that are tracked. You can add their names, what the units they are measured in are called, and the color of the line. After that you can add a file that will be monitored to create the graph.

Here you can define the directory path of the file you want monitored. The columns are the lines that you defined in the Graphs section. The Date format can be set to MM-DD-YY HH:mm:ss.SSS. The file count is specified to how many files you have added. Once this is all set you’ll now want to open the snap application by typing in the URL (JNIOR’s IP)/snap. This is to pull information for the graph you want to crate.

Like in the picture above, you’ll want to pull a block function into the block area, and name it. The one in the example is called temp_logs. Then the filename is defined as the one you named in the file section in Grapher. (The date.format part of the file name auto inputs the date when creating the file). The Text is defined as separate values that will act as the lines we created in the graph section of Grapher. So you will only have text values equal to the amount of different lines in the graph your creating.

The values need to be labeled as this in order from top to bottom from Grapher, {{env_[1].fahrenheit}}, {{env_[1].humidity}}. These text values represent one module getting humidity and Fahrenheit. How the text values work is, the double squiggly brackets and comma between each value are needed to separate each value. The env_ is what you have to preface each value with in the text. The “.fahrenheit” has to be replaced with “.celcius”, “.humidity”, or each words first letter like “.f”, “.c”, or “.h” depending on what type of value you are trying to monitor. The number surrounded by brackets represents which module is getting that value so if you only have on module you’d label every bracket with a 1.

As for commands, you can use the extern command to tell you what modules you have connected, and the extern -r command to remove a module on your device to switch to another.

After you define those text values, you’ll want to pull a loop block into the block area. You’ll change the name to the name of the function we just created, and then you can set every time it adds information to the chart. Then you’ll go back to the functions tab and add the function we created into the loop block. Once that is done you should be able to go back to the main Grapher page and see your graph updating with information. Keep in mind that if you ever want more then one graph to be able to display, when creating multiple files in the Grapher configuration page, make sure you also create the blocks for them in snap.

Sometimes an application wont run on a JNIOR Series 3 unit.  This issue may be due to “insufficient heap“.

This error message means that there was not enough contiguous space in “heap” or the SRAM memory for the application.  The application must find contiguous memory of at least the file size of the application.  Once the application finds that space it will stay in that same space until the application is updated.  The memory can become fragmented over time since the SRAM is used for application executables, application memory and the root file system.

Most likely this error condition will occur after updating to a new version of an application.  If the new application is larger than the old application it cannot occupy the same contiguous block in memory.  It must find a new contiguous block.  That space may not be available depending on the fragmentation of the memory. Even if there is a contiguous block of memory large enough when the file is updated, it still might give you an “insufficient heap” error. This might happen because until its run as an executable, the file doesn’t know it needs to be stored as contiguous space and fragment its memory anyways, which would then cause the error.

The fragmentation is caused by file blocks that have become scattered throughout memory over time.  To clear up the fragmentation we could delete a file at a time until a contiguous block has become available.  This would be a very slow approach.  You would not know which file gives you the best chance of finding a contiguous block.  Since the root of the file system contains mostly log files we can just clear the heap on a reboot.  In order to that we execute the reboot -a command.

What about my cinema devices and macros files?

The cinema files are automatically backed up to flash/cinema_backup.  This location is not affected by the reboot -a.  The cinema files will be restored next time cinema runs.

If you experience issues with your Dolby IMS2000 Cinema Server connecting to or executing commands on the JNIOR you may need to follow one of the procedures below. There are two issues that I have seen.

Dolby has resolved the issue for the IMS3000.

A Dolby may not even try to connect to a JNIOR when it should.

Make sure you have rebooted the Dolby IMS after adding the JNIOR as a device.

To determine if this is the issue:

  1. Go to the DCP for the JNIOR
  2. Click on the Console tab
  3. Click ‘Start Session’
  4. Log in when prompted
  5. enter the netstat command
  6. There should be a connection to 9200 with the Dolby Server IP Address for the Remote IP

The Dolby is connected but nothing happens on the JNIOR when the Dolby sends the command.

When Dolby tries to connect to the JNIOR it may not be able to log in to the JNIOR due to a bad password. The highlighted bytes below are corrupted.

The bytes should represent the password like this…

The previous images are screenshots for the WireShark application when analyzing a network capture. This capture is included in a JNIOR Support Tool Snapshot. I have been told by Dolby that this is likely due to the browser auto-fill.

To determine if this is the issue you should check the protocol.log on the JNIOR

To do that:

  1. Go to the DCP for the JNIOR
  2. Click on the Console tab
  3. Click ‘Start Session’
  4. Log in when prompted
  5. Enter the cat protocol.log command

If you see the failed login then do the following:

  1. Go to the JNIOR Device Configuration on the Dolby IMS
  2. Remove the JNIOR device
  3. Reboot the Dolby IMS
  4. Add the JNIOR as a device but DO NOT enter the password
  5. Reboot the Dolby IMS

You can now re-test the JNIOR connection to see if this is resolved.

If it is not resolved then make sure your browser is not using auto-fill for the site. The procedure differs per browser. Follow one of the links below for your browser.

If it is not resolved you can try to analyze the network capture or contact INTEG for additional support.

I hope this article helped you out. Please contact us to let us know!

The reboot command is used to restart the JNIOR. When a reboot is called on a JNIOR it kills all the applications its running, and then if any have a run key, those applications boot back up once its restarted. It will also disconnect and reconnect all connections on a JNIOR.The reboot command has multiple options along with it.

The first one is -A which cleans system and heap memory on reboot.

-F will not prompt a confirmation and immediately do a reboot of the JNIOR.

There is also a another command for a reboot that will not appear in the help command of reboot. If you type -eraseall with reboot, it will factory restart a JNIOR deleting any information that wasn’t already on them when they were first received.

A normal reboot usually fixes a lot of temporary problems the JNIOR is confronting. The -eraseall command should be used with lots of caution, as you lose everything you’ve done on the JNIOR since its been received. The reboot -eraseall is only for series 4 JNIORs.

The following information describes how to use the JNIOR to capture data on the Ethernet network and the JNIOR Serial ports. Capturing the data can be a great troubleshooting technique for communicating with various devices.

The Netstat command on the JNIOR Series 4 has multiple functions and some of them are very helpful when trying to troubleshoot a network connection via the Ethernet network.

The standard Netstat command will list all the TCP ports that are listening on the JNIOR and indicate any connections made.

Typing help netstat will show all the different options you can use with netstat.

The -C, -R, and -F options are great for getting, resetting, and filtering a file of the packets being sent on the TCP ports. This file can opened in wireshark so you can better view the information being sent back and forth on each port.

There is a chance you will see the following PHP error. For this to be seen you must have a Series 4 JNIOR that had JANOS version 1.6 or older and you just updated to a new JANOS version

Why did this happen?

The older JNIORs had a different web page than we have now. The main web page used to be served out of the flash/www folder. Now the DCP, the newer web page, is served out of the flash/www.zip file. If the flash/www/index.php file is still found then the web server will process it and serve it instead of the index.php in the www.zip file.

How do we fix it?

To fix this we need to remove the old flash/www/index.php file. This will allow JANOS to look in the flash/www.zip file. This should be a step in the All-In-One update project. You can do it manually with a Telnet connection like this…

This post will outline and provide the source code to our Serial Control application.

The application should really be called ASCII Control instead of Serial Control. The application got it’s name because communication was originally only available via the serial ports. Ethernet communication was added in a later release.

The code was rewritten to clean it up and make it available as a sample. We will talk about the features of the application that deal with serial communication, Ethernet communication, I/O control and I/O monitoring. Features such as versioning and logging are parts of this application that are beyond the scope of this post.

This post explains how to send and receive messages from a System Message Pump. There is a previous post showing how to create a System Message Pump that you can access here. Please look over that post first as this one uses code from and references that post. 

After creating a Message Pump program from the previous System Message Pump sample, the next step is to create and receive messages between two different programs. To start, we can create a new program that will interact with the previous System Message Pump program. We’ll call this program our PostMessage program. This sample program only has two messages it can send, but could be edited to add more. These messages will also only pulse output relays but can be edited to do a lot of other actions as well.

import com.integpg.system.JANOS;
import com.integpg.system.SystemMsg;
import com.integpg.system.MessagePump;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Json;

public class CommunicationPost2 {

    //This funciton decides from the user input it gets whether or not the program should post another message or close the program.
    //The only message you can create is message 1300
    public static int getresponse(MessagePump closesPump) throws IOException {

        String type = "";
        BufferedReader reading = new BufferedReader(new InputStreamReader(System.in));
        int testtype = 0;
        boolean running = true;
        boolean typecheck = false;

        while (running == true) {

            System.out.println("\nPlease enter a System Pump command. Type 'create' to make a command. Type 'finished' when done.\n");
            String choice = reading.readLine();
            System.out.println("|" + choice + "|");

            switch (choice) {

                case "finished":
                    System.out.println("Finishing program...\n");
                    System.out.println();
                    closesPump.close();
                    System.out.println();
                    System.exit(0);

                case "create":
                    System.out.println();
                    System.out.println("\nPlease enter the type number\n");
                    System.out.println();
                    while (typecheck == false) {
                            type = reading.readLine();
                            try{
                            testtype = Integer.parseInt(type);
                            typecheck = true;
                            }
                            catch (NumberFormatException e) {
                                System.out.println("\nIncorrect input. Try again\n");
                            }
                    }
                    return testtype;

                default:
                    System.out.println("\nBad input. Try again.\n");
            }
        }
        return testtype;
    }

    //adds a value to the Json object that we be sent as part of the message to the other program
    public static Json addToJson(Json gettingJson, String value, Object jsonvalue) {

        gettingJson.put(value, jsonvalue);
        return gettingJson;

    }

    //creates the message that will be sent to the other program to complete
    public static SystemMsg createMessage(int messagetype, byte[] messageinfo) {

        SystemMsg newMsg = new SystemMsg();
        newMsg.type = messagetype;
        newMsg.msg = messageinfo;
        System.out.println(newMsg);
        return newMsg;

    }

    //completes the message 1301 if it was sent from the other program
    public static void completeMessage1301(String recievedJsonInfo) {

        Json holdinginfo = new Json(recievedJsonInfo);
        String[] arrayofkeys = holdinginfo.keyarray();
        int togglecheck = holdinginfo.getInt(arrayofkeys[0]);
        int channelscheck = holdinginfo.getInt(arrayofkeys[1]);
        int durationcheck = holdinginfo.getInt(arrayofkeys[2]);
        System.out.println(arrayofkeys[0] + ": " + togglecheck + ", " + arrayofkeys[1] + ": " + channelscheck + ", " + arrayofkeys[2] + ": " + durationcheck);
        try {
            JANOS.setOutputPulsed(togglecheck, channelscheck, durationcheck);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public static Json getInfoToJson() throws IOException {

        Json newJson = new Json();
        String tempduration = "";
        String tempchannels = "";
        String temp_O_or_C = "";
        boolean successcheck1 = false;
        boolean successcheck2 = false;
        boolean successcheck3 = false;
        BufferedReader reading = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("\nThis is for toggling pulse outputs.\n");
        System.out.println("\nPlease enter if which channels you are pulsing: ' 1 - 255'\n");

        while (successcheck1 == false) {
            try {
                temp_O_or_C = reading.readLine();
                successcheck1 = true;
            } catch (IOException | NumberFormatException e) {
                System.out.println("\nIncorrect format, try again.\n");
            }
            if (successcheck1 == true) {
                int O_or_C = Integer.parseInt(temp_O_or_C);
                newJson = addToJson(newJson, "Pulse", O_or_C);
            }
        }

        System.out.println("\nPlease enter what channels: '1 - 255'\n");
        while (successcheck2 == false) {
            try {
                tempchannels = reading.readLine();
                successcheck2 = true;
            } catch (IOException | NumberFormatException e) {
                System.out.println("\nIncorrect format, try again.\n");

            }
            if (successcheck2 == true) {
                int channels = Integer.parseInt(tempchannels);
                newJson = addToJson(newJson, "Channels", channels);
            }
        }

        System.out.println("\nPlease enter duration in milliseconds:\n");
        while (successcheck3 == false) {
            try {
                tempduration = reading.readLine();
                successcheck3 = true;
            } catch (IOException | NumberFormatException e) {
                System.out.println("\nIncorrect format, try again.\n");
            }
            if (successcheck3 == true) {
                int duration = Integer.parseInt(tempduration);
                newJson = addToJson(newJson, "Duration", duration);
            }
        }

        return newJson;

    }

    public static void main(String[] args) throws IOException, InterruptedException {

        MessagePump MESSAGE_PUMP = new MessagePump();

        MESSAGE_PUMP.open();

        while (true) {

            boolean checkmsg = false;

            int fixedtype = getresponse(MESSAGE_PUMP);

            if (fixedtype == 1300) {

                Json firstJson = getInfoToJson();
                SystemMsg systemMsg = createMessage(fixedtype, firstJson.toString().getBytes());
                MESSAGE_PUMP.postMessage(systemMsg);
                System.out.println();
            }

            while (checkmsg == false) {

                SystemMsg msgRecieved = MESSAGE_PUMP.getMessage(1301);

                if (msgRecieved.type == 1301) {
                    System.out.println("Message 1301 recieved, pulsing output 1.");
                    String jsoninfo2 = new String(msgRecieved.msg);
                    completeMessage1301(jsoninfo2);
                    checkmsg = true;
                }

            }

        }

    }

}

This PostMessage program will create a message that, after getting inputs from the user, will be sent to the previously created System Message Pump program. The program starts by asking the user if they wish to create a message or close the program, then calling the “getresponse” function to initiate whichever the user chooses.

    public static int getresponse(MessagePump closesPump) throws IOException {

        String type = "";
        BufferedReader reading = new BufferedReader(new InputStreamReader(System.in));
        int testtype = 0;
        boolean running = true;
        boolean typecheck = false;

        while (running == true) {

            System.out.println("\nPlease enter a System Pump command. Type 'create' to make a command. Type 'finished' when done.\n");
            String choice = reading.readLine();
            System.out.println("|" + choice + "|");

            switch (choice) {

                case "finished":
                    System.out.println("Finishing program...\n");
                    System.out.println();
                    closesPump.close();
                    System.out.println();
                    System.exit(0);

                case "create":
                    System.out.println();
                    System.out.println("\nPlease enter the type number\n");
                    System.out.println();
                    while (typecheck == false) {
                            type = reading.readLine();
                            try{
                            testtype = Integer.parseInt(type);
                            typecheck = true;
                            }
                            catch (NumberFormatException e) {
                                System.out.println("\nIncorrect input. Try again\n");
                            }
                    }
                    return testtype;

                default:
                    System.out.println("\nBad input. Try again.\n");
            }
        }
        return testtype;
    }

If the user decides to create a message, it will call a function called “getInfoToJson”. This will gather information to form a Json object. The first two values are from 1 – 255 to represent the 8 outputs in bit values, and the last value is time in milliseconds. The “getInfoToJson” function will call the “addToJson” function to create the Json object “getInfoToJson” will return. 

public static Json getInfoToJson() throws IOException {

        Json newJson = new Json();
        String tempduration = "";
        String tempchannels = "";
        String temp_O_or_C = "";
        boolean successcheck1 = false;
        boolean successcheck2 = false;
        boolean successcheck3 = false;
        BufferedReader reading = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("\nThis is for toggling pulse outputs.\n");
        System.out.println("\nPlease enter if which channels you are pulsing: ' 1 - 255'\n");

        while (successcheck1 == false) {
            try {
                temp_O_or_C = reading.readLine();
                successcheck1 = true;
            } catch (IOException | NumberFormatException e) {
                System.out.println("\nIncorrect format, try again.\n");
            }
            if (successcheck1 == true) {
                int O_or_C = Integer.parseInt(temp_O_or_C);
                newJson = addToJson(newJson, "Pulse", O_or_C);
            }
        }

        System.out.println("\nPlease enter what channels: '1 - 255'\n");
        while (successcheck2 == false) {
            try {
                tempchannels = reading.readLine();
                successcheck2 = true;
            } catch (IOException | NumberFormatException e) {
                System.out.println("\nIncorrect format, try again.\n");

            }
            if (successcheck2 == true) {
                int channels = Integer.parseInt(tempchannels);
                newJson = addToJson(newJson, "Channels", channels);
            }
        }

        System.out.println("\nPlease enter duration in milliseconds:\n");
        while (successcheck3 == false) {
            try {
                tempduration = reading.readLine();
                successcheck3 = true;
            } catch (IOException | NumberFormatException e) {
                System.out.println("\nIncorrect format, try again.\n");
            }
            if (successcheck3 == true) {
                int duration = Integer.parseInt(tempduration);
                newJson = addToJson(newJson, "Duration", duration);
            }
        }

        return newJson;

    }

Then it will call the “createMessage” function to get the ID and information of the message that we are going to send.

public static SystemMsg createMessage(int messagetype, byte[] messageinfo) {

        SystemMsg newMsg = new SystemMsg();
        newMsg.type = messagetype;
        newMsg.msg = messageinfo;
        System.out.println(newMsg);
        return newMsg;

    }

After this message is sent, it will be received from an edited version of the System Message Pump program and then send a certain message. The code for the edited Engine Pump file of the System Message Pump program is below.

import com.integpg.system.JANOS;
import com.integpg.system.MessagePump;
import com.integpg.system.SystemMsg;
import java.io.IOException;
import java.util.Json;
import java.util.Vector;

public class MessagePumpEngine implements Runnable {

    private static final MessagePumpEngine THIS = new MessagePumpEngine();
    private static final MessagePump MESSAGE_PUMP = new MessagePump();
    private static final Vector LISTENERS = new Vector<>();

    private static Thread _thread;

    /**
     * Singleton constructor
     */
    private MessagePumpEngine() {
    }

    /**
     * adds a listener that will be alerted of all received messages. The
     * listener will be responsible for determining if the message has meaning
     * to them
     *
     * @param listener
     */
    public static void addListener(MessagePumpListener listener) {
        synchronized (LISTENERS) {
            LISTENERS.addElement(listener);
        }
    }

    /**
     * starts our message pump engine.
     */
    static void start() {
        if (null == _thread) {
            _thread = new Thread(THIS);
            _thread.setName("message-pump-engine");
            _thread.setDaemon(true);
            _thread.start();
        }
    }
    
    //completes the message 1300 after being sent from the other application
    
    public static void completeMessage1300 (String recievedJsonInfo) {
        
        Json holdinginfo = new Json(recievedJsonInfo);
        String[] arrayofkeys = holdinginfo.keyarray();
        int togglecheck = holdinginfo.getInt(arrayofkeys[0]);
        int channelscheck = holdinginfo.getInt(arrayofkeys[1]);
        int durationcheck = holdinginfo.getInt(arrayofkeys[2]);
        System.out.println(arrayofkeys[0] + ": " + togglecheck + ", " + arrayofkeys[1] + ": " + channelscheck + ", " + arrayofkeys[2] + ": " + durationcheck);
        try {
            JANOS.setOutputPulsed(togglecheck, channelscheck, durationcheck);
        } 
        catch (IOException ex) {
            ex.printStackTrace();
        }
    }
    
    //creates the message that will be sent to the other program to complete
    
    public static SystemMsg createMessage (int messageType, byte [] messageInfo) {
        
        SystemMsg returnMsg = new SystemMsg();
        returnMsg.type = messageType;
        returnMsg.msg = messageInfo;
        
        System.out.println(returnMsg);
        return returnMsg;
        
    }
    
    //adds a value to the Json object that we be sent as part of the message to the other program
    
    public static Json addToJson(Json Jsonadd, String valuename, Object jsonvalue) {
    
        Jsonadd.put(valuename, jsonvalue);
        return Jsonadd;
        
    }
    
    @Override
    public void run() {
        System.out.println("open the message pump and start monitoring.\r\n");
        MESSAGE_PUMP.open();

        for (;;) {
            // read all messages from the message pump
            SystemMsg systemMsg = MESSAGE_PUMP.getMessage();

            // we must repost as fast as we can
            MESSAGE_PUMP.postMessage(systemMsg);

            // notify all of our listeners

            if (systemMsg.type == 1300) {

                System.out.println();
                System.out.println("Recieved command 1300, pulsing output. Sending another command.\n");
                String jsoninfo = new String(systemMsg.msg);
                completeMessage1300(jsoninfo);
                Json thirdjson = new Json();
                addToJson(thirdjson, "setclose", 1); 
                addToJson(thirdjson, "settingchannel", 1);
                addToJson(thirdjson, "timeset", 5000);
                SystemMsg returnMsg = createMessage(1301, thirdjson.toString().getBytes());
                MESSAGE_PUMP.postMessage(returnMsg);                

            }

        }

    }

    /**
     * Exposes the postMesssage method of the System MessagePump
     *
     * @param msg the message the will be sent to the system message pump
     */
    public static void postMessage(SystemMsg msg) {
        MESSAGE_PUMP.postMessage(msg);
    }

}

When this file of code replaces the engine pump file in the System Message Pump program, there is a loop that will be listening for the message sent from our previous program with the message type of 1300. After it receives that message, it will create a string from all of the message’s info, and then call the “completeMessage1301” function to pulse the correct outputs. Once the program does that, it will then use the “createMessage” function to create another message for the PostMessage program to read. There is another loop for the listeners to read that message when its sent as well.

public void run() {
        System.out.println("open the message pump and start monitoring.\r\n");
        MESSAGE_PUMP.open();

        for (;;) {
            // read all messages from the message pump
            SystemMsg systemMsg = MESSAGE_PUMP.getMessage();

            // we must repost as fast as we can
            MESSAGE_PUMP.postMessage(systemMsg);
            

            if (systemMsg.type == 1300) {

                System.out.println();
                System.out.println("Recieved command 1300, pulsing output. Sending another command.\n");
                String jsoninfo = new String(systemMsg.msg);
                completeMessage1300(jsoninfo);
                Json thirdjson = new Json();
                addToJson(thirdjson, "setclose", 1); 
                addToJson(thirdjson, "settingchannel", 1);
                addToJson(thirdjson, "timeset", 5000);
                SystemMsg returnMsg = createMessage(1301, thirdjson.toString().getBytes());
                MESSAGE_PUMP.postMessage(returnMsg);

                    }
                }

            }

        }

    }

This will have us go back to the PostMessage program to receive the message the Engine Pump file sent back. The PostMessage program calls the completeMessage1301 function to grab the values from the message and pulse the correct outputs. After that, the program will loop back to the beginning and re-prompt the user if they want to create or finish the program, and repeat this process until the user decides to finish the program.

 while (checkmsg == false) {

                SystemMsg msgRecieved = MESSAGE_PUMP.getMessage(1301);

                if (msgRecieved.type == 1301) {
                    System.out.println("Message 1301 recieved, pulsing output 1.");
                    String jsoninfo2 = new String(msgRecieved.msg);
                    completeMessage1301(jsoninfo2);
                    checkmsg = true;
                }

            }