enable utils compilation.
[AROS-Contrib.git] / FryingPan / Optical / CfgIOMeas.cpp
blobff9844596a79cd30c04420f9d997e272ca9087b0
1 /*
2 * FryingPan - Amiga CD/DVD Recording Software (User Interface and supporting Libraries only)
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "CfgIOMeas.h"
21 #include <Generic/LibrarySpool.h>
22 #include <libclass/intuition.h>
24 CfgIOMeas::CfgIOMeas(uint32 ds, uint16 io, uint16 cnt, uint32 t)
26 discsize = ds;
27 iospeed = io;
28 count = cnt;
29 time = t;
32 CfgIOMeas::~CfgIOMeas()
36 void CfgIOMeas::setTime(uint16 t)
38 uint32 val;
40 val = (count * time) + t;
41 ++count;
42 val /= count;
43 time = val;
46 uint16 CfgIOMeas::getTime()
48 return time;
51 uint32 CfgIOMeas::getDiscSize()
53 return discsize;
56 uint16 CfgIOMeas::getIOSpeed()
58 return iospeed;
61 uint16 CfgIOMeas::getCount()
63 return count;
66 void CfgIOMeas::begin()
68 Intuition->CurrentTime(&ctime, &ctenth);
69 ctenth /= 100000;
72 void CfgIOMeas::end()
74 uint32 t1, t2;
76 Intuition->CurrentTime(&t1, &t2);
77 t2 /= 100000;
79 t1 -= ctime;
80 t2 -= ctenth;
82 t1 *= 10;
83 t1 += t2;
84 t1 += 9;
85 t1 /= 10;
86 setTime(t1);
89 uint16 CfgIOMeas::getProgress()
91 int val = 0;
93 if (time == 0)
94 return 0;
96 uint32 t1, t2;
97 Intuition->CurrentTime(&t1, &t2);
99 t2 /= 100000;
100 t2 -= ctenth;
101 t1 -= ctime;
103 t1 = t1*10+t2;
105 if (t1 < (unsigned)(time * 10))
106 val = (t1 << 16)/(time * 10);
107 else
108 val = 65535;
109 return val;