Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am reading log file which contains huge data
C#
Timestamps Bus   MsgId
   1.8963     1     CFF8027x        Rx   d 8 0C 00 01 FC FD F0 0F 00
   1.8966     1     CFFB027x        Rx   d 8 FC FF FF D3 FC FF FF FF
   1.8967     2     CFE6CEEx        Rx   d 8 FF FF FF FF 00 00 00 00
   1.8967     3     18ECFF27x       Rx   d 8 20 12 00 03 FF EC FE 00
   1.8972     2     CFFB027x        Rx   d 8 FC FF FF D3 FC FF FF FF
   1.8973     3     CFE6CEEx        Rx   d 8 FF FF FF FF 00 00 00 00


The above is example of data
There are 4623509 lines of data

Bus with number 1 is red
Bus with number 2 is yellow
Bus with number 3 is green

I read the data using Readalllines and using constructor with 3 objects to save timestamps,bus and msgId

C#
CANMsgIdList.Add(new MsgIdTimeStampMap(CANBus, CANMsgId, timeStamp1));


MsgIdTimeStampMap is my constructor with 3 objets

I also deleted the repeated msgids using .Distict method

Now I am trying to find the messages passing from red to yellow with same msgId and different bus without passing to green or other in between

C#
int p = 233;

               
                     for (int i = 0; i < CANMsgIdList.Count; i++)
                    {

                        for (int k = 0; k < CANMsgIdList.Count; k++)
                        {
                           

                   

                        if ((gatewayRYmsgId[p] == CANMsgIdList[i].MsgId) 
                            && (CANMsgIdList[i].Bus).Equals(ConsoleApplication13.Buses.CANBusRed)
                            && (gatewayRYmsgId[p] == CANMsgIdList[k].MsgId) 
                            && (CANMsgIdList[k].Bus).Equals(ConsoleApplication13.Buses.CANBusYellow))
                           
                             {
                           
                                  {

                                    gatewayRtimeStamp.Add(CANMsgIdList[i].TimeStamp);

                                    Console.WriteLine(gatewayRtimeStamp[j]);
                                    Console.ReadKey();

                                    j++;

                                   
                                  }
                               }                           
                          }
                        }       


I am getting error at line
C#
if ((gatewayRYmsgId[p] == CANMsgIdList[i].MsgId)
                           && (CANMsgIdList[i].Bus).Equals(ConsoleApplication13.Buses.CANBusRed)
                           && (gatewayRYmsgId[p] == CANMsgIdList[k].MsgId)
                           && (CANMsgIdList[k].Bus).Equals(ConsoleApplication13.Buses.CANBusYellow))


Error:Index out of range

But I do not understand. wy this error???

Thanks
John
Posted
Comments
Sergey Alexandrovich Kryukov 3-Jan-14 19:02pm    
Use the debugger to see where the index goes out of the valid range. Understand why it happened and fix it.
—SA

See the comment from SA about debugging.

Do that and examine the size of gatewayRYmsgId

Note that it is less than 233.
 
Share this answer
 
Comments
Maciej Los 3-Jan-14 19:21pm    
Chill, it's not worth to answer. Please, have a look at the number of questions posted by OP. OP needs to start learning...
CHill60 3-Jan-14 19:26pm    
Yeah - spotted that. Answer is mainly to get it out of the list. Do you think OP will realise why 233 is significant? I was thinking of running a book on what the next post will be ;-)
Dear @[Member 10408451],

As i mentioned in a comment to the Solution 1 by CHill60, you need to start with basics. Have a look at the number of your questions[^]. Most of them beat about some "Buses". You're trying to make calculations on List<t></t> generic list and arrays.

I would suggest to re-think your application and start coding from 0 (zero). I think you'll never go further in case of several lacks of knowledge, sorry...

Please, describe your problem in details:

  1. the way you retrieve data...
  2. what do you want to achieve?
  3. what methods do you prefer
  4. provide sample data
  5. etc...


Please, make yourself a big favor and provide more information about your dilemma. We can help you to find a solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900