aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-01-10 00:32:22 +0000
committerJustin Clark-Casey (justincc)2013-01-25 23:48:59 +0000
commit9ddddde42ec3b92393f699e4f6cace8267cda5db (patch)
tree96e76e59b555858bc50bff90946df56c8bf2b7b7 /OpenSim/Region/ScriptEngine/Shared
parentminor: Remove unnecessary commented out code from last commit c28a2f05 and fi... (diff)
downloadopensim-SC-9ddddde42ec3b92393f699e4f6cace8267cda5db.zip
opensim-SC-9ddddde42ec3b92393f699e4f6cace8267cda5db.tar.gz
opensim-SC-9ddddde42ec3b92393f699e4f6cace8267cda5db.tar.bz2
opensim-SC-9ddddde42ec3b92393f699e4f6cace8267cda5db.tar.xz
Add "show sensors" command to show script sensor information for debug purposes.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs94
1 files changed, 62 insertions, 32 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 24cceea..37422d7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -42,6 +42,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
42 { 42 {
43// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 /// <summary>
46 /// Used by one-off and repeated sensors
47 /// </summary>
48 public class SensorInfo
49 {
50 public uint localID;
51 public UUID itemID;
52 public double interval;
53 public DateTime next;
54
55 public string name;
56 public UUID keyID;
57 public int type;
58 public double range;
59 public double arc;
60 public SceneObjectPart host;
61
62 public SensorInfo Clone()
63 {
64 SensorInfo s = new SensorInfo();
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 }
78 }
79
45 public AsyncCommandManager m_CmdManager; 80 public AsyncCommandManager m_CmdManager;
46 81
47 /// <summary> 82 /// <summary>
@@ -79,24 +114,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
79 private int maximumToReturn = 16; 114 private int maximumToReturn = 16;
80 115
81 // 116 //
82 // SenseRepeater and Sensors
83 //
84 private class SenseRepeatClass
85 {
86 public uint localID;
87 public UUID itemID;
88 public double interval;
89 public DateTime next;
90
91 public string name;
92 public UUID keyID;
93 public int type;
94 public double range;
95 public double arc;
96 public SceneObjectPart host;
97 }
98
99 //
100 // Sensed entity 117 // Sensed entity
101 // 118 //
102 private class SensedEntity : IComparable 119 private class SensedEntity : IComparable
@@ -128,7 +145,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
128 /// 145 ///
129 /// Always lock SenseRepeatListLock when updating this list. 146 /// Always lock SenseRepeatListLock when updating this list.
130 /// </remarks> 147 /// </remarks>
131 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>(); 148 private List<SensorInfo> SenseRepeaters = new List<SensorInfo>();
132 private object SenseRepeatListLock = new object(); 149 private object SenseRepeatListLock = new object();
133 150
134 public void SetSenseRepeatEvent(uint m_localID, UUID m_itemID, 151 public void SetSenseRepeatEvent(uint m_localID, UUID m_itemID,
@@ -142,7 +159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
142 return; 159 return;
143 160
144 // Add to timer 161 // Add to timer
145 SenseRepeatClass ts = new SenseRepeatClass(); 162 SensorInfo ts = new SensorInfo();
146 ts.localID = m_localID; 163 ts.localID = m_localID;
147 ts.itemID = m_itemID; 164 ts.itemID = m_itemID;
148 ts.interval = sec; 165 ts.interval = sec;
@@ -161,11 +178,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
161 AddSenseRepeater(ts); 178 AddSenseRepeater(ts);
162 } 179 }
163 180
164 private void AddSenseRepeater(SenseRepeatClass senseRepeater) 181 private void AddSenseRepeater(SensorInfo senseRepeater)
165 { 182 {
166 lock (SenseRepeatListLock) 183 lock (SenseRepeatListLock)
167 { 184 {
168 List<SenseRepeatClass> newSenseRepeaters = new List<SenseRepeatClass>(SenseRepeaters); 185 List<SensorInfo> newSenseRepeaters = new List<SensorInfo>(SenseRepeaters);
169 newSenseRepeaters.Add(senseRepeater); 186 newSenseRepeaters.Add(senseRepeater);
170 SenseRepeaters = newSenseRepeaters; 187 SenseRepeaters = newSenseRepeaters;
171 } 188 }
@@ -176,8 +193,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
176 // Remove from timer 193 // Remove from timer
177 lock (SenseRepeatListLock) 194 lock (SenseRepeatListLock)
178 { 195 {
179 List<SenseRepeatClass> newSenseRepeaters = new List<SenseRepeatClass>(); 196 List<SensorInfo> newSenseRepeaters = new List<SensorInfo>();
180 foreach (SenseRepeatClass ts in SenseRepeaters) 197 foreach (SensorInfo ts in SenseRepeaters)
181 { 198 {
182 if (ts.localID != m_localID || ts.itemID != m_itemID) 199 if (ts.localID != m_localID || ts.itemID != m_itemID)
183 { 200 {
@@ -192,7 +209,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
192 public void CheckSenseRepeaterEvents() 209 public void CheckSenseRepeaterEvents()
193 { 210 {
194 // Go through all timers 211 // Go through all timers
195 foreach (SenseRepeatClass ts in SenseRepeaters) 212 foreach (SensorInfo ts in SenseRepeaters)
196 { 213 {
197 // Time has passed? 214 // Time has passed?
198 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) 215 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
@@ -209,7 +226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
209 double range, double arc, SceneObjectPart host) 226 double range, double arc, SceneObjectPart host)
210 { 227 {
211 // Add to timer 228 // Add to timer
212 SenseRepeatClass ts = new SenseRepeatClass(); 229 SensorInfo ts = new SensorInfo();
213 ts.localID = m_localID; 230 ts.localID = m_localID;
214 ts.itemID = m_itemID; 231 ts.itemID = m_itemID;
215 ts.interval = 0; 232 ts.interval = 0;
@@ -225,7 +242,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
225 SensorSweep(ts); 242 SensorSweep(ts);
226 } 243 }
227 244
228 private void SensorSweep(SenseRepeatClass ts) 245 private void SensorSweep(SensorInfo ts)
229 { 246 {
230 if (ts.host == null) 247 if (ts.host == null)
231 { 248 {
@@ -301,7 +318,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
301 } 318 }
302 } 319 }
303 320
304 private List<SensedEntity> doObjectSensor(SenseRepeatClass ts) 321 private List<SensedEntity> doObjectSensor(SensorInfo ts)
305 { 322 {
306 List<EntityBase> Entities; 323 List<EntityBase> Entities;
307 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 324 List<SensedEntity> sensedEntities = new List<SensedEntity>();
@@ -450,7 +467,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
450 return sensedEntities; 467 return sensedEntities;
451 } 468 }
452 469
453 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) 470 private List<SensedEntity> doAgentSensor(SensorInfo ts)
454 { 471 {
455 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 472 List<SensedEntity> sensedEntities = new List<SensedEntity>();
456 473
@@ -626,7 +643,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
626 { 643 {
627 List<Object> data = new List<Object>(); 644 List<Object> data = new List<Object>();
628 645
629 foreach (SenseRepeatClass ts in SenseRepeaters) 646 foreach (SensorInfo ts in SenseRepeaters)
630 { 647 {
631 if (ts.itemID == itemID) 648 if (ts.itemID == itemID)
632 { 649 {
@@ -656,7 +673,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
656 673
657 while (idx < data.Length) 674 while (idx < data.Length)
658 { 675 {
659 SenseRepeatClass ts = new SenseRepeatClass(); 676 SensorInfo ts = new SensorInfo();
660 677
661 ts.localID = localID; 678 ts.localID = localID;
662 ts.itemID = itemID; 679 ts.itemID = itemID;
@@ -677,5 +694,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
677 idx += 6; 694 idx += 6;
678 } 695 }
679 } 696 }
697
698 public List<SensorInfo> GetSensorInfo()
699 {
700 List<SensorInfo> retList = new List<SensorInfo>();
701
702 lock (SenseRepeatListLock)
703 {
704 foreach (SensorInfo si in SenseRepeaters)
705 retList.Add(si.Clone());
706 }
707
708 return retList;
709 }
680 } 710 }
681} 711} \ No newline at end of file