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;
}
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);
}
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());
}
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();
}
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);
}
Aggregations