After you have created a DtModelManager object for the model, you can create a request for results from any component in the model using the ResultRequestMgr class. To make the transfer of data as light-weight as possible (especially when connecting to a SIMULIA Execution Engine database over the network), you can create the request to include only a subset of the parameters from the component. This example sets up a request for results for the root component of the model. To obtain results for other components, you can iterate over the child components of each component using DtComponent.getComponentIterator(); DtComponent comp = modelMgr.getRootComponent(); DtComponentPathDescriptor pathDesc = new DtComponentPathDescriptor(comp); List parmList = comp.getParameterList(); ResultRequestMgr requestMgr = ResultRequestMgrFactory.createInstanceWithVariables( jobId, pathDesc, parmList); You can wait for the results from a synchronous call or register a listener and get results asynchronously on another thread. To keep this example simple, we will just wait for the results. requestMgr.getSynchronousResults(); Results are returned as a FiperResultSet object, which is an extension of the java.sql.ResultSet; if you know how to process JDBC results, you know how to process Isight results. FiperResultSet resultSet = requestMgr.getResultSetSnapShot(); Much of the information associated with a FiperResultSet can be obtained from the FiperResultSetMetaData object it contains: FiperResultSetMetaData resultMetaData = (FiperResultSetMetaData)resultSet.getMetaData(); You can think of the result set as a table of data in which each column represents a parameter and each row represents a “run” of that component. Thus, to get the number of items/parameters and the number of runs in the result set call: int numColumns = resultMetaData.getColumnCount(); int numRows = resultSet.getNumRows(); To get the name of any column (where column numbers are 1-based) resultMetaData.getColumnName(i); There are different ways you could choose to retrieve the actual data from the result set. As discussed previously in Overview of Building a Model, the values of parameters are held in Value objects. You can obtain a Value[] that contains all the results for a parameter as follows: VariableDescriptor varDesc = metaData.getVariableDescriptor(i); Value[] paramValues = resultSet.getValuesForVariable(varDesc); You can also get a single Value if you know the row number and column number of interest: Value val = resultSet.getValue(row, column); If you know that your result set contains only Real parameters, you can get the results returned in a double[][] using double[][] vals = resultSet.getDoubleTable(); If you prefer to iterate over each run to get the results row by row (or for specific rows), you can use the RowDescriptor objects that represent each row: Iterator rowIter = resultSet.getRowDescriptors().iterator(); On each RowDescriptor in this iterator you can call resultSet.getValue(rowDesc, colNum); or resultSet.getValue(rowDesc, paramName); Review the FiperResultSet and FiperResultSetMetaData javadocs for other useful methods related to retrieving results. |