diff --git a/HVACTOOL/Module1.vb b/HVACTOOL/Module1.vb index 13a64d23677419677e471d3378dc0e843c96f0b4..1aecf26653c94b12e0832e9f64a998b076af8200 100644 --- a/HVACTOOL/Module1.vb +++ b/HVACTOOL/Module1.vb @@ -14,7 +14,6 @@ Sub main() Dim altSignals As New CombinedAlternatorSignals() ' Dim frm As New frmHVACTool("BusDatabase.abdb", "ssm.ahsm") - ' Dim frm As New frmCombinedAlternators("testCombinedAlternatorMap.aalt",altSignals) Dim frm As New frmCombinedAlternators("ABCDEFG.aalt",altSignals) frm.ShowDialog() diff --git a/VECTOAux/VectoAuxiliaries/Electrics/AltUserInput.vb b/VECTOAux/VectoAuxiliaries/Electrics/AltUserInput.vb index 48bfd05098e86ff5720e26bb482f12e4ef76a13e..2e26b66a0ae47bf322eaa198608798b5fae4b841 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/AltUserInput.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/AltUserInput.vb @@ -1,4 +1,5 @@ - +Option Strict On + Namespace Electrics diff --git a/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb index 4408494954bea48f200979028aef199fc04cfeab..b88803918564f2ff759effb2ebef8dcdb552123d 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb @@ -1,4 +1,6 @@ - +Option Strict On + + Namespace Electrics @@ -54,7 +56,7 @@ Public Class Alternator Dim range as List(Of AltUserInput) = RangeTable.Select( Function(s) New AltUserInput(s.RPM,s.Efficiency)).ToList() - Dim v As Single = Alternator.Iterpolate( range, SpindleSpeed) + Dim v As Single = Alternator.Iterpolate( range,Convert.ToSingle( SpindleSpeed)) Return v @@ -193,7 +195,7 @@ Public Class Alternator RangeTable(4).RPM = M14 'Row 1 - RPM - M11 = IF(M12=IF(N12>N13,M12-((M12-M13)/(N12-N13))*(N12-N11),M12-((M12-M13)/(N12-N13))*(N12-N11)), M12-0.01, IF(N12>N13,M12-((M12-M13)/(N12-N13))*(N12-N11),M12-((M12-M13)/(N12-N13))*(N12-N11))) + M11 = Convert.ToSingle(IF(M12=IF(N12>N13,M12-((M12-M13)/(N12-N13))*(N12-N11),M12-((M12-M13)/(N12-N13))*(N12-N11)), M12-0.01, IF(N12>N13,M12-((M12-M13)/(N12-N13))*(N12-N11),M12-((M12-M13)/(N12-N13))*(N12-N11)))) RangeTable(1).RPM =M11 'Row 0 - RPM @@ -201,7 +203,7 @@ Public Class Alternator RangeTable(0).RPM = M10 'Row 5 - RPM - M15 = IF(M14=IF((N14=0 OrElse N14=N13),M14+1,IF(N13>N14,((((M14-M13)/(N13-N14))*N14)+M14),((((M14-M13)/(N13-N14))*(N14-N15))+M14))),M14+0.01,IF((N14=0 OrElse N14=N13),M14+1,IF(N13>N14,((((M14-M13)/(N13-N14))*N14)+M14),((((M14-M13)/(N13-N14))*(N14-N15))+M14)))) + M15 = Convert.ToSingle(IF(M14=IF((N14=0 OrElse N14=N13),M14+1,IF(N13>N14,((((M14-M13)/(N13-N14))*N14)+M14),((((M14-M13)/(N13-N14))*(N14-N15))+M14))),M14+0.01,IF((N14=0 OrElse N14=N13),M14+1,IF(N13>N14,((((M14-M13)/(N13-N14))*N14)+M14),((((M14-M13)/(N13-N14))*(N14-N15))+M14))))) RangeTable(5).RPM = M15 diff --git a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb index 01a27bddac49888a370f58a59faadf4af19088d9..dc0d57ffe5b62d248d264174b0e1a96881600dd7 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb @@ -1,4 +1,4 @@ - +Option Strict On Imports VectoAuxiliaries.Electrics Imports System @@ -38,7 +38,7 @@ Public Class CombinedAlternator altSignals.CrankRPM = CrankRPM altSignals.CurrentDemandAmps = Amps / Alternators.Count - Return New AlternatorMapValues(Alternators.Average(Function(a) a.Efficiency) / 100) + Return New AlternatorMapValues( Convert.ToSingle(Alternators.Average(Function(a) a.Efficiency) / 100)) End Function @@ -175,12 +175,17 @@ Public Class CombinedAlternator End Function Public Function DeleteAlternator(alternatorName As String, ByRef feedback As String) As Boolean + 'Is this the last alternator, if so deny the user the right to remove it. + If Alternators.Count<2 then + feedback="There must be at least one alternator remaining, operation aborted." + Return false + End If + If Alternators.Where(Function(w) w.AlternatorName = alternatorName).Count = 0 Then feedback = "This alternator does not exist" Return False End If - Dim altToRemove As IAlternator = Alternators.First(Function(w) w.AlternatorName = alternatorName) Dim numAlternators As Integer = Alternators.Count @@ -228,33 +233,36 @@ Public Class CombinedAlternator sb.AppendLine("[AlternatorName],[RPM],[Amps],[Efficiency],[PulleyRatio]") 'write details - For Each alt As IAlternator In Alternators + For Each alt As IAlternator In Alternators.OrderBy( Function(o) o.AlternatorName) '2000 - IE Alt1,2000,10,50,3 For row = 1 To 3 amps = alt.InputTable2000(row).Amps : eff = alt.InputTable2000(row).Eff - sb.Append(alt.AlternatorName + ",2000," + amps.ToString() + "," + eff.ToString() + "," + alt.PulleyRatio.ToString()) + sb.Append(alt.AlternatorName + ",2000," + amps.ToString("0.000") + "," + eff.ToString("0.000") + "," + alt.PulleyRatio.ToString("0.000")) sb.AppendLine("") Next '4000 - IE Alt1,2000,10,50,3 For row = 1 To 3 amps = alt.InputTable4000(row).Amps : eff = alt.InputTable4000(row).Eff - sb.Append(alt.AlternatorName + ",4000," + amps.ToString() + "," + eff.ToString() + "," + alt.PulleyRatio.ToString()) + sb.Append(alt.AlternatorName + ",4000," + amps.ToString("0.000") + "," + eff.ToString("0.000") + "," + alt.PulleyRatio.ToString("0.000")) sb.AppendLine("") Next '4000 - IE Alt1,2000,10,50,3 For row = 1 To 3 amps = alt.InputTable4000(row).Amps : eff = alt.InputTable6000(row).Eff - sb.Append(alt.AlternatorName + ",6000," + amps.ToString() + "," + eff.ToString() + "," + alt.PulleyRatio.ToString()) + sb.Append(alt.AlternatorName + ",6000," + amps.ToString("0.000") + "," + eff.ToString("0.000") + "," + alt.PulleyRatio.ToString("0.000")) sb.AppendLine("") Next Next + 'Add Model Source + sb.AppendLine("[MODELSOURCE]") + sb.Append( Me.ToString()) ' Write the stream cotnents to a new file named "AllTxtFiles.txt" Using outfile As New StreamWriter(aaltPath) @@ -347,13 +355,13 @@ End Function sb.AppendLine("") For i = 0 To 5 - a1 = alt.InputTable2000(i).Amps.ToString("0.###") - e1 = alt.InputTable2000(i).Eff.ToString("0.###") - a2 = alt.InputTable4000(i).Amps.ToString("0.###") - e2 = alt.InputTable4000(i).Eff.ToString("0.###") - a3 = alt.InputTable6000(i).Amps.ToString("0.###") - e3 = alt.InputTable6000(i).Eff.ToString("0.###") - sb.AppendLine(a1 + vbTab + e1 + vbTab + a2 + vbTab + e2 + vbTab + a3 + vbTab + e3 + vbTab) + a1 = alt.InputTable2000(i).Amps.ToString("0") + e1 = alt.InputTable2000(i).Eff.ToString("0.000") + a2 = alt.InputTable4000(i).Amps.ToString("0") + e2 = alt.InputTable4000(i).Eff.ToString("0.000") + a3 = alt.InputTable6000(i).Amps.ToString("0") + e3 = alt.InputTable6000(i).Eff.ToString("0.000") + sb.AppendLine(a1 + vbTab + e1 + vbTab + a2 + vbTab + e2 + vbTab + a3 + vbTab + e3 + vbTab) Next @@ -372,7 +380,7 @@ End Function Dim eff As Single = GetEfficiency(r, a).Efficiency - sb.Append(eff.ToString("0.###") + vbTab) + sb.Append(eff.ToString("0.000") + vbTab) Next sb.AppendLine("") diff --git a/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb b/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb index 011a7d3da192806df909f156715a59c35317c605..8017fa2c56519e48b1639abf13876989d959e4d3 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb @@ -7,16 +7,15 @@ Imports System.Drawing Public Class DeleteCell Inherits DataGridViewButtonCell + Public property ToolTip As String = "Delete tech benefit line" + Private del As Image = My.Resources.ResourceManager.GetObject("Delete") - Dim del As Image = My.Resources.ResourceManager.GetObject("Delete") - 'Image.("..\\..\\images\\delete.png") - - Protected Overrides Sub Paint(graphics As Graphics, clipBounds As Rectangle, cellBounds As Rectangle, rowIndex As Integer, elementState As DataGridViewElementStates, value As Object, formattedValue As Object, errorText As String, cellStyle As DataGridViewCellStyle, advancedBorderStyle As DataGridViewAdvancedBorderStyle, paintParts As DataGridViewPaintParts) + Protected Overrides Sub Paint(graphics As Graphics, clipBounds As Rectangle, cellBounds As Rectangle, rowIndex As Integer, elementState As DataGridViewElementStates, value As Object, formattedValue As Object, errorText As String, cellStyle As DataGridViewCellStyle, advancedBorderStyle As DataGridViewAdvancedBorderStyle, paintParts As DataGridViewPaintParts) advancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single - Me.ToolTipText="Delete this Tech benefit line." + Me.ToolTipText=ToolTip cellStyle.BackColor= Color.White MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts) @@ -27,3 +26,24 @@ Public Class DeleteCell End Class +Public Class DeleteAlternatorCell + Inherits DataGridViewButtonCell + + Public property ToolTip As String = "Delete alternator" + Private del As Image = My.Resources.ResourceManager.GetObject("Delete") + + + Protected Overrides Sub Paint(graphics As Graphics, clipBounds As Rectangle, cellBounds As Rectangle, rowIndex As Integer, elementState As DataGridViewElementStates, value As Object, formattedValue As Object, errorText As String, cellStyle As DataGridViewCellStyle, advancedBorderStyle As DataGridViewAdvancedBorderStyle, paintParts As DataGridViewPaintParts) + + advancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single + + Me.ToolTipText=ToolTip + + cellStyle.BackColor= Color.White + MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts) + graphics.DrawImage(del, cellBounds) + + End Sub + + +End Class \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb b/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb index 617aa5f6cfa874d26ff81e82bb9a426a82ad247a..03baf8586bb1245f856943f1afba378b18fb14d4 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb @@ -5,12 +5,32 @@ Public Class DeleteColumn Inherits DataGridViewButtonColumn - Sub new() - Me.CellTemplate = New DeleteCell() + Public Sub new() + + MyBase.New() + Me.CellTemplate = New DeleteCell() + + End Sub + - End Sub End Class +Public Class DeleteAlternatorColumn + Inherits DataGridViewButtonColumn + + + + Public Sub new() + + MyBase.New() + Me.CellTemplate = New DeleteAlternatorCell() + + End Sub + + + + +End Class \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.vb b/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.vb index 0102b0305c72d0b0d41c67ad85295c55c7bc5fd3..1a4cc65a110aec7a026823b24fe80487d74f7c8f 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.vb @@ -69,14 +69,16 @@ Public Class frmCombinedAlternators gvAlternators.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - Dim deleteColumn As New DeleteColumn - With deleteColumn + Dim deleteColumn As New DeleteAlternatorColumn() + With deleteColumn .HeaderText = "" .ToolTipText = "Delete this row" .Name = "Delete" .Width = 25 .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter End With + + ' deleteColumn.CellTemplate.ToolTipText="Delete this alternator" gvAlternators.Columns.Add(deleteColumn) @@ -591,14 +593,6 @@ End Sub - - - - - - - - End Class