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
{------------------------------------------------------------------------------}
{µ¥ÔªÃû³Æ£ºresetThread.pas                                                     }
{Ä£¿éÃû³Æ£ºÒÇÆ÷¸´Î»Ï̠߳                                                       }
{Ä£¿é˵Ã÷£ºÏ̴߳´½¨ºó×Ô¶¯ÔËÐУ¬¸üи´Î»¼ÆÊ±½çÃæ                                }
{½¨Á¢ÈÕÆÚ£º2025-01-17                                                          }
{ÐÞ¸ÄÐ޸ģº2025-01-17                                                          }
{°æÈ¨ËùÓУºÀîÁ¼Í¥ liangtingli@outlook.com                                      }
{------------------------------------------------------------------------------}
unit resetThread;
 
interface
 
uses
  Classes, PubUtils, SysUtils, ActuatorLib;
 
type
  TResetThread = class(TThread)
  private
    { Private declarations }
    t_ret : Integer;                //·µ»ØÖµ
    t_faultCode : Word;             //Ë®·ÖÒǹÊÕÏÂë
    
    procedure UpdateStart;
    procedure UpdateStop;
    procedure UpdateTest;
    procedure UpdateFaultCode;
  protected
    procedure Execute; override;
  public
    constructor Create(param: Boolean=false);
    procedure Terminate;
  end;
 
implementation
 
uses
  uMain, Global, log4me, uDM, uInit;
 
{ TResetThread }
 
//--------Ï̳߳õʼ»¯----------------------------------------
//Ï̳߳õʼ»¯
constructor TResetThread.Create(param: Boolean=false);
begin
  //Ïß³ÌÍ£Ö¹ºó×Ô¶¯ÊÍ·Å
  inherited Create(param);        //ÉèÖÃÏß³ÌÔËÐÐ, False-×Ô¶¯ÔËÐÐ, True-ÊÖ¶¯Æô¶¯
  FreeOnTerminate := True;        //ÉèÖÃÏß³ÌÍ˳ö×Ô¶¯Ïú
  t_ret := 0;
end;
 
//Ïß³ÌÏú»Ùʼþ
procedure TResetThread.Terminate;
begin
  inherited;
  m_ResetThread := 0;        //ÇåÀíÏ߳̾ä±ú
end;
 
//------- ½çÃæÊä³ö ----------------------------------------
//Æô¶¯¶¨Ê±Æ÷
procedure TResetThread.UpdateStart;
begin
  glStartTest := GetMillisecondTimeStamp;
  dm.tmReset.Enabled := true;
end;
 
//¸üмì²â½á¹ûµ½½çÃæ
procedure TResetThread.UpdateStop;
begin
  dm.tmReset.Enabled := false;
  //ÉèÖð´Å¥²»¿ÉÓÃ
  frmMain.SetResetUI(true);
end;
 
//¸´Î»Ìáʾ
procedure TResetThread.UpdateTest;
begin
  if t_ret=0 then
    frmMain.lblMaintain.Caption := 'Ìáʾ£ºÏ·¢Ë®·ÖÒÇ [¸´Î»] ²Ù×÷³É¹¦£¡'
  else
    frmMain.lblMaintain.Caption := 'Ìáʾ£ºÏ·¢Ë®·ÖÒÇ [¸´Î»] ²Ù×÷ʧ°Ü£¡';
end;
 
//³ö´íÏÔʾ--ÒÇÆ÷×Ô¼ì³ö´í
procedure TResetThread.UpdateFaultCode;
begin
  RefashFaultCode(t_faultCode);
end;
 
//------- Ïß³ÌÖ´ÐР----------------------------------------
//Ïß³ÌÈë¿Ú
procedure TResetThread.Execute;
begin
  try
    //Ö´Ðнؾàµ÷Õû´úÂë
    Synchronize(UpdateStart);
    t_ret := ResetCommand(hWrDev);
    Synchronize(UpdateStop);
 
    //Êä³ö¸´Î»½á¹û
    Synchronize(UpdateTest);
 
    //¼ì²éË®·ÖÒǹÊÕÏÂë
    ReadFaultCode(hWrDev, @t_faultCode);
    Synchronize(UpdateFaultCode);
  finally
    //Ïú»ÙÏß³Ì
    Terminate;
  end;
end;
 
end.