16-07-2020, 16:01:01
(Esta mensagem foi modificada pela última vez a: 16-07-2020, 16:04:25 por admin.)
program Prog1;
var
Code_1: string;
KM: Integer;
procedure ReadKM;
begin
if not ReadDevice then
begin
MsgBox('Erro de Leitura', 'Erro', MB_OK);
end;
verifyDevice;
begin
AddMsg('Lendo Chrylesr 300C');
Code_1 := inttohex(GetByteHexEdit($FB4), 2) + inttohex(GetByteHexEdit($FB5), 2);
KM := strtoint('$' + Code_1) * 27;
AddMsg('Kilometragem Atual' + ' = ' + IntToStr(KM) + ' km');
MsgBox(IntToStr(KM) + ' km', 'KM Atual', MB_OK);
end;
end;
procedure NewKM;
var
n, n3, new_KM, x, y, x1, y1, a, b: integer;
n1, n2, n4, code: string;
begin
SetProgramModifiedOnly(true);
if InBox('Digite KM', 'Nova KM', code) then
begin
if length(code) > 6 then
begin
if MsgBox('Um valor de 000001 até 999999', 'Erro', MB_RETRYCANCEL) = IDRETRY then
begin
NewKM;
end;
exit;
end;
end;
n := StrToInt(code);
new_KM := (65536 + (n / 27));
n1 := IntToHex(new_KM, 4);
n2 := IntToHex(new_KM, 4)[5];
n3 := strtoint('$' + n2);
n4 := inttohex(n3, 1);
Y := 3952;
while y < 4016 do
begin
SetByteHexEdit(y, (strtoint('$' + n1[2] + n1[3])));
y := y + 4;
end;
Y1 := 3953; a := 16
while y1 < 4016 do
begin
SetByteHexEdit(y1, (strtoint('$' + n1[4] + n4) + a));
y1 := y1 + 4; a := a + 1
end;
x := 4016;
while x < 4078 do
begin
SetByteHexEdit(x, (strtoint('$' + n1[2] + n1[3])));
x := x + 4
end;
x1 := 4017; b := 0
while x1 < 4079 do
begin
SetByteHexEdit(x1, (strtoint('$' + n1[4] + n4) + b));
x1 := x1 + 4; b := B + 1
end;
RefreshHexEdit;
if MsgBox('Programar?', 'Confirme', MB_YESNO) = IDYES then begin
ProgramDevice;
VerifyDevice;
ReadKM;
end;
end;
begin
AddDeviceGroup('DASH', 'Select a car');
AddDevice('300C', 'Motorola MCU', 'DASH', 'MC9S12DG256');
AddAction('Read KM', 'ReadKM', '300C');
AddAction('New KM', 'NewKM', '300C');
SetProductInfo('MSBig', 'Device Script Example'#$D'Copyright'#169' 2020 Fórum MSBig - www.msbig.net');
end.
Administrador