views:

49

answers:

2

Hey all, I'm currently working on a robot interface GUI, using C#. The robot has two sensors, and two powered wheels. I need to let the user the option to load a Look Up Table (LUT) during runtime, one for each sensor, that will tell the robot what to do according to the sensor's reading. I think the best way to do it is using a .csv file, formatted like so:

index , right wheel order, left wheel order

the index is an int between 0-1023 and is actually the sensor's reading. the orders for the right and left wheel are integers, between -500 - 500.

Example - left sensor's readings:

1,10,20 meaning:

sensor reads 1 --> left wheel 10 rpm right wheel 20 rpm

So my question is this:

what is the best way to implement it? using a dataset?(if so, how?) using an array? (if so, how do I load it during runtime?)

Any help would be much appreciated,

Yarok

+1  A: 

For loading text files look at the StreamReader class. For storing these values I would use a dictionary.

Christopherous 5000
thank you!Does the StreamReader class have a graphic component? (like a button or so?)
Yarok
You can also use `File.ReadAllText()` and `File.ReadAllLines()`
Callum Rogers
A: 

If you're using .NET 4.0 you can store the values in a Tuple<int,int,int> and a collection of those in a List.

If you need fast lookups you can use a dictionary to key on a value, but that value must be unique.

If you're not using .NET 4.0 just create a data class with 3 int variables for your readings.

Aren
Thanks for the answer, but what is Tuple? some kind of dictionary?
Yarok
A Tuple is just a way of grouping a fixed number `n` number of items together. Strongly. It's just the data element, it dosen't take dynamic `n`. So you have 3 data values, you'd use `Tuple<T,T2,T3>` and then have a list of them as the most simple implementation.
Aren