Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Overview
GELLO code will be used to calculate the value of 'Total Cost'. It will retrieve the values from 'Number' and 'Cost' and return the result of one multiplied by the other. Click on the RHS in the pane next to IsCalculated for the 'Total Cost'. Then click on on the far right hand side of this pane, which is now a white background colour.
The first bit of GELLO code is prefilled and sets the context
No Format Context CEN_Apple_v1::ArchetypeRoot
Now let's set up a local variable to hold the value for instances of the archetype where 'Cost' is entered. Add the following code:
No Format Let cost: Integer = template.Apple.Cost.value.oclAsType(PQ).value
Same again for 'Number':
No Format Let number:Integer = template.Apple.Number.value.oclAsType(Integer)
- Test this code if you like with the compile button.
Next thing is to do the line that produces the result:
No Format Let result_Real: Real = cost * number
But 'Total Cost' is a Physical Quantity*, so the result needs to be returned in this form. This line of code just declares what needs to be returned by the GELLO v. 1 expression:
No Format --- PQ{value = result_Real, unit = '$'}
- Running in Preview Archetype:
- Don't forget to save the archetype!!
Table of Contents | ||||
---|---|---|---|---|
|