| Display.(a)syncExec() execution problem [message #662384] |
Wed, 30 March 2011 09:32  |
Eclipse User |
|
|
|
Hi RAP developers and community,
I am relatively new to this topic, but nevertheless I am trying to implement an application consisting of several bundles in RAP. One of them acts as a GUI (GUI bundle) and another one (monitoring bundle) is meant for collecting data from sensors attached to a platform running OSGi.
Among others the GUI consits of several views and one of them is used for displaying the informaiton received from the monitoring bundle in tabular mode (using org.eclipse.jface.viewers.TableViewer). For this purpose the GUI bundle registers a service which is used by the monitoring bundle for transmitting the collected data in an appropriate way. This is done periodically by implementing a java.util.Timer. Upon receiving new data, the data model of the GUI bundle gets updated and Display.asyncExec(runnable) is called. But the execution of the runnable occurs only after a user interaction with the browser window (e.g. resizing it, scrolling up/down or reordering the collumns of a table).
The corresponding pieces of code are listed below:
GUI bundle
public void updateRegularData(final String sensorclassID, final Node[] nodes) {
//create a list for the sensor data
List<SimpleSensor> sensorList = new ArrayList<SimpleSensor>();
//traverse all nodes of the sensorclass
for(Node node : nodes) {
//and every sensor of a node
for(Sensor sensor : node.getSensors()) {
//create new simplesensor with its properties
SimpleSensor newSensor = new SimpleSensor();
newSensor.setId(sensor.getID());
newSensor.setName(sensor.getName());
newSensor.setValue(sensor.getSensorValue().getValue());
newSensor.setMax(sensor.getSensorValue().getMax());
newSensor.setMin(sensor.getSensorValue().getMin());
newSensor.setUnit(sensor.getSensorValue().getUnit());
newSensor.setOnline(!sensor.isOffline());
newSensor.setParent(node.getID());
//and put it into the list
sensorList.add(newSensor);
}
}
//update the data of the model with the newly created list
SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
}
private class MyRunnable implements Runnable {
private final String sensorclassID;
MyRunnable(String sensorclassID) {
this.sensorclassID = sensorclassID;
}
@Override
public void run() {
//this call does not affect anything
UICallBack.activate(sensorclassID);
//check whether there is already a view for displaying the data
if(!manager.containsViewer(sensorclassID)) {
//if not, create a new one
manager.createViewer(MonitoringView.TOP_CONTAINER, sensorclassID);
}
else {
//otherwise just update the view
manager.updateViewer(sensorclassID);
}
//this call does not affect anything
UICallBack.deactivate(sensorclassID);
}
}
As stated above, the execution of run()s occurs only after a user interaction with the GUI, meaning that the corresponding threads are waiting for an event, which is not intended.
Is there any possibility to force the execution, so that the GUI gets updated immediately after receiving new data?
Every helpful suggestion for solving this behavior is greatly appreciated.
Greetings,
Dimitri
[Updated on: Wed, 30 March 2011 09:32] by Moderator
|
|
|
| Re: Display.(a)syncExec() execution problem [message #662613 is a reply to message #662384] |
Thu, 31 March 2011 05:45   |
Eclipse User |
|
|
|
Hi Dimitri,
activate the UICallBack outside the runnable... something like this:
SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
UICallBack.activate(sensorclassID);
MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
HTH,
Ivan
On 3/30/2011 4:32 PM, Dimitri Jeske wrote:
> Hi RAP developers and community,
>
> I am relatively new to this topic, but nevertheless I am trying to
> implement an application consisting of several bundles in RAP. One of
> them acts as a GUI (GUI bundle) and another one (monitoring bundle) is
> meant for collecting data from sensors attached to a platform running
> OSGi.
> Among others the GUI consits of several views and one of them is used
> for displaying the informaiton received from the monitoring bundle in
> tabular mode (using org.eclipse.jface.viewers.TableViewer). For this
> purpose the GUI bundle registers a service which is used by the
> monitoring bundle for transmitting the collected data in an
> appropriate way. This is done periodically by implementing a
> java.util.Timer. Upon receiving new data, the data model of the GUI
> bundle gets updated and Display.asyncExec(runnable) is called. But the
> execution of the runnable occurs only after a user interaction with
> the browser window (e.g. resizing it, scrolling up/down or reordering
> the collumns of a table).
>
> The corresponding pieces of code are listed below:
>
> GUI bundle
> public void updateRegularData(final String sensorclassID, final Node[]
> nodes) {
> //create a list for the sensor data
> List<SimpleSensor> sensorList = new ArrayList<SimpleSensor>();
> //traverse all nodes of the sensorclass
> for(Node node : nodes) {
> //and every sensor of a node
> for(Sensor sensor : node.getSensors()) {
> //create new simplesensor with its properties
> SimpleSensor newSensor = new SimpleSensor();
> newSensor.setId(sensor.getID());
> newSensor.setName(sensor.getName());
> newSensor.setValue(sensor.getSensorValue().getValue());
> newSensor.setMax(sensor.getSensorValue().getMax());
> newSensor.setMin(sensor.getSensorValue().getMin());
> newSensor.setUnit(sensor.getSensorValue().getUnit());
> newSensor.setOnline(!sensor.isOffline());
> newSensor.setParent(node.getID());
> //and put it into the list
> sensorList.add(newSensor);
> }
> }
> //update the data of the model with the newly created list
> SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
> MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
> }
>
> private class MyRunnable implements Runnable {
> private final String sensorclassID;
> MyRunnable(String sensorclassID) {
> this.sensorclassID = sensorclassID;
> }
> @Override
> public void run() {
> //this call does not affect anything
> UICallBack.activate(sensorclassID);
> //check whether there is already a view for displaying the data
> if(!manager.containsViewer(sensorclassID)) {
> //if not, create a new one
> manager.createViewer(MonitoringView.TOP_CONTAINER, sensorclassID);
> }
> else {
> //otherwise just update the view
> manager.updateViewer(sensorclassID);
> }
> //this call does not affect anything
> UICallBack.deactivate(sensorclassID);
> }
> }
> As stated above, the execution of run()s occurs only after a user
> interaction with the GUI, meaning that the corresponding threads are
> waiting for an event, which is not intended.
> Is there any possibility to force the execution, so that the GUI gets
> updated immediately after receiving new data?
> Every helpful suggestion for solving this behavior is greatly
> appreciated.
>
> Greetings,
> Dimitri
|
|
|
|
|
|
|
|
| Re: Display.(a)syncExec() execution problem [message #665735 is a reply to message #662613] |
Fri, 15 April 2011 12:35  |
Eclipse User |
|
|
|
Hi all,
first of all sorry for hijacking this thread, but I am dealing with a (remotely) related issue.
The issue is this:
1. UICallback is active
2. We are using Display.syncExec() to run some UI code within a background thread
3. The UI is updated just fine
4. But, it's quite slow
5. In some cases syncExec() has a delay of more than 900ms before runnnig the UI code
6. Multiple syncExec() calls result in accumulative 3-4s to run 100 ms code
I've got three questions:
1. Is there any way to force syncExec() to run with a shorter delay? Does the browser
need to send requests faster for that purpose? The desirable delay would be
less than 100ms.
2. The purpose of having the background thread with the syncExec() calls is to split the
generated JS code into smaller chunks. Otherwise the script takes too long to execute.
Could you propose an alternative way of sending smaller JS chunks to the browser,
which avoids the delays of syncExec calls?
3. Is my approach generally wrong? Like could higher latency make the syncExec() delay multiple times longer?
Thanks & Regards,
tibersept
|
|
|
Powered by
FUDForum. Page generated in 0.05247 seconds