aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs18
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs52
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs46
3 files changed, 81 insertions, 35 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 37422d7..dd45406 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -61,19 +61,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
61 61
62 public SensorInfo Clone() 62 public SensorInfo Clone()
63 { 63 {
64 SensorInfo s = new SensorInfo(); 64 return (SensorInfo)this.MemberwiseClone();
65 s.localID = localID;
66 s.itemID = itemID;
67 s.interval = interval;
68 s.next = next;
69 s.name = name;
70 s.keyID = keyID;
71 s.type = type;
72 s.range = range;
73 s.arc = arc;
74 s.host = host;
75
76 return s;
77 } 65 }
78 } 66 }
79 67
@@ -701,8 +689,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
701 689
702 lock (SenseRepeatListLock) 690 lock (SenseRepeatListLock)
703 { 691 {
704 foreach (SensorInfo si in SenseRepeaters) 692 foreach (SensorInfo i in SenseRepeaters)
705 retList.Add(si.Clone()); 693 retList.Add(i.Clone());
706 } 694 }
707 695
708 return retList; 696 return retList;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index bc63030..0b14565 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -35,6 +35,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
35{ 35{
36 public class Timer 36 public class Timer
37 { 37 {
38 public class TimerInfo
39 {
40 public uint localID;
41 public UUID itemID;
42 //public double interval;
43 public long interval;
44 //public DateTime next;
45 public long next;
46
47 public TimerInfo Clone()
48 {
49 return (TimerInfo)this.MemberwiseClone();
50 }
51 }
52
38 public AsyncCommandManager m_CmdManager; 53 public AsyncCommandManager m_CmdManager;
39 54
40 public int TimersCount 55 public int TimersCount
@@ -59,17 +74,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
59 return localID.ToString() + itemID.ToString(); 74 return localID.ToString() + itemID.ToString();
60 } 75 }
61 76
62 private class TimerClass 77 private Dictionary<string,TimerInfo> Timers = new Dictionary<string,TimerInfo>();
63 {
64 public uint localID;
65 public UUID itemID;
66 //public double interval;
67 public long interval;
68 //public DateTime next;
69 public long next;
70 }
71
72 private Dictionary<string,TimerClass> Timers = new Dictionary<string,TimerClass>();
73 private object TimerListLock = new object(); 78 private object TimerListLock = new object();
74 79
75 public void SetTimerEvent(uint m_localID, UUID m_itemID, double sec) 80 public void SetTimerEvent(uint m_localID, UUID m_itemID, double sec)
@@ -81,7 +86,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
81 } 86 }
82 87
83 // Add to timer 88 // Add to timer
84 TimerClass ts = new TimerClass(); 89 TimerInfo ts = new TimerInfo();
85 ts.localID = m_localID; 90 ts.localID = m_localID;
86 ts.itemID = m_itemID; 91 ts.itemID = m_itemID;
87 ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait 92 ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait
@@ -121,8 +126,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
121 lock (TimerListLock) 126 lock (TimerListLock)
122 { 127 {
123 // Go through all timers 128 // Go through all timers
124 Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; 129 Dictionary<string, TimerInfo>.ValueCollection tvals = Timers.Values;
125 foreach (TimerClass ts in tvals) 130 foreach (TimerInfo ts in tvals)
126 { 131 {
127 // Time has passed? 132 // Time has passed?
128 if (ts.next < DateTime.Now.Ticks) 133 if (ts.next < DateTime.Now.Ticks)
@@ -147,8 +152,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
147 152
148 lock (TimerListLock) 153 lock (TimerListLock)
149 { 154 {
150 Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; 155 Dictionary<string, TimerInfo>.ValueCollection tvals = Timers.Values;
151 foreach (TimerClass ts in tvals) 156 foreach (TimerInfo ts in tvals)
152 { 157 {
153 if (ts.itemID == itemID) 158 if (ts.itemID == itemID)
154 { 159 {
@@ -167,7 +172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
167 172
168 while (idx < data.Length) 173 while (idx < data.Length)
169 { 174 {
170 TimerClass ts = new TimerClass(); 175 TimerInfo ts = new TimerInfo();
171 176
172 ts.localID = localID; 177 ts.localID = localID;
173 ts.itemID = itemID; 178 ts.itemID = itemID;
@@ -181,5 +186,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
181 } 186 }
182 } 187 }
183 } 188 }
189
190 public List<TimerInfo> GetTimersInfo()
191 {
192 List<TimerInfo> retList = new List<TimerInfo>();
193
194 lock (TimerListLock)
195 {
196 foreach (TimerInfo i in Timers.Values)
197 retList.Add(i.Clone());
198 }
199
200 return retList;
201 }
184 } 202 }
185} 203}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs
index e47917d..efb854d 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs
@@ -47,20 +47,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine
47 public void RegisterCommands() 47 public void RegisterCommands()
48 { 48 {
49 MainConsole.Instance.Commands.AddCommand( 49 MainConsole.Instance.Commands.AddCommand(
50 "Scripts", false, "show sensors", "show sensors", "Show script sensors information", 50 "Scripts", false, "show script sensors", "show script sensors", "Show script sensors information",
51 HandleShowSensors); 51 HandleShowSensors);
52
53 MainConsole.Instance.Commands.AddCommand(
54 "Scripts", false, "show script timers", "show script timers", "Show script sensors information",
55 HandleShowTimers);
56 }
57
58 private bool IsSceneSelected()
59 {
60 return MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_engine.World;
52 } 61 }
53 62
54 private void HandleShowSensors(string module, string[] cmdparams) 63 private void HandleShowSensors(string module, string[] cmdparams)
55 { 64 {
56 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_engine.World)) 65 if (!IsSceneSelected())
57 return; 66 return;
58 67
59 SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(m_engine); 68 SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(m_engine);
60 69
61 if (sr == null) 70 if (sr == null)
62 { 71 {
63 MainConsole.Instance.Output("Sensor plugin not yet initialized"); 72 MainConsole.Instance.Output("Plugin not yet initialized");
64 return; 73 return;
65 } 74 }
66 75
@@ -82,5 +91,36 @@ namespace OpenSim.Region.ScriptEngine.XEngine
82 MainConsole.Instance.Output(cdt.ToString()); 91 MainConsole.Instance.Output(cdt.ToString());
83 MainConsole.Instance.OutputFormat("Total: {0}", sensorInfo.Count); 92 MainConsole.Instance.OutputFormat("Total: {0}", sensorInfo.Count);
84 } 93 }
94
95 private void HandleShowTimers(string module, string[] cmdparams)
96 {
97 if (!IsSceneSelected())
98 return;
99
100 Timer timerPlugin = AsyncCommandManager.GetTimerPlugin(m_engine);
101
102 if (timerPlugin == null)
103 {
104 MainConsole.Instance.Output("Plugin not yet initialized");
105 return;
106 }
107
108 List<Timer.TimerInfo> timersInfo = timerPlugin.GetTimersInfo();
109
110 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
111 cdt.AddColumn("Part local ID", 13);
112 cdt.AddColumn("Script item ID", 36);
113 cdt.AddColumn("Interval", 10);
114 cdt.AddColumn("Next", 8);
115
116 foreach (Timer.TimerInfo t in timersInfo)
117 {
118 // Convert from 100 ns ticks back to seconds
119 cdt.AddRow(t.localID, t.itemID, (double)t.interval / 10000000, t.next);
120 }
121
122 MainConsole.Instance.Output(cdt.ToString());
123 MainConsole.Instance.OutputFormat("Total: {0}", timersInfo.Count);
124 }
85 } 125 }
86} \ No newline at end of file 126} \ No newline at end of file