1 /*******************************************************************************
2 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * VTT Technical Research Centre of Finland - initial API and implementation
10 *******************************************************************************/
11 package org.simantics.simulation.data;
13 import java.util.Collection;
14 import java.util.concurrent.Executor;
15 import java.util.concurrent.locks.Lock;
17 import org.simantics.databoard.binding.Binding;
18 import org.simantics.databoard.binding.NumberBinding;
19 import org.simantics.databoard.type.Datatype;
20 import org.simantics.databoard.util.Bean;
23 * Interface for adapting data provider to HistoryCollector.
25 * @author Toni Kalajainen
27 public interface Datasource {
29 Collection<String> getVariables();
30 Datatype getType(String key);
32 void addListener(DatasourceListener listener);
33 void removeListener(DatasourceListener listener);
36 * Try to open a handle to a variable
39 * the subscription item to open a handle for
41 * requested handle address, should equal
42 * SubscriptionItem#variableId
44 * binding for handling the requested value
45 * @return Variable Handle or <code>null</code> if handle cannot be resolved
48 VariableHandle openHandle(Bean item, String key, Binding valueBinding);
50 public interface DatasourceListener {
53 * When listeners are processed, the data source does not proceed.
54 * It is locked, but this is valid only for listeners with executor
55 * as null. Values are typically read within a listener.
59 void onStep(Datasource source);
62 * Get executor where listener is handled.
63 * If returned value is null, listener is handled synchronously in
68 Executor getExecutor();
72 // The following methods produce sensible values only when the source
73 // is locked or within listener (when it is locked).
76 Object getTime(NumberBinding binding);