Examples/applications
10.2 RF182C user application
RF182C communication module
92
Operating Instructions, 10/2010
// (ReceiveCallback is asynchronous)
lock (ReceiveBuffer)
{
for (XMLTag tag = FirstTag(); tag != null; tag = FirstTag())
{
// Extract the parsed message and append it
String message = ReceiveBuffer.Substring(tag.startIndex, tag.length);
AppendInMessage(message);
// Remove parsed message from ReceiveBuffer
ReceiveBuffer = ReceiveBuffer.Substring(tag.star tag.length);
// See if we got information about detected tags
if (message.Contains("<tagCount>"))
{
if (message.Contains("<tagCount>0000</tagCount>"))
{
//There are no tags in the field
SetTagDetectionState(TagDetectionState.NO);
}
else
{
// There are tags in the field
SetTagDetectionState(TagDetectionState.YES);
}
}
}
}
}
// Looks for the first complete XML telegram in ReceiveBuffer.
private XMLTag FirstTag()
{
// Is there a reply, a notification or an alarm
int index1 = ReceiveBuffer.IndexOf("<reply>");
int index2 = ReceiveBuffer.IndexOf("<notification>");
int index3 = ReceiveBuffer.IndexOf("<alarm>");
if( index1==-1 && index2==-1 &&index3==-1) return null; //No XML tag found
if (index1 == -1) index1 = Int32.MaxValue;
if (index2 == -1) index2 = Int32.MaxValue;
if (index3 == -1) index3 = Int32.MaxValue;
//Assume that the first tag is an alarm
String endTag="</alarm>";
XMLTag tag = new XMLTag();
tag.type="alarm";
tag.startIndex = index3;
//See if this is true and change it if necessary
if (index1 < index2 && index1 < index3)
{