unit prub1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus,nukonx,dsocks, ExtCtrls;

type
  Tprubf = class(TForm)
    mm: TMainMenu;
    Connect1: TMenuItem;
    Controllers1: TMenuItem;
    stim: TTimer;
    procedure Connect1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Controllers1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure stimTimer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure onconnect;
  end;

var
  prubf: Tprubf;

implementation

 uses rr1;

{$R *.DFM}

procedure Tprubf.Connect1Click(Sender: TObject);
begin
 if Hostexists(dhostnam) then
 begin
// ShowMessage(dhostnam);
   host:=TMTCS.Create('tampa',dhostnam,'root', 'rootbeer','\mtcs');
   host.tosock('?');
   sleep(1000);
   if host.checkmtcs then
   host.connect2mtcs;
   if host.dconnect then
   begin
  //  ShowMEssage('ok '+ host.mtcspc);
 //   host.disconnect;
    onconnect;
   end
   else
   host.showerrors;
 end
 else
  ShowMessage('Host '+dhostnam+' not found');
end;

procedure Tprubf.FormCreate(Sender: TObject);
begin
 dhostnam:='192.168.100.245';
end;

procedure Tprubf.FormDestroy(Sender: TObject);
begin
 if assigned(host) then
 begin
  host.disconnect;
  host.free;
 end;
end;

procedure Tprubf.Controllers1Click(Sender: TObject);
begin
 rrf.show;
end;

procedure Tprubf.onconnect;
begin
 connect1.visible:=false;
 controllers1.visible:=true;
 host.rqtxids;
 sleep(1000);
 host.getxids;
// ShowMessage('nxids='+inttostr(host.nxids));
 host.rqtxstats;
 if host.nxids>0 then  stim.enabled:=true;
end;
procedure Tprubf.FormActivate(Sender: TObject);
begin
 //ShowMessage('Activate');
end;

procedure Tprubf.stimTimer(Sender: TObject);
begin
  host.rqtxstats;
  host.getxstats;
end;

end.
