Search in sources :

Example 21 with MonitorBlob

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);
}
Also used : MonitorPointValue(alma.acs.monitoring.MonitorPointValue) Any(org.omg.CORBA.Any) TMCDB.doubleSeqBlobData(alma.TMCDB.doubleSeqBlobData) MonitorBlob(alma.TMCDB.MonitorBlob) TMCDB.floatBlobData(alma.TMCDB.floatBlobData) TMCDB.booleanSeqBlobData(alma.TMCDB.booleanSeqBlobData) TMCDB.longLongBlobData(alma.TMCDB.longLongBlobData) TMCDB.doubleBlobData(alma.TMCDB.doubleBlobData) TMCDB.doubleSeqBlobData(alma.TMCDB.doubleSeqBlobData) TMCDB.floatSeqBlobData(alma.TMCDB.floatSeqBlobData) MonitorPointTimeSeries(alma.acs.monitoring.MonitorPointTimeSeries) MonitorDataBlock(alma.TMCDB.MonitorDataBlock) Test(org.junit.Test)

Example 22 with MonitorBlob

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);
}
Also used : TMCDB.floatBlobData(alma.TMCDB.floatBlobData) ComponentData(alma.acs.monitoring.DAO.ComponentData) Any(org.omg.CORBA.Any) MonitorBlob(alma.TMCDB.MonitorBlob) MonitorDataBlock(alma.TMCDB.MonitorDataBlock)

Aggregations

MonitorBlob (alma.TMCDB.MonitorBlob)22 MonitorDataBlock (alma.TMCDB.MonitorDataBlock)22 Any (org.omg.CORBA.Any)20 ComponentData (alma.acs.monitoring.DAO.ComponentData)15 TMCDB.doubleBlobData (alma.TMCDB.doubleBlobData)7 TMCDB.doubleSeqBlobData (alma.TMCDB.doubleSeqBlobData)6 TMCDB.floatBlobData (alma.TMCDB.floatBlobData)6 TMCDB.floatSeqBlobData (alma.TMCDB.floatSeqBlobData)6 TMCDB.longLongBlobData (alma.TMCDB.longLongBlobData)6 MonitorPointTimeSeries (alma.acs.monitoring.MonitorPointTimeSeries)6 TMCDB.booleanSeqBlobData (alma.TMCDB.booleanSeqBlobData)5 MonitorPointValue (alma.acs.monitoring.MonitorPointValue)5 Test (org.junit.Test)5 TMCDB.enumBlobData (alma.TMCDB.enumBlobData)2 TMCDB.longBlobData (alma.TMCDB.longBlobData)1 TMCDB.longLongSeqBlobData (alma.TMCDB.longLongSeqBlobData)1 TMCDB.longSeqBlobData (alma.TMCDB.longSeqBlobData)1 TMCDB.patternBlobData (alma.TMCDB.patternBlobData)1 TMCDB.stringBlobData (alma.TMCDB.stringBlobData)1 TMCDB.stringSeqBlobData (alma.TMCDB.stringSeqBlobData)1