unit uMeasureHeight;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uMeasureBase, dxExEdtr, SPComm, ADODB, DB, ExtCtrls, dxBar,
  dxBarExtItems, ImgList, StdCtrls, MPlayer, dxTL, dxCntner,uFunMesClient,
  Common,PublicDBUnit;

type
  TfrmMeasureHeight = class(TfrmMeasureBase)
    procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
      BufferLength: Word);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    ZF: String;
    { Public declarations }
  end;

var
  frmMeasureHeight: TfrmMeasureHeight;

implementation

{$R *.dfm}

procedure TfrmMeasureHeight.Comm1ReceiveData(Sender: TObject;
  Buffer: Pointer; BufferLength: Word);
var
  C_num : real;
  str,firchar :string;
begin
  ImageOff.Visible  := false ;
  ImageOn.Visible   := true ;
  if edtCode.Text = '' then Exit;
  x := x + 1 ;
  x := X mod 3;
  if x = 0 then
  begin
    SetLength(Str,BufferLength);
    move(buffer^,pchar(@Str[1])^,bufferlength);
    str := StrToHexStr(Str);
    str := GetHeight(str) ;
    firchar := Copy(str,1,1);
    if firchar <> ZF then
    begin
      Exit ;
    end;
    Delete(Str,1,1) ;
    C_num := StrToFloat(Str );
    if meNum <> C_num then
    begin
      ImgYel.Visible := not ImgYel.Visible ;
      meNum := C_num ;
      Exit;
    end;
    if (meNum > MyWork.MaxNum)or (meNum < MyWork.MinNum) then
    begin
      ImgRed.Visible := true   ;
      ImgGreen.Visible := false ;
    end
    else
    begin
      ImgRed.Visible := false   ;
      ImgGreen.Visible := true ;
    end;
    edtNum.Text := FloatToStr(meNum)+ 'mm' ;
  end;

end;

procedure TfrmMeasureHeight.FormCreate(Sender: TObject);
begin
  inherited;
  ZF := '+' ;
end;

end.
