User-defined IO
The digital and analog input and output blocks by default only work with
the interface cards available at the Department of Automatic Control. However,
it is possible to define your own implementations of these blocks.
The way to do this is to write a class that implements the Java interface
LocalIO:
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);
}
Four methods must be implemented. Each of them should return a object that
implements a corresponding interface. The interfaces are:
AnalogInput:
package grafchart.sfc;
public interface AnalogInput {
public double get();
}
AnalogOutput:
package grafchart.sfc;
public interface AnalogOutput {
public void set(double value);
}
DigitalInput.
package grafchart.sfc;
public interface DigitalInput {
public boolean get();
}
DigitalOutput:
package grafchart.sfc;
public interface DigitalOutput {
public void set(boolean value);
}
The files should be placed in the directory .../Grafchart/source/grafchart/sfc
and they should belong to the package grafchart.sfc. In order
to specify that JGrafchart should use a local IO
implementation the following comman line argument is used in the
start-up file from which JGrafchart is started (found in .../Grafchart/bin/)
java -classpath %CP% grafchart.sfc.Editor -localIO grafchart.sfc.MyIO
-geometry 1024x768
Here we assume that the implementation of LocalIO is called MyIO (within
the file MyIO.java)