Exemple #1
0
        private void readFile(string path, int numToRead)
        {
            if (File.Exists(path))
            {
                using (BinaryReader2 reader = new BinaryReader2(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    Version = reader.ReadInt32();
                    if (Version == 3)
                    {
                        StartTime = FromLVTime(reader.ReadInt64(), reader.ReadUInt64());
                        int tempRead = 0;
                        while (reader.BaseStream.Position != reader.BaseStream.Length)
                        {
                            DateTime time = FromLVTime(reader.ReadInt64(), reader.ReadUInt64());
                            Int32    l    = reader.ReadInt32();
                            string   s    = System.Text.Encoding.ASCII.GetString(reader.ReadBytes(l));
                            //EntryList.Add(new InfoEntry(time, s));
                            //if (s.StartsWith("Warning <Code> 44008")) ReadWarning44008(s, time);
                            //if (s.StartsWith("Warning <Code> 44004")) ReadWarning44004(s, time);
                            if (s.Contains("FMS Connected:   Qualification") || s.Contains("FMS Connected:   Elimination") || s.Contains("FMS Connected:   Practice") || s.Contains("FMS Connected:   None"))
                            {
                                FMSMatch = true;
                                FMSData  = s;
                            }

                            //Make sure we don't read every line for the listView
                            if (numToRead != -1)
                            {
                                if (FMSMatch)
                                {
                                    if (s.Contains("FMS Event Name: "))
                                    {
                                        break;
                                    }
                                }
                                else if (numToRead < tempRead)
                                {
                                    break;
                                }
                                tempRead++;
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void readEntry(BinaryReader2 reader, int counter)
        {
            double trip       = TripTimeToDouble(reader.ReadByte());
            double packetLoss = PacketLossToDouble(reader.ReadSByte());
            double voltage    = VoltageToDouble(reader.ReadUInt16());
            double cpu        = RoboRioCPUToDouble(reader.ReadByte());

            bool[] statusFlags = StatusFlagsToBooleanArray(reader.ReadByte());
            brownout = brownout || statusFlags[0];
            bool   watchdog      = statusFlags[1];
            bool   dsTele        = statusFlags[2];
            bool   dsAuto        = statusFlags[3];
            bool   dsDisabled    = statusFlags[4];
            bool   robotTele     = statusFlags[5];
            bool   robotAuto     = statusFlags[6];
            bool   robotDisabled = statusFlags[7];
            double can           = CANUtilToDouble(reader.ReadByte());
            double wifi          = WifidBToDouble(reader.ReadByte());
            double bandwidth     = BandwidthToDouble(reader.ReadUInt16());
            int    pdpId         = reader.ReadByte();

            double[] pdpV    = PDPValuesToArrayList(reader.ReadBytes(21));
            double   pdpRes  = reader.ReadByte();
            double   pdpVol  = reader.ReadByte();
            double   pdpTemp = reader.ReadByte();
            DateTime time    = StartTime.AddMilliseconds(20 * counter);

            packetLossTS.add(packetLoss);
            leftDriveTS.add(pdpV[2], pdpV[3]);
            rightDriveTS.add(pdpV[0], pdpV[1]);
            intakeLeftTS.add(pdpV[4]);
            intakeRightTS.add(pdpV[5]);
            armTS.add(pdpV[6]);
            elevatorTS.add(pdpV[8], pdpV[9], pdpV[10], pdpV[11]);
            climbForwardTS.add(pdpV[7]);
            climbRearTS.add(pdpV[12], pdpV[13]);
            climbFrontTS.add(pdpV[14], pdpV[15]);
        }
Exemple #3
0
 public LogReader(string path)
 {
     if (File.Exists(path))
     {
         using (BinaryReader2 reader = new BinaryReader2(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
         {
             Version = reader.ReadInt32();
             if (Version == 3)
             {
                 StartTime = FromLVTime(reader.ReadInt64(), reader.ReadUInt64());
                 int i = 0;
                 while (reader.BaseStream.Position != reader.BaseStream.Length)
                 {
                     readEntry(reader, i++);
                 }
             }
             else
             {
                 Console.WriteLine("Invalid file: " + path);
             }
         }
     }
 }