Sign in to follow this  

Comunicating Programs

This topic is 4246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. Im making a small program for my dad which involves 2 little cars, now one of the cars should move, depending on what a variable from matlab says the distance is. My problem is, how do i get that variable in matlab, to be passed on to my C++ program. I have thought of using a file, however this would really need to be dynamic, so that as soon as the variable is changed, it will affect the distance of the car at the same time. Does anyone know what i should do for this?

Share this post


Link to post
Share on other sites
With Windows, you can set up a file change notification so that your application receives a special message when the file - that you register for monitoring - changes.

See FindFirstChangeNotification and it's "sister" functions on MSDN.

Share this post


Link to post
Share on other sites
Is there a way, to make one program "send" the information in the variable to the other. The FindFirstChangeNotification method seems to use files, which is not what i want (unless i read the description wrong)

Share this post


Link to post
Share on other sites
If you go to the Mathworks site for matlab you will find the information you need.

Look at this.. http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/

Look for the COM and DDE capabilites. This will allow your program to directly communicate with Matlab and Matlab to communicate with your program. This should do all that you need.

theTroll

Share this post


Link to post
Share on other sites
Quote:
Original post by Kris2456
Is there a way, to make one program "send" the information in the variable to the other. The FindFirstChangeNotification method seems to use files, which is not what i want (unless i read the description wrong)


You specifically said that you thought about using a file for this purpose, so I gave you advice on how to do that.

However, if Matlab indeed supports using COM interfaces, it would probably be easier to go for that route instead of custom files.

Share this post


Link to post
Share on other sites
I had a trawl through their website, however i could not find specifically how to integrate my two programs. Do any of you know maybe a simpler tutorial (something where i can learn about COM's) that i could use. Thanks in advance.

Share this post


Link to post
Share on other sites
COM is a pretty big subject. Just do a search on google for COM, basics and what langauge you are using. It is going to take you a little bit of time to get the COM basics down so you can integrate your program.

theTroll

Share this post


Link to post
Share on other sites
Is the variable or information you're talking about, somehow displayed in matlab (whatever that is), such as in a label of some sort? If so, get WinSpector , and run it while matlab is running, figure out which control is the one with the information (Make it show an example value such as 1337 which you could then identify within winspector), after doing so, write down the specifications (Handles, etc.) and the you can use the FindWindow calls (I believe you'll also need FindWindowEx to find the control within the window?) to retrieve the handle to the control, you can then do a SendMessage or GetWindowText (Or what was it called? I think that's what it was called) on it to retrieve the value. Polling could be a bit inefficient, but this is probably the most dirtiest way you can do what you want, you can for example poll ever second to second and a half probably, see if the value has changed and act accordingly. (Possibly 'hooking' might be of some use here? Thugh I don't know exactly how it'd be implimented)

EDIT: I don't know much about what the program you're talking about is, but I just skimmed over the docs and it seems like you can build your own subroutine into it, which you could then possibly use to inform your own program of the value changes?

Just my two cents.

Share this post


Link to post
Share on other sites

This topic is 4246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this