4

met with some problem in getting started on this.. Currently my project receives data from serial port. But the data received looks like this

Time >>>>>>>Unit no.

10:40:17:08  16   26.7
10:40:17:10  16   26.7
10:40:17:23  16   26.7

All these data received upon real time.

How should i modify the Datetime.Now coding to show the data like this..

8:40:17:08  16   26.7
9:40:17:10  16   26.7
10:40:17:23  16   26.7

meaning that only the last received data will be of the real time timing, the remaining data with the common "seconds" should have their hour being push back accordingly.

I roughly understand that i should add this "DateTime.Now.AddHours(-1)" only

EDITED

The system should know that if it received thrice same number (16) data, the timing of those 3 number16 data should change accordingly.. So how should i compare the data received?

if (number = 3times)

{edit the time}

else

{record as usual} 
Athena
  • 73
  • 1
  • 8
  • @GrantWinney Actually what i received from the serial port is only the behind portion, no time stamp. The time stamp is a component i added in individually. It is rather impractical to have the same data received thrice or more at the same hr:min:sec as a result I'm trying to push back the Hr accordingly – Athena Jun 22 '15 at 04:30
  • I would not use a timestamp like this, the timestamp class has a strong indication that it is based on time. If you want to order these records further how about adding an integer `orderReceived` and incrementing that each time you process a record. – David Waters Jun 22 '15 at 04:39
  • @DavidWaters can you show me an example? i dont quite understand.. – Athena Jun 22 '15 at 05:37
  • What are you actually trying to do? It seems like you're trying to smooth out some readings over a period of time? There's plenty of ways to handle that, without faking "timestamps" - but you have to focus on the problem you actually have, not on the problems your "solution" has. Try adding more information about the *core* of what you need to do. – Luaan Jun 22 '15 at 07:58
  • @Luaan Basically, the program received a string of data like "16 26.7". Initially, when i start running the serial port, data will flow in as time past. But I want to know when did the data was received, therefore DateTime.Now function was added. By right data flowing should be of diff Unit no. one after another. But let say a particular Unit no. received thrice, it means that 2 out of the 3 data was actually back traced ones.. Hence, I need to change the time stamp.. *Sorry for my english tho.. – Athena Jun 22 '15 at 08:13

0 Answers0