void OnMesg(object sender, MesgEventArgs e) { logger.Trace("OnMesg: Received Mesg with global ID#{0}, its name is {1}", e.mesg.Num, e.mesg.Name); var msg = new Mesg(e.mesg.Name, e.mesg.Num); for (byte i = 0; i < e.mesg.GetNumFields(); i++) { var field = e.mesg.fields[i]; var f = new Field(field.Name, field.Num, field.Type, field.Scale, field.Offset, field.Units); for (int j = 0; j < e.mesg.fields[i].GetNumValues(); j++) { logger.Trace("\tField{0} Index{1} (\"{2}\" Field#{4}) Value: {3} (raw value {5})", i, j, e.mesg.fields[i].GetName(), e.mesg.fields[i].GetValue(j), e.mesg.fields[i].Num, e.mesg.fields[i].GetRawValue(j)); f.SetValue(j, field.GetValue(j)); } msg.SetField(field); } Encoder.Write(msg); if (mesgCounts.ContainsKey(e.mesg.Num) == true) { mesgCounts[e.mesg.Num]++; } else { mesgCounts.Add(e.mesg.Num, 1); } }