1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
function TPilotageDistoX.OpenDistoXConnexion(const CommPort: string;
const Baudrate: integer;
const DataBits: integer;
const StopBits: integer;
const Parity : char;
const TimeOutInSecs: integer): boolean;
var
EWE: Integer;
begin
Result:= false;
try
AfficherMessageErreur(Format('%s.OpenDistoXConnexion sur %s', [ClassName, CommPort]));
// Variables pour éviter un doublon dans les mesures
FOldMesureType := 0;
FOldMesureX := 0;
FOldMesureY := 0;
FOldMesureZ := 0;
FTimeOutInMilliseconds := TimeOutInSecs * 1000;
self.Config(Baudrate, DataBits, Parity, StopBits, false, false);
AfficherMessageErreur(Format('Baudrate: %d, DataBits: %d, StopBits: %d, Parity: "%s", TimeOut: %d sec', [Baudrate, DataBits, StopBits, Parity, TimeOutInSecs]));
self.OnStatus := OnChangeSerialStatus;
self.TestDSR := True;
self.Connect(CommPort);
EWE := self.LastError;
if (0 <> EWE) then AfficherMessageErreur(self.LastErrorDesc);
Result := (0 = EWE);
AfficherMessageErreur(Format('Connexion %s - ErrCode: %d - ErrDesc: %s', [IIF(0 = EWE, 'OK', 'KO'), self.LastError, LastErrorDesc]));
except
on E: Exception do
begin
AfficherMessageErreur(Format('Connexion sur port "%s" impossible (%s)', [self.Device, E.Message]));
end;
end;
end; |
Partager