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

📄 power.pas

📁 Monitor.dfm Meter.dpr pasMain.pas
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit power;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ComCtrls, ImgList, ExtCtrls;

type
  Tfrmpower = class(TForm)
    Label1: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    Statuslab: TStatusBar;
    GroupBox1: TGroupBox;
    Image1: TImage;
    BitBtn4: TBitBtn;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    Uno_E: TEdit;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    Button1: TButton;
    Label5: TLabel;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmpower: Tfrmpower;

implementation

{$R *.DFM}
uses Global, Promot;
procedure Tfrmpower.BitBtn1Click(Sender: TObject);
var
    sBuf, rStr: string;
    i:integer;
    delaystatu,delayuno1,delayuno2,delayuno3,phase,delaydeep:string;
    delay2uno:string;
begin
    StatusLab.simpletext := '';
    if UNO_E.Text = '' then
    BEGIN
        statusLab.simpletext  := '表号为空,请输入。';
        exit;
    end;
    sbuf := ConvertID(UNO_E.Text);
    activecommand:=true;
    BreakRead:=false;
    frmPromot.Hide;
    frmPromot.Promot.Caption := '是否对 [' + UNO_E.Text + '] 用户通电操作?';
    if frmPromot.ShowModal <> mrOK then exit;
    StatusLab.simpletext  := '';

    for I := 1  to 3 do
    begin
        if PutTXD('R' +Uno_E.text+ Chr(13), 159, rStr, 1500)  and UnLockFlag=true then break;
        if not UnLockFlag then
        begin
                frmPromot.Hide;
                frmPromot.Promot.Caption := '请先通过集中器口令检测。';
                frmPromot.ShowModal;
                BreakRead := true;

                exit;
        end;
    end;
    if i>3 then
    begin
                frmPromot.Hide;
                frmPromot.Promot.Caption := '请检查集中器中是否有此表号。';
                frmPromot.ShowModal;
                BreakRead := true;

                exit;
    end;
     delaystatu:=copy(rstr,14,1);
    phase:=copy(rstr,95,1);
    delaydeep:=copy(rstr,97,1);
    delayuno1:=copy(rstr,99,12);
    delayuno2:=copy(rstr,112,12);
    delayuno3:=copy(rstr,125,12);
    //Read SCALE and CONSTANT

    if BreakRead then
        begin

            activecommand:=false;
            exit;
        end;
    if delaystatu='0' then
        begin
                sBuf := 'H' + Phase + _CR;
                if PutTXD(sBuf, 4, rStr,2500) and (Copy(rStr, 1, 4) = _OK) then
                begin
                        for I := 1  to 3 do
                        begin

                                if PutTXD('S'+uno_e.text+'5650'+CHR(13), 22, rStr, 2500) and (Copy(rStr, 1, 4) = _OK) AND (Copy(rStr, 5, 10)='0000000000') AND (Copy(rStr, 21, 2) = _CRLF) then break;
                        end;


                        if I> 3 then
                        begin
                                StatusLab.simpletext  := '通电操作不成功,请检查线路。' ;
                                label5.Caption:='通电操作不成功';
                                image1.Picture:=image4.Picture;
                                activecommand:=false;
                                exit;
                        end;
                        for I := 1  to 3 do
                        begin

                                if PutTXD('S'+uno_e.text+'5660'+CHR(13), 22, rStr, 2500) and (Copy(rStr, 1, 4) = _OK) AND (Copy(rStr, 5, 10)='0000000000') AND (Copy(rStr, 21, 2) = _CRLF) then break;
                        end;
                        if I> 3 then
                        begin
                                StatusLab.simpletext  := '通电操作不成功,请检查线路。';
                                activecommand:=false;
                                label5.Caption:='通电操作不成功';
                                frmpower.BitBtn3Click(Sender);
                                image1.Picture:=image4.Picture;

                                exit;
                        end
                        else
                        begin
                                StatusLab.simpletext  := '通电操作成功。';
                                label5.Caption:='已经通电';
                                image1.Picture:=image2.Picture;
                                activecommand:=false;

                        end;
                end;
        end;
        if delaystatu='1' then
        begin
                for I := 1  to 3 do
                begin
                        if PutTXD('R' +delayuno1+ Chr(13), 159, rStr, 1500)  and UnLockFlag=true then break;
                        if not UnLockFlag then
                        begin
                                frmPromot.Hide;
                                frmPromot.Promot.Caption := '请先通过集中器口令检测。';
                                frmPromot.ShowModal;
                                BreakRead := true;

                                exit;
                        end;
                end;
                if i>3 then
                begin
                        frmPromot.Hide;
                        frmPromot.Promot.Caption := '请检查集中器中是否有此表号。';
                        frmPromot.ShowModal;
                        BreakRead := true;

                        exit;
                end;
                delaydeep:=copy(rstr,14,1);
                phase:= copy(rstr,95,1);
                if delaydeep='0' then
                begin
                     sBuf := 'H' + Phase + _CR;
                     if PutTXD(sBuf, 4, rStr,2500) and (Copy(rStr, 1, 4) = _OK) then
                     begin
                        for i:=1 to 3 do
                        begin
                                sBuf := 'S' +Delayuno1+'8001'  + _CR;
                                StatusLab.simpletext  := '正在设置中继表号......';
                                if PutTXD(sBuf, 18, rStr,4000) and (Copy(rStr, 1, 12) = 'SetupSuccess') then continue;
                        end;
                        for I := 1  to 3 do
                        begin

                                if PutTXD('S'+uno_e.text+'6651'+CHR(13), 22, rStr, 4000) and (Copy(rStr, 1, 4) = _OK) AND (Copy(rStr, 5, 10)='0000000000') AND (Copy(rStr, 21, 2) = _CRLF) then break;
                        end;


                        if I> 3 then
                        begin
                                StatusLab.simpletext  := '通电操作不成功,请检查线路。' ;
                                label5.Caption:='通电操作不成功';
                                image1.Picture:=image4.Picture;
                                activecommand:=false;
                                exit;
                        end;
                        for I := 1  to 3 do
                        begin

                                if PutTXD('S'+uno_e.text+'6661'+CHR(13), 22, rStr, 4000) and (Copy(rStr, 1, 4) = _OK) AND (Copy(rStr, 5, 10)='0000000000') AND (Copy(rStr, 21, 2) = _CRLF) then break;
                        end;
                        if I> 3 then
                        begin
                                StatusLab.simpletext  := '通电操作不成功,请检查线路。';
                                activecommand:=false;
                                label5.Caption:='通电操作不成功';
                                image1.Picture:=image4.Picture;
                                frmpower.BitBtn3Click(Sender);
                                exit;
                        end
                        else
                        begin
                                StatusLab.simpletext  := '通电操作成功。';
                                label5.Caption:='已经通电';
                                image1.Picture:=image2.Picture;
                                activecommand:=false;

                        end;
                     end;
                end;
        end;

end;

procedure Tfrmpower.BitBtn2Click(Sender: TObject);
var
    sBuf, rStr: string;
    i:integer;
    delaystatu,delayuno1,delayuno2,delayuno3,phase,delaydeep:string;
    delay2uno:string;
begin
    StatusLab.simpletext := '';
    if UNO_E.Text = '' then
    BEGIN
        statusLab.simpletext  := '表号为空,请输入。';
        exit;
    end;
    sbuf := ConvertID(UNO_E.Text);
    activecommand:=true;
    BreakRead:=false;
    frmPromot.Hide;
    frmPromot.Promot.Caption := '是否对 [' + UNO_E.Text + '] 用户断电操作?';
    if frmPromot.ShowModal <> mrOK then exit;

    StatusLab.simpletext  := '';
    for I := 1  to 3 do
    begin
        if PutTXD('R' +Uno_E.text+ Chr(13), 159, rStr, 1500)  and UnLockFlag=true then break;
        if not UnLockFlag then
        begin
                frmPromot.Hide;
                frmPromot.Promot.Caption := '请先通过集中器口令检测。';
                frmPromot.ShowModal;
                BreakRead := true;

                exit;
        end;
    end;
    if i>3 then
    begin
                frmPromot.Hide;
                frmPromot.Promot.Caption := '请检查集中器中是否有此表号。';
                frmPromot.ShowModal;
                BreakRead := true;

                exit;
    end;
     delaystatu:=copy(rstr,14,1);
    phase:=copy(rstr,95,1);
    delaydeep:=copy(rstr,97,1);
    delayuno1:=copy(rstr,99,12);
    delayuno2:=copy(rstr,112,12);
    delayuno3:=copy(rstr,125,12);
    //Read SCALE and CONSTANT

    if BreakRead then
        begin

            activecommand:=false;
            exit;
        end;
    if delaystatu='0' then
        begin
                sBuf := 'H' + Phase + _CR;
                if PutTXD(sBuf, 4, rStr,2500) and (Copy(rStr, 1, 4) = _OK) then
                begin
                        for I := 1  to 3 do
                        begin

                                if PutTXD('S'+uno_e.text+'5670'+CHR(13), 22, rStr, 2500) and (Copy(rStr, 1, 4) = _OK) AND (Copy(rStr, 5, 10)='0000000000') AND (Copy(rStr, 21, 2) = _CRLF) then break;
                        end;


⌨️ 快捷键说明

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