@@ -60,12 +60,17 class throttle(object): | |||
|
60 | 60 | def __call__(self, fn): |
|
61 | 61 | @wraps(fn) |
|
62 | 62 | def wrapper(*args, **kwargs): |
|
63 | now = datetime.datetime.now() | |
|
64 | time_since_last_call = now - self.time_of_last_call | |
|
65 | time_left = self.throttle_period - time_since_last_call | |
|
63 | coerce = kwargs.pop('coerce', None) | |
|
64 | if coerce: | |
|
65 | self.time_of_last_call = datetime.datetime.now() | |
|
66 | return fn(*args, **kwargs) | |
|
67 | else: | |
|
68 | now = datetime.datetime.now() | |
|
69 | time_since_last_call = now - self.time_of_last_call | |
|
70 | time_left = self.throttle_period - time_since_last_call | |
|
66 | 71 | |
|
67 | if time_left > datetime.timedelta(seconds=0): | |
|
68 | return | |
|
72 | if time_left > datetime.timedelta(seconds=0): | |
|
73 | return | |
|
69 | 74 | |
|
70 | 75 | self.time_of_last_call = datetime.datetime.now() |
|
71 | 76 | return fn(*args, **kwargs) |
@@ -104,6 +109,9 class Data(object): | |||
|
104 | 109 | ret = numpy.swapaxes(ret, 0, 1) |
|
105 | 110 | return ret |
|
106 | 111 | |
|
112 | def __contains__(self, key): | |
|
113 | return key in self.data | |
|
114 | ||
|
107 | 115 | def setup(self): |
|
108 | 116 | ''' |
|
109 | 117 | Configure object |
@@ -564,26 +572,30 class PlotterReceiver(ProcessingUnit, Process): | |||
|
564 | 572 | |
|
565 | 573 | while True: |
|
566 | 574 | dataOut = self.receiver.recv_pyobj() |
|
567 | tm = dataOut.utctime | |
|
568 | if dataOut.useLocalTime: | |
|
569 |
|
|
|
570 |
|
|
|
571 | dt = datetime.datetime.fromtimestamp(tm).date() | |
|
572 | else: | |
|
573 | if self.localtime: | |
|
574 |
tm |
|
|
575 |
dt = datetime.datetime. |
|
|
576 |
|
|
|
577 |
if |
|
|
578 | if self.data: | |
|
579 | self.data.ended = True | |
|
580 | self.send(self.data) | |
|
581 |
|
|
|
582 |
self.data |
|
|
583 |
self.dat |
|
|
584 | ||
|
585 | self.data.update(dataOut) | |
|
575 | if not dataOut.flagNoData: | |
|
576 | if dataOut.type == 'Parameters': | |
|
577 | tm = dataOut.utctimeInit | |
|
578 | else: | |
|
579 | tm = dataOut.utctime | |
|
580 | if dataOut.useLocalTime: | |
|
581 | if not self.localtime: | |
|
582 | tm += time.timezone | |
|
583 | dt = datetime.datetime.fromtimestamp(tm).date() | |
|
584 | else: | |
|
585 | if self.localtime: | |
|
586 | tm -= time.timezone | |
|
587 | dt = datetime.datetime.utcfromtimestamp(tm).date() | |
|
588 | coerce = False | |
|
589 | if dt not in self.dates: | |
|
590 | if self.data: | |
|
591 | self.data.ended = True | |
|
592 | self.send(self.data) | |
|
593 | coerce = True | |
|
594 | self.data.setup() | |
|
595 | self.dates.append(dt) | |
|
586 | 596 | |
|
597 | self.data.update(dataOut) | |
|
598 | ||
|
587 | 599 | if dataOut.finished is True: |
|
588 | 600 | self.connections -= 1 |
|
589 | 601 | if self.connections == 0 and dt in self.dates: |
@@ -594,9 +606,9 class PlotterReceiver(ProcessingUnit, Process): | |||
|
594 | 606 | if self.realtime: |
|
595 | 607 | self.send(self.data) |
|
596 | 608 | # self.sender_web.send_string(self.data.jsonify()) |
|
597 | else: | |
|
598 | if not sended: | |
|
599 | self.sendData(self.send, self.data) | |
|
609 | else: | |
|
610 | self.sendData(self.send, self.data, coerce=coerce) | |
|
611 | coerce = False | |
|
600 | 612 | |
|
601 | 613 | return |
|
602 | 614 |
General Comments 0
You need to be logged in to leave comments.
Login now