Esempio n. 1
0
 def __init__(self):
     self.pathstorage = Pathstorage()
     self.obstacle_map = [[]]
     self.fifo = Fifo(self)
     self.islands = Islands()
     #TODO: searching Islands!
     self.jobs = []  # contains all pathfindingjobs
Esempio n. 2
0
def graphConstructor(wikiInput, stop):
    fifo = Fifo.Fifo()
    hashT = hashingTable.UrlDistinctTester()
    depthC = depthController.DepthController(stop)
    fifo.addElement(wikiInput)  # initialization of the fifo

    G = nx.DiGraph()  # creating direct graph

    while not (fifo.isFifoEmpty()):
        # handling fifo
        current_url = fifo.removeFirstIn()  # extracting elt to use
        depthC.elementsTreated()
        links_current_url = WikiPagesReader.wikiPagesFinder(current_url)  # computing all mentionned pages

        if depthC.depthControl() == 1:

            # removing all url already in fifo
            links_current_distinct_url = []
            for url in links_current_url:
                if hashT.add(url):  # return True if url not in hashing table
                    links_current_distinct_url.append(url)

            # feeding the fifo
            fifo.addList(links_current_distinct_url)
            depthC.addElementsToTreat(links_current_distinct_url)

            # feeding the graph
            G.add_node(current_url)
            G.add_nodes_from(links_current_distinct_url)

            # adding edge from current_url to elt (because elt is mentionned in current_url)
            for elt in links_current_url:
                G.add_edge(current_url,
                           elt)

        # when going through last layer's nodes
        elif depthC.depthControl() == 2:
            edges_to_add = [elt for elt in links_current_url if hashT.checkInTable(elt)]
            for elt in edges_to_add:
                G.add_edge(current_url,
                           elt)  # adding edge from current_url to elt (because elt is mentionned in current_url

        depthC.cursorUpdate()

    nx.write_gml(G, "network_depth_2.gml")  # saving the graph into a .gml file
Esempio n. 3
0
 def setUp(self):
     self.policity = Fifo()
     self.aPCB = PCB("Program1")
     self.bPCB = PCB("Program2", 20)
     self.cPCB = PCB("Program2", 50)
     self.dPCB = PCB("Program2", 15)
Esempio n. 4
0
##Testing Fifo class
import sys

sys.path.append('..')
import Fifo

fifo = Fifo.Fifo()

fifo.addList([1, 2, 3])
print(fifo.getList())

fifo.removeFirstIn()
print(fifo.getList())

fifo.addElement(4)
print(fifo.getList())

while not (fifo.isFifoEmpty()):
    x = fifo.removeFirstIn()
    if x == 4:
        fifo.addElement(5)
    print(x)

#return:
# [1, 2, 3]
# [2, 3]
# [2, 3, 4]
# 2
# 3
# 4
# 5
import audioop
import threading
import time

import Fifo
import config

_received_queue = Fifo.Fifo()
_sending_queue = Fifo.Fifo()
silence = chr(0) * 1024 * 4
_MAX_BUFFER_SIZE = int(config.RATE / 10)
_DELAY_RATE = 1 / config.RATE


def receive_audio(audio_stream, socket_connection, chunk=config.CHUNK):
    t1 = threading.Thread(target=play_audio, args=(audio_stream, ))
    t1.start()
    while True:
        _received_queue.put((socket_connection.recv(chunk)))
        if len(_received_queue) > _MAX_BUFFER_SIZE:
            _received_queue.get(len(_received_queue) - _MAX_BUFFER_SIZE)


def send_audio(
    audio_stream,
    socket_connection,
    node,
    chunk=config.CHUNK,
):
    t1 = threading.Thread(target=record_audio, args=(audio_stream, ))
    t1.start()
Esempio n. 6
0
import Arbiter
from Arbiter import *
import Requestor
from Requestor import *
import Request
from Request import *
import json

requestor_cfg_fname = 'requestorConfig.txt'

requestor_0 = Requestor(requestor_cfg_fname)
requestor_1 = Requestor(requestor_cfg_fname)
requestor_2 = Requestor(requestor_cfg_fname)
requestor_3 = Requestor(requestor_cfg_fname)

fifo_0 = Fifo(depth=8)
fifo_1 = Fifo(depth=8)
fifo_2 = Fifo(depth=8)
fifo_3 = Fifo(depth=8)

pipe_0 = Pipe(num_stages=8)
pipe_1 = Pipe(num_stages=4)
pipe_2 = Pipe(num_stages=2)
pipe_3 = Pipe(num_stages=12)

arb_0 = Arbiter(num_ports=4)

all_requestors_done = False
clk_cnt = 0

def inc_clk():