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

📄 unitparam.pas

📁 本目录内所有代码仅作指导用户编程之用,用户如果要作为 商业用途,建议使用正版软件进行编译. 开发环境说明: delphi demo : delphi 6.0 vc de
💻 PAS
📖 第 1 页 / 共 4 页
字号:
                 or ((Longword(param[2]) shl 8) and $0000ff00)
                 or (Longword(param[3]) and $000000ff);
    addr.S_addr := ntohl(four_byte);
    ComboBox9.Text := inet_ntoa(addr);
  end;
  paramlen := 4;
  if GetParam($20, param, paramlen) = 1 then
  begin
    four_byte := ((Longword(param[0]) shl 24) and $ff000000)
                 or ((Longword(param[1]) shl 16) and $00ff0000)
                 or ((Longword(param[2]) shl 8) and $0000ff00)
                 or (Longword(param[3]) and $000000ff);
    addr.S_addr := ntohl(four_byte);
    Edit20.Text := inet_ntoa(addr);
  end;
  paramlen := 2;
  if GetParam($21, param, paramlen) = 1 then
  begin
    two_byte := ((Word(param[0]) shl 8) and $ff00)
              or ((Word(param[1])) and $00ff);
    Edit21.Text := inttostr(two_byte);
  end;

  //获取串口设置
  paramlen := 30;
  if GetParam($12, param, paramlen) = 1 then begin
    s := '';
    for i := 0 to paramlen - 1 do
      if (param[i] = '-') or (param[i] = #0) then
        break
      else
        s := s + param[i];
    ComboBox8.Text := s;
    i := i + 1;

    if (i < paramlen - 1) and (param[i] >= '5') and (param[i] <= '8') then begin
      ComboBox5.ItemIndex := Byte(param[i]) - $30 - 5;
      i := i + 2;
    end else 
      ComboBox5.ItemIndex := -1;

    if (i < paramlen - 1) and (param[i] >= '1') and (param[i] <= '2') then begin
      ComboBox4.ItemIndex := Byte(param[i]) - $30 - 1;
      i := i + 2;
    end else
      ComboBox4.ItemIndex := -1;

    if (i < paramlen - 1) and (param[i] >= '0') and (param[i] <= '2') then begin
      ComboBox2.ItemIndex := Byte(param[i]) - $30;
      i := i + 2;
    end else
      ComboBox2.ItemIndex := -1;

    if (i <= paramlen - 1) and (param[i] >= '1') and (param[i] <= '5') then
      ComboBox3.ItemIndex := Byte(param[i]) - $30 - 1
    else
      ComboBox3.ItemIndex := -1;
  end;
    {if SeparateSerialParam(param, paramlen, baudrate, databit, stopbit, paritybit, flowcontrol) = 1 then
    begin
      ComboBox8.Text := inttostr(baudrate);

      if databit <= 3 then
        ComboBox5.ItemIndex := databit
      else
        ComboBox5.ItemIndex := -1;

      if stopbit = 0 then
        ComboBox4.ItemIndex := 0
      else if stopbit = $04 then
        ComboBox4.ItemIndex := 1
      else
        ComboBox4.ItemIndex := -1;

      if paritybit = 0 then
        ComboBox2.ItemIndex := 0
      else if paritybit = $08 then
        ComboBox2.ItemIndex := 1
      else if paritybit = $18 then
        ComboBox2.ItemIndex := 2
      else
        ComboBox2.ItemIndex := -1;

      if (1 <= flowcontrol) and (flowcontrol <= 5) then
        ComboBox3.ItemIndex := flowcontrol - 1
      else
        ComboBox3.ItemIndex := -1;
    end;}

  //获取特殊设置
  paramlen := 1;
  if GetParam($13, param, paramlen) = 1 then
    Edit23.Text := inttostr(byte(param[0]));
  paramlen := 1;
  if GetParam($14, param, paramlen) = 1 then
    Edit24.Text := inttostr(byte(param[0]));
  paramlen := 2;
  if GetParam($15, param, paramlen) = 1 then
  begin
    two_byte := ((Word(param[0]) shl 8) and $ff00)
              or ((Word(param[1])) and $00ff);
    Edit25.Text := inttostr(two_byte);
  end;
  paramlen := 2;
  if GetParam($16, param, paramlen) = 1 then
  begin
    two_byte := ((Word(param[0]) shl 8) and $ff00)
              or ((Word(param[1])) and $00ff);
    Edit26.Text := inttostr(two_byte);
  end;
  paramlen := 12;
  if GetParam($17, param, paramlen) = 1 then
    Edit27.Text := param;
  paramlen := 1;
  if (GetParam($18, param, paramlen) = 1)
    and ((Byte(param[0]) = 0) or (Byte(param[0]) = 1)) then
      ComboBox6.ItemIndex := Byte(param[0])
  else
    ComboBox6.ItemIndex := -1;
  paramlen := 1;
  if (GetParam($19, param, paramlen) = 1)
    and ((Byte(param[0]) = 0) or (Byte(param[0]) = 1)) then
      ComboBox7.ItemIndex := Byte(param[0])
  else
    ComboBox7.ItemIndex := -1;
  paramlen := 2;
  if GetParam($22, param, paramlen) = 1 then
  begin
    two_byte := ((Word(param[0]) shl 8) and $ff00)
              or ((Word(param[1])) and $00ff);
    Edit29.Text := inttostr(two_byte);
  end;

  //其他信息
  paramlen := 25;
  if GetParam($30, param, paramlen) = 1 then
    Edit17.Text := param;
  paramlen := 25;
  if GetParam($31, param, paramlen) = 1 then
    Edit18.Text := param;
  paramlen := 14;
  if GetParam($32, param, paramlen) = 1 then
    if paramlen = 13 then begin
      s := '';
      s := s + param[0];
      s := s + param[1];
      s := s + param[2];
      s := s + param[3];
      s := s + '-';
      s := s + param[4];
      s := s + param[5];
      s := s + '-';
      s := s + param[6];
      s := s + param[7];
      if param[8] = 'A' then
        s := s + ' 上午 '
      else
        s := s + ' 下午 ';
      s := s + param[9];
      s := s + param[10];
      s := s + ':';
      s := s + param[11];
      s := s + param[12];
      Edit19.Text := s;
    end;
end;

function TFParam.checkparam: boolean;
var
  tmpstr: string;
  tmpint: integer;
  paramcount: Integer;
begin
  result := false;
  paramcount := 0;

  if CheckBox7.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit1.Text);
    if tmpstr = '' then
    begin
      MessageBox(Handle, PChar('服务代码不能为空'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 0;
      Edit1.SetFocus;
      exit;
    end;
  end;

  if CheckBox8.Checked then
    paramcount := paramcount + 1;

  if CheckBox9.Checked then
    paramcount := paramcount + 1;

  if RadioButton1.Checked then
    if CheckBox10.Checked then begin
      paramcount := paramcount + 1;
      if Trim(Edit4.Text) = '' then
      begin
        MessageBox(Handle, PChar('选择配置GPRS DTU,接入点不能为空'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
        PageControl1.ActivePageIndex := 0;
        Edit4.SetFocus;
        exit;
      end;
    end;
    {else begin
      MessageBox(Handle, PChar('选择配置GPRS DTU,必须勾上接入点'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 0;
      CheckBox10.SetFocus;
      exit;
    end;}

  if CheckBox11.Checked then
    paramcount := paramcount + 1;

  if CheckBox12.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit6.Text);
    if Length(tmpstr) <> 11 then
    begin
      MessageBox(Handle, PChar('DTU标识必须是11位长度'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 1;
      Edit6.SetFocus;
      exit;
    end;
  end;

  if CheckBox13.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit7.Text);
    if (tmpstr = '') or (strtoint(tmpstr) > 65535) then
    begin
      MessageBox(Handle, PChar('本地端口不能为空,取值范围从0到65535'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 1;
      Edit7.SetFocus;
      exit;
    end;
  end;

  if CheckBox14.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit8.Text);
    tmpint := strtoint(tmpstr);
    if (tmpstr = '') or (tmpint = 1)
      or (tmpint = 2) or (tmpint > 65535) then
    begin
      MessageBox(Handle, PChar('在线报告间隔不能为空,取值范围0或者3到65535'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 1;
      Edit8.SetFocus;
      exit;
    end;
  end;

  if CheckBox15.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit9.Text);
    if (tmpstr = '') or (strtoint(tmpstr) > 1024) then
    begin
      MessageBox(Handle, PChar('最大包长不能为空,取值范围从0到1024'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 1;
      Edit9.SetFocus;
      exit;
    end;
  end;

  if CheckBox16.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit10.Text);
    if (tmpstr = '') or (strtoint(tmpstr) > 65535) then
    begin
      MessageBox(Handle, PChar('重连接间隔不能为空,取值范围从0到65535'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 1;
      Edit10.SetFocus;
      exit;
    end;
  end;

  if CheckBox17.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit12.Text);
    if (tmpstr = '') or (strtoint(tmpstr) > 1) then
    begin
      MessageBox(Handle, PChar('调试状态不能为空,取值范围0或1'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 1;
      Edit12.SetFocus;
      exit;
    end;
  end;

  if CheckBox18.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit11.Text);
    tmpint := strtoint(tmpstr);
    if (tmpstr = '') or (tmpint < 100)
      or (tmpint > 65535) then
    begin
      MessageBox(Handle, PChar('每包最小间隔不能为空,取值范围从100到65535'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 1;
      Edit11.SetFocus;
      exit;
    end;
  end;

  if CheckBox35.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit30.Text);
    tmpint := strtoint(tmpstr);
    if (tmpstr = '') or (tmpint < 0)
      or (tmpint > 255) then
    begin
      MessageBox(Handle, PChar('调试状态不能为空,取值范围0到255'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 1;
      Edit30.SetFocus;
      exit;
    end;
  end;

  if CheckBox24.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit13.Text);
    if tmpstr = '' then
    begin
      MessageBox(Handle, PChar('主DSC地址不能为空'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 2;
      Edit13.SetFocus;
      exit;
    end;
  end;

  if CheckBox25.Checked then
    paramcount := paramcount + 1;

  if CheckBox26.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit15.Text);
    tmpint := strtoint(tmpstr);
    if (tmpstr = '') or ((tmpint > 0) and (tmpint < 10))
      or (tmpint > 65535) then
    begin
      MessageBox(Handle, PChar('域名检测间隔不能为空,取值范围0或10到65535'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 2;
      Edit15.SetFocus;
      exit;
    end;
  end;

  if CheckBox27.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit16.Text);
    if (tmpstr = '') or (strtoint(tmpstr) > 65535) then
    begin
      MessageBox(Handle, PChar('主DSC端口不能为空,取值范围从0到65535'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 2;
      Edit16.SetFocus;
      exit;
    end;
  end;

  if CheckBox28.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(ComboBox9.Text);
    if tmpstr = '' then
    begin
      MessageBox(Handle, PChar('域名服务器地址不能为空'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 2;
      ComboBox9.SetFocus;
      exit;
    end;
  end;

  if CheckBox21.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit20.Text);
    if tmpstr = '' then
    begin
      MessageBox(Handle, PChar('备用DSC地址不能为空'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 2;
      Edit20.SetFocus;
      exit;
    end;
  end;

  if CheckBox22.Checked then begin
    paramcount := paramcount + 1;
    tmpstr := Trim(Edit21.Text);
    if (tmpstr = '') or (strtoint(tmpstr) > 65535) then
    begin
      MessageBox(Handle, PChar('备用DSC端口不能为空,取值范围从0到65535'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 2;
      Edit21.SetFocus;
      exit;
    end;
  end;

  if CheckBox19.Checked then begin
    paramcount := paramcount + 1;

    tmpstr := Trim(ComboBox8.Text);
    if (tmpstr = '') or (strtoint(tmpstr) = 0) then
    begin
      MessageBox(Handle, PChar('波特率不能为空或等于0'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 3;
      ComboBox8.SetFocus;
      exit;
    end;

    if ComboBox5.ItemIndex = -1 then
    begin
      MessageBox(Handle, PChar('数据位不能为空'), PChar('参数错误'), MB_OK or MB_ICONEXCLAMATION);
      PageControl1.ActivePageIndex := 3;

⌨️ 快捷键说明

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