aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Examples/SimpleApp/MySceneObject.cs
blob: 1218dacc003c4435e1441fc1f6fefcf4703e6c2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Scenes;
using libsecondlife;
using OpenSim.Framework.Types;
using System.Timers;
using System.Diagnostics;

namespace SimpleApp
{
    public class MySceneObject : SceneObject
    {
        private PerformanceCounter m_counter;
        
        public MySceneObject(Scene world, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
            : base(world, ownerID, localID, pos, shape )
        {
            String objectName = "Processor";
            String counterName = "% Processor Time";
            String instanceName = "_Total";

            m_counter = new PerformanceCounter(objectName, counterName, instanceName);

            Timer timer = new Timer();
            timer.Enabled = true;
            timer.Interval = 100;
            timer.Elapsed += new ElapsedEventHandler(this.Heartbeat);

        }

        public void Heartbeat(object sender, EventArgs e)
        {
            float cpu = m_counter.NextValue() / 40f;
            LLVector3 size = new LLVector3(cpu, cpu, cpu);            
            rootPrimitive.ResizeGoup( size );
            update();
        }
    }
}