I've had a go at getting it working based on the thread:
I had some issues where my .offer didn't seem to actually append anything to my queue.
I made a project library script called alarmQueue:
from java.util.concurrent import LinkedBlockingDeque, TimeUnit
logger = system.util.getLogger("Alarm Event Queue")
# Capacity = 100. The new instance is thrown away if already in globals.
deque = system.util.getGlobals().setdefault('MyAlarmQueue', LinkedBlockingDeque(100))
def someTimerEvent():
nextItem = deque.poll(15000, TimeUnit.MILLISECONDS)
#logger.info(str(system.util.getGlobals()))
if nextItem:
pass
# Run the above at a fixed **rate** matching the poll timeout.
def addDeque(message):
response = deque.offer(str(message))
logger.warn(str(response))
I call the someTimerEvent() every 15000 ms in a timer script (using dedicated thread, fixed rate), I added the addDeque to the alarm active script on a a testing tag, with the below script:
path = str(alarmEvent.getDisplayPath())
AlarmQueue.addDeque(path)
The response value always returns a True
, but whenever I try querying the queue using:
print AlarmQueue.Deque
is just returns single value even though I trigger my alarm several times. They also dissapear after some time, does this timer event erase the queue?
Where am I getting it wrong? Or is it okay, I just don't know how to get the data back out of it