String[] slst = deviceList.getDeviceNameList();
return (short)dout.putData(StringToName.stringArrayToName16(slst));
}
}
if (!propertyList.hasProperty(propertyName)) return TErrorList.illegal_property;
TExportProperty prp = propertyList.getFirstProperty(propertyName);
if (prp == null) return TErrorList.illegal_property;
TPropertyEGU egu;
int cc = 0;
float[] fv = new float[1];
switch (metaIndex)
{
case TMetaProperties.URL_ID:
return (short) dout.putData(prp.getDescription().getUrl());
case TMetaProperties.DSC_ID:
return (short) dout.putData(prp.getDescription().getText());
case TMetaProperties.MAX_ID:
case TMetaProperties.XMAX_ID:
egu = metaIndex == TMetaProperties.XMAX_ID ?
prp.getDescription().getXRange() : prp.getDescription().getYRange();
if (devAccess.isWrite())
{
if (din.dArrayLength != 1) return TErrorList.dimension_error;
if (!TFormat.isNumberFormat(din.dFormat)) return TErrorList.illegal_format;
if ((cc=din.getData(fv)) != 0) return (short)cc;
egu.setMaxValue(fv[0]);
if (dout.dArrayLength == 0) return 0;
}
if (!TFormat.isNumberFormat(dout.dFormat)) return TErrorList.illegal_format;
fv[0] = egu.getMaxValue();
return (short) dout.putData(fv);
case TMetaProperties.MIN_ID:
case TMetaProperties.XMIN_ID:
egu = metaIndex == TMetaProperties.XMIN_ID ?
prp.getDescription().getXRange() : prp.getDescription().getYRange();
if (devAccess.isWrite())
{
if (din.dArrayLength != 1) return TErrorList.dimension_error;
if (!TFormat.isNumberFormat(din.dFormat)) return TErrorList.illegal_format;
if ((cc=din.getData(fv)) != 0) return (short)cc;
egu.setMinValue(fv[0]);
if (dout.dArrayLength == 0) return 0;
}
if (!TFormat.isNumberFormat(dout.dFormat)) return TErrorList.illegal_format;
fv[0] = egu.getMinValue();
return (short) dout.putData(fv);
case TMetaProperties.XEGU_ID:
case TMetaProperties.EGU_ID: // to satisfy DOOCS calls ...
egu = metaIndex == TMetaProperties.XEGU_ID ?
prp.getDescription().getXRange() :
prp.getDescription().getYRange();
if (devAccess.isWrite())
{
switch (din.dFormat)
{
case TFormat.CF_NAME16:
case TFormat.CF_NAME32:
case TFormat.CF_NAME64:
if (din.getArrayLength() != 1) return TErrorList.dimension_error;
case TFormat.CF_TEXT:
char[] newUnits = new char[64];
cc = din.getData(newUnits);
if (cc != 0) return (short)cc;
egu.setUnits(new String(newUnits));
break;
case TFormat.CF_FLOAT:
case TFormat.CF_DOUBLE:
case TFormat.CF_DLONG:
case TFormat.CF_LONG:
case TFormat.CF_SHORT:
if (din.dArrayLength != 2) return TErrorList.dimension_error;
float[] yrng = new float[2];
cc = din.getData(yrng);
if (cc != 0) return (short)cc;
egu.setMinValue(yrng[0]);
egu.setMaxValue(yrng[1]);
break;
case TFormat.CF_USTRING:
if (din.getArrayLength() != 1) return TErrorList.dimension_error;
USTRING[] u = new USTRING[1];
cc = din.getData(u);
if (cc != 0) return (short)cc;
egu.setUnits(u[0].getString());
egu.setMinValue(u[0].f1val);
egu.setMaxValue(u[0].f2val);
egu.setGraphType((short)u[0].ival);
break;
default:
return TErrorList.illegal_format;
}
if (dout.dArrayLength == 0) return 0;
}
switch (dout.dFormat)
{
case TFormat.CF_TEXT:
case TFormat.CF_NAME16:
case TFormat.CF_NAME32:
case TFormat.CF_NAME64:
return (short) dout.putData(egu.getUnits());
case TFormat.CF_FLOAT:
case TFormat.CF_DOUBLE:
case TFormat.CF_DLONG:
case TFormat.CF_LONG:
case TFormat.CF_SHORT:
float[] yrng = new float[2];
yrng[0] = egu.getMinValue();
yrng[1] = egu.getMaxValue();
return (short) dout.putData(yrng);
case TFormat.CF_USTRING:
USTRING[] u = new USTRING[1];
u[0] = new USTRING(egu.getGraphType(),
egu.getMinValue(),
egu.getMaxValue(),
0,
egu.getUnits());
return (short) dout.putData(u);
default:
return TErrorList.illegal_format;
}
case TMetaProperties.HST_ID:
THistoryRecord hst = null;
int listsize = gLclHstList.size();
int index = 0, sample = 0;
long start = 0;
long stop = System.currentTimeMillis()-1000;
float lwr = 0, upr = 0;
Object data = null;
int dataSize = 0, inputDataSize = 0;
boolean isCentralArchiveRequest = false;
if (TMetaProperties.isCentralArchive(metaPropertyName))
{
isCentralArchiveRequest = true;
}
boolean isSnapshot = TMetaProperties.isHistorySnapshot(metaPropertyName);
dataSize = dout.getArrayLength();
if (dout.dFormat == TFormat.CF_HISTORY)
{ // trap this early
int hsiz = TFormat.getCarriedFormatSize(dout.getTag());
if (hsiz > 0) dataSize /= hsiz + TFormat.getHistoryHeaderSize();
}
start = stop - dataSize * 1000; // millisecond timestamps here!
// check the time range and/or filtering criteria the caller has given us ...
if (din != null && (inputDataSize=din.getArrayLength()) > 0)
{
switch (din.getFormat())
{
case TFormat.CF_LONG:
int[] ival = (int[])din.getDataObject();
switch (inputDataSize)
{
case 4: sample = ival[3];
case 3: index = ival[2];
case 2: if (ival[1] < (int)(stop/1000)) stop = ((long)ival[1])*1000;
case 1: start = ((long)ival[0])*1000;
default: break;
}
if (sample < 0) sample = 0;
break;
case TFormat.CF_DLONG:
long[] lval = (long[])din.getDataObject();
switch (inputDataSize)
{
case 4: sample = (int)lval[3];
case 3: index = (int)lval[2];
case 2: if (lval[1] < stop/1000) stop = (long)(lval[1]*1000);
case 1: start = (long)(lval[0]*1000);
default: break;
}
if (sample < 0) sample = 0;
break;
case TFormat.CF_DOUBLE:
double[] dval = (double[])din.getDataObject();
switch (inputDataSize)
{
case 4: sample = (int)dval[3];
case 3: index = (int)dval[2];
case 2: if (dval[1] < stop/1000) stop = (long)(dval[1]*1000);
case 1: start = (long)(dval[0]*1000);
default: break;
}
if (sample < 0) sample = 0;
break;
case TFormat.CF_FWINDOW:
FWINDOW[] fw = (FWINDOW[])din.getDataObject();
start = ((FWINDOW[])fw)[0].i1val * 1000;
stop = ((FWINDOW[])fw)[0].i2val * 1000;
lwr = ((FWINDOW[])fw)[0].f1val;
upr = ((FWINDOW[])fw)[0].f2val;
if (lwr < upr) sample = -1;
break;
default:
return TErrorList.illegal_format;
}
}
else
{ // no input given
if (dataSize == 1)
{
start = stop;
isSnapshot = true;
}
}
if (isSnapshot)
{
if (start < 1) return TErrorList.argument_list_error;
stop = start;
sample = 0;
index = 0;
lwr = upr = (float)0.0;
}
// what the caller wants returned ....
boolean literalDevice = false;
for (int i=0; i<listsize; i++)
{ // go thru the list to see if the requested device was stored literally
hst = (THistoryRecord)gLclHstList.get(i);
if (hst.getPrp().compareToIgnoreCase(prp.getName()) != 0) continue;
if (hst.getDev().compareTo(devName) != 0) continue;
literalDevice = true;
break;
}
for (int i=0; i<listsize; i++)
{
hst = (THistoryRecord)gLclHstList.get(i);
if (hst.getPrp().compareToIgnoreCase(prp.getName()) == 0)
{
if (hst.getDev().compareTo(devName) != 0)
{ // should we look for a match in the device name ?
if (index == 0 && !literalDevice)
index = getDeviceList().getDeviceNumber(devName);
else
continue;
}
if (isCentralArchiveRequest)
{
String rmtsrv = hst.getRemoteHistoryServer();
if (rmtsrv == null || rmtsrv.length() == 0)
{ // try the central archive systematics ...
rmtsrv = "/"+getContext()+"/HISTORY/"+devName+"["+getExportName()+"."+propertyName+"]";
}
return (short)gEqmFactory.setRedirectionString(rmtsrv);
}
// snapshots always have index = 0
if (start == stop && dataSize > 1) index = 0;
switch (dout.dFormat)
{
case TFormat.CF_BYTE:
data = new byte[dataSize]; break;
case TFormat.CF_SHORT:
data = new short[dataSize]; break;
case TFormat.CF_LONG:
data = new int[dataSize]; break;
case TFormat.CF_DLONG:
data = new long[dataSize]; break;
case TFormat.CF_INTINT:
data = new INTINT[dataSize]; break;
case TFormat.CF_FLOAT:
data = new float[dataSize]; break;
case TFormat.CF_FLTINT:
data = new FLTINT[dataSize]; break;
case TFormat.CF_INTFLTINT:
data = new INTFLTINT[dataSize]; break;
case TFormat.CF_DOUBLE:
data = new double[dataSize]; break;
case TFormat.CF_DBLDBL:
data = new DBLDBL[dataSize]; break;
case TFormat.CF_DBLTIME:
data = new DBLTIME[dataSize]; break;
case TFormat.CF_NAME16:
data = new NAME16[dataSize]; break;
case TFormat.CF_NAME16I:
data = new NAME16I[dataSize]; break;
case TFormat.CF_NAME32:
data = new NAME32[dataSize]; break;
case TFormat.CF_NAME32I:
data = new NAME32I[dataSize]; break;
case TFormat.CF_NAME64:
data = new NAME64[dataSize]; break;
case TFormat.CF_NAME64I:
data = new NAME64I[dataSize]; break;
case TFormat.CF_HISTORY:
data = new HISTORY[dataSize];
// create the first one so as to pass the tag along
short f = TFormat.getFormatCode(dout.getTag());
if (f == TFormat.CF_NULL) return TErrorList.illegal_format;
TDataType d = new TDataType(1,f);
((HISTORY[])data)[0] = new HISTORY(d);
break;
default:
data = TFormat.makeCompoundDataObjectArray(dout.dFormat, dout.getTag(), dataSize);
break;
}
int nr = hst.getDataFromLTS(index,start,stop,lwr,upr,data,dataSize,0,sample);
if (nr < 0)
{
if (nr == -TErrorList.server_redirection)
{
String rmtsrv = hst.getRemoteHistoryServer();
if (rmtsrv == null || rmtsrv.length() == 0) return TErrorList.not_implemented;
return (short)gEqmFactory.setRedirectionString(rmtsrv);
}
return (short)-nr;
}
boolean needStsData = true;
if (nr > 0)
{
if (isSnapshot || nr >= dataSize - 1)
{ // found the snapshot in or filled the buffer from LTS
dout.putData(data);
dout.setDataTimeStamp(hst.getLastReadTimestamp());
return 0;
}
start = hst.getLastReadTimestamp() + 1;
if (start >= stop) needStsData = false; // we're finished
}
if (needStsData)
{ // still recent points to acquire
nr = hst.getDataFromSTS(index,start,stop,lwr,upr,data,dataSize,nr,sample);
if (nr < 0) return (short)-nr;
}
if (dataSize > 1 && nr < dataSize) dout.dArrayLength = nr;
dout.putData(data);
dout.setDataTimeStamp(hst.getLastReadTimestamp());
return 0;
}
}
return TErrorList.not_implemented;
case TMetaProperties.NAM_ID:
// if .NAM properties are registered they are handled with the normal property handler
String[] slst = deviceList.getDeviceNameList();
ArrayList<String> lst = prp.getDeviceList();
if (lst != null && lst.size() > 0)
{
slst = new String[lst.size()];
lst.toArray(slst);
}