*/
void setState(Bean newState);
+ /**
+ * Allows history collector writers to optimize their invocations of the collector.
+ *
+ * @return <code>true</code> if the this collector is enabled for collection or
+ * <code>false</code> otherwise.
+ * @since 1.50.0, 1.35.3, 1.48.0.1
+ */
+ default boolean isEnabled() {
+ return true;
+ }
+
}
/** True when all items are open */
boolean itemsOpen = true;
+
+ /** True when history collection will write data to disk */
+ boolean enabled = true;
+
+ /**
+ * Transient info only set in {@link #beginStep(NumberBinding, Object)} based on
+ * {@link #enabled}
+ */
+ private transient boolean stepEnabled = true;
public FlushPolicy flushPolicy = FlushPolicy.FlushOnEveryStep;
this.history = history;
this.state = (CollectorState) previousState.clone();
}
-
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
@Override
public synchronized void addItem(Bean item) throws HistoryException {
try {
@Override
public void beginStep(NumberBinding binding, Object time) throws HistoryException {
- openAllItems();
+ stepEnabled = enabled;
updateDt(binding, time);
state.time.setValue(binding, time);
+ if (enabled) {
+ openAllItems();
+ }
}
@Override
public void setValue(String id, Binding binding, Object value) throws HistoryException {
+ // Short-circuit calls when collection not enabled
+ if (!stepEnabled)
+ return;
+
VariableState vs = state.values.get( id );
if (vs == null) {
vs = new VariableState();
@Override
public void endStep() throws HistoryException {
+ if (!stepEnabled)
+ return;
// Write values to streams
for (ActiveStream i : items)
{
import java.util.Collection;
import java.util.Iterator;
+import org.simantics.databoard.Bindings;
import org.simantics.databoard.annotations.Identifier;
+import org.simantics.databoard.binding.Binding;
import org.simantics.databoard.type.Datatype;
import org.simantics.databoard.util.Bean;
*/
public class SubscriptionItem extends Bean {
+ private static final Binding BINDING = Bindings.getBindingUnchecked(SubscriptionItem.class);
+
+ public SubscriptionItem() {
+ super(BINDING);
+ }
+
/**
* Create HistoryItem descriptions for collecting one variable with multiple
* sampling formats.