133 lines
5.1 KiB
VB.net
133 lines
5.1 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 gratingDimensions As New DataTable
|
|
|
|
Public Shared Sub Calculate_Grid()
|
|
maxGratingWidth = Get_Max_Width()
|
|
maxGratingLength = Get_Max_Length(maxGratingWidth)
|
|
|
|
Get_NumOf_Vertical(maxGratingWidth)
|
|
Get_NumOf_Horizontal(maxGratingLength)
|
|
|
|
|
|
gratingDimensions.Clear()
|
|
gratingDimensions.Columns.Clear()
|
|
gratingDimensions.Columns.Add("INDEX", GetType(Integer))
|
|
gratingDimensions.Columns.Add("ROW", GetType(Integer))
|
|
gratingDimensions.Columns.Add("COLUMN", GetType(Integer))
|
|
gratingDimensions.Columns.Add("WIDTH", GetType(Integer))
|
|
gratingDimensions.Columns.Add("LENGTH", GetType(Integer))
|
|
|
|
gratingLength = Calculate_Grating_Length(maxGratingLength, 100)
|
|
|
|
For i = 0 To numOfHorizontal * numOfVertical - 1
|
|
Dim tempDR As DataRow = gratingDimensions.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
|
|
|
|
gratingDimensions.Rows.Add(tempDR)
|
|
Next
|
|
|
|
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
|
|
|
|
End Class
|