Yoctopuce Yocto-PowerRelay-V2 Mode D'emploi page 135

Table des Matières

Publicité

program
helloworld;
{$APPTYPE CONSOLE}
uses
SysUtils,
yocto_api,
yocto_relay;
Procedure
Usage();
var
exe : string;
begin
exe:= ExtractFileName(paramstr(0));
WriteLn(exe+' <serial_number>
WriteLn(exe+' <logical_name>
WriteLn(exe+' any
WriteLn('');
WriteLn('Example:');
WriteLn(exe+' any
halt;
End;
procedure
setRelayState(relay:TYRelay; state:boolean);
begin
if (relay.isOnline()) then
begin
if
state
then relay.set_state(Y_STATE_B)
else
end
else
Writeln('Module not connected (check identification and USB
end;
var
relay
: TYRelay;
errmsg
: string;
begin
if (paramcount<2) 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
// try to first the first relay available
relay := yFirstRelay();
if relay=nil then
begin
writeln('No module connected (check USB
halt;
end
end
else
// or use the one specified the command line
relay:= YFindRelay(paramstr(1)+'.relay1');
// make sure it connected
if not relay.isOnline() then
begin
writeln('No module connected (check USB
halt;
end;
// lets drive the relay
if
paramstr(2)='B'
yFreeAPI();
end.
www.yoctopuce.com
A|B');
A|B');
A|B');
B');
relay.set_state(Y_STATE_A);
usage();
'+errmsg);
then
then
setRelayState(relay,true)
else
setRelayState(relay,false);
17. Utilisation du Yocto-PowerRelay-V2 en Delphi
then
cable)');
cable)');
cable)');
129

Publicité

Table des Matières
loading

Table des Matières