📄 mainu.~pas
字号:
unit mainU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp,inifiles, Menus, iPositionComponent, iScaleComponent,
iThermometer, iSwitchToggle, iSevenSegmentDisplay, iSevenSegmentInteger,
iLabel, iLedArrow, iSwitchLed, iSwitchPanel, StdCtrls, ExtCtrls, iLed,
iLedRound, iPipe, iComponent, iVCLComponent, iCustomComponent, iGradient;
type
Tmainform = class(TForm)
ClientSocket1: TClientSocket;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
Panel2: TPanel;
iGradient1: TiGradient;
iPipe7: TiPipe;
iPipe9: TiPipe;
iPipe8: TiPipe;
iPipe6: TiPipe;
iPipe2: TiPipe;
iPipe5: TiPipe;
iPipe4: TiPipe;
iPipe1: TiPipe;
iPipe3: TiPipe;
Image1: TImage;
Image2: TImage;
iLedRound7: TiLedRound;
iLedRound5: TiLedRound;
iLedRound6: TiLedRound;
Image3: TImage;
iPipe10: TiPipe;
Panel3: TPanel;
Bevel1: TBevel;
Image4: TImage;
GroupBox1: TGroupBox;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
iSwitchPanel1: TiSwitchPanel;
iSwitchLed1: TiSwitchLed;
iSwitchLed2: TiSwitchLed;
iSwitchPanel2: TiSwitchPanel;
iSwitchPanel3: TiSwitchPanel;
GroupBox2: TGroupBox;
Label5: TLabel;
iLedArrow1: TiLedArrow;
iLedArrow2: TiLedArrow;
iLedArrow3: TiLedArrow;
iLedArrow4: TiLedArrow;
iLabel1: TiLabel;
iLedRound1: TiLedRound;
iLedRound2: TiLedRound;
iLabel2: TiLabel;
iLabel3: TiLabel;
iLabel4: TiLabel;
iLedRound3: TiLedRound;
iLedRound4: TiLedRound;
iLabel5: TiLabel;
iSevenSegmentInteger2: TiSevenSegmentInteger;
iLabel6: TiLabel;
iLabel7: TiLabel;
iSevenSegmentInteger3: TiSevenSegmentInteger;
iLabel10: TiLabel;
iSwitchToggle1: TiSwitchToggle;
iLabel8: TiLabel;
iLabel9: TiLabel;
iThermometer1: TiThermometer;
iSevenSegmentInteger1: TiSevenSegmentInteger;
Label6: TLabel;
procedure FormCreate(Sender: TObject);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure N2Click(Sender: TObject);
procedure fsmk;
procedure iSwitchPanel1PositionChange(Sender: TObject);
procedure iSwitchPanel2PositionChange(Sender: TObject);
procedure iSwitchPanel3PositionChange(Sender: TObject);
procedure iSwitchLed1Change(Sender: TObject);
procedure iSwitchLed2Change(Sender: TObject);
procedure iSwitchToggle1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
mainform: Tmainform;
fsxx:string;
jsxx:string;
yhm:string;
sf:string;
implementation
uses loginU,upassU;
{$R *.dfm}
procedure Tmainform.fsmk;
begin
mainform.ClientSocket1.Socket.SendText(fsxx);
end;
procedure yzyh;
begin
bz:=copy(jsxx,2,1);
if bz='0' then
begin
mainform.ClientSocket1.Active:=false;
showmessage('您输入的用户名或密码有误!');
end
else
begin
yhm:=trim(loginform.Edit1.Text);
loginform.Close;
mainform.Show;
end;
end;
procedure xgmm;
begin
if copy(jsxx,2,1)='1'then
showmessage('修改成功!');
end;
procedure fourd(x,y:integer);
begin
if x=1 then
begin
mainform.iLedArrow1.Active:=false;
mainform.iLedArrow3.Active:=false;
end;
if x=0 then
begin
mainform.iLedArrow1.Active:=true;
mainform.iLedArrow3.Active:=false;
end;
if x=2 then
begin
mainform.iLedArrow1.Active:=false;
mainform.iLedArrow3.Active:=true;
end;
if y=1 then
begin
mainform.iLedArrow2.Active:=false;
mainform.iLedArrow4.Active:=false;
end;
if y=0 then
begin
mainform.iLedArrow2.Active:=true;
mainform.iLedArrow4.Active:=false;
end;
if y=2 then
begin
mainform.iLedArrow2.Active:=false;
mainform.iLedArrow4.Active:=true;
end;
end;
procedure tbgc; //同步程序
begin
mainform.iSwitchPanel1.Position:=strtoint(copy(jsxx,2,1));
mainform.iSwitchPanel2.Position:=strtoint(copy(jsxx,3,1));
mainform.iSwitchPanel3.Position:=strtoint(copy(jsxx,4,1));
if copy(jsxx,5,1)='1' then mainform.iSwitchLed1.Active:=true else mainform.iSwitchLed1.Active:=false;
if copy(jsxx,6,1)='1' then mainform.iSwitchLed2.Active:=true else mainform.iSwitchLed2.Active:=false;
if copy(jsxx,7,1)='1' then mainform.iSwitchToggle1.Active:=true else mainform.iSwitchToggle1.Active:=false;
mainform.iThermometer1.Position:=strtofloat(copy(jsxx,8,2));
mainform.iSevenSegmentInteger2.Value:=strtoint(copy(jsxx,10,1));
mainform.iSevenSegmentInteger3.Value:=strtoint(copy(jsxx,11,2));
mainform.iGradient1.Top:=184-strtoint(copy(jsxx,13,3));
mainform.Image4.Left:=624+strtoint(copy(jsxx,16,4));
mainform.Panel3.Left:=704+strtoint(copy(jsxx,16,4));
mainform.Panel3.Height:=145+strtoint(copy(jsxx,20,3));
if copy(jsxx,23,1)='1' then
begin
mainform.Image3.Left:=664+strtoint(copy(jsxx,16,4));
mainform.Image3.Top:=272+strtoint(copy(jsxx,20,3));
end;
fourd(strtoint(copy(jsxx,3,1)),strtoint(copy(jsxx,4,1)));
end;
procedure kzqx;
begin
sf:=copy(jsxx,2,1);
if sf='1' then
mainform.Label6.Caption:='享有控制权'
else
mainform.Label6.Caption:='没有控制权';
end;
procedure jsmk;
var
i:integer;
begin
i:=strtoint(copy(jsxx,1,1));
case i of
1: yzyh;
2: xgmm;
3: tbgc;
4: kzqx;
end;
end;
procedure linkaddr;
var
myini:Tinifile;
begin
myini:=Tinifile.Create(ExtractFilePath(paramstr(0))+'link.ini');
mainform.ClientSocket1.Address:=myini.ReadString('link','addr','默认值');
end;
procedure Tmainform.FormCreate(Sender: TObject);
begin
application.ShowMainForm:=false;
linkaddr;
loginform:=Tloginform.Create(self);
loginform.ShowModal;
loginform.Free;
end;
procedure Tmainform.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
jsxx:=socket.ReceiveText;
jsmk;
end;
procedure Tmainform.N2Click(Sender: TObject);
begin
updatepass:=Tupdatepass.Create(self);
updatepass.ShowModal;
updatepass.Free;
end;
procedure Tmainform.iSwitchPanel1PositionChange(Sender: TObject);
begin
if sf='1' then
begin
fsxx:='3'+inttostr(iSwitchPanel1.Position);
fsmk;
end;
if iSwitchPanel1.Position=0 then
begin
iLedRound1.Active:=true;
iLedRound2.Active:=false;
iLedRound5.Active:=true;
iLedRound7.Active:=false;
iPipe1.FlowOn:=true;
iPipe1.FlowReverse:=false;
iPipe2.FlowOn:=true;
iPipe2.FlowReverse:=false;
iPipe8.FlowOn:=true;
iPipe8.FlowReverse:=false;
iPipe9.FlowOn:=true;
iPipe9.FlowReverse:=true;
end;
if iSwitchPanel1.Position=1 then
begin
iLedRound1.Active:=false;
iLedRound2.Active:=false;
iLedRound5.Active:=false;
iLedRound7.Active:=false;
iPipe1.FlowOn:=false;
iPipe2.FlowOn:=false;
iPipe8.FlowOn:=false;
iPipe9.FlowOn:=false;
end;
if iSwitchPanel1.Position=2 then
begin
iLedRound1.Active:=false;
iLedRound2.Active:=true;
iLedRound5.Active:=false;
iLedRound7.Active:=true;
iPipe1.FlowOn:=true;
iPipe1.FlowReverse:=true;
iPipe2.FlowOn:=true;
iPipe2.FlowReverse:=true;
iPipe8.FlowOn:=true;
iPipe8.FlowReverse:=true;
iPipe9.FlowOn:=true;
iPipe9.FlowReverse:=false;
end;
end;
procedure Tmainform.iSwitchPanel2PositionChange(Sender: TObject);
begin
if sf='1' then
begin
fsxx:='4'+inttostr(iSwitchPanel2.Position);
fsmk;
end;
end;
procedure Tmainform.iSwitchPanel3PositionChange(Sender: TObject);
begin
if sf='1' then
begin
fsxx:='5'+inttostr(iSwitchPanel3.Position);
fsmk;
end;
end;
procedure Tmainform.iSwitchLed1Change(Sender: TObject);
begin
if iSwitchLed1.Active=true then fsxx:='61' else fsxx:='60';
if sf='1' then
fsmk;
if iSwitchLed1.Active=true then
begin
iLedRound3.Active:=true;
iPipe3.FlowOn:=true;
iPipe4.FlowOn:=true;
iPipe5.FlowOn:=true;
iPipe6.FlowOn:=true;
iPipe7.FlowOn:=true;
end
else
begin
iLedRound3.Active:=false;
iPipe3.FlowOn:=false;
iPipe4.FlowOn:=false;
iPipe5.FlowOn:=false;
iPipe6.FlowOn:=false;
iPipe7.FlowOn:=false;
end;
end;
procedure Tmainform.iSwitchLed2Change(Sender: TObject);
begin
if iSwitchLed2.Active=true then
begin
iLedRound4.Active:=true;
fsxx:='71'
end
else
begin
iLedRound4.Active:=false;
fsxx:='70';
end;
if sf='1' then
fsmk;
end;
procedure Tmainform.iSwitchToggle1Change(Sender: TObject);
begin
if sf='1' then
begin
if iSwitchToggle1.Active=true then fsxx:='81' else fsxx:='80';
fsmk;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -