int
count
while (await tilt1.isOnline()) {
if (count++ %
WriteLine("tilt1
}
Write(await tilt1.get_currentValue() + "\t");
Write(await tilt2.get_currentValue() + "\t");
Write(await compass.get_currentValue() + "\t");
Write(await accel.get_currentValue() + "\t");
WriteLine(""
await YAPI.Sleep(250);
}
WriteLine("Module not connected (check identification and USB
} catch
(YAPI_Exception
WriteLine("error: "
}
YAPI.FreeAPI();
return 0;
}
}
}
19.6. 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.
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
using com.yoctopuce.YoctoAPI;
namespace
Demo
{
public
class
Demo
{
public
string
public
string
public
bool
Beacon
public override async Task<int> Run()
{
YModule
m;
string
errmsg
if (await YAPI.RegisterHub(HubURL) != YAPI.SUCCESS) {
WriteLine("RegisterHub error: "
return -1;
}
m
=
YModule.FindModule(Target
if (await m.isOnline()) {
if (Beacon) {
await m.set_beacon(YModule.BEACON_ON);
} else {
await m.set_beacon(YModule.BEACON_OFF);
}
WriteLine("serial: "
WriteLine("logical name: "
WriteLine("luminosity: "
Write("beacon:
if (await m.get_beacon() == YModule.BEACON_ON)
WriteLine("ON");
else
WriteLine("OFF");
WriteLine("upTime: "
WriteLine("USB current: "
WriteLine("Logs:\r\n"
www.yoctopuce.com
= 0;
10
== 0) {
tilt2
+ await gyro.get_currentValue());
ex) {
+ ex.Message);
:
DemoBase
HubURL
{ get; set; }
Target
{ get; set; }
{ get; set; }
= "";
+ ".module");
+ await m.get_serialNumber());
+ await m.get_logicalName());
+ await m.get_luminosity());
");
+ (await m.get_upTime() / 1000) +
+ await m.get_usbCurrent() +
+ await m.get_lastLogs());
19. Utilisation du Yocto-3D-V2 avec Universal Windows Platform
compass
acc
gyro");
+ errmsg);
// use serial or logical name
cable)");
"
sec");
"
mA");
155