123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- # from . import DataHandler #此时是导入文件
- from .DataStream import DataWriteStream, NetPosmap, day_stamp
- import numpy as np
- __all__ = ['NeterrWriter']
- class NeterrWriter(DataWriteStream, NetPosmap):
- def write(self, method, params):
- if method == 'net_succ':
- self._onSucc(params)
- elif method == 'net_fail':
- self._onFail(params)
- else:
- pass
- def _onSucc(self, params):
- def parse(input):
- return input['channel_name'], input['time']
- chname, time = parse(params)
- path, pos = self.path_pos(chname, time)
- self.file[path][self._pos_map['succ_count'], pos] += 1
- pass
- def _onFail(self, params):
- def parse(input):
- return input['channel_name'], input['time']
- chname, time = parse(params)
- path, pos = self.path_pos(chname, time)
- self.file[path][self._pos_map['fail_count'], pos] += 1
- pass
- def path_pos(self, chname, time):
- today = day_stamp(time)
- path = f'/{self._version}/{today}/{chname}'
- hfive = self.file
- if path not in hfive:
- dim = len(self._pos_map)
- hfive[path] = np.zeros((dim, 86400))
- return path, time - today
- pass
|