Esempio n. 1
0
        public void EndUpdate_NestedUpdates_CollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int>();

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.BeginUpdate();

            collection.Add(1234);

            collection.BeginUpdate();

            collection.Add(5678);

            collection.EndUpdate();

            Assert.Empty(collectionChangedEventArgsList);

            collection.EndUpdate();

            Assert.Equal(2, collection.Count);
            Assert.Single(collectionChangedEventArgsList);
            Assert.Equal(NotifyCollectionChangedAction.Reset, collectionChangedEventArgsList[0].Action);
        }
Esempio n. 2
0
        public void Synchronization_TwoItemsAddedWithNoneSyncMethod_ItemsAreAddedAndCollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int>(SynchronizationContext.Current, SynchronizationMethod.None, () => new LockSlimLockingMechanism());

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.Add(123);
            collection.Add(456);

            Assert.Equal(2, collection.Count);
            Assert.Equal(123, collection[0]);
            Assert.Equal(456, collection[1]);

            Assert.Equal(2, collectionChangedEventArgsList.Count);
            Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedEventArgsList[0].Action);
            Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedEventArgsList[1].Action);

            Assert.NotNull(collectionChangedEventArgsList[0].NewItems);
            Assert.Single(collectionChangedEventArgsList[0].NewItems);

            Assert.NotNull(collectionChangedEventArgsList[1].NewItems);
            Assert.Single(collectionChangedEventArgsList[1].NewItems);

            Assert.Equal(123, collectionChangedEventArgsList[0].NewItems[0]);
            Assert.Equal(456, collectionChangedEventArgsList[1].NewItems[0]);
        }
Esempio n. 3
0
        public async Task InvokeTestFromOtherThread()
        {
            var collection = new ExtendedObservableCollection <string>();

            var firstTask = Task.Run(() =>
            {
                for (var i = 0; i <= 99999; i++)
                {
                    collection.Add("test1");
                }
            });

            var secondTask = Task.Run(() =>
            {
                for (var i = 0; i <= 99999; i++)
                {
                    collection.Add("test2");
                }
            });

            await Task.WhenAll(firstTask, secondTask);

            Assert.Equal(200000, collection.Count);
            Assert.Equal(100000, collection.Count(x => x == "test1"));
            Assert.Equal(100000, collection.Count(x => x == "test2"));
        }
Esempio n. 4
0
        public void Add_TwoItems_ItemsAreAddedAndCollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int>();

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.Add(123);
            collection.Add(456);

            Assert.Equal(2, collection.Count);
            Assert.Equal(123, collection[0]);
            Assert.Equal(456, collection[1]);

            Assert.Equal(2, collectionChangedEventArgsList.Count);
            Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedEventArgsList[0].Action);
            Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedEventArgsList[1].Action);

            Assert.NotNull(collectionChangedEventArgsList[0].NewItems);
            Assert.Single(collectionChangedEventArgsList[0].NewItems);

            Assert.NotNull(collectionChangedEventArgsList[1].NewItems);
            Assert.Single(collectionChangedEventArgsList[1].NewItems);

            Assert.Equal(123, collectionChangedEventArgsList[0].NewItems[0]);
            Assert.Equal(456, collectionChangedEventArgsList[1].NewItems[0]);
        }
Esempio n. 5
0
        public void MarkUnrecognized()
        {
            var unrecognizedPacket = new UnrecognizedPacket(Body);

            _payloadPackets.Clear();
            _payloadPackets.Add(unrecognizedPacket);
        }
Esempio n. 6
0
        private void LoadReferences()
        {
            References      = new ExtendedObservableCollection <ReferenceModel>();
            NuGetReferences = new ExtendedObservableCollection <ReferenceModel>();

            List <string> packageDirs = new List <string>();

            packageDirs.Add("/packages/");
            packageDirs.Add("\\packages\\");

            if (SolutionFile.Exists)
            {
                string nuGetRepositoryPath = GetNuGetRepositoryPath(SolutionFile.Directory);
                if (!string.IsNullOrEmpty(nuGetRepositoryPath))
                {
                    packageDirs.Add(nuGetRepositoryPath);
                }
            }

            foreach (var vsReference in _vsProject.References.OfType <Reference>())
            {
                var reference = new ReferenceModel(vsReference);
                References.Add(reference);
                string vsReferencePath = vsReference.Path.ToLower();
                foreach (string packageDir in packageDirs)
                {
                    if (vsReferencePath.Contains(packageDir))
                    {
                        NuGetReferences.Add(reference);
                        break;
                    }
                }
            }
        }
Esempio n. 7
0
        public void Test_Add_Ok()
        {
            int eventCount = 0;

            IEnumerable <int> initialNumbers = Enumerable.Range(1, 4);
            IEnumerable <int> newNumbers     = Enumerable.Range(16, 32);

            ExtendedObservableCollection <int> observableCollection = new ExtendedObservableCollection <int>(initialNumbers);

            observableCollection.CollectionChanged += (sender, args) => eventCount++;

            foreach (int number in newNumbers)
            {
                observableCollection.Add(number);
            }

            Assert.Equal(initialNumbers.Count() + newNumbers.Count(), observableCollection.Count);

            foreach (int number in initialNumbers)
            {
                Assert.Contains(observableCollection, numberItem => numberItem == number);
            }

            foreach (int number in newNumbers)
            {
                Assert.Contains(observableCollection, numberItem => numberItem == number);
            }

            Assert.Equal(newNumbers.Count(), eventCount);
        }
        private void currentLayout_PropertyChanged(KeyValuePair <string, string> property)
        {
            // alert event handlers
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(property);
            }

            if (ConfigClass.IsOperator)
            {
                SendLayoutChanges(new LayoutChangeCommand(property));
            }


            if (property.Key.Equals(PropertyValues.PLUGIN_PRIORITY.ToString()))
            {
                StackTrace stackTrace = new StackTrace();
                if (!stackTrace.ToString().Contains("PluginPriority_CollectionChanged"))
                {
                    ExtendedObservableCollection <string> o = new ExtendedObservableCollection <string>();
                    foreach (string s in property.Value.Split(';'))
                    {
                        o.Add(s);
                    }
                    this.PluginPriority = o;
                }
                //else { Console.WriteLine("Skipped to set the Collection new"); }
                stackTrace = null;
            }
        }
Esempio n. 9
0
        public void TreeViewItemSourceResetRecreateItems()
        {
            RunOnUIThread.Execute(() =>
            {
                ExtendedObservableCollection <TreeViewItemSource> items
                    = new ExtendedObservableCollection <TreeViewItemSource>();
                TreeViewItemSource item1 = new TreeViewItemSource()
                {
                    Content = "item1"
                };
                TreeViewItemSource item2 = new TreeViewItemSource()
                {
                    Content = "item2"
                };
                TreeViewItemSource item3 = new TreeViewItemSource()
                {
                    Content = "item3"
                };
                items.Add(item1);
                items.Add(item2);
                items.Add(item3);

                var treeView         = new TreeView();
                treeView.ItemsSource = items;

                Verify.AreEqual(treeView.RootNodes.Count, 3);
                Verify.AreEqual(treeView.RootNodes[0].Content as TreeViewItemSource, items[0]);

                List <TreeViewItemSource> newItems = new List <TreeViewItemSource>();
                TreeViewItemSource item4           = new TreeViewItemSource()
                {
                    Content = "item4"
                };
                TreeViewItemSource item5 = new TreeViewItemSource()
                {
                    Content = "item5"
                };

                newItems.Add(item4);
                newItems.Add(item5);

                items.ReplaceAll(newItems);

                Verify.AreEqual(treeView.RootNodes.Count, 2);
                Verify.AreEqual(treeView.RootNodes[0].Content as TreeViewItemSource, items[0]);
            });
        }
Esempio n. 10
0
        public void Reentrancy_AddNewItemOnCollectionChanged_ItemIsAdded()
        {
            var collection = new ExtendedObservableCollection <int>(SynchronizationContext.Current, SynchronizationMethod.None, () => new LockSlimLockingMechanism());

            collection.CollectionChanged += (_, _) =>
            {
                if (collection.Count == 1)
                {
                    collection.Add(collection.Count + 1);
                }
            };

            collection.Add(123);

            Assert.Equal(2, collection.Count);
            Assert.Equal(123, collection[0]);
        }
Esempio n. 11
0
        public void Update_ItemsAdded_CollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int>();

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            using (collection.Update())
            {
                collection.Add(123);
                collection.Add(456);
            }

            Assert.Equal(2, collection.Count);
            Assert.Single(collectionChangedEventArgsList);
            Assert.Equal(NotifyCollectionChangedAction.Reset, collectionChangedEventArgsList[0].Action);
        }
Esempio n. 12
0
        private void LoadReferences()
        {
            References      = new ExtendedObservableCollection <ReferenceModel>();
            NuGetReferences = new ExtendedObservableCollection <ReferenceModel>();

            List <string> packageDirs = new List <string>();

            // Check if the NuGet.Config file has a repository path set and use it
            var nugetSettingsPath =
                System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NuGet",
                                       "NuGet.Config");
            var configRepositoryPathOverride = false;

            if (File.Exists(nugetSettingsPath))
            {
                var repositoryPath = (string)XElement.Load(nugetSettingsPath).Descendants("add").FirstOrDefault(add => (string)add.Attribute("key") == "repositoryPath")?.Attribute("value");
                if (repositoryPath != null)
                {
                    packageDirs.Add(repositoryPath);
                    configRepositoryPathOverride = true;
                }
            }

            // If the Nuget.Config file has not repository path set then use default paths
            if (!configRepositoryPathOverride)
            {
                packageDirs.Add("/packages/");
                packageDirs.Add("\\packages\\");
            }

            if (SolutionFile.Exists)
            {
                string nuGetRepositoryPath = GetNuGetRepositoryPath(SolutionFile.Directory);
                if (!string.IsNullOrEmpty(nuGetRepositoryPath))
                {
                    packageDirs.Add(nuGetRepositoryPath);
                }
            }

            foreach (var vsReference in _vsProject.References.OfType <Reference>())
            {
                var reference = new ReferenceModel(vsReference);
                References.Add(reference);
                string vsReferencePath = vsReference.Path.ToLower();
                foreach (string packageDir in packageDirs)
                {
                    if (vsReferencePath.Contains(packageDir))
                    {
                        NuGetReferences.Add(reference);
                        break;
                    }
                }
            }
        }
Esempio n. 13
0
        public void Reentrancy_AddNewItemOnCollectionChangedWithTwoEventHandler_ExceptionIsThrown()
        {
            var collection = new ExtendedObservableCollection <int>(SynchronizationContext.Current, SynchronizationMethod.None, () => new LockSlimLockingMechanism());

            collection.CollectionChanged += (_, _) =>
            {
                if (collection.Count == 1)
                {
                    Assert.Throws <InvalidOperationException>(() => collection.Add(collection.Count + 1));
                }
            };
            collection.CollectionChanged += (_, _) =>
            {
                if (collection.Count == 1)
                {
                    Assert.Throws <InvalidOperationException>(() => collection.Add(collection.Count + 1));
                }
            };

            collection.Add(123);
        }
Esempio n. 14
0
        public static void Main(string[] args)
        {
            var collection = new ExtendedObservableCollection <string>();

            collection.CollectionChanged += Collection_CollectionChanged;

            collection.Add("item1");
            collection.AddRange(new string[] { "item2", "item3", "item4" });
            collection[0] = "item1 mk2";
            collection.Move(0, 3);
            collection.Remove("item3");
            collection.Clear();
        }
Esempio n. 15
0
        /// <summary>
        /// Gets the graph data.
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private ExtendedObservableCollection <GraphItemViewModel> GetGraphData(IList <Transaction> list)
        {
            ExtendedObservableCollection <GraphItemViewModel> graphItems = null;

            if (list != null && list.Any())
            {
                graphItems = new ExtendedObservableCollection <GraphItemViewModel>();
                var totalNeed = list.Where(t => t.PurposeType == TransactionPurposeType.Need).Sum(t => t.Amount);
                var totalWant = list.Where(t => t.PurposeType == TransactionPurposeType.Want).Sum(t => t.Amount);
                graphItems.Add(new GraphItemViewModel()
                {
                    Description = "Need",
                    Value       = totalNeed
                });
                graphItems.Add(new GraphItemViewModel()
                {
                    Description = "Want",
                    Value       = totalWant
                });
            }
            return(graphItems);
        }
Esempio n. 16
0
        private void LoadReferences()
        {
            References      = new ExtendedObservableCollection <ReferenceModel>();
            NuGetReferences = new ExtendedObservableCollection <ReferenceModel>();

            foreach (var vsReference in _vsProject.References.OfType <Reference>())
            {
                var reference = new ReferenceModel(vsReference);
                References.Add(reference);
                if (vsReference.Path.Contains("/packages/") || vsReference.Path.Contains("\\packages\\"))
                {
                    NuGetReferences.Add(reference);
                }
            }
        }
Esempio n. 17
0
        public void BeginUpdate_AddToItemsAfterBeginUpdate_NoCollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int> {
                135, 123, 456, 789
            };

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.BeginUpdate();
            collection.Add(42);

            Assert.Empty(collectionChangedEventArgsList);
        }
Esempio n. 18
0
        public void EndUpdate_OneEndUpdateAfterTwoBeginUpdate_NoCollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int>();

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.BeginUpdate();
            collection.BeginUpdate();
            collection.Add(1234);
            collection.EndUpdate();

            Assert.Single(collection);
            Assert.Empty(collectionChangedEventArgsList);
        }
Esempio n. 19
0
        public void EndUpdate_EndUpdateAfterBeginUpdate_NoCollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int> {
                135, 123, 456, 789
            };

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.BeginUpdate();
            collection.Add(42);

            Assert.Empty(collectionChangedEventArgsList);

            collection.EndUpdate();

            Assert.Single(collectionChangedEventArgsList);
            Assert.Equal(NotifyCollectionChangedAction.Reset, collectionChangedEventArgsList[0].Action);
        }
Esempio n. 20
0
        private async Task FetchConversations()
        {
            string currentDir    = Directory.GetCurrentDirectory();
            string conversations = @"\conversations\";
            string folderPath    = currentDir + conversations;

            string[] folders = Directory.GetDirectories(folderPath);


            foreach (string path in folders)
            {
                string           infoStr          = File.ReadAllText(path + @"\info.json"); //DatabaseManager.ReadPathContent(path);
                ConversationInfo conversationInfo = JsonConvert.DeserializeObject <ConversationInfo>(infoStr);
                allConversations.Add(conversationInfo);
                Console.WriteLine(allConversations.Count);
            }
            await Application.Current.Dispatcher.BeginInvoke(new Action(() => SetSearchResultToAll()));

            Console.WriteLine(Conversations.Count);
        }
Esempio n. 21
0
        public static ExtendedObservableCollection <IndicatorValue> filterDiagramValues(IEnumerable <IndicatorValue> values)
        {
            var sortedValues = values.OrderBy(x => x.Timestamp);

            ExtendedObservableCollection <IndicatorValue> resultList = new ExtendedObservableCollection <IndicatorValue>();

            // add average values to the diagram list
            int intervalToAverage = values.Count() / NUMBER_OF_VALUES_IN_DIAGRAM;

            if (intervalToAverage > 1)
            {
                for (int i = 0; i < sortedValues.Count(); i += intervalToAverage)
                {
                    if (sortedValues.Count() >= i + intervalToAverage)
                    {
                        try
                        {
                            double sum = 0;
                            for (int j = i; j < i + intervalToAverage; j++)
                            {
                                sum += Convert.ToInt32(sortedValues.ElementAt(j).Value);
                            }
                            IndicatorValue middleElement = sortedValues.ElementAt(i + intervalToAverage / 2);
                            resultList.Add(new IndicatorValue(Convert.ToInt32(sum / intervalToAverage), middleElement.DataType, middleElement.Timestamp, middleElement.MappingState));
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("DiagramHelper.filterDiagramValues: Problem filtering values for diagram. " + e.Message);
                        }
                    }
                }
            }
            else
            {
                foreach (IndicatorValue v in sortedValues)
                {
                    try{
                        resultList.Add(new IndicatorValue(Convert.ToInt32(v.Value), v.DataType, v.Timestamp, v.MappingState));
                    }catch (Exception) {}
                }
            }

            // collect distances and define "normal" time distance between two values
            // lets take the median
            List <TimeSpan> distances = new List <TimeSpan>();

            for (int i = 0; i < resultList.Count; i++)
            {
                if (i < resultList.Count - 1)
                {
                    distances.Add((resultList.ElementAt(i + 1).Timestamp - resultList.ElementAt(i).Timestamp));
                }
            }
            //sort and take middle as reference distance
            distances.Sort();
            double referenceDistanceInSeconds = 0;

            if (distances.Count > 0)
            {
                referenceDistanceInSeconds = distances.ElementAt(distances.Count / 2).TotalSeconds;
            }

            List <IndicatorValue> valuesToAdd = new List <IndicatorValue>();

            for (int i = 0; i < resultList.Count; i++)
            {
                if (i < resultList.Count - 1)
                {
                    if ((resultList.ElementAt(i + 1).Timestamp - resultList.ElementAt(i).Timestamp).TotalSeconds > referenceDistanceInSeconds * 5)
                    {
                        // Add Dummy 0 Values, so the graph shows no ugly lines when system was off
                        valuesToAdd.Add(new IndicatorValue(0, resultList.ElementAt(i).DataType, resultList.ElementAt(i).Timestamp.AddMilliseconds(100), resultList.ElementAt(i).MappingState));
                        valuesToAdd.Add(new IndicatorValue(0, resultList.ElementAt(i + 1).DataType, resultList.ElementAt(i + 1).Timestamp.AddMilliseconds(-100), resultList.ElementAt(i + 1).MappingState));
                    }
                }
            }

            foreach (IndicatorValue v in valuesToAdd)
            {
                resultList.Add(v);
            }
            return(resultList);
        }
Esempio n. 22
0
        /// <summary>
        /// Loads all JPEG images from a directori into the list of ImagePreview instances.
        /// </summary>
        /// <param name="resourcesDir">A directory with images.</param>
        /// <param name="maxImagesCount">The maximum images, that can loaded. If less than 0, all images are loaded.</param>
        /// <returns>A list of ImagePreview instances.</returns>
        public static ExtendedObservableCollection <ImagePreview> LoadImages(string resourcesDir, int maxImagesCount = 20)
        {
            // If nothing to do...
            if (maxImagesCount == 0)
            {
                return(new ExtendedObservableCollection <ImagePreview>());
            }

            var imageFilesList = new List <string>();

            try
            {
                var count   = 0;
                var dirInfo = new DirectoryInfo(resourcesDir);
                foreach (var file in dirInfo.GetFiles("*.jp*", SearchOption.TopDirectoryOnly))
                {
                    var fn = file.Name.ToLower();

                    // Only JPEG images.
                    if (fn.EndsWith(".jpg") || fn.EndsWith(".jpeg"))
                    {
                        imageFilesList.Add(file.FullName);

                        // Are we unlimited?
                        if (maxImagesCount < 0)
                        {
                            continue;
                        }

                        count++;
                        if (count >= maxImagesCount)
                        {
                            // No more than maxImagesCount images should be loaded into the preview.
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
                ;  // Exceptions can be ignored.
            }

            var results = new ExtendedObservableCollection <ImagePreview>();

            // No images found?
            if (imageFilesList.Count == 0)
            {
                return(results);
            }

            foreach (var fileName in imageFilesList)
            {
                results.Add(new ImagePreview()
                {
                    Path = fileName, Image = LoadImage(fileName)
                });
            }

            return(results);
        }
 /// <summary>
 /// Gets the graph data.
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 private ExtendedObservableCollection<GraphItemViewModel> GetGraphData(IList<Transaction> list)
 {
     ExtendedObservableCollection<GraphItemViewModel> graphItems = null;
     if (list != null && list.Any())
     {
         graphItems = new ExtendedObservableCollection<GraphItemViewModel>();
         var totalNeed = list.Where(t => t.PurposeType == TransactionPurposeType.Need).Sum(t => t.Amount);
         var totalWant = list.Where(t => t.PurposeType == TransactionPurposeType.Want).Sum(t => t.Amount);
         graphItems.Add(new GraphItemViewModel()
         {
             Description = "Need",
             Value = totalNeed
         });
         graphItems.Add(new GraphItemViewModel()
         {
             Description = "Want",
             Value = totalWant
         });
     }
     return graphItems;
 }
        private void LoadReferences()
        {
            References = new ExtendedObservableCollection<ReferenceModel>();
            NuGetReferences = new ExtendedObservableCollection<ReferenceModel>();

            foreach (var vsReference in _vsProject.References.OfType<Reference>())
            {
                var reference = new ReferenceModel(vsReference);
                References.Add(reference);
                if (vsReference.Path.Contains("/packages/") || vsReference.Path.Contains("\\packages\\"))
                    NuGetReferences.Add(reference);
            }
        }
Esempio n. 25
0
        public override void SelectIndicatorValues()
        {
            this.IndicatorValues.ClearOnUI();

            this.Temperature.ClearOnUI();
            this.TemperaturePerCore.ClearOnUI();

            this.Load.ClearOnUI();
            this.LoadPerCore.ClearOnUI();

            try
            {
                // Name
                var name = (from p in this.Indicators
                            where p.Name == "ProcessorName"
                            from q in p.IndicatorValues
                            orderby q.Timestamp descending
                            select q).FirstOrDefault();
                if (name != null)
                {
                    this.Name = name.Value as string;
                }
                else
                {
                    this.Name = " - ";
                }
            }
            catch (Exception)
            {
                Console.WriteLine("CPU VIS PLUGIN: Problem at getting ProcessorName");
                this.Name = " - ";
            }

            try
            {
                var temperatures = (from p in this.Indicators
                                    where p.Name == "Temperature"
                                    from q in p.IndicatorValues
                                    orderby q.Timestamp descending
                                    select new IndicatorValue(Convert.ToByte(q.Value), q.DataType, q.Timestamp, q.MappingState));
                ExtendedObservableCollection <IndicatorValue> filteredTemps = DiagramHelper.filterDiagramValues(temperatures);
                Temperature.BeginAddRange(filteredTemps);


                // this adds all values to the diagram, way too much for wpf toolkit diagrams
                // Temperature
                //this.Temperature.BeginAddRange(from p in this.Indicators
                //                               where p.Name == "Temperature"
                //                               from q in p.IndicatorValues
                //                               select new IndicatorValue(Convert.ToByte(q.Value), q.DataType, q.Timestamp, q.MappingState));
            }
            catch (Exception)
            {
                Console.WriteLine("CPU VIS PLUGIN: Problem at getting Temperature");
            }

            try
            {
                // Temperature Per Core
                var temperatures = from p in this.Indicators
                                   where p.Name == "TemperaturePerCore"
                                   from q in p.IndicatorValues
                                   select q;
                if (temperatures.Count() > 0)
                {
                    IndicatorValue first = null;
                    int            z     = 0;
                    while (first == null)
                    {
                        if (!temperatures.ElementAt(z).Value.ToString().Equals(""))
                        {
                            first = temperatures.ElementAt(z);
                        }
                        z++;
                    }

                    for (int i = 0; i < first.Value.ToString().Split(';').Length; i++)
                    {
                        ExtendedObservableCollection <IndicatorValue> rawValues = new ExtendedObservableCollection <IndicatorValue>();
                        ExtendedObservableCollection <IndicatorValue> filteredValues;

                        foreach (IndicatorValue tempValue in temperatures)
                        {
                            string[] temps = tempValue.Value.ToString().Split(';');
                            if (temps.Length > 0 && temps.Length == first.Value.ToString().Split(';').Length&& !temps[i].Equals(""))
                            {
                                rawValues.Add(new IndicatorValue(Convert.ToByte(temps[i]), tempValue.DataType, tempValue.Timestamp, tempValue.MappingState));
                            }
                        }
                        filteredValues = DiagramHelper.filterDiagramValues(rawValues);
                        this.TemperaturePerCore.BeginAddOnUI(filteredValues);
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("CPU VIS PLUGIN: Problem at getting TemperaturePerCore");
            }


            try
            {
                // Load
                var load = (from p in this.Indicators
                            where p.Name == "Load"
                            from q in p.IndicatorValues
                            select new IndicatorValue(Convert.ToByte(q.Value), q.DataType, q.Timestamp, q.MappingState));
                this.Load.BeginAddRange(DiagramHelper.filterDiagramValues(load));
            }
            catch (Exception)
            {
                Console.WriteLine("CPU VIS PLUGIN: Problem at getting Load");
            }

            try
            {
                // Load Per Core
                var loadValues = from p in this.Indicators
                                 where p.Name == "LoadPerCore"
                                 from q in p.IndicatorValues
                                 select q;

                if (loadValues.Count() > 0)
                {
                    IndicatorValue first = null;
                    int            z     = 0;
                    while (first == null)
                    {
                        if (!loadValues.ElementAt(z).Value.ToString().Equals(""))
                        {
                            first = loadValues.ElementAt(z);
                        }
                        z++;
                    }

                    for (int i = 0; i < first.Value.ToString().Split(';').Length; i++)
                    {
                        ExtendedObservableCollection <IndicatorValue> rawValues = new ExtendedObservableCollection <IndicatorValue>();
                        ExtendedObservableCollection <IndicatorValue> filteredValues;

                        foreach (IndicatorValue value in loadValues)
                        {
                            string[] loads = value.Value.ToString().Split(';');
                            if (loads.Length > 0 && loads.Length == (first.Value as string).Split(';').Length&& !loads[i].Equals(""))
                            {
                                rawValues.Add(new IndicatorValue(Convert.ToByte(loads[i]), value.DataType, value.Timestamp, value.MappingState));
                            }
                        }
                        filteredValues = DiagramHelper.filterDiagramValues(rawValues);
                        this.LoadPerCore.BeginAddOnUI(filteredValues);
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("CPU VIS PLUGIN: Problem at getting LoadPerCore");
            }
        }
Esempio n. 26
0
 private void InsertPacket()
 {
     _packetItems.Add(TransformPacketModel(null));
 }