* @param raw flag indicating if this data is to be treated as raw
* @return timephased work
*/
public TimephasedWorkData getBaselineWork(ResourceAssignment assignment, ProjectCalendar calendar, TimephasedWorkNormaliser normaliser, byte[] data, boolean raw)
{
TimephasedWorkData result = null;
if (data != null && data.length > 0)
{
LinkedList<TimephasedWork> list = null;
//System.out.println(MPPUtility.hexdump(data, false));
int index = 8; // 8 byte header
int blockSize = 40;
double previousCumulativeWorkPerformedInMinutes = 0;
Date blockStartDate = MPPUtility.getTimestampFromTenths(data, index + 36);
index += blockSize;
TimephasedWork work = null;
while (index + blockSize <= data.length)
{
double cumulativeWorkInMinutes = ((long) MPPUtility.getDouble(data, index + 20)) / 1000;
if (cumulativeWorkInMinutes != previousCumulativeWorkPerformedInMinutes)
{
//double unknownWorkThisPeriodInMinutes = ((long) MPPUtility.getDouble(data, index + 0)) / 1000;
double normalActualWorkThisPeriodInMinutes = ((double)MPPUtility.getInt(data, index+ 8))/10;
double normalRemainingWorkThisPeriodInMinutes = ((double)MPPUtility.getInt(data, index+ 28))/10;
double workThisPeriodInMinutes = cumulativeWorkInMinutes - previousCumulativeWorkPerformedInMinutes;
double overtimeWorkThisPeriodInMinutes = workThisPeriodInMinutes - (normalActualWorkThisPeriodInMinutes+normalRemainingWorkThisPeriodInMinutes);
double overtimeFactor = overtimeWorkThisPeriodInMinutes / (normalActualWorkThisPeriodInMinutes+normalRemainingWorkThisPeriodInMinutes);
double normalWorkPerDayInMinutes = 480;
double overtimeWorkPerDayInMinutes = normalWorkPerDayInMinutes * overtimeFactor;
work = new TimephasedWork();
work.setFinish(MPPUtility.getTimestampFromTenths(data, index + 16));
work.setStart(blockStartDate);
work.setTotalAmount(Duration.getInstance(workThisPeriodInMinutes, TimeUnit.MINUTES));
work.setAmountPerDay(Duration.getInstance(normalWorkPerDayInMinutes+overtimeWorkPerDayInMinutes, TimeUnit.MINUTES));
previousCumulativeWorkPerformedInMinutes = cumulativeWorkInMinutes;
if (list == null)
{
list = new LinkedList<TimephasedWork>();
}
list.add(work);
//System.out.println(work);
}
blockStartDate = MPPUtility.getTimestampFromTenths(data, index + 36);
index += blockSize;
}
if (list != null)
{
if (work != null)
{
work.setFinish(assignment.getFinish());
}
result = new TimephasedWorkData(calendar, normaliser, list, raw);
}
}
return result;
}