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

📄 uthread.pas

📁 1. 发卡服务端:Server 项目文件:autojet.prj 2. 计费客户端:Client 项目文件:internet.prj Explorer.prj 先启动Exp
💻 PAS
字号:
unit uthread;

interface

uses
  Classes, windows, sysutils,dialogs,forms ;

type
  TReadCard = class(TThread)
  private
     procedure MyNotice ;
    { Private declarations }
  protected
    chkMs, wrtms: Dword;
    Checktime, Moneytime: Dword ;
    procedure Execute; override;
  public
    isStop: boolean;
    Constructor Create(chktime, montime: dword);
  end;

implementation

uses DllDef, Ucomm, sys_global, fmain, ShowUser ;

var
  used : boolean;

{ ReadCard }

procedure TReadCard.MyNotice ;  // 费用不足1元提示
begin
  try
    m_ShowStop := '1' ;
    frm_ShowUser.Show ;
    SetForegroundWindow(frm_ShowUser.Handle);
  except
    beep ;
  end;
end;


procedure TReadCard.Execute;
begin
  while not isstop do begin
        if (chkms>0) and (GetTiCkCount-chkMS<CHECKTIME) and
           (wrtms>0) and (GetTiCkCount-wrtMS<moneyTIME)   then
           CONTINUE;
        IF used and not waitcom THEN
           CONTINUE;
        if isstop then
           exit;

        USED:=TRUE;

        if (chkms=0) or (GetTiCkCount-chkms>=checkTIME) then
        begin
           if m_stop='9' then begin
              f_main.ADOCNT1.close;
              try
                 f_main.ADOCNT1.Open;
                 m_stop:='0';
              except
              end;
           end;
           if m_stop<>'9' then begin
              if ChkCard(m_com) <> 0 then exit ;  // 若没有插卡, 则中断这个线程
              if CardInfo(m_ICtype, m_ICno, m_ICmoney, m_ICdateTime)<>0 then exit ;// 若读卡失败, 则中断这个线程
              if (m_ICtype <> '5') and (m_ICmoney <0.01) then exit ;       // 若没有钱, 则中断这个线程
           end;
           if m_ICdateTime < m_DateTime then exit ;
           chkMS := GetTickCount();
        end;

        if ((wrtms=0) or (GetTiCkCount-wrtms>=moneyTIME)) and (m_ictype<>'5') then
        begin
           if GetMoney <> 0 then exit ;// 计算 m_montime微秒, 要扣的钱

           if (m_ICtype <> '5') and (m_ShowStop='0') and ((m_ictype='4') and (m_ICMoney < 5) or (m_ictype<>'4') and (m_icmoney<1)) then
               Synchronize(MyNotice);    // 时间不足5分钟或金额不足1元时,报警

            if ChgTable <> 0 then exit; // 根据卡型, 将当前的时间\剩余金额\剩余时间写入数据表CARD中

           if ChgMoneyTimes(m_com, pchar(m_ICtype+m_ICno), pchar(m_TimesMoney))<>0 then exit ; //扣除上机m_montime微秒, 所需要的钱

           wrtMS := GetTickCount();
        end;
        USED:=FALSE;
  end;
end;

Constructor TReadCard.Create(chktime, montime: dword);
begin
  inherited Create(True);
  FreeOnTerminate := True ;
  isStop := false ;
  chkMs := GetTickCount() ;
  wrtms:=0;
  checktime := chktime ;
  moneytime := montime ;
  resume ;
end;

end.

⌨️ 快捷键说明

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