Fóruns

Versão Completa: UPA Script - Correção de KM S10 e Vectra
Esta é uma versão reduzida do nosso conteúdo. Ver versão completa com o formato adequado.
program Prog1;
var
Code, Code_1: string;
KM: Integer;
procedure ReadKM;
begin
if not ReadDevice then
begin
MsgBox('Read Error', 'Error', MB_OK);
end
else
begin
AddMsg('Chevrolet 93C66');
Code_1 := inttohex(GetByteHexEdit($1F1), 2) + inttohex(GetByteHexEdit($1F0), 2);
KM := ((65535 - strtoint('$' + Code_1)) * 16);
AddMsg('Kilometragem Atual' + ' = ' + IntToStr(KM) + ' km');
MsgBox(IntToStr(KM) + ' km', 'KM Atual', MB_OK);
end;
end;

procedure NewKM;
var
n, new_KM: integer;
n1: string;
begin
SetProgramModifiedOnly(true);
if InBox('Digite KM', 'Nova KM', code) then
begin
//nada
end;
if StrToInt(code) > 999999 then
begin
MsgBox('Valor entre 000001-999999', 'Erro', MB_OK);
exit;
end;

n := StrToInt(code);
new_KM := (65535 - (n / 16));
n1 := IntToHex(new_KM, 4);
SetByteHexEdit($1F0, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1F1, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1F2, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1F3, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1F4, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1F5, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1F6, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1F7, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1F8, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1F9, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1FA, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1FB, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1FC, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1FD, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1FE, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1FF, (strtoint('$' + n1[1] + n1[2])));

RefreshHexEdit;
if MsgBox('Programar?', 'Confirme', MB_YESNO) = IDYES then
begin
SetProgramModifiedOnly(true);
ProgramDevice;
VerifyDevice;
ReadKM;
end;
end;

begin
AddDeviceGroup('APLICAÇÃO ODÔMETRO', 'Select a car');
AddDevice('VECTRA PAINEL 93C66', '93C66', 'APLICAÇÃO ODÔMETRO', '93C66 x16');
AddAction('Read KM', 'ReadKM', 'VECTRA PAINEL 93C66');
AddAction('New KM', 'NewKM', 'VECTRA PAINEL 93C66');

AddDeviceGroup('APLICAÇÃO ODÔMETRO', 'Select a car');
AddDevice('S10 PAINEL 93C66', '93C66', 'APLICAÇÃO ODÔMETRO', '93C66 x16');
AddAction('Read KM', 'ReadKM', 'S10 PAINEL 93C66');
AddAction('New KM', 'NewKM', 'S10 PAINEL 93C66');
AddMsg('GM - S10 & VECTRA - Installed '#169' 2020 FÓRUM MSBIG - www.msbig.net');
SetProductInfo('Sample1', 'Device Script Example'#$D'Copyright'#169' 2020 FÓRUM MSBIG - www.msbig.net');
end.