| | |
| | | { |
| | | block.Electric = (double)(end_Ele - start_ELe); //ç¨çµé |
| | | } |
| | | if(time_block.Item2==new DateTime(2023, 3, 22)) |
| | | { } |
| | | block.Money = GetMoney(time_block.Item2, time_block.Item3, 0); |
| | | if (time_block.Item1 == 1) |
| | | { |
| | |
| | | (Starthour < Hour.StartHour && Endhour > Hour.EndHour)) // If the range spans across multiple hours |
| | | { |
| | | // Calculate the amount based on the portion of hours covered |
| | | double? start_flow_in = GetPumpFlowIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Starthour, 0, 0)); |
| | | double? end_flow = GetPumpFlowIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Endhour, 0, 0)); |
| | | double? start_flow_in = GetPumpEleIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Starthour, 0, 0)); |
| | | double? end_flow = GetPumpEleIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Endhour, 0, 0)); |
| | | double amount = 0; |
| | | if (Starthour >= Hour.StartHour && Endhour <= Hour.EndHour) // If start and end hours are within this hour range |
| | | { |
| | |
| | | } |
| | | else if (Starthour < Hour.StartHour && Endhour <= Hour.EndHour) // If the range starts before this hour range |
| | | { |
| | | double? next_flow = GetPumpFlowIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Hour.StartHour, 0, 0)); |
| | | double? next_flow = GetPumpEleIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Hour.StartHour, 0, 0)); |
| | | amount = (double)(next_flow - start_flow_in); |
| | | Price += Hour.Price * amount; // Accumulate price |
| | | Starthour = Hour.StartHour; // Update StartHour to Hour.StartHour for next iteration |
| | | } |
| | | else if (Starthour >= Hour.StartHour && Endhour > Hour.EndHour && Starthour < Hour.EndHour) // If the range ends after this hour range |
| | | { |
| | | double? prev_flow = GetPumpFlowIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Hour.EndHour, 0, 0)); |
| | | double? prev_flow = GetPumpEleIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Hour.EndHour, 0, 0)); |
| | | amount = (double)(prev_flow - start_flow_in); |
| | | Price += Hour.Price * amount; // Accumulate price |
| | | Starthour = Hour.EndHour; // Update StartHour to Hour.EndHour for next iteration |
| | | } |
| | | else // If the range spans across this hour range |
| | | { |
| | | double? next_flow = GetPumpFlowIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Hour.StartHour, 0, 0)); |
| | | double? prev_flow = GetPumpFlowIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Hour.EndHour, 0, 0)); |
| | | double? next_flow = GetPumpEleIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Hour.StartHour, 0, 0)); |
| | | double? prev_flow = GetPumpEleIndexByStartTime(sort, sort, new DateTime(str.Year, str.Month, str.Day, Hour.EndHour, 0, 0)); |
| | | amount = (double)(next_flow - prev_flow); |
| | | Price += Hour.Price * amount; // Accumulate price |
| | | Starthour = Hour.EndHour; // Update StartHour to Hour.EndHour for next iteration |