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

📄 tempp.pas

📁 自已用DELPHI编写的MODBUS测试软件及源代码
💻 PAS
字号:
unit tempp;

interface

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

type
  Ttempform = class(TForm)
    tempedit: TEdit;
    tempbutton: TBitBtn;
    UpDown1: TUpDown;
    procedure tempbuttonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  tempform: Ttempform;

implementation
uses econv230p, filedefine;
{$R *.DFM}

procedure Ttempform.tempbuttonClick(Sender: TObject);
var
  temp: string;
  i, j, k: integer;
begin

  temp := tempform.caption;

  i:=pos('两帧间隔时间', temp);
  if i>0 then
  begin
    econfile.comm.timepoll := strtointdef(tempedit.text, 10);
    tempform.close;
    exit;
  end;

  i := pos('超时时间', temp);
  if i>0 then
  begin
    econfile.comm.timeout := strtointdef(tempedit.text, 100);
    tempform.close;
    exit;
  end;

  i := pos('控制', temp);
  if i>0 then
  begin
    j := strtointdef(tempedit.text, -1);
    case j of
      0:
      begin
        econfile.comm.sendbuffer3 := '05' + inttohex(smindex-1, 4) + '0000';
        econfile.comm.sendbuffer4 := '01' + inttohex(smindex-1, 4) + '0001';
        addsendbuffer2(econfile, '01' + inttohex(smindex-1,4) + '0001');
      end;

      1:
      begin
        econfile.comm.sendbuffer3 := '05' + inttohex(smindex-1, 4) + 'ff00';
        econfile.comm.sendbuffer4 := '01' + inttohex(smindex-1, 4) + '0001';
        addsendbuffer2(econfile, '01' + inttohex(smindex-1,4) + '0001');
      end;
   end;
   tempform.close;
   exit;
  end;

  i := pos('修改',temp);
  if i>0 then
  begin
    j := strtointdef(tempedit.text, -1);
    if j>=0 then
    begin
      econfile.comm.sendbuffer3 := '06' + inttohex(smindex-1, 4) + inttohex(j, 4);
      econfile.comm.sendbuffer4 := '03' + inttohex(smindex-1, 4) + '0001';
      //addsendbuffer2(econfile, '06' + inttohex(smindex-1, 4) + inttohex(j, 4));
      //addsendbuffer2(econfile, '03' + inttohex(smindex-1, 4) + '0001');
    end;
    tempform.Close;
    exit;
  end;

  i := pos('基数', temp);
  if i>0 then
  begin
    j := smindex;
    if j>0 then
    begin
      if (j mod 2)=0 then
      for k:=1 to 21 do econfile.xieboarray[k*2].address2 := tempedit.text;
      if (j mod 2)=1 then
      for k:=1 to 21 do econfile.xieboarray[k*2-1].address2 := tempedit.text;
     end;
    tempform.Close;
    exit;
  end;

  i := pos('投退', temp);
  if i>0 then
  begin
    i := strtointdef(tempedit.text, 0);
    if i=0 then
    begin
      j := strtointdef(econfile.holdregisterarray[smindex].value, 0)and $000f;
      econfile.comm.sendbuffer3 := '06' + inttohex(smindex-1, 4) + inttohex(j, 4);
      econfile.comm.sendbuffer4 := '03' + inttohex(smindex-1, 4) + '0001';
      //addsendbuffer2(econfile, '06' + inttohex(smindex-1, 4) + inttohex(i, 4));
      //addsendbuffer2(econfile, '03' + inttohex(smindex-1, 4) + '0001');
//        econfile.holdregisterarray[smindex].value:=inttohex(i,4);
      tempform.Close;
      exit;
    end;

    if i=1 then
    begin
      j := strtointdef(econfile.holdregisterarray[smindex].value, 0)or $8000;
      econfile.comm.sendbuffer3 := '06' + inttohex(smindex-1, 4) + inttohex(j, 4);
      econfile.comm.sendbuffer4 := '03' + inttohex(smindex-1, 4) + '0001';
      //addsendbuffer2(econfile, '06' + inttohex(smindex-1, 4) + inttohex(i, 4));
      //addsendbuffer2(econfile, '03' + inttohex(smindex-1, 4) + '0001');
    end;
    tempform.Close;
    exit;
  end;

  i := pos('动作继电器', temp);
  if i>0 then
  begin
    i := strtointdef(tempedit.text, -1);
    if (i>=0) then
    begin
      j := (strtointdef(econfile.holdregisterarray[smindex].value,0) and $8000)+i;
      econfile.comm.sendbuffer3 := '06' + inttohex(smindex-1, 4) + inttohex(j, 4);
      econfile.comm.sendbuffer4 := '03' + inttohex(smindex-1, 4) + '0001';
      //addsendbuffer2(econfile, '06' + inttohex(smindex-1, 4) + inttohex(i, 4));
      //addsendbuffer2(econfile, '03' + inttohex(smindex-1, 4) + '0001');
    end;
    tempform.Close;
    exit;
  end;

  i := pos('设置', temp);
  if i>0 then
  begin
    j := strtointdef(tempedit.text, -1);
    if j>=0 then
    begin
      i := strtointdef(econfile.setpowerarray[smindex].address1, 0)-1;
      econfile.comm.sendbuffer3 := '06' + inttohex(i,4) + inttohex(j mod 65536, 4);
      //addsendbuffer2(econfile,'06' + inttohex(i,4) + inttohex(j mod 65536, 4));
      //addsendbuffer2(econfile,'03' + inttohex(i, 4) + '0001');
      i := strtointdef(econfile.setpowerarray[smindex].address2,0)-1;
      addsendbuffer2(econfile,'06' + inttohex(i, 4) + inttohex(j div 65536, 4));
      addsendbuffer2(econfile,'03' + inttohex(i, 4) + '0002');
      tempform.updown1.Visible := true;
      tempform.close;
    end;
    tempform.Close;
    exit;
  end;

  tempform.Close;
end;

end.

⌨️ 快捷键说明

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