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

📄 wbtaunit1.pas

📁 System will automatically delete the directory of debug and release, so please do not put files on t
💻 PAS
📖 第 1 页 / 共 3 页
字号:
                if Ch = #$0A then WriteScreen(#$0A+#$0D);
             end else WriteScreen(Ch);
          end
       end else
          If ComTerminal1.Visible = True then WriteScreen(Str);
    End;
    sleep(100);
    Application.ProcessMessages;
  end; {while}
end;   { terminal EPI / SS2000I }


procedure TForm1.Scanforindexer1Click(Sender: TObject);
begin
   Timer1.Enabled := False; // stop any auto repeat wb 04.01.2002
   WBTA_32_IDX.ScanIDX;
end;

procedure TForm1.FormResize(Sender: TObject);
// var  M : TMemoryStream;
//     N : Integer;
begin
(*
  M := TMemoryStream.Create;
  try
    ComTerminal1.SaveToStream(M);
    N := Round((Form1.Height -94) / 15.3);
    ComTerminal1.Height := round(N * 15.3);
    Form1.Height :=  ComTerminal1.Height + 94;
    ComTerminal1.Rows := N;
    M.Position := 0;
    ComTerminal1.LoadFromStream(M);
    ComTerminal1.Update;
    Edit2.Text := IntToStr(ComTerminal1.Rows);
  finally
     M.Free;
  end;  *)
end;

procedure TForm1.SpeedButton5Click(Sender: TObject);
begin
  StatusBar1.Panels[2].Text := ' Unit : ' + WBTA_32_IDX.GetH23;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  Params  := NOT Params ;
   //   Visible := NOT Comterminal1.Visible;
  StringGrid1.Visible  := Params;
  Label1.Visible       := Params;
//   := NOT Params;
  If not Params then begin
//   Comterminal1.Height := 364;
//   Comterminal1.Width  := 657;
     Comterminal1.Visible := True;
     Comterminal1.SetFocus;
     SpeedButton1.Caption := 'Parameters';
  end else begin
       Comterminal1.Hide ;
//     Comterminal1.Height := 1;
//     Comterminal1.Width  := 1;
     SpeedButton1.Caption := 'Terminal';
  end;
end;

procedure TForm1.IDXtpoPC1Click(Sender: TObject);
begin
  ProgPars := False;
  Form1.Enabled := False;
  WBTA_32_IDX.IDXToPC;
  Form1.Enabled := True;
end;

procedure TForm1.ReadLParameters1Click(Sender: TObject);
var I : Integer;
  XPos, YPos : Integer;
begin
  Form1.Enabled := False;
  for I := 1 to 3 * 17 do begin  // clear stringgrid
    Xpos := ((I - 1) DIV 17);    // 17 = stringgrid rows
    Ypos := ((I - 1) MOD 17);
    StringGrid1.Cells[XPos,YPos] := ' ';
  end;
  Label1.caption := 'L Parameters ' + WBTA_32_IDX.GetH23;
  WBTA_32_IDX.GetPar;
  Form1.Enabled := True;
  for I := 1 to LParamStr.Count do begin
    Xpos := ((I - 1) DIV 17); // 17 stringgrid rows
    Ypos := ((I - 1) MOD 17);
    Form1.StringGrid1.Cells[XPos,YPos] := LParamStr[I - 1];
  end;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  Doorgaan := False;
//  ComPort1.StoreSettings(stIniFile, INIFilename);
  SaveINI;
  if ComPort1.Connected then
     ComPort1.Close;

  IniFile := TIniFile.Create(INIFileName);
  IniFile.WriteString  ('MainSection',  'Control Type ',IntToStr(ContrType));
  IniFile.Free;
end;

procedure TForm1.Copy1Click(Sender: TObject);
var  M : TMemoryStream;
  StrL : TStringList;
begin
  M := TMemoryStream.Create;
  StrL := TStringList.Create;
  try
    ComTerminal1.SaveToStream(M);
    M.Position := 0;
    StrL.LoadFromStream(M);
    Clipboard.AsText := StrL.Text;
  finally
     M.Free;
     StrL.Free;
  end;
end;

procedure TForm1.StringGrid1Click(Sender: TObject);
var S : String;
    N : Integer;
begin
  S := StringGrid1.Cells[StringGrid1.Col ,StringGrid1.Row];
  If length(S) > 3 then
     S := Copy(S,1,3)
  else S := '99';
  N := StrToInt(Copy(S,2,2));
  If  S <> '99' then
    Label2.Caption := S + ' : '+WBTA_32_IDX.ParInfo(N)
  else
    Label2.Caption := ' ';
end;

procedure TForm1.RepSetupClick(Sender: TObject);
begin
  try
    Form2 := TForm2.Create(Application);
    Form2.Edit1.Text := IntToStr(RepDelay);
    if Form2.ShowModal = mrOK then
       RepDelay := StrToInt(Form2.Edit1.Text);
  finally
    Form2.Release;
    Form2 := NIL;
  end;
end;


procedure TForm1.Editmacros1Click(Sender: TObject);
begin
  try
    Form1.Enabled := False;
    MacroForm := TMacroForm.Create(Application);
    if MacroForm.ShowModal = mrOK then
       SaveINI;
  finally
    MacroForm.Release;
    MacroForm := NIL;
    Form1.Enabled := True;
  end;
end;

procedure TForm1.N01Click(Sender: TObject);
begin
  SendMacro((Sender As TMenuItem).Tag);
end;

procedure TForm1.WBTA1Click(Sender: TObject);
begin
//   XWETA0001;
//  Edit2.Text := IntToStr(GetL70);
  PCtoIDX;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  If CommandRepeat = false then begin
     Timer1.Enabled := False;
     doorgaan := true;
     TermReceive;
     //     SS2000I1Click(sender);
  end else begin  // automatic repeat handling
     RepeatButton4Click(Sender);
  end;
end;

procedure TForm1.ProgPar1Click(Sender: TObject);
begin
// parameters and program to file
  ProgPars := True;  // to save both to disk
  Form1.Enabled := False;
  WBTA_32_IDX.IDXToPC;
  Form1.Enabled := True;
end;

procedure TForm1.NoIDXSel;
begin
  Application.MessageBox('There is no control selected.'
  +#13#10+'Use Alt+S to select a control.',
  ' No control selected', mb_applmodal+mb_iconerror+mb_ok+mb_defbutton1);
end;

procedure TForm1.IOButton2Click(Sender: TObject);
begin
  Case ContrType of
    4 : begin
          try
            SS2K_IO_Form := TSS2K_IO_Form.Create(Application);
            SS2K_IO_Form.ShowModal;
          finally
            SS2K_IO_Form.Release;
            SS2k_IO_Form := NIL;
          end;
        end;
    5 : begin
          try
            EPI_IO_Form := TEPI_IO_Form.Create(Application);
            EPI_IO_Form.ShowModal;
          finally
            EPI_IO_Form.Release;
            EPI_IO_Form := NIL;
          end;
        end;
  6,7 : begin
          try
            WarpIOForm := TWarpIOForm.Create(Application);
            WarpIOForm.ShowModal;
          finally
            WarpIOForm.Release;
            WarpIOForm := NIL;
          end;
        end;
   end;     
  Doorgaan := True;
  TermReceive;
end;

procedure TForm1.RepeatButton4Click(Sender: TObject);
begin
  Comport1.WriteStr(ComboBox1.Items[ComboBox1.ItemIndex] +CR+LF);  // repeat
  WriteScreen(ComboBox1.Items[ComboBox1.ItemIndex] +CR+LF); // to screen and logfile 
end;

procedure TForm1.Autorepeat1Click(Sender: TObject);
begin
  Timer1.Interval := RepDelay;
  Timer1.Enabled  := True;
  CommandRepeat   := True;
end;

function TForm1.AddTextToFile(const aFileName, aText: string; AddCRLF: Boolean): Boolean;
var lF : Integer;
    lS : string;
begin
  // only for debug
  AddTextToFile := False;
  if aFilename = 'error.log' then exit;

  Result := False;
  if FileExists(aFileName) then
    lF := FileOpen(aFileName, fmOpenWrite + fmShareDenyNone)
  else lF := FileCreate(aFileName);
  if (lF >= 0) then
    try
      FileSeek(lF, 0, 2);
      if AddCRLF then lS := aText + #13#10
      else lS := aText;
      FileWrite(lF, lS[1], Length(lS));
    finally
      FileClose(lF);
   end;
end;

procedure TForm1.SpeedButton3Click(Sender: TObject);
var S : String;
begin
  S := DateToStr(Date) + ' ' +  TimeToStr(Time);
  AddTextToFile(LogFile,' ',True);
  LogOn := NOT LogOn;
  If LogOn then begin
     SpeedButton3.Caption := 'Log is ON';
     AddTextToFile(LogFile,'Log ON : ' + S,True);
     AddTextToFile(LogFile,' ',True);
  end else begin
     SpeedButton3.Caption := 'Log is OFF';
     AddTextToFile(LogFile,'Log OFF: ' + S,True);
     AddTextToFile(LogFile,' ',True);
  end;
end;

procedure TForm1.Viewlogfile1Click(Sender: TObject);
begin
  OpenDialog1.Filename := LogFile;
  OpenDialog1.Filter :=  'Logfiles (*.LOG)|*.LOG';
  OpenDialog1.DefaultExt := 'LOG';
  If OpenDialog1.Execute then begin
     ShellExecute(Handle,'open',PChar(OpenDialog1.Filename),'','',sw_ShowNormal);
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Timer1.Enabled := False;  // added wimb 2003.12.06
  AddTextToFile('error.log','WBTA closing : ' + DateToStr(Date) + ' ' +  TimeToStr(Time),True);
  AddTextToFile('error.log',' ',True);
end;

procedure TForm1.helpIndex1Click(Sender: TObject);
var  command: array[0..255] of Char;
begin
  command := 'SEARCH()';
  application.helpcommand(HELP_FORCEFILE, 0);
  application.helpcommand(HELP_COMMAND, Longint(@command));
end;

procedure TForm1.About1Click(Sender: TObject);
begin
  Application.HelpContext(99999);
end;

procedure TForm1.Contents1Click(Sender: TObject);
begin
  Application.HelpCommand(HELP_FINDER, 0);
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = 112 then  Application.HelpCommand(HELP_FINDER, 0);
end;

procedure TForm1.ComboBox2Change(Sender: TObject);
var S : String;
begin
  S := copy(ComboBox2.Text,1,3);
  S := StringReplace(S,'#','<',[]);
  S := StringReplace(S,' ','',[rfReplaceAll]);
  Comterminal1.WriteStr(LF + CR + S);
  Comport1.WriteStr(S + '? '); // select control
  Comport1.WriteStr(LF + CR);
  StatusBar1.Panels[2].Text := ' Unit :' + copy(ComboBox2.Text,6,999);
  try
    If Comterminal1.Visible = True then
       Comterminal1.SetFocus;
  except
  end;
end;

procedure TForm1.StatusBar1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  // Statusbar1.Panels[3].Text := IntToStr(X) + '  ' + IntToStr(Y);
  If ((X > 560) and (X < 650)) then begin
     IF Application.MessageBox('Do you want to connect with www.wimb.net ?',
     'Internet connection',
     mb_applmodal+mb_iconquestion+mb_okcancel+mb_defbutton1) = 1 then
     ShellExecute(Handle,'open',PChar('http://www.wimb.net'),'', '', sw_ShowNormal);
  end;
end;

END.




⌨️ 快捷键说明

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