I am trying to implement a mechanism to send alarm SMS. For this, I have created an Alarm Class with a Notification Action which calls a POU. This POU implements IAlarmNotifiable making it selectable in the Alarm Class configuration. IAlarmNotifiable has an Execute method which is called by the alarm class.
Now, I want to extract the alarm message of the triggered alarm. The Execute method comes with a VAR_INPUT itfAlarm: AlarmManager.IAlarm which supplies a method called GetMessage. The help text says:
Returns the message text, that has been configured for the alarm. The result is a pointer to the buffer, where the message text is stored
The type of the result is CharBufferPtr, and at some place I read that it can be interpreted as a pointer to string. But I cannot manage to extract the alarm message, all I get are numbers. I have tried the following:
Solved it! The simple answer was to declare a variable as POINTER TO STRING and assign the GetMessage result to that variable. Then, the ^ operator can be used to extract the message as string.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to implement a mechanism to send alarm SMS. For this, I have created an Alarm Class with a Notification Action which calls a POU. This POU implements IAlarmNotifiable making it selectable in the Alarm Class configuration. IAlarmNotifiable has an Execute method which is called by the alarm class.
Now, I want to extract the alarm message of the triggered alarm. The Execute method comes with a
VAR_INPUT itfAlarm: AlarmManager.IAlarm
which supplies a method called GetMessage. The help text says:The type of the result is CharBufferPtr, and at some place I read that it can be interpreted as a pointer to string. But I cannot manage to extract the alarm message, all I get are numbers. I have tried the following:
So how do I get access to the alarm message as clear text? (In this case, "Larm 1")
Solved it! The simple answer was to declare a variable as POINTER TO STRING and assign the GetMessage result to that variable. Then, the ^ operator can be used to extract the message as string.