📄 com_send.pas
字号:
254: begin
statestype[channel+1].Canvas.draw(0,0,green);
statetext[channel+1].Caption:='超时';
k25[channel] := 254;
end;
255: begin
statestype[channel+1].Canvas.draw(0,0,orange);
statetext[channel+1].Caption:='未知';
k25[channel] := 255;
end;
else begin
statestype[channel+1].Canvas.draw(0,0,red);
statetext[channel+1].Caption:='未定义状态';
k25[channel] := 256;
end;
end;
LeftShiftRQueue(16);
}
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if comm1.PortOpen = true then
comm1.PortOpen := false;
application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
lalen.Caption := '';
edcount.Text := '';
edcount_1.Text := '';
edcount_2.Text := '';
edcount_3.Text := '';
edcount_4.Text := '';
edset_1.Text := '';
edset_2.Text := '';
edkey.Text := '';
edangle.Text := '';
check_channel[1] := cb1;
check_channel[2] := cb2;
check_channel[3] := cb3;
check_channel[4] := cb4;
check_channel[5] := cb5;
check_channel[6] := cb6;
check_channel[7] := cb7;
check_channel[8] := cb8;
check_channel_16[1] := cb9;
check_channel_16[2] := cb10;
check_channel_16[3] := cb11;
check_channel_16[4] := cb12;
check_channel_16[5] := cb13;
check_channel_16[6] := cb14;
check_channel_16[7] := cb15;
check_channel_16[8] := cb16;
check_channel_16[9] := cb17;
check_channel_16[10] := cb18;
check_channel_16[11] := cb19;
check_channel_16[12] := cb20;
check_channel_16[13] := cb21;
check_channel_16[14] := cb22;
check_channel_16[15] := cb23;
check_channel_16[16] := cb24;
comm1.PortOpen := false;
ZjCommFun := TCommonFunction.create;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i:integer;
ComStr:String;
hNewCommFile: THandle;
j : integer;
k : integer;
get_flag : boolean;
SCommandInfo,SErrorInfo : string;
power_limit1,power_limit2,power_limit3,power_limit4,power_limit5,power_limit6,power_limit7,power_limit8 : real;
differ1,differ2,differ3,differ4,differ5, differ6,differ7,differ8 : real;
angle : integer;
hinder : real;
begin
allfalse;
memo1.Clear;
get_flag := ZjCommFun.get_single_board_power_and_other(cocomm.Text, strtoint(edhouse.Text), strtoint(edadress.Text),
power_limit1,power_limit2,power_limit3,power_limit4,power_limit5,power_limit6,power_limit7,power_limit8 ,
differ1,differ2,differ3,differ4,differ5, differ6,differ7,differ8 ,
angle ,
hinder ,
SCommandInfo,SErrorInfo);
if get_flag = true then
begin
memo1.Lines.add('功限1: ' + floattostr(power_limit1) + ' 差1: ' + floattostr(differ1));
memo1.Lines.Add(' ');
memo1.Lines.add('功限2: ' + floattostr(power_limit2) + ' 差2: ' + floattostr(differ2));
memo1.Lines.Add(' ');
memo1.Lines.add('功限3: ' + floattostr(power_limit3) + ' 差3: ' + floattostr(differ3));
memo1.Lines.Add(' ');
memo1.Lines.add('功限4: ' + floattostr(power_limit4) + ' 差4: ' + floattostr(differ4));
memo1.Lines.Add(' ');
memo1.Lines.add('功限5: ' + floattostr(power_limit5) + ' 差5: ' + floattostr(differ5));
memo1.Lines.Add(' ');
memo1.Lines.add('功限6: ' + floattostr(power_limit6) + ' 差6: ' + floattostr(differ6));
memo1.Lines.Add(' ');
memo1.Lines.add('功限7: ' + floattostr(power_limit7) + ' 差7: ' + floattostr(differ7));
memo1.Lines.Add(' ');
memo1.Lines.add('功限8: ' + floattostr(power_limit8) + ' 差8: ' + floattostr(differ8));
memo1.Lines.Add(' ');
memo1.Lines.add('阻性角度: ' + inttostr(angle));
memo1.Lines.Add(' ');
memo1.Lines.add('阻性功限: ' + floattostr(hinder));
memo1.Lines.Add(' ');
memo2.Lines.Add('OK');
end
else memo2.Lines.Add(SErrorInfo);
alltrue;
{
clear;
try // by hs
if comm1.PortOpen = true then
comm1.PortOpen := false;
if coComm.text='com1' then
begin
comm1.CommPort:=pnCOM1;
end;
if coComm.text='com2' then
begin
comm1.CommPort:=pnCOM2;
end;
if coComm.text='com3' then
begin
comm1.CommPort:=pnCOM3;
end;
if coComm.text='com4' then
begin
comm1.CommPort:=pnCOM4;
end;
if coComm.text='com5' then
begin
comm1.CommPort:=pnCOM5;
end;
ComStr:=cocomm.Text;
hNewCommFile := CreateFile( PChar(ComStr),
GENERIC_READ or GENERIC_WRITE,
0, {not shared}
// nil, {no security ??}
// OPEN_EXISTING,
// 0,{No Overlapped}
// 0 {template} );
{
if hNewCommFile = INVALID_HANDLE_VALUE then
begin
showmessage( '此端口不存在或正在为其他程序占用!' ) ;
exit;
end
else
begin
PurgeComm( hNewCommFile, PURGE_TXABORT or PURGE_RXABORT or PURGE_TXCLEAR or PURGE_RXCLEAR ) ; // by hs
CloseHandle( hNewCommFile );
hNewCommFile := 0 ;
// comm1.portopen:=false;
end;
sendbuf[0] := strtoint(edhouse.Text);
sendbuf[1] := strtoint(edadress.Text);
sendbuf[2] := $22;
sendbuf[3] := $00;
sendbuf[4] := $00;
sendbuf[5] := $00;
checksum;
if comm1.PortOpen=false then
comm1.PortOpen:=true;
outputdata ;
info_type :=$22;
except // by hs
;
end;
}
end;
procedure TForm1.Button28Click(Sender: TObject);
var
i:integer;
ComStr:String;
hNewCommFile: THandle;
j : integer;
k : integer;
count_s : string;
count : integer;
hei : string;
low : string;
get_flag : boolean;
SCommandInfo,SErrorInfo : string;
begin
allfalse;
if trim(edchannel_11 .Text) = '' then
begin
showmessage('请输入通道号!!');
edchannel_1.SetFocus;
alltrue;
exit;
end;
get_flag := ZjCommFun.set_enabled_true(cocomm.Text,strtoint(edadress.Text),
strtoint(edchannel_11.text), SCommandInfo,SErrorInfo) ;
if get_flag = true then memo2.Lines.Add('OK')
else memo2.Lines.Add(SErrorInfo);
alltrue;
end;
procedure TForm1.Button6Click(Sender: TObject);
var
i:integer;
ComStr:String;
hNewCommFile: THandle;
j : integer;
k : integer;
count_s : string;
count : integer;
hei : string;
low : string;
get_flag : boolean;
SCommandInfo,SErrorInfo : string;
begin
allfalse;
if trim(edchannel_1 .Text) = '' then
begin
showmessage('请输入通道号!!');
edchannel_1.SetFocus;
alltrue;
exit;
end;
if trim(edset_1 .Text) = '' then
begin
showmessage('请单用户功率限制!!');
edset_1.SetFocus;
alltrue;
exit;
end;
get_flag := ZjCommFun.setroom_powerlimit(cocomm.Text, strtoint(edhouse.Text), strtofloat(edset_1.Text),
strtoint(edadress.Text),strtoint(edchannel_1.text), SCommandInfo,SErrorInfo) ;
if get_flag = true then memo2.Lines.Add('OK')
else memo2.Lines.Add(SErrorInfo);
alltrue;
{
clear;
try // by hs
if comm1.PortOpen = true then
comm1.PortOpen := false;
if coComm.text='com1' then
begin
comm1.CommPort:=pnCOM1;
end;
if coComm.text='com2' then
begin
comm1.CommPort:=pnCOM2;
end;
if coComm.text='com3' then
begin
comm1.CommPort:=pnCOM3;
end;
if coComm.text='com4' then
begin
comm1.CommPort:=pnCOM4;
end;
if coComm.text='com5' then
begin
comm1.CommPort:=pnCOM5;
end;
ComStr:=cocomm.Text;
hNewCommFile := CreateFile( PChar(ComStr),
GENERIC_READ or GENERIC_WRITE,
0, {not shared}
// nil, {no security ??}
// OPEN_EXISTING,
// 0,{No Overlapped}
// 0 {template} );
{
if hNewCommFile = INVALID_HANDLE_VALUE then
begin
showmessage( '此端口不存在或正在为其他程序占用!' ) ;
exit;
end
else
begin
PurgeComm( hNewCommFile, PURGE_TXABORT or PURGE_RXABORT or PURGE_TXCLEAR or PURGE_RXCLEAR ) ; // by hs
CloseHandle( hNewCommFile );
hNewCommFile := 0 ;
// comm1.portopen:=false;
end;
sendbuf[0] := strtoint(edhouse.Text);
sendbuf[1] := strtoint(edadress.Text);
sendbuf[2] := $27;
sendbuf[3] := strtoint(edchannel_1.Text);
sendbuf[4] := strtoint(edset_1.Text);
sendbuf[5] := $00;
checksum;
if comm1.PortOpen=false then
comm1.PortOpen:=true;
outputdata;
info_type :=$27;
except // by hs
;
end;
}
end;
procedure TForm1.Button7Click(Sender: TObject);
var
i:integer;
ComStr:String;
hNewCommFile: THandle;
j : integer;
k : integer;
count_s : string;
count : integer;
hei : string;
low : string;
get_flag : boolean;
SCommandInfo,SErrorInfo : string;
begin
allfalse;
if trim(edset_2.Text) = '' then
begin
showmessage('请输入功率!!');
edset_2.SetFocus;
alltrue;
exit;
end;
get_flag := ZjCommFun.setsingle_board_powerlimit(cocomm.Text, strtoint(edhouse.Text), strtofloat(edset_2.Text),
strtoint(edadress.Text), SCommandInfo,SErrorInfo) ;
if get_flag = true then memo2.Lines.Add('OK')
else memo2.Lines.Add(SErrorInfo);
alltrue;
{
clear;
try // by hs
if comm1.PortOpen = true then
comm1.PortOpen := false;
if coComm.text='com1' then
begin
comm1.CommPort:=pnCOM1;
end;
if coComm.text='com2' then
begin
comm1.CommPort:=pnCOM2;
end;
if coComm.text='com3' then
begin
comm1.CommPort:=pnCOM3;
end;
if coComm.text='com4' then
begin
comm1.CommPort:=pnCOM4;
end;
if coComm.text='com5' then
begin
comm1.CommPort:=pnCOM5;
end;
ComStr:=cocomm.Text;
hNewCommFile := CreateFile( PChar(ComStr),
GENERIC_READ or GENERIC_WRITE,
0, {not shared}
// nil, {no security ??}
// OPEN_EXISTING,
// 0,{No Overlapped}
// 0 {template} );
{
if hNewCommFile = INVALID_HANDLE_VALUE then
begin
showmessage( '此端口不存在或正在为其他程序占用!' ) ;
exit;
end
else
begin
PurgeComm( hNewCommFile, PURGE_TXABORT or PURGE_RXABORT or PURGE_TXCLEAR or PURGE_RXCLEAR ) ; // by hs
CloseHandle( hNewCommFile );
hNewCommFile := 0 ;
// comm1.portopen:=false;
end;
sendbuf[0] := strtoint(edhouse.Text);
sendbuf[1] := strtoint(edadress.Text);
sendbuf[2] := $28;
sendbuf[3] := $00;
sendbuf[4] := strtoint(edset_1.Text);
sendbuf[5] := $00;
checksum;
if comm1.PortOpen=false then
comm1.PortOpen:=true;
outputdata;
info_type :=$28;
except // by hs
;
end;
}
end;
procedure TForm1.Button8Click(Sender: TObject);
var
i:integer;
ComStr:String;
hNewCommFile: THandle;
j : integer;
k : integer;
count_s : string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -