Package cs350s22.component.ui.parser
Class MapperParser
java.lang.Object
cs350s22.component.ui.parser.MapperParser
- All Implemented Interfaces:
SubParser
Mapper commands are responsible for creating mappers that modify the raw value
reported directly by a sensor.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final String[]
private final int
private final cs350s22.component.ui.parser.A_ParserHelper
-
Constructor Summary
ConstructorDescriptionMapperParser
(String[] args, cs350s22.component.ui.parser.A_ParserHelper parserHelper) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
linearInterpolation
(cs350s22.support.Identifier id, cs350s22.support.Filespec filename) Creates mapper id that remaps the raw value based on the comma-delimited interpolation table defined in string.private void
normalizeEquation
(cs350s22.support.Identifier id, int valueOne, int valueTwo) Creates mapper id that remaps the raw value onto a percentage scale as defined by the lower limit valueOne and upper limit valueTwo.void
parse()
Method each sub parser is required to use to begin parsing their respective commands.private void
passThroughEquation
(cs350s22.support.Identifier id) Creates mapper id that does not remap the raw value.Recursively parse through the command.private void
scaleEquation
(cs350s22.support.Identifier id, int value) Creates mapper id that remaps the raw value by the linear coefficient value.private void
splineInterpolation
(cs350s22.support.Identifier id, cs350s22.support.Filespec filename) Creates mapper id that remaps the raw value based on the comma-delimited interpolation table defined in string.
-
Field Details
-
args
-
parserHelper
private final cs350s22.component.ui.parser.A_ParserHelper parserHelper -
numOfCmdArgs
private final int numOfCmdArgs
-
-
Constructor Details
-
MapperParser
Constructor.
-
-
Method Details
-
parse
Description copied from interface:SubParser
Method each sub parser is required to use to begin parsing their respective commands.- Specified by:
parse
in interfaceSubParser
- Throws:
IOException
- Invalid input.
-
recParser
Recursively parse through the command.- Parameters:
arg
- Index of command argument to reference.map
- Hashmap to store identify information of the given command.- Returns:
- The Hashmap.
- Throws:
IOException
-
passThroughEquation
private void passThroughEquation(cs350s22.support.Identifier id) Creates mapper id that does not remap the raw value. This is equivalent to CREATE MAPPER id EQUATION SCALE 1.- Parameters:
id
- Name of the mapper object to be created.
-
scaleEquation
private void scaleEquation(cs350s22.support.Identifier id, int value) Creates mapper id that remaps the raw value by the linear coefficient value.- Parameters:
id
- Name of the mapper object to be created.value
- The linear coefficient value passed to the mapper.
-
normalizeEquation
private void normalizeEquation(cs350s22.support.Identifier id, int valueOne, int valueTwo) Creates mapper id that remaps the raw value onto a percentage scale as defined by the lower limit valueOne and upper limit valueTwo.- Parameters:
id
- Name of the mapper object to be created.valueOne
- Lower limit of the mapper.valueTwo
- Upper limit of the mapper.
-
linearInterpolation
private void linearInterpolation(cs350s22.support.Identifier id, cs350s22.support.Filespec filename) throws IOException Creates mapper id that remaps the raw value based on the comma-delimited interpolation table defined in string. Each row defines a point in the two-dimensional graph. The first value is the raw sensor value; the second is its mapped value. LINEAR mode does linear interpolation; SPLINE does a smoother nonlinear interpolation.- Parameters:
id
- Name of the mapper object to be created.filename
- Name of the file to be used.- Throws:
IOException
- Invalid input.
-
splineInterpolation
private void splineInterpolation(cs350s22.support.Identifier id, cs350s22.support.Filespec filename) throws IOException Creates mapper id that remaps the raw value based on the comma-delimited interpolation table defined in string. Each row defines a point in the two-dimensional graph. The first value is the raw sensor value; the second is its mapped value. LINEAR mode does linear interpolation; SPLINE does a smoother nonlinear interpolation.- Parameters:
id
- Identifier for the command type.filename
- Name of the file to be used.- Throws:
IOException
- Invalid input.
-