Niagara Ax: How to programmatically get a module version

Here’s the code snippet to programmatically get a module’s version.

Sys.getRegistry().getModule("moduleName")
.getVendorVersion().toString();

Or if your class has a TYPE field

Sys.getRegistry().getModule(TYPE.getModule().getModuleName())
.getVendorVersion().toString();

This returns the vendorVersion value written in the module’s build.xml as shown below.

<module
	bajaVersion="3.4"
	description="Niagara Ax Module"
	edition="j2se-5.0"
	name="NiagaraModule"
	preferredSymbol="nm"
	vendor="Tridium Inc"
	vendorVersion="1.3.1"
>

Disclaimer: Niagara Ax tips in this website are sourced from the Open Niagara Ax online community http://www.niagara-central.com/ . A forum where you can ask and resolve Niagara framework related queries.

Niagara Ax: How to increase workbench client request timeout

When a Niagara workbench is connected to a remote supervisor, chances are there when client makes a request to the server, requests will be timed out after 1 minute or 60 seconds, because the server was taking more than 60 seconds to service the request.

Although Tridium will not encourage this, but we can increase the time out for clients in certain known scenarios. The file to be changed is %NIAGARA_HOME%/lib/system.properties

#UnComment the line below and provide a new value instead of 60000
niagara.fox.requestTimeout=60000

Disclaimer: Niagara Ax tips in this website are sourced from the Open Niagara Ax online community http://www.niagara-central.com/ . A forum where you can ask and resolve Niagara framework related queries.

Niagara Ax : Copy a BComponent to a bog file.

In Niagara Ax, a bog file is nothing but a zipped xml. Whenever we need to serialize a BComponent as a file in the station files structure, we can use the below code to achieve the same.

/**
 Copy a BComponent to a bogFile
 @param comp : The source component
 @param bogFile : The bogfile to be persisted to.
*/
 public static void copyComponentToBog(BComponent comp,BIFile bogFile) throws IOException {
      BogEncoder bogencoder = new  BogEncoder(bogFile.getOutputStream());
      bogencoder.setZipped(true);
      bogencoder.encodeDocument(comp);
      bogencoder.close();
    }

Vice-verse, to decode or convert a bog file to a component you can use BodDecoder class as shown below.

    /**
     * Decode a bog file and return its BComponent object.
     * @param sourceFile : The source bog file
     * @return BComponent
     * @throws Exception
     */
    public static BComponent bogFileToComponent(BIFile sourceFile throws Exception {
      BogDecoder bogDec = null;
      try{
          BogDecoder bogDec = new BogDecoder(file);
          BComponent component = ((BComponent)(bogDec.decodeDocument()));

         }finally{
          if(null != bogDec){
           bogDec.close();
          }
         }
      return component;
    }

Disclaimer: Niagara Ax tips in this website are sourced from the Open Niagara Ax online community http://www.niagara-central.com/ . A forum where you can ask and resolve Niagara framework related queries.