Beispiel #1
0
        private static void GenerateCPULoad(SystemStatusData data)
        {
            double core1  = SystemStatusModel.LastCore1;
            double core2  = SystemStatusModel.LastCore2;
            int    pass   = 99;
            Random random = new Random();

            if (!data.Init)
            {
                data.CPULoad.RemoveAt(0);

                data.CPULoad.Each(new JFunction
                {
                    Args    = new string[] { "item", "key" },
                    Handler = "item.data.Time = key;" // update time
                });

                core1 = SystemStatusModel.GenerateCPUValue(core1, random);
                core2 = SystemStatusModel.GenerateCPUValue(core2, random);

                data.CPULoad.LoadData(new[] { new { Core1 = core1, Core2 = core2, Time = pass } }, true);
            }
            else
            {
                List <object> d = new List <object>();
                d.Add(new { Core1 = 0, Core2 = 0, Time = 0 });

                for (int i = 1; i < 100; i++)
                {
                    core1 = SystemStatusModel.GenerateCPUValue(core1, random);
                    core2 = SystemStatusModel.GenerateCPUValue(core2, random);

                    d.Add(new
                    {
                        Core1 = core1,
                        Core2 = core2,
                        Time  = i
                    });
                }

                data.CPULoadData = d;
                if (data.CPULoad != null)
                {
                    data.CPULoad.Data = d;
                }
                SystemStatusModel.Pass = 99;
            }

            SystemStatusModel.LastCore1 = core1;
            SystemStatusModel.LastCore2 = core2;
        }
Beispiel #2
0
        public static void UpdateCharts(SystemStatusData data)
        {
            if (data.Init)
            {
                SystemStatusModel.Init();
            }

            int pass = SystemStatusModel.Pass;

            var store = data.Memory;

            if (pass % 3 == 0 || data.Init)
            {
                data.MemoryData = SystemStatusModel.GenerateData(new string[] { "Wired", "Active", "Inactive", "Free" });
                if (store != null)
                {
                    if (data.Init)
                    {
                        store.Data = data.MemoryData;
                    }
                    else
                    {
                        store.LoadData(data.MemoryData);
                    }
                }
            }

            store = data.Process;
            if (pass % 2 == 0 || data.Init)
            {
                data.ProcessData = SystemStatusModel.GenerateData(new string[] { "Explorer", "Monitor", "Charts", "Desktop", "Ext3", "Ext4" });
                if (store != null)
                {
                    if (data.Init)
                    {
                        store.Data = data.ProcessData;
                    }
                    else
                    {
                        store.LoadData(data.ProcessData);
                    }
                }
            }

            SystemStatusModel.GenerateCPULoad(data);
            SystemStatusModel.Pass++;
        }
        public static void UpdateCharts(SystemStatusData data)
        {
            if (data.Init)
            {
                SystemStatusModel.Init();
            }

            int pass = SystemStatusModel.Pass;

            var store = data.Memory;
            if (pass % 3 == 0 || data.Init)
            {
                data.MemoryData = SystemStatusModel.GenerateData(new string[] { "Wired", "Active", "Inactive", "Free" });
                if (store != null)
                {
                    if (data.Init)
                    {
                        store.Data = data.MemoryData;
                    }
                    else
                    {
                        store.LoadData(data.MemoryData);
                    }
                }
            }

            store = data.Process;
            if (pass % 2 == 0 || data.Init)
            {
                data.ProcessData = SystemStatusModel.GenerateData(new string[] { "Explorer", "Monitor", "Charts", "Desktop", "Ext3", "Ext4" });
                if (store != null)
                {
                    if (data.Init)
                    {
                        store.Data = data.ProcessData;
                    }
                    else
                    {
                        store.LoadData(data.ProcessData);
                    }
                }
            }

            SystemStatusModel.GenerateCPULoad(data);
            SystemStatusModel.Pass++;
        }
        private static void GenerateCPULoad(SystemStatusData data)
        {
            double core1 = SystemStatusModel.LastCore1;
            double core2 = SystemStatusModel.LastCore2;
            int pass = 99;
            Random random = new Random();

            if (!data.Init)
            {
                data.CPULoad.RemoveAt(0);

                data.CPULoad.Each(new JFunction
                {
                    Args = new string[] { "item", "key" },
                    Handler = "item.data.Time = key;" // update time
                });

                core1 = SystemStatusModel.GenerateCPUValue(core1, random);
                core2 = SystemStatusModel.GenerateCPUValue(core2, random);

                data.CPULoad.LoadData(new[] { new { Core1 = core1, Core2 = core2, Time = pass } }, true);
            }
            else
            {
                List<object> d = new List<object>();
                d.Add(new { Core1 = 0, Core2 = 0, Time = 0 });

                for (int i = 1; i < 100; i++)
                {
                    core1 = SystemStatusModel.GenerateCPUValue(core1, random);
                    core2 = SystemStatusModel.GenerateCPUValue(core2, random);

                    d.Add(new
                    {
                        Core1 = core1,
                        Core2 = core2,
                        Time = i
                    });
                }

                data.CPULoadData = d;
                if (data.CPULoad != null)
                {
                    data.CPULoad.Data = d;
                }
                SystemStatusModel.Pass = 99;
            }

            SystemStatusModel.LastCore1 = core1;
            SystemStatusModel.LastCore2 = core2;
        }