コード例 #1
0
    def test_unpack_trace(self):
        """Test unpacking a trace

        Example trace from station 508 event 1432684741282735016 detector 4.

        """
        trace = [189, 197, 188, 198, 190, 196, 189, 199, 193, 249, 443,
                 1098, 1753, 2393, 2709, 3014, 3125, 3243, 3203, 3168,
                 3022, 2932, 2761, 2621, 2411, 2266, 2083, 1910, 1696,
                 1489, 1275, 1167, 1053, 968, 855, 783, 680, 654, 604,
                 595, 531, 509, 464, 457, 415, 409, 370, 380, 356, 354,
                 326, 343, 319, 324, 304, 305, 286, 299, 286, 306, 289,
                 314, 305, 314, 300, 300, 276, 284, 272, 286, 266, 265,
                 248, 253, 242, 257, 249, 251, 237, 247, 235, 248, 237,
                 248, 237, 247, 239, 245, 237, 253, 235, 250, 241, 239,
                 226, 230, 218, 236, 218, 231, 214, 225, 209, 219, 215,
                 227, 217, 224, 222, 260, 242, 241, 225, 226, 210, 226,
                 221, 228, 216, 226, 210, 217, 205, 218, 213, 222, 209,
                 214, 198, 211, 207, 216, 203, 218, 206, 232, 224, 229,
                 220, 230, 221, 235, 225, 229, 222, 235, 225, 229, 212,
                 227, 216, 230, 220, 220, 206, 207, 192, 200, 197, 215]

        packed_trace = self.pack_trace(trace)
        unpacked_trace = HiSPARCEvent.unpack_trace(packed_trace)
        self.assertEqual(trace, [int(x) for x in unpacked_trace.split(',')
                                 if not x == ''])

        self.assertRaises(Exception, HiSPARCEvent.unpack_trace,
                          packed_trace[:-1])
コード例 #2
0
    def createEvent(self, eventcode, message):
        """Create an event corresponding to the eventcode"""

        if eventcode == "CIC":
            event = HiSPARCEvent(message)
        elif eventcode == "ERR":
            event = HiSPARCError(message)
        elif eventcode == "CFG":
            event = HiSPARCConfig(message)
        elif eventcode == "CMP":
            event = HiSPARCComparator(message)
        elif eventcode == "SIN":
            event = HiSPARCSingles(message)
        elif eventcode == "SAT":
            event = HiSPARCSatellites(message)
        elif eventcode == "WTR":
            event = WeatherEvent(message)
        elif eventcode == "WER":
            event = WeatherError(message)
        elif eventcode == "WCG":
            event = WeatherConfig(message)
        elif eventcode == "LIT":
            event = LightningEvent(message)
        elif eventcode == "LER":
            event = LightningError(message)
        elif eventcode == "LCG":
            event = LightningConfig(message)
        elif eventcode == "LST":
            event = LightningStatus(message)
        elif eventcode == "LNS":
            event = LightningNoise(message)
        else:
            logger.warning("Unknown message type %s (%d)." % (eventcode, message[0]))
            return None

        event.uploadCode = eventcode
        event.data = event.parseMessage()
        return event