HP\李良庭
2025-07-08 868daf94f29ce1ffdd799a68c07bb668cd373bcd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{------------------------------------------------------------------------------}
{µ¥ÔªÃû³Æ£ºverifyThread.pas                                                    }
{Ä£¿éÃû³Æ£º¼ÆËãУ׼Ï̠߳                                                       }
{Ä£¿é˵Ã÷£ºÏ̴߳´½¨ºó×Ô¶¯ÔËÐУ¬Íê³ÉÒ»×éУ׼¼ìÑ飬¹²Îå×é                        }
{½¨Á¢ÈÕÆÚ£º2023-11-01                                                          }
{ÐÞ¸ÄÐ޸ģº2023-11-01                                                          }
{°æÈ¨ËùÓУºÀîÁ¼Í¥ liangtingli@outlook.com                                      }
{------------------------------------------------------------------------------}
unit verifyThread;
 
interface
 
uses
  Windows, Classes, SysUtils, PubUtils, DateUtils, sBitBtn, ActuatorLib;
 
type
  TVerifyThread = class(TThread)
  private
    { Private declarations }
    t_ret : Integer;
    t_nVcc : Word;
    procedure UpdateStartClock;
    procedure UpdateStopClock;
    procedure UpdateTest;
    procedure UpdateTestError;
    procedure UpdateCaption;
  protected
    procedure startVerify();
    procedure Execute; override;
  public
    constructor Create(param: Boolean=false);
    procedure Terminate;
  end;
 
implementation
 
uses
  uMain, uDM, uInit, uSaveData, Global, log4me;
 
{ TVerifyThread }
//--------Ï̳߳õʼ»¯----------------------------------------
//Ï̳߳õʼ»¯
constructor TVerifyThread.Create(param: Boolean=false);
begin
  //Ïß³ÌÍ£Ö¹ºó×Ô¶¯ÊÍ·Å
  inherited Create(param);        //ÉèÖÃÏß³ÌÔËÐÐ, False-×Ô¶¯ÔËÐÐ, True-ÊÖ¶¯Æô¶¯
  FreeOnTerminate := True;        //ÉèÖÃÏß³ÌÍ˳ö×Ô¶¯Ïú
  t_ret := 0;
  t_nVcc:= 0;
end;
 
//Ïß³ÌÏú»Ùʼþ
procedure TVerifyThread.Terminate;
begin
  inherited;
  m_VerifyThread := 0;             //ÇåÀíÏ߳̾ä±ú
end;
 
//--------½çÃæ´¦Àíº¯Êý--------------------------------------
//¼ÆÊýÆ÷¿ªÊ¼
procedure TVerifyThread.UpdateStartClock;
begin
  //Æô¶¯¼ì²â¼ÆÊ±Æ÷¶¯»­
  glStartTest := GetMillisecondTimeStamp;
  dm.tmVerify.Enabled := true;
end;
 
//¼ÆÊýÆ÷½áÊø
procedure TVerifyThread.UpdateStopClock;
begin
  dm.tmVerify.Enabled := false;
  frmMain.mtVerifyClock.Value := 0;
end;
 
//---------------------------------------------------------
//Õý³£ÏÔʾ--Ö´Ðмì²â
procedure TVerifyThread.UpdateTest;
begin
  //¸üнçÃæÐÅÏ¢
  frmMain.lblVerify.Caption := 'У׼һ×éϵÊý³É¹¦£¡';
end;
 
//³ö´íÏÔʾ--Ö´Ðмì²â³ö´í
procedure TVerifyThread.UpdateTestError;
begin
  //¸üнçÃæÐÅÏ¢
  frmMain.lblVerify.Caption := 'У׼²âÊÔʧ°Ü£¬Ë®·ÖÒǹÊÕÏ£¡';
end;
 
procedure TVerifyThread.UpdateCaption;
begin
  with frmMain do begin
    case glBtnTag of
      1: edtTest1.Text := IntToStr(t_nVcc);
      2: edtTest2.Text := IntToStr(t_nVcc);
      3: edtTest3.Text := IntToStr(t_nVcc);
      4: edtTest4.Text := IntToStr(t_nVcc);
      5: edtTest5.Text := IntToStr(t_nVcc);
    end;
  end;
end;
 
//------- Ö´ÐÐÏ̠߳----------------------------------------
procedure TVerifyThread.StartVerify();
begin
  //·µ»ØÖµ
  t_ret := 0;
 
  //Ï·¢Ë®·ÖÒÇÆô¶¯Ö¸Áî
  Synchronize(UpdateStartClock);
  t_ret := SendCommands(hWrDev, WR_VERIFY, glTime2);
  Synchronize(UpdateStopClock);
  if t_ret<0 then begin
    Synchronize(UpdateTestError);
    Exit;
  end;
 
  //´ÓË®·ÖÒÇÆ÷¶ÁÈ¡Êý¾Ý
  ReadVcc(hWrDev, @t_nVcc);
  Synchronize(UpdateTest);
 
  //Êä³ö¼ÆË㺬ˮÂÊ
  Synchronize(UpdateCaption);
end;
 
//------- Ïß³ÌÈë¿Ú ----------------------------------------
procedure TVerifyThread.Execute;
begin
  { Place thread code here }
  try
    //Ö´Ðмì²â´úÂë
    StartVerify();
    //·ÀÖ¹Ïß³Ì×èÈûCPU
    Sleep(1);
  finally
    //Ïú»ÙÏß³Ì
    //m_VerifyThread := 0;
    Terminate;
  end;
end;
 
end.