int devlistsize = 0;
String[] devlist = null;
int atype;
NAME16FI[] nfi;
NAME16II[] nii;
TDevice dev;
TEquipmentModule eqm = tct.eqm;
TDeviceList dlst = eqm.getDeviceList();
String devprp = tct.contract.eqmProperty;
String devnam = tct.contract.eqmDeviceName;
TExportProperty prp = eqm.propertyList.getFirstProperty(devprp);
if ((atype=prp.getDescription().getArrayType()) == TArrayType.AT_SPECTRUM)
return TErrorList.not_allowed;
if (tct.dout == null || tct.dout.dArrayLength < 1) return TErrorList.not_allowed;
if (!eqm.isDeviceSetLocal(devnam,devprp)) return TErrorList.data_not_local;
if (prp.getDeviceList() != null)
{
devlistsize = prp.getDeviceList().size();
devlist = new String[devlistsize];
prp.getDeviceList().toArray(devlist);
}
if (devlistsize == 0)
{ // normal state of affairs: use the registered device list
devlist = dlst.getDeviceNameList();
devlistsize = devlist.length;
chkOffline = true;
if (tct.din != null && tct.din.dArrayLength == 1 && tct.din.dFormat == TFormat.CF_INT32)
{ // appears to be an input device mask
int[] msk = new int[1];
tct.din.getData(msk);
mask = msk[0];
if (mask != 0) chkMask = true;
}
}
if ((atype & TArrayType.AT_CHANNEL) == TArrayType.AT_CHANNEL)
{
len = devlistsize;
int endpoints[] = StringToName.getContiguousEndpoints(devlist,devnam);
if (endpoints != null)
{
isCont = true;
start = endpoints[0];
len = endpoints[1] - endpoints[0] + 1;
}
}
WildcardMatch wc = new WildcardMatch(devnam);
switch (tct.dout.dFormat)
{
case TFormat.CF_NAME16DBLDBL:
case TFormat.CF_NAME32DBLDBL:
case TFormat.CF_NAME64DBLDBL:
case TFormat.CF_USTRING:
case TFormat.CF_NAME16FI:
if (isCont)
{
int dsiz = tct.contract.dataSizeOut > len ? len : tct.contract.dataSizeOut;
nfi = new NAME16FI[dsiz];
float[] frb = new float[dsiz];
drdb = new TDataType(frb);
cc = tct.eqm.callProperty(devprp, devlist[start], drdb, tct.din, acc);
if (cc != 0) return cc;
for (i=0, k=0; i<drdb.dArrayLength; i++)
{
dev = dlst.getDevice(i);
if (chkMask) if (dev == null || !dev.isMaskSet(mask)) continue;
if (chkOffline) if (dev == null || dev.isOffline()) continue;
nfi[k] = new NAME16FI(devlist[start+i],0,frb[i]);
k++;
}
tct.drb.dArrayLength = k;
}
else
{
int dsiz = tct.contract.dataSizeOut;
nfi = new NAME16FI[dsiz];
float[] frb = new float[1];
drdb = new TDataType(frb);
for (i=0, k=0; i<devlistsize && k<tct.dout.dArrayLength; i++)
{
if (!wc.matches(devlist[i])) continue;
dev = dlst.getDevice(i);
if (chkMask) if (dev == null || !dev.isMaskSet(mask)) continue;
if (chkOffline) if (dev == null || dev.isOffline()) continue;
cc = tct.eqm.callProperty(devprp, devlist[i], drdb, tct.din, acc);
if (cc == TErrorList.server_redirection) return TErrorList.data_not_local;
nfi[k] = new NAME16FI(devlist[i],cc,frb[0]);
k++;
}
tct.drb.dArrayLength = k;
}
tct.drb.putData(nfi);
return 0;
case TFormat.CF_NAME16II:
if (isCont)
{
int dsiz = tct.contract.dataSizeOut > len ? len : tct.contract.dataSizeOut;
nii = new NAME16II[dsiz];
int[] irb = new int[dsiz];
drdb = new TDataType(irb);
cc = tct.eqm.callProperty(devprp, devlist[start], drdb, tct.din, acc);
if (cc != 0) return cc;
for (i=0,k=0; i<drdb.dArrayLength; i++)
{
dev = dlst.getDevice(i);
if (chkMask) if (dev == null || !dev.isMaskSet(mask)) continue;
if (chkOffline) if (dev == null || dev.isOffline()) continue;
nii[k] = new NAME16II(devlist[start+i],0,irb[i]);
k++;
}
tct.drb.dArrayLength = k;
}