*
* @param dependency
* @return
*/
private static long calcFreeSlack(Dependency dependency) {
ScheduleWindow predecessor = (ScheduleWindow) dependency
.getPredecessor();
ScheduleWindow successor = (ScheduleWindow) dependency.getSuccessor();
long t = 0;
WorkCalendar cal = dependency.getEffectiveWorkCalendar();
if (dependency.getDependencyType() == DependencyType.FS) {
t = cal.compare(cal.add(successor.getEarlyStart(),
-dependency.getLeadValue(), true), predecessor
.getEarlyFinish(), false);
} else if (dependency.getDependencyType() == DependencyType.FF) {
t = cal.compare(cal.add(successor.getEarlyFinish(),
-dependency.getLeadValue(), true), predecessor
.getEarlyFinish(), false);
} else if (dependency.getDependencyType() == DependencyType.SS) {
t = cal.compare(cal.add(successor.getEarlyStart(),
-dependency.getLeadValue(), true), predecessor
.getEarlyStart(), false);
} else if (dependency.getDependencyType() == DependencyType.SF) {
t = cal.compare(cal.add(successor.getEarlyFinish(),
-dependency.getLeadValue(), true), predecessor
.getEarlyStart(), false);
}
return t;
}