Package de.michaeldenk.yasdi4j
Class YasdiMaster
java.lang.Object
de.michaeldenk.yasdi4j.YasdiMaster
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>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe different states of the master. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a device event listener to the device event listener list.voiddetectDevices(int nrDevices) Starts the device detection.Returns a copy of the array of detected devices.Returns a copy of the array of available drivers.static YasdiMasterReturns the only instance ofYasdiMaster.intReturns the number of detected devices.intReturns the number of available drivers.getState()Returns the current state of the master.voidInitializes the master with the INI file yasdi.ini.voidinitialize(String configFile) Initializes the master with the INI file configFilevoidRemoves a device event listener from the device event listener list.voidreset()Resets the master.booleansetAccessLevel(String user, String password) Sets the access level of YASDI (see YASDI manual for details).voidSets the driver d offline.voidSets the driver d online.voidshutdown()Shuts down the master.
-
Method Details
-
getInstance
Returns the only instance ofYasdiMaster. -
initialize
Initializes the master with the INI file yasdi.ini. This is the same as callinginitialize("yasdi.ini").- Throws:
IOException
-
initialize
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
Returns a copy of the array of available drivers. -
setDriverOnline
Sets the driver d online.- Throws:
IOException- if the driver can't be set online
-
setDriverOffline
Sets the driver d offline. -
detectDevices
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
Returns a copy of the array of detected devices. -
addDeviceListener
Adds a device event listener to the device event listener list. -
removeDeviceListener
Removes a device event listener from the device event listener list. -
setAccessLevel
Sets the access level of YASDI (see YASDI manual for details).- Parameters:
user- the user namepassword- the password- Returns:
- true if the access level change was successful; false otherwise.
-
getState
Returns the current state of the master.
-