I have a couple of questions relating to how PowerPmac and the IDE handle string arrays.
The guys writing the HMI application (running on a separate host PC) for our machine have asked that I store the machine alarm message strings in the Pmac. Creating and saving the 'string array' seems simple enough, I plan on having a PLC run at startup that will populate the shared user memory with all the alarm strings needed. The script code would be as shown below.
local indexStart,strgLen;
indexStart=16000; // byte offset into share user memory
strgLen=72; // default length of alarm string
stringIndex=sprintf((indexStart+(1*strgLen)),"Alarm Message 01");
stringIndex=sprintf((indexStart+(2*strgLen)),"Alarm Message 02");
.
.
stringIndex=sprintf((indexStart+(96*strgLen)),"Alarm Message 96");
At this point I plan on having a total of 96 alarm messages, of 72 characters each, so I'll need 96 commands similar to what is shown above. When a particular alarm is active, the strncpy command will be used to copy the message for the alarm into a separate buffer in user shared memory that the HMI app will poll to read and display the active alarm to an operator.
My first question - Is this the best way to populate string arrays?
Second question - Is there a way to easily display a string that is stored in user shared memory, in the IDE? I don't see an option to format data in the watch window as a string.
Third question - I'd like to echo the active alarm string to a port using the send instruction; for example to the IDE Unsolicited Messages window. But...strings for the send instruction look like they need to be defined explicitly in the send command. Is there a way to have the send command 'point' to a string in user shared memory?
There may be ways to handle this better in CPLCs but my C programming skills are not so good, so...script PLCs for now.
Thanks,
Kmonroe