-
Notifications
You must be signed in to change notification settings - Fork 11
/
PoMoCoModule.py
47 lines (38 loc) · 1.26 KB
/
PoMoCoModule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import wx
import threading, os, time
import Queue
class Note():
def __init__(self):
self.sender = ""
self.receiver = ""
self.type = ""
self.message = ""
class Node(threading.Thread):
modules = {}
def __init__(self):
self.inNoteQueue = Queue.Queue()
self.moduleType = ""
self.NoteTypes = []
def sendNote(self, note):
Node.modules[note.receiver].put(note)
#print self.moduleType,"Sent Note:",note.sender,"->",note.receiver,"-",note.type,":",note.message
def writeAndSendNote(self, type, message, receiver):
toSend = Note()
toSend.sender = self.moduleType
toSend.type = type
toSend.message = message
toSend.receiver = receiver
self.sendNote(toSend)
def processNote(self, note):
pass
def addNote(self, note):
print self.inNoteQueue
self.inNoteQueue.put(note)
def run(self):
while True:
try:
message = self.inNoteQueue.get(block=False)
self.processNote(message)
except Queue.Empty:
pass
time.sleep(0) # keeps infinite loop from hogging all the CPU