merge with upstream master
This commit is contained in:
@@ -6,15 +6,15 @@ from helix.constants.ebom_parts import *
|
||||
from helix.constants.parts import wire_clip_large, cable_support, cable_support_lid, channel_nut, sunshade
|
||||
from helix.constants.system_type import SystemType
|
||||
from helix.constants.inverter_brand import InverterBrand
|
||||
from helix.forms.ebom_form import InverterBrandForm
|
||||
|
||||
|
||||
class EbomCalculator(object):
|
||||
def __init__(self, user_values, row_count, column_count, modules_count = None):
|
||||
def __init__(self, user_values, row_count, column_count, modules_count = None, panels = None):
|
||||
self.values = user_values
|
||||
self.row_count = row_count
|
||||
self.column_count = column_count
|
||||
self.modules_count = modules_count
|
||||
self.panels = panels
|
||||
|
||||
def resolve_power_monitor_type(self):
|
||||
module_type = self.values.module_type()
|
||||
@@ -30,6 +30,14 @@ class EbomCalculator(object):
|
||||
else:
|
||||
return monitor_controller_240_v
|
||||
|
||||
def resolve_is_delta(self):
|
||||
if len(self.values.inverter_brands()) > 0:
|
||||
return self.values.inverter_brands()[0]['inverter_brand_id'] == InverterBrand.DELTA.value
|
||||
if len(self.values.standalone_inverters()) > 0:
|
||||
return self.values.standalone_inverters()[0]['model'].get_type == InverterBrand.DELTA.label
|
||||
# can't determine without data
|
||||
return False
|
||||
|
||||
def compute_ebom(self):
|
||||
part_list = {}
|
||||
|
||||
@@ -38,25 +46,14 @@ class EbomCalculator(object):
|
||||
monitors = self.values.power_monitors()
|
||||
module_type = self.values.module_type()
|
||||
system_type = self.values.system_type()
|
||||
|
||||
is_delta=None
|
||||
try:
|
||||
is_delta=(self.values.inverter_brands()[0]['inverter_brand_id']==InverterBrand.DELTA.value)
|
||||
except IndexError :
|
||||
#Some tests are calculating bom without providing inverter brand so inverter_brands is empty
|
||||
#for those tests, inverter brand is irrelevant
|
||||
is_delta=False
|
||||
|
||||
|
||||
is_delta = self.resolve_is_delta()
|
||||
|
||||
inverter_count = 0
|
||||
total_ac_run_length = 0
|
||||
panel_board_counts = [0, 0]
|
||||
proper_monitor_controller = self.resolve_power_monitor_type()
|
||||
|
||||
try:
|
||||
is_delta = (self.values.inverter_brands()[0]['inverter_brand_id']==InverterBrand.DELTA.value)
|
||||
except IndexError:
|
||||
is_delta = False
|
||||
|
||||
for power_station in power_stations:
|
||||
power_station_count = power_station['power_station_quantity']
|
||||
total_ac_run_length += power_station['ac_run_length']
|
||||
@@ -94,12 +91,17 @@ class EbomCalculator(object):
|
||||
if (is_delta):
|
||||
add_parts_to_list(part_list, {ethernet_plug: 2},1)
|
||||
|
||||
add_parts_to_list(part_list, {wire_clip_large: inverter_count}, self.row_count)
|
||||
if is_delta:
|
||||
clips_amount = inverter_count * self.row_count * 1.15
|
||||
clips_rounded = int(ceil(clips_amount / 10.0)) * 10
|
||||
add_parts_to_list(part_list, {wire_clip_large: clips_rounded})
|
||||
else:
|
||||
add_parts_to_list(part_list, {wire_clip_large: inverter_count}, self.row_count)
|
||||
|
||||
add_parts_to_list(part_list, {stump: 1}, ceil(total_ac_run_length / 4.0))
|
||||
cable_supports = self.calculate_cable_supports(panel_board_counts, len(standalone_inverters))
|
||||
cable_supports = self.calculate_cable_supports(panel_board_counts, len(standalone_inverters), is_delta)
|
||||
add_parts_to_list(part_list, {cable_support: 1, cable_support_lid: 1}, cable_supports)
|
||||
add_parts_to_list(part_list, {rear_skirt: -1}, ceil(cable_supports*.38))
|
||||
add_parts_to_list(part_list, {rear_skirt_1_1: -1}, ceil(cable_supports*.38))
|
||||
|
||||
dependent_part_list = {}
|
||||
|
||||
@@ -121,21 +123,37 @@ class EbomCalculator(object):
|
||||
if inverter['dc_switch']:
|
||||
add_parts_to_list(part_list, dc_switch_parts, multiplier)
|
||||
|
||||
def calculate_cable_supports(self, panel_board_counts, standalone_inverter_count):
|
||||
if sum(panel_board_counts) == 0:
|
||||
def calculate_cable_supports(self, panel_board_counts, standalone_inverter_count, is_delta):
|
||||
# There are some tests that don't have panels
|
||||
if is_delta and self.panels is None:
|
||||
return 0
|
||||
|
||||
if self.values.system_type() == SystemType.dualTilt:
|
||||
dimension1 = self.column_count
|
||||
dimension2 = self.row_count
|
||||
if is_delta:
|
||||
panels_count = len(self.panels)
|
||||
if panels_count == 0:
|
||||
return 0
|
||||
if self.values.system_type() == SystemType.dualTilt:
|
||||
Avg_Columns = self.column_count / panels_count
|
||||
Col2Row_Ratio = self.column_count / self.row_count
|
||||
Col2Row_Ratio = 1 if Col2Row_Ratio < 1 else Col2Row_Ratio
|
||||
return ceil(standalone_inverter_count * 1.25 * Avg_Columns * Col2Row_Ratio + Avg_Columns)
|
||||
else:
|
||||
Avg_Rows = self.row_count / panels_count
|
||||
Row2Col_Ratio = self.row_count / self.column_count
|
||||
Row2Col_Ratio = 1 if Row2Col_Ratio < 1 else Row2Col_Ratio
|
||||
return ceil(standalone_inverter_count * 1.25 * Avg_Rows * Row2Col_Ratio + Avg_Rows)
|
||||
else:
|
||||
dimension1 = self.row_count
|
||||
dimension2 = self.column_count
|
||||
|
||||
result = (standalone_inverter_count + panel_board_counts[0] + (2 * panel_board_counts[1])) / sum(panel_board_counts)
|
||||
result *= dimension1 * max(dimension1 / dimension2, 1)
|
||||
result += dimension1
|
||||
return ceil(result)
|
||||
if sum(panel_board_counts) == 0:
|
||||
return 0
|
||||
if self.values.system_type() == SystemType.dualTilt:
|
||||
dimension1 = self.column_count
|
||||
dimension2 = self.row_count
|
||||
else:
|
||||
dimension1 = self.row_count
|
||||
dimension2 = self.column_count
|
||||
result = (standalone_inverter_count + panel_board_counts[0] + (2 * panel_board_counts[1])) / sum(panel_board_counts)
|
||||
result *= dimension1 * max(dimension1 / dimension2, 1)
|
||||
result += dimension1
|
||||
return ceil(result)
|
||||
|
||||
def get_standalone_inverters(self, power_station):
|
||||
standalone_inverters = self.values.standalone_inverters()
|
||||
|
||||
Reference in New Issue
Block a user