Fóruns

Versão Completa: UPA Script - Correção de KM FIAT Strada
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('Erro de Leitura', 'Erro', MB_OK);
end
else
begin
AddMsg('FIAT Strada 24C16');
Code_1 := inttohex(GetByteHexEdit($01), 2) + inttohex(GetByteHexEdit($00), 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 a 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($00, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($01, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($02, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($03, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($04, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($05, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($06, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($07, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($08, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($09, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($0A, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($0B, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($0C, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($0D, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($0E, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($0F, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($10, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($11, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($12, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($13, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($14, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($15, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($16, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($17, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($18, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($19, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1A, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1B, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1C, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1D, (strtoint('$' + n1[1] + n1[2])));
SetByteHexEdit($1E, (strtoint('$' + n1[3] + n1[4])));
SetByteHexEdit($1F, (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('STRADA PAINEL 24C16', '24C16', 'APLICAÇÃO ODÔMETRO', '24C16');
AddAction('Read KM', 'ReadKM', 'STRADA PAINEL 24C16');
AddAction('New KM', 'NewKM', 'STRADA PAINEL 24C16');
AddMsg('FIAT - STRADA - 24C16 - Installed '#169' 2020 Fórum MSBig - www.msbig.net');
SetProductInfo('Script', 'Device Script'#$D'Copyright'#169' 2020 Fórum MSBig - www.msbig.net');
end.