ここでは、カスタムWindDataPointタイプのデータポイントのロードを保存しようとしています。
しかし、最近、私のコードが何万もの重複データポイントを作成していることがわかりました。データポイントは最新の値に変更されますが、新しいデータポイントを追加する代わりに、すべてのデータポイントもその値に設定されます。
懸念されるコードは次のとおりです。
private void Timer_Data_Tick(object sender)
{
if (!Timer_Data_Enabled)
return;
for (int i = 0; (itsDAQ.getStreamCount() > 0) && (i < 6); i++)
{
WindDAQ.WindDataPoint thisDataPoint = new WindDAQ.WindDataPoint();
thisDataPoint = itsDAQ.getValue(Recording);
dataPointCollection.Add(thisDataPoint);
newChartPoint = true;
}
}
getValue()およびgetValue(bool record)のコードは次のとおりです
//Get Real-world values
public WindDataPoint getValue()
{
holdDequeueValue = DAQStream.Dequeue();
holdWindDataPoint.Lift = Lift_Sensor.getForce(holdDequeueValue[ChannelOutOrder[0]]);
holdWindDataPoint.Drag = Drag_Sensor.getForce(holdDequeueValue[ChannelOutOrder[1]]);
holdWindDataPoint.Velocity = Pitot_Sensor.getVelocity(holdDequeueValue[ChannelOutOrder[2]]);
holdWindDataPoint.isRecorded = false;
//This translates the number of samples since start into actual time since start
//Why not get current time? I don't want the current time. I want the time the sample was taken.
holdWindDataPoint.Time = SamplesToTime(SamplesReadSinceStart);
SamplesReadSinceStart++;
return holdWindDataPoint;
}
//Get Read-world values and set whether the sample is recorded.
public WindDataPoint getValue(bool record)
{
getValue();
holdWindDataPoint.isRecorded = record;
return holdWindDataPoint;
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加