Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Last active August 29, 2015 14:11
Show Gist options
  • Save madhephaestus/4143ada38e0450ad3775 to your computer and use it in GitHub Desktop.
Save madhephaestus/4143ada38e0450ad3775 to your computer and use it in GitHub Desktop.
public class CounterInputTestAsync implements ICounterInputListener{
//The Counter channel is a property of the class
private CounterInputChannel dip;
public CounterInputTestAsync(){
//Instantiate a new Counter channel
//The second parameter tells the Counter channel that is it an asynchronous channel
dip = new CounterInputChannel(dyio.getChannel(23),true);
//Add this instance of the Tester class to the Counter channel
dip.addCounterInputListener(this);
//Run forever printing out Counter events
System.out.println("Running...");
while (ana.addAnalogInputListener(this);){
Thread.sleep(100);
}
// remove listener on exit
dip.removeCounterInputListener(this);
}
@Override
public void onCounterValueChange(CounterInputChannel source, int value) {
//Check the source of the event
if (source == dip)
System.out.println("Counter event:"+value);
}
}
new CounterInputTestAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment