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