When moving our code from using hotspots to vizproximity I seem to have discovered a bug in this module (both already available in Vizard4). The method
vizproximity.Manager.getActiveSensors() can return sensors which have already been deleted through
vizproximity.Manager.removeSensor(). Which, when you have the need to add and remove frequently, leads to accumulation of (not available) sensors in the active list of a target.
I took the liberty to check the module and found this: the update routine adds a set of sensors that are currently triggered to each target and stores this in the self._target dictionary:
Code:
def update(self):
"""Update state of proximity sensors and trigger enter/exit events if needed"""
# Don't bother checking if no targets or sensors
if not (self._targets and self._sensors):
return
# Set of active sensors for debugging purposes
activeSensors = None
if self._debugRoot is not None:
activeSensors = set()
# Check if each target is in range of each sensor
events = []
for t,active in self._targets.iteritems(): pos = t.getPosition()
for s in self._sensors.iterkeys():
isInside = s.containsPoint(pos)
if isInside and activeSensors is not None:
activeSensors.add(s)
wasInside = s in active
if wasInside != isInside:
if isInside:
active.add(s)
events.append( (ENTER_PROXIMITY_EVENT, ProximityEvent(s,t,self)) )
else:
active.remove(s)
events.append( (EXIT_PROXIMITY_EVENT, ProximityEvent(s,t,self)) )
:
:
Unfortunately, when a sensor is deleted, this set of active sensors at each target is not updated. The code highlighted does correct the problem (get in touch about my fee, please

)
Code:
def removeSensor(self,sensor):
"""Remove a proximity sensor from the manager"""
try:
data = self._sensors[sensor]
except KeyError:
return
# Remove debug node of sensor
if data.debug:
data.debug.remove()
# Remove sensor from target's active list (C) Siemens AG
for active in self._targets.itervalues():
active.discard(sensor)
# Remove sensor from dictionary
del self._sensors[sensor]
sensor.removeRemoveCallback(self.removeSensor)
Hope this helps to make the Vizard5 release even better!