Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1.  
  2. var costs = {};
  3. costs.enrgyHT = 0.06499;
  4. costs.enrgyLT = 0.03599;
  5. costs.exciseDuty = 0.00305;
  6. costs.contrib67ActEZ = 0.00050;
  7. costs.ntwrkChrgHT = 0.04177;
  8. costs.ntwrkChrgLT = 0.03219;
  9. costs.taxFactor = 1.22;
  10. var cumuEnrgyHT = 0;
  11. var cumuEnrgyLT = 0;
  12. var cumuEnrgy = 0;
  13. var cumulativeCostArray = [];
  14.  
  15. chart1Series.powerTotal.forEach(function (point) {
  16. var enrgy = point[1] / 1000;
  17. var timestamp = new Date(point[0]);
  18. if (isHighTariff(timestamp)) {
  19. var cost = enrgy * (costs.enrgyHT + costs.exciseDuty + costs.contrib67ActEZ + costs.ntwrkChrgHT) * costs.taxFactor;
  20. cumuEnrgyHT += enrgy;
  21. }
  22. else {
  23. var cost = enrgy * (costs.enrgyLT + costs.exciseDuty + costs.contrib67ActEZ + costs.ntwrkChrgLT) * costs.taxFactor;
  24. cumuEnrgyLT += enrgy;
  25. }
  26. cost = parseFloat(cost.toFixed(2));
  27.  
  28. if (!chart3Series.cumulativeCost.length)
  29. chart3Series.cumulativeCost.push([point[0], cost]);
  30. else
  31. chart3Series.cumulativeCost.push([point[0], cost + chart3Series.cumulativeCost[chart3Series.cumulativeCost.length - 1][1]]);
  32.  
  33. cumuEnrgy += enrgy;
  34. var cumuEnrgyKW = parseFloat((cumuEnrgy / 1000).toFixed(2));
  35. if (!chart3Series.cumulativeEnergy.length)
  36. chart3Series.cumulativeEnergy.push([point[0], cumuEnrgyKW]);
  37. else
  38. chart3Series.cumulativeEnergy.push([point[0], cumuEnrgyKW + chart3Series.cumulativeEnergy[chart3Series.cumulativeEnergy.length - 1][1]]);
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement