use of cern.c2mon.shared.common.datatag.ValueUpdate in project c2mon by c2mon.
the class RequestControllerTest method getBasicConfigurationController.
/**
* @return configurationController
*/
private ConfigurationController getBasicConfigurationController() {
ConfigurationController configurationController = new ConfigurationController();
ProcessConfiguration processConfiguration = new ProcessConfiguration();
EquipmentConfiguration equipmentConfiguration = new EquipmentConfiguration();
EquipmentConfiguration equipmentConfiguration2 = new EquipmentConfiguration();
SourceCommandTag commandTag = new SourceCommandTag(1L, "hello");
DataTagAddress address = new DataTagAddress();
SourceDataTag sourceDataTag = new SourceDataTag(1L, "asd", false, (short) 0, "Integer", address);
SourceDataTag sourceDataTag2 = new SourceDataTag(2L, "asd", false, (short) 0, "Integer", address);
SourceDataTag sourceDataTag3 = new SourceDataTag(3L, "asd", false, (short) 0, "Integer", address);
processConfiguration.setProcessID(1L);
equipmentConfiguration.setId(1L);
sourceDataTag.update(new ValueUpdate(25));
sourceDataTag2.update(new ValueUpdate(25));
sourceDataTag3.update(new ValueUpdate(25));
configurationController.setProcessConfiguration(processConfiguration);
processConfiguration.getEquipmentConfigurations().put(1L, equipmentConfiguration);
processConfiguration.getEquipmentConfigurations().put(2L, equipmentConfiguration2);
equipmentConfiguration.getCommandTags().put(1L, commandTag);
equipmentConfiguration.getDataTags().put(1L, sourceDataTag);
equipmentConfiguration2.getDataTags().put(2L, sourceDataTag2);
equipmentConfiguration2.getDataTags().put(3L, sourceDataTag3);
return configurationController;
}
use of cern.c2mon.shared.common.datatag.ValueUpdate in project c2mon by c2mon.
the class SDTTimeDeadbandScheduler method run.
/**
* The run method called from the timer.
*/
@Override
public void run() {
log.debug("scheduler[{}] : entering run()..", this.sourceDataTag.getId());
try {
synchronized (this.sourceDataTag) {
if (isScheduledForSending()) {
SourceDataTagValue currentSDValue = this.sourceDataTag.getCurrentValue();
FilterType filterType;
// The first time the lastSentSDTagValue is empty
if (this.lastSourceDataTag == null) {
filterType = FilterType.NO_FILTERING;
log.debug("\tscheduler[{}] : first time running scheduler", this.sourceDataTag.getId());
} else {
// Check the current Source Data tag against the last one sent since
// they have never been compared
// Cast the value to the proper type before sending it
Object newValueCasted = TypeConverter.cast(currentSDValue.getValue(), this.lastSourceDataTag.getDataType());
ValueUpdate update = new ValueUpdate(newValueCasted, currentSDValue.getValueDescription(), currentSDValue.getTimestamp().getTime());
filterType = this.dataTagValueFilter.isCandidateForFiltering(this.lastSourceDataTag, update, currentSDValue.getQuality());
log.debug("\tscheduler[" + this.sourceDataTag.getId() + "] : Filter type: " + filterType);
}
// The new value is not filtered out
if (filterType == FilterType.NO_FILTERING) {
// Clone the last value sent to the server
this.lastSourceDataTag = this.sourceDataTag.clone();
currentSDValue.setValueDescription(createValueDescription(this.lastSourceDataTag));
// Add the value sent
this.processMessageSender.addValue(currentSDValue);
log.debug("\tscheduler[{}] : sending value: {}", this.sourceDataTag.getId(), currentSDValue.getValue());
} else {
// The new value is filtered out
ValueUpdate update = new ValueUpdate(currentSDValue.getValue(), currentSDValue.getValueDescription(), currentSDValue.getTimestamp().getTime());
// Send to filter module (Dynamic or Static information added)
if (this.dynamicTimeDeadbandFilterer.isDynamicTimeDeadband(this.sourceDataTag)) {
log.debug("\tscheduler[" + this.sourceDataTag.getId() + "] : value filtered with Dynamic TimeDeadband : " + currentSDValue.getValue());
this.equipmentSenderFilterModule.sendToFilterModuleByDynamicTimedeadbandFilterer(this.sourceDataTag, update, filterType.getNumber());
} else {
log.debug("\tscheduler[" + this.sourceDataTag.getId() + "] : value filtered with Static TimeDeadband: " + currentSDValue.getValue());
this.equipmentSenderFilterModule.sendToFilterModule(this.sourceDataTag, update, filterType.getNumber());
}
}
// Reset the sendValue variable
this.sendValue = false;
} else {
log.debug("\tscheduler[#{}] : no new value to be sent", this.sourceDataTag.getId());
}
}
// synchronized
} catch (Exception exception) {
log.error("Critical error in scheduler for tag #{}", this.sourceDataTag.getId(), exception);
}
log.debug("scheduler[#{}] : leaving run()", this.sourceDataTag.getId());
}
use of cern.c2mon.shared.common.datatag.ValueUpdate in project c2mon by c2mon.
the class EquipmentTimeDeadband method sendToFilterModule.
/**
* Send to filter module (Dynamic or Static information added)
* @param currentTag The current tag value
*/
private void sendToFilterModule(final SourceDataTag currentTag) {
long tagID = currentTag.getId();
ValueUpdate currentValue = new ValueUpdate(currentTag.getCurrentValue().getValue(), currentTag.getCurrentValue().getValueDescription(), currentTag.getCurrentValue().getTimestamp().getTime());
log.debug("Sending time deadband filtered value to statistics module for #{}", tagID);
// Send to filter module (Dynamic or Static information added)
if (this.dynamicTimeDeadbandFilterer.isDynamicTimeDeadband(currentTag)) {
log.debug("Tag filtered through Dynamic time deadband filtering: '" + tagID + "'");
if (currentTag.getCurrentValue().getQuality() == null) {
this.equipmentSenderFilterModule.sendToFilterModuleByDynamicTimedeadbandFilterer(currentTag, currentValue, FilterType.TIME_DEADBAND.getNumber());
} else {
this.equipmentSenderFilterModule.sendToFilterModuleByDynamicTimedeadbandFilterer(currentTag, currentValue, currentTag.getCurrentValue().getQuality(), FilterType.TIME_DEADBAND.getNumber());
}
} else {
log.debug("Tag filtered through Static time deadband filtering: '" + tagID + "'");
if (currentTag.getCurrentValue().getQuality() == null) {
this.equipmentSenderFilterModule.sendToFilterModule(currentTag, currentValue, FilterType.TIME_DEADBAND.getNumber());
} else {
this.equipmentSenderFilterModule.sendToFilterModule(currentTag, currentValue, currentTag.getCurrentValue().getQuality(), FilterType.TIME_DEADBAND.getNumber());
}
}
}
Aggregations