forked from pycubed/software_example_beepsat
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating imports for priority queue class
- Loading branch information
Showing
3 changed files
with
6 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,9 @@ | ||
"""The Transmission Queue is a max heap of messages to be transmitted. | ||
"""The Image Queue is a max heap of filepaths to be transmitted. | ||
Messages must support the `__lt__`, `__le__`, `__eq__`, `__ge__`, and `__gt__` operators. | ||
This enables to the max heap to compare messages based on their priority. | ||
""" | ||
from . import priority_queue as pq | ||
# from . import priority_queue as pq | ||
from .priority_queue import PriorityQueue | ||
|
||
queue = [] | ||
limit = 5 | ||
|
||
def push(msg): | ||
"""Push a msg into the transmission queue | ||
:param msg: The message to push | ||
:type msg: Message | MemoryBufferedMessage | DiskBufferedMessage | ||
""" | ||
if len(queue) < limit: | ||
pq.push(queue, msg) | ||
else: | ||
raise Exception("Queue is full") | ||
|
||
def peek(): | ||
"""Returns the next message to be transmitted | ||
:return: The next message to be transmitted | ||
:rtype: Message | MemoryBufferedMessage | DiskBufferedMessage | ||
""" | ||
return queue[0] | ||
|
||
def pop(): | ||
"""Returns the next message to be transmitted and removes it from the transmission queue | ||
:return: The next message to be transmitted | ||
:rtype: Message | MemoryBufferedMessage | DiskBufferedMessage | ||
""" | ||
return pq.pop(queue) | ||
|
||
def empty(): | ||
"""Returns if the transmission queue is empty""" | ||
return len(queue) == 0 | ||
|
||
def clear(): | ||
"""Clears the transmission queue""" | ||
global queue | ||
queue = [] | ||
|
||
def size(): | ||
"""Returns the number of messages in the transmission queue""" | ||
global queue | ||
return len(queue) | ||
image_queue = PriorityQueue([], 5) |