Télécharger Imprimer la page

Yoctopuce Yocto-MaxiMicroVolt-Rx Mode D'emploi page 147

Publicité

Un exemple réel
Lancez votre environnement Delphi, copiez la DLL yapi.dll dans un répertoire et créez une nouvelle
application console dans ce même répertoire, et copiez-coller le code ci dessous.
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_genericsensor;
Procedure
Usage();
var
exe : string;
begin
exe:= ExtractFileName(paramstr(0));
WriteLn(exe+'
WriteLn(exe+'
WriteLn(exe+'
sleep(3000);
halt;
End;
var
sensor,ch1,ch2 : TYGenericSensor;
module : TYModule;
errmsg,serial : string;
unitSensor1,unitSensor2:string;
begin
if (paramcount<1) then
usage();
// 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 := yFirstGenericSensor();
if sensor=nil then
begin
writeln('No module connected (check USB
halt;
end
end
else
sensor:= YFindGenericSensor(paramstr(1)+'.genericSensor1');
module:=sensor.get_module();
serial:=module.get_serialNumber();
ch1:=YFindGenericSensor(serial+'.genericSensor1');
ch2:=YFindGenericSensor(serial+'.genericSensor2');
if ch1.isOnline() then
if ch2.isOnline() then
while
ch1.isOnline() and
begin
Write('Channel 1:
Write('
Channel 2:
Writeln('
Sleep(1000);
end;
yFreeAPI();
Writeln('Module not connected (check identification and USB
end.
www.yoctopuce.com
<serial_number>');
<logical_name>');
any');
'+errmsg);
then
unitSensor1:= ch1.get_unit();
unitSensor2:= ch2.get_unit();
ch2.isOnline() do
'+FloatToStr(ch1.get_currentValue())+unitSensor1);
'+FloatToStr(ch2.get_currentValue())+unitSensor2);
(press Ctrl-C to
exit)');
17. Utilisation du Yocto-MaxiMicroVolt-Rx en Delphi
then
cable)');
cable)');
141

Publicité

loading

Ce manuel est également adapté pour:

Yocto-bridgeYwbridg1