use of alma.TMCDB.MonitorBlob in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method testExtractData_doubleSeqBlobDataSeq_multivalued.
/**
* Test of extractData method for 'doubleSeqBlobDataSeq' data for a multi-valued MP.
*/
@Test
public void testExtractData_doubleSeqBlobDataSeq_multivalued() throws Exception {
String propertyName = "MODULE_MODE_STATUS";
Any any = create_any();
double[] doubleData_time1 = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
double[] doubleData_time2 = { 11.1, 12.2, 13.3, 14.4, 15.5, 16.6, 17.7, 18.8, 19.9, 20.0 };
double[] doubleData_time3 = { 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0 };
double[][] doubleDataMatrix = { doubleData_time1, doubleData_time2, doubleData_time3 };
doubleSeqBlobData[] doubleSeqBlobDataArray = createDoubleSeqBlobData(doubleDataMatrix);
doubleSeqBlobDataSeqHelper.insert(any, doubleSeqBlobDataArray);
monitorPointExpert.setMultivalued(propertyName, true);
// Test the AnyExtractor stand-alone
List<MonitorPointTimeSeries> extractedData = anyExtractor.extractData(any, propertyName);
assertThat("No demultiplexing into several MonitorPointTimeSeries instances expected", extractedData, hasSize(1));
// Check the raw data
MonitorPointTimeSeries mpTs = extractedData.get(0);
assertThat(mpTs.getCorbaTypeId(), equalTo("IDL:alma/TMCDB/doubleSeqBlobDataSeq:1.0"));
assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
List<MonitorPointValue> dataList = mpTs.getDataList();
assertThat(dataList, hasSize(doubleDataMatrix.length));
for (int i = 0; i < doubleDataMatrix.length; i++) {
MonitorPointValue mpVal = dataList.get(i);
assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
List<Object> data = mpVal.getData();
assertThat(data, hasSize(doubleData_time1.length));
for (int j = 0; j < doubleData_time1.length; j++) {
Object dataPart = data.get(j);
assertThat(dataPart, instanceOf(Double.class));
double dataPartExpected = doubleDataMatrix[i][j];
assertThat(((Double) dataPart).doubleValue(), equalTo(dataPartExpected));
}
}
logger.info("Validated doubleSeqBlobDataSeq interpreted as coming from a multivalued MP.");
// As a variation we test also "BlobberWorker.createBlobData" which in real life surrounds the AnyExtractor call
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
MonitorBlob blob = new MonitorBlob(false, (short) 0, new String[] {}, "wrong:" + propertyName, any);
MonitorBlob[] blobs = new MonitorBlob[] { blob };
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
BlobData blobData = BlobberWorker.createBlobData(block, blob, extractedData.get(0), propertyName, serialNumber, logger);
String clobExpected = BASE_TIME + "|1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0|" + (BASE_TIME + 1) + "|11.1 12.2 13.3 14.4 15.5 16.6 17.7 18.8 19.9 20.0|" + (BASE_TIME + 2) + "|21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0\n";
checkComponentData(blobData, clobExpected, 3, componentName, propertyName, serialNumber, startTime, stopTime, 0, null);
}
use of alma.TMCDB.MonitorBlob in project ACS by ACS-Community.
the class BlobberWorkerUnitTest method testStandardFloat.
public void testStandardFloat() throws Exception {
// was 0, which is now illegal
blobber.setCollectorIntervalSeconds(1);
getTestWorker().setCanHandle(true);
// Collector "TestCollector" is just a dummy to trick the worker to believe that
// there is a collector registered and start operating. "TestCollector" is not used at all.
// The TestBlobberWorker creates its own single collector from which the blobber worker will get data.
getTestWorker().addCollector("TestCollector");
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
String propertyName = "VOLTAGE_MID_1";
Any anyUp = create_any();
float[] dataArrayUp = { 1.0F, 2.0F, 3.0F, 4.0F, 5.0F, 6.0F, 7.0F, 8.0F, 9.0F, 10.0F };
floatBlobData[] dataUp = new floatBlobData[dataArrayUp.length];
int index = 0;
for (float value : dataArrayUp) {
dataUp[index] = new floatBlobData(BASE_TIME + index, value);
index++;
}
floatBlobDataSeqHelper.insert(anyUp, dataUp);
MonitorBlob blobUp = new MonitorBlob(false, (short) 0, null, "wrong:" + propertyName, anyUp);
MonitorBlob[] blobs = new MonitorBlob[1];
blobs[0] = blobUp;
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
MonitorDataBlock[] blocks = new MonitorDataBlock[1];
blocks[0] = block;
getTestWorker().getCollector().setMonitorData(blocks);
ComponentData data = getTestWorker().fetchData();
String clob = BASE_TIME + "|1.0|" + (BASE_TIME + 1) + "|2.0|" + (BASE_TIME + 2) + "|3.0|" + (BASE_TIME + 3) + "|4.0|" + (BASE_TIME + 4) + "|5.0|" + (BASE_TIME + 5) + "|6.0|" + (BASE_TIME + 6) + "|7.0|" + (BASE_TIME + 7) + "|8.0|" + (BASE_TIME + 8) + "|9.0|" + (BASE_TIME + 9) + "|10.0\n";
checkData(data, clob, 10, componentName, propertyName, serialNumber, startTime, stopTime);
checkStatistics(data, 1.0, 10.0, 5.5, 3.0276503563);
}
Aggregations