Jump to content
OMRON Forums

Reading PMAC IDE defined globals within C# app running on linux


KEJR

Recommended Posts

Hello, I am in the process of writing a C#/GTK# application for an HMI for the Power PMAC. It will run on the Power PMAC using the Mono runtime. I need to access PMAC Global variables defined in the IDE. Since the IDE is generating a C header file with the P variable names how do I access these from the C# language (since it doesn't have #include directives in the preprocessor like C/C++ does)? I would prefer not to use the command line interpreter to parse the variable name if possible for type checking reasons as well as efficiency. Thank you, KEJR
Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

The best way to do this is with some newer C API functions named GetPmacVar() and SetPmacVar(). These take in a string and quickly decide if the string is reachable from shared memory or not then take the most efficient route. j = GetPmacVar("MyVar", &dAnswer); These functions have been in firmware for awhile but have recently been improved. I suggest you get firmware newer than version 1.0.0.170 when you do speed testing.
Link to comment
Share on other sites

Will the interpreter that matches the string to the PPMAC variable be able to handle differences in case (e.g. if you forgot to capitalize a letter, or vice versa)? This could mitigate some simple problems. I have to admit that I am somewhat concerned that a variable name spelling error will result in a runtime error (as opposed to a compile time error), but it is probably not as much of an issue for the HMI as it would be for the realtime machine control. Thank you, ~Ken
Link to comment
Share on other sites

The names you give variables are case sensitive so if you have the case wrong and there is no matching variable you will get an error returned by the function so checking for valid returns can make your code more robust. If the wrong case means you get the wrong data (i.e. in01 or In01 are both valid names in the project) we can not do anything. In the future (hopefully in 6 months) a PPmacServer will be available. This will allow C# programs to execute remotely or on the PPmac using the same communications which means the same program can execute in either place. The server will have the functions that use an auto generated class containing the PPmac variables. In this system errors will be caught at compile time.
Link to comment
Share on other sites

Hello, Will the auto generated class be similar to the auto generated header file (when using C), in that the class members will contain P, Q, and M variable [i]indeces[/i] (which then get passed to SetGlobalVar(), etc)? Or will the class members actually contain the actual *[i]values[/i]* reported by the PPMAC? Either way it sounds like a nice option. I'm curious so that I can write our HMI library to accommodate different method overloads if we decide somewhen down the road to change to the PMAC server you described. Thank you, KEJR
Link to comment
Share on other sites

It is still in the idea phase so its hard to be specific. We want to address the problem of catching errors at compile time vs. execution time. Secondary is communication speed of the ASCII port since it is pretty fast anyway. Current idea is to make a big class that you use something like this: myInpos = ppmac.Motor[1].InPos; or myVar = ppmac.myLineSpeed; But until it is working I can not suggest much.
Link to comment
Share on other sites

  • 3 months later...
Guest
This topic is now closed to further replies.

×
×
  • Create New...