}
int rc;
boolean isOffline = false;
TLink lnk;
TDataType tdt;
NAME32[] n32 = new NAME32[100];
al.add("security :");
tdt = new TDataType(n32);
lnk = new TLink(tgt,"USERS",tdt,null,TAccess.CA_READ);
rc = lnk.executeAndClose();
if (rc == TErrorList.link_timeout || rc == TErrorList.connection_timeout)
isOffline = true;
if (rc == 0 && tdt.getCompletionLength() > 0)
{
al.add("WRITE access open to Users : ");
for (int i=0; i<tdt.getCompletionLength(); i++)
al.add("\t"+n32[i].name);
}
else
{
if (!isOffline) al.add("WRITE access open to : ALL users");
}
lnk = new TLink(tgt,"IPNETS",tdt,null,TAccess.CA_READ);
rc = isOffline ? TErrorList.connection_timeout : lnk.executeAndClose();
if (rc == 0 && tdt.getCompletionLength() > 0)
{
al.add("WRITE access open to Network Addresses : ");
for (int i=0; i<tdt.getCompletionLength(); i++)
al.add("\t"+n32[i].name);
}
else
{
if (!isOffline) al.add("WRITE access open to : ALL network addresses");
}
al.add("servers running on same host :");
ServerQuery[] sqhst = TQuery.getDeviceServersEx(context, ip,"ALL");
for (ServerQuery sq : sqhst) al.add("\t"+sq.getName());
String[] alst = ENSTools.getServerAliasList(tgt);
if (alst != null && alst.length > 0)
{
al.add("aliases for "+tgt+":");
for (String s : alst) al.add("\t"+s+ " -> "+tgt);
}
if (!isOffline)
{
String[] devs = TQuery.getDeviceNames(context, server);
if (devs != null)
{
al.add(tgt+" has "+devs.length+" devices");
if (TQuery.devices_have_query_function)
{
al.add(tgt+" has property query precedence (classic property server model)");
tgtdev = "#0";
}
if (devs.length > 0 && tgtdev == null) tgtdev = devs[0];
//for (String s: devs) al.add(s);
}
String[] prps = TQuery.getDeviceProperties(context, server, tgtdev);
if (prps != null)
{
al.add(tgt+" has "+prps.length+" properties");
if (TQuery.properties_have_query_function)
{
al.add(tgt+" has device query precedence (classic device server model)");
}
if (devs.length > 0 && tgtdev == null) tgtdev = devs[0];
//for (String s: prps) al.add(s);
}
TPropertyQuery pztpq[] = null;
long t0;
String rdr = null, lclhststr = null;
int callsOK = 0;
int callsErr = 0;
int callsNA = 0;
int len = prps.length;
if (limit > 0 && limit < len) len = limit;
for (int i=0; prps != null && i<len; i++)
{
pztpq = TQuery.getPropertyInformation(context, server, tgtdev, prps[i]);
if (pztpq == null)
{
callsErr++;
continue;
}
for (TPropertyQuery p: pztpq)
{
if (TAccess.isRead(p.prpAccess))
{
al.add("read "+p.prpName+" : "+p.prpDescription);
lclhststr = p.prpHistoryDepthShort == 0 ? "none" :
p.prpHistoryDepthShort < 0 ? "redirected" :
p.prpHistoryDepthLong > 0 ? ""+p.prpHistoryDepthLong+" month(s)" :
""+p.prpHistoryDepthShort+" entries in ring buffer";
al.add("\tlocal history : "+lclhststr);
al.add("\tarray type : "+TArrayType.toString(p.prpArrayType));
if (p.prpRedirection.length() > 0)
al.add("\tis redirected to "+p.prpRedirection);
if (p.prpSizeIn > 0) al.add("\ttakes input: "+p.prpSizeIn+" "+TFormat.toString(p.prpFormatIn)+" elements");
al.add("\tresults:");
if (p.prpFormat == TFormat.CF_STRUCT)
{
int ssiz = 0;
if ((ssiz=TStructRegistry.getSizeInBytes(p.prpTag)) <= 0)
{
TQuery.AcquireAndRegisterStructInfo(context, server, p.prpTag);
ssiz = TStructRegistry.getSizeInBytes(p.prpTag,context,server);
}
if (ssiz > 0) tdt = new TDataType(new byte[ssiz],p.prpTag);
else
{
al.add("\tunable to acquire and register structure tag "+p.prpTag);
tdt = new TDataType(p.prpSize,p.prpFormat);
}
}
else if (p.prpFormat == TFormat.CF_AIMAGE || p.prpFormat == TFormat.CF_ASPECTRUM)
{
al.add("\t"+lnk.getFullDeviceNameAndProperty()+" adjustable format not accessed");
callsNA++;
continue;
}
else
{
tdt = new TDataType(p.prpSize,p.prpFormat);
}
lnk = new TLink(tgt+"/"+tgtdev,p.prpName,tdt,null,TAccess.CA_READ);
t0 = System.currentTimeMillis();
rc = lnk.executeAndClose();
if (rc == TErrorList.illegal_read_write && p.prpSizeIn > 0)
{
al.add("\t"+lnk.getFullDeviceNameAndProperty()+" not accessed: requires input data");
callsNA++;
}
else
{
al.add("\t"+lnk.getFullDeviceNameAndProperty()+" "+p.prpSize+" "+
TFormat.toString(p.prpFormat)+" value(s) in "+
(System.currentTimeMillis()-t0)+" ms : "+lnk.getLastError());
TDataType dout = lnk.getOutputDataObject();
switch (dout.dFormat)
{
case TFormat.CF_STRUCT:
al.add("\tStructure type "+dout.getTag());
break;
case TFormat.CF_BITFIELD8:
case TFormat.CF_BITFIELD16:
case TFormat.CF_BITFIELD32:
case TFormat.CF_BITFIELD64:
al.add("\tBitfield type "+dout.getTag());
break;
case TFormat.CF_IMAGE:
IMAGE img = (IMAGE)dout.getDataObject();
al.add("\tImage; Frame size "+img.getFrameHeader().appendedFrameSize+" bytes");
break;
default:
if (dout.dCompletionLength <= 10)
{
dout.setArrayDelimiter(" ");
al.add("\tvalues: "+dout.toString());
}
else
{
al.add("\treceived "+dout.dCompletionLength+" values");
}