From f701d51f18562787716eb3d578710f64133ccff4 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Wed, 28 Mar 2018 17:03:05 -0700 Subject: [PATCH] 1. Added check to make sure that HSPEXP+ does not crash if GENER operation doesn't exist. 2. Added more colors fo Box-Whiskers plot. --- HSPEXP/SetUpScript.iss | 4 +- HSPEXP/SplashScreen1.vb | 2 +- HSPEXP/install.txt | 6 ++ atcHspfSupport/atcConstituentTables.vb | 73 ++++++++++++++++------ atcHspfSupport/atcHspfConstituentBudget.vb | 42 +++++++------ atcHspfSupport/modGraphBoxWhiskers.vb | 8 +++ 6 files changed, 93 insertions(+), 42 deletions(-) diff --git a/HSPEXP/SetUpScript.iss b/HSPEXP/SetUpScript.iss index c8342b33e..0e9c2ea86 100644 --- a/HSPEXP/SetUpScript.iss +++ b/HSPEXP/SetUpScript.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "HSPEXP+" -#define MyAppVersion "2.00beta1" +#define MyAppVersion "2.00beta2" #define MyAppPublisher "RESPEC" #define MyAppURL "http://www.respec.com/product/hspexp/" #define MyAppExeName "HSPEXP+.exe" @@ -23,7 +23,7 @@ AppContact= {#MyAppURL} VersionInfoCopyright=Mozilla Public License (MPL) 1.1 DefaultDirName={reg:HKLM\SOFTWARE\RESPEC\BASINS45,Base Directory|{pf}\HSPEXP+} DefaultGroupName={#MyAppName} -OutputBaseFilename=HSPEXP+2.00beta1SetUp +OutputBaseFilename=HSPEXP+2.00beta2SetUp Compression=lzma SolidCompression=yes InfoBeforeFile=install.txt diff --git a/HSPEXP/SplashScreen1.vb b/HSPEXP/SplashScreen1.vb index f1d178bd5..5bc7385aa 100644 --- a/HSPEXP/SplashScreen1.vb +++ b/HSPEXP/SplashScreen1.vb @@ -27,7 +27,7 @@ ' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision) With My.Application.Info.Version - Version.Text = "Version " & .Major & "." & .Minor & " beta1" + Version.Text = "Version " & .Major & "." & .Minor & " beta2" If .MajorRevision > 0 OrElse .MinorRevision > 0 Then Version.Text &= "." & .MajorRevision & "." & .MinorRevision End If diff --git a/HSPEXP/install.txt b/HSPEXP/install.txt index cefe574d9..307a59ac2 100644 --- a/HSPEXP/install.txt +++ b/HSPEXP/install.txt @@ -1,3 +1,9 @@ +HSPEXP+2.0beta2 +Date: 03/28/2018 + +Bugs Fixed +1. In some cases, if the GENER operation didn't exist, HSPEXP+ crashed. That behavior has been fixed. + HSPEXP+2.0beta1 Date: 03/17/2018 Features: diff --git a/atcHspfSupport/atcConstituentTables.vb b/atcHspfSupport/atcConstituentTables.vb index 38c05871a..8175b9acb 100644 --- a/atcHspfSupport/atcConstituentTables.vb +++ b/atcHspfSupport/atcConstituentTables.vb @@ -2451,6 +2451,37 @@ Public Module atcConstituentTables Next lSource + Case "Water" + lGENERLoad = 0 + 'If aReach.Id = 157 Then Stop + For Each lSource As HspfConnection In aReach.Sources + Dim lGENERSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then + Dim lGENEROperationisOutputtoWDM As Boolean = False + With GetGENERSum(aUCI, lSource, aSDateJ, aEDateJ) + lGENERSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERSum *= lSource.MFact + For Each lMassLink As HspfMassLink In aUCI.MassLinks + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "IVOL" Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + Exit For + End If + Next lMassLink + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "IVOL" Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + End If + If Not lGENEROperationisOutputtoWDM Then + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If + + Next lSource Case Else lGENERLoad = 0 @@ -2653,28 +2684,30 @@ Public Module atcConstituentTables Dim aGENERID As Integer = aSource.Source.VolId Dim aGENEROperationisOutputtoWDM As Boolean = False Dim aGENEROperation As HspfOperation = aSource.Source.Opn - For Each EXTTarget As HspfConnection In aGENEROperation.Targets - If EXTTarget.Target.VolName.Contains("WDM") Then - aGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - For i As Integer = 0 To aUCI.FilesBlock.Count - If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + If Not aGENEROperation Is Nothing Then + For Each EXTTarget As HspfConnection In aGENEROperation.Targets + If EXTTarget.Target.VolName.Contains("WDM") Then + aGENEROperationisOutputtoWDM = True + Dim lWDMFile As String = EXTTarget.Target.VolName.ToString + Dim lDSN As Integer = EXTTarget.Target.VolId + For i As Integer = 0 To aUCI.FilesBlock.Count + If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then + Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) + Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) + If lDataSource Is Nothing Then + If atcDataManager.OpenDataSource(lFileName) Then + lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + End If End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - aGenerSum = ltimeseries.Attributes.GetDefinedValue("Sum").Value / YearCount(aSDateJ, aEDateJ) + Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) + ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) + aGenerSum = ltimeseries.Attributes.GetDefinedValue("Sum").Value / YearCount(aSDateJ, aEDateJ) - End If - Next - End If - Next EXTTarget + End If + Next + End If + Next EXTTarget + End If Return New Tuple(Of Double, Boolean)(aGenerSum, aGENEROperationisOutputtoWDM) End Function diff --git a/atcHspfSupport/atcHspfConstituentBudget.vb b/atcHspfSupport/atcHspfConstituentBudget.vb index 8534a8193..9a5b096f5 100644 --- a/atcHspfSupport/atcHspfConstituentBudget.vb +++ b/atcHspfSupport/atcHspfConstituentBudget.vb @@ -1723,28 +1723,32 @@ Public Module ConstituentBudget Dim aGENERID As Integer = aSource.Source.VolId Dim aGENEROperationisOutputtoWDM As Boolean = False Dim aGENEROperation As HspfOperation = aSource.Source.Opn - For Each EXTTarget As HspfConnection In aGENEROperation.Targets - If EXTTarget.Target.VolName.Contains("WDM") Then - aGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - For i As Integer = 0 To aUCI.FilesBlock.Count - If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + If Not aGENEROperation Is Nothing Then + For Each EXTTarget As HspfConnection In aGENEROperation.Targets + If EXTTarget.Target.VolName.Contains("WDM") Then + aGENEROperationisOutputtoWDM = True + Dim lWDMFile As String = EXTTarget.Target.VolName.ToString + Dim lDSN As Integer = EXTTarget.Target.VolId + For i As Integer = 0 To aUCI.FilesBlock.Count + If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then + Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) + Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) + If lDataSource Is Nothing Then + If atcDataManager.OpenDataSource(lFileName) Then + lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + End If End If + Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) + ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) + aGenerSum = ltimeseries.Attributes.GetDefinedValue("Sum").Value / YearCount(aSDateJ, aEDateJ) + End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - aGenerSum = ltimeseries.Attributes.GetDefinedValue("Sum").Value / YearCount(aSDateJ, aEDateJ) + Next + End If + Next EXTTarget + + End If - End If - Next - End If - Next EXTTarget Return New Tuple(Of Double, Boolean)(aGenerSum, aGENEROperationisOutputtoWDM) End Function diff --git a/atcHspfSupport/modGraphBoxWhiskers.vb b/atcHspfSupport/modGraphBoxWhiskers.vb index d3ca1a0c8..8d587f1c4 100644 --- a/atcHspfSupport/modGraphBoxWhiskers.vb +++ b/atcHspfSupport/modGraphBoxWhiskers.vb @@ -101,6 +101,14 @@ Public Module modGraphBoxWhiskers .Add(Color.DodgerBlue) .Add(Color.Gold) .Add(Color.Indigo) + .Add(Color.Aqua) + .Add(Color.Black) + .Add(Color.BlanchedAlmond) + .Add(Color.CornflowerBlue) + .Add(Color.DarkOrange) + .Add(Color.Gray) + .Add(Color.HotPink) + End With lGrapher.DataColors = data_colors