コード例 #1
0
 def testDecodeToioIDReturnsStandardID(self):
     tid = tm.decodeToioID(bytes([0x02, 0x00, 0x00, 0x38, 0x00, 0x15,
                                  0x00]))
     self.assertIsInstance(tid, td.StandardID)
     self.assertTrue(tid.isStandard)
     self.assertEqual(tid.value, 3670016)
     self.assertEqual(tid.angle, 21)
コード例 #2
0
 def testDecodeToioIDReturnsPositionID(self):
     tid = tm.decodeToioID(
         bytes([
             0x01, 0xc5, 0x02, 0x7f, 0x01, 0x32, 0x01, 0xbc, 0x02, 0x82,
             0x01, 0x33, 0x01
         ]))
     self.assertIsInstance(tid, td.PositionID)
     self.assertTrue(tid.isPosition)
     self.assertEqual(tid.x, 709)
     self.assertEqual(tid.y, 383)
     self.assertEqual(tid.angle, 306)
     self.assertEqual(tid.sensorX, 700)
     self.assertEqual(tid.sensorY, 386)
     self.assertEqual(tid.sensorAngle, 307)
コード例 #3
0
 def testDecodeToioIDReturnsMissedFromStandardID(self):
     tid = tm.decodeToioID(bytes([0x04]))
     self.assertIsInstance(tid, td.MissedID)
     self.assertTrue(tid.isMissed)
     self.assertEqual(tid.fromType, td.ToioIDType.STANDARD)
コード例 #4
0
 def testDecodeToioIDReturnsMissedFromPositionID(self):
     tid = tm.decodeToioID(bytes([0x03]))
     self.assertIsInstance(tid, td.MissedID)
     self.assertTrue(tid.isMissed)
     self.assertEqual(tid.fromType, td.ToioIDType.POSITION)
コード例 #5
0
 def testDecodeToioIDReturnsMissedFromInvalidType(self):
     tid = tm.decodeToioID(bytes([0xff, 0x01, 0x02]))
     self.assertIsInstance(tid, td.MissedID)
     self.assertTrue(tid.isMissed)
     self.assertEqual(tid.fromType, td.ToioIDType.INVALID)