def createTwoDWorkspace(finalResponse, rpnStack): gridOptionsObj = twoDDefaults.getDefault() try: #Solve the function for all values in the range plots = parser.getPlots(gridOptionsObj["rangeObj"], rpnStack, 1000) except: print("Exception at 2D parser") gridObjs = {} try: #Create the grid gridObjs = grid.generateGrid(gridOptionsObj["rangeObj"], gridOptionsObj["canvasSize"]) except: print("Exception at 2D grid") plotObjs = [] try: #Get the actual points that will be placed on screen plotObjs = plotter.createPlots(gridOptionsObj["rangeObj"], plots, gridOptionsObj["canvasSize"], gridOptionsObj["colors"]) except: print("Exception at 2D plotter") finalResponse["plot2D"] = { "grid": gridObjs, "plots": plotObjs } #Create table tableOptionsObj = tableDefaults.getDefault() tablePlots = [] try: #Solve the function for all values in the range tablePlots = rangeSolver.getValues(rpnStack, tableOptionsObj) except: print("Exception at table solver") tableColumns = [] tableData = [] try: #Solve the function for all values in the range tableColumns = wijmoFormatting.getColumns(tablePlots) tableData = wijmoFormatting.formatData(tablePlots, tableOptionsObj["delta"], tableOptionsObj["start"]) except: print("Exception at table formatter") finalResponse["table"] = { "values": {}, "column": tableColumns, "data": tableData } for k in range(0, len(tablePlots["stack"])): finalResponse["table"]["values"][str("f" + str(k))] = tablePlots["stack"][k] finalResponse["table"]["labels"] = tablePlots["labels"] return finalResponse
def updateControl(request): response = {} #Update the table if (request["control"] == "table"): lastQuery = getLastHistoryItem(request["username"]) tableOptions = tableDefaults.combineOptions(request["options"]) formattedQuery = formatInput(lastQuery) tokens = tokenizeInput(formattedQuery["functions"]) rpnStack = postfixInput(tokens["tokens"]) tablePlots = [] try: #Solve the function for all values in the range tablePlots = rangeSolver.getValues(rpnStack, tableOptions) except: print("Exception at table solver") tableColumns = [] tableData = [] try: #Solve the function for all values in the range tableColumns = wijmoFormatting.getColumns(tablePlots) tableData = wijmoFormatting.formatData(tablePlots, tableOptions["delta"], tableOptions["start"]) except: print("Exception at table formatter") response["table"] = { "values": {}, "column": tableColumns, "data": tableData } for k in range(0, len(tablePlots["stack"])): response["table"]["values"][str("f" + str(k))] = tablePlots["stack"][k] response["table"]["labels"] = tablePlots["labels"] return formatResponse(response) #Update the 2D plot if (request["control"] == "2dplot"): lastQuery = getLastHistoryItem(request["username"]) gridOptions = twoDDefaults.combineOptions(request["options"]) formattedQuery = formatInput(lastQuery) tokens = tokenizeInput(formattedQuery["functions"]) rpnStack = postfixInput(tokens["tokens"]) plots = [] try: #Solve the function for all values in the range plots = parser.getPlots(gridOptions["rangeObj"], rpnStack, 1000) except: print("Exception at 2D parser") gridObjs = {} try: #Create the grid gridObjs = grid.generateGrid(gridOptions["rangeObj"], gridOptions["canvasSize"]) except: print("Exception at 2D grid") try: #Get the actual points that will be placed on screen plotObjs = plotter.createPlots(gridOptions["rangeObj"], plots, gridOptions["canvasSize"], gridOptions["colors"]) except: print("Exception at 2D plotter") response["plot2D"] = { "grid": gridObjs, "plots": plotObjs } return formatResponse(response)