Hydraulic System Simulation - Extended

Extend, inside class HSystemExt the functions already implemented in class HSystem.

The class HSystemExt extends class HSystem.

R5. Multi-split

Class Multisplit represents an extension of class Split that allows multiple outputs. The constructor accepts, in addition to the name, the number of outputs.

The method connect() accepts two arguments: the element to be connected and the output number to connect it to. Outputs are numbered starting from 0.

To find out which elements are connected to the outputs of a multi-splice, method getOutputs() can be used; it returns an array of the connected elements. If no elements is connected to an output the corresponding item in the array is set to null.

In preparation for the simulation method setProportions() can be used; it accepts a series of double values that define the proportion according to which the input flow is divided among the outputs.

R6. Visualization

Method layout() in class HSystemExt (warning: not HSystem) returns a string containing the layout of the system using ASCII characters and spacing.

For instance, a system composed of a Source, connected to a Tab, that is connected to a Split whose outputs are connected to Sinks, would return a layout like the following one:

[Src]Source -> [R]Tap -> [T]Split +-> [sink A]Sink
                                  | 
                                  +-> [sink B]Sink

R7. Element removal

Method deleteElement() of class HSystemExt deletes from the system a previously added element; the method takes as input parameter the name of element to be deleted.

If such element is not Split or a Multisplit having more than one output connected to other elements, no operation is performed and the method returns false.

Otherwise (Split or Multisplit with at most one output connected or any other element type), the element is removed from the system, and if the element to be removed is connected to other elements in input or output, connections must be modified appropriately so that the upstream element is connected to the downstream one. In this case the method returns true.

Taking the example from R5, the layout after deleting the Tap should be like the following one:

[Src]Source -> [T]Split +-> [sink A]Sink
                        |
                        +-> [sink B]Sink

R8. Maximum flow rate and related alarms

The new class ElementExt extends the class Element adding a method setMaxFlow(), which takes as input parameter a real number, representing the maximum flow rate of an element. If an element takes in input a flow greater than its max flow rate, the element is in danger of breaking down. For Source objects, since they do not have any input, calls to the setMaxFlow() method should not have any effect.

The HSystemExt class contains an overloaded version of the simulate method, taking as parameter the boolean enableMaxFlowCheck: if the latter is true, the method should check also the maximum flow of elements, notifying an error if the element input flow is greater than its maximum flow rate. The overloaded simulate method takes in input also an object implementing the SimulationObserverExt interface, which extends the SimulationObserver, adding a method notifyFlowError, which can be used to notify the aforementioned maximum flow error, passing the element type, the name, the input flow and the maximum flow rate.