2

I am dealing with a stream of data on serial port. The baud rate is 19200 kbps, leaving a shot time (about 100 ms) to process data and display the result on the screen.

There is no issue with data processing performance. The main problem is updating the screen. The application specification needs me to show data in a tabular view. Cell contexts in this view might have different colours based on the information they indicate. For example red for errors, green or blue for some kinds of messages and etc.

Currently, I am using a datagridview to display the data as it has a flexible tabular view, and its cells has ForeColor property to change the colour. But, it is too slow compared to the input data and processing rate. Specifically, when I add new rows on new data arrival or remove old rows from the beginning. To add and remove a row I use the DGV.Rows.Add(...), and DGV.Rows.RemoveAt(...) methods.

I considered two approaches:

1) Two different threads for processing data and updating UI. However, as data processing is much faster than operations on datagridview, data will be accumulated and finally slow down everything.

2) Processing data and update the screen sequentially. In this case, after processing of each message, the message will be displayed on the screen (will be added to the datagridview), and the next will be processed after the screen update. Obviously, this way decreases the processing speed which in not desirable.

So, I am wondering if there is any better ways to handle this condition... or if I am not using the right control in terms of the performance for this purpose.

Thanks.

Andrey Agibalov
  • 7,624
  • 8
  • 66
  • 111
Afshin
  • 487
  • 6
  • 22
  • BreK it down - how many rows/second are coming in, and how many is the user able (willing) to read? A GUI should be user-oreineted. – H H Aug 31 '11 at 23:05
  • say about 20 rows/seconds, and the user should be able too see all of them. – Afshin Sep 01 '11 at 13:23
  • But no human being _can_ read 20 rows/second. – H H Sep 01 '11 at 13:25
  • You are right. But, he/she may scroll down or up through incoming data. So, the data should be ready to be scrolled. – Afshin Sep 01 '11 at 13:31
  • And that data should stand still. I think this calls for a virtualized view of historical data. – H H Sep 01 '11 at 13:32

1 Answers1

0

1 with some smart programming that does not make the griview fall behind. I am runnin a grid here that shows real time financial updates and I do not fall behind, and that grid gets more data than your 19200 baud connection holds - I pretty much get up to 10.000 data items per second. I just discard those not of visible interest. Optimize the grid presentation. Get an alterantive grid (that is made to handle tons of updates).

TomTom
  • 61,059
  • 10
  • 88
  • 148
  • How do you add data items to the grid? Do you bind it to a data source, or use the Add method? Basically, in terms of the performance, is it a good idea to use Add or Remove methods to handle data at high data rate ? – Afshin Aug 31 '11 at 21:13
  • I dont. I update them. The items on the grid are "fixed" (i.e. rarely changed). The content of the cells changes. Plus I dont use the standard Grid - the Infragistics one is optimized for that sort of behavior a lot more. – TomTom Sep 01 '11 at 04:41
  • My problem is adding new rows, and removing old rows. For example, I have to show the last 1000 rows (newest ones), while the view should look like a stream of data. – Afshin Sep 01 '11 at 13:27
  • Ah. Hm, no problem with that either. Do you use graphic card level buffers for the rows? This hint makes HUGH difference for me. Goes into the templates. – TomTom Sep 01 '11 at 13:40
  • Could you explain it more. I am not sure if I got you perfectly. – Afshin Sep 01 '11 at 14:24