コード例 #1
0
ファイル: RecordDataFile.cs プロジェクト: ywwjzsf/CANStream
        public RecordDataFile(PcanTrcFileInfo oTrcInfo, string VCLibCollectionPath) : base(oTrcInfo.TrcFileInfo.FullName)
        {
            bTrcConverted = false;
            Channels      = new List <RecordDataChannel>();

            oRecordEvent   = null;
            oRecordSession = null;

            if (bTrcLoaded)
            {
                if (!(oTrcInfo.TrcCanConfig == null))
                {
                    oCanConfig = oTrcInfo.TrcCanConfig;

                    VCLibraries = null;
                    if (!(VCLibCollectionPath.Equals("")))
                    {
                        VCLibraries = new CS_VCLibrariesCollection();
                        VCLibraries.LoadLibrariesList(VCLibCollectionPath);
                    }

                    bTrcConverted = DecodeTrcFile();

                    oRecordEvent   = oTrcInfo.TrcFileEvent;
                    oRecordSession = oTrcInfo.TrcFileSession;
                }
            }
        }
コード例 #2
0
        private void ShowTrcFiles()
        {
            LV_TrcFiles.Items.Clear();
            CANStreamTools.ResetTrcFileInfoEventSession();

            if (Directory.Exists(RecordsFolder))
            {
                DirectoryInfo RecDirInfo = new DirectoryInfo(RecordsFolder);

                TrcFilesInfos = CANStreamTools.GetTrcFileInfoList(RecDirInfo.FullName);

                if (!(TrcFilesInfos == null))
                {
                    for (int iTrc = 0; iTrc < TrcFilesInfos.Length; iTrc++)
                    {
                        PcanTrcFileInfo TrcInfo = TrcFilesInfos[iTrc];

                        ListViewItem TrcIt = LV_TrcFiles.Items.Add(TrcInfo.TrcFileInfo.Name);
                        TrcIt.Tag = iTrc;

                        if (!(TrcInfo.TrcFileEvent == null || TrcInfo.TrcFileSession == null))
                        {
                            ListViewGroup oEventSessionGroup = Get_EventSessionGroup(TrcInfo.TrcFileEvent.Name, TrcInfo.TrcFileSession.Name);

                            if (oEventSessionGroup == null)
                            {
                                oEventSessionGroup = LV_TrcFiles.Groups.Add(LV_TrcFiles.Groups.Count.ToString(), TrcInfo.TrcFileEvent.Name + " :: " + TrcInfo.TrcFileSession.Name);
                            }

                            TrcIt.Group = oEventSessionGroup;
                        }

                        TrcIt.SubItems.Add(TrcInfo.TrcFileInfo.LastWriteTime.ToShortDateString() + " " + TrcInfo.TrcFileInfo.LastWriteTime.ToShortTimeString());
                        TrcIt.SubItems.Add(CANStreamTools.GetScaledFileSize(TrcInfo.TrcFileInfo.Length));
                    }

                    LV_TrcFiles.Sort();
                }
            }
            else
            {
                MessageBox.Show("Records folder doesn't exist or is not available !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #3
0
        public static PcanTrcFileInfo[] GetTrcFileInfoList(string FolderPath)
        {
            List <PcanTrcFileInfo> FolderTrcFilesInfo = new List <PcanTrcFileInfo>();

            DirectoryInfo FolderInfo = new DirectoryInfo(FolderPath);

            DirectoryInfo[] SubDirsInfo = FolderInfo.GetDirectories();
            FileInfo[]      TrcFiles    = FolderInfo.GetFiles("*.trc");

            //Update event
            if (File.Exists(FolderPath + "\\EventDetails.xml"))
            {
                oEventCurrent = new CS_RecordEvent();

                if (!(oEventCurrent.Load_RecordEventInformationFile(FolderPath + "\\EventDetails.xml")))
                {
                    oEventCurrent = null;
                }
            }

            //Update session
            if (File.Exists(FolderPath + "\\SessionDetails.xml"))
            {
                oSessionCurrent = new CS_RecordSession();

                if (!(oSessionCurrent.Load_RecordSessionInformationFile(FolderPath + "\\SessionDetails.xml")))
                {
                    oSessionCurrent = null;
                }
            }

            //Look for trc files
            if (TrcFiles.Length > 0)
            {
                foreach (FileInfo oTrc in TrcFiles)
                {
                    PcanTrcFileInfo oTrcInfo = new PcanTrcFileInfo();

                    oTrcInfo.TrcFileInfo = oTrc;

                    if (!(oEventCurrent == null || oSessionCurrent == null))
                    {
                        oTrcInfo.TrcFileEvent   = oEventCurrent;
                        oTrcInfo.TrcFileSession = oSessionCurrent;
                    }

                    FolderTrcFilesInfo.Add(oTrcInfo);
                }
            }

            //Look in sub-directories
            if (SubDirsInfo.Length > 0)
            {
                foreach (DirectoryInfo oSubDir in SubDirsInfo)
                {
                    FolderTrcFilesInfo.AddRange(GetTrcFileInfoList(oSubDir.FullName));
                }
            }

            return(FolderTrcFilesInfo.ToArray());
        }