stanley-king 2 jaren geleden
bovenliggende
commit
47911c224a

+ 1 - 1
helper/refill/policy/chctlex.php

@@ -338,7 +338,7 @@ class chctlex
             $ender = [];
             foreach ($ctls as $item)
             {
-                if($item->notify_time() > $left_time) {
+                if($item->notify_time() > $left_time + 60) {
                     $header[] = $item;
                 } else {
                     $ender[] = $item;

+ 8 - 1
plot/refill/ChannelReader.py

@@ -117,7 +117,14 @@ class ChannelReader(DataReadStream):
 
         hfive = self.file
         if path in hfive:
-            return hfive[path]
+            dset = hfive[path]
+            if dset.shape[0] == pos_map.dim():
+                return dset
+            else:
+                dim = pos_map.dim()
+                result = np.zeros((dim, 86400))
+                result[0:dset.shape[0], :] = dset[:, :]
+                return result
         else:
             return None
     pass

+ 16 - 6
plot/refill/ChannelWriter.py

@@ -6,8 +6,10 @@ import numpy as np
 __all__ = ['ChannelWriter']
 
 import logging
+
 log = logging.getLogger('writer')
 
+
 class ChannelWriter(DataWriteStream):
     def __init__(self, hfive):
         DataWriteStream.__init__(self, hfive)
@@ -37,10 +39,13 @@ class ChannelWriter(DataWriteStream):
     def _write_batch(self, path, messages):
         def _commit(input):
             return input['time'], input['channel_amount']
+
         def _succ(input):
             return input['time'], input['channel_amount'], input['period']
+
         def _fail(input):
             return input['time'], input['channel_amount'], input['period']
+
         def _pos(time):
             today = day_stamp(time)
             return time - today
@@ -83,13 +88,17 @@ class ChannelWriter(DataWriteStream):
 
     def _onSucc(self, params):
         def parse(input):
-            return input['channel_name'], input['time'], input['spec'], input['card_type'], input['channel_amount'], input['period']
+            mch_amount = 0 if 'mch_amount' not in input else input['mch_amount']
+            return input['channel_name'], input['time'], input['spec'], input['card_type'], input['channel_amount'], input['period'], mch_amount
 
-        chname, time, spec, card_type, channel_amount, period = parse(params)
+        chname, time, spec, card_type, channel_amount, period, mch_amount = parse(params)
         dset, pos = self.path_pos(chname, time, spec, card_type)
-
-        rows = [pos_map.succ_count, pos_map.succ_amounts, pos_map.succ_periods]
-        vals = [1, channel_amount, period]
+        if dset.shape[0] == pos_map.dim():
+            rows = [pos_map.succ_count, pos_map.succ_amounts, pos_map.succ_periods, pos_map.succ_mch_amounts]
+            vals = [1, channel_amount, period, mch_amount]
+        else:
+            rows = [pos_map.succ_count, pos_map.succ_amounts, pos_map.succ_periods]
+            vals = [1, channel_amount, period]
         dset[rows, pos] += vals
         pass
 
@@ -108,13 +117,14 @@ class ChannelWriter(DataWriteStream):
     def get_path(self, method, params):
         def _parse(input):
             return input['channel_name'], input['time'], input['spec'], input['card_type']
+
         def _path(input):
             chname, time, spec, card_type = _parse(input)
             today = day_stamp(time)
             path = f'/{self._version}/{today}/{chname}/{card_type}/{spec}'
             return path
 
-        if method in ['ch_commit','ch_succ','ch_fail']:
+        if method in ['ch_commit', 'ch_succ', 'ch_fail']:
             path = _path(params)
             return path
         else:

+ 1 - 1
plot/refill/DataStream.py

@@ -225,7 +225,7 @@ class EChPosmap(IntEnum):
 
     @staticmethod
     def dim():
-        return 8
+        return 9
 
     @staticmethod
     def old_dim():

+ 4 - 11
plot/refill/WriterConsumer.py

@@ -18,18 +18,11 @@ class WriterConsumer(Thread):
         while True:
             size = self._messages.qsize()
             log.debug("%s messages size=%d", self._name, size)
-            # if size < self._max_threshold:
-            #     time.sleep(1)
-            # else:
-            #     self._batch()
-            #
-            # if self._stopped:
+            self._single()
+            # if size > self._max_threshold:
             #     self._batch()
-
-            if size > self._max_threshold:
-                self._batch()
-            else:
-                self._single()
+            # else:
+            #     self._single()
 
             if self._stopped and self._messages.empty():
                 break

+ 4 - 2
plot/testPlot.py

@@ -106,8 +106,10 @@ class MyTestCase(unittest.TestCase):
 
         hfive = open_hdf5('/var/www/html/data/stdata/channel.hdf5', True)
         chwriter = ChannelWriter(hfive)
-        item = {'channel_name':'zero', 'time':time.time(), 'spec':50, 'card_type':4, 'channel_amount':49, 'period':30}
-        chwriter.write('ch_succ',item)
+        itema = {'channel_name':'zero', 'time':int(time.time()), 'spec':50, 'card_type':4, 'channel_amount':49, 'period':30}
+        itemb = {'channel_name':'xxxxxx', 'time':int(time.time()), 'spec':50, 'card_type':4, 'channel_amount':49, 'period':30,'mch_amount':49.625}
+        chwriter.write('ch_succ',itema)
+        chwriter.write('ch_succ',itemb)
 
     def test_netcheck(self):
         from refill import NetchkReader