Class YasdiMaster

java.lang.Object
de.michaeldenk.yasdi4j.YasdiMaster

public class YasdiMaster extends Object
YasdiMaster is the high level interface to the YASDI master library functions.

A typical invocation looks like this: After getting the instance of this class, we have to initialize the master (this is to remind you, that you have to call shutdown() when you're done). initialize and shutdown may only be called once. Once the master is shut down it is in a state where it can't be used anymore, and it cannot be initialized again.

 YasdiMaster master = YasdiMaster.getInstance();
 master.initialize();
 

After the initialization we have to set one or more drivers online (don't forget to set them offline when you're done). For simplicity we only set the first driver online.

 YasdiDriver[] drivers = master.getDrivers();
 master.setDriverOnline(drivers[0]);
 

Now we can start the device detection. Let's say we have only one device.

 master.detectDevices(1);
 ... // do something with the devices
 

We're finished, clean up.

 master.setDriverOffline(drivers[0]);
 master.shutdown();
 
Author:
Michael Denk <code@michaeldenk.de>
  • Method Details

    • getInstance

      public static YasdiMaster getInstance()
      Returns the only instance of YasdiMaster.
    • initialize

      public void initialize() throws IOException
      Initializes the master with the INI file yasdi.ini. This is the same as calling initialize("yasdi.ini").
      Throws:
      IOException
    • initialize

      public void initialize(String configFile) throws IOException
      Initializes the master with the INI file configFile
      Parameters:
      configFile -
      Throws:
      IOException - if configFile doesn't exist or is not readable.
    • shutdown

      public void shutdown()
      Shuts down the master. This method should be called when you're done using the master. When the master is shut down, you can't use it anymore and you can't initialize it again. Thus this is the final method to call.
    • reset

      public void reset()
      Resets the master. After calling this method, the master is in the same state as after calling initialize.
    • getNrDrivers

      public int getNrDrivers()
      Returns the number of available drivers.
    • getDrivers

      public YasdiDriver[] getDrivers()
      Returns a copy of the array of available drivers.
    • setDriverOnline

      public void setDriverOnline(YasdiDriver d) throws IOException
      Sets the driver d online.
      Throws:
      IOException - if the driver can't be set online
    • setDriverOffline

      public void setDriverOffline(YasdiDriver d)
      Sets the driver d offline.
    • detectDevices

      public void detectDevices(int nrDevices) throws IOException
      Starts the device detection.
      Parameters:
      nrDevices - the minimum nr of devices to detect
      Throws:
      IOException - if fewer than nrDevices devices are detected or if no devices can be detected at all.
    • getNrDevices

      public int getNrDevices()
      Returns the number of detected devices.
    • getDevices

      public YasdiDevice[] getDevices()
      Returns a copy of the array of detected devices.
    • addDeviceListener

      public void addDeviceListener(YasdiDeviceListener l)
      Adds a device event listener to the device event listener list.
    • removeDeviceListener

      public void removeDeviceListener(YasdiDeviceListener l)
      Removes a device event listener from the device event listener list.
    • setAccessLevel

      public boolean setAccessLevel(String user, String password)
      Sets the access level of YASDI (see YASDI manual for details).
      Parameters:
      user - the user name
      password - the password
      Returns:
      true if the access level change was successful; false otherwise.
    • getState

      public YasdiMaster.State getState()
      Returns the current state of the master.