public string AddRoundBlock(RoundOPTypes roundType, string inputBlockName) { string a = GetUniqueName(); AddBlock(a, RoundOP.XML_TYPE_NAME); SetField(a, RoundOP.OPTypeFieldName, RoundOP.RoundOpTypeToString(roundType)); AddConnection(a, RoundOP.NUMBER_FIELD_NAME, inputBlockName); return(a); }
public static Block Parse(XmlNode node, DFG <Block> dfg, ParserInfo parserInfo, bool canBeScheduled) { string id = ParseTools.ParseID(node); RoundOPTypes roundType = StringToRoundOPType(id, ParseTools.ParseString(node, OPTypeFieldName)); VariableBlock numberBlock = ParseTools.ParseBlock <VariableBlock>(node, dfg, parserInfo, id, NUMBER_FIELD_NAME, new MissingBlockException(id, "Number defining block is missing.")); dfg.AddNode(numberBlock); return(new RoundOP(numberBlock, parserInfo.GetUniqueAnonymousName(), roundType, id, canBeScheduled)); }
public static string RoundOpTypeToString(RoundOPTypes type) { switch (type) { case RoundOPTypes.ROUND: return("ROUND"); case RoundOPTypes.ROUNDDOWN: return("ROUNDDOWN"); case RoundOPTypes.ROUNDUP: return("ROUNDUP"); default: throw new InternalParseException("Failed to parse the round operator type. Type: " + type.ToString()); } }
public RoundOP(VariableBlock numberBlock, string output, RoundOPTypes roundType, string id, bool canBeScheduled) : base(false, null, new List <string>() { numberBlock?.OutputVariable }, output, id, canBeScheduled) { this.NumberBlock = numberBlock; this.RoundType = roundType; }