Class MapperParser

java.lang.Object
cs350s22.component.ui.parser.MapperParser
All Implemented Interfaces:
SubParser

public class MapperParser extends Object implements SubParser
Mapper commands are responsible for creating mappers that modify the raw value reported directly by a sensor.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String[]
     
    private final int
     
    private final cs350s22.component.ui.parser.A_ParserHelper
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MapperParser(String[] args, cs350s22.component.ui.parser.A_ParserHelper parserHelper)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    private 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
    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.
    recParser(int arg, HashMap<String,String> map)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • args

      private final String[] args
    • parserHelper

      private final cs350s22.component.ui.parser.A_ParserHelper parserHelper
    • numOfCmdArgs

      private final int numOfCmdArgs
  • Constructor Details

    • MapperParser

      public MapperParser(String[] args, cs350s22.component.ui.parser.A_ParserHelper parserHelper)
      Constructor.
  • Method Details

    • parse

      public void parse() throws IOException
      Description copied from interface: SubParser
      Method each sub parser is required to use to begin parsing their respective commands.
      Specified by:
      parse in interface SubParser
      Throws:
      IOException - Invalid input.
    • recParser

      private HashMap<String,String> recParser(int arg, HashMap<String,String> map) throws IOException
      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.