| 1 |
/* |
| 2 |
* TaskScenario.h - TaskJuggler |
| 3 |
* |
| 4 |
* SPDX-FileCopyrightText: 2002 Chris Schlaeger <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of version 2 of the GNU General Public License as |
| 8 |
* published by the Free Software Foundation. |
| 9 |
* |
| 10 |
* $Id$ |
| 11 |
*/ |
| 12 |
|
| 13 |
// clazy:excludeall=qstring-arg |
| 14 |
#include "TaskScenario.h" |
| 15 |
#include "Resource.h" |
| 16 |
#include "ResourceTreeIterator.h" |
| 17 |
#include "Project.h" |
| 18 |
|
| 19 |
namespace TJ |
| 20 |
{ |
| 21 |
|
| 22 |
|
| 23 |
TaskScenario::TaskScenario() : |
| 24 |
task(nullptr), |
| 25 |
index(0), |
| 26 |
specifiedStart(0), |
| 27 |
specifiedEnd(0), |
| 28 |
start(0), |
| 29 |
end(0), |
| 30 |
minStart(0), |
| 31 |
maxStart(0), |
| 32 |
minEnd(0), |
| 33 |
maxEnd(0), |
| 34 |
startBuffer(-1.0), |
| 35 |
endBuffer(-1.0), |
| 36 |
startBufferEnd(0), |
| 37 |
endBufferStart(0), |
| 38 |
duration(0.0), |
| 39 |
length(0.0), |
| 40 |
effort(0.0), |
| 41 |
startCredit(-1.0), |
| 42 |
endCredit(-1.0), |
| 43 |
criticalness(0.0), |
| 44 |
pathCriticalness(0.0), |
| 45 |
isOnCriticalPath(false), |
| 46 |
reportedCompletion(-1.0), |
| 47 |
containerCompletion(-1.0), |
| 48 |
completionDegree(0.0), |
| 49 |
status(Undefined), |
| 50 |
statusNote(), |
| 51 |
specifiedScheduled(false), |
| 52 |
scheduled(false), |
| 53 |
startCanBeDetermined(false), |
| 54 |
endCanBeDetermined(false), |
| 55 |
specifiedBookedResources(), |
| 56 |
bookedResources(), |
| 57 |
criticalLinks() |
| 58 |
{ |
| 59 |
//qDebug()<<"TaskScenario:"<<this; |
| 60 |
} |
| 61 |
|
| 62 |
void |
| 63 |
TaskScenario::calcCompletionDegree(time_t now) |
| 64 |
{ |
| 65 |
if (now > end) |
| 66 |
{ |
| 67 |
completionDegree = 100.0; |
| 68 |
status = reportedCompletion >= 0 && reportedCompletion < 100 ? |
| 69 |
Late : Finished; |
| 70 |
} |
| 71 |
else if (now <= start) |
| 72 |
{ |
| 73 |
completionDegree = 0.0; |
| 74 |
status = reportedCompletion > 0 ? InProgressEarly : NotStarted; |
| 75 |
} |
| 76 |
else |
| 77 |
{ |
| 78 |
status = OnTime; |
| 79 |
if (effort > 0.0) |
| 80 |
{ |
| 81 |
completionDegree = (100.0 / effort) * |
| 82 |
task->getLoad(index, Interval(start, now)); |
| 83 |
} |
| 84 |
else if (length > 0.0) |
| 85 |
{ |
| 86 |
completionDegree = (100.0 / |
| 87 |
task->getProject()->calcWorkingDays(Interval(start, end))) * |
| 88 |
task->getProject()->calcWorkingDays(Interval(start, now)); |
| 89 |
} |
| 90 |
else |
| 91 |
completionDegree = (100.0 / (end - start + 1)) * (now - start); |
| 92 |
|
| 93 |
if (reportedCompletion >= 0.0) |
| 94 |
{ |
| 95 |
if (reportedCompletion < completionDegree) |
| 96 |
status = InProgressLate; |
| 97 |
else if (reportedCompletion > completionDegree) |
| 98 |
status = InProgressEarly; |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
bool TaskScenario::isDutyOf(const Resource* r) const |
| 104 |
{ |
| 105 |
for (ConstResourceTreeIterator rti(r); *rti; ++rti) |
| 106 |
if (bookedResources.contains |
| 107 |
(const_cast<CoreAttributes*>(static_cast<const CoreAttributes*>(*rti)))) |
| 108 |
return true; |
| 109 |
|
| 110 |
return false; |
| 111 |
} |
| 112 |
|
| 113 |
} // namespace TJ |