예제 #1
0
 def test_getvalue_compound(self):
     x = getValue("UINT,USHORT[2]", bytearray([0x08, 0x52, 0x79, 0x4D])) # Date
     self.assertEqual(x, [21000, 121, 77])
     x = getValue("USHORT[3],UINT", bytearray([ 0x79, 0x4D, 0xFF, 0x08, 0x52])) # Time
     self.assertEqual(x, [121, 77, 255, 21000])
     x = getValue("INT[2],BYTE", bytearray([ 0x05, 0x00, 0xFB, 0xFF, 0x05])) # Encoder
     self.assertEqual(x, [5, -5, [True, False, True, False, False, False, False, False]])
예제 #2
0
 def test_getvalue_compound(self):
     x = getValue("UINT,USHORT[2]", bytearray([0x08, 0x52, 0x79,
                                               0x4D]))  # Date
     self.assertEqual(x, [21000, 121, 77])
     x = getValue("USHORT[3],UINT",
                  bytearray([0x79, 0x4D, 0xFF, 0x08, 0x52]))  # Time
     self.assertEqual(x, [121, 77, 255, 21000])
     x = getValue("INT[2],BYTE", bytearray([0x05, 0x00, 0xFB, 0xFF,
                                            0x05]))  # Encoder
     self.assertEqual(
         x, [5, -5, [True, False, True, False, False, False, False, False]])
예제 #3
0
 def test_getvalue_basic_word(self):
     y = [True, False, True]
     y.extend([False] * 5)
     y.extend(y)
     x = getValue("WORD", bytearray([0x05, 0x05]))
     self.assertEqual(x, y)
예제 #4
0
 def test_getvalue_basic_byte(self):
     y = [True, False, True]
     y.extend([False] * 5)
     x = getValue("BYTE", bytearray([0x05]))
     self.assertEqual(x, y)
예제 #5
0
 def test_getvalue_basicfloat(self):
     for each in self.float_tests:
         x = getValue("FLOAT", each[1])
         self.assertEqual(x, each[0])
예제 #6
0
 def test_getvalue_basicuint(self):
     for each in self.uint_tests:
         x = getValue("UINT", each[1], each[2])
         self.assertEqual(x, each[0])
예제 #7
0
 def test_getvalue_basic_word(self):
     y = [True, False, True]
     y.extend([False]*5)
     y.extend(y)
     x = getValue("WORD", bytearray([0x05, 0x05]))
     self.assertEqual(x, y)
예제 #8
0
 def test_getvalue_basic_byte(self):
     y = [True, False, True]
     y.extend([False]*5)
     x = getValue("BYTE", bytearray([0x05]))
     self.assertEqual(x, y)
예제 #9
0
 def test_getvalue_basicfloat(self):
     for each in self.float_tests:
         x = getValue("FLOAT",each[1])
         self.assertEqual(x, each[0])
예제 #10
0
 def test_getvalue_basicuint(self):
     for each in self.uint_tests:
         x = getValue("UINT",each[1], each[2])
         self.assertEqual(x, each[0])