⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.~pas

📁 snmp设计增加相应SNMP的OID,是实时处理的.
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, SNMPsend, ExtCtrls, Mask;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Timer1: TTimer;
    InputVol: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    tem: TEdit;
    Fre: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    OutVol: TEdit;
    Label7: TLabel;
    Loa: TEdit;
    Label8: TLabel;
    ba: TEdit;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    edtip: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var rep:string;
begin
if edtip.text<>''then
begin
  if Button1.Caption = 'Start'  then
  begin
     if  SNMPget('1.3.6.1.4.1.935.1.1.1.3.2.1.0', 'public', edtIP.Text, rep) then
     begin
    Timer1.Enabled := true;
    Button1.Caption := 'Stop';
    edtip.Enabled:=false;
    end
    else
    begin
    showmessage('请检查设置是否正确!');
    end;
  end
  else
  begin
    Button1.Caption := 'Start';
    Timer1.Enabled := false;
    edtip.Enabled:=true;
  end;
  end
  else
  begin
  showmessage('请检查设置是否正常!');
    end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  Inputval: string;
  outputval:string;
  InputFre:string;
  Temp:string;
  Batvol:string;
  Load:string;
  Bypass:string;
  INV:string;
  Bat:string;
  test:string;
  shut:string;
  fail:string;
  connect:string;
  begin
   SNMPget('1.3.6.1.4.1.935.1.1.1.3.2.1.0', 'public', edtIP.Text, inputval);
   snmpget('1.3.6.1.4.1.935.1.1.1.4.2.1.0','public',edtip.Text,outputval);
  snmpget('1.3.6.1.4.1.935.1.1.1.3.2.4.0','public',edtip.text,Inputfre);
  snmpget('1.3.6.1.4.1.935.1.1.1.2.2.2.0','public',edtip.text,Batvol);
  snmpget('1.3.6.1.4.1.935.1.1.1.4.2.3.0','public',edtip.text,Load);
  snmpget('1.3.6.1.4.1.935.1.1.1.2.2.3.0','public',edtip.text,temp);
  SNMPget('1.3.6.1.4.1.2350.1.1.2.6.0', 'public', edtIP.Text, Bypass);
  SNMPget('1.3.6.1.4.1.2350.1.1.2.8.0', 'public', edtIP.Text, INV);
  SNMPget('1.3.6.1.4.1.2350.1.1.2.7.0', 'public', edtIP.Text, Bat);
  SNMPget('1.3.6.1.4.1.2350.1.1.2.3.0', 'public', edtIP.Text, test);
  SNMPget('1.3.6.1.4.1.2350.1.1.2.2.0', 'public', edtIP.Text, shut);
  SNMPget('1.3.6.1.4.1.2350.1.1.2.5.0', 'public', edtIP.Text, fail);
  SNMPget('1.3.6.1.4.1.2350.1.1.2.32.0', 'public', edtIP.Text, connect);
  Inputvol.text := floattostr(strtoint(Inputval)/10);
  Outvol.text:= floattostr(strtoint(outputval)/10);
  Fre.text:=floattostr(strtoint(inputfre)/10);
  ba.Text:=floattostr(strtoint(batvol)/10);
  Loa.text:=load;
  tem.text:=floattostr(strtoint(temp)/10);
  if bypass='1' then
  begin
  label9.Caption:='UPS旁路';
  label9.Font.Color:=clred;
  end
  else
  begin
  label9.caption:='UPS正常';
  label9.Font.Color:=clLime;
  end;
   if INV='1' then
  begin
  label11.Caption:='UPS市电故障';
  label11.Font.Color:=clred;
  end
  else
  begin
  label11.caption:='UPS正常';
  label11.Font.Color:=clLime;
  end;
   if bat='1' then
  begin
  label13.Caption:='UPS电池电压低';
  label13.Font.Color:=clred;
  end
  else
  begin
  label13.caption:='UPS正常';
  label13.Font.Color:=clLime;
  end;
   if test='1' then
  begin
  label10.Caption:='UPS测试中';
  label10.Font.Color:=clred;
  end
  else
  begin
  label10.caption:='UPS正常';
  label10.Font.Color:=clLime;
  end;
   if shut='1' then
  begin
  label12.Caption:='UPS关机';
  label12.Font.Color:=clred;
  end
  else
  begin
  label12.caption:='UPS正常';
  label12.Font.Color:=clLime;
  end;
   if fail='1' then
  begin
  label14.Caption:='UPS故障';
  label14.Font.Color:=clred;
  end
  else
  begin
  label14.caption:='UPS正常';
  label14.Font.Color:=clLime;
  end;
if Connect='1' then
  begin
  label2.Caption:='UPS连接中断';
  label2.Font.Color:=clred;
  end
  else
  begin
  label2.caption:='UPS连接正常';
  label2.Font.Color:=clLime;
  end;
  end;
end.


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -