Custom IO
It is possible for the user to provide his own implementations of the digital
and analog IO objects. This is done by providing Java implementations of
a few simple Java interfaces and to give the class name as a command line
argument when JGrafchart is started.
Interface LocalIO
In order to provide a custom IO the use should provide a class that implements
the interface LocalIO. The interface and the implementation class should
be placed in the grafchart/source/grafchart/sfc/ directory. The interface
defines four methods:
package grafchart.sfc;
public interface LocalIO {
public AnalogInput createAnalogInput(int
channel);
public AnalogOutput createAnalogOutput(int channel);
public DigitalInput createDigitalInput(int channel);
public DigitalOutput createDigitalOutput(int channel);
}
The interface makes use of four additional interfaces: AnalogInput, AnalogOutput, DigitalInput,
and DigitalOutput.
Interface AnalogInput
This interface defines a generic analog input. It contains the following
definition:
package grafchart.sfc;
public interface AnalogInput
{
public double get();
}
Interface AnalogOutput
This interfaces defines a generic analog output, It contains the following
definition:
package grafchart.sfc;
public interface AnalogOutput {
public void set(double value);
}
Interface DigitalInput
This interfaces defines a generic digital input, It contains the following
definition:
package grafchart.sfc;
public interface DigitalInput {
public boolean get();
}
Interface DigitalOutput
This interfaces defines a generic digital output, It contains the following
definition:
package grafchart.sfc;
public interface DigitalOutput {
public void set(boolean value);
}
Example: LundPrintIO
The example implementation LundPrintIO.java
provides a simple example that writes all output to the command terminal from
which JGrafchart is started and which returns random values as inputs. The
example is found in grafchart/source/grafchart/sfc. The directory grafchart/bin
contains command files for compiling the example and for starting JGrafchart
with this IO.