Class BaseOLParser

java.lang.Object
org.yamcs.scos2k.ol.BaseOLParser
Direct Known Subclasses:
OLParser

public abstract class BaseOLParser extends Object
Transforms OL Formulas into java classes.
  • Field Details

  • Constructor Details

    • BaseOLParser

      public BaseOLParser()
  • Method Details

    • generateCodeImports

      public static void generateCodeImports(StringBuilder code)
      Generates the import statement required before the class definition
      Parameters:
      code -
    • generateCodeStandalone

      public String generateCodeStandalone(String name, Function<String,ParameterType> inputParameterTypes) throws ParseException
      Generate code that can be used in a java compilation unit
      Parameters:
      name - - the name of the output parameter
      inputParameterTypes - - function that gives the types for the input parameters; the function should return null if the parameter is unknown (a ParseException will be thrown in this case).
      Returns:
      a piece of java code ready to be compiled
      Throws:
      ParseException
    • generateCode

      public void generateCode(String name, StringBuilder sb, Function<String,ParameterType> inputParameterTypes) throws ParseException
      Appends the class definition to the StringBuilder (which needs to have on top the package and import declaration). Can be used to generate multiple classes in the same unit.
      Parameters:
      name -
      sb -
      Throws:
      ParseException
    • getReturnCode

      protected String getReturnCode(ExpressionCode ec)
    • addVariable

      protected void addVariable(String name, org.yamcs.scos2k.ol.Type type) throws ParseException
      Throws:
      ParseException
    • getIdentifierCode

      protected ExpressionCode getIdentifierCode(String id) throws ParseException
      Throws:
      ParseException
    • isGlobalVar

      protected boolean isGlobalVar(String id)
    • isLocalVar

      protected boolean isLocalVar(String id)
    • getSynthExpression

      protected ExpressionCode getSynthExpression(List<String> paraList)
    • parse

      protected abstract void parse(StringBuilder body) throws ParseException
      Throws:
      ParseException
    • isNoTrigger

      public boolean isNoTrigger(String pname)
    • getInputParameters

      public List<String> getInputParameters()
    • parseDeltaTime

      public static long parseDeltaTime(String timeString) throws ParseException
      Parses the format ddd.hh.mm.ss[mmm] into milliseconds
      Throws:
      ParseException
    • parseAdsTime

      public static long parseAdsTime(String timeString) throws ParseException
      Parses the ADS format: yyyy.ddd.hh.mm.ss[mmm] into milliseconds
      Throws:
      ParseException
    • parseAsciiATime

      public static long parseAsciiATime(String timeString) throws ParseException
      Parses the format yyyy-mm-ddThh:mm:ss.[uuuuuuu] into milliseconds
      Throws:
      ParseException
    • parseAsciiBTime

      public static long parseAsciiBTime(String timeString) throws ParseException
      Parses the format yyyy-dddThh:mm:ss.[uuuuuu] into milliseconds
      Throws:
      ParseException
    • getEngType

      public static Yamcs.Value.Type getEngType(ParameterType ptype)