}
YGenericSensor
if
(args.length
sensor
} else {
sensor
}
if
(sensor
System.out.println("No module connected (check USB
System.exit(1);
}
try {
YGenericSensor
).get_serialNumber() + ".genericSensor1");
YGenericSensor
).get_serialNumber() + ".genericSensor2");
while (s1.isOnline() && s2.isOnline()) {
double
System.out.println("Channel 1 :"
s1.get_unit());
value
System.out.println("Channel 2 : "
s2.get_unit());
System.out.println("
YAPI.Sleep(1000);
}
} catch
(YAPI_Exception
System.out.println("Module "
identification and USB
}
YAPI.FreeAPI();
}
}
11.3. Contrôle de la partie module
Chaque module peut-être contrôlé d'une manière similaire, vous trouverez ci-dessous un simple
programme d'exemple affichant les principaux paramètres d'un module et permettant d'activer la
balise de localisation.
import com.yoctopuce.YoctoAPI.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class
Demo
public static
{
try {
// setup the API to use local VirtualHub
YAPI.RegisterHub("127.0.0.1");
} catch
(YAPI_Exception
System.out.println("Cannot contact VirtualHub on 127.0.0.1 ("
ex.getLocalizedMessage() + ")");
System.out.println("Ensure that the VirtualHub application is
System.exit(1);
}
System.out.println("usage: demo [serial or logical name]
YModule
module;
if
(args.length
module
if
(module
System.out.println("No module connected (check USB
System.exit(1);
}
} else {
module
www.yoctopuce.com
sensor;
> 0) {
= YGenericSensor.FindGenericSensor(args[0]);
= YGenericSensor.FirstGenericSensor();
== null) {
s1
= YGenericSensor.FindGenericSensor(sensor.get_module(
s2
= YGenericSensor.FindGenericSensor(sensor.get_module(
value
=s1.get_currentValue();
= s2.get_currentValue();
(press Ctrl-C to
ex) {
cable)");
{
void
main(String[] args)
ex) {
== 0) {
= YModule.FirstModule();
== null) {
= YModule.FindModule(args[0]);
11. Utilisation du Yocto-MaxiMicroVolt-Rx en Java
+ s1.get_currentValue() +
+ s2.get_currentValue() +
exit)");
+ sensor.describe() +
// use serial or logical name
cable)");
" "
+
" "
+
" disconnected (check
+
running");
[ON/OFF]");
cable)");
83