Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » Passive Class with Usermade attribute type(Accessing Methods in Nested Passive Classes and Attributes)
Passive Class with Usermade attribute type [message #1769580] Tue, 01 August 2017 21:40 Go to next message
Christopher Won is currently offline Christopher WonFriend
Messages: 11
Registered: July 2017
Junior Member
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 #1769581 is a reply to message #1769580] Tue, 01 August 2017 21:47 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Can you share your model or the generated code?
Re: Passive Class with Usermade attribute type [message #1769700 is a reply to message #1769581] Wed, 02 August 2017 18:46 Go to previous messageGo to next message
Christopher Won is currently offline Christopher WonFriend
Messages: 11
Registered: July 2017
Junior Member
Sorry for the late reply, here is my model
Re: Passive Class with Usermade attribute type [message #1769705 is a reply to message #1769700] Wed, 02 August 2017 19:51 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
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 #1769717 is a reply to message #1769705] Wed, 02 August 2017 21:09 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
I've created a small example (attached) that shows that it should work, so I'm guessing that the problem is somewhere else in your code.

By the way, in several places you access directly the zVector's elements with the [] operator, while you are defining a getZombie method in the Vector class.

Re: Passive Class with Usermade attribute type [message #1769728 is a reply to message #1769717] Wed, 02 August 2017 23:06 Go to previous messageGo to next message
Christopher Won is currently offline Christopher WonFriend
Messages: 11
Registered: July 2017
Junior Member
Sorry about that, I forgot my project uses openCV so you would have to download that for it to work. Unfortunately my generated CVT folder is too large to attach so I'll attach the file generated after I make my program, however I'm not sure if you'll be able to run it without the rest of the files or openCV

[Updated on: Wed, 02 August 2017 23:09]

Report message to a moderator

Re: Passive Class with Usermade attribute type [message #1769729 is a reply to message #1769728] Thu, 03 August 2017 00:16 Go to previous messageGo to next message
Christopher Won is currently offline Christopher WonFriend
Messages: 11
Registered: July 2017
Junior Member
I found it, I was using an older version of the image that had no zombies yet so it had nothing to push into the vector and therefore was returning a segfault when i was trying to access it

Sorry about that
Re: Passive Class with Usermade attribute type [message #1769929 is a reply to message #1769729] Sun, 06 August 2017 11:04 Go to previous message
Christopher Won is currently offline Christopher WonFriend
Messages: 11
Registered: July 2017
Junior Member
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
Previous Topic:Using timeout in action code and querying current state in another state machine
Next Topic:Papyrus-rt 0.9 Getting_Started: cannot select protocol for port
Goto Forum:
  


Current Time: Sat Nov 09 04:13:53 GMT 2024

Powered by FUDForum. Page generated in 0.04184 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top