SmartFactory_NEOL/SOURCE/Agent,Kiosk/NEOL-LS-PLC-TEST/LC_PLC_TEST/PlcAddressEdit.pas
2026-09-04 14:08:41 +09:00

121 lines
3.5 KiB
ObjectPascal
Raw Blame History

unit PlcAddressEdit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls,
LsPlcMain, plc_addr_info;
type
TfrmPlcAddressEdit = class(TForm)
GroupBox1: TGroupBox;
LabeledEdit1: TLabeledEdit;
LabeledEdit2: TLabeledEdit;
LabeledEdit3: TLabeledEdit;
GroupBox2: TGroupBox;
LabeledEdit4: TLabeledEdit;
LabeledEdit5: TLabeledEdit;
Panel1: TPanel;
Panel2: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
RadioGroup1: TRadioGroup;
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure LabeledEdit4KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure LabeledEdit5KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure LabeledEdit6KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
FPlcAddr: string;
FobjPlc: Tplc_addr_info;
public
{ Public declarations }
property PlcAddr: string read FPlcAddr write FPlcAddr;
property objPlc: Tplc_addr_info read FobjPlc write FobjPlc;
end;
var
frmPlcAddressEdit: TfrmPlcAddressEdit;
implementation
{$R *.dfm}
procedure TfrmPlcAddressEdit.BitBtn1Click(Sender: TObject);
begin
if Tag = 0 then FobjPlc := Tplc_addr_info.Create;
FobjPlc.MachNum := Trim(LabeledEdit2.Text);
FobjPlc.MachName := Trim(LabeledEdit1.Text);
FobjPlc.Kind := Trim(LabeledEdit3.Text);
FobjPlc.Name := Trim(LabeledEdit4.Text);
FobjPlc.Address := Trim(LabeledEdit5.Text);
FobjPlc.Descriptions := RadioGroup1.Items.Strings[RadioGroup1.ItemIndex];
//FobjPlc.Idx := '1';
FobjPlc.IsValid := '1';
end;
procedure TfrmPlcAddressEdit.FormCreate(Sender: TObject);
begin
FPlcAddr := '';
FobjPlc := nil;
end;
procedure TfrmPlcAddressEdit.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then ModalResult := mrCancel;
end;
procedure TfrmPlcAddressEdit.FormShow(Sender: TObject);
var
idx: Integer;
begin
LabeledEdit3.Text := frmLsPlcMain.ComboBox2.Text;
LabeledEdit1.Text := frmLsPlcMain.LabeledEdit3.Text;
LabeledEdit2.Text := frmLsPlcMain.LabeledEdit4.Text;
if Tag = 0 then begin
//LabeledEdit4 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Է<EFBFBD>..
LabeledEdit4.Text := '';
//LabeledEdit5 <20>׸<EFBFBD><D7B8><EFBFBD> <20><><EFBFBD><EFBFBD>..
LabeledEdit5.Text := FplcAddr;
//LabeledEdit6 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Է<EFBFBD>..
// LabeledEdit6.Text := '';
RadioGroup1.ItemIndex := RadioGroup1.Items.IndexOf('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end else begin
LabeledEdit4.Text := FobjPlc.Name;
LabeledEdit5.Text := FobjPlc.Address;
idx := RadioGroup1.Items.IndexOf(FobjPlc.Descriptions);
if idx = -1 then RadioGroup1.ItemIndex := RadioGroup1.Items.IndexOf('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
else RadioGroup1.ItemIndex := idx;
// LabeledEdit6.Text := FobjPlc.Descriptions;
end;
LabeledEdit4.SetFocus;
end;
procedure TfrmPlcAddressEdit.LabeledEdit4KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RETURN then LabeledEdit5.SetFocus;
end;
procedure TfrmPlcAddressEdit.LabeledEdit5KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
// if Key = VK_RETURN then LabeledEdit6.SetFocus;
end;
procedure TfrmPlcAddressEdit.LabeledEdit6KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RETURN then BitBtn1.SetFocus;
end;
end.