forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Passing Data between applications

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
DavidR
Contributor
Contributor


Joined: 05 Aug 2003
Posts: 83
Location: Bethel Pennsylvania U.S.A.

PostPosted: Thu May 17, 2007 1:58 pm    Post subject: Passing Data between applications Reply with quote

I'm struggling with the best way to pass data between multiple VDS applications. If possible I'd like to avoid additional external dll's but would consider it if it's the only reasonable option. It needs to work with Win98 & XP.
Here's the application. A PC has a digital I/O card installed. The card has 48 digital I/O, each of which can be configured as either an input or an output. I have created a VDS application that can read the status of each input and can turn on/off each output. This app utilizes an external (non-vds) dll and works very well.
What I want is to create a "memory table" of both the inputs and the outputs. In the finished product my existing application will examine the inputs and update the input memory table with the status. Then it would examine the output "memory table" and set the real world outputs to match. This process would continuously scan I/O and update at (hopefully) less than 100ms. In other words 10 times per second or faster in order to avoid missing short duration inputs.
My other application(s) would then read the input table, make the appropriate decisions based on the input conditions and set the appropriate outputs or perform administrative functions.
I've considered using file I/O to store and read data but that seems very cumbersome and would result in a lot of disk activity at the scan rate I desire.
Another option is to create Registry entries and read/write to them
This seems to make more sense but I don't know how windows would handle that much registry access. Is the registry written to disk every time it's changed? This is an area I'm not too clear on.
The ideal thing would be to simply reserve a small range of memory addresses that could be accessed by each application. I've tinkered with the @addr() function but while I can get the memory location of a variable and could pass that location to another application through a registry key, I haven't been able to figure out how to get the value back into a variable in that application.
Perhaps I'm making this too complicated. I would appreciate any input and suggestions. An API function perhaps?
Thanks........
............David
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Thu May 17, 2007 8:53 pm    Post subject: Reply with quote

Have you looked at VDSMEM.DLL?
_________________
John Trappett
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Fri May 18, 2007 4:50 am    Post subject: Reply with quote

You could also use VDSIPP, create a localhost server and applications would connect locally to the server application and send data back and forth - using UDP or TCP protocol.

One benefit to this is you could add a remote feature to your software which allows remote execution over the internet.

But if you don't want remote access, then you will need to add checks into your application so no outside IP's are accessing the server and manipulating any data.
Back to top
View user's profile Send private message
DavidR
Contributor
Contributor


Joined: 05 Aug 2003
Posts: 83
Location: Bethel Pennsylvania U.S.A.

PostPosted: Mon May 21, 2007 4:54 pm    Post subject: What about the registry Reply with quote

Thanks for the suggestions.
I looked at VSDMEM.DLL and it looks like it would work great for the small amount of data I need to pass.
What about using the registry for passing data between applications. Any ideas how much overhead/latency would be incurred using Registry functions as opposed to VDSMEM or VDSIPP?
One obvious advantage would be that it wouldn't require a dll and any application that can read or write registry keys could access the data.

Any thoughts?

...............David
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Mon May 21, 2007 5:33 pm    Post subject: Reply with quote

The registry is stored in files on your harddrive, and would be the same as using INI files in terms of overhead/disk activity.

I have used something in C, but I'm not sure if it can be done in VDS.
It uses Global Atoms, which are basically strings stored in RAM.

-Use GlobalAddAtomA to store your string, and it returns the identifier of the atom.
-Pass that atom identifier to your other program(s) with PostMessageA
-Get the message with VDS's OPTION MSGEVENT.
-Use GlobalGetAtomNameA to retrieve the string stored in the atom.
-Use GlobalDeleteAtomA to delete the atom after reading it.

This could be problematic with the way you have use @addr and the fact that VDS doesn't pass all messages to your MSGEVENT, but worth a try.

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Mon May 21, 2007 6:18 pm    Post subject: Reply with quote

SnarlingSheep, I tried the functions you suggested. I found that there is also a GlobalFindAtomA function with which you should be able to search for text inside and atom after which a Atom identifier has to be returned. Unfortunately, I couldn't get it to work. If you comment out the specified line, it does work however.

Code:
#define function,ReadAtom
#define command,WriteAtom

# Load DLL
loadlib kernel32.dll

# Write text to the atom
WriteAtom MyPrefix,Hello world!

# Read text from the atom
%%AtomValue = @ReadAtom(MyPrefix)
info %%AtomValue

# Unload DLL
freelib kernel32.dll

# Stop script
stop

:WriteAtom
# Write to the atom and prefix the text.
%%Atom = @lib(kernel32.dll,GlobalAddAtomA,INT:,STR:%1|%2)
exit

:ReadAtom
# %b for buffer, 255 bytes is the maximum length
%b = @fill(255)
# This will look for the atom with the specified prefix. Doesn't work right
# now. When commenting out the next line, everything will work.
%%Atom = @lib(kernel32.dll,GlobalFindAtomA,INT:,STR:%1)
# Read atom value and return the value in the %b variable to the main script.
%z = @lib(kernel32.dll,GlobalGetAtomNameA,INT:,INT:%%Atom,@addr("%b"),@len(%b))
# Remove atom from memory.
%z = @lib(kernel32.dll,GlobalDeleteAtom,INT:,INT:%%Atom)
exit %b


My idea was to simply put a value in memory and to prefix it with an unique identifier which is only used between two applications, so that they can communicate by prefixing all data with it and by removing old Atoms. Does anybody know how to let the GlobalFindAtomA function to work?

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Mon May 21, 2007 6:25 pm    Post subject: Reply with quote

The problem with that is, GlobalFindAtom searches for the exact string, it doesn't just search for atoms with a certain prefix(That's the way I read it anyway).

Its really too bad that you can't just edit an atom once you add it. That way you could add a Global Atom, store the identifier to it in the registry/ini and continue to use that identifier to store other Atoms later.

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Tue May 22, 2007 1:26 pm    Post subject: Reply with quote

Here's a few other ideas Idea You could use DDE? Or you could also use @SendMessage() and a Message Hook with a user defined Message ID? I don't know if your programs have a Dialog or not?

I do have a GadgetX demo of how to share data between VDS applications. The demo actually shows 3 distinct ways of sharing data both encrypted and unencrypted all in memory. One of the ways GadgetX allows the sharing data does not require a Dialog. It's just a global memory buffer that all applications that attach to GadgetX has access too.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
DavidR
Contributor
Contributor


Joined: 05 Aug 2003
Posts: 83
Location: Bethel Pennsylvania U.S.A.

PostPosted: Tue May 22, 2007 1:49 pm    Post subject: Reply with quote

dragonsphere wrote:
Here's a few other ideas Idea You could use DDE? Or you could also use @SendMessage() and a Message Hook with a user defined Message ID? I don't know if your programs have a Dialog or not?

I do have a GadgetX demo of how to share data between VDS applications. The demo actually shows 3 distinct ways of sharing data both encrypted and unencrypted all in memory. One of the ways GadgetX allows the sharing data does not require a Dialog. It's just a global memory buffer that all applications that attach to GadgetX has access too.


Hmmm... I forgot about DDE, I've used that in other applications but for some reason hadn't really considered it for this. I wasn't really planning on having Dialogs open for every program but I suppose I could.. I'll have to think about that approach as well. GadgetX sounds like a neat idea but it would require an additional DLL which I was trying to avoid..
I suppose it's too late to put in a request for VDS6 to allow "Global" variables Sad

In any case, thanks for the suggestions.. I'll do some experimenting and see which works best!

...............David
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Tue May 22, 2007 2:15 pm    Post subject: Reply with quote

David,
You can hide the dialogs. They don't need to be displayed.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group