Passive Class with Usermade attribute type [message #1769580] |
Tue, 01 August 2017 17:40  |
Eclipse User |
|
|
|
I'm not sure how to access methods in my nested passive class
Currently I have a class called Zombie which holds int x, int y and int d as attributes. Inside this class are operations to change x and y, change d, get x, get y and get d. I also have another passive class called Vector that has an attribute called zVector that I have set the type to std::vector<Zombie>. The passive class Vector contains two methods, one that lets me give it a Zombie and it will push that Zombie into the zVector attribute and one that asks for an index and returns the zombie from zVector that is stored at that index
Inside of my capsule I have an attribute called zombieVector that is type Vector, after checking for specific conditions I push several Zombie with there x,y and d values set into the zVector attribute of the Vector class. Later on in a different transition I try to access the x value of the first zombie through zombieVector.getZombie(0).getX());, this however results in a seg fault
I'm not quite sure what i did wrong or how I'm supposed to do this properly so any help would be appreciated
Thanks
Chris
|
|
|
|
|
Re: Passive Class with Usermade attribute type [message #1769705 is a reply to message #1769700] |
Wed, 02 August 2017 15:51   |
Eclipse User |
|
|
|
Sorry, I can't find anything obviously wrong with your model or the generated code.
I can't compile it however, as there seem to be some issues in the Calculation capsule, like an undefined namespace "cv" and undefined type "Mat".
I suggest trying to make a minimal model with only the Vector class, the Zombie class, a capsule like ZombieBehaviour and a capsule like Calculation (which sends the Zombie), but with much simpler state machines and action code, with only one or two states, as few ports as possible, etc. Try creating a single Zombie in a vector in the sender and send only that. Try sending only one parameter in the message.
This might help narrow down the potential problems.
|
|
|
|
|
|
Re: Passive Class with Usermade attribute type [message #1769929 is a reply to message #1769729] |
Sun, 06 August 2017 07:04  |
Eclipse User |
|
|
|
I'm not sure if this is specifically related to Papyrus-RT or if its just a c++ problem but after modifying the producer and consumer model you posted earlier I realized that I can't change the value of the label in the consumer capsule.
I couldn't quite think of a reason as to why i couldn't though, if the code gets executed the only reason would be that i'm changing the memory of some other location rather than the location of the label however when changing the value of label you used this-> which should specify that that the value inside the class should be changed and not some other value.
I will attach your model with the changes I made
|
|
|
Powered by
FUDForum. Page generated in 0.06003 seconds