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
{------------------------------------------------------------------------------}
{µ¥ÔªÃû³Æ£ºstatusThread.pas                                                    }
{Ä£¿éÃû³Æ£ºÒÇÆ÷״̬¼ì²âÏ̠߳                                                   }
{Ä£¿é˵Ã÷£ºÏ̴߳´½¨ºó×Ô¶¯ÔËÐУ¬¶ÁË®·ÖÒÇ´íÎó´úÂëºóÍ˳ö                          }
{½¨Á¢ÈÕÆÚ£º2025-01-20                                                          }
{ÐÞ¸ÄÐ޸ģº2025-01-20                                                          }
{°æÈ¨ËùÓУºÀîÁ¼Í¥ liangtingli@outlook.com                                      }
{------------------------------------------------------------------------------}
unit statusThread;
 
interface
 
uses
  Classes, SysUtils, PubUtils, ActuatorLib;
 
type
  TStatusThread = class(TThread)
  private
    { Private declarations }
    t_ret : Integer;                //·µ»ØÖµ
  procedure UpdateCaption;
  protected
    procedure readStatus();
    procedure Execute; override;
  public
    constructor Create(param: Boolean=false);
    procedure Terminate;
  end;
 
implementation
 
uses
  uMain, Global, log4me;
 
{ TStatusThread }
 
//--------Ï̳߳õʼ»¯----------------------------------------
//Ï̳߳õʼ»¯
constructor TStatusThread.Create(param: Boolean=false);
begin
  //Ïß³ÌÍ£Ö¹ºó×Ô¶¯ÊÍ·Å
  inherited Create(param);        //ÉèÖÃÏß³ÌÔËÐÐ, False-×Ô¶¯ÔËÐÐ, True-ÊÖ¶¯Æô¶¯
  FreeOnTerminate := True;        //ÉèÖÃÏß³ÌÍ˳ö×Ô¶¯Ïú
  t_ret := 0;                     //·µ»ØÖµ
end;
 
//Ïß³ÌÏú»Ùʼþ
procedure TStatusThread.Terminate;
begin
  inherited;
  m_StatusThread := 0;             //ÇåÀíÏ߳̾ä±ú
end;
 
//--------½çÃæ´¦Àíº¯Êý--------------------------------------
//¸üÐÂÒÇÆ÷´íÎó´úÂëµ½×Ô¶¯/ÊÖ¶¯¼ì²â½çÃæ
procedure TStatusThread.UpdateCaption;
begin
  //
end;
 
//------- Ö´ÐÐÏ̠߳----------------------------------------
procedure TStatusThread.readStatus();
begin
  //·µ»ØÖµ
  t_ret := 0;
 
  //¶Áȡˮ·ÖÒÇ´íÎó´úÂëÖ¸Áî
  t_ret := SendCommands(hWrDev, WR_DETECT, 0, glTime2);    
 
  //Êä³ö¼ÆË㺬ˮÂÊ
  if t_ret<0 then
    Synchronize(UpdateCaption);
end;
 
//------- Ïß³ÌÈë¿Ú ----------------------------------------
procedure TStatusThread.Execute;
begin
  { Place thread code here }
  try
    readStatus();
    Sleep(1);
  finally
    Terminate;
  end;
end;
 
end.