Tutorial: Building an Rogue Wave Server Application > Using Dynamic Modeling Services > Defining the Behavior of the Application > Defining Computation Methods
 
Defining Computation Methods
In “Defining Attributes”., you defined two derived attributes for the class Node: inputCapacity and outputCapacity. You must therefore define now two computation methods for these derived attributes. To compute the inputCapacity value of a node, Rogue Wave® Server will automatically look up for the Rogue Wave Views Script function Node_compute_inputCapacity(node). This function should return the value of the input capacity for the node passed as the argument, like this:
function Node_compute_inputCapacity(node)
{
var total = 0;
// create an iterator
var i = new IlsServerRelationIterator(node.inputLines);
while (i.next()) {
total = total + i.current.capacity;
}
return total;
}
This script function creates an iterator to sum up the capacity of all the lines that use this node as their output node. It then returns that sum.
The script file should also define a computation method for the derived attribute outputCapacity.
Save the code to a file named network.ilj. This file will be read at runtime by the dynamic server.

Version 5.7
Copyright © 2013, Rogue Wave Software, Inc. All Rights Reserved.