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.RBSUMMARY_ID:
case TMetaProperties.RBMAX_ID:
case TMetaProperties.RBMIN_ID:
case TMetaProperties.RBAVE_ID:
{
double[] sampleInterval = new double[] {0};
if (din != null && (din.getArrayLength()) > 0)
{
if ((cc=din.getData(sampleInterval)) != 0) return (short)cc;
}
int index = 0;
int[] idxr = new int[]{index};
THistoryRecord hst = getLocalHistoryRecord(prp.getName(), devName, idxr);
if (hst == null) return TErrorList.not_implemented;
index = idxr[0];
DSUMMARY ds = null;
try
{
ds = hst.getDataSummaryFromSTS(sampleInterval[0]);
}
catch (TineRuntimeErrorException e)
{
return (short)e.getErrorCode();
}
switch (dout.dFormat)
{
case TFormat.CF_STRUCT:
if (metaIndex != TMetaProperties.RBSUMMARY_ID)
return TErrorList.illegal_property;
if (dout.getTag().compareTo("DSUMMARY") != 0)
return TErrorList.invalid_structure_tag;
cc = dout.putData(ds);
break;
default:
double[] vals = ds.getSummary();
switch (metaIndex)
{
case TMetaProperties.RBAVE_ID:
cc = dout.putData(vals,1,0);
break;
case TMetaProperties.RBMAX_ID:
cc = dout.putData(vals,1,2);
break;
case TMetaProperties.RBMIN_ID:
cc = dout.putData(vals,1,3);
break;
default:
cc = dout.putData(vals);
break;
}
}
if (cc != 0) return (short)cc;
dout.setDataTimeStamp(hst.getLastReadTimestamp());
dout.setSystemDataStamp(hst.getLastReadSystemStamp());
}
return 0;
case TMetaProperties.HST_ID:
THistoryRecord hst = null;
int index = 0, sample = 0;
long start = 0;
long stop = TDataTime.now() - 1000;
int sysstart = 0, sysstop = 0;
int cycnr = TEquipmentModuleFactory.getCycleNumber();
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_INT32:
int[] ival = (int[])din.getDataObject();
switch (inputDataSize)
{
case 6: sysstop = ival[5];
if (cycnr == 0) sysstop = 0;
if (sysstop > cycnr) sysstop = cycnr;
case 5: sysstart = ival[4];
if (cycnr == 0) sysstart = 0;
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_INT64:
long[] lval = (long[])din.getDataObject();
switch (inputDataSize)
{
case 6: sysstop = (int)lval[5];
if (cycnr == 0) sysstop = 0;
if (sysstop > cycnr) sysstop = cycnr;
case 5: sysstart = (int)lval[4];
if (cycnr == 0) sysstart = 0;
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 6: sysstop = (int)dval[5];
if (cycnr == 0) sysstop = 0;
if (sysstop > cycnr) sysstop = cycnr;
case 5: sysstart = (int)dval[4];
if (cycnr == 0) sysstart = 0;
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;
if (sysstart > 0) sysstop = sysstart; else stop = start;
sample = 0;
index = 0;
lwr = upr = (float)0.0;
}
// what the caller wants returned ....
int[] idxr = new int[]{index};
hst = getLocalHistoryRecord(prp.getName(), devName, idxr);
if (hst == null) return TErrorList.not_implemented;
index = idxr[0];
if (start == 0)
{ // start still not set, so:
start = stop - dataSize*hst.getHspec().getPollngRate();
}
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);
}
boolean isSummary = false;
if (metaPropertyName.contains(".RB"))
{
if (metaPropertyName.contains(".RBAVE."))
{
index = 0;
isSummary = true;
}
if (metaPropertyName.contains(".RBMAX."))
{
index = 2;
isSummary = true;
}
if (metaPropertyName.contains(".RBMIN."))
{
index = 3;
isSummary = true;
}
if (isSnapshot) return TErrorList.not_implemented;
}
// snapshots always have index = 0
if (start == stop && dataSize > 1) index = 0;
data = makeLocalHistoryDataObject(dout.dFormat,dout.getTag(),dataSize);
if (data == null) return TErrorList.illegal_format;
int nr = hst.getDataFromLTS(index,start,stop,sysstart,sysstop,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 = !isSummary; // no STS Data in history call for Summary
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());
dout.setSystemDataStamp(hst.getLastReadSystemStamp());
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,sysstart,sysstop,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());
dout.setSystemDataStamp(hst.getLastReadSystemStamp());
return 0;
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);
}