stockList.addProperty(TStockProperties.METAPROPS_STRUCT, metapropertiesStructHandler);
stockList.addProperty(TStockProperties.DEVLOCATION, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
TDevice tdv = deviceList.getDevice(devName);
if (tdv == null) return TErrorList.illegal_device;
if (din != null && devAccess.isWrite())
{
int cc = 0;
char[] newLocation = new char[64];
if ((cc=din.getData(newLocation)) != 0) return cc;
tdv.setLocation(new String(newLocation));
}
String dloc = tdv.getLocation();
if (dloc == null) dloc = gEqmFactory.getFecLocation();
if (dloc != null && dloc.startsWith("<"))
{ /* redirection character */
String rdrstr = null, envstr;
dloc = dloc.substring(1); dloc.trim();
if (dloc.startsWith("$"))
{
int idx = dloc.indexOf('/');
if (idx < 0) idx = dloc.length();
envstr = dloc.substring(1, idx);
rdrstr = System.getenv(envstr);
if (rdrstr == null) MsgLog.log("TEquipmentModule:DEVLOCATION", "environment variable "+envstr+" not set",TErrorList.not_defined,null,0);
dloc = dloc.substring(idx);
}
if (rdrstr == null) rdrstr = "";
rdrstr += dloc;
if (rdrstr.indexOf('[') < 0) rdrstr += "[Location]";
return gEqmFactory.setRedirectionString(rdrstr);
}
return dout.putData(dloc == null ? "" : dloc);
}
});
stockList.addProperty(TStockProperties.DEVMASK, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
TDevice tdv = deviceList.getDevice(devName);
if (tdv == null) return TErrorList.illegal_device;
if (din != null && devAccess.isWrite())
{
int cc = 0;
int[] newMask = new int[1];
if ((cc=din.getData(newMask)) != 0) return cc;
tdv.setMask(newMask[0]);
}
int mask = tdv.getMask();
return dout.putData(mask);
}
});
stockList.addProperty(TStockProperties.ZPOSITION, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
TDevice tdv = deviceList.getDevice(devName);
if (tdv == null) return TErrorList.illegal_device;
if (din != null && devAccess.isWrite())
{
int cc = 0;
float[] newZPos = new float[1];
if ((cc=din.getData(newZPos)) != 0) return cc;
tdv.setZposition(newZPos[0]);
}
float p = tdv.getZposition();
return dout.putData(p);
}
});
stockList.addProperty(TStockProperties.DEVONLINE, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
TDevice tdv = deviceList.getDevice(devName);
if (tdv == null) return TErrorList.illegal_device;
if (din != null && devAccess.isWrite())
{
int cc = 0;
int[] newFlg = new int[1];
if ((cc=din.getData(newFlg)) != 0) return cc;
tdv.setOffline(newFlg[0] == 0 ? true : false);
}
boolean p = !tdv.isOffline();
return dout.putData(p);
}
});
stockList.addProperty(TStockProperties.PROPERTIES, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
return prpQueryCall(devName,dout,din,devAccess);
}
});
stockList.addProperty(TStockProperties.PROPERTIES_USTRING, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
return prpQueryCall(devName,dout,din,devAccess);
}
});
stockList.addProperty(TStockProperties.PROPERTIES_STRUCT, propertiesStructHandler);
stockList.addProperty(TStockProperties.PROPS, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
return prpQueryCall(devName,dout,din,devAccess);
}
});
stockList.addProperty(TStockProperties.PROPS_USTRING, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
return prpQueryCall(devName,dout,din,devAccess);
}
});
stockList.addProperty(TStockProperties.PROPS_STRUCT, propertiesStructHandler);
stockList.addProperty(TStockProperties.NPROPERTIES, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
return dout.putData(propertyList.countUniqueProperties());
}
});
// Same as NPROPERTIES
stockList.addProperty(TStockProperties.NPROPS, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
return dout.putData(propertyList.countUniqueProperties());
}
});
stockList.addProperty(TStockProperties.NDEVICES, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
//return dout.putData(deviceList.size());
return dout.putData(deviceList.getNumberOfDevices());
}
});
stockList.addProperty(TStockProperties.DEVICES, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
String[] namlst;
if (devName.compareTo("*") != 0 && devName.indexOf("*") != -1)
{ // query for a subset of device names ...
WildcardMatch wc = new WildcardMatch(devName);
TDevice dev;
LinkedList<String> nl = new LinkedList<String>();
String dn;
int n = 0, mask = 0;
if (din != null && din.dArrayLength == 1 && din.dFormat == TFormat.CF_INT32)
{
int[] msk = new int[1];
din.getData(msk);
mask = msk[0];
}
for (int i=0; i<deviceList.getNumberOfDevices(); i++)
{
if ((dev=deviceList.getDevice(i)) == null) continue;
if (dev.isOffline()) continue;
if (mask > 0 && !dev.isMaskSet(mask)) continue;
dn = dev.getName();
if (!wc.matches(dn)) continue;
nl.add(dn);
n++;
}
namlst = nl.toArray(new String[n]);
}
else
{
namlst = deviceList.getDeviceNameList();
}
int cc = dout.putData(StringToName.stringArrayToName64(namlst));
if (cc == 0)
{
if (dout.getArrayLength() > namlst.length) dout.setArrayLength(namlst.length);
if (getDeviceList().isPropertyOriented())
cc = TErrorList.has_query_function | TErrorList.CE_SENDDATA;
}
return cc;
}
});
stockList.addProperty(TStockProperties.DEVDESCRIPTION, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
TDevice tdv = deviceList.getDevice(devName);
if (tdv == null) return TErrorList.illegal_device;
String dsc = tdv.getDescription();
return dout.putData(dsc == null ? "" : dsc);
}
});
stockList.addProperty(TStockProperties.SRVSUBSYSTEM, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
String subs = getSubsystem();
return dout.putData(subs == null ? "" : subs);
}
});
stockList.addProperty(TStockProperties.SRVIDLE, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
int cc = 0;
int[] idleState = new int[1];
if (din != null && devAccess.isWrite())
{
if ((cc=din.getData(idleState)) != 0) return cc;
isIdle = idleState[0] == 0 ? false : true;
}
if (dout != null && dout.dArrayLength > 0)
{
idleState[0] = isIdle ? -1 : 0;
cc = dout.putData(idleState);
}
return cc;
}
});
stockList.addProperty(TStockProperties.SRVINIT, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
int cc = 0;
if (!devAccess.isWrite()) return TErrorList.illegal_read_write;
{
if (eqpIni == null) return TErrorList.not_implemented;
cc = eqpIni.initialize();
}
return cc;
}
});
stockList.addProperty(TStockProperties.SRVADDR, new TPropertyHandler()
{
protected int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
NAME32[] n32 = new NAME32[dout.dArrayLength];
String eqm, exp;
TEquipmentModule eq;
int cc = 0;
if (gEqmFactory.isServiceRequest(moduleName))
{
NAME32[] tgt = new NAME32[3];
if ((cc=din.getData(tgt)) != 0) return cc;
String ctxName = tgt[0].getName();
//String eqmName = tgt[1].getName();
String expName = tgt[2].getName();
if ((eq=gEqmFactory.getEquipmentModuleFromExportName(expName)) == null)
return TErrorList.invalid_data;
if (eq.context.compareToIgnoreCase(ctxName) != 0) return TErrorList.invalid_data;
eqm = eq.moduleName;
exp = eq.exportName;
}
else
{
eqm = moduleName;
exp = exportName;
}
cc = gEqmFactory.getSrvAddress(n32,eqm,exp);
return (short) dout.putData(n32);
}
});
stockList.addProperty(TStockProperties.USERS, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
NAME16[] n16 = getRegisteredUsers();
if (din != null && din.dArrayLength > 0)
{
if (!TFormat.isString(din.dFormat)) return TErrorList.illegal_format;
char[] data = new char[TStrings.PROPERTY_NAME_SIZE];
int cc = din.getData(data);
if (cc != 0) return cc;
String str = new String(data).trim();
TExportProperty txp = getPropertyList().getFirstProperty(str);
if (txp != null)
{ // property name given as input
n16 = txp.getRegisteredUsers();
}
else
{ // maybe a device name then ...
TDevice dev = getDeviceList().getDevice(str);
if (dev != null) n16 = dev.getRegisteredUsers();
else return TErrorList.invalid_keyword;
}
}
if (n16 == null)
{
n16 = new NAME16[1];
n16[0] = new NAME16("");
}
dout.dArrayLength = n16 == null ? 0 : n16.length;
return n16 == null ? 0 : dout.putData(n16);
}
});
stockList.addProperty(TStockProperties.NUSERS, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
short n = (short)gRegisteredUsersList.size();
if (din != null && din.dArrayLength > 0)
{
if (!TFormat.isString(din.dFormat)) return TErrorList.illegal_format;
char[] data = new char[TStrings.PROPERTY_NAME_SIZE];
int cc = din.getData(data);
if (cc != 0) return cc;
String str = new String(data).trim();
TExportProperty txp = getPropertyList().getFirstProperty(str);
if (txp != null)
{ // property name given as input
n = (short)txp.getNumberRegisteredUsers();
}
else
{ // maybe a device name then ...
TDevice dev = getDeviceList().getDevice(str);
if (dev != null) n = (short)dev.getNumberRegisteredUsers();
else return TErrorList.invalid_keyword;
}
}
return dout.putData(n);
}
});
stockList.addProperty(TStockProperties.ADDUSER, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
int cc;
if (din != null && devAccess.isWrite())
{
NAME16[] usr = new NAME16[1];
if ((cc=din.getData(usr)) != 0) return cc;
return addRegisteredUser(usr[0].getName());
}
return TErrorList.illegal_read_write;
}
});
stockList.addProperty(TStockProperties.DELUSER, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
int cc;
if (din != null && devAccess.isWrite())
{
NAME16[] usr = new NAME16[1];
if ((cc=din.getData(usr)) != 0) return cc;
return removeRegisteredUser(usr[0].getName());
}
return TErrorList.illegal_read_write;
}
});
stockList.addProperty(TStockProperties.IPNETS, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
NAME16[] n16 = getRegisteredNets();
if (din != null && din.dArrayLength > 0)
{
if (!TFormat.isString(din.dFormat)) return TErrorList.illegal_format;
char[] data = new char[TStrings.PROPERTY_NAME_SIZE];
int cc = din.getData(data);
if (cc != 0) return cc;
String str = new String(data).trim();
TExportProperty txp = getPropertyList().getFirstProperty(str);
if (txp != null)
{ // property name given as input
n16 = txp.getRegisteredNets();
}
else
{ // maybe a device name then ...
TDevice dev = getDeviceList().getDevice(str);
if (dev != null) n16 = dev.getRegisteredNets();
else return TErrorList.invalid_keyword;
}
}
dout.dArrayLength = n16 == null ? 0 : n16.length;
return n16 == null ? 0 : dout.putData(n16);
}
});
stockList.addProperty(TStockProperties.NIPNETS, new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
short n = (short)gRegisteredNetsList.size();
if (din != null && din.dArrayLength > 0)
{
if (!TFormat.isString(din.dFormat)) return TErrorList.illegal_format;
char[] data = new char[TStrings.PROPERTY_NAME_SIZE];
int cc = din.getData(data);
if (cc != 0) return cc;
String str = new String(data).trim();
TExportProperty txp = getPropertyList().getFirstProperty(str);
if (txp != null)
{ // property name given as input
n = (short)txp.getNumberRegisteredUsers();
}
else
{ // maybe a device name then ...
TDevice dev = getDeviceList().getDevice(str);
if (dev != null) n = (short)dev.getNumberRegisteredNets();
else return TErrorList.invalid_keyword;
}
}
return dout.putData(n);
}