Hardware - Comunicao com NCRBi-Otico e scanners em geral |
Top Previous Next |
// comunicação com scanner NCR-BitOtic
function TVendaForm.PegaDadosBalanca: string; var Contador: Word; Dados : string; Peso : Double; Tempo : Word; begin if ScannerBiOtico then SerialScanner.PutString(#$31#$31#$03#$03); // isto solicita o peso... (Levei um tempo para "descobrir" esta sequencia (31,31,03,03) gisela mandou email
if not Balanca then Exit; Tecla(False); Dados := ''; Tempo := DM.ParametrosQuery.GetInteger('tempbalanc'); try with SerialBalanca do begin PutChar(#5); Delay(Tempo); if CharReady then begin for Contador := 1 to InBuffUsed do Dados := Dados + GetChar; if LimpaBalanca(Dados) = '' then begin Tecla(True); FlushInBuffer; Exit; end; Peso := Str2Float(LimpaBalanca(Dados)) / 1000; if (Peso > 0.006) and (Peso < 30) then begin CodigoProdutoPanel.Caption := ''; MensagemPanel.Caption := 'Pronto...'; Quantidade := Peso; Erro_Geral := True; if Quantidade > 15 then begin MsgErro('Quantidade superior a 15 Kg. [Entra] Confirma [Limpa] Cancela', 20); end; if Erro_Geral then begin QuantidadePanel.Caption := Format('%7.3f',[Quantidade]) + ' Kg x'; FocoCodigo; end; end else begin Quantidade := 0; QuantidadePanel.Caption := ''; end; end; end; except end; Application.ProcessMessages; Tecla(True); SerialBalanca.FlushInBuffer; Application.ProcessMessages; end; |