uses
  uIOCt01,
  NumToStr,
  Crt;

var
  aCt   : array[0..2] of pIOCt01;
  i,j   : Byte;
  a,b,c : Real;
  s     : String;
  vVal  : Real;
  vMin  : Real;
  vMax  : Real;
  FlNew : Boolean;
const
  cMux = 2;
  cMin = 60;
  aDiv : array[0..2]of byte=(2*cMux,2*cMux,2*cMux);
  aFl  : array[0..2]of Boolean=(true,true,true);
begin

  a:=$ffff;

  for i:=0 to 2 do
  begin
    aCt[i]:=new(pIOCt01,Init({ $300}$360,i,1843200));
    if aCt[i]=nil then RunError(203);
  end;
  j:=0;
  FlNew:=true;
  WriteLn('Test IOCT01');
  for i:=0 to 2 do
  with aCt[i]^ do
  begin
    SetDivider(aDiv[i]);
    a:=SetRange((3700/cMin)/cMux,(2720/cMin)/cMux);
    StartMeasure;
    GetRange(a,b,c);
    WriteLn('a=',a*cMin*cMux:10:5,' b=',b*cMin*cMux:10:5,' c=',c*cMin*cMux:10:5);
  end;
  repeat
    repeat
      FlNew:=false;
      for i:=0 to 2 do
      with aCt[i]^ do
      begin
        if TestMeasure then
        begin
          vVal:=GetMeasure;
          Delay(Random(6)+15{22});
          StartMeasure;
          if aFl[i] then
          begin
            if vMin>vVal then
              vMin:=vVal;
            if vMax<vVal then
              vMax:=vVal;
          end;
          Write(vVal*cMin*cMux:10:5,'   ');
          FlNew:=true;
        end
        else
          Write('          '+'   ');
      end;
      if FlNew then
      begin
        if aFl[0] then Write('a')
                  else Write('_');
        if aFl[1] then Write('b')
                  else Write('_');
        if aFl[2] then Write('c')
                  else Write('_');
        WriteLn('=',vMin*cMin*cMux:10:5,'-',vMax*cMin*cMux:10:5,' $'+WordStrHex(aCt[2]^.Ct_Val));
      end;
      GotoXY(1,WhereY);
{
      Delay(100);
}
    until KeyPressed;
    ReadLn(s);
    if Length(s)=1 then
    begin
      case UpCase(s[1]) of
        'S' : begin
              end;
        'B' : begin
                vMin:=0;
                vMax:=0;
                for i:=0 to 2 do
                with aCt[i]^ do
                  if aFl[i] then
                  begin
                    vMin:=GetMeasure;
                    vMax:=GetMeasure;
                  end;
              end;
        'H' : WriteLn('a=',a*cMin*cMux:10:5,' b=',b*cMin*cMux:10:5,' c=',c*cMin*cMux:10:5);
   '0'..'2' : begin
                i:=Ord(s[1])-Ord('0');
                aFl[i]:=not aFl[i];
              end;
      end;
    end;
  until UpCase(s[1])='E';
end.