Fóruns

Versão Completa: UPA Script - Correção de KM Celta
Esta é uma versão reduzida do nosso conteúdo. Ver versão completa com o formato adequado.
Atenção: Esse Script deve ser utilizado apenas para correção de KM em troca de painel.
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('Celta');                                             
    Code_1 := inttohex(GetByteHexEdit($6F),2) + inttohex(GetByteHexEdit($6E),2);
    KM:=((65535 - strtoint('$'+Code_1)) * 16);             
    AddMsg('KM 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( 'Entre com novo KM', 'Novo KM', code ) then begin
    end;
    if  StrToInt(code) > 999999 then
begin
      MsgBox( 'Digite valor entre 000001-999999', 'Erro', MB_OK );   
      exit;                   
    end;                       

    n := StrToInt( code );   
    new_KM:= (65535-(n/16));                                                                 
    n1:= IntToHex(new_KM,4);       

  SetByteHexEdit( $6E,(strtoint ('$'+n1[3]+n1[4])));
  SetByteHexEdit( $6F,(strtoint ('$'+n1[1]+n1[2])));
  SetByteHexEdit( $70,(strtoint ('$'+n1[3]+n1[4])));
  SetByteHexEdit( $71,(strtoint ('$'+n1[1]+n1[2])));
  SetByteHexEdit( $72,(strtoint ('$'+n1[3]+n1[4])));
  SetByteHexEdit( $73,(strtoint ('$'+n1[1]+n1[2])));
  SetByteHexEdit( $74,(strtoint ('$'+n1[3]+n1[4])));
  SetByteHexEdit( $75,(strtoint ('$'+n1[1]+n1[2]))); 
  SetByteHexEdit( $76,(strtoint ('$'+n1[3]+n1[4])));
  SetByteHexEdit( $77,(strtoint ('$'+n1[1]+n1[2])));
  SetByteHexEdit( $78,(strtoint ('$'+n1[3]+n1[4])));
  SetByteHexEdit( $79,(strtoint ('$'+n1[1]+n1[2])));
  SetByteHexEdit( $7A,(strtoint ('$'+n1[3]+n1[4])));
  SetByteHexEdit( $7B,(strtoint ('$'+n1[1]+n1[2])));
  SetByteHexEdit( $7C,(strtoint ('$'+n1[3]+n1[4])));   
  SetByteHexEdit( $7D,(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('CELTA PAINEL', '93S46', 'APLICAÇÃO ODÔMETRO', '93S46' );
  AddAction( 'Read KM', 'ReadKM', 'CELTA PAINEL' );                                                           
  AddAction( 'New KM', 'NewKM',  'CELTA PAINEL' );                                                     
  AddOpenFileAction( 'Ver Foto', 'CELTA PAINEL', 'i04.jpg' );
  AddMsg('GM - CELTA PAINEL KM 93S46 - Installed '#169' 2020 MSBig - www.msbig.net');         
  SetProductInfo( 'Celta', 'Device Script'#$D'Copyright'#169' 2020 MSBig - www.msbig.net' );
end.
[attachment=3127]