Quote:
Originally Posted by Zaque
Not to be rude, but this is the Java sub-forum, so some who do not have experience with LabVIEW may not be able to make heads or tails of the code you posted. If I get time I may be able to translate what you posted into Java pseudocode though  .
|
Thanks for pointing that out, Zaque. I guess I got a little ahead of myself. This is still a generic counter utility based on edges of a boolean input that could come from a DIO read, but I am sure there are other ways (like the one posted by jhersh)
To accomplish an equivalent of what I posted in Java, it would require static variables. i.e.
class Counter
{
private static boolean LastUpCount;
private static boolean LastDownCount;
private static int count;
public static int counter(boolean upCounter, boolean downCounter)
{
if(upCounter && !LastUpCount)
{
count++;
}
if(downCounter && !LastDownCount)
{
count--;
}
LastDownCount = downCounter;
LastUpCount = upCounter;
return count;
}
};