Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New way of accessing P vars - How do I enable it?
#1
Hello,

How do I configure my project for auto-generating the P vars in pp_proj.h so that I can access them by name in C code vs the old way where they were defined as an integers? I am in the process of converting my project in the new Sept 2011 IDE and want to know where this is.

Thanks,
KEJR
Reply
#2
In your C Program, if you want to use the new P-Variable method wherein you use the P-Variable's (Global Variable's) name directly in C, put this preprocessor directive in your program:

Code:
#define _PPScriptMode_    // PMAC Script-type access; type Global Variable name directly in C

If you want to use the old method, where the P-Variable's (Global Variable's) name, when used in C, is just an integer value corresponding to the P-Variable number (this is the default setting), use the following preprocessor directive in your program:

Code:
#define _EnumMode_            // PMAC enum data type checking on Set & Get global functions;
                             // Global Variable name returns an integer corresponding to the P-Variable number used

With the old method, you must access the P-Variable with pshm->P[MyGlobalVar] rather than writing MyGlobalVar directly in C.

This is actually listed at the top of any new Background C Program in comments when created in the new September 2011 version of the IDE.

Important Note: You must make this definition BEFORE you include pp_proj.h. E.g. in a Background C Program:

Code:
#define _PPScriptMode_
#include "../../Include/pp_proj.h"

Another note: You can look at how the new P-Variable mapping was implemented by opening up pp_proj.h under C Language-->Include from within the IDE.
Reply
#3
Hi KEJR,

Here is what I did:

in my Global definitions.pmh file I defined my variables:
Code:
global TestVar1, TestVar2;

and in my c program I wrote an example code:
Code:
#include <gplib.h>
#define _PPScriptMode_
#include "../../Include/pp_proj.h"

int main(void)
{
    InitLibrary();
    
    TestVar1++;
    TestVar2=exp2(TestVar1);
    
    CloseLibrary();    
    return 0;
}
Sina Sattari
Chief Engineer
Delta Tau Data Systems, Inc.
Reply
#4
Thanks for the prompt replies.

It seems that neither my old project or a newly created on is performing the proper define statements in pp_proj.h even after defining _PPScriptMode_

I did the same thing as Sina with a new project and it doesn't work. See the code:

Code:
#include <gplib.h>   // Global Gp Shared memory pointer
//----------------------------------------------------------------------------------
// pp_proj.h is the C header for accessing PMAC Global, CSGlobal, Ptr vars
// _PPScriptMode_ for Pmac Script like access global & csglobal
// global Mypvar - access with "Mypvar"
// global Myparray(32) - access with "Myparray(i)"
// csglobal Myqvar - access with "Myqvar(i)" where "i" is Coord #
// csglobal Myqarray(16) - access with "Myqvar(i,j)" where "j" is index
// _EnumMode_ for Pmac enum data type checking on Set & Get global functions
// Example
// global Mypvar
// csglobal Myqvar
// "SetGlobalVar(Myqvar, data)" will give a compile error because its a csglobal var.
// "SetCSGlobalVar(Mypvar, data)" will give a compile error because its a global var.
//------------------------------------------------------------------------------------
#define _PPScriptMode_    // uncomment for Pmac Script type access
// #define _EnumMode_            // uncomment for Pmac enum data type checking on Set & Get global functions        // uncomment for Pmac Script type access


//----------------------------------------------------------------------------------
// To use the functions defined in the Libraries, create a prototype of the function
// in this file or in a header file that is included in this file.
// For Example:
// If a Library project has been created with the following function and you intend to use
// that function in this C file:
// int MyFunction(int MyVar)
// {
//    return MyVar*10;
// }
// Then a prototype of this function must be created in this c file or in a
// header file that is being included in this file. The prototype is the following:
// int MyFunction(int);
//------------------------------------------------------------------------------------

#include "../../Include/pp_proj.h"

int main(void)
{
    InitLibrary();
    
    foo++;
    bar--;
    //Put your code here
    CloseLibrary();    
    return 0;
}

Where foo and bar are "global" in global definitions.pmh file. The pp_proj.h file confirms that foo and bar are 8192 and 8193 repectively.

I chose the "repair" option on the installation over the Feb 2011 release. Should I try to completely uninstall and reinstall the software?

Also note that our PCs are logged into domains on the server with "my documents" residing on the network. This does tend to confuse some software. For a while the addins were misbehaving although I didn't have to mess with that in the last go-around so I think that much is fixed. I mention this just on the off chance that it has something to do with this not working.

Thanks,
KEJR
Reply
#5
I also enabled just the enum mode and I am not getting the enumerations, just the old style defines:

Code:
//***********************************************
// "pp_proj.ini" generated C header file
// For accessing PMAC Global, CSGlobal, Ptr vars
//***********************************************
#ifndef _PP_PROJ_H_
#define _PP_PROJ_H_
#define foo 8192
#define bar 8193
#endif //_PP_PROJ_H_

So it would appear that something is missing, right?

Thanks,
KEJR
Reply
#6
Hi KEJR

I just thought I would add that your example works (script and enum) on my (Sept 1.4.0.62 IDE, 1.4.0.27 firmware) system where I did an uninstall-reinstall. I do remember seeing the _PPScriptMode_ not working at some point on my systems and I think that was with an upgraded IDE.

Does your pp_proj.h file only have entries for foo and bar in the 'bottom section'? Mine contains the following (edited):

Code:
#ifdef _PPScriptMode_
...
#define    foo    pshm->P[8192]
#define    bar    pshm->P[8193]
...
#else
#ifdef _EnumMode_
enum globalP {_globalP_=-1
,foo=8192
,bar=8193};
...

#else
// ***** Standard default mode *****
#define foo 8192
#define bar 8193
#endif
#endif

I would also mention I found uninstalling and reinstalling a bit of a hassle to get past the "Cannot find one or more components" "CreateFile failed" errors, deleting registry keys, InstallShield folders, MySQL installs and reinstalling VS shell stuff which are mentioned in other posts...

I really like the fact that the script mode has far more readable lines of code and uses the fastest P[] access method. I do however have some other questions/requests for my purposes but I won't hijack your thread.

Dave
Reply
#7
(10-18-2011, 01:02 AM)daves Wrote: Does your pp_proj.h file only have entries for foo and bar in the 'bottom section'? Mine contains the following (edited):

My file *just* has the #define 's and nothing else. I think I'll try uninstall - re-install and hope that I don't have the problems you did. I'll check your other posts, I recall seeing something like that in the last few weeks which lead me to do the repair instead of uninstall/reinstall.

(10-18-2011, 01:02 AM)daves Wrote: I really like the fact that the script mode has far more readable lines of code and uses the fastest P[] access method.

I was doing alot of application coding in C with lots of Ptr vars and global vars and I found myself passing a global var index to an IO routine more than I care to admit. As you can imagine, this is very dangerous when dealing with real equipment. I had recommended doing something with enums so that the two types could be type checked, but DT came back with the native assign to pshm->P[8192] which is *so* much better IMHO. I had created a macro called "Var()" which did the same thing, but it is so much uglier in the code when you do "if" statements and things like that. I appreciate you not hijacking the thread, but I look forward to hearing your points in the other thread. :)

Thanks Dave,

KEJR
Reply
#8
OK, this was fixed by the uninstall and re-install.

I also noticed that my antivirus popped up a message that it blocked projppssfx.exe or something like that during install. I then disabled antivirus and re-ran install with the repair option. Upon rebooting all was well. This may have been the root cause.

Thanks,
KEJR
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)