Exemplo n.º 1
0
    def test_noCommonAncestor(self):
        a = self.newSysClock()
        b = self.newSysClock()
        a1 = CorrelatedClock(a, tickRate=1000, correlation=Correlation(0, 0))
        b1 = CorrelatedClock(b, tickRate=1000, correlation=Correlation(0, 0))
        a2 = CorrelatedClock(a1, tickRate=1000, correlation=Correlation(0, 0))
        b2 = CorrelatedClock(b1, tickRate=1000, correlation=Correlation(0, 0))

        self.assertRaises(NoCommonClock, lambda: a.toOtherClockTicks(b, 5))
        self.assertRaises(NoCommonClock, lambda: a.toOtherClockTicks(b1, 5))
        self.assertRaises(NoCommonClock, lambda: a.toOtherClockTicks(b2, 5))

        self.assertRaises(NoCommonClock, lambda: a1.toOtherClockTicks(b, 5))
        self.assertRaises(NoCommonClock, lambda: a1.toOtherClockTicks(b1, 5))
        self.assertRaises(NoCommonClock, lambda: a1.toOtherClockTicks(b2, 5))

        self.assertRaises(NoCommonClock, lambda: a2.toOtherClockTicks(b, 5))
        self.assertRaises(NoCommonClock, lambda: a2.toOtherClockTicks(b1, 5))
        self.assertRaises(NoCommonClock, lambda: a2.toOtherClockTicks(b2, 5))

        self.assertRaises(NoCommonClock, lambda: b.toOtherClockTicks(a, 5))
        self.assertRaises(NoCommonClock, lambda: b.toOtherClockTicks(a1, 5))
        self.assertRaises(NoCommonClock, lambda: b.toOtherClockTicks(a2, 5))

        self.assertRaises(NoCommonClock, lambda: b1.toOtherClockTicks(a, 5))
        self.assertRaises(NoCommonClock, lambda: b1.toOtherClockTicks(a1, 5))
        self.assertRaises(NoCommonClock, lambda: b1.toOtherClockTicks(a2, 5))

        self.assertRaises(NoCommonClock, lambda: b2.toOtherClockTicks(a, 5))
        self.assertRaises(NoCommonClock, lambda: b2.toOtherClockTicks(a1, 5))
        self.assertRaises(NoCommonClock, lambda: b2.toOtherClockTicks(a2, 5))
Exemplo n.º 2
0
    def test_noCommonAncestor(self):
        a = SysClock()
        b = SysClock()
        a1 = CorrelatedClock(a, tickRate=1000, correlation=(0,0))
        b1 = CorrelatedClock(b, tickRate=1000, correlation=(0,0))
        a2 = CorrelatedClock(a1, tickRate=1000, correlation=(0,0))
        b2 = CorrelatedClock(b1, tickRate=1000, correlation=(0,0))
        
        self.assertRaises(NoCommonClock, lambda:a.toOtherClockTicks(b, 5))
        self.assertRaises(NoCommonClock, lambda:a.toOtherClockTicks(b1, 5))
        self.assertRaises(NoCommonClock, lambda:a.toOtherClockTicks(b2, 5))

        self.assertRaises(NoCommonClock, lambda:a1.toOtherClockTicks(b, 5))
        self.assertRaises(NoCommonClock, lambda:a1.toOtherClockTicks(b1, 5))
        self.assertRaises(NoCommonClock, lambda:a1.toOtherClockTicks(b2, 5))
        
        self.assertRaises(NoCommonClock, lambda:a2.toOtherClockTicks(b, 5))
        self.assertRaises(NoCommonClock, lambda:a2.toOtherClockTicks(b1, 5))
        self.assertRaises(NoCommonClock, lambda:a2.toOtherClockTicks(b2, 5))
        
        self.assertRaises(NoCommonClock, lambda:b.toOtherClockTicks(a, 5))
        self.assertRaises(NoCommonClock, lambda:b.toOtherClockTicks(a1, 5))
        self.assertRaises(NoCommonClock, lambda:b.toOtherClockTicks(a2, 5))

        self.assertRaises(NoCommonClock, lambda:b1.toOtherClockTicks(a, 5))
        self.assertRaises(NoCommonClock, lambda:b1.toOtherClockTicks(a1, 5))
        self.assertRaises(NoCommonClock, lambda:b1.toOtherClockTicks(a2, 5))
        
        self.assertRaises(NoCommonClock, lambda:b2.toOtherClockTicks(a, 5))
        self.assertRaises(NoCommonClock, lambda:b2.toOtherClockTicks(a1, 5))
        self.assertRaises(NoCommonClock, lambda:b2.toOtherClockTicks(a2, 5))
Exemplo n.º 3
0
 def test_distantParentMidHierarchy(self):
     a = SysClock(tickRate=1000000)
     a1 = CorrelatedClock(a, tickRate=100, correlation=(50,0))
     a2 = CorrelatedClock(a1, tickRate=78, correlation=(28,999))
     a3 = CorrelatedClock(a2, tickRate=178, correlation=(5,1003))
     a4 = CorrelatedClock(a3, tickRate=28, correlation=(17,9))
     self.assertEquals(a3.toOtherClockTicks(a1, 500), a2.toParentTicks(a3.toParentTicks(500)))
Exemplo n.º 4
0
 def test_distantParentMidHierarchy(self):
     a = self.newSysClock(tickRate=1000000)
     a1 = CorrelatedClock(a, tickRate=100, correlation=Correlation(50, 0))
     a2 = CorrelatedClock(a1, tickRate=78, correlation=Correlation(28, 999))
     a3 = CorrelatedClock(a2,
                          tickRate=178,
                          correlation=Correlation(5, 1003))
     a4 = CorrelatedClock(a3, tickRate=28, correlation=Correlation(17, 9))
     self.assertEquals(a3.toOtherClockTicks(a1, 500),
                       a2.toParentTicks(a3.toParentTicks(500)))
Exemplo n.º 5
0
 def test_differentBranches(self):
     a = SysClock(tickRate=1000000)
     a1 = CorrelatedClock(a, tickRate=100, correlation=(50,0))
     a2 = CorrelatedClock(a1, tickRate=78, correlation=(28,999))
     a3 = CorrelatedClock(a2, tickRate=178, correlation=(5,1003))
     a4 = CorrelatedClock(a3, tickRate=28, correlation=(17,9))
     b3 = CorrelatedClock(a2, tickRate=1000, correlation=(10,20))
     b4 = CorrelatedClock(b3, tickRate=2000, correlation=(15,90))
     
     v = a4.toParentTicks(500)
     v = a3.toParentTicks(v)
     v = b3.fromParentTicks(v)
     v = b4.fromParentTicks(v)
     
     self.assertEquals(a4.toOtherClockTicks(b4, 500), v)
Exemplo n.º 6
0
    def test_differentBranches(self):
        a = self.newSysClock(tickRate=1000000)
        a1 = CorrelatedClock(a, tickRate=100, correlation=Correlation(50, 0))
        a2 = CorrelatedClock(a1, tickRate=78, correlation=Correlation(28, 999))
        a3 = CorrelatedClock(a2,
                             tickRate=178,
                             correlation=Correlation(5, 1003))
        a4 = CorrelatedClock(a3, tickRate=28, correlation=Correlation(17, 9))
        b3 = CorrelatedClock(a2,
                             tickRate=1000,
                             correlation=Correlation(10, 20))
        b4 = CorrelatedClock(b3,
                             tickRate=2000,
                             correlation=Correlation(15, 90))

        v = a4.toParentTicks(500)
        v = a3.toParentTicks(v)
        v = b3.fromParentTicks(v)
        v = b4.fromParentTicks(v)

        self.assertEquals(a4.toOtherClockTicks(b4, 500), v)
Exemplo n.º 7
0
 def test_distantParent(self):
     a = self.newSysClock(tickRate=1000000)
     a1 = CorrelatedClock(a, tickRate=100, correlation=Correlation(50, 0))
     a2 = CorrelatedClock(a1, tickRate=78, correlation=Correlation(28, 999))
     self.assertEquals(a2.toOtherClockTicks(a, 500),
                       a1.toParentTicks(a2.toParentTicks(500)))
Exemplo n.º 8
0
 def test_distantParent(self):
     a = SysClock(tickRate=1000000)
     a1 = CorrelatedClock(a, tickRate=100, correlation=(50,0))
     a2 = CorrelatedClock(a1, tickRate=78, correlation=(28,999))
     self.assertEquals(a2.toOtherClockTicks(a, 500), a1.toParentTicks(a2.toParentTicks(500)))