Structures and stuff

P

Thread Starter

phil wilshire

Hi,

Just thought I would add a bit here , hope I am welcome. I have been working on PLC type software for a while and have produced 3 or 4 engines.
I have also been working with a very experienced co worker Rick Jafrate who is from the GE Fanuc stable and was originally designing these things a few years ago.

We can help here and bring some solid software tools and techniques to the table if you wish.
Once again I hope we are welcome.

As far as structures are concerned I use a lot of " pointerless" structures. These can exist in shared memory and can me mapped into different
addresses by different programs. Each "pointer" is in fact an int offset from the head of the structure.

A simple macro pointer2Addr will create a void * pointer from the integer " pointer" using the base address.

e.g.
char * base_address = mapthememory();

void * ptr = pointer2Addr(index)

void * pointer2Addr(int index)
{
return (void *) &base_address[index];
}

this makes every thing easy.
You can also dump the memory to disk and use it on another system if needed.

As far as structures are concerned I have a standard head for any structure.

the head members are:-

int magic; /* what am I */
int size; /* how big I am */
int this; /* where I am useful believe me */
int next; /* the next one like me */
int prev; /* the last one like me */
int child; /* a child if I have one */
int parent; /* a parent if I have one */
char name[xx]; /* my name */


Doing this you can write a set of generic software routines to navigate any list.
The actual goodies in the structure appear after the standard header.

There may be too much in the header for your needs but I thing that memory is cheaper now so this should not matter.

A last point I use a generic shared memory package from the Real Time Linux guys.
Look in
http://crds.chemie.unibas.ch/PCI-MIO-E/
This allows you to simple share named memry regions between programs.

Any comments ???
I only browse the digests to get back direct to flame etc...

Thanks
Phil Wilshire

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
S
On Fri Jan 21 10:01:39 2000 phil wilshire wrote...
>
>Hi,
>
>Just thought I would add a bit here , hope I am welcome.

Indeed you are!

>the head members are:-
>
> int magic; /* what am I */
> int size; /* how big I am */
> int this; /* where I am useful believe me */
> int next; /* the next one like me */
> int prev; /* the last one like me */
> int child; /* a child if I have one */
> int parent; /* a parent if I have one */
> char name[xx]; /* my name */

Interesting, do you use this for every single data item in the data tables? If so why do you think it's better than just storing the data
items sequentially in shared memory? Since each Data table file can contain only 1 type of data, they will be of fixed size, thus referencing each one simply requires calculating its portion relative to the start of that shared memory segment.

--
Stan Brown [email protected] 843-745-3154
Westvaco
Charleston SC.

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
P

phil wilshire

Stan wrote:
>>the head members are:-
>>
>> int magic; /* what am I */
>> int size; /* how big I am */
>> int this; /* where I am useful believe me */
>> int next; /* the next one like me */
>> int prev; /* the last one like me */
>> int child; /* a child if I have one */
>> int parent; /* a parent if I have one */
>> char name[xx]; /* my name */
>
> Interesting, do you use this for every single data item in the data
> tables? If so why do you think it's better than just storing the data
> items sequentially in shared memory? Since each Data table file can
> contain only 1 type of data, they will be of fixed size, thus
> referencing each one simply requires calculating its portion relative
> to the start of that shared memory segment.

Stan,
This is what's nice about it.
You own the magic so it can be a table if you wish...

The manipulation code is a snap.

I'll dig some out and let you all have it over the weekend.


Thanks for the welcome
Phil Wilshire

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Top