📄 harmware.pas
字号:
10:begin
MarkCode := 'C717';
Third := Trim(ChEdit_MeterMode4.Text);
shqDl645.Datalen := 7;
cpGeneralWrite.DataLen := 7;
end;
11:begin
MarkCode := 'C719';
Third := Trim(ChEdit_HRepair.Text);
shqDl645.Datalen := 7;
cpGeneralWrite.DataLen := 7;
end;
12:begin
MarkCode := 'C71A';
Third := Trim(ChEdit_NRepair.Text);
shqDl645.Datalen := 7;
cpGeneralWrite.DataLen := 7;
end;
13:begin
MarkCode := 'C02B';
shqDl645.Datalen := 6;
cpGeneralWrite.DataLen := 6;
Third :=Trim(ChEdit_BurthMode2.Text);
end; // end of 11: begin
end; //the second case
if FReadFlag then //读数据
begin
shqDl645.MarkCode := MarkCode;
shqDl645.DecimalDigit := 0;
SendStr:=shqdl645.OutPutStr;
end
else begin
cpGeneralWrite.PassWord := PassWord2;
cpGeneralWrite.PassPope := '01';
cpGeneralWrite.MarkCode := MarkCode;
cpGeneralWrite.SetData :=Third;
SendStr:=cpGeneralWrite.OutPutStr;
cpGeneralWrite.SetData :=High;
Fourth:=cpGeneralWrite.OutPutStr;
end;
if ((ControlIndex=9) or (ControlIndex=10)) then
sendframe(SendStr)
else
sendframe(SendStr);
end //if checked
else begin
ControlIndex := ControlIndex+1;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
end;
end; //end of 7: begin
end;//case
end;
//-----------------------------------------------------------------------------------
procedure THarmForm.SendFrame(SendStr :string);
var
i,DataLen:integer;
commflg:boolean;
sbuf:array[1..50] of byte;
begin
if(RichEdit.Count>Lines) then
RichEdit.Clear;
RichEdit.Items.Add('发:'+shqDl645.StrToHex2(SendStr));
DataLen:=Length(SendStr);
for i:=1 to DataLen do
sbuf[i]:=byte(SendStr[i]);
commflg:=true;
Comm.StopComm;
Comm.StartComm;
sleep(50);
for i:=1 to DataLen do
begin
if not Comm.writecommdata(@sbuf[i],1) then
begin
commflg:=false;
exit;
end;
sleep(FWordDelay);
end;
if not commflg then
begin
Application.MessageBox('发送失败 !' ,'系统信息',MB_ICONSTOP);
PostMessage(Handle,WM_STOPREAD,0,0);
exit;
end;
delay(FOrderDelay);
if(RecieveStr='') then
begin
Application.MessageBox('无应答 !' ,'系统信息',MB_ICONSTOP);
PostMessage(Handle,WM_STOPREAD,0,0);
exit;
end;
end;
//-----------------------------------------------------------------------------------
procedure THarmForm.CommReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
i,j,n:integer;
rbuf:array[1..255] of byte;
BreadData : single;
DataList : TStringList;
RecStr ,TmpStr: string;
begin
move(buffer^,rbuf,bufferlength);
RecieveStr:='';
for i:=1 to bufferlength do
begin
TmpStr := inttohex(rbuf[i],2);
RecieveStr:=RecieveStr+ TmpStr;
RecStr := RecStr + TmpStr+ ' ';
end;
if(RichEdit.Count>Lines) then
RichEdit.Clear;
RichEdit.Items.Add('收:'+RecStr);
if not FReadFlag then //写数据
begin
AppMessage := shqdl645.AnalyseData(RecieveStr);
Application.MessageBox(Pchar(AppMessage),'系统信息',MB_ICONINFORMATION);
end
else begin
case PageIndex of
0: begin
AppMessage := shqdl645.AnalyseData(RecieveStr);
CE_Valve[ControlIndex].text := shqdl645.Data;
end;
1: begin
AppMessage := shqdl645.AnalyseData(RecieveStr);
CE_Electry[ControlIndex].text := shqdl645.Data;
end;
2:begin
AppMessage := shqdl645.AnalyseData(RecieveStr);
CE_DelayTime[ControlIndex].text := shqdl645.Data ;
end;
3:begin
AppMessage := shqdl645.AnalyseData(RecieveStr);
CE_VolCurr[ControlIndex].text := shqdl645.Data;
end;
4:begin
AppMessage := shqdl645.AnalyseData(RecieveStr);
DataList:= TStringList.Create;
DataList.CommaText := shqdl645.Data;
for i:=1 to DataList.Count do
begin
TmpStr := DataList.Strings[i-1];
BreadData := HexToFloat(TmpStr);
FE_BreadPos[i].text := FloatToStr(BreadData) ;
end;
end;
5:begin
AppMessage := shqdl645.AnalyseData(RecieveStr);
CE_Break[ControlIndex].text := shqdl645.Data;
end;
6:begin
if(FMarkCode='E000') then
begin
AppMessage := cpEventProgram.AnalyseData(RecieveStr);
FEventRecord:= cpEventProgram.REventData;
end
else begin
AppMessage := cpEventRecord.AnalyseData(RecieveStr);
FEventRecord:= cpEventRecord.REventData;
end;
CE_EventTime[ControlIndex].Text := DateTimeToStr(FEventRecord.CDateTime);
FE_Value1[ControlIndex].Text := FEventRecord.EventData;
end;
7:begin
AppMessage := BurthCurve645.AnalyseData(RecieveStr);
FBurThData:= BurthCurve645.BurthenData;
ShowBurthenData(); //显示负荷曲线数据
end;
8:begin
AppMessage := shqdl645.AnalyseData(RecieveStr);
case ControlIndex of
1:begin
DataList:= TStringList.Create;
DataList.CommaText := shqdl645.Data;
ChEdit_RepairAG.Text := DataList.Strings[0];
ChEdit_RepairAR.Text := DataList.Strings[1];
ChEdit_RepairAB.Text := DataList.Strings[2];
ChEdit_RepairAX.Text := DataList.Strings[3];
end;
2:begin
DataList:= TStringList.Create;
DataList.CommaText := shqdl645.Data;
ChEdit_RepairBG.Text := DataList.Strings[0];
ChEdit_RepairBR.Text := DataList.Strings[1];
ChEdit_RepairBB.Text := DataList.Strings[2];
ChEdit_RepairBX.Text := DataList.Strings[3];
end;
3:begin
DataList:= TStringList.Create;
DataList.CommaText := shqdl645.Data;
ChEdit_RepairCG.Text := DataList.Strings[0];
ChEdit_RepairCR.Text := DataList.Strings[1];
ChEdit_RepairCB.Text := DataList.Strings[2];
ChEdit_RepairCX.Text := DataList.Strings[3];
end;
4..8:CE_Others[ControlIndex].Text := shqdl645.Data;
9:begin
TmpStr := shqdl645.Data;
ChEdit_DSP.Text := TmpStr;
TmpStr := copy(TmpStr,3,2)+copy(TmpStr,1,2);
if(TmpStr<>'') then
begin
j:= StrToInt('$'+TmpStr);
for i:=1 to 4 do
begin
FCB_MeterMode[i].ItemIndex:=j and 1;
j:=j shr 1;
end;
end;
end;
10..12:begin
TmpStr := shqdl645.Data;
// TmpStr := copy(TmpStr,Length(TmpStr)-1,2);
CE_Others[ControlIndex].Text := TmpStr;
end;
13:begin
TmpStr := shqdl645.Data;
for i:=0 to 5 do
begin
try
n := StrToInt('$'+copy(TmpStr,(5-i)*2+1,2));
except
break;
end;
for j:=1 to 8 do
begin
if n and 1=1 then
CB_BurthMode2[i*8+j].Checked := true
else
CB_BurthMode2[i*8+j].Checked := false;
n:=n shr 1;
end;
end;
ChEdit_BurthMode2.Text := TmpStr;
end; //end of 11: begin
end;//end of 8 case
end;
end;//case
end;
ControlIndex := ControlIndex+1;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
// if(AppMessage<>'操作成功') then
// Application.MessageBox(pchar(AppMessage),'系统提示',MB_ICONSTOP);
end;
//-----------------------------------------------------------------------------------
procedure THarmForm.ShowBurthenData();
begin
FE_Time.Text := DateTimeToStr(FBurThData[1].OnDate);
FE_VoltA.Text := FBurThData[1].Buthen1.Volt_A;
FE_VoltB.Text := FBurThData[1].Buthen1.Volt_B;
FE_VoltC.Text := FBurThData[1].Buthen1.Volt_C;
FE_CurrA.Text := FBurThData[1].Buthen1.Curr_A;
FE_CurrB.Text := FBurThData[1].Buthen1.Curr_B;
FE_CurrC.Text := FBurThData[1].Buthen1.Curr_C;
FE_Squence.Text := FBurThData[1].Buthen1.Frequ;
FE_HavePowerZ.Text := FBurThData[1].Buthen2.Have_All;
FE_HavePowerA.Text := FBurThData[1].Buthen2.Have_A;
FE_HavePowerB.Text := FBurThData[1].Buthen2.Have_B;
FE_HavePowerC.Text := FBurThData[1].Buthen2.Have_C;
FE_NoPowerZ.Text := FBurThData[1].Buthen2.Nothing_ALL;
FE_NoPowerA.Text := FBurThData[1].Buthen2.Nothing_A;
FE_NoPowerB.Text := FBurThData[1].Buthen2.Nothing_B;
FE_NoPowerC.Text := FBurThData[1].Buthen2.Nothing_C;
FE_HFlagZ.Text := FBurThData[1].Buthen2.HaveFlag_ALL;
FE_HFlagA.Text := FBurThData[1].Buthen2.HaveFlag_A ;
FE_HFlagB.Text := FBurThData[1].Buthen2.HaveFlag_B ;
FE_HFlagC.Text := FBurThData[1].Buthen2.HaveFlag_C ;
FE_NFlagZ.Text := FBurThData[1].Buthen2.NoFlag_ALL;
FE_NFlagA.Text := FBurThData[1].Buthen2.NoFlag_A ;
FE_NFlagB.Text := FBurThData[1].Buthen2.NoFlag_B ;
FE_NFlagC.Text := FBurThData[1].Buthen2.NoFlag_C ;
FE_FactorZ.Text := FBurThData[1].Buthen3.Power_ALL;
FE_FactorA.Text := FBurThData[1].Buthen3.Power_A ;
FE_FactorB.Text := FBurThData[1].Buthen3.Power_B ;
FE_FactorC.Text := FBurThData[1].Buthen3.Power_C ;
FE_ActHave.Text := FBurThData[1].Buthen4.ActHave;
FE_SenseHave.Text := FBurThData[1].Buthen4.GeistNo;
FE_ReActHave.Text := FBurThData[1].Buthen4.ReactHave;
FE_SenseNo.Text := FBurThData[1].Buthen4.ActNo;
FE_Qurdrant1.Text := FBurThData[1].Buthen5.Quadrant1;
FE_Qurdrant2.Text := FBurThData[1].Buthen5.Quadrant2;
FE_Qurdrant3.Text := FBurThData[1].Buthen5.Quadrant3;
FE_Qurdrant4.Text := FBurThData[1].Buthen5.Quadrant4;
FE_HDemand.Text := FBurThData[1].Buthen6.HaveNeed;
FE_NDemand.Text := FBurThData[1].Buthen6.NoNeed;
FE_HarmInElect.Text := FBurThData[1].Buthen7.HarmInWave;
FE_HarmOutElect.Text := FBurThData[1].Buthen7.HarmOutWave;
FE_BaseInElect.Text := FBurThData[1].Buthen7.BaseInWave;
FE_BaseOutElect.Text := FBurThData[1].Buthen7.BaseOutWave;
//FE_HarmElectABC.Text := FBurThData[1].Buthen8.HarmPower_ABC;
// FE_BaseElectABC.Text := FBurThData[1].Buthen8.BasePower_ABC;
FE_HarmVoltA.Text := FBurThData[1].Buthen8.HarmVolt_A;
FE_HarmVoltB.Text := FBurThData[1].Buthen8.HarmVolt_B;
FE_HarmVoltC.Text := FBurThData[1].Buthen8.HarmVolt_C;
FE_HarmCurrA.Text := FBurThData[1].Buthen8.HarmCurr_A;
FE_HarmCurrB.Text := FBurThData[1].Buthen8.HarmVolt_B;
FE_HarmCurrC.Text := FBurThData[1].Buthen8.HarmCurr_C;
FE_VoltATHD.Text := FBurThData[1].Buthen8.HarmVolt_ATHD;
FE_VoltBTHD.Text := FBurThData[1].Buthen8.HarmVolt_BTHD;
FE_VoltCTHD.Text := FBurThData[1].Buthen8.HarmVolt_CTHD;
FE_CurrATHD.Text := FBurThData[1].Buthen8.HarmCurr_ATHD;
FE_CurrBTHD.Text := FBurThData[1].Buthen8.HarmCurr_BTHD;
FE_CurrCTHD.Text := FBurThData[1].Buthen8.HarmCurr_CTHD;
FE_HarmDegree.Text := FBurThData[1].Buthen9.HarmWaveTime;
FE_VoltBread.Text := FBurThData[1].Buthen9.Volt_Breadth;
FE_VoltPos.Text := FBurThData[1].Buthen9.Volt_XiangWei;
FE_CurrBread.Text := FBurThData[1].Buthen9.Curr_Breadth;
FE_CurrPos.Text := FBurThData[1].Buthen9.Curr_XiangWei;
end;
//-----------------------------------------------------------------------------------
procedure THarmForm.FEB_ReadClick(Sender: TObject);
begin
FSB_Stop.Enabled := true;
FEB_Read.Enabled := false;
FEB_write.Enabled := false;
ControlIndex:=1;
FReadFlag := true;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
end;
//-----------------------------------------------------------------------------------
procedure THarmForm.SelectAll_CB0Click(Sender: TObject);
var
i:byte;
CE_SelectAll: array[1..21] of TCheckedEdit;
begin
case PageIndex of
0:begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -