Following that tutorial (
https://www.youtube.com/watch?v=lhNvmjHRa0o ), I was able to create a custom viewpoint.
In the tutorial, a class Cost is created, with the attribute ‘objective’. Generating and using the viewpoint in Capella, it appear that I don’t know whether I can define the value of that attribute with, for instance, a Literal Numeric Value defined in a data package in an other part of my project.
My guess is that I have to bring some modifications to the ‘.ui.vptext’ file, but I’m quite a beginner in that subject, and some help would be really appreciated
I am not certain exactly what you are asking for, but it sounds like you would like to know how to type your attributes?
Your question actually decomposes into two seperate parts: the type of the attribute (string, int, float etc.) and the entry method of your attribute.
- The type of your attribute is set in your data.vptext file. When you add attributes to your object class, you need to type them (EX: “currentMass type ecore.EInt”, see Data.jpg). This sets what type the value associated with your attribute has to be. If within your viewpoint development you break this typing, the IDE will give you an error warning as usual in any coding language/IDE.
- The entry method for your attribute is defined in the ui.vptext signaled by a “Field” classifier (EX: “Field currentMassField label: “Current Mass” type text , mapped-to MassPlus.data.Mass.currentMass”, see UI.jpg). Here we set the field type to be “text”, and map it to our existing attribute in our data file. Capella does a really nice thing here by automatically including fail-safes. Although the field “text” can take any and all text entries (not just int), since we have mapped it to an attribute of type int, it will only save the entries that match the attribute type! This means that your attribute type is entirely defined in your data file, and the ui file only defines how a value change can be made. Capella will also automatically throw you an error if you try to match an attribute to a field that cannot take in the given type of values. For example, if we were to map our EInt type to a field type “checkbox”, Capella will give an error since checkboxes can only represent Boolean information, and thus it is impossible to communicate an integer value through that field.
Let me know if you have any other questions or if I need to clarify anything.
Thank you for your answer ! However, I think I was not precise enough in my question.
When I use the customized viewpoint, I can change its attributes on the “Properties” view, as shown in the image linked.
But, let us imagine that I have already defined my mass in a Data package previously, how will I manage to link that value with the one of the BasicMass ?
I also have an other question, quite unrelated to this one. In the BasicMass viewpoint, where is the sum of each subcomponent mass is done in the code ?
Thank you in advance for your answers,
Yes it does seem that I have completely misunderstood the question. I do not unfortunately have a lot of knowledge about the BasicMass custom viewpoint. As far as I know, it is not possible to link a BasicMass object with an existing Data object.
I have not looked at the code of BasicMass viewpoint so unfortunately cannot help with the second question.
Thank you fr your time anyway Daniil, the topic is then still open : I hope someone will provides us an answer !
regarding mass computation, it’s in the mass.diagram.vptext subfile. The file defines diagram extensions over the PhysicalArchitectureBlank diagram, and add a color customization on part containers, modifying background and foreground depending on a condition implemented in two services : isMassSaturated and isMassOverhead. Theses services are implemented in the java service file MassOpenJavaService.java, defined in the generated plugin org.polarsys.capella.vp.mass.design. You can notice some methods in this file are marked using @generated NOT to avoid modifications on viewpoint generation.
considering the extended object, kitalpha is based over a metamodel extension Mechanism. In the data.vptext file, you can create this extension. In the context of the “BasicMass” point of view, two new classes are created. The Mass class contains mass information for a component. And the link between capella objects and mass objects are made with the extension mechanism, here the PartMass extends the Part metaclass and link a Mass by inheritence.
If you want to refer an existing value, such as a LiteralNumericValue, you will have to declare an association. Like the declaration of mass attributes, you can create an association definition, to create an association. I can suggest you to check all the datavalue metamodel to select the correct destination metaclass.
myValue refers [1,1] external datavalue.LiteralNumericValue
With best regards,
Thank you for your answer. I made a short test and it worked exactly the way I wanted.