Skip to content

Commit

Permalink
Merge pull request #93 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
Updating master
  • Loading branch information
anastasia-mbithe authored Dec 2, 2022
2 parents 1174882 + c0d691f commit ce0e215
Show file tree
Hide file tree
Showing 20 changed files with 1,705 additions and 784 deletions.
2 changes: 1 addition & 1 deletion instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Public Class RLink
Private strRVersionRequired As String = strRVersionMajorRequired & "." & strRVersionMinorRequired & ".0"

''' <summary> The R bundled version. </summary>
Private strRBundledVersion As String = "4.1.2"
Private strRBundledVersion As String = "4.1.3"

Private clsOutputLogger As clsOutputLogger

Expand Down
73 changes: 68 additions & 5 deletions instat/dlgApsimx.Designer.vb

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

89 changes: 86 additions & 3 deletions instat/dlgApsimx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,110 @@
' along with this program. If not, see <http://www.gnu.org/licenses/>.

Imports instat.Translations
Imports System.IO

Public Class dlgApsimx
Public bFirstLoad As Boolean = True
Private bReset As Boolean = True
Private clsApsimxExampleFunction As New RFunction
Private clsBaseFunction, clsDataListFunction As New RFunction
Private clsReportOperator As New ROperator
Private Sub dlgApsimx_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If bFirstLoad Then
InitialiseDialog()
SetDefaults()
bFirstLoad = False
End If
TestOKEnabled()
If bReset Then
SetDefaults()
End If
SetRCodeForControls(bReset)
bReset = False
autoTranslate(Me)
TestOKEnabled()
End Sub

Private Sub InitialiseDialog()
ucrBase.iHelpTopicID = 479

ucrInputComboList.IsReadOnly = True

ucrChkSilent.SetText("Silent")
ucrChkSilent.SetParameter(New RParameter("silent", 1))
ucrChkSilent.SetValuesCheckedAndUnchecked("TRUE", "FALSE")
ucrChkSilent.SetRDefault("FALSE")

Dim dctExamplesModels As New Dictionary(Of String, String) From {
{"Barley", Chr(34) & "Barley" & Chr(34)},
{"Controlled Environment", Chr(34) & "ControlledEnvironment" & Chr(34)},
{"Eucalyptus", Chr(34) & "Eucalyptus" & Chr(34)},
{"Eucalyptus Rotation", Chr(34) & "EucalyptusRotation" & Chr(34)},
{"Maize", Chr(34) & "Maize" & Chr(34)},
{"Oats", Chr(34) & "Oats" & Chr(34)},
{"Rotation", Chr(34) & "Rotation" & Chr(34)},
{"Soybean", Chr(34) & "Soybean" & Chr(34)},
{"Sugarcane", Chr(34) & "Sugarcane" & Chr(34)},
{"Wheat", Chr(34) & "Wheat" & Chr(34)}}

ucrInputComboList.SetParameter(New RParameter("example", 0))
ucrInputComboList.SetItems(dctExamplesModels)
ucrInputComboList.SetDropDownStyleAsNonEditable()

End Sub

Private Sub SetDefaults()
clsApsimxExampleFunction = New RFunction
clsBaseFunction = New RFunction
clsDataListFunction = New RFunction
clsReportOperator = New ROperator

clsReportOperator.SetOperation("$")
clsReportOperator.AddParameter("left", "Rotation", iPosition:=0)
clsReportOperator.AddParameter("right", "Report", iPosition:=1)
clsReportOperator.bSpaceAroundOperation = False
clsReportOperator.SetAssignTo("Rotation")

clsBaseFunction.SetRCommand("data_book$import_data")
clsBaseFunction.AddParameter("data_tables", clsRFunctionParameter:=clsDataListFunction, iPosition:=0)
clsDataListFunction.SetRCommand("list")
clsApsimxExampleFunction.SetPackageName("apsimx")
clsApsimxExampleFunction.SetRCommand("apsimx_example")
clsApsimxExampleFunction.AddParameter("example", Chr(34) & "Barley" & Chr(34), iPosition:=0)

ucrBase.clsRsyntax.SetBaseRFunction(clsBaseFunction)
End Sub

Private Sub SetRCodeForControls(bReset As Boolean)
ucrChkSilent.SetRCode(clsApsimxExampleFunction, bReset)
ucrInputComboList.SetRCode(clsApsimxExampleFunction, bReset)
End Sub

Private Sub TestOKEnabled()
ucrBase.OKEnabled(ucrInputSaveData.GetText <> "")
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
SetRCodeForControls(True)
TestOKEnabled()
End Sub

Private Sub SetDefaults()
Private Sub ucrInputPath_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrChkSilent.ControlContentsChanged
TestOKEnabled()
End Sub

Private Sub ucrInputComboList_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputComboList.ControlValueChanged
Dim strDataName As String = frmMain.clsRLink.MakeValidText(ucrInputComboList.GetText)
ucrInputSaveData.SetText(strDataName)
clsApsimxExampleFunction.SetAssignTo(strDataName)
clsDataListFunction.ClearParameters()
ucrBase.clsRsyntax.ClearCodes()
If ucrInputComboList.GetText = "Rotation" Then
clsDataListFunction.AddParameter(strDataName, clsRFunctionParameter:=clsApsimxExampleFunction, iPosition:=0)
ucrBase.clsRsyntax.AddToBeforeCodes(clsApsimxExampleFunction, 0)
ucrBase.clsRsyntax.AddToBeforeCodes(clsReportOperator, 1)
Else
clsDataListFunction.AddParameter(ucrInputSaveData.GetText, clsRFunctionParameter:=clsApsimxExampleFunction, iPosition:=0)
End If
ucrBase.clsRsyntax.SetBaseRFunction(clsBaseFunction)
End Sub
End Class
Loading

0 comments on commit ce0e215

Please sign in to comment.