uses
  uIOCt01,
  Crt;

var
  aCt   : array[0..2] of pIOCt01;
  i,j   : Byte;
  a,b,c : Real;
  s     : String;
  vVal0 : Real;
  vVal1 : Real;
  vVal2 : Real;
  vMin  : Real;
  vMax  : Real;
  FlNew : Boolean;
  Fl0   : Boolean;
  Fl1   : Boolean;
  Fl2   : Boolean;

begin
  for i:=0 to 2 do
  begin
    aCt[i]:=new(pIOCt01,Init($360{ $300},i,1843200));
    if aCt[i]=nil then RunError(203);
  end;
  j:=0;
  FlNew:=true;
  repeat
    repeat
      for i:=0 to 2 do
        with aCt[i]^ do
        begin
          SetDivider(2);
          a:=SetRange(100,1);
          GetRange(a,b,c);
          if (j=0) {FlNew} then
          begin
            WriteLn('a=',a:8:3,' b=',b:8:3,' c=',c:8:6);
          end;
        end;
      for i:=0 to 2 do
        with aCt[i]^ do
        begin
          StartMeasure;
        end;

      Fl0:=true;
      Fl1:=true;
      Fl2:=true;
      repeat
        if aCt[0]^.TestMeasure and Fl0 then
        begin
          Fl0:=false;
          vVal0:=aCt[0]^.GetMeasure;
        end;
        if aCt[1]^.TestMeasure and Fl1 then
        begin
          Fl1:=false;
          vVal1:=aCt[1]^.GetMeasure;
        end;
        if aCt[2]^.TestMeasure and Fl2 then
        begin
          Fl2:=false;
          vVal2:=aCt[2]^.GetMeasure;
        end;

      until not(Fl0 or Fl1 or Fl2);
{
      repeat
      until aCt[2]^.TestMeasure;
}
      Delay(100);

      FlNew:=false;

      if vMin>vVal0 then
      begin
        FlNew:=true;
        vMin:=vVal0;
      end;
      if vMin>vVal1 then
      begin
        FlNew:=true;
        vMin:=vVal1;
      end;
      if vMin>vVal2 then
      begin
        FlNew:=true;
        vMin:=vVal2;
      end;

      if vMax<vVal0 then
      begin
        FlNew:=true;
        vMax:=vVal0;
      end;
      if vMax<vVal1 then
      begin
        FlNew:=true;
        vMax:=vVal1;
      end;
      if vMax<vVal2 then
      begin
        FlNew:=true;
        vMax:=vVal2;
      end;

      if true {FlNew} then
      begin
        Write  (' h0=',vVal0:8:3);
        Write  (' h1=',vVal1:8:3);
        Write  (' h2=',vVal2:8:3);
        WriteLn(' min-max=',vMin:8:3,'-',vMax:8:3);
      end;
      if j>=40 then
      begin
        j:=0;
{
        Delay(100);
}
      end
      else
        Inc(j);




      repeat
        i:=0;
        port[aCt[i]^.Ct_Addr+$8]:=aCt[i]^.Ct_Div;
        port[aCt[i]^.Ct_Addr+$8]:=aCt[i]^.Ct_Div;

        i:=1;
        port[aCt[i]^.Ct_Addr+$e]:=aCt[i]^.Ct_Div;
        port[aCt[i]^.Ct_Addr+$e]:=aCt[i]^.Ct_Div;
        i:=2;
        port[aCt[i]^.Ct_Addr+$c]:=aCt[i]^.Ct_Div;
        port[aCt[i]^.Ct_Addr+$c]:=aCt[i]^.Ct_Div;


        Delay(10);

      until KeyPressed;




    until KeyPressed;
    ReadLn(s);
    if Length(s)=1 then
    begin
      case upcase(s[1]) of
        's' : begin
              end;
        'b' : begin
                vMin:=aCt[0]^.GetMeasure;
                vMax:=aCt[0]^.GetMeasure;
              end;
      end;
    end;
  until upcase(s[1])='E';
end.