File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
test/java/src/junit/test/neuronrobotics/namespace Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,35 @@ public void shutdownDevices(){
130130 harness .setMode (testerIndex , DyIOChannelMode .DIGITAL_IN );
131131 }
132132 }
133+ }
134+
135+ @ Test public void DyIOAnalogInputTest (){
136+ if (!testDevice .isAvailable () || harness == null )
137+ fail ();
138+ int numPins = testDevice .getDyIOChannelCount ();
133139
140+ //Test device as input
141+ for (int i =0 ;i <numPins ;i ++){
142+ if (testDevice .getChannel (i ).canBeMode (DyIOChannelMode .ANALOG_IN ) ){
143+ int testerIndex = numPins -1 -i ;
144+ harness .setMode (testerIndex , DyIOChannelMode .DIGITAL_OUT );
145+ testDevice .setMode (i , DyIOChannelMode .ANALOG_IN );
146+
147+ boolean state =false ;
148+ for (int j =0 ;j <5 ;j ++){
149+ int pinState = state ?1 :0 ;
150+ harness .setValue (testerIndex , pinState );
151+ ThreadUtil .wait (200 );
152+ int gotValue = testDevice .getValue (i );
153+ System .out .println (" Pin:" +i +" Tester:" +testerIndex +" setting to: " +pinState +" got:" +gotValue );
154+ assertTrue (gotValue ==(state ?1023 :0 ));
155+ state = !state ;
156+ }
157+ harness .setMode (testerIndex , DyIOChannelMode .DIGITAL_IN );
158+ }else {
159+ System .out .println ("Pin " +i +" can not be analog in" );
160+ }
161+ }
134162 }
135163
136164 @ Test public void DyIOOutputTest (){
@@ -161,6 +189,8 @@ public void shutdownDevices(){
161189 }
162190
163191 }
192+
193+
164194
165195 @ Test
166196 public void dyioNamespaceTest () {
You can’t perform that action at this time.
0 commit comments