DMA logging now working - logging 25x faster than MUT
#16
With the strings, you may also want to look into the StringBuilder class.
I would definitely try and keep the conversions from string to floats a minimal as possible.
How big is your project so far?
I would definitely try and keep the conversions from string to floats a minimal as possible.
How big is your project so far?
#18
Evolved Member
Thread Starter
I think then that the easy way is to have an array of single precision float for the scaling to convert the ECU replies into real units. I have a multiplier and an adder for all except the coolant and air temps which are not speed sensitive as they won't be in my really fast loop.
The slimmed down project is now only 350 lines of code to do the following except process the DMA reply (I've got rid of all the hard coded ECU model specific stuff and it is all in the xml now even though I know I'm not following the full xml schema it works, I've got rid of all the text boxes, excess buttons, graphs, knock plots etc that were bloating it, far tidier):
Read xml for logging, live mapping and map switching settings
Display above in listviews when app opened
Display live fuel and timing maps with correct dimensions, axes and memory addresses
Connect to the ECU
Open logging file
Request the logged items from the ECU (just send request E5 and await the reply length programmed into the ECU - 14 bytes for first test as below)
(process the DMA reply to a string to write a row to the log file)
Allow live fuel and timing maps to be read/written/edited with short interruptions in normal logging (these are still done through normal MUT rather than DMA - I will add that later)
Close logging file and disconnect from ECU
So it is nearly ready to test after the holiday period. ECU is ready to roll to support all the above already - I just need to write a 14 byte DMA table equivalent to the MUT table containing in sequence my fast loop logging items that are time sensitive.
The slimmed down project is now only 350 lines of code to do the following except process the DMA reply (I've got rid of all the hard coded ECU model specific stuff and it is all in the xml now even though I know I'm not following the full xml schema it works, I've got rid of all the text boxes, excess buttons, graphs, knock plots etc that were bloating it, far tidier):
Read xml for logging, live mapping and map switching settings
Display above in listviews when app opened
Display live fuel and timing maps with correct dimensions, axes and memory addresses
Connect to the ECU
Open logging file
Request the logged items from the ECU (just send request E5 and await the reply length programmed into the ECU - 14 bytes for first test as below)
(process the DMA reply to a string to write a row to the log file)
Allow live fuel and timing maps to be read/written/edited with short interruptions in normal logging (these are still done through normal MUT rather than DMA - I will add that later)
Close logging file and disconnect from ECU
So it is nearly ready to test after the holiday period. ECU is ready to roll to support all the above already - I just need to write a 14 byte DMA table equivalent to the MUT table containing in sequence my fast loop logging items that are time sensitive.
Last edited by jcsbanks; Dec 24, 2007 at 03:04 PM.
#19
Newbie
iTrader: (17)
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes
on
0 Posts
I am an embedded developer, in industry, and we're using C# for everything we can now. There was some resistance, but take a look at what MS is doing with C# and you'll be more than pleasantly surprised, especially comparing to managed C++ code.
Try out C# for the GUI over VB.NET, I promise it's worth the switch now. Any of the easy designer stuff you have in VB, you have in C# and it's a much better language. I would be willing to help out time permitting as this is all stuff I've done before, just not with VB code. I've done all of the async callbacks in C# and could help out with that portion of the framework as well.
Mike
#20
Evolved Member
Thread Starter
Thanks both for the info on stringbuilder, reading up on this has started to explain some of the performance issues I have seen before.
There is also a lot of heavy string manipulation in my dataset/datagridview stuff for the realtime mapping. You can actually see the datagridview redraw (quickly). Each cell is accessed as a string, this is the only way I got it to work. Can anyone suggest a really quick way to link an integer or floating point array to an editable grid display (editing a fuel or timing map)?
There is also a lot of heavy string manipulation in my dataset/datagridview stuff for the realtime mapping. You can actually see the datagridview redraw (quickly). Each cell is accessed as a string, this is the only way I got it to work. Can anyone suggest a really quick way to link an integer or floating point array to an editable grid display (editing a fuel or timing map)?
#21
Evolved Member
iTrader: (22)
Thanks both for the info on stringbuilder, reading up on this has started to explain some of the performance issues I have seen before.
There is also a lot of heavy string manipulation in my dataset/datagridview stuff for the realtime mapping. You can actually see the datagridview redraw (quickly). Each cell is accessed as a string, this is the only way I got it to work. Can anyone suggest a really quick way to link an integer or floating point array to an editable grid display (editing a fuel or timing map)?
There is also a lot of heavy string manipulation in my dataset/datagridview stuff for the realtime mapping. You can actually see the datagridview redraw (quickly). Each cell is accessed as a string, this is the only way I got it to work. Can anyone suggest a really quick way to link an integer or floating point array to an editable grid display (editing a fuel or timing map)?
The visible redraw is definitely happening because you don't have multi-threading. The main thread in the process for a GUI app is also responsible for taking care of the redraw. When its not locked up, it can do it quickly enough so you don't notice it happening. Redraws, bleeding etc. are always signs that the thread is getting hammered.
An expensive way to stop this from happening would be to prematurely manually force the redraw yourself while doing the logging but then you'd probably end up making the logging loose resolution or some other effect .
#22
Newbie
iTrader: (17)
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes
on
0 Posts
If you're using it for a map, you're probably going to want to use a DataTable underneath. You can set the DataGridView.DataSource to a BindingSource and set the BindingSource.DataSource to the table. That will allow you to edit the map.
MSDN has a class reference http://msdn2.microsoft.com/en-us/library/ms229335.aspx
MSDN has a class reference http://msdn2.microsoft.com/en-us/library/ms229335.aspx
#23
Evolved Member
Thread Starter
I am finding pretty poor performance on the datagridview in that it takes about 1-2 seconds to redraw the ignition map even when it isn't doing anything else.
This is the setup:
Dim ignition As New DataSet
ignition.Tables.Add("MyIgnTable")
Me.DataGridView2.DataSource = ignition
Me.DataGridView2.DataMember = "MyIgnTable"
Then I write in the row and column values (once, speed doesn't matter).
Then the sub that is called 400 times to update the values:
Private Sub gridign(ByVal x As Integer, ByVal y As Integer, ByVal d As Integer)
ignition.Tables(0).Rows(y).Item(x) = d.ToString 'THIS IS THE SLOW INSTRUCTION
End Sub
I would like to use a 2d array of single precision floating point for the fuel map and integer for the ignition map and use a BindingSource to link these to the DataGridView. All the stuff I can read up on is biased towards loading in databases and I can't find an example to help me simply show and allow editing of the underlying 2d array. Any suggestions?
This is the setup:
Dim ignition As New DataSet
ignition.Tables.Add("MyIgnTable")
Me.DataGridView2.DataSource = ignition
Me.DataGridView2.DataMember = "MyIgnTable"
Then I write in the row and column values (once, speed doesn't matter).
Then the sub that is called 400 times to update the values:
Private Sub gridign(ByVal x As Integer, ByVal y As Integer, ByVal d As Integer)
ignition.Tables(0).Rows(y).Item(x) = d.ToString 'THIS IS THE SLOW INSTRUCTION
End Sub
I would like to use a 2d array of single precision floating point for the fuel map and integer for the ignition map and use a BindingSource to link these to the DataGridView. All the stuff I can read up on is biased towards loading in databases and I can't find an example to help me simply show and allow editing of the underlying 2d array. Any suggestions?
Last edited by jcsbanks; Dec 25, 2007 at 04:00 PM.
#24
Newbie
iTrader: (17)
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes
on
0 Posts
I whipped something up real quick in C# for you to look at. The program has a 2D table (just 2 columns) and every second a Timer expires and updates one of the 3 rows in the DataTable underneath. I did the binding i mentioned in my post above and you'll see the updates to the GUI automagically occur.
Mike
Mike
I am finding pretty poor performance on the datagridview in that it takes about 1-2 seconds to redraw the ignition map even when it isn't doing anything else.
This is the setup:
Dim ignition As New DataSet
ignition.Tables.Add("MyIgnTable")
Me.DataGridView2.DataSource = ignition
Me.DataGridView2.DataMember = "MyIgnTable"
Then I write in the row and column values (once, speed doesn't matter).
Then the sub that is called 400 times to update the values:
Private Sub gridign(ByVal x As Integer, ByVal y As Integer, ByVal d As Integer)
ignition.Tables(0).Rows(y).Item(x) = d.ToString 'THIS IS THE SLOW INSTRUCTION
End Sub
I would like to use a 2d array of single precision floating point for the fuel map and integer for the ignition map and use a BindingSource to link these to the DataGridView. All the stuff I can read up on is biased towards loading in databases and I can't find an example to help me simply show and allow editing of the underlying 2d array. Any suggestions?
This is the setup:
Dim ignition As New DataSet
ignition.Tables.Add("MyIgnTable")
Me.DataGridView2.DataSource = ignition
Me.DataGridView2.DataMember = "MyIgnTable"
Then I write in the row and column values (once, speed doesn't matter).
Then the sub that is called 400 times to update the values:
Private Sub gridign(ByVal x As Integer, ByVal y As Integer, ByVal d As Integer)
ignition.Tables(0).Rows(y).Item(x) = d.ToString 'THIS IS THE SLOW INSTRUCTION
End Sub
I would like to use a 2d array of single precision floating point for the fuel map and integer for the ignition map and use a BindingSource to link these to the DataGridView. All the stuff I can read up on is biased towards loading in databases and I can't find an example to help me simply show and allow editing of the underlying 2d array. Any suggestions?
#27
Newbie
iTrader: (17)
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes
on
0 Posts
I'm not sure if you're familiar with partial classes but it basically allows you to split a class into multiple files but still have all the code behave as if it's all in the same file in the same class. MS uses partials to split up autogen code from user written code in the same class.
#28
Evolved Member
Thread Starter
Thanks, it loaded into 2008 Express fine and ran as you intended.
I've managed to get some of my own code working with a datatable and displaying. Will see if the performance is better.
I've managed to get some of my own code working with a datatable and displaying. Will see if the performance is better.
#30
Evolved Member
Thread Starter
Thanks v much. With your example I have managed to use datatables or datasets with various types. However, it was still slow! Eventually I found that having autoresize columns off speeded it up whether strings ints or floats were used. I am trying to work out how to set the column width in the code for a datagridview.