14. Utilisation du Yocto-Meteo en Delphi
SysUtils,
Windows,
yocto_api,
yocto_humidity,
yocto_temperature,
yocto_pressure;
Procedure
Usage();
var
exe : string;
begin
exe:= ExtractFileName(paramstr(0));
WriteLn(exe+'
WriteLn(exe+'
WriteLn(exe+'
sleep(2500);
halt;
End;
var
hsensor
: TYHumidity;
tsensor
: TYTemperature;
psensor
: TYPressure;
m
: 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:
exit;
end;
if
paramstr(1)='any'
begin
// lets try to find the first available humidity sensor
hsensor := yFirstHumidity();
if hsensor=nil then
begin
writeln('No module connected (check USB
halt;
end
end
else
// or the one specified on command line
hsensor:= YFindHumidity(paramstr(1)+'.humidity');
// make sure it is online
if
not hsensor.isOnline() then
begin
writeln('No module connected (check USB
halt;
end;
// lets find the parent module so we can get the other sensors
m :=
hsensor.get_module();
serial :=
m.get_serialNumber();
// retreive all sensor present on the yocto-meteo
hsensor := yFindHumidity(serial+'.humidity');
tsensor := yFindTemperature(serial+'.temperature');
psensor := yFindPressure(serial+'.pressure');
// let's poll
done := false;
repeat
if (hsensor.isOnline()) then
begin
Writeln('Curr humidity:
Writeln('Curr temperature: '+FloatToStr(tsensor.get_currentValue())+' deg
Writeln('Curr pressure:
Writeln('
Writeln('');
98
<serial_number>');
<logical_name>');
any');
usage();
'+errmsg);
then
'+FloatToStr(hsensor.get_currentValue())+'
'+FloatToStr(psensor.get_currentValue())+'
(press Ctrl-C to
exit)');
then
cable)');
cable)');
%RH');
C');
hPa');
www.yoctopuce.com