| View previous topic :: View next topic |
| Author |
Message |
DavidR Contributor

Joined: 05 Aug 2003 Posts: 83 Location: Bethel Pennsylvania U.S.A.
|
Posted: Thu May 17, 2007 1:58 pm Post subject: Passing Data between applications |
|
|
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 |
|
 |
trapper Contributor


Joined: 28 Jan 2005 Posts: 112 Location: Brisbane, Australia
|
Posted: Thu May 17, 2007 8:53 pm Post subject: |
|
|
Have you looked at VDSMEM.DLL? _________________ John Trappett |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Fri May 18, 2007 4:50 am Post subject: |
|
|
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 |
|
 |
DavidR Contributor

Joined: 05 Aug 2003 Posts: 83 Location: Bethel Pennsylvania U.S.A.
|
Posted: Mon May 21, 2007 4:54 pm Post subject: What about the registry |
|
|
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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon May 21, 2007 5:33 pm Post subject: |
|
|
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 |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Mon May 21, 2007 6:18 pm Post subject: |
|
|
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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon May 21, 2007 6:25 pm Post subject: |
|
|
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 |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Tue May 22, 2007 1:26 pm Post subject: |
|
|
Here's a few other ideas 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 |
|
 |
DavidR Contributor

Joined: 05 Aug 2003 Posts: 83 Location: Bethel Pennsylvania U.S.A.
|
Posted: Tue May 22, 2007 1:49 pm Post subject: |
|
|
| dragonsphere wrote: | Here's a few other ideas 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
In any case, thanks for the suggestions.. I'll do some experimenting and see which works best!
...............David |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Tue May 22, 2007 2:15 pm Post subject: |
|
|
David,
You can hide the dialogs. They don't need to be displayed. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
|