Calculator is used for user defined code inside other composite items code.
If attached to streams they are by default named in Calculators code, otherwise user has to name each stream involved in the Calculator calculations.
|
What do you want to see?
|
|
Function Calculator_Run_Proc(ModelItem As ModelItem, ByVal Step As Long, _
ByVal DebugModel As Boolean, ByVal ContinueRun As Boolean) As MaxEventReturn
Calculator_Run_Proc = mxEventReturnTrue
' Get the total inlet flow
inflow = InStrm.Data("Total Flow")
' Copy the calling model's outlet stream data to the internal outlet streams.
InterfaceOut.ReverseCopy = True
InterfaceOut.Run (Step)
' Transfer inlet state/composition to outlets and sum outlet flow.
Dim flow As Double
tflow = 0#
Dim ni As Integer, sni As String, outstrmname As String, outstrm As StreamItem
For ni = 1 To 10
sni = ni
outstrmname = "OutStrm" + sni
Set outstrm = Me.GetMethodItem(outstrmname)
flow = outstrm.Data("Total Flow")
tflow = tflow + flow
Call InStrm.CopyData(outstrm)
Call Stream_Utilities.ThisModel.SetTotalFlow(outstrm, flow)
Call outstrm.Initialize(Nothing)
Next ni
End Function