You are on page 1of 3

HW Joker

Deadline: 15th December Monday, 23:59


It is expected you design a form application with the controls of two buttons, one listbox, one
openfiledialog and one timer.

When you press the Select File button, it will allow you to select the Sensor_data.dat file. (Put
Sensor_data.dat file under the Debug folder. )
Sensor_data.dat file includes data from a sensor:
00
00
00
00
AA
56
34
12
02
AA
00
00

Pay attention to the data that the end of each line includes space. Hence, you must use the Trim method
of string class.

The sensor normally sends a package of 5 data: AA 56 34 12 00.


The start of package is AA.
The 5th data represents either the sensor reading is positive or negative. 00 means positive and
02 means negative.
Other characters represent the value read by the sensor: 12,3456 or -12,3456. As you notice, 4th
data is the 1st and 2nd digits of the sensor reading, 3rd data is 4th and 5th digits, and 2nd data is 5th
and 6th digits.

If you look at the file, you can see that one package is including less than 5 data, and another one
has more than 5 data. This may happen because of the loss of data in the communication. Your
code should handle such problems.

After you select the file and press Open, all data in the file will be assigned to a List<string> collection:
Lets name it as msgStore.

After selecting the file, when you press the Start Reading button, timer control will start to tick. Time
interval is 10ms. At each tick, the code will call the LogMe method by sending the each element of
msgStore consecutively: LogMe(msgStore[cntr]);
In LogMe method, at first, the code will look for the AA. Till AA comes, at each tick, Waiting for AA will
be written to the listbox. Pay attention to the methods BeginUpdate and EndUpdate of listbox
control. If you do not use them properly, your code may not work.
When the whole package is read, the reading value will be added to the listbox as shown below. Do not
forget the item number in the listbox. Note that, there is no item number for the line Waiting for AA.
When the reading has reached to the end of list, the timer must stop.
Your code will convert the data to the meaningful readings and will handle corrupted
data(communication problems). Your output screen will be exactly as shown below.

You might also like