Ver Mensaje Individual
  #3  
Antiguo 23-07-2007
Avatar de axesys
axesys axesys is offline
Miembro
 
Registrado: ene 2007
Ubicación: Los Mochis Sinaloa
Posts: 208
Reputación: 18
axesys Va por buen camino
Yo hice una aplicación con basculas y use estos componentes para leer el peso
http://sourceforge.net/projects/tpapro/

El componente se llama TComPort

Código Delphi [-]
//Asignas el puerto
    comBalanza.Port:= cbbPuerto.Text;
//Y luego lo abres
    comBalanza.Open;
//Envias el caracter
  comBalanza.WriteStr('P');
//Por último recibes el peso
procedure TfrmPrincipal.comBalanzaRxChar(Sender: TObject; Count: Integer);
function IsNumeric(const s: string): boolean;
var
 i: integer;
begin
 Result := True;
 for i:=1 to length(s) do
   if not (s[i] in ['0'..'9','.']) then
   begin
     Result := False;
     Break;  //Exit ?
   end;
end;
var
  I : Word;
  C : Char;
  Str : string;
begin
  comBalanza.ReadStr(Str, Count);
  for I := 1 to Count do begin
    C := Str[i];
    case C of
      #13:if sPeso<>'' then begin
        if IsNumeric(Trim(LeftStr(sPeso, 8))) then
          edtPeso.Text := LeftStr(sPeso, 8)
        else
          edtPeso.Text:= '  0.000 ';
        lblMedida.Caption := RightStr(Trim(sPeso), 2);
        sPeso := '';
      end;
      #0..#12,#14..#31 : {Don't display} ;
      else sPeso := sPeso + C;
    end;
  end;
end;

Última edición por axesys fecha: 23-07-2007 a las 18:47:40.
Responder Con Cita