Some sanity checks. Removed activateSiggen and deactivateSiggen fucntionality, as it has no use.
This commit is contained in:
parent
5e26f4a026
commit
d51d3f7d37
@ -67,8 +67,6 @@ class StreamMsg(Enum):
|
|||||||
endProcess = auto()
|
endProcess = auto()
|
||||||
scanDaqDevices = auto()
|
scanDaqDevices = auto()
|
||||||
|
|
||||||
activateSiggen = auto()
|
|
||||||
deactivateSiggen = auto()
|
|
||||||
"""
|
"""
|
||||||
Second part, status messages that are send back on all listeners
|
Second part, status messages that are send back on all listeners
|
||||||
"""
|
"""
|
||||||
@ -116,7 +114,6 @@ class AudioStream:
|
|||||||
self.running = False
|
self.running = False
|
||||||
self.aframectr = 0
|
self.aframectr = 0
|
||||||
self.avtype = avtype
|
self.avtype = avtype
|
||||||
self.siggen_activated = Atomic(False)
|
|
||||||
|
|
||||||
api_devices = devices[daqconfig.api]
|
api_devices = devices[daqconfig.api]
|
||||||
self.processCallback = processCallback
|
self.processCallback = processCallback
|
||||||
@ -138,6 +135,12 @@ class AudioStream:
|
|||||||
|
|
||||||
if en_in_ch == 0 and en_out_ch == 0:
|
if en_in_ch == 0 and en_out_ch == 0:
|
||||||
raise RuntimeError('No enabled input / output channels')
|
raise RuntimeError('No enabled input / output channels')
|
||||||
|
elif en_out_ch == 0 and avtype in (AvType.audio_duplex,
|
||||||
|
AvType.audio_output):
|
||||||
|
raise RuntimeError('No enabled output channels')
|
||||||
|
elif en_in_ch == 0 and avtype in (AvType.audio_input,
|
||||||
|
AvType.audio_duplex):
|
||||||
|
raise RuntimeError('No enabled input channels')
|
||||||
|
|
||||||
logging.debug('Ready to start device...')
|
logging.debug('Ready to start device...')
|
||||||
samplerate = self.daq.start(self.streamCallback)
|
samplerate = self.daq.start(self.streamCallback)
|
||||||
@ -264,7 +267,6 @@ class AvStreamProcess(mp.Process):
|
|||||||
|
|
||||||
# Check for devices
|
# Check for devices
|
||||||
self.rescanDaqDevices()
|
self.rescanDaqDevices()
|
||||||
self.siggen_activated = Atomic(False)
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -275,13 +277,7 @@ class AvStreamProcess(mp.Process):
|
|||||||
self.terminate()
|
self.terminate()
|
||||||
logging.debug(f"Streamprocess obtained message {msg}")
|
logging.debug(f"Streamprocess obtained message {msg}")
|
||||||
|
|
||||||
if msg == StreamMsg.activateSiggen:
|
if msg == StreamMsg.scanDaqDevices:
|
||||||
self.siggen_activated <<= True
|
|
||||||
|
|
||||||
elif msg == StreamMsg.deactivateSiggen:
|
|
||||||
self.siggen_activated <<= False
|
|
||||||
|
|
||||||
elif msg == StreamMsg.scanDaqDevices:
|
|
||||||
self.rescanDaqDevices()
|
self.rescanDaqDevices()
|
||||||
|
|
||||||
elif msg == StreamMsg.stopAllStreams:
|
elif msg == StreamMsg.stopAllStreams:
|
||||||
@ -355,7 +351,7 @@ class AvStreamProcess(mp.Process):
|
|||||||
self.sendAllQueues(
|
self.sendAllQueues(
|
||||||
StreamMsg.streamError,
|
StreamMsg.streamError,
|
||||||
stream.avtype,
|
stream.avtype,
|
||||||
"Error occured in stopping stream: {str(e)}",
|
f"Error occured in stopping stream: {str(e)}",
|
||||||
)
|
)
|
||||||
self.streams[avtype] = None
|
self.streams[avtype] = None
|
||||||
|
|
||||||
@ -427,28 +423,22 @@ class AvStreamProcess(mp.Process):
|
|||||||
"""This is called (from a separate thread) for each audio block."""
|
"""This is called (from a separate thread) for each audio block."""
|
||||||
# logging.debug('streamCallback()')
|
# logging.debug('streamCallback()')
|
||||||
if outdata is not None:
|
if outdata is not None:
|
||||||
if self.siggen_activated():
|
if not self.outq.empty():
|
||||||
if not self.outq.empty():
|
newdata = self.outq.get()
|
||||||
newdata = self.outq.get()
|
if newdata.shape[0] != outdata.shape[0] or newdata.ndim != 1:
|
||||||
if newdata.shape[0] != outdata.shape[0] or newdata.ndim != 1:
|
msgtxt = "Invalid output data obtained from queue"
|
||||||
msgtxt = "Invalid output data obtained from queue"
|
logging.fatal(msgtxt)
|
||||||
logging.fatal(msgtxt)
|
|
||||||
self.sendAllQueues(
|
|
||||||
StreamMsg.streamFatalError, audiostream.avtype, msgtxt
|
|
||||||
)
|
|
||||||
return 1
|
|
||||||
outdata[:, :] = newdata[:, None]
|
|
||||||
else:
|
|
||||||
msgtxt = "Signal generator buffer underflow. Signal generator cannot keep up with data generation."
|
|
||||||
# logging.error(msgtxt)
|
|
||||||
self.sendAllQueues(
|
self.sendAllQueues(
|
||||||
StreamMsg.streamTemporaryError, audiostream.avtype, msgtxt
|
StreamMsg.streamFatalError, audiostream.avtype, msgtxt
|
||||||
)
|
)
|
||||||
outdata[:, :] = 0
|
return 1
|
||||||
|
outdata[:, :] = newdata[:, None]
|
||||||
# Siggen not activated
|
|
||||||
else:
|
else:
|
||||||
logging.debug("siggen not activated")
|
msgtxt = "Signal generator buffer underflow. Signal generator cannot keep up with data generation."
|
||||||
|
# logging.error(msgtxt)
|
||||||
|
self.sendAllQueues(
|
||||||
|
StreamMsg.streamTemporaryError, audiostream.avtype, msgtxt
|
||||||
|
)
|
||||||
outdata[:, :] = 0
|
outdata[:, :] = 0
|
||||||
|
|
||||||
if indata is not None:
|
if indata is not None:
|
||||||
@ -617,15 +607,7 @@ class StreamManager:
|
|||||||
self.handleMessages()
|
self.handleMessages()
|
||||||
return self.outq
|
return self.outq
|
||||||
|
|
||||||
def activateSiggen(self):
|
|
||||||
self.handleMessages()
|
|
||||||
logging.debug("activateSiggen()")
|
|
||||||
self.sendPipe(StreamMsg.activateSiggen, None)
|
|
||||||
|
|
||||||
def deactivateSiggen(self):
|
|
||||||
self.handleMessages()
|
|
||||||
logging.debug("deactivateSiggen()")
|
|
||||||
self.sendPipe(StreamMsg.deactivateSiggen, None)
|
|
||||||
|
|
||||||
def addMsgQueueListener(self):
|
def addMsgQueueListener(self):
|
||||||
"""
|
"""
|
||||||
@ -692,6 +674,7 @@ class StreamManager:
|
|||||||
break
|
break
|
||||||
|
|
||||||
def stopStream(self, avtype: AvType):
|
def stopStream(self, avtype: AvType):
|
||||||
|
logging.debug(f'StreamManager::stopStream({avtype})')
|
||||||
self.handleMessages()
|
self.handleMessages()
|
||||||
self.sendPipe(StreamMsg.stopStream, avtype)
|
self.sendPipe(StreamMsg.stopStream, avtype)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user