how to obtain station uptime(start time) information in Niagara-4?

564 views Asked by At
  1. I am trying to get the start time of niagara station.
  2. I see there is a Sys Class that provides singleton to access all the functionality.
  3. i want to get the start time of the station and i am unable to find a property that would result in that.
  4. I can see in resourcemanager and when spied on station to see there is start time information there but i am not able to retrieve it. i access those information by going to following ords:
    local:|foxs:|spy:/sysInfo
    local:|foxs:|view:chart:ResourceManager

code i have been playing with:

Sys.getStation().getSysInfo().getFacets()

the sysinfo facets looks empty.

1

There are 1 answers

0
phil76 On BEST ANSWER

You can access the static field Nre.bootTime, which is set to System.currentTimeMillis() when the station starts, and then subtract it from "now" in order to obtain the uptime - something like this:

import com.tridium.sys.Nre;
import javax.baja.sys.BRelTime;

long uptimeMilliseconds = BAbsTime.now().getMillis() - Nre.bootTime;
  
BRelTime uptime = BRelTime.make(uptimeMilliseconds);
  
System.out.println("Uptime:");
System.out.println(uptimeMilliseconds + " ms");
System.out.println(uptime);