Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions instat/dlgEndOfRainsSeason.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 105 additions & 3 deletions instat/dlgEndOfRainsSeason.vb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Public Class dlgEndOfRainsSeason

#Region "general_code_structures"
' General
Private clsVectorFunction, clsDeleteunusedrowFunction, clsStationtypeFunction, clsConvertColumnTypeStationFunction, clsConvertlinkedvariable1Function, clsConvertlinkedvariableFunction, clsConvertColumnType1Function, clsGetColumnDataTypeFunction, clsConvertColumnTypeFunction, clsRunCalculation, clsListCalFunction, clsDummyFunction As New RFunction
Private clsVectorFunction, clsGetEndRainDefFunction, clsGetEndSeasonDefFunction, clsGetCalculationsFunction, clsGetOffsetTermFunction, clsGetDataframeFunction, clsDeleteunusedrowFunction, clsStationtypeFunction, clsConvertColumnTypeStationFunction, clsConvertlinkedvariable1Function, clsConvertlinkedvariableFunction, clsConvertColumnType1Function, clsGetColumnDataTypeFunction, clsConvertColumnTypeFunction, clsRunCalculation, clsListCalFunction, clsDummyFunction As New RFunction
Private clsFirstOrLastFunction As New RFunction

' Group by
Expand Down Expand Up @@ -306,6 +306,10 @@ Public Class dlgEndOfRainsSeason
ucrChkEndofSeasonDate.AddParameterValuesCondition(True, "sub2", "True")
ucrChkEndofSeasonDate.AddParameterValuesCondition(False, "sub2", "False")

ucrChkDefinitions.SetText("Definitions")
ucrChkDefinitions.AddParameterValuesCondition(True, "def", "True")
ucrChkDefinitions.AddParameterValuesCondition(False, "def", "False")

ucrInputEndofSeasonDate.SetParameter(New RParameter("result_name", 3))
ucrInputEndofSeasonDate.SetValidationTypeAsRVariable()
ucrInputEndofSeasonDate.SetDataFrameSelector(ucrSelectorForWaterBalance.ucrAvailableDataFrames)
Expand All @@ -326,7 +330,6 @@ Public Class dlgEndOfRainsSeason
ucrInputFilled.SetDataFrameSelector(ucrSelectorForWaterBalance.ucrAvailableDataFrames)
ucrInputFilled.SetValidationTypeAsRVariable()


ucrChkWB.AddParameterPresentCondition(True, "WB_evap", True)
ucrChkWB.AddParameterPresentCondition(False, "WB_evap", False)
ucrChkWB.SetText("Reducing")
Expand All @@ -343,6 +346,7 @@ Public Class dlgEndOfRainsSeason
ucrChkEndofSeasonDate.AddToLinkedControls(ucrInputEndofSeasonDate, {True}, bNewLinkedHideIfParameterMissing:=True)
ucrChkEndofSeasonDoy.AddToLinkedControls(ucrInputSeasonDoy, {True}, bNewLinkedHideIfParameterMissing:=True)
ucrChkFilled.AddToLinkedControls(ucrInputFilled, {True}, bNewLinkedHideIfParameterMissing:=True)
ucrChkDefinitions.AddToLinkedControls(ucrSaveObject, {True}, bNewLinkedHideIfParameterMissing:=True)
ucrChkWB.AddToLinkedControls(ucrNudWB, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:=0.5)
ucrPnlEvaporation.AddToLinkedControls(ucrInputEvaporation, {rdoValueEvaporation}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:=5)
ucrPnlEvaporation.AddToLinkedControls(ucrReceiverEvaporation, {rdoVariableEvaporation}, bNewLinkedHideIfParameterMissing:=True)
Expand All @@ -363,6 +367,12 @@ Public Class dlgEndOfRainsSeason
ucrChkEndofSeasonDoy.SetLinkedDisplayControl(grpEndofSeason)
ucrNudTotalOverDays.SetLinkedDisplayControl(lblTotalOverDays)

ucrSaveObject.SetSaveType(strRObjectType:=RObjectTypeLabel.StructureLabel, strRObjectFormat:=RObjectFormat.Text)
ucrSaveObject.SetDataFrameSelector(ucrSelectorForWaterBalance.ucrAvailableDataFrames)
ucrSaveObject.SetLabelText("Definition Object Name:")
ucrSaveObject.SetIsComboBox()
ucrSaveObject.SetAssignToBooleans(bTempAssignToIsPrefix:=True)

#End Region
End Sub

Expand Down Expand Up @@ -399,7 +409,12 @@ Public Class dlgEndOfRainsSeason
clsFirstFilledFunction = New RFunction
clsIsNafilledFunction = New RFunction
clsFirstFilled1Function = New RFunction
clsGetEndRainDefFunction = New RFunction
clsGetEndSeasonDefFunction = New RFunction
clsDeleteunusedrowFunction = New RFunction
clsGetCalculationsFunction = New RFunction
clsGetOffsetTermFunction = New RFunction
clsGetDataframeFunction = New RFunction
clsConditionCheckOperator = New ROperator
clsConditionChecksecondOperator = New ROperator
clsCheckConditionFilterOperator = New ROperator
Expand Down Expand Up @@ -578,6 +593,7 @@ Public Class dlgEndOfRainsSeason
clsDummyFunction = New RFunction
clsDummyFunction.AddParameter("sub2", "True", iPosition:=0)
clsDummyFunction.AddParameter("sub3", "True", iPosition:=1)
clsDummyFunction.AddParameter("def", "false", iPosition:=2)

' Group by
clsGroupByStationYearCalc.SetPackageName("instatCalculations")
Expand Down Expand Up @@ -1172,6 +1188,27 @@ Public Class dlgEndOfRainsSeason
clsLinkeddataFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_linked_to_data_name")
clsLinkeddataFunction.SetAssignTo(strLinkeddata)

clsGetDataframeFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame")
clsGetDataframeFunction.AddParameter("summary_data", strLinkeddata, iPosition:=0, bIncludeArgumentName:=False)
clsGetDataframeFunction.SetAssignTo("summary_data")

clsGetCalculationsFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_calculations")
clsGetCalculationsFunction.AddParameter("summary_data", strLinkeddata, iPosition:=0, bIncludeArgumentName:=False)
clsGetCalculationsFunction.SetAssignTo("calculations_data")

clsGetOffsetTermFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_offset_term")
clsGetOffsetTermFunction.SetAssignTo("definitions_offset")

clsGetEndRainDefFunction.SetRCommand("get_end_rains_definition")
clsGetEndRainDefFunction.AddParameter("summary_data", clsRFunctionParameter:=clsGetDataframeFunction, iPosition:=0, bIncludeArgumentName:=False)
clsGetEndRainDefFunction.AddParameter("summary_calc", clsRFunctionParameter:=clsGetCalculationsFunction, iPosition:=1, bIncludeArgumentName:=False)
clsGetEndRainDefFunction.AddParameter("summary_offset", clsRFunctionParameter:=clsGetOffsetTermFunction, iPosition:=5, bIncludeArgumentName:=False)

clsGetEndSeasonDefFunction.SetRCommand("get_end_season_definition")
clsGetEndSeasonDefFunction.AddParameter("summary_data", clsRFunctionParameter:=clsGetDataframeFunction, iPosition:=0, bIncludeArgumentName:=False)
clsGetEndSeasonDefFunction.AddParameter("summary_calc", clsRFunctionParameter:=clsGetCalculationsFunction, iPosition:=1, bIncludeArgumentName:=False)
clsGetEndSeasonDefFunction.AddParameter("summary_offset", clsRFunctionParameter:=clsGetOffsetTermFunction, iPosition:=5, bIncludeArgumentName:=False)

clsVectorCalFormListFunction.SetRCommand("c")
clsVectorCalFormListFunction.AddParameter("x", clsRFunctionParameter:=clsSetNamesEndSeasonStatusFunction, iPosition:=0, bIncludeArgumentName:=False)
clsVectorCalFormListFunction.AddParameter("y", clsRFunctionParameter:=clsSetNamesEndSeasonFunction, iPosition:=1, bIncludeArgumentName:=False)
Expand Down Expand Up @@ -1244,6 +1281,7 @@ Public Class dlgEndOfRainsSeason
RemoveUnusedRow()
StationType()
EnableFilledvariable()
AddSaveDefinitionOptions()
End Sub

Private Sub SetRCodeForControls(bReset As Boolean)
Expand All @@ -1258,6 +1296,7 @@ Public Class dlgEndOfRainsSeason
ucrReceiverEvaporation.AddAdditionalCodeParameterPair(clsWBMaxTailFunction1, New RParameter("x", 0), iAdditionalPairNo:=1)
ucrReceiverEvaporation.AddAdditionalCodeParameterPair(clsAsNumericFunction, New RParameter("x", 0), iAdditionalPairNo:=2)
ucrReceiverDate.AddAdditionalCodeParameterPair(clsFirstDateFunction, New RParameter("x", 0), iAdditionalPairNo:=1)
ucrSaveObject.AddAdditionalRCode(clsGetEndSeasonDefFunction, iAdditionalPairNo:=1)

ucrReceiverDOY.SetRCode(clsDayToOperator, bReset)

Expand All @@ -1275,6 +1314,7 @@ Public Class dlgEndOfRainsSeason
ucrReceiverRainfall.SetRCode(clsRollSumRainFunction, bReset)

ucrNudWBLessThan.SetRCode(clsEndSeasonWBConditionOperator, bReset)
ucrSaveObject.SetRCode(clsGetEndRainDefFunction, bReset)

If bReset Then
ucrChkWB.SetRCode(clsWBEvaporationMinFunction, bReset)
Expand All @@ -1287,6 +1327,7 @@ Public Class dlgEndOfRainsSeason
ucrChkEndofRainsOccurence.SetRCode(clsDummyFunction, bReset)
ucrChkEndofSeasonDoy.SetRCode(clsEndSeasonCombinationSubCalcList, bReset)
ucrChkEndofSeasonDate.SetRCode(clsDummyFunction, bReset)
ucrChkDefinitions.SetRCode(clsDummyFunction, bReset)
ucrChkEndofSeasonOccurence.SetRCode(clsDummyFunction, bReset)
End If

Expand Down Expand Up @@ -1469,6 +1510,7 @@ Public Class dlgEndOfRainsSeason
clsConvertColumnTypeStationFunction.AddParameter("data_name", Chr(34) & ucrSelectorForWaterBalance.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34), iPosition:=0)
clsLinkeddataFunction.AddParameter("data_name", Chr(34) & ucrSelectorForWaterBalance.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34), iPosition:=0, bIncludeArgumentName:=False)
clsDeleteunusedrowFunction.AddParameter("data_name", Chr(34) & ucrSelectorForWaterBalance.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34), iPosition:=0)
clsGetOffsetTermFunction.AddParameter("data_name", Chr(34) & ucrSelectorForWaterBalance.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34), iPosition:=0, bIncludeArgumentName:=False)
End Sub

Private Sub ucrPnlEvaporation_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlEvaporation.ControlValueChanged, ucrReceiverEvaporation.ControlValueChanged, ucrInputEvaporation.ControlValueChanged
Expand Down Expand Up @@ -1568,6 +1610,8 @@ Public Class dlgEndOfRainsSeason
clsFirstOrLastFunction = clsFirstDoyFunction
Evaporation()
End If
AddSaveDefinitionOptions()

End Sub

Private Sub ucrChkEndofRainsDoy_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkEndofRainsDoy.ControlValueChanged
Expand All @@ -1576,6 +1620,7 @@ Public Class dlgEndOfRainsSeason
Else
clsEndRainsCombinationSubCalcList.RemoveParameterByName("sub1")
End If
AddSaveDefinitionOptions()
End Sub

Private Sub ucrChkEndofRainsDate_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkEndofRainsDate.ControlValueChanged
Expand All @@ -1584,6 +1629,7 @@ Public Class dlgEndOfRainsSeason
Else
clsEndRainsCombinationSubCalcList.RemoveParameterByName("sub2")
End If
AddSaveDefinitionOptions()
End Sub

Private Sub ucrChkEndofSeasonDoy_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkEndofSeasonDoy.ControlValueChanged
Expand All @@ -1608,6 +1654,53 @@ Public Class dlgEndOfRainsSeason
Else
clsEndRainsCombinationSubCalcList.RemoveParameterByName("sub3")
End If
AddSaveDefinitionOptions()
End Sub

Private Sub AddSaveDefinitionOptions()
' Clear all existing parameters first
clsGetEndRainDefFunction.RemoveParameterByName("end_rains_date")
clsGetEndRainDefFunction.RemoveParameterByName("end_rains")
clsGetEndRainDefFunction.RemoveParameterByName("end_rains_status")

clsGetEndSeasonDefFunction.RemoveParameterByName("end_season_date")
clsGetEndSeasonDefFunction.RemoveParameterByName("end_season")
clsGetEndSeasonDefFunction.RemoveParameterByName("end_season_status")
ucrBase.clsRsyntax.RemoveFromAfterCodes(clsGetEndRainDefFunction)
ucrBase.clsRsyntax.RemoveFromAfterCodes(clsGetEndSeasonDefFunction)

If ucrChkDefinitions.Checked Then

If rdoEndOfSeasons.Checked Then
ucrBase.clsRsyntax.AddToAfterCodes(clsGetEndSeasonDefFunction, iPosition:=13)
ucrSaveObject.SetPrefix("end_season_definition")

If ucrChkEndofSeasonDate.Checked Then
clsGetEndSeasonDefFunction.AddParameter("end_season_date", Chr(34) & ucrInputEndofSeasonDate.GetText & Chr(34), iPosition:=2)
End If
If ucrChkEndofSeasonDoy.Checked Then
clsGetEndSeasonDefFunction.AddParameter("end_season", Chr(34) & ucrInputSeasonDoy.GetText & Chr(34), iPosition:=3)
End If
If ucrChkEndofSeasonOccurence.Checked Then
clsGetEndSeasonDefFunction.AddParameter("end_season_status", Chr(34) & ucrInputEndofSeasonOccurence.GetText & Chr(34), iPosition:=4)
End If

ElseIf rdoEndOfRains.Checked Then
ucrBase.clsRsyntax.AddToAfterCodes(clsGetEndRainDefFunction, iPosition:=13)
ucrSaveObject.SetPrefix("end_rain_definition")

If ucrChkEndofRainsDate.Checked Then
clsGetEndRainDefFunction.AddParameter("end_rains_date", Chr(34) & ucrInputEndofRainsDate.GetText & Chr(34), iPosition:=2)
End If
If ucrChkEndofRainsDoy.Checked Then
clsGetEndRainDefFunction.AddParameter("end_rains", Chr(34) & ucrInputEndRainDoy.GetText & Chr(34), iPosition:=3)
End If
If ucrChkEndofRainsOccurence.Checked Then
clsGetEndRainDefFunction.AddParameter("end_rains_status", Chr(34) & ucrInputEndofRainsOccurence.GetText & Chr(34), iPosition:=4)
End If
End If

End If
End Sub

Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrPnlEndOfRainsAndSeasons.ControlContentsChanged, ucrReceiverRainfall.ControlContentsChanged, ucrReceiverDate.ControlContentsChanged, ucrReceiverYear.ControlContentsChanged, ucrReceiverDOY.ControlContentsChanged, ucrNudCapacity.ControlContentsChanged, ucrNudWBLessThan.ControlContentsChanged, ucrInputSeasonDoy.ControlContentsChanged, ucrNudTotalOverDays.ControlContentsChanged, ucrNudAmount.ControlContentsChanged, ucrChkEndofRainsDoy.ControlContentsChanged, ucrInputEndRainDoy.ControlContentsChanged, ucrChkEndofRainsDate.ControlContentsChanged, ucrInputEndofRainsDate.ControlContentsChanged, ucrChkEndofRainsOccurence.ControlContentsChanged, ucrInputEndofRainsOccurence.ControlContentsChanged, ucrChkEndofSeasonDoy.ControlContentsChanged, ucrPnlEvaporation.ControlContentsChanged, ucrReceiverEvaporation.ControlContentsChanged, ucrChkEndofSeasonOccurence.ControlContentsChanged, ucrInputEndofSeasonOccurence.ControlContentsChanged, ucrChkEndofSeasonDate.ControlContentsChanged, ucrInputEndofSeasonDate.ControlContentsChanged, ucrInputEvaporation.ControlContentsChanged
Expand All @@ -1624,6 +1717,8 @@ Public Class dlgEndOfRainsSeason

Private Sub ucrNudWBLessThan_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrNudWBLessThan.ControlValueChanged, ucrChkEndofSeasonOccurence.ControlValueChanged, ucrInputEndofSeasonOccurence.ControlValueChanged, ucrChkEndofSeasonDate.ControlValueChanged, ucrInputEndofSeasonDate.ControlValueChanged, ucrChkEndofSeasonDoy.ControlValueChanged, ucrInputSeasonDoy.ControlValueChanged, ucrSelectorForWaterBalance.ControlValueChanged
EnableFilledvariable()
AddSaveDefinitionOptions()

If Not ucrNudWBLessThan.IsEmpty Then
clsEndSeasonWBConditionOperator.AddParameter("1", ucrNudWBLessThan.GetText(), iPosition:=1)
Else
Expand Down Expand Up @@ -1684,4 +1779,11 @@ Public Class dlgEndOfRainsSeason
End If
End Sub

End Class
Private Sub ucrChkDefinitions_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkDefinitions.ControlValueChanged
AddSaveDefinitionOptions()
End Sub

Private Sub ucrInputEndofRainsDate_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputEndofRainsDate.ControlValueChanged, ucrInputEndofRainsOccurence.ControlValueChanged, ucrInputEndRainDoy.ControlValueChanged
AddSaveDefinitionOptions()
End Sub
End Class
Loading