Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
model:creating_a_model_in_python [2025/02/18 03:30]
optrix
model:creating_a_model_in_python [2025/02/18 05:02] (current)
optrix
Line 32: Line 32:
 <code> <code>
 #My Tank Model #My Tank Model
-@mdl.part("Tank Model")+@mdl.part("Online Tank Model")
 def TankModel(mod): def TankModel(mod):
    pass    pass
 </code> </code>
  
-Once we've created the model function, we can add it to the [[host]] object we created earlierat the bottom of our code.+The '@part' decorator marks the function defines a **model**. Inside the function, we can define which specific inputsoutputs, constants and calculations we need.
  
-This defines our (currently empty) model, and adds that model to our running system with the name 'Tank'.+The human readable name for our model is 'Online Tank Model'.
  
 ===Filling in the Inputs=== ===Filling in the Inputs===
Line 88: Line 88:
 For example, the function here will be... For example, the function here will be...
  
-<code>(LevelPerc.num() / 100) * Capacity.num()</code>+<code>(float(LevelPerc) / 100) * float(Capacity)</code>
  
-//Note that the 'numfunction converts a DataPoint to a floating-point number. Some points will be strings, so it's important to always cast the value to a number if you're using it as one.//.+//Note that data points aren't simple numbers you'll need to cast them to floats or integers if you want to use them as numeric values. If you need to access the raw value, use **.value**.//.
  
 ==Used Points== ==Used Points==