code refactor
This commit is contained in:
@@ -5,7 +5,7 @@ from helix.constants.panel_type import PanelType
|
||||
|
||||
|
||||
class DualTilt128CellConstants(object):
|
||||
tolerance = 0.1 #require 10% additional space for panel spacing
|
||||
scaling_factor = 1.1 #require 10% additional space for panel spacing
|
||||
panel_spacing = (88.24, 82.0) # inches
|
||||
spacing_size_inches = 5.12 # This is inches
|
||||
presenter_spacing = (1.5, 1.5)
|
||||
|
||||
@@ -5,7 +5,7 @@ from helix.constants.panel_type import PanelType
|
||||
|
||||
|
||||
class DualTilt96CellConstants(object):
|
||||
tolerance = 0.1 #require 10% additional space for panel spacing
|
||||
scaling_factor = 1.1 #require 10% additional space for panel spacing
|
||||
panel_spacing = (88.24, 62.0) # inches
|
||||
spacing_size_inches = 5.12 # This is inches
|
||||
presenter_spacing = (1.5, 1)
|
||||
|
||||
@@ -5,7 +5,7 @@ from helix.constants.panel_type import PanelType
|
||||
|
||||
|
||||
class DualTiltPSeriesConstants(object):
|
||||
tolerance = 0.1 #require 10% additional space for panel spacing
|
||||
scaling_factor = 1.1 #require 10% additional space for panel spacing
|
||||
panel_spacing = (88.24, 82.0) # inches
|
||||
spacing_size_inches = 8.8503937 # This is inches
|
||||
presenter_spacing = (1.5, 1.5)
|
||||
|
||||
@@ -8,7 +8,7 @@ from helix.constants.system_type_constants.single_tilt_constants import SingleTi
|
||||
|
||||
|
||||
class SingleTilt128CellConstants(object):
|
||||
tolerance = 0.1 #require 10% additional space for panel spacing
|
||||
scaling_factor = 1.1 #require 10% additional space for panel spacing
|
||||
panel_spacing = (82.0, 60.0) # inches
|
||||
presenter_spacing = (1.5, 1)
|
||||
panel_area = 23.29
|
||||
|
||||
@@ -7,7 +7,7 @@ from helix.constants.system_type_constants.single_tilt_constants import SingleTi
|
||||
|
||||
|
||||
class SingleTilt96CellConstants(object):
|
||||
tolerance = 0.1 #require 10% additional space for panel spacing
|
||||
scaling_factor = 1.1 #require 10% additional space for panel spacing
|
||||
panel_spacing = (62.0, 60.0) # inches
|
||||
presenter_spacing = (1, 1)
|
||||
panel_area = 17.58
|
||||
|
||||
@@ -7,7 +7,7 @@ from helix.constants.system_type_constants.single_tilt_constants import SingleTi
|
||||
|
||||
|
||||
class SingleTiltPSeriesConstants(object):
|
||||
tolerance = 0.1 #require 10% additional space for panel spacing
|
||||
scaling_factor = 1.1 #require 10% additional space for panel spacing
|
||||
panel_spacing = (82.0, 61.8755) # inches
|
||||
presenter_spacing = (1.5, 1)
|
||||
panel_area = 22.22
|
||||
|
||||
@@ -14,33 +14,7 @@ class CsvInputValidator(object):
|
||||
if len(headers) < 5:
|
||||
return FileValidationError(FileValidationMessage.InvalidHeaders, 0)
|
||||
if len(rows) == 0:
|
||||
return FileValidationError(FileValidationMessage.InvalidRowCount, 0)
|
||||
|
||||
#check for spacing
|
||||
try:
|
||||
min_spacing = self.user_values.module_system_constants().panel_spacing
|
||||
tolerance = self.user_values.module_system_constants().tolerance + 1
|
||||
min_spacing = (min_spacing[0]*tolerance, min_spacing[1]*tolerance)
|
||||
|
||||
for row_index, row in enumerate(rows):
|
||||
for row_index2, row2 in enumerate(rows):
|
||||
if row_index2 <= row_index:
|
||||
continue
|
||||
|
||||
x1_pos = float(row[11])
|
||||
y1_pos = float(row[12])
|
||||
|
||||
x2_pos = float(row2[11])
|
||||
y2_pos = float(row2[12])
|
||||
|
||||
x_diff = abs(x1_pos-x2_pos)
|
||||
y_diff = abs(y1_pos-y2_pos)
|
||||
|
||||
if (x_diff < min_spacing[0]) and (y_diff < min_spacing[1]):
|
||||
return FileValidationError(FileValidationMessage.PanelsTooClose,None)
|
||||
|
||||
except:
|
||||
pass
|
||||
return FileValidationError(FileValidationMessage.InvalidRowCount, 0)
|
||||
|
||||
for row_index, row in enumerate(rows):
|
||||
chain = [
|
||||
@@ -54,6 +28,7 @@ class CsvInputValidator(object):
|
||||
|
||||
file_validation_chain = [
|
||||
CsvInputValidator.validate_file_for_panel_types,
|
||||
CsvInputValidator.validate_for_spacing,
|
||||
]
|
||||
result = self.run_validation_chain(headers, rows, file_validation_chain)
|
||||
if result:
|
||||
@@ -101,6 +76,32 @@ class CsvInputValidator(object):
|
||||
return FileValidationMessage.panel_type_too_few_corners(self.user_values.system_type())
|
||||
return None
|
||||
|
||||
def validate_for_spacing(self, headers, rows):
|
||||
try:
|
||||
min_spacing = self.user_values.module_system_constants().panel_spacing
|
||||
scaling_factor = self.user_values.module_system_constants().scaling_factor
|
||||
min_spacing = (min_spacing[0]*scaling_factor, min_spacing[1]*scaling_factor)
|
||||
|
||||
for row_index, row in enumerate(rows):
|
||||
for row_index2, row2 in enumerate(rows):
|
||||
if row_index2 <= row_index:
|
||||
continue
|
||||
|
||||
x1_pos = float(row[11])
|
||||
y1_pos = float(row[12])
|
||||
|
||||
x2_pos = float(row2[11])
|
||||
y2_pos = float(row2[12])
|
||||
|
||||
x_diff = abs(x1_pos-x2_pos)
|
||||
y_diff = abs(y1_pos-y2_pos)
|
||||
|
||||
if (x_diff < min_spacing[0]) and (y_diff < min_spacing[1]):
|
||||
return FileValidationMessage.PanelsTooClose
|
||||
|
||||
except:
|
||||
return FileValidationMessage.Generic
|
||||
|
||||
# Helpers
|
||||
|
||||
def run_validation_chain(self, headers, data, chain):
|
||||
|
||||
Reference in New Issue
Block a user