當前位置: 首頁>>代碼示例>>Python>>正文


Python Machine.run方法代碼示例

本文整理匯總了Python中machine.Machine.run方法的典型用法代碼示例。如果您正苦於以下問題:Python Machine.run方法的具體用法?Python Machine.run怎麽用?Python Machine.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在machine.Machine的用法示例。


在下文中一共展示了Machine.run方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: StarTest

# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import run [as 別名]
class StarTest(object):
    def __init__(self, tmpdir):
        self.tmpdir = str(tmpdir)
        self.root = Compound(None, 'root')
        self.events = {}
        for meth_name in dir(self):
            meth = getattr(self, meth_name)
            ticks = getattr(meth, 'ticks', None)
            if ticks is not None:
                for tick in ticks:
                    events = self.events.get(tick, [])
                    events.append(meth)
                    self.events[tick] = events

    def each_tick(self, tick):
        pass

    def each_clock(self, clock):
        pass

    def get_total_ticks(self):
        return max(self.events.keys() or [0]) + 1

    def run_machine(self, ticks=None):
        self.machine = Machine(self.root, on_tick=self.each_tick,
                               on_clock=self.each_clock)
        self.machine.run(ticks or self.get_total_ticks(), self.events)

    def view(self, prefix, tick=None):
        tick = tick if tick is not None else self.machine.tick
        builder = GraphBuilder()
        graph = builder.visit(self.root)
        graph.render(os.path.join(self.tmpdir, '%s_%i' % (prefix, tick)))
開發者ID:MeadBarrel,項目名稱:starschematic,代碼行數:35,代碼來源:_startest.py

示例2: test_brUnit1

# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import run [as 別名]
 def test_brUnit1(self):
     sys.stdout = output = io.StringIO()
     machine = Machine()
     machine.loadProgram('Tomasulo/brUnit1.hex')
     machine.run()
     with open('Tomasulo/brUnit1.out', 'r') as answerFile:
         answer = answerFile.read()
     self.assertEquals(output.getvalue(), answer)
開發者ID:kaledj,項目名稱:TomasuloSim,代碼行數:10,代碼來源:test_tomasulo.py

示例3: test_allInts

# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import run [as 別名]
 def test_allInts(self):
     for i in range(1, 9):
         sys.stdout = output = io.StringIO()
         machine = Machine()
         machine.loadProgram('Tomasulo/intUnit{0}.hex'.format(i))
         machine.run()
         with open('Tomasulo/intUnit{0}.out'.format(i), 'r') as answerFile:
             answer = answerFile.read()
         self.assertEquals(output.getvalue(), answer)
開發者ID:kaledj,項目名稱:TomasuloSim,代碼行數:11,代碼來源:test_tomasulo.py

示例4: test_all

# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import run [as 別名]
 def test_all(self):
     sys.stdout = output = io.StringIO()
     for inputFile in os.listdir('Tomasulo'):
         if inputFile.endswith('.dlx'): continue
         if inputFile.endswith('.out'): continue
         machine = Machine()
         machine.loadProgram('Tomasulo/' + inputFile)
         machine.run()
         with open('Tomasulo/' + inputFile.strip('.hex') + '.out', 'r') as answerFile:
             answer = answerFile.read()
         self.assertEquals(output.getvalue(), answer)
開發者ID:kaledj,項目名稱:TomasuloSim,代碼行數:13,代碼來源:test_tomasulo.py


注:本文中的machine.Machine.run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。