📄 sendcommand.pas
字号:
begin
i:=StrToInt(tbStandardG['ExtensionID']);
if (i>=0) and (i<=(MaxExtensionCount-1)) then
StandardG[i].Value:=tbStandardG['Value'];
tbStandardG.Next;
end;
tbStandardG.Close;
end;
{高度初始化}
with dmMainDB.tbOriginData do
begin
Last;
MoveBy(1-StateInfo.MaxExtensionCount);
for i:=0 to StateInfo.MaxExtensionCount-1 do
begin
AllExtension[i].Height:=FieldbyName('Height').AsInteger;
Next;
AllExtension[i].Status:=ssNormal;
end;
end;
InItializeCheck();
//TimerSample.Enabled:=True;
TimerAutoCountrol.Enabled:=True;
StartSampling(2);
end;
procedure TfrmSendCommand.ListBoxProjectClick(Sender: TObject);
begin
LabelProject.Caption:=ListBoxProject.Items.Strings[ListBoxProject.ItemIndex];
dmMainDB.ViewProjectID.Locate('ACode',GetID(ListBoxProject.Items.Strings[ListBoxProject.ItemIndex]),[loCaseInsensitive]);
ListBoxHourse.Items.Clear;
with dmMainDB.ViewPH do
begin
First;
While Not Eof do
begin
ListBoxHourse.Items.Append(FieldByName('HourseIDLookup').AsString+' ['+FieldByName('HourseID').AsString+']');
Next;
end;
end;
LabelHourse.Caption:='';
end;
procedure TfrmSendCommand.ListBoxHourseClick(Sender: TObject);
begin
LabelHourse.Caption:=ListBoxHourse.Items.Strings[ListBoxHourse.ItemIndex];
end;
procedure TfrmSendCommand.ActionListPRestrictUpdate(Action: TBasicAction; ///???
var Handled: Boolean);
begin
ActionOK.Enabled:=(LabelProject.Caption<>'') and (LabelHourse.Caption<>'');
ActionClearAll.Enabled:=(ListBoxSelect.Items.Count>=1);
ActionClearSelect.Enabled:=(ListBoxSelect.SelCount>=1);
ActionRight.Enabled:=(TreeViewSelect.Selected<>nil);
if RadioGroupSelect.ItemIndex=0 then
begin
ActionSendCommand.Enabled:=GetCondition1();
ActionDownLoad.Enabled:=GetCondition2();
ActionReverse.Enabled:=ActionDownLoad.Enabled;
end
else
begin
ActionSendCommand.Enabled:=GetCondition1();
ActionDownLoad.Enabled:=GetCondition2();
ActionReverse.Enabled:=ActionDownLoad.Enabled;
end;
end;
Function TfrmSendCommand.GetCondition1():Boolean;
begin
Result:=((ComPort.Connected) and ((ListBoxSelect.Items.Count>=1) or (ListBoxSelect.SelCount>=1))
and (StateInfo.SystemState=ssNormal)
and (StateInfo.Height<=StateInfo.MaxHeight)
and (StateInfo.Height>=1));
end;
Function TfrmSendCommand.GetCondition2():Boolean;
begin
Result:=((ComPort.Connected) and ((ListBoxSelect.Items.Count>=1) or (ListBoxSelect.SelCount>=1))
and (StateInfo.SystemState=ssNormal));
end;
procedure TfrmSendCommand.ActionDownLoadExecute(Sender: TObject);
var
i: Integer;
StrExtensionID,StrID:string;
NotPresent:Boolean;
begin
NotPresent:=False;
if CheckBoxIQ.Checked then
begin
for i:=0 to StateInfo.MaxExtensionCount-1 do
begin
if AllExtension[i].CommErr then NotPresent:=True;
break;
end;
end;
if Notpresent then
begin
ShowMessage('有分机不在位,无法执行操作,请检查分机后再试!');
Exit;
end;
if IsPasswordCorrect(AppInfo,UserInfo) then
begin
try
PauseSampling;
try
InitializeFlag;
CountDownload:=0;
DisplayState(6);
StartProgress(DownloadOverflow);
if RadioGroupSelect.ItemIndex=0 then
begin
StrExtensionID:='';
for i:=0 to ListBoxSelect.Items.Count-1 do
begin
StrID:=GetID(ListBoxSelect.Items.Strings[i]);
StrExtensionID:=StrExtensionID+StrID;
AllExtension[StrToInt(StrID)].Status:=ssDownLoad;
//SendDownLoadCommand(GetID(ListBoxSelect.Items.Strings[i]));
end;
SendDownLoadCommand(StrExtensionID);
end
else
begin
StrExtensionID:='';
for i:=0 to ListBoxSelect.Items.Count-1 do
begin
if ListBoxSelect.Selected[i] then
begin
StrID:=GetID(ListBoxSelect.Items.Strings[i]);
StrExtensionID:=StrExtensionID+StrID;
AllExtension[StrToInt(StrID)].Status:=ssDownLoad;
//SendDownLoadCommand(GetID(ListBoxSelect.Items.Strings[i]));
end;
end;
SendDownLoadCommand(StrExtensionID);
end;
finally
DisplayInfo('发送卸荷命令','0');
LogInfo.UserName:=UserInfo.UserName;
Loginfo.Operation:=OperationType[7];
Loginfo.DDate:=Date();
Loginfo.DTime:=Time();
Loginfo.Remark:='success';
WriteLog(dmMainDB.qryPublic,LogInfo);
end;
finally
ResumeSampling;
end;
end;
end;
Function TfrmSendCommand.GetSystemFlag():String;
begin
case StateInfo.SystemState of
ssAscPrepare,ssAscend, ssNullAsc:
begin
Result:='↑';
end;
ssDesPrepare,ssDescend,ssNullDes:
begin
Result:='↓';
end;
else
Result:='—'
end;
end;
Function TfrmSendCommand.GetState(iState:TSystemState):String;
begin
case iState of
ssAscPrepare:
begin
Result:='||';
end;
ssAscend:
begin
Result:='↑';
end;
ssNullAsc:
begin
Result:='┏';
end;
ssDesPrepare:
begin
Result:='||';
end;
ssDescend:
begin
Result:='↓';
end;
ssNullDes:
begin
Result:='┛';
end;
ssDownLoad:
begin
Result:='◎';
end;
else
begin
Result:='—'
end;
end;
end;
Procedure TfrmSendCommand.SetStateInfo(i:Integer);
begin
case i of
0:
StateInfo.SystemState:=ssAscPrepare;
1:
StateInfo.SystemState:=ssAscend;
2:
StateInfo.SystemState:=ssNullAsc;
3:
StateInfo.SystemState:=ssDesPrepare;
4:
StateInfo.SystemState:=ssDescend;
5:
StateInfo.SystemState:=ssNullDes;
6:
StateInfo.SystemState:=ssDownLoad;
end;
end;
function TfrmSendCommand.GetCurrentExtensionID():Byte;
var
i:Integer;
begin
if RadioGroupSelect.ItemIndex=0 then
begin
Result:=StrToInt(GetID(ListBoxSelect.Items.Strings[0]));
end
else
begin
for i:=0 to ListBoxSelect.Items.Count-1 do
begin
if ListBoxSelect.Selected[i] then
begin
Result:=StrToInt(GetID(ListBoxSelect.Items.Strings[i]));
Break;
end;
end;
end;
end;
procedure TfrmSendCommand.ActionSendCommandExecute(Sender: TObject);
var
i:Integer;
StrExtensionID:string;
NotPresent:Boolean;
begin
if not GetUserRegister() then
begin
Raise Exception.Create('这是演示版软件,请到销售商那里注册');
end;
NotPresent:=False;
if CheckBoxIQ.Checked then
begin
for i:=0 to StateInfo.MaxExtensionCount-1 do
begin
if AllExtension[i].CommErr then NotPresent:=True;
break;
end;
end;
if (RadioGroupOperation.ItemIndex>=0) and (not NotPresent) then
begin
if IsPasswordCorrect(AppInfo,UserInfo) then
begin
try
SetStateInfo(RadioGroupOperation.ItemIndex);
CurrentExtensionID:=GetCurrentExtensionID();
StartHeight:=Round(AllExtension[CurrentExtensionID].Height);
PauseSampling;
// TimerAutoCountrol.Enabled:=True;
try
SetStateInfo(RadioGroupOperation.ItemIndex);
case RadioGroupOperation.ItemIndex of
0:
begin
DisplayInfo('进行提升准备...','0');
StartProgress(PrepareOverflow);
CountPrepare:=0;
end;
1:
begin
DisplayInfo('直接提升...','0');
StartProgress(StateInfo.Height);
end;
2:
begin
DisplayInfo('吊点上移...','0');
StartProgress(StateInfo.Height);
end;
3:
begin
DisplayInfo('进行下降准备...','0');
StartProgress(PrepareOverflow);
CountPrepare:=0;
end;
4:
begin
DisplayInfo('直接下降...','0');
StartProgress(StateInfo.Height);
end;
5:
begin
DisplayInfo('吊点下移','0');
StartProgress(StateInfo.Height);
end;
end;
InitializeFlag;
if RadioGroupSelect.ItemIndex=0 then
begin
RawCommand.ExtensionID:='';
for i:=0 to ListBoxSelect.Items.Count-1 do
begin
StrExtensionID:=GetID(ListBoxSelect.Items.Strings[i]);
RawCommand.ExtensionID:=RawCommand.ExtensionID+StrExtensionID;
//RawCommand.Data:=FloatToStr(StandardG[StrToInt(RawCommand.ExtensionID)].Value);
case RadioGroupOperation.ItemIndex of
0:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssAscPrepare;
end;
1:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssAscend;
end;
2:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssNullAsc;
end;
3:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssDesPrepare;
end;
4:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssDescend;
end;
5:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssNullDes;
end;
else
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssNormal;
end;
end;
end;
RawCommand.CommandID:=CommandID[RadioGroupOperation.ItemIndex+1];
SendACommand(RawCommand);
end
else
begin
RawCommand.ExtensionID:='';
for i:=0 to ListBoxSelect.Items.Count-1 do
begin
if ListBoxSelect.Selected[i] then
begin
StrExtensionID:=GetID(ListBoxSelect.Items.Strings[i]);
RawCommand.ExtensionID:=RawCommand.ExtensionID+StrExtensionID;
//RawCommand.Data:=FloatToStr(StandardG[StrToInt(RawCommand.ExtensionID)].Value);
case RadioGroupOperation.ItemIndex of
0:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssAscPrepare;
end;
1:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssAscend;
end;
2:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssNullAsc;
end;
3:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssDesPrepare;
end;
4:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssDescend;
end;
5:
begin
AllExtension[StrToInt(StrExtensionID)].Status:=ssNullDes;
end;
else
begin
AllExtension[StrToInt(StrextensionID)].Status:=ssNormal;
end;
end;
end;
end;
RawCommand.CommandID:=CommandID[RadioGroupOperation.ItemIndex+1];
SendACommand(RawCommand);
end;
finally
LogInfo.UserName:=UserInfo.UserName;
Loginfo.Operation:=OperationType[RadioGroupOperation.ItemIndex];
Loginfo.DDate:=Date();
Loginfo.DTime:=Time();
Loginfo.Remark:='success';
WriteLog(dmMainDB.qryPublic,LogInfo);
RadioGroupOperation.ItemIndex:=-1;
end;
finally
ResumeSampling;
end;
end;
end
else
begin
if NotPresent then
ShowMessage('有分机不在位,无法执行操作,请检查分机后再试!')
else
ShowMessage('切记!,每次发布命令前,请选择操作类型');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -