FloWorks products
How FloWorks uses products (or not)
All FloWorks objects have a product type defined. FloWorks has made a conscious choice not to transfer product types automatically from one object to the next: products only affects the product stored in or flowing through the object. This gives you, as a modeller, a lot of flexibility. For example, you can quickly build a model in which product types are split, mixed or blended, without having to tell FloWorks anything about the densities and component mixes of your products. Of course, if you do require that level of detail, FloWorks allows you to implement it yourself.
The product type usually changes the color of the fluids in or flowing through the object, but as explained above, the color may change instantly upon entering a next object. There are a few exceptions to this rule:- While collecting ingredients, the flow mixer will keep the product types from the previous objects. After mixing, however, the mixer changes the product type of its contents to the final product as defined on the FlowMixer.
- The conveyor reads the product type from the input ports, and displays its contents as stacked layers. However, upon reaching the end of the conveyor, the outflow will get the product type of the topmost layer - considering the contents as a stack of bulk of which only the product on top remains visible.
- The flow pipe has an option of passing its product type downstream. You can explicitly enable this in the "product out change" trigger, when using multiple connected flow pipes to model a network of multi-product pipelines.
Numeric vs. named products
FloWorks products can either be simple numbers, that you can use in any way that makes sense in your particular model; or they can be predefined products with fixed names and colors from a table that you need to fill before (or while) you create the model. The next two sections describe these two options in more detail.
Numeric product types
When you start a new FloWorks model, product identifiers are by default positive integer numbers: FloWorks objects can have product 1, 2, 3, etc. Each product ID is automatically assigned a color. The pallette of available colors is shown below. The number of products is not limited, but the pallette below will wrap around, e.g. product #21 will have the same color as product #1.
Product ID | HTML color | (R, G, B) | Preview |
---|---|---|---|
1 | #008000 | (0, 128, 0) | |
2 | #0000FF | (0, 0, 255) | |
3 | #FFFF00 | (255, 255, 0) | |
4 | #FF8000 | (255, 128, 0) | |
5 | #800080 | (128, 0, 128) | |
6 | #00FF00 | (0, 255, 0) | |
7 | #FF0080 | (255, 0, 128) | |
8 | #808080 | (128, 128, 128) | |
9 | #408080 | (64, 128, 128) | |
10 | #00FFFF | (0, 255, 255) | |
11 | #804000 | (128, 64, 0) | |
12 | #0080FF | (0, 128, 255) | |
13 | #BFBFBF | (191, 191, 191) | |
14 | #FFFFFF | (255, 255, 255) | |
15 | #71B10E | (113, 177, 14) | |
16 | #C6D9D8 | (198, 217, 216) | |
17 | #1D02A3 | (29, 2, 163) | |
18 | #722A6D | (114, 42, 109) | |
19 | #7AEB38 | (122, 235, 56) | |
20 | #FF0000 | (255, 0, 0) |
User-defined product types
It is possible to define a custom set of products and their colors, instead of the default numeric product IDs. You can toggle to Product Table mode by clicking the Product Table button () to the right of the Product Type field on the Settings tab of any FloWorks object. This button brings up the Products Table editor:
To edit a product, select it on the left-hand side. The fields on the right will change to allow you to edit the properties of this product.
The buttons at the top allow you to:
- Add a new product to the list of products
- Remove the selected product from the list. All products below it will shift up.
- Remove the product table and go back to using numeric product IDs.
- / Move the product up and down in the list.
All other products
The All other products color picker indicates which color will be used for all FloWorks objects which do not have a product from the list. FloWorks objects may get a product which is not in the list because the product they were using was removed, because they had a numeric product ID (see previous section) higher than the number of products you define in the table, or because you have explicitly set the product ID (see previous section) higher than the number of products defined in the table.
Defining mixer recipes
Usually in FloWorks, flow mixers have locally defined recipes. This means that each flow mixer has a recipe table which defines the steps and ingredients required for each step. Since these recipe tables are not shared between two mixers, the ingredients table will reference specific input ports to decide from which input object an ingredient can be collected.
It is however possible to define the recipe for a specific product not locally on a single mixer, but
globally in the model, so that multiple mixers in the model can
mix the same product. These recipes are defined in the product table, and can then be loaded in the recipe
table of a mixer using the "Load recipe" trigger option or
the FlowMixer.loadrecipe
method (see the class reference).
Entering a global mixer recipe is similar to the local mixer interface with one major difference: because different mixers in the model may acquire the same ingredient from different input ports, ingredients for global recipes are defined by product types. When a global recipe is loaded in a mixer's current recipe, the mixer uses its own Product Source trigger to decide from which specific input port each ingredient should be acquired.
To define a global recipe for a product, first make sure all ingredients have been defined. Then for the product you want to mix, check the "Define recipe for Flow Mixer" checkbox and use the Add button to add one or more steps for the recipe. The screenshot below shows an example of a global recipe.
The following screenshot shows how a "Load Recipe" event is added to the Reset trigger of a specific mixer and how its Product Sources table is filled.
Finally we can confirm that, after resetting the model, the global recipe for Strawberry Ice Cream has indeed been loaded on the mixer and that the general references to the ice cream ingredients have indeed been replaced with specific input port numbers according to the Product Sources table.
The product
property
When accessing FloWorks objects through FlexScript coding, you should use the FlowObject
class (see the class reference for more information).
This class has a property product
, which can be used to request or
change the current product. Note that most FloWorks objects do not automatically
change their product on reset, so if you change the product of an object during the run it will not change
back to its initial product when you reset the model.
The type of the product property is a Variant
that can take the
following values:
-
When using numeric product IDs
the
product
will always be a number. If the product is not applicable, for example because you are requesting the outflow product of an empty conveyor, the number zero will be returned. For example:FlowObject source = model.find("FlowSource1"); source.product = 3; // Returns a Variant with numeric value 3 return source.product;
-
When using a user-defined product table the
product
will usually be a string with the product name. For example, assuming you have defined a product called "My Product":FlowObject source = model.find("FlowSource1"); source.product = "My Product"; // Returns a Variant with string value "My Product" return source.product;
If you are using a user-defined product table and you know the internal product ID, you can still use that
in the product setter, for example you can replace the second line in the example above by
source.product = 1
. If "My Product" corresponds to product ID 1,
the last line will still return a Variant containing the
string value "My Product". However,
if no product in the table has internal ID 1, the last line will return a Variant with numeric value 1 and
the product will be colored according to the
"All other products" color defined in the product table.
In case the product is not applicable, for example because you are requesting the outflow product of an
empty conveyor, the empty variant nullvar
will be returned.
Converting using GetFlowProductId
When using a user-defined product table, if necessary you can use the function GetFlowProductId(string productName)
to find the numeric
product ID corresponding to the named product. This function will return the number zero (0) if the product
name is not a valid name in the table.