Fixes for interrupts
This commit is contained in:
parent
30064b7101
commit
cc31d606a7
4 changed files with 13 additions and 2 deletions
BIN
pypdevs.tgz
Normal file
BIN
pypdevs.tgz
Normal file
Binary file not shown.
|
|
@ -1095,7 +1095,15 @@ class BaseSimulator(Solver):
|
||||||
self.threading_backend.wait(wait_time, self.runsim)
|
self.threading_backend.wait(wait_time, self.runsim)
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
portname, event_value = interrupt.split(" ")
|
info = interrupt.split(" ")
|
||||||
|
portname = info[0]
|
||||||
|
event_value = " ".join(info[1:])
|
||||||
|
if event_value[0] in "([{": # also allow tuples, lists or dictionaries
|
||||||
|
try:
|
||||||
|
event_value = eval(event_value)
|
||||||
|
except: pass
|
||||||
|
# event_value = eval(" ".join(info[1:]))
|
||||||
|
# portname, event_value = interrupt.split(" ")
|
||||||
event_port = self.portmap[portname]
|
event_port = self.portmap[portname]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Couldn't split, means we should stop
|
# Couldn't split, means we should stop
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
from threading import Event, Thread, Lock
|
from threading import Event, Thread, Lock
|
||||||
import pypdevs.accurate_time as time
|
import pypdevs.accurate_time as time
|
||||||
|
from pypdevs.infinity import INFINITY
|
||||||
|
|
||||||
class ThreadingPython(object):
|
class ThreadingPython(object):
|
||||||
"""
|
"""
|
||||||
|
|
@ -34,6 +35,8 @@ class ThreadingPython(object):
|
||||||
:param delay: time to wait
|
:param delay: time to wait
|
||||||
:param func: the function to call
|
:param func: the function to call
|
||||||
"""
|
"""
|
||||||
|
if delay == INFINITY:
|
||||||
|
return
|
||||||
#NOTE this call has a granularity of 5ms in Python <= 2.7.x in the worst case, so beware!
|
#NOTE this call has a granularity of 5ms in Python <= 2.7.x in the worst case, so beware!
|
||||||
# the granularity seems to be much better in Python >= 3.x
|
# the granularity seems to be much better in Python >= 3.x
|
||||||
p = Thread(target=ThreadingPython.callFunc, args=[self, delay, func])
|
p = Thread(target=ThreadingPython.callFunc, args=[self, delay, func])
|
||||||
|
|
|
||||||
|
|
@ -82,4 +82,4 @@ class ThreadingTkInter(object):
|
||||||
"""
|
"""
|
||||||
if not self.last_infinity:
|
if not self.last_infinity:
|
||||||
self.queue.append(None)
|
self.queue.append(None)
|
||||||
self.unlock()
|
self.unlock()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue