cork.util
Class CorkRuntime

java.lang.Object
  |
  +--cork.util.CorkRuntime

public final class CorkRuntime
extends java.lang.Object

Runtime methods for use by the entire Cork library. There will only be one instance of CorkRuntime per VM.

Version:
0.2.1
Author:
Brill Pappin

Field Summary
static java.lang.String RUNTIME_PROPERTY_DEBUG
          The system property that puts teh cork library in debug mode.
static int SYSTEM_UNHANDLED_EXCEPTION_PATTERN
          The blink pattern to use when the signalUnhandledException() method is called.
 
Method Summary
static boolean capturePin(Device device, com.ajile.drivers.gpio.GpioPin pin)
          Captures a GPIO pin for use by a particular class.
static boolean getDebugMode()
          Checks to see if the system is in debug mode.
static java.util.Vector getOwnedPins(Device device)
          Gets all the pins owned by a particular device.
static Device getPinOwner(com.ajile.drivers.gpio.GpioPin pin)
          Finds the owner of a captured pin.
static boolean isCaptured(com.ajile.drivers.gpio.GpioPin pin)
          Tests if a GPIO pin has been catured.
static boolean releaseAllPins(Device device)
          Releases all pins captured by the specified device.
static boolean releasePin(Device device, com.ajile.drivers.gpio.GpioPin pin)
          Releases a pin captured with the capturePin() method.
static void signalException(int pattern)
          Use this method to signal an exception by blinking the power LED on the JStamp module.
static void signalUnhandledException(java.lang.Throwable t)
          This method can be entered into the "Uncaught Exception" field of the JemBuilder project (JVM0|Main property sheet).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSTEM_UNHANDLED_EXCEPTION_PATTERN

public static final int SYSTEM_UNHANDLED_EXCEPTION_PATTERN
The blink pattern to use when the signalUnhandledException() method is called. Blink pattern is 1000 blinks with 1.5 second pause between them.
Since:
0.1.0

RUNTIME_PROPERTY_DEBUG

public static final java.lang.String RUNTIME_PROPERTY_DEBUG
The system property that puts teh cork library in debug mode. All classes that can output to System.out will do so when this flag is true.
Since:
0.1.0
Method Detail

signalException

public static final void signalException(int pattern)
Use this method to signal an exception by blinking the power LED on the JStamp module. The method should be used to indicate a situation where the processor can not continue without a reset.

The pattern of blinks will be the number of blinks specified followed by a 1.5 second pause. this will repeat until another exception is signaled, or the processor is reset. Multiple exceptions can be signaled by calling this method with a different pattern number. e.g. the default for a system unhandled exception is 1000 blinks followed by a 1.5 second pause. Currently this only works for the aj80 chip. It will work for the aj100 when someone checks to see if the parameters need to change, or writes a new version of the method.

WARNING: The PIO A pins of the JStamp will "blink" with the power LED.

Parameters:
pattern - int the number of blinks to signal for this exception.
Since:
0.1.0

signalUnhandledException

public static final void signalUnhandledException(java.lang.Throwable t)
This method can be entered into the "Uncaught Exception" field of the JemBuilder project (JVM0|Main property sheet). The pattern is 1000 blinks followed by 1.5 seconds of pause.
Parameters:
t - Throwable the throwable exception. The exception will be ignored, it is specified to conform to the limitations set by JemBuilder on teh name of the method.
Since:
0.1.1

capturePin

public static final boolean capturePin(Device device,
                                       com.ajile.drivers.gpio.GpioPin pin)
Captures a GPIO pin for use by a particular class. Only classes that will be driving those pins need to capture the pin before using it. Classes that only want to monitor the pin are not required to capture it first.
Parameters:
device - The Device wishing to capture the specified GPIO pin.
pin - GPIO pin to capture.
Returns:
boolean true is the cature was successful, false otherwise.
Since:
0.2.1

releasePin

public static final boolean releasePin(Device device,
                                       com.ajile.drivers.gpio.GpioPin pin)
Releases a pin captured with the capturePin() method. Only the device that captured the pin can release it.
Parameters:
device - The Device wishing to release the specified GPIO pin.
pin - GPIO pin to release.
Returns:
boolean true is the release was successful, false otherwise.
Since:
0.2.1

releaseAllPins

public static final boolean releaseAllPins(Device device)
Releases all pins captured by the specified device.
Parameters:
device - The Device wishing to release all of it's captured GPIO pin.
Returns:
boolean true is the release was successful, false otherwise.
Since:
0.2.1

getDebugMode

public static final boolean getDebugMode()
Checks to see if the system is in debug mode. Usualy debug mode will print messages to the console.
Returns:
boolean true is the system is in debug mode, false otherwise.
Since:
0.1.0

isCaptured

public static final boolean isCaptured(com.ajile.drivers.gpio.GpioPin pin)
Tests if a GPIO pin has been catured.
Parameters:
pin - The pin to test.
Returns:
boolean true if the pin has been captured, false otherwise.
Since:
0.2.1

getPinOwner

public static final Device getPinOwner(com.ajile.drivers.gpio.GpioPin pin)
Finds the owner of a captured pin.
Parameters:
pin - The pin in question.
Returns:
Device the device that owns the captured pin, or null if the pin has not been captured.
Since:
0.2.1

getOwnedPins

public static final java.util.Vector getOwnedPins(Device device)
Gets all the pins owned by a particular device.
Parameters:
device - the device who's pins we want to get.
Returns:
java.util.Vector a list of the pins owned by the specified device.
Since:
0.2.1