Ejemplo n.º 1
0
        /// <summary>
        /// Loads Directory Info
        /// </summary>
        /// <param name="path"></param>
        private void LoadDirectory(string path, IDirectory parent)
        {
            if (parent.IsLoaded)
            {
                return;
            }
            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            parent.InfoList.Clear();
            DirectoryInfo directory = new DirectoryInfo(path);

            DirectoryInfo[] folders = directory.GetDirectories();
            FileInfo[]      files   = directory.GetFiles();
            foreach (var entry in folders)
            {
                if (entry.Attributes == FileAttributes.Directory)
                {
                    FolderDataPoint folder     = new FolderDataPoint(entry.Name, entry.FullName);
                    DirectoryInfo[] subFolders = entry.GetDirectories();
                    FileInfo[]      subFIles   = entry.GetFiles();
                    if (subFolders.Length != 0)
                    {
                        foreach (var subFolder in subFolders)
                        {
                            folder.Add(new FolderDataPoint(subFolder.Name, subFolder.FullName));
                        }
                    }
                    if (subFIles.Length != 0)
                    {
                        foreach (var subFIle in subFIles)
                        {
                            folder.Add(new FileDataPoint(subFIle.Name, subFIle.FullName));
                        }
                    }

                    parent.Add(folder);
                }
            }
            foreach (var file in files)
            {
                FileDataPoint fileItem = new FileDataPoint(file.Name, file.FullName);
                parent.Add(fileItem);
            }
            parent.IsLoaded = true;
        }
Ejemplo n.º 2
0
        private void InitDetailsFromMeta(MetaFrame metaMessage)
        {
            if (m_VisualizerForm.InvokeRequired)
            {
                m_VisualizerForm.Invoke(new Action <MetaFrame>(InitDetailsFromMeta), metaMessage);
            }
            else
            {
                try
                {
                    string publisherID = metaMessage.NetworkMessageHeader.PublisherID.Value;
                    ushort writerID    = metaMessage.DataSetWriterID;
                    ConcurrentDictionary <ushort, BindingSource> writerDictionary =
                        m_Bindings.GetOrAdd(publisherID, pubID => new ConcurrentDictionary <ushort, BindingSource>());
                    BindingSource bs = writerDictionary.GetOrAdd(writerID, s => new BindingSource());
                    bs.Clear();
                    m_VisualizerForm.ResetGroupedTypeIndex(publisherID, writerID);

                    if (metaMessage.FieldMetaDataList != null)
                    {
                        for (int i = 0; i < metaMessage.FieldMetaDataList.Count; i++)
                        {
                            FieldMetaData fieldMetaData     = metaMessage.FieldMetaDataList[i];
                            bool          isOldEnum         = false,
                                          isGroupedDataType = false;
                            if (metaMessage.StructureDataTypes.TryGetValue(fieldMetaData.DataType, out StructureDescription structDesc))
                            {
                                if (metaMessage.EnumDataTypes != null &&
                                    structDesc.Name.Name.ToString()
                                    .Contains("EnumValue"))
                                {
                                    isOldEnum = true;
                                }
                            }
                            if (!isOldEnum)
                            {
                                isGroupedDataType = ProcessValueFactory.GetNodeIDType(fieldMetaData.DataType) == NodeIDType.GroupDataTypeTimeSeries;
                            }
                            DataPointBase dp = null;
                            if (fieldMetaData.DataType == File.PreDefinedNodeID)
                            {
                                dp = new FileDataPoint();
                            }
                            else
                            {
                                dp = new ProcessDataPoint();
                            }
                            dp.Index = fieldMetaData.Index;
                            dp.Name  = dp.GetType()
                                       .Name
                                       == "FileDataPoint"
                                              ? Path.GetFileName(fieldMetaData.Name.Value)
                                              : fieldMetaData.Name.Value;
                            bs.Add(dp);
                            if (isGroupedDataType)
                            {
                                m_VisualizerForm.AddGroupDataTypeIndex(publisherID, writerID, bs.Count - 1);
                                List <StructureField> fields = metaMessage.StructureDataTypes[fieldMetaData.DataType]
                                                               .Fields;
                                int count = fields.Count;
                                for (int k = 0; k < count; k++)
                                {
                                    string name = fields[k]
                                                  .Name.Value;
                                    if (name != "_time" && name.Contains("_qc") == false)
                                    {
                                        ProcessDataPoint dp1 = new ProcessDataPoint();
                                        dp1.Index = fieldMetaData.Index;
                                        dp1.Name  = fields[k]
                                                    .Name.Value;
                                        bs.Add(dp1);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }