// Home | Go Back //
import java.io.*;
import java.util.*;
import com.ireasoning.util.*;
import com.ireasoning.protocol.*;
import com.ireasoning.protocol.tl1.*;
public class tl1
{
static class NotificationListener extends Thread
{
public void run()
{
try
{
TL1Session session = new TL1Session("localhost", 9000);
TL1Command req = TL1Command.act_user("abc", "123");
session.send(req);
while(true)
{ TL1NotificationMsg[] notes = session.waitForNotificationMsg();
for (int i = 0; i < notes.length ; i++)
{
System.out.println( "Got a new alarm:\r\n" + notes[i]);
}
}
}
catch(Exception e)
{
System.out.println( e);
e.printStackTrace();
}
}
}
public static void main(String[] args)
{
try
{
System.out.println( "login to localhost");
TL1Session session = new TL1Session("localhost", 9000);
new NotificationListener().start(); TL1Command req = new TL1Command();
System.out.println( "send login command" );
req = TL1Command.act_user("abc", "123");
session.send(req);
req.setCommand("rtrv-inv:NodeA:SLOT-ALL:123;");
print(session.send(req));
req.setCommand("rtrv-eqpt:NodeA:SLOT-ALL:123;");
TL1ResponseMsg msg = (session.send(req))[0];
TL1Line [] lines = msg.getPayloadData();
for (int j = 0; j < lines.length ; j++)
{
TL1Section [] sections = lines[j].getSections();
System.out.println( "cardname=" + lines[j].lookupValue("CARDNAME"));
System.out.println( "line: " + j);
for (int k = 0; k < sections.length ; k++)
{
System.out.println( "section: " + k);
TL1Field [] fields = sections[k].getFields();
for ( int m = 0; m < fields.length; m++)
{
TL1Field f = fields[m];
System.out.println("<" + f.getName() + "> = <" + f.getValue()
+ ">");
}
}
}
req = TL1Command.canc_user("abc");
session.send(req);
}
catch(Exception e)
{
System.out.println( e);
e.printStackTrace();
}
}
static void print(TL1ResponseMsg [] ms)
{
TL1Util.printOutputMsg(ms);
}
}