Search in sources :

Example 26 with DataTagAddress

use of cern.c2mon.shared.common.datatag.DataTagAddress in project c2mon by c2mon.

the class TestConfigurationProvider method createSubEquipment.

/**
 * SubEquipment
 * id: 26
 * statusTagId: 300
 * commFaultTagId: 301
 * aliveTagId: 302
 */
public static Configuration createSubEquipment() {
    Configuration configuration = new Configuration();
    SubEquipment subEquipment = SubEquipment.create("SE_INI_TEST").id(25L).statusTag(StatusTag.create("SE:STATUS").id(300L).build()).commFaultTag(CommFaultTag.create("SE:Comm").id(301L).build()).aliveTag(AliveTag.create("SE:Alive").id(302L).address(new DataTagAddress()).build(), 60000).build();
    subEquipment.setEquipmentId(15L);
    configuration.addEntity(subEquipment);
    return configuration;
}
Also used : DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) SubEquipment(cern.c2mon.shared.client.configuration.api.equipment.SubEquipment)

Example 27 with DataTagAddress

use of cern.c2mon.shared.common.datatag.DataTagAddress in project c2mon by c2mon.

the class AbstractTestDynamicTimeDeadbandActivator method setUpClass.

@BeforeClass
public static void setUpClass() {
    getSourceDataTags().put(getTestKey(), getTestTag());
    DataTagAddress address = new DataTagAddress();
    address.setTimeDeadband(0);
    getTestTag().setAddress(address);
}
Also used : DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) BeforeClass(org.junit.BeforeClass)

Example 28 with DataTagAddress

use of cern.c2mon.shared.common.datatag.DataTagAddress in project c2mon by c2mon.

the class AbstractTestDynamicTimeDeadbandActivator method testDataTagAddRemove.

@Test
public void testDataTagAddRemove() {
    SourceDataTag tag = new SourceDataTag(2L, "123", false);
    DataTagAddress address = new DataTagAddress();
    address.setTimeDeadband(30);
    tag.setAddress(address);
    activator.addDataTag(tag);
    assertTrue(tag.getAddress().isTimeDeadbandEnabled());
    assertNotNull(activator.getDataTagMap().get(2L));
    activator.removeDataTag(tag);
    assertNull(activator.getDataTagMap().get(2L));
    assertFalse(tag.getAddress().isTimeDeadbandEnabled());
}
Also used : SourceDataTag(cern.c2mon.shared.common.datatag.SourceDataTag) DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) Test(org.junit.Test)

Example 29 with DataTagAddress

use of cern.c2mon.shared.common.datatag.DataTagAddress in project c2mon by c2mon.

the class AbstractTestDynamicTimeDeadbandActivator method testMultiThread.

@Test
public void testMultiThread() throws InterruptedException {
    Collection<Timer> timers = new ArrayList<Timer>();
    for (long i = 0; i < NUMBER_OF_TEST_TAGS; i++) {
        DataTagAddress address = new DataTagAddress();
        address.setTimeDeadband(0);
        activator.addDataTag(new SourceDataTag(i, "asd", false, (short) 0, "Boolean", address));
    }
    for (int j = 0; j < 10; j++) {
        Timer timer = new Timer();
        timers.add(timer);
        timer.scheduleAtFixedRate(new TimerTask() {

            @Override
            public void run() {
                for (int i = 0; i < NUMBER_OF_TEST_TAGS; i++) activator.newTagValueSent(Double.valueOf(Math.random() * NUMBER_OF_TEST_TAGS - 1).intValue());
            }
        }, 0, 1);
    }
    for (Timer timer : timers) {
        timer.cancel();
    }
    activator.clearDataTags();
}
Also used : DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) SourceDataTag(cern.c2mon.shared.common.datatag.SourceDataTag) Test(org.junit.Test)

Example 30 with DataTagAddress

use of cern.c2mon.shared.common.datatag.DataTagAddress in project c2mon by c2mon.

the class ConfigurationUpdaterTest method testUpdateDataTag.

@Test
public void testUpdateDataTag() throws IllegalAccessException, NoSuchFieldException {
    SourceDataTag sourceDataTag = new SourceDataTag(1L, "asd", false);
    sourceDataTag.setMaxValue(100L);
    sourceDataTag.setMode((short) 1);
    TestHardwareAddress oldHwAddress = new TestHardwareAddress("start");
    DataTagAddress address = new DataTagAddress();
    address.setTimeDeadband(100);
    sourceDataTag.setAddress(address);
    address.setHardwareAddress(oldHwAddress);
    DataTagUpdate update = new DataTagUpdate();
    update.setMaxValue(1000L);
    update.addFieldToRemove("mode");
    DataTagAddressUpdate dataTagAddressUpdate = new DataTagAddressUpdate();
    dataTagAddressUpdate.setTimeDeadband(10);
    dataTagAddressUpdate.setFreshnessInterval(100);
    update.setDataTagAddressUpdate(dataTagAddressUpdate);
    HardwareAddressUpdate hwUpdate = new HardwareAddressUpdate();
    hwUpdate.getChangedValues().put("testField", "new");
    dataTagAddressUpdate.setHardwareAddressUpdate(hwUpdate);
    assertEquals(1, sourceDataTag.getMode());
    assertNotSame(update.getMaxValue(), sourceDataTag.getMaxValue());
    configurationUpdater.updateDataTag(update, sourceDataTag);
    assertEquals(update.getMaxValue(), sourceDataTag.getMaxValue());
    assertEquals("asd", sourceDataTag.getName());
    assertEquals(0, sourceDataTag.getMode());
    assertEquals(10, address.getTimeDeadband());
    assertEquals("new", ((TestHardwareAddress) sourceDataTag.getHardwareAddress()).getTestField());
    assertTrue(address.getFreshnessInterval() == 100);
}
Also used : SourceDataTag(cern.c2mon.shared.common.datatag.SourceDataTag) DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) HardwareAddressUpdate(cern.c2mon.shared.daq.config.HardwareAddressUpdate) DataTagUpdate(cern.c2mon.shared.daq.config.DataTagUpdate) DataTagAddressUpdate(cern.c2mon.shared.daq.config.DataTagAddressUpdate) Test(org.junit.Test)

Aggregations

DataTagAddress (cern.c2mon.shared.common.datatag.DataTagAddress)46 Timestamp (java.sql.Timestamp)13 Test (org.junit.Test)12 Configuration (cern.c2mon.shared.client.configuration.api.Configuration)11 DataTagCacheObject (cern.c2mon.server.common.datatag.DataTagCacheObject)10 DataTag (cern.c2mon.shared.client.configuration.api.tag.DataTag)10 ContextConfiguration (org.springframework.test.context.ContextConfiguration)8 SourceDataTag (cern.c2mon.shared.common.datatag.SourceDataTag)7 Properties (java.util.Properties)7 ConfigurationDataTagUtil.buildCreateAllFieldsDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateAllFieldsDataTag)5 ConfigurationDataTagUtil.buildCreateBasicDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag)5 ControlTagCacheObject (cern.c2mon.server.common.control.ControlTagCacheObject)4 ConfigurationReport (cern.c2mon.shared.client.configuration.ConfigurationReport)4 Metadata (cern.c2mon.shared.client.metadata.Metadata)4 ConfigurationChangeEventReport (cern.c2mon.shared.daq.config.ConfigurationChangeEventReport)4 HashMap (java.util.HashMap)4 Metadata (cern.c2mon.server.common.metadata.Metadata)3 ConfigurationElement (cern.c2mon.shared.client.configuration.ConfigurationElement)3 SubEquipment (cern.c2mon.shared.client.configuration.api.equipment.SubEquipment)3 Tag (cern.c2mon.shared.client.configuration.api.tag.Tag)3