Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

# -*- coding: utf-8 -*- 

""" 

Module to hold a SeedLink stream descriptions (selectors) for network/station. 

 

Part of Python implementation of libslink of Chad Trabant and 

JSeedLink of Anthony Lomax 

 

:copyright: 

    The ObsPy Development Team (devs@obspy.org) & Anthony Lomax 

:license: 

    GNU Lesser General Public License, Version 3 

    (http://www.gnu.org/copyleft/lesser.html) 

""" 

 

from obspy.core.utcdatetime import UTCDateTime 

 

 

class SLNetStation(object): 

    """ 

    Class to hold a SeedLink stream selectors for a network/station. 

 

    :var MAX_SELECTOR_SIZE: Maximum selector size. 

    :type MAX_SELECTOR_SIZE: int 

    :var net: The network code. 

    :type net: str 

    :var station: The station code. 

    :type station: str 

    :var selectors: SeedLink style selectors for this station. 

    :type selectors: str 

    :var seqnum: SeedLink sequence number of last packet received. 

    :type seqnum: int 

    :var btime: Time stamp of last packet received. 

    :type btime: TTT 

    """ 

    MAX_SELECTOR_SIZE = 8 

    net = None 

    station = None 

    selectors = [] 

    seqnum = -1 

    btime = None 

 

    def __init__(self, net, station, selectors, seqnum, timestamp): 

        """ 

        Creates a new instance of SLNetStation. 

 

        :param net: network code. 

        :param station: station code. 

        :param selectors: selectors for this net/station, null if none. 

        :param seqnum: SeedLink sequence number of last packet received, 

            -1 to start at the next data. 

        :param timestamp: SeedLink time stamp in a UTCDateTime format for 

            last packet received, null for none. 

        """ 

        self.net = str(net) 

        self.station = str(station) 

        #print "DEBUG: selectors:", selectors 

        if selectors is not None: 

            self.selectors = selectors 

        self.seqnum = seqnum 

        if timestamp is not None: 

            self.btime = UTCDateTime(timestamp) 

 

    def appendSelectors(self, newSelectors): 

        """ 

        Appends a selectors String to the current selectors for this 

        SLNetStation. 

 

        :return: 0 if selectors added successfully, 1 otherwise 

        """ 

        self.selectors.append(newSelectors) 

        return 1 

 

    def getSelectors(self): 

        """ 

        Returns the selectors as an array of Strings 

 

        :return: array of selector Strings 

        """ 

        return self.selectors 

 

    def getSLTimeStamp(self): 

        """ 

        Returns the time stamp in SeedLink string format: 

        "year,month,day,hour,minute,second" 

 

        :return: SeedLink time 

        """ 

        return self.btime.formatSeedLink()