if (deviceString == null) return false;
return deviceString.indexOf('*') != -1;
}
private int doContractWithWildcardDevice(TContractTable tct)
{
TDataType drdb, dnull;
int start = 0, len = 0, mask = 0;
boolean isCont = false, chkMask = false, chkOffline = false;
int cc = TErrorList.not_allowed, i, k;
TAccess acc = new TAccess(tct.contract.dataAccess);
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);
dnull = new TDataType();
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, dnull, 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, dnull, 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, dnull, 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;
}
else
{
int dsiz = tct.contract.dataSizeOut;
nii = new NAME16II[dsiz];
int[] irb = new int[1];
drdb = new TDataType(irb);
for (i=0, k=0; i<devlistsize && k<tct.dout.dArrayLength; i++)
{
if (!wc.matches(devlist[i])) continue;
cc = tct.eqm.callProperty(devprp, devlist[i], drdb, dnull, acc);
if (cc == TErrorList.server_redirection) return TErrorList.data_not_local;
nii[k] = new NAME16II(devlist[i],irb[0],cc);
k++;
}
tct.drb.dArrayLength = k;
}
tct.drb.putData(nii);
return 0;
default:
if (tct.dout.dFormat <= TFormat.CF_NAME32 && devnam.compareTo("*") == 0)
{ /* primitive format allowed in this case */
if (isCont)
{
if (tct.drb.dArrayLength > len) tct.drb.dArrayLength = len;
return tct.eqm.callProperty(devprp, devlist[0], tct.drb, dnull, acc);
}
drdb = new TDataType(1,tct.dout.dFormat);
for (i=0; i<devlistsize && i<tct.dout.dArrayLength; i++)
{
cc = tct.eqm.callProperty(devprp, devlist[i], drdb, dnull, acc);
if (cc != 0) break;
}