Sending an object via a signal

Moderator: Moderators

Sending an object via a signal

Postby Joshua.Simpson@ngc.com » Wed Aug 12, 2020 4:02 pm

Hello,

I am creating a model to demonstrate the ability to send an object via a signal from one block to another and have the object be stored in a Queue inside the second block. My model is a simple stoplight with cars and pedestrians as the objects moving around the system. My question focuses on the cars in particular. Attached is an image of the model ibd ("StopLightModel.png").

StopLightModel.png


I am generating the cars inside of the CarGenerator block with the activity diagram in "CarGen.png".

CarGen.png


The cars are being read from an excel sheet and mapped to the CarGenClass. The car has various value properties along with two proxy ports needed for when the car is stored in the queue later on and will need to recieve info from the road and the stoplight (you can see this inside the two Road block instances).

From here, the car is sent via a SendSignalAction through the signal called "CarOnRoad" which has a property called a "Car" so that it can send CarGenClass objects (just sending cars). That signal travels to whichever road the car is on (determined by a value property from the excel sheet) and is recieved through an activity diagram in the image "WaitForCar.png". Here, the "Car" property is grabbed from the received signal and is subsequently put into the Queue called "CarQueueStraight".

WaitForCar.png


Here is the issue: When I run the model, a car is generated in the CarGenerator with a particular place in memory (see image "Memory1.png"). Once the signal is sent and then received by the Road, this car that has been sent to the Road now has a different place in memory (see image "Memory2.png"). This is fine, I guess, except for one major problem. As you can see when comparing the two images "Memory1.png" and "Memory2.png", the place in memory for the car itself has changed, however the two proxy ports retain the original memory association. In other words, the picture "Memory2.png" clearly shows that the car object in the Road and the car object's ports do NOT have the same place in memory. Thus, when I later try to send signals to these cars in the Queue, they don't respond at all because their ports still thing they belong to the previous place in memory.

Memory1.png

Memory2.png


Not only this, but the image "Variables.png" (will be attached in a comment below) shows the variable tab after running the model for a bit. You can see that some cars have been correctly generated and stored in the correct Queue exactly as I want them to. However, the section circled in red shows that NONE of the cars are executing their state diagrams (you can see the car's state diagram in the photo "CarAction.png"). In summary, whatever happened to the cars when they got sent from the CarGenerator to the Road via the SendSignalAction messed up the ports of the car and stopped/deactivated their state machines.

How can I get this to work? i just want to be able to send an object read from a spreadsheet from one block to another and have that object execute a state diagram while its at it. I know this is possible, and I know that my model is functioning correctly because I used the ALH API to do exactly what I described above and everything worked. However, the ALH API is not as intuitive and is more like "Copy-Paste"ing an object from one spot to another. I want to send an object via a signal.

Thank you for reading this long text. I appreciate the help.

-Josh
You do not have the required permissions to view the files attached to this post.
Joshua.Simpson@ngc.com
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Wed Jul 22, 2020 6:54 pm

Re: Sending an object via a signal

Postby Joshua.Simpson@ngc.com » Wed Aug 12, 2020 4:04 pm

Here are the images: "Variables.png"

Variables.png


"CarAction.png"

CarAction.png
You do not have the required permissions to view the files attached to this post.
Joshua.Simpson@ngc.com
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Wed Jul 22, 2020 6:54 pm


Return to Cameo Simulation Toolkits

Who is online

Users browsing this forum: No registered users and 0 guests