Input Files
VDisp
input files are parsed using the InputParser.jl
module. This module is responsible for parsing input files, creating InputData
instances, and reporting any possible errors in the input file format in a descriptive and helpful manner.
Note:
VDisp
still contains code that parses the old input file format from the originalVDispl
project. This code is kept in mainly for testing purposes, in which we test the newVDisp
's results against that of the original program's. This also allows flexibility for any future developers or contributors to the project!
Main.InputParser.parseCurrentLine
— FunctionparseCurrentLine(input::Array{String}, items::Int, index::Int, delimiter::String=" ")
Given an array of String
values, input
, the index of a string in this array to parse, index
, and the number of values expected to be parsed in this string, items
, parseCurrentLine()
returns an Array
of values parsed from the specified line, or a NotEnoughValuesError
if not enough values were found. There is also an optional argument, delimiter
, which specifies the delimiter which separates each value. The default value for delimiter
is a single space.
Main.InputParser.InputData
— TypeInputData()
The InputData
struct contains all the variables needed to perform VDisp
calculations.
There are two main ways to construct an instance of InputData
:
Parse an input file which follows the speciication of the old
VDispl
file format. Details about this file format can be found in Appendix F of this publication. This functionality is not used in the modern version ofVDisp
, it has only been kept to allow people to parse the old input files if they want.By converting values entered in the GUI into the values that populate the fields of an
InputData
instance. This is the wayVDisp
createsInputData
instances, which are then used to makeOutputData
instances, in thecreateOutputDataFromGUI()
function.
Main.InputParser.GUIData
— TypeGUIData()
The GUIData
struct contains all the information parsed from new input file format. This information is used to populate the GUI entries, significantly speeding up the process and improving the user experience.
vdisp.createOutputDataFromGUI
— FunctioncreateOutputDataFromGUI()
Returns OutputData
instance created from data entered by user in VDisp GUI. Data entered by user is accessed through the global Observable
variables they are stored in.
vdisp.writeGUIDataToFile
— FunctionwriteGUIDataToFile(path, outData)
writeGUIDataToFile()
takes in a String, path
, which represents a relative file path and writes the contents of writeDefaultOutput(path, outData)
to file at path
Error Handling
As mentioned above, the InputParser.jl
module is also responsible for handling any errors that might come up in input files. The following are custom defined exceptions to help in this process.
Main.InputParser.ParsingError
— TypeParsingError()
There was an error parsing old input file type to create InputData
instance.
This is usually thrown when the module has already caught a specific error while parsing in another function, and given user the neccessary feedback. This error is then thrown so it can be caught and handled gracefuly by the script calling the function.
Note: Old input file type is no longer used in the modern version of
VDisp
. The parsing has been left in for developers who would like to test it out.
Main.InputParser.FoundationError
— TypeFoundationError()
The foundationOption was not read as 1 or 2 in old input file type.
Note: Old input file type is no longer used in the modern version of
VDisp
. The parsing has been left in for developers who would like to test it out.
Main.InputParser.SoilNumberError
— TypeSoilNumberError(line::Int)
Invalid sequence of soilLayerNumber specified in old input file type.
Ex. The soilLayerNumber of layer 12 is given before layer 11. Invalid sequence:
1 1
12 2
11 3
16 3
Note: Old input file type is no longer used in the modern version of
VDisp
. The parsing has been left in for developers who would like to test it out.
Main.InputParser.NotEnoughValuesError
— TypeNotEnoughValuesError(requiredValues::Int, givenValues::Int, line::Int)
Not enough values were given on the current line being parsed.
Note: If more values than needed are given, extra values are ignored and no error is thrown.
Main.InputParser.ModelError
— TypeModelError(line::Int32, value::String)
model
value was not 0, 1 or 2.
Main.InputParser.UnitError
— TypeUnitError(line::Int32, value::String)
unit
value was not 0, or 1.
Main.InputParser.FoundationTypeError
— TypeFoundationTypeError(line::Int32, value::String)
foundationType
value was not 0, or 1.
Main.InputParser.FloatConvertError
— TypeFloatConvertError(line::Int32, var::String, value::String)
Value could not be converted to a Float
. This happens when user enters a non-numeric value for a field that must be a floating point value.
Main.InputParser.IntConvertError
— TypeIntConvertError(line::Int32, var::String, value::String)
Value could not be converted to an Int
. This happens when user enters a non-numeric value for a field that must be an integer value.
Main.InputParser.BoolConvertError
— TypeBoolConvertError(line::Int32, var::String, value::String)
Value could not be converted to a Bool
. This happens when user enters a value that is not 0 (false
) or 1(true
).
Main.InputParser.DimensionNegativeError
— TypeDimensionNegativeError(line::Int32, var::String, value::String)
A dimension was given a negative value.
Main.InputParser.MaterialIndexOutOfBoundsError
— TypeMaterialIndexOutOfBoundsError(line::Int32, value::String)
Given material index is not within bounds of given list of materials.
Main.InputParser.PropertyError
— TypePropertyError(msg::String)
Value given for this property is not within constraints. A descriptive message is passed in for msg
.