Herunterladen Inhalt Inhalt Diese Seite drucken

Siemens RF182C Betriebsanleitung Seite 98

Simatic rfid-systeme kommunikationsmodul
Inhaltsverzeichnis
Beispiele/Applikationen
10.2 Anwenderapplikation RF182C
// (ReceiveCallback is asynchronous)
lock (ReceiveBuffer)
{
for (XMLTag tag = FirstTag(); tag != null; tag = FirstTag())
{
}
}
}
// Looks for the first complete XML telegramm in ReceiveBuffer.
private XMLTag FirstTag()
{
// Is there a reply, a notifacation 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)
{
98
// 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.startIndex + 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 tag in the field
SetTagDetectionState(TagDetectionState.YES);
}
}
Kommunikationsmodul RF182C
Betriebsanleitung, 10/2010, J31069-D0204-U001-A2-0018
Inhaltsverzeichnis
loading

Inhaltsverzeichnis