Runtime

javadoc

The Runtime is the first Service to start when MyRobotLab begins.  Every running instance of MyRobotLab includes a single Runtime Service.  The Runtime is a singleton, which means there should be only one per running process of MyRobotLab.  Its responsibilities include the creation, removal, and merging of Services into the Service registry.

The registry is critical for routing communication between Services.

In addition to managing the endpoints of Service communication the Runtime can retrieve information regarding details of the Java VM, operating system, and other details.

 

Examples:


#file : service/Runtime.py edit raw
# fun with Runtime :)

# prints the days hours minutes your MRL has been alive
print Runtime.getUptime()

# print the id of your instance of mrl
print "my mrl version is {}".format(Runtime.getVersion)
print "myrobotlab id is {}".format(Runtime.getId())
print "computer {}".format(Runtime.getHostname())
print "process id {}".format(Runtime.getPid())

# learn about your system
print "{} processors".format(Runtime.availableProcessors())
print "{} Gb free memory".format(Runtime.getFreeMemory()/10000000)
print "{} Gb free memory".format(Runtime.getTotalMemory()/10000000)

# get list of currently running services
services = Runtime.getServices()
print "list my {} currently running services".format(len(services))
for service in services:
  print service.getName()

# create and start an Arduino service
Runtime.start("arduino", "Arduino")

Runtime.noWorky("GroG")
# the Big Hammer - the last thing
# MRL will see - shuts everything down in 10 seconds
# Runtime.shutdown(10)