227 lines
9.0 KiB
VB.net
227 lines
9.0 KiB
VB.net
Public Class Calculate_Fill_Grid
|
|
Public Shared maxGratingWidth, maxGratingLength As Integer
|
|
Public Shared numOfHorizontal, numOfVertical As Integer
|
|
Public Shared gratingLength, gratingWidth As Integer
|
|
|
|
Public Shared gratingDimensionsDT As New DataTable
|
|
Public Shared supportBeamsDT As New DataTable
|
|
Public Shared withSupportBeam As Boolean = False
|
|
|
|
Public Shared Sub Calculate_Grid()
|
|
maxGratingWidth = Get_Max_Width()
|
|
maxGratingLength = Get_Max_Length(maxGratingWidth)
|
|
|
|
Get_NumOf_Vertical(maxGratingWidth)
|
|
Get_NumOf_Horizontal(maxGratingLength)
|
|
|
|
Fill_Dimension_DT()
|
|
|
|
Calculate_Support_Beams()
|
|
|
|
Individual.Panel_Grating.Refresh()
|
|
End Sub
|
|
|
|
|
|
Private Shared Function Get_Max_Width()
|
|
If Data.gratingW >= 1000 Then
|
|
If Data.gratingW Mod 1000 > 0 AndAlso Data.gratingW Mod 1000 <= 200 Then
|
|
Return (Data.gratingW Mod 1000) + 1000
|
|
End If
|
|
Return 1000
|
|
End If
|
|
|
|
Return Data.gratingW
|
|
End Function
|
|
Private Shared Function Get_Max_Length(gratingMaxWidth As Integer)
|
|
' Funkar just nu bara för pressure welded (ty diameter)
|
|
|
|
Dim loadBarHeight As Integer = 25
|
|
Dim loadBarThickness As Integer = 2
|
|
Dim crossBarDiameter As Integer = 5
|
|
|
|
Dim loadBarWeight As Double = 0.385 ' För 1x1 m
|
|
Dim crossBarWeight As Double = 0.153 ' För 1x1 m
|
|
|
|
Dim maxWeight As Double = 70 ' FIXA: Sätta i GUI?
|
|
|
|
Dim LBHdiff As Double = 1 + (User_Input.gratingHeight - loadBarHeight) / loadBarHeight
|
|
loadBarWeight *= LBHdiff
|
|
Dim LBTdiff As Double = 1 + (User_Input.loadBarThickness - loadBarThickness) / loadBarThickness
|
|
loadBarWeight *= LBTdiff
|
|
Dim CBDdiff As Double = 1 + (User_Input.CBDiameter - crossBarDiameter) / crossBarDiameter
|
|
crossBarWeight *= CBDdiff
|
|
|
|
Dim numOfLB As Integer = 1 + Math.Floor((1000 - User_Input.loadBarSpacing) / User_Input.loadBarSpacing)
|
|
Dim numOfCB As Integer = 1 + Math.Floor((1000 - User_Input.crossBarSpacing) / User_Input.crossBarSpacing)
|
|
|
|
Dim gratingWeight As Double = (numOfLB + 4) * loadBarWeight + numOfCB * crossBarWeight
|
|
|
|
Dim maxArea As Double = maxWeight / gratingWeight
|
|
Dim maxLength As Double = maxArea / (gratingMaxWidth / 1000)
|
|
maxLength = Math.Floor(maxLength * 10) * 100
|
|
|
|
Return CInt(maxLength)
|
|
End Function
|
|
|
|
Private Shared Sub Get_NumOf_Horizontal(maxGratingLength As Integer)
|
|
If (Data.gratingL / maxGratingLength) Mod 1 = 0 Then
|
|
numOfHorizontal = Data.gratingL / maxGratingLength
|
|
Else
|
|
numOfHorizontal = Math.Floor(Data.gratingL / maxGratingLength) + 1
|
|
End If
|
|
End Sub
|
|
Private Shared Sub Get_NumOf_Vertical(maxGratingWidth As Integer)
|
|
If Data.gratingW < 1000 Then
|
|
numOfVertical = 1
|
|
ElseIf Data.gratingW Mod 1000 = 0 Then
|
|
numOfVertical = Data.gratingW / 1000
|
|
Else
|
|
If Data.gratingW Mod 1000 <= 200 Then
|
|
numOfVertical = Math.Floor(Data.gratingW / 1000)
|
|
Else
|
|
numOfVertical = Math.Floor(Data.gratingW / 1000) + 1
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Shared Function Calculate_Grating_Length(gratingLength As Integer, modInterval As Integer)
|
|
Dim gLength As Integer
|
|
|
|
If Data.gratingL Mod gratingLength = 0 Then
|
|
gLength = gratingLength
|
|
ElseIf Data.gratingL Mod gratingLength >= 300 AndAlso Math.Floor((Data.gratingL + 0.5) / gratingLength) + 1 = numOfHorizontal Then
|
|
gLength = gratingLength
|
|
ElseIf Math.Floor((Data.gratingL + 0.5) / gratingLength) + 1 > numOfHorizontal Then
|
|
gLength = Calculate_Grating_Length(maxGratingLength, 10)
|
|
Else
|
|
gLength = Calculate_Grating_Length(gratingLength - modInterval, modInterval)
|
|
End If
|
|
|
|
Return gLength
|
|
End Function
|
|
|
|
Private Shared Sub Fill_Dimension_DT()
|
|
gratingDimensionsDT.Clear()
|
|
gratingDimensionsDT.Columns.Clear()
|
|
gratingDimensionsDT.Columns.Add("INDEX", GetType(Integer))
|
|
gratingDimensionsDT.Columns.Add("ROW", GetType(Integer))
|
|
gratingDimensionsDT.Columns.Add("COLUMN", GetType(Integer))
|
|
gratingDimensionsDT.Columns.Add("WIDTH", GetType(Integer))
|
|
gratingDimensionsDT.Columns.Add("LENGTH", GetType(Integer))
|
|
|
|
gratingLength = Calculate_Grating_Length(maxGratingLength, 100)
|
|
|
|
For i = 0 To numOfHorizontal * numOfVertical - 1
|
|
Dim tempDR As DataRow = gratingDimensionsDT.NewRow
|
|
tempDR("INDEX") = i
|
|
tempDR("ROW") = Math.Floor((i + 0.5) / numOfHorizontal)
|
|
tempDR("COLUMN") = i Mod numOfHorizontal
|
|
|
|
If tempDR("ROW") + 1 < numOfVertical Then
|
|
tempDR("WIDTH") = 1000
|
|
Else
|
|
If Data.gratingW Mod 1000 <= 200 Then
|
|
tempDR("WIDTH") = maxGratingWidth
|
|
Else
|
|
tempDR("WIDTH") = Data.gratingW Mod 1000
|
|
End If
|
|
End If
|
|
|
|
If tempDR("COLUMN") + 1 < numOfHorizontal Then
|
|
tempDR("LENGTH") = gratingLength
|
|
Else
|
|
tempDR("LENGTH") = Data.gratingL - gratingLength * (numOfHorizontal - 1)
|
|
End If
|
|
|
|
gratingDimensionsDT.Rows.Add(tempDR)
|
|
Next
|
|
End Sub
|
|
|
|
Private Shared Sub Calculate_Support_Beams()
|
|
' Hämta belastning från gui
|
|
Dim maxLoad As Double = CDbl(Individual.Panel_Data.Controls("TextBox_Max_Load").Text)
|
|
' Kolla mot load tables och hitta max längd
|
|
Dim loadDT As DataTable = Database.database.Tables("LOAD")
|
|
|
|
Dim nameInDT As String = loadDT.Rows(0)("NAME")
|
|
Dim LBHeightInDT As Integer = loadDT.Rows(0)("LB-HEIGHT")
|
|
Dim LBThicknessInDT As Integer = loadDT.Rows(0)("LB-THICKNESS")
|
|
|
|
Dim loadName As String = User_Input.gratingName.Substring(0, 1)
|
|
If User_Input.gratingName.Substring(User_Input.gratingName.Length - 1, 1) = "T" Then
|
|
loadName += "-T"
|
|
If loadName = "F-T" Then
|
|
loadName = "H-T" ' Fixa: Tillfällig då det inte finns load data för F-T
|
|
End If
|
|
ElseIf loadName = "A" Then
|
|
loadName += User_Input.gratingMesh.Split(" ")(0)
|
|
End If
|
|
|
|
Dim maxUnsupportedLenght As Integer
|
|
For i = 0 To loadDT.Rows.Count - 1
|
|
If loadName = nameInDT AndAlso User_Input.gratingHeight = LBHeightInDT _
|
|
AndAlso User_Input.loadBarThickness = LBThicknessInDT Then
|
|
If loadDT.Rows(i)("300") < maxLoad Then
|
|
MessageBox.Show("Max supported load for chosen grating parameters is: " & loadDT.Rows(i)("300") & " [kN/m^2]")
|
|
Return
|
|
End If
|
|
For j = loadDT.Columns.Count - 1 To 0 Step -1
|
|
If loadDT.Rows(i)(j) >= maxLoad Then
|
|
maxUnsupportedLenght = CInt(loadDT.Columns(j).ColumnName)
|
|
Exit For
|
|
End If
|
|
Next
|
|
Exit For
|
|
End If
|
|
Try
|
|
nameInDT = loadDT.Rows(i + 1)("NAME")
|
|
LBHeightInDT = loadDT.Rows(i + 1)("LB-HEIGHT")
|
|
LBThicknessInDT = loadDT.Rows(i + 1)("LB-THICKNESS")
|
|
Catch ex As Exception
|
|
End Try
|
|
Next
|
|
|
|
' Jämför med längd
|
|
If Math.Floor((gratingLength + 1) / maxUnsupportedLenght) < 1 Then '+1 för att floor inte kan hantera jämna tal
|
|
withSupportBeam = False
|
|
Return
|
|
End If
|
|
|
|
withSupportBeam = True
|
|
' Definera support beams
|
|
supportBeamsDT.Clear()
|
|
supportBeamsDT.Columns.Clear()
|
|
supportBeamsDT.Columns.Add("COLUMN", GetType(Integer))
|
|
supportBeamsDT.Columns.Add("COLUMN_OFFSET", GetType(Integer))
|
|
supportBeamsDT.Columns.Add("GLOBAL_OFFSET", GetType(Integer))
|
|
supportBeamsDT.Columns.Add("LENGTH", GetType(Integer))
|
|
supportBeamsDT.Columns.Add("OFFSET_TOP", GetType(Integer))
|
|
supportBeamsDT.Columns.Add("OFFSET_BOTTOM", GetType(Integer))
|
|
For i = 0 To numOfHorizontal - 1
|
|
Dim gratingL As Integer = gratingDimensionsDT.Rows(i)("LENGTH")
|
|
Dim numOfBeamsNeeded As Integer = Math.Floor((gratingL + 1) / maxUnsupportedLenght)
|
|
If numOfBeamsNeeded > 0 Then
|
|
Dim beamSpacing As Integer = (Math.Floor(((gratingL + 1) / (numOfBeamsNeeded + 1)) / 10)) * 10
|
|
|
|
For j = 1 To numOfBeamsNeeded
|
|
Dim tempDR As DataRow = supportBeamsDT.NewRow
|
|
tempDR("COLUMN") = i
|
|
tempDR("COLUMN_OFFSET") = j * beamSpacing
|
|
tempDR("GLOBAL_OFFSET") = gratingLength * i + tempDR("COLUMN_OFFSET")
|
|
tempDR("LENGTH") = Data.gratingW
|
|
tempDR("OFFSET_TOP") = 0
|
|
tempDR("OFFSET_BOTTOM") = 0
|
|
|
|
supportBeamsDT.Rows.Add(tempDR)
|
|
Next
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
Next
|
|
End Sub
|
|
End Class
|