10. Utilisation du Yocto-Temperature-IR en C#
}
// retreive module serial
string
serial
// retreive both channels
YTemperature
YTemperature
if (!ch2.isOnline()) {
Console.WriteLine("Module not
Console.WriteLine("check identification and USB
Environment.Exit(0);
}
while (ch2.isOnline()) {
Console.Write("Ambiant: "
Console.Write("Infrared: "
Console.WriteLine("
YAPI.Sleep(1000,
}
YAPI.FreeAPI();
}
}
}
10.4. 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.Collections.Generic;
using System.Linq;
using System.Text;
namespace
ConsoleApplication1
{
class
Program
{
static
void
usage()
{
string
execname
Console.WriteLine("Usage:");
Console.WriteLine(execname
System.Threading.Thread.Sleep(2500);
Environment.Exit(0);
}
static
void
Main(string[] args)
{
YModule
m;
string
errmsg
if
(YAPI.RegisterHub("usb",
Console.WriteLine("RegisterHub error: "
Environment.Exit(0);
}
if
(args.Length
m
= YModule.FindModule(args[0]);
if (m.isOnline()) {
if
(args.Length
if (args[1].ToUpper() == "ON") {
m.set_beacon(YModule.BEACON_ON);
}
if (args[1].ToUpper() == "OFF") {
m.set_beacon(YModule.BEACON_OFF);
}
}
54
= tsensor.get_module().get_serialNumber();
ch1
=
YTemperature.FindTemperature(serial
ch2
=
YTemperature.FindTemperature(serial
connected");
+ ch1.get_currentValue().ToString() +
+ ch2.get_currentValue().ToString() +
(press Ctrl-C to
ref errmsg);
= System.AppDomain.CurrentDomain.FriendlyName;
+
" <serial or logical name>
= "";
ref errmsg) !=
< 1)
usage();
// use serial or logical name
>= 2) {
+ ".temperature1");
+ ".temperature2");
cable");
exit)");
[ON/OFF]");
YAPI.SUCCESS) {
+ errmsg);
" °C
");
" °C
");
www.yoctopuce.com