📄 unit1.~pas
字号:
begin
if(curChoose>0) and (curChoose<33) then
UpButton(curChoose);
curChoose:=tmpNo;
DownButton(curChoose);
//载入该云台的三个状态按钮
for i:=0 to 2 do
begin
if (ByteStatus[curChoose,i]=1) then
DownButton(33+i)
else
UpButton(33+i);
end;
end
{点击三个状态按钮}
else if(tmpNo>32) and (tmpNo<36) then
begin
//改变当前云台状态按钮的显示状态
if (curChoose>=0) or (curChoose<=33) then
begin
if (ByteStatus[curChoose,(tmpNo-33)]=1) then
begin
ByteStatus[curChoose,(tmpNo-33)]:=0;
UpButton(tmpNo);
end
else
begin
ByteStatus[curChoose,(tmpNo-33)]:=1;
DownButton(tmpNo);
end;
//发送底层指令
Code:=$c0;
if ByteStatus[curChoose,0]=1 then
Code:= Code+1;
if ByteStatus[curChoose,1]=1 then
Code:= Code+2;
if ByteStatus[curChoose,2]=1 then
Code:= Code+4;
WriteToPort(Code);
end
//如果没有云台被选中
else
StatusBar1.SimpleText:='请先选则云台镜头组合';
end;
end;
end;
//*******************************************
//功能:用户点击“设置控制端口”,生成云台配置窗体
// 如果用户点击“确定”按钮则应用用户改变的配置
// 如果用户点击“取消”按钮则不相应用户的改变
//*******************************************
procedure TMainForm.btConfCodeClick(Sender: TObject);
var
ConfCodeForm:TConfCodeForm;
i:integer;
begin
ConfCodeForm:=TConfCodeForm.Create(Application);
try
if ConfCodeForm.ShowModal =mrOk then
begin
//保存云台选择指令集
//由于主单元已经引用了ConfCodeForm窗体的单元,故可以直接访问ConfIOForm
for i:=1 to 32 do
ByteCodeChoose[i]:=CBinToByte(ConfCodeForm.edtNum[i].Text);
//保存动作控制指令集
ByteCodeAct[0]:=CBinToByte(ConfCodeForm.edtActUp.Text);
ByteCodeAct[1]:=CBinToByte(ConfCodeForm.edtActDown.Text);
ByteCodeAct[2]:=CBinToByte(ConfCodeForm.edtActLeft.Text);
ByteCodeAct[3]:=CBinToByte(ConfCodeForm.edtActRight.Text);
ByteCodeAct[4]:=CBinToByte(ConfCodeForm.edtCodeReset.Text);
//保存镜头控制指令集
ByteCodeMir[0]:=CBinToByte(ConfCodeForm.edtMir0.Text);
ByteCodeMir[1]:=CBinToByte(ConfCodeForm.edtMir1.Text);
ByteCodeMir[2]:=CBinToByte(ConfCodeForm.edtMir2.Text);
ByteCodeMir[3]:=CBinToByte(ConfCodeForm.edtMir3.Text);
ByteCodeMir[4]:=CBinToByte(ConfCodeForm.edtMir4.Text);
ByteCodeMir[5]:=CBinToByte(ConfCodeForm.edtMir5.Text);
//保存状态控制指令集
ByteCodeStatus[0]:=CBinToByte(ConfCodeForm.edtCodeLight.Text );
ByteCodeStatus[1]:=CBinToByte(ConfCodeForm.edtCodeBrush.Text );
ByteCodeStatus[2]:=CBinToByte(ConfCodeForm.edtCodeAuto.Text );
end;
finally
//
释放该窗体
ConfCodeForm.Free;
ConfCodeForm:=nil;
end;
end;
//*******************************************
//功能:用户点击“推出系统”按钮退出当前程序
//*******************************************
procedure TMainForm.btExitClick(Sender: TObject);
begin
Application.Terminate;
end;
//*******************************************
//功能:在程序中实现系统的重起,在首次装载WinIo后调用
//*******************************************
procedure TMainForm.SystemReboot;
var
dwVersion : dword;
hProcess : HWND;
hToken:thandle;
pri,Prev : TTokenPrivileges;
i : dword;
str : string;
begin
dwVersion := GetVersion; //获取当前操作系统的版本信息
if (dwVersion < $80000000) then //Run on WinNT
begin
//获取当前进程的句柄
hProcess := OpenProcess(PROCESS_QUERY_INFORMATION, False,GetCurrentProcessId);
if (hProcess <> NULL) then
begin
if (OpenProcessToken(hProcess, (TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY), hToken)) then
begin
//设置TTokenPrivileges变量
pri.PrivilegeCount := 1;
str :='SeShutdownPrivilege';
if not LookupPrivilegeValue(nil,pchar(str),pri.Privileges[0].Luid) then
showmessage('failed');
Pri.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
//使当前进程获取关闭系统的安全级别
if not AdjustTokenPrivileges(hToken, FALSE, Pri, SizeOf(Pri),Prev, i) then
ShowMessage('first-->'+inttostr(GetLastError));
end
else
ShowMessage('twice-->'+inttostr(GetLastError));
end
else
ShowMessage('thirth-->'+inttostr(GetLastError));
end;
if (not ExitWindowsEx(EWX_REBOOT, 0)) then
ShowMessage('fourth-->'+inttostr(GetLastError));
end;
//*******************************************
//功能:“变焦”的“+”按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.btMir0MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
WriteToPort(ByteCodeMir[0]);
end;
//*******************************************
//功能:相应相关按钮的OnMouseUp事件
// 底层发送复位的指令
//*******************************************
procedure TMainForm.btMir0MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
WriteToPort(ByteCodeAct[4]);
end;
//*******************************************
//功能:“变焦”的“-”按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.btMir1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
WriteToPort(ByteCodeMir[1]);
end;
//*******************************************
//功能:“光圈”的“+”按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.btMir4MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
WriteToPort(ByteCodeMir[4]);
end;
//*******************************************
//功能:“变倍”的“-”按钮按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.btMir3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
WriteToPort(ByteCodeMir[3]);
end;
//*******************************************
//功能:“光圈”的“-”按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.btMir5MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
WriteToPort(ByteCodeMir[5]);
end;
//*******************************************
//功能:“变倍”的“+”按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.btMir2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
WriteToPort(ByteCodeMir[2]);
end;
//*******************************************
//功能:向上动作按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.bbtnUpMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
begin
if (ByteStatus[curChoose,0]=1) then
pnlAutoActClick(pnlAutoAct);
end;
WriteToPort(ByteCodeAct[0]);
end;
//*******************************************
//功能:向下动作按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.bbtnDownMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
begin
if (ByteStatus[curChoose,0]=1) then
pnlAutoActClick(pnlAutoAct);
end;
WriteToPort(ByteCodeAct[1]);
end;
//*******************************************
//功能:向左动作按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.bbtnLeftMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
begin
if (ByteStatus[curChoose,0]=1) then
pnlAutoActClick(pnlAutoAct);
end;
WriteToPort(ByteCodeAct[2]);
end;
//*******************************************
//功能:向右动作按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.bbtnRightMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
begin
if (ByteStatus[curChoose,0]=1) then
pnlAutoActClick(pnlAutoAct);
end;
WriteToPort(ByteCodeAct[3]);
end;
//*******************************************
//功能:向左下动作按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.bbtnLeftDownMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
begin
if (ByteStatus[curChoose,0]=1) then
pnlAutoActClick(pnlAutoAct);
end;
WriteToPort(ByteCodeAct[1]);
WriteToPort(ByteCodeAct[2]);
end;
//*******************************************
//功能:向右下动作按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.bbtnRightDownMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
begin
if (ByteStatus[curChoose,0]=1) then
pnlAutoActClick(pnlAutoAct);
end;
WriteToPort(ByteCodeAct[1]);
WriteToPort(ByteCodeAct[3]);
end;
//*******************************************
//功能:向左上动作按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.bbtnLeftUpMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
begin
if (ByteStatus[curChoose,0]=1) then
pnlAutoActClick(pnlAutoAct);
end;
WriteToPort(ByteCodeAct[0]);
WriteToPort(ByteCodeAct[2]);
end;
//*******************************************
//功能:向右上动作按钮OnMouseDown事件的响应代码
// 底层发送相应的指令
//*******************************************
procedure TMainForm.bbtnRightUpMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (curChoose>=1) and (curChoose<=32) then
begin
if (ByteStatus[curChoose,0]=1) then
pnlAutoActClick(pnlAutoAct);
end;
WriteToPort(ByteCodeAct[0]);
WriteToPort(ByteCodeAct[3]);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -