📄 harmware.pas
字号:
unit HarmWare;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BaseFrm, TFlatSpeedButtonUnit, ExtCtrls, TFlatPanelUnit, SPComm,
cpEventRecord, cpEventProgram, cpBurthCurve645, cpGerenralWrite, cpComm,
cpDL645, StdCtrls, TFlatComboBoxUnit, ComCtrls, TFlatCheckBoxUnit,
TFlatEditUnit, cpCheckEdit, TFlatGroupBoxUnit,Math;
const WM_STARTREAD=WM_USER+100;
const WM_STOPREAD=WM_USER+101;
const Zero = '0-9次';
const First = '10-19次';
const Second = '20-29次';
const Third = '30-39次';
const Fourth = '40-49次';
const Lines = 30;
//const ModelPass = '000000000000';//'9A5E16D23F85';
//
type
PSingle = ^Single;
type
THarmForm = class(TBaseForm)
procedure CommReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
procedure FEB_ReadClick(Sender: TObject);
procedure SelectAll_CB0Click(Sender: TObject);
procedure TV_BreadPosClick(Sender: TObject);
procedure TV_EventClick(Sender: TObject);
procedure FSB_StopClick(Sender: TObject);
procedure FSB_StopMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FlatPanel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FEB_WriteClick(Sender: TObject);
procedure FCB_SunSelectAllClick(Sender: TObject);
procedure CB_Byte3Change(Sender: TObject);
procedure FlatCheckBox1Click(Sender: TObject);
procedure TV_BreadPosChange(Sender: TObject; Node: TTreeNode);
procedure TV_EventChange(Sender: TObject; Node: TTreeNode);
procedure RichEditDblClick(Sender: TObject);
private
FMarkCode :string;
RecieveStr:string;
FEventRecord : TEventRecord ;
FBurThData : TBurthenRecord;
FReadFlag: boolean;
procedure WMStartReadProc(var Mas:TMessage);Message WM_STARTREAD;
procedure WMStopReadProc(var Mas:TMessage);Message WM_STOPREAD;
procedure SendFrame(SendStr :string);
procedure ShowBurthenData();
Function GetBurthenMode2(): string;
// Function TwoPower()
{ Private declarations }
public
{ Public declarations }
DataString :string;
AppMessage :string;
end;
Function HexToFloat(HexStr : string):single;
var
HarmForm: THarmForm;
implementation
//-----------------------------------------------------------------------------------
{$R *.dfm}
procedure THarmForm.WMStopReadProc(var Mas:TMessage);
begin
FSB_Stop.Enabled := false;
FEB_Read.Enabled := true;
if((PageIndex=0) or (PageIndex=2)or(PageIndex=8)) then
FEB_Write.Enabled := true ;
Screen.Cursor := crDefault;
Comm.StopComm;
end;
//-----------------------------------------------------------------------------------
procedure THarmForm.WMStartReadProc(var Mas:TMessage);
var
i,j:byte;
low,high : string;
Third,Fourth : string;
SendStr :string;
MarkCode : string;
tmp : integer;
begin
Screen.Cursor := crHourGlass;
case Mas.WParam of
0:begin //上下限值
high := 'C4';
if Mas.LParam>CountVale then
PostMessage(Handle,WM_STOPREAD,0,0)
else
if CE_Valve[Mas.LParam].CheckBox.Checked then
begin
ControlIndex := Mas.LParam;
low := IntToHex($20+Mas.LParam-1,2);
if FReadFlag then //读数据
begin
shqDl645.MarkCode := high+low;
shqDl645.Datalen := CE_Valve[Mas.LParam].Tag;
shqDl645.DecimalDigit := 0;
SendStr:=shqdl645.OutPutStr;
end
else begin //写数据
cpGeneralWrite.PassWord := PassWord2;
cpGeneralWrite.PassPope := '01';
cpGeneralWrite.MarkCode := high+low;
cpGeneralWrite.DataLen := CE_Valve[Mas.LParam].Tag;
cpGeneralWrite.SetData := Trim(CE_Valve[Mas.LParam].Text);
SendStr:=cpGeneralWrite.OutPutStr;
end;
sendframe(SendStr);
end
else begin
ControlIndex := ControlIndex+1;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
end;
end;
1:begin //电能量
high := '90';
if Mas.LParam>CountElect then
PostMessage(Handle,WM_STOPREAD,0,0)
else
if CE_Electry[Mas.LParam].CheckBox.Checked then
begin
ControlIndex := Mas.LParam;
Third := IntToHex(($8+(ControlIndex-1) div 4),1);
Fourth := IntToHex(($0+(ControlIndex-1) mod 4),1);
low := Third+Fourth;
shqDl645.MarkCode := high+low;
shqDl645.Datalen := 4;//TabSheet_Elect.Tag;
shqDl645.DecimalDigit := 2;
SendStr:=shqdl645.OutPutStr;
sendframe(SendStr);
end
else
begin
ControlIndex := ControlIndex+1;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
end;
end;
2:begin //迟续时间
high := 'C4';
if Mas.LParam>CountDelay then
PostMessage(Handle,WM_STOPREAD,0,0)
else
if CE_DelayTime[Mas.LParam].CheckBox.Checked then
begin
ControlIndex := Mas.LParam;
low := IntToHex($40+Mas.LParam-1,2);
if FReadFlag then //读数据
begin
shqDl645.MarkCode := high+low;
shqDl645.Datalen := 2;
shqDl645.DecimalDigit := 0;
SendStr:=shqdl645.OutPutStr;
end
else begin //写数据
cpGeneralWrite.PassWord := PassWord2;
cpGeneralWrite.PassPope := '01';
cpGeneralWrite.MarkCode := high+low;
cpGeneralWrite.SetData :=Trim(CE_DelayTime[Mas.LParam].Text);
cpGeneralWrite.DataLen := 2;
SendStr:=cpGeneralWrite.OutPutStr;
end;
sendframe(SendStr);
end
else begin
ControlIndex := ControlIndex+1;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
end;
end;
3:begin //电流电压畸变率
high := 'B6';
if Mas.LParam>CountVoltCurr then
PostMessage(Handle,WM_STOPREAD,0,0)
else
if CE_VolCurr[Mas.LParam].CheckBox.Checked then
begin
ControlIndex := Mas.LParam;
Third := IntToHex(($7+(ControlIndex-1) div 3),1);
Fourth := IntToHex(($0+(ControlIndex-1) mod 3),1);
low := Third+Fourth;
shqDl645.MarkCode := high+low;
shqDl645.Datalen := 2;
if (ControlIndex<7) then
shqDl645.DecimalDigit := 2
else
shqDl645.DecimalDigit := 1;
SendStr:=shqdl645.OutPutStr;
sendframe(SendStr);
end
else
begin
ControlIndex := ControlIndex+1;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
end;
end;
4:begin //幅值相位
if(Mas.LParam>1) then
PostMessage(Handle,WM_STOPREAD,0,0)
else begin
shqDl645.MarkCode := FMarkCode ;
shqDl645.Datalen := 4;
SendStr:=shqdl645.OutPutStr;
sendframe(SendStr);
end;
end;
5:begin //断相记录
if Mas.LParam>CountBreak then
PostMessage(Handle,WM_STOPREAD,0,0)
else
if CE_Break[Mas.LParam].CheckBox.Checked then
begin
High := 'B7';
ControlIndex := Mas.LParam;
Third := IntToHex(($1+(ControlIndex-1) div 4),1);
Fourth := IntToHex(($0+(ControlIndex-1) mod 4),1);
low := Third+Fourth;
shqDl645.MarkCode := high+low;
shqDl645.Datalen := CE_Break[Mas.LParam].Tag;
shqDl645.DecimalDigit := 0;
SendStr:=shqDl645.OutPutStr;
sendframe(SendStr);
end
else
begin
ControlIndex := ControlIndex+1;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
end;
end;
6:begin //事件记录
if Mas.LParam>CountEvent then
PostMessage(Handle,WM_STOPREAD,0,0)
else
if CE_EventTime[Mas.LParam].CheckBox.Checked then
begin
ControlIndex := Mas.LParam;
MarkCode := IntToHex(StrToInt('$'+FMarkCode)+ControlIndex-1,4);
if(FMarkCode='E000') then
begin
cpEventProgram.Datalen := TV_Event.Tag;
cpEventProgram.MarkCode := MarkCode;
cpEventProgram.FieldLen := '1,1';
cpEventProgram.FieldDecimal := '0,0';
SendStr:= cpEventProgram.OutPutStr;
end
else begin
cpEventRecord.Datalen := TV_Event.Tag;
cpEventRecord.FieldLen :='4';
cpEventRecord.FieldDecimal :='0';
cpEventRecord.MarkCode := MarkCode;
SendStr:=cpEventRecord.OutPutStr;
end;
sendframe(SendStr);
end
else
begin
ControlIndex := ControlIndex+1;
PostMessage(Handle,WM_STARTREAD,PageIndex,ControlIndex);
end;
end;
7:begin //负荷曲线
if(Mas.LParam>1) then
begin
PostMessage(Handle,WM_STOPREAD,0,0);
exit;
end;
i:= RG_Select.ItemIndex;
MarkCode := IntToHex($D110+i,4);
BurthCurve645.Block := 1;
BurthCurve645.MarkCode := MarkCode;
BurthCurve645.TimePoint :='';
if(i=0) then
BurthCurve645.TimePoint := Trim(FE_Time.Text);
SendStr:=BurthCurve645.OutPutStr;
sendframe(SendStr);
end;
8:begin //其它参数
if Mas.LParam>CountOther then
PostMessage(Handle,WM_STOPREAD,0,0)
else if CE_Others[Mas.LParam].CheckBox.Checked then
begin
ControlIndex := Mas.LParam;
shqDl645.Datalen := 2;
cpGeneralWrite.DataLen := 2;
if ControlIndex<6 then
MarkCode := IntToHex($C450+ControlIndex-1,4);
case ControlIndex of
1: begin
Third := Trim(ChEdit_RepairAG.Text)+Trim(ChEdit_RepairAR.Text)
+Trim(ChEdit_RepairAB.Text)+Trim(ChEdit_RepairAX.Text);
shqDl645.Datalen := 4;
cpGeneralWrite.DataLen := 16;
end;
2: begin
Third := Trim(ChEdit_RepairBG.Text)+Trim(ChEdit_RepairBR.Text)
+Trim(ChEdit_RepairBB.Text)+Trim(ChEdit_RepairBX.Text);
shqDl645.Datalen := 4;
cpGeneralWrite.DataLen := 16;
end;
3: begin
Third := Trim(ChEdit_RepairCG.Text)+Trim(ChEdit_RepairCR.Text)
+Trim(ChEdit_RepairCB.Text)+Trim(ChEdit_RepairCX.Text);
shqDl645.Datalen := 4;
cpGeneralWrite.DataLen := 16;
end;
4: begin
Third := Trim(CE_Others[Mas.LParam].Text);
shqDl645.Datalen := 4;
cpGeneralWrite.DataLen := 16;
end;
5: begin
Third := Trim(CE_Others[Mas.LParam].Text);
shqDl645.Datalen := 1;
cpGeneralWrite.DataLen := 1;
end;
6..8:begin
Third := Trim(CE_Others[Mas.LParam].Text);
MarkCode := IntToHex($C520+ControlIndex-6,4);
end;
9:begin
MarkCode := 'C718';
shqDl645.Datalen := 8;
cpGeneralWrite.DataLen := 8;
Third :=Trim(ChEdit_DSP.Text);
if (Third='') then
begin
for i:=1 to 4 do
if FCB_MeterMode[i].ItemIndex<0 then
FCB_MeterMode[i].ItemIndex:=0;
Third := IntToHex((FCB_MeterMode[1].ItemIndex+FCB_MeterMode[2].ItemIndex*2
+FCB_MeterMode[3].ItemIndex*4 +FCB_MeterMode[4].ItemIndex*8),2);
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -