|
@@ -1,17 +1,20 @@
|
|
|
# from . import DataHandler #此时是导入文件
|
|
|
-from .DataStream import DataWriteStream, ChPosmap, day_stamp
|
|
|
+from .DataStream import DataWriteStream, day_stamp
|
|
|
+from .DataStream import EChPosmap as pos_map
|
|
|
import numpy as np
|
|
|
|
|
|
__all__ = ['ChannelWriter']
|
|
|
|
|
|
+import logging
|
|
|
+log = logging.getLogger('writer')
|
|
|
|
|
|
-class ChannelWriter(DataWriteStream, ChPosmap):
|
|
|
+class ChannelWriter(DataWriteStream):
|
|
|
def write(self, method, params):
|
|
|
- if method == 'refill_commit':
|
|
|
+ if method == 'ch_commit':
|
|
|
self._onCommit(params)
|
|
|
- elif method == 'notify_succ':
|
|
|
+ elif method == 'ch_succ':
|
|
|
self._onSucc(params)
|
|
|
- elif method == 'notify_fail':
|
|
|
+ elif method == 'ch_fail':
|
|
|
self._onFail(params)
|
|
|
else:
|
|
|
pass
|
|
@@ -23,8 +26,8 @@ class ChannelWriter(DataWriteStream, ChPosmap):
|
|
|
chname, time, spec, card_type, channel_amount = parse(params)
|
|
|
path, pos = self.path_pos(chname, time, spec, card_type)
|
|
|
|
|
|
- self.file[path][self._pos_map['commit_count'], pos] += 1
|
|
|
- self.file[path][self._pos_map['commit_amounts'], pos] += channel_amount
|
|
|
+ self.file[path][pos_map.commit_count, pos] += 1
|
|
|
+ self.file[path][pos_map.commit_amounts, pos] += channel_amount
|
|
|
pass
|
|
|
|
|
|
def _onSucc(self, params):
|
|
@@ -34,9 +37,9 @@ class ChannelWriter(DataWriteStream, ChPosmap):
|
|
|
chname, time, spec, card_type, channel_amount, period = parse(params)
|
|
|
path, pos = self.path_pos(chname, time, spec, card_type)
|
|
|
|
|
|
- self.file[path][self._pos_map['succ_count'], pos] += 1
|
|
|
- self.file[path][self._pos_map['succ_amounts'], pos] += channel_amount
|
|
|
- self.file[path][self._pos_map['succ_periods'], pos] += period
|
|
|
+ self.file[path][pos_map.succ_count, pos] += 1
|
|
|
+ self.file[path][pos_map.succ_amounts, pos] += channel_amount
|
|
|
+ self.file[path][pos_map.succ_periods, pos] += period
|
|
|
pass
|
|
|
|
|
|
def _onFail(self, params):
|
|
@@ -46,9 +49,9 @@ class ChannelWriter(DataWriteStream, ChPosmap):
|
|
|
chname, time, spec, card_type, channel_amount, period = parse(params)
|
|
|
path, pos = self.path_pos(chname, time, spec, card_type)
|
|
|
|
|
|
- self.file[path][self._pos_map['fail_count'], pos] += 1
|
|
|
- self.file[path][self._pos_map['fail_amounts'], pos] += channel_amount
|
|
|
- self.file[path][self._pos_map['fail_periods'], pos] += period
|
|
|
+ self.file[path][pos_map.fail_count, pos] += 1
|
|
|
+ self.file[path][pos_map.fail_amounts, pos] += channel_amount
|
|
|
+ self.file[path][pos_map.fail_periods, pos] += period
|
|
|
pass
|
|
|
|
|
|
def path_pos(self, chname, time, spec, card_type):
|
|
@@ -57,7 +60,7 @@ class ChannelWriter(DataWriteStream, ChPosmap):
|
|
|
|
|
|
hfive = self.file
|
|
|
if path not in hfive:
|
|
|
- dim = len(self._pos_map)
|
|
|
+ dim = pos_map.dim()
|
|
|
hfive[path] = np.zeros((dim, 86400))
|
|
|
|
|
|
return path, time - today
|