* @param raw flag indicating if this data is to be treated as raw
* @return timephased work
*/
public TimephasedCostData getBaselineCost(ProjectCalendar calendar, TimephasedCostNormaliser normaliser, byte[] data, boolean raw)
{
TimephasedCostData result = null;
if (data != null && data.length > 0)
{
LinkedList<TimephasedCost> list = null;
//System.out.println(MPPUtility.hexdump(data, false));
int index = 16; // 16 byte header
int blockSize = 20;
double previousTotalCost = 0;
Date blockStartDate = MPPUtility.getTimestampFromTenths(data, index + 16);
index += blockSize;
while (index + blockSize <= data.length)
{
Date blockEndDate = MPPUtility.getTimestampFromTenths(data, index + 16);
double currentTotalCost = ((long) MPPUtility.getDouble(data, index + 8)) / 100;
if (previousTotalCost != currentTotalCost)
{
TimephasedCost cost = new TimephasedCost();
cost.setStart(blockStartDate);
cost.setFinish(blockEndDate);
cost.setTotalAmount(Double.valueOf(currentTotalCost - previousTotalCost));
if (list == null)
{
list = new LinkedList<TimephasedCost>();
}
list.add(cost);
//System.out.println(cost);
previousTotalCost = currentTotalCost;
}
blockStartDate = blockEndDate;
index += blockSize;
}
if (list != null)
{
result = new TimephasedCostData(calendar, normaliser, list, raw);
}
}
return result;
}