我如何...解决此异常 [英] How do I...solve this exception
问题描述
我正在阅读包含大量数据的日志文件
Hi,
I am reading log file which contains huge data
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
以上是数据示例
有4623509行数据
总线号码为1红色
2号巴士为黄色
3号巴士为绿色
我使用Readalllines并使用带有3个对象的构造函数来保存时间戳,总线和消息
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
CANMsgIdList.Add(new MsgIdTimeStampMap(CANBus, CANMsgId, timeStamp1));
MsgIdTimeStampMap是我的构造函数,包含3个objets
我还使用.Distict方法删除了重复的msgids
现在我试图找到从红色传递的消息黄色与相同的msgId和不同的总线没有传递到绿色或其他之间
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
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
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))
错误:索引超出范围
但我不明白。我的错误???
谢谢
John
Error:Index out of range
But I do not understand. wy this error???
Thanks
John
推荐答案
参见SA关于调试的评论。
这样做并检查gatewayRYmsgId的大小
注意它小于233。
See the comment from SA about debugging.
Do that and examine the size of gatewayRYmsgId
Note that it is less than 233.
亲爱的@ [会员10408451],
正如我在对解决方案1的评论中所提到的CHill60,你需要从基础开始。看一下你的问题的数量[ ^ ]。大多数人都打败了一些公共汽车。您正尝试在列表< t>< / t>
通用列表和数组
上进行计算。
我建议重新考虑你的应用程序并从0(零)开始编码。我想你几乎不会因为几个缺乏知识而走得更远,对不起...
请详细描述你的问题:
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 onList<t></t>
generic list andarrays
.
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:
- 您检索数据的方式......
- 您想要达到什么目标?
- 您更喜欢哪种方法?
- 提供样本数据
- 等......
请自己做一个非常有利,并提供有关您的困境的更多信息。我们可以帮助您找到解决方案。
Please, make yourself a big favor and provide more information about your dilemma. We can help you to find a solution.
这篇关于我如何...解决此异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!