Yoctopuce Yocto-Thermocouple Mode D'emploi page 141

Table des Matières

Publicité

Vous reconnaîtrez dans cet exemple l'utilisation des fonctions expliquées ci-dessus, cette fois
utilisées avec le décorum nécessaire à en faire un petit programme d'exemple concret.
program
helloworld;
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
yocto_api,
yocto_temperature;
Procedure
Usage();
var
exe : string;
begin
exe:= ExtractFileName(paramstr(0));
WriteLn(exe+'
WriteLn(exe+'
WriteLn(exe+'
halt;
End;
var
sensor,ch1,ch2 : TYTemperature;
module : TYModule;
errmsg,serial : string;
done
: boolean;
begin
if (paramcount<1) then
// Setup the API to use local USB devices
if
yRegisterHub('usb', errmsg)<>YAPI_SUCCESS
begin
Write('RegisterHub error:
halt;
end;
if
paramstr(1)='any'
begin
sensor := yFirstTemperature();
if sensor=nil then
begin
writeln('No module connected (check USB
halt;
end
end
else
sensor:= YFindTemperature(paramstr(1)+'.temperature1');
module:=sensor.get_module();
serial:=module.get_serialNumber();
ch1:=YFindTemperature(serial+'.temperature1');
ch2:=YFindTemperature(serial+'.temperature2');
done:= false;
repeat
if (sensor.isOnline()) then
begin
Write('Channel 1: '+FloatToStr(ch1.get_currentValue())+' C
Write('Channel 2: '+FloatToStr(ch2.get_currentValue())+' C
Writeln('
Sleep(1000);
end
else
begin
Writeln('Module not connected (check identification and USB
done := true;
end;
until
done;
yFreeAPI();
end.
www.yoctopuce.com
<serial_number>');
<logical_name>');
any');
usage();
'+errmsg);
then
(press Ctrl-C to
exit)');
18. Utilisation du Yocto-Thermocouple en Delphi
then
cable)');
');
');
cable)');
135

Publicité

Table des Matières
loading

Table des Matières