Contrôle De La Partie Module - Yoctopuce Yocto-4-20mA-Tx Mode D'emploi

Table des Matières

Publicité

{
System.out.println("Bad command line
System.out.println("Usage:");
System.out.println(" demo <serial_number>
System.out.println(" demo <logical_name>
System.out.println(" demo
System.out.println("Eg.");
System.out.println(" demo
System.out.println(" demo TX420MA1-123456
System.exit(1);
}
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
return;
}
YCurrentLoopOutput
if
(args.length
loop
= YCurrentLoopOutput.FindCurrentLoopOutput(args[0]);
} else {
loop
= YCurrentLoopOutput.FirstCurrentLoopOutput();
if
(loop
System.out.println("No module connected (check USB
return;
}
}
if
(args.length
try {
double
loop.set_current(value);
int
loopPower
if
(loopPower
System.out.println("Current loop not
return;
}
if
(loopPower
System.out.println("Insufficient voltage on current
return;
}
System.out.println("current loop set to "
} catch
(YAPI_Exception
System.out.println("Module "
identification and USB
}
YAPI.FreeAPI();
}
}
16.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 {
www.yoctopuce.com
value");
15");
void
main(String[] args)
ex) {
loop;
> 1) {
== null) {
< 1) usage();
value
=
Double.valueOf(args[args.length
= loop.get_loopPower();
== YCurrentLoopOutput.LOOPPOWER_NOPWR) {
== YCurrentLoopOutput.LOOPPOWER_LOWPWR) {
e) {
cable)");
{
void
main(String[] args)
16. Utilisation du Yocto-4-20mA-Tx en Java
arguments");
value");
value");
4");
- 1]);
powered");
+
value
+ loop.describe() +
" disconnected (check
+
running");
cable)");
loop");
+
"
mA");
109

Publicité

Table des Matières
loading

Table des Matières