1 |
|
5 |
//------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
// MAGiC
|
4 |
|
|
// Jean Christophe Cuillière et Vincent FRANCOIS
|
5 |
|
|
// Département de Génie Mécanique - UQTR
|
6 |
|
|
//------------------------------------------------------------
|
7 |
|
|
// Le projet MAGIC est un projet de recherche du département
|
8 |
|
|
// de génie mécanique de l'Université du Québec à
|
9 |
|
|
// Trois Rivières
|
10 |
|
|
// Les librairies ne peuvent être utilisées sans l'accord
|
11 |
|
|
// des auteurs (contact : francois@uqtr.ca)
|
12 |
|
|
//------------------------------------------------------------
|
13 |
|
|
//------------------------------------------------------------
|
14 |
|
|
//
|
15 |
|
|
// tgauge.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H26
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h"
|
26 |
|
|
|
27 |
|
|
#include <vcl.h>
|
28 |
|
|
#include <dos.h>
|
29 |
|
|
|
30 |
|
|
#include "tgauge.h"
|
31 |
|
|
#include "main.h"
|
32 |
|
|
#pragma package(smart_init)
|
33 |
|
|
//---------------------------------------------------------------------------
|
34 |
|
|
|
35 |
|
|
// Important: Methods and properties of objects in VCL can only be
|
36 |
|
|
// used in a method called using Synchronize, for example:
|
37 |
|
|
//
|
38 |
|
|
// Synchronize(UpdateCaption);
|
39 |
|
|
//
|
40 |
|
|
// where UpdateCaption could look like:
|
41 |
|
|
//
|
42 |
|
|
// void __fastcall Unit1::UpdateCaption()
|
43 |
|
|
// {
|
44 |
|
|
// Form1->Caption = "Updated in a thread";
|
45 |
|
|
// }
|
46 |
|
|
//---------------------------------------------------------------------------
|
47 |
|
|
|
48 |
|
|
__fastcall gauge::gauge(bool CreateSuspended)
|
49 |
|
|
: TThread(CreateSuspended)
|
50 |
|
|
{
|
51 |
|
|
Priority=tpLowest;
|
52 |
|
|
debut=time(NULL);
|
53 |
|
|
}
|
54 |
|
|
//---------------------------------------------------------------------------
|
55 |
|
|
void __fastcall gauge::Execute()
|
56 |
|
|
{
|
57 |
|
|
Sleep(1500);
|
58 |
|
|
do
|
59 |
|
|
{
|
60 |
|
|
_FILETIME lpct,lpet,lpkt,lput;
|
61 |
|
|
long res=GetProcessTimes(GetCurrentProcess(),&lpct,&lpet,&lpkt,&lput);
|
62 |
|
|
double temps;
|
63 |
|
|
static double tempsancien;
|
64 |
|
|
if (res)
|
65 |
|
|
{
|
66 |
|
|
temps=lput.dwHighDateTime*pow(2,32)*0.0000001;
|
67 |
|
|
temps=temps+lput.dwLowDateTime*0.0000001;
|
68 |
|
|
}
|
69 |
|
|
else temps=0;
|
70 |
|
|
time_t fin=time(NULL);
|
71 |
|
|
long valeur=(temps-tempsancien)/(fin-debut)*100.;
|
72 |
|
|
debut=fin;
|
73 |
|
|
if (valeur>100) valeur=100;
|
74 |
francois |
56 |
if (valeur<0) valeur=0;
|
75 |
|
|
if (valeur>75) MainForm->CGauge1->ForeColor=clRed;
|
76 |
|
|
else if (valeur>50) MainForm->CGauge1->ForeColor=clYellow; else MainForm->CGauge1->ForeColor=clGreen;
|
77 |
|
|
MainForm->CGauge1->Font->Color =clWhite;
|
78 |
|
5 |
MainForm->CGauge1->Progress=valeur;
|
79 |
|
|
tempsancien=temps;
|
80 |
|
|
Sleep(1000);
|
81 |
|
|
}
|
82 |
|
|
while (0==0);
|
83 |
|
|
}
|
84 |
|
|
//---------------------------------------------------------------------------
|