stanley-king před 4 roky
rodič
revize
9bcbbfb786
3 změnil soubory, kde provedl 11 přidání a 10 odebrání
  1. 8 9
      plot/DataCenter.py
  2. 1 0
      plot/app.py
  3. 2 1
      plot/thdf5.py

+ 8 - 9
plot/DataCenter.py

@@ -185,7 +185,6 @@ class DataCenter(object):
                 data = np.array(data)
                 predata = predata + data
                 self._draw_plot(ax, x, day_stamp, start_pos, end_pos, data, interval, path)
-                logger.info("path=%s", path)
 
             self._draw_plot(ax, x, day_stamp, start_pos, end_pos, predata, interval, filer_text)
 
@@ -268,9 +267,8 @@ class DataCenter(object):
         return filer_text, paths
 
     def _draw_plot(self, ax, x, day_stamp, start_pos, end_pos, data, interval=300, path=''):
-        import matplotlib.dates as mdate
         # 'commit-succ': 0, 'commit-fail': 1, 'notify-succ': 2, 'notify-fail': 3, 'user_succ': 4
-
+        logging.getLogger('app').debug("path=%s", path)
         all = data[2] + data[3]
         all = all.reshape((-1, interval))
         all = np.sum(all, axis=1)
@@ -293,7 +291,8 @@ class DataCenter(object):
             ySucc = ySucc[pos]
 
         opened = np.where(ySucc > 0)
-        if len(opened) == 0:
+        if len(opened[0]) == 0:
+            logging.getLogger('app').debug("path=%s,opened=False", path)
             return False
 
         xs = np.array([stime.strftime('%H:%M', stime.localtime(d + day_stamp)) for d in x])
@@ -308,15 +307,15 @@ class DataCenter(object):
             (_, _sday, _chname, _quality, _card_type, _amount) = items
             card_type = ''
             if _card_type == '1':
-                card_type = 'sy'
+                card_type = 'SY'
             elif _card_type == '2':
-                card_type = 'sh'
+                card_type = 'SH'
             elif _card_type == '4':
-                card_type = 'yd'
+                card_type = 'YD'
             elif _card_type == '5':
-                card_type = 'lt'
+                card_type = 'LT'
             elif _card_type == '6':
-                card_type = 'dianxin'
+                card_type = 'DX'
             return f"{_chname}-{_quality}-{card_type}-{_amount}"
         else:
             return path

+ 1 - 0
plot/app.py

@@ -55,6 +55,7 @@ def index():
 @app.route('/plot/days')
 def days():
     dates = dataCenter.days()
+    dates = dates[0:30]
     dates.reverse()
     return jsonify(dates)
 

+ 2 - 1
plot/thdf5.py

@@ -56,11 +56,12 @@ class DataTest(unittest.TestCase):
 
     def test_days(self):
         days = dataCenter.days()
+        days = days[0:30]
         result = json.dumps(days)
         print(days)
 
     def test_data(self):
-        buf = dataCenter.draw_plot(1619020800)
+        buf = dataCenter.draw_plot(start_time=1619078400, interval= 1800,card_type=4)
         img = Image.open(buf)
         img.show()