⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ithreadtimers.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 4 页
字号:
{*******************************************************}
{                                                       }
{       TiThreadTimers Component                        }
{                                                       }
{       Copyright (c) 1997,2003 Iocomp Software         }
{                                                       }
{*******************************************************}
{$I iInclude.inc}

{$ifdef iVCL}unit  iThreadTimers;{$endif}
{$ifdef iCLX}unit QiThreadTimers;{$endif}

interface

uses
  {$I iIncludeUses.inc}
  {$IFDEF iVCL} iTypes,  iGPFunctions,  iMath;{$ENDIF}
  {$IFDEF iCLX}QiTypes, QiGPFunctions, QiMath;{$ENDIF}

{$ifdef iVCL}
const
  WM_ITHREADTIMERMSG = WM_USER + 100;
{$ENDIF}

type
  {$ifdef iCLX}TiThreadPriority = (itpIdle, itpLowest, itpLower, itpNormal, itpHigher, itpHighest, itpTimeCritical);{$endif}
  {$ifdef iCLX}TiThreadPolicy   = (itpSCHED_OTHER, itpSCHED_FIFO, itpSCHED_RR);                                     {$endif}

  TiTimerThread = class(TThread)
  private
    {$ifdef iVCL}                  WindowHandle     : HWND;            {$ENDIF}
    {$ifdef LINUX}                 FPriorityWindows : TiThreadPriority;{$ENDIF}
    {$ifdef iCLX}{$ifdef MSWINDOWS}FPriorityLinux   : Integer;         {$ENDIF}{$ENDIF}
    {$ifdef iCLX}{$ifdef MSWINDOWS}FPolicyLinux     : TiThreadPolicy;  {$ENDIF}{$ENDIF}
  protected
    {$IFDEF iCLX}
    procedure SetPriorityWindows(const Value: TiThreadPriority);
    procedure SetPriorityLinux  (const Value: Integer);
    procedure SetPolicyLinux    (const Value: TiThreadPolicy);

    function GetPriorityWindows: TiThreadPriority;
    function GetPriorityLinux  : Integer;
    function GetPolicyLinux    : TiThreadPolicy;
    {$ENDIF}

    procedure Execute; override;
    {$ifdef iVCL}procedure MessageMethod(var Message: TMessage);{$ENDIF}
    procedure DoEvent;
  public
    Owner    : TComponent;
    OnTimer  : TNotifyEvent;
    Interval : Integer;
    {$IFDEF iCLX}
    property PriorityWindows : TiThreadPriority read GetPriorityWindows write SetPriorityWindows;
    property PriorityLinux   : Integer          read GetPriorityLinux   write SetPriorityLinux;
    property PolicyLinux     : TiThreadPolicy   read GetPolicyLinux     write SetPolicyLinux;
    {$ENDIF}
    procedure   AfterConstruction; override;
    destructor  Destroy;           override;
  end;

  TiThreadTimers = class(TCustomControl)
  private
    FTimer1   : TiTimerThread;
    FTimer2   : TiTimerThread;
    FTimer3   : TiTimerThread;
    FTimer4   : TiTimerThread;
    FTimer5   : TiTimerThread;
    FTimer6   : TiTimerThread;
    FTimer7   : TiTimerThread;
    FTimer8   : TiTimerThread;
    FTimer9   : TiTimerThread;

    FEnabled1 : Boolean;
    FEnabled2 : Boolean;
    FEnabled3 : Boolean;
    FEnabled4 : Boolean;
    FEnabled5 : Boolean;
    FEnabled6 : Boolean;
    FEnabled7 : Boolean;
    FEnabled8 : Boolean;
    FEnabled9 : Boolean;

    procedure SetEnabled1       (const Value: Boolean);
    procedure SetEnabled2       (const Value: Boolean);
    procedure SetEnabled3       (const Value: Boolean);
    procedure SetEnabled4       (const Value: Boolean);
    procedure SetEnabled5       (const Value: Boolean);
    procedure SetEnabled6       (const Value: Boolean);
    procedure SetEnabled7       (const Value: Boolean);
    procedure SetEnabled8       (const Value: Boolean);
    procedure SetEnabled9       (const Value: Boolean);

    procedure SetInterval1      (const Value: Integer);
    procedure SetInterval2      (const Value: Integer);
    procedure SetInterval3      (const Value: Integer);
    procedure SetInterval4      (const Value: Integer);
    procedure SetInterval5      (const Value: Integer);
    procedure SetInterval6      (const Value: Integer);
    procedure SetInterval7      (const Value: Integer);
    procedure SetInterval8      (const Value: Integer);
    procedure SetInterval9      (const Value: Integer);

    function GetInterval1       : Integer;
    function GetInterval2       : Integer;
    function GetInterval3       : Integer;
    function GetInterval4       : Integer;
    function GetInterval5       : Integer;
    function GetInterval6       : Integer;
    function GetInterval7       : Integer;
    function GetInterval8       : Integer;
    function GetInterval9       : Integer;

    procedure SetOnTimer1       (const Value: TNotifyEvent);
    procedure SetOnTimer2       (const Value: TNotifyEvent);
    procedure SetOnTimer3       (const Value: TNotifyEvent);
    procedure SetOnTimer4       (const Value: TNotifyEvent);
    procedure SetOnTimer5       (const Value: TNotifyEvent);
    procedure SetOnTimer6       (const Value: TNotifyEvent);
    procedure SetOnTimer7       (const Value: TNotifyEvent);
    procedure SetOnTimer8       (const Value: TNotifyEvent);
    procedure SetOnTimer9       (const Value: TNotifyEvent);

    function GetOnTimer1        : TNotifyEvent;
    function GetOnTimer2        : TNotifyEvent;
    function GetOnTimer3        : TNotifyEvent;
    function GetOnTimer4        : TNotifyEvent;
    function GetOnTimer5        : TNotifyEvent;
    function GetOnTimer6        : TNotifyEvent;
    function GetOnTimer7        : TNotifyEvent;
    function GetOnTimer8        : TNotifyEvent;
    function GetOnTimer9        : TNotifyEvent;

    {$ifdef iVCL}
    procedure SetThreadPriority1(const Value: TThreadPriority);
    procedure SetThreadPriority2(const Value: TThreadPriority);
    procedure SetThreadPriority3(const Value: TThreadPriority);
    procedure SetThreadPriority4(const Value: TThreadPriority);
    procedure SetThreadPriority5(const Value: TThreadPriority);
    procedure SetThreadPriority6(const Value: TThreadPriority);
    procedure SetThreadPriority7(const Value: TThreadPriority);
    procedure SetThreadPriority8(const Value: TThreadPriority);
    procedure SetThreadPriority9(const Value: TThreadPriority);

    function GetThreadPriority1 : TThreadPriority;
    function GetThreadPriority2 : TThreadPriority;
    function GetThreadPriority3 : TThreadPriority;
    function GetThreadPriority4 : TThreadPriority;
    function GetThreadPriority5 : TThreadPriority;
    function GetThreadPriority6 : TThreadPriority;
    function GetThreadPriority7 : TThreadPriority;
    function GetThreadPriority8 : TThreadPriority;
    function GetThreadPriority9 : TThreadPriority;
    {$endif}

    {$ifdef iCLX}
    procedure SetThreadPriorityWindows1(const Value: TiThreadPriority);
    procedure SetThreadPriorityWindows2(const Value: TiThreadPriority);
    procedure SetThreadPriorityWindows3(const Value: TiThreadPriority);
    procedure SetThreadPriorityWindows4(const Value: TiThreadPriority);
    procedure SetThreadPriorityWindows5(const Value: TiThreadPriority);
    procedure SetThreadPriorityWindows6(const Value: TiThreadPriority);
    procedure SetThreadPriorityWindows7(const Value: TiThreadPriority);
    procedure SetThreadPriorityWindows8(const Value: TiThreadPriority);
    procedure SetThreadPriorityWindows9(const Value: TiThreadPriority);

    procedure SetThreadPriorityLinux1(const Value: Integer);
    procedure SetThreadPriorityLinux2(const Value: Integer);
    procedure SetThreadPriorityLinux3(const Value: Integer);
    procedure SetThreadPriorityLinux4(const Value: Integer);
    procedure SetThreadPriorityLinux5(const Value: Integer);
    procedure SetThreadPriorityLinux6(const Value: Integer);
    procedure SetThreadPriorityLinux7(const Value: Integer);
    procedure SetThreadPriorityLinux8(const Value: Integer);
    procedure SetThreadPriorityLinux9(const Value: Integer);

    function GetThreadPriorityWindows1 : TiThreadPriority;
    function GetThreadPriorityWindows2 : TiThreadPriority;
    function GetThreadPriorityWindows3 : TiThreadPriority;
    function GetThreadPriorityWindows4 : TiThreadPriority;
    function GetThreadPriorityWindows5 : TiThreadPriority;
    function GetThreadPriorityWindows6 : TiThreadPriority;
    function GetThreadPriorityWindows7 : TiThreadPriority;
    function GetThreadPriorityWindows8 : TiThreadPriority;
    function GetThreadPriorityWindows9 : TiThreadPriority;

    function GetThreadPriorityLinux1 : Integer;
    function GetThreadPriorityLinux2 : Integer;
    function GetThreadPriorityLinux3 : Integer;
    function GetThreadPriorityLinux4 : Integer;
    function GetThreadPriorityLinux5 : Integer;
    function GetThreadPriorityLinux6 : Integer;
    function GetThreadPriorityLinux7 : Integer;
    function GetThreadPriorityLinux8 : Integer;
    function GetThreadPriorityLinux9 : Integer;

    procedure SetThreadPolicyLinux1(const Value: TiThreadPolicy);
    procedure SetThreadPolicyLinux2(const Value: TiThreadPolicy);
    procedure SetThreadPolicyLinux3(const Value: TiThreadPolicy);
    procedure SetThreadPolicyLinux4(const Value: TiThreadPolicy);
    procedure SetThreadPolicyLinux5(const Value: TiThreadPolicy);
    procedure SetThreadPolicyLinux6(const Value: TiThreadPolicy);
    procedure SetThreadPolicyLinux7(const Value: TiThreadPolicy);
    procedure SetThreadPolicyLinux8(const Value: TiThreadPolicy);
    procedure SetThreadPolicyLinux9(const Value: TiThreadPolicy);

    function GetThreadPolicyLinux1 : TiThreadPolicy;
    function GetThreadPolicyLinux2 : TiThreadPolicy;
    function GetThreadPolicyLinux3 : TiThreadPolicy;
    function GetThreadPolicyLinux4 : TiThreadPolicy;
    function GetThreadPolicyLinux5 : TiThreadPolicy;
    function GetThreadPolicyLinux6 : TiThreadPolicy;
    function GetThreadPolicyLinux7 : TiThreadPolicy;
    function GetThreadPolicyLinux8 : TiThreadPolicy;
    function GetThreadPolicyLinux9 : TiThreadPolicy;
    {$endif}
  protected
    procedure Paint;                                              override;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -