Пример #1
0
 def test_time_b_to_bytes_big(self):
     d = datetime.datetime(2017, 11, 29, 23, 58, 59, 978000)
     tiempo = app_asdu.TimeB(d)
     thebytes = tiempo.to_bytes()
     print(thebytes)
     tiempo2 = app_asdu.TimeB()
     tiempo2.from_hex(thebytes)
     self.assertEqual(tiempo2.datetime, localize(d))
Пример #2
0
    def test_empty_time_b_from_hex(self):
        tiempo = app_asdu.TimeB()

        # 2000 0 0 0 0 0
        tiempo.from_hex(bytearray.fromhex("00 00 00 00 00 00 00"))
        print(tiempo)
        self.assertEqual(tiempo.datetime,
                         localize(datetime.datetime(2000, 1, 1, 0, 0, 0, 0)))
Пример #3
0
    def test_time_b_from_hex(self):
        tiempo = app_asdu.TimeB()

        # al voltant del 2019-08-28 11:40
        tiempo.from_hex(bytearray.fromhex("00 90 25 8b 7c 08 13"))
        print(tiempo)
        self.assertEqual(
            tiempo.datetime,
            localize(datetime.datetime(2019, 8, 28, 11, 37, 36, 0)))

        tiempo.from_hex(bytearray.fromhex("0a 2a 10 0b e7 02 0a"))
        print(tiempo)
        self.assertEqual(
            tiempo.datetime,
            localize(datetime.datetime(2010, 2, 7, 11, 16, 10, 522000)))