| 2263 |
kivins |
1 |
//## begin module%1.7%.codegen_version preserve=yes
|
|
|
2 |
// Read the documentation to learn more about C++ code generator
|
|
|
3 |
// versioning.
|
|
|
4 |
//## end module%1.7%.codegen_version
|
|
|
5 |
|
|
|
6 |
//## begin module%4211C91D02DE.cm preserve=no
|
|
|
7 |
//## end module%4211C91D02DE.cm
|
|
|
8 |
|
|
|
9 |
//## begin module%4211C91D02DE.cp preserve=no
|
|
|
10 |
// C O P Y R I G H T N O T I C E
|
|
|
11 |
// This material is confidential to ERG and may not be disclosed in whole
|
|
|
12 |
// or in part to any third party nor used in any manner whatsoever other
|
|
|
13 |
// than for the purposes expressly consented to by ERG in writing.
|
|
|
14 |
//
|
|
|
15 |
// This material is also copyright and may not be reproduced, stored in a
|
|
|
16 |
// retrieval system or transmitted in any form or by any means in whole or
|
|
|
17 |
// in part without the express written consent of ERG.
|
|
|
18 |
//## end module%4211C91D02DE.cp
|
|
|
19 |
|
|
|
20 |
//## Module: TimeEstimate%4211C91D02DE; Pseudo Package body
|
|
|
21 |
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
|
|
|
22 |
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\TimeEstimate.cpp
|
|
|
23 |
|
|
|
24 |
//## begin module%4211C91D02DE.additionalIncludes preserve=no
|
|
|
25 |
//## end module%4211C91D02DE.additionalIncludes
|
|
|
26 |
|
|
|
27 |
//## begin module%4211C91D02DE.includes preserve=yes
|
|
|
28 |
//## end module%4211C91D02DE.includes
|
|
|
29 |
|
|
|
30 |
// TimeEstimate
|
|
|
31 |
#include "TimeEstimate.h"
|
|
|
32 |
//## begin module%4211C91D02DE.additionalDeclarations preserve=yes
|
|
|
33 |
//## end module%4211C91D02DE.additionalDeclarations
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
// Class TimeEstimate
|
|
|
37 |
|
|
|
38 |
//## Operation: TimeEstimate%4211CC9F029D
|
|
|
39 |
TimeEstimate::TimeEstimate (TStatusPanel &panel)
|
|
|
40 |
//## begin TimeEstimate::TimeEstimate%4211CC9F029D.hasinit preserve=no
|
|
|
41 |
: m_panel(0),
|
|
|
42 |
m_position(0),
|
|
|
43 |
m_step( 0, 0, 2, 500 ),
|
|
|
44 |
m_total(0)
|
|
|
45 |
//## end TimeEstimate::TimeEstimate%4211CC9F029D.hasinit
|
|
|
46 |
//## begin TimeEstimate::TimeEstimate%4211CC9F029D.initialization preserve=yes
|
|
|
47 |
//## end TimeEstimate::TimeEstimate%4211CC9F029D.initialization
|
|
|
48 |
{
|
|
|
49 |
//## begin TimeEstimate::TimeEstimate%4211CC9F029D.body preserve=yes
|
|
|
50 |
|
|
|
51 |
m_panel = &panel;
|
|
|
52 |
|
|
|
53 |
//## end TimeEstimate::TimeEstimate%4211CC9F029D.body
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
TimeEstimate::~TimeEstimate()
|
|
|
58 |
{
|
|
|
59 |
//## begin TimeEstimate::~TimeEstimate%4211C91D02DE_dest.body preserve=yes
|
|
|
60 |
|
|
|
61 |
stop();
|
|
|
62 |
|
|
|
63 |
m_panel = 0; // We don't own this.
|
|
|
64 |
|
|
|
65 |
//## end TimeEstimate::~TimeEstimate%4211C91D02DE_dest.body
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
//## Other Operations (implementation)
|
|
|
71 |
//## Operation: increment%4211CA05001F
|
|
|
72 |
void TimeEstimate::increment (const unsigned int &delta)
|
|
|
73 |
{
|
|
|
74 |
//## begin TimeEstimate::increment%4211CA05001F.body preserve=yes
|
|
|
75 |
|
|
|
76 |
update( m_position + delta );
|
|
|
77 |
|
|
|
78 |
//## end TimeEstimate::increment%4211CA05001F.body
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
//## Operation: start%4211C99F032C
|
|
|
82 |
void TimeEstimate::start (const unsigned int &total)
|
|
|
83 |
{
|
|
|
84 |
//## begin TimeEstimate::start%4211C99F032C.body preserve=yes
|
|
|
85 |
|
|
|
86 |
m_total = total;
|
|
|
87 |
m_position = 0;
|
|
|
88 |
|
|
|
89 |
m_start = m_update = TDateTime::CurrentDateTime();
|
|
|
90 |
|
|
|
91 |
//## end TimeEstimate::start%4211C99F032C.body
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
//## Operation: stop%4211C99F031C
|
|
|
95 |
void TimeEstimate::stop ()
|
|
|
96 |
{
|
|
|
97 |
//## begin TimeEstimate::stop%4211C99F031C.body preserve=yes
|
|
|
98 |
|
|
|
99 |
m_panel->Text = "";
|
|
|
100 |
m_position = 0;
|
|
|
101 |
m_total = 0;
|
|
|
102 |
|
|
|
103 |
//## end TimeEstimate::stop%4211C99F031C.body
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
//## Operation: update%4211CA05002E
|
|
|
107 |
void TimeEstimate::update (const unsigned int &position)
|
|
|
108 |
{
|
|
|
109 |
//## begin TimeEstimate::update%4211CA05002E.body preserve=yes
|
|
|
110 |
|
|
|
111 |
// Do this only if we're open.
|
|
|
112 |
if ( m_total )
|
|
|
113 |
{
|
|
|
114 |
m_position = position;
|
|
|
115 |
|
|
|
116 |
const TDateTime now = TDateTime::CurrentDateTime();
|
|
|
117 |
if ( now - m_update >= m_step )
|
|
|
118 |
{
|
|
|
119 |
const double scale = double( m_total ) / double( m_position );
|
|
|
120 |
const double duration = now - m_start;
|
|
|
121 |
const double estimate = ( duration * scale ) - duration;
|
|
|
122 |
|
|
|
123 |
//m_panel->Text = "te Estimated Time Remaining: " + TDateTime( estimate ).FormatString( "tt" );
|
|
|
124 |
//Application->ProcessMessages();
|
|
|
125 |
|
|
|
126 |
m_update = now;
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
//## end TimeEstimate::update%4211CA05002E.body
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
// Additional Declarations
|
|
|
135 |
//## begin TimeEstimate%4211C91D02DE.declarations preserve=yes
|
|
|
136 |
//## end TimeEstimate%4211C91D02DE.declarations
|
|
|
137 |
|
|
|
138 |
//## begin module%4211C91D02DE.epilog preserve=yes
|
|
|
139 |
//## end module%4211C91D02DE.epilog
|