|
@@ -70,7 +70,7 @@ if cython:
|
|
|
import cy.ArtNetProcessor_cy as cy
|
|
|
|
|
|
from collections import OrderedDict
|
|
|
-
|
|
|
+from datetime import datetime
|
|
|
#print(dir())
|
|
|
#input()
|
|
|
# ============================================================
|
|
@@ -122,11 +122,12 @@ def update_mc_artpoll_index(key,val=""):
|
|
|
if type(_index) is type(None):
|
|
|
_index = {}
|
|
|
#print("A",_index)
|
|
|
-
|
|
|
+ #now = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
|
|
|
+ now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
|
|
if key not in _index:
|
|
|
_index[key] = [0,""]
|
|
|
_index[key][0] += 1
|
|
|
- _index[key][1] = val
|
|
|
+ _index[key][1] = now #val
|
|
|
|
|
|
mc.set(INDEX ,_index)
|
|
|
except Exception as e:
|
|
@@ -743,7 +744,48 @@ def ArtPollCheck(data,addr):
|
|
|
update_mc_artpoll_index(k,val="")
|
|
|
except Exception as e:
|
|
|
print("ArtPollCheck err:",e)
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+if mc:
|
|
|
+ mc.set("artnet-pkg-count" ,{})
|
|
|
+class PKG_COUNT():
|
|
|
+ def __init__(self,name="PKG_COUNT"):
|
|
|
+ self.time = 0
|
|
|
+ self.fps = 0
|
|
|
+ self._count = 0
|
|
|
+ self.fps_hitory = [0]*10
|
|
|
+ self.fps_count = 0
|
|
|
+ self.name = name
|
|
|
+ self.start = time.time()
|
|
|
+ def count(self):
|
|
|
+ self.fps_count += 1
|
|
|
+ def check(self):
|
|
|
+ if time.time()-self.time > 10:
|
|
|
+ self.reset()
|
|
|
+ return True
|
|
|
+ def reset(self,t=None):
|
|
|
+ if t is None:
|
|
|
+ self.time = time.time()
|
|
|
+ else:
|
|
|
+ self.time = t
|
|
|
+ #print("reset",self.name, self.time)
|
|
|
+ def info(self):
|
|
|
+ self.fps = self.fps_count/10
|
|
|
+ self.fps_count = 0
|
|
|
+ #run_time=int((time.time()-self.start)/60)
|
|
|
+ self.fps_hitory = self.fps_hitory[1:]
|
|
|
+ self.fps_hitory.append(self.fps)
|
|
|
+ self._count += 1
|
|
|
+ return {self.name+"-fps":self.fps,self.name+"-hist":self.fps_hitory,self.name+"-count":self._count}
|
|
|
+ def update_mc(self):
|
|
|
+ data = {}
|
|
|
+ x =mc.get("artnet-pkg-count")
|
|
|
+ if x:
|
|
|
+ data.update(x)
|
|
|
+ data.update(self.info())
|
|
|
+ mc.set("artnet-pkg-count" ,data)
|
|
|
+
|
|
|
+
|
|
|
class IN_Socket():
|
|
|
def __init__(self,bind='',port=6454):
|
|
|
self.__port =port
|
|
@@ -755,10 +797,8 @@ class IN_Socket():
|
|
|
self.__hosts = {}
|
|
|
self.hosts = self.__hosts
|
|
|
self.open()
|
|
|
- self.pkg_time = time.time()
|
|
|
self.start = time.time()
|
|
|
- self.pkg_fps = 0
|
|
|
- self.pkg_fps_count = 0
|
|
|
+ self.pkg_in_count = PKG_COUNT(name="in")
|
|
|
def open(self):
|
|
|
try:
|
|
|
print("connecting to ArtNet bind:",self.__bind,"Port",self.__port)
|
|
@@ -777,17 +817,14 @@ class IN_Socket():
|
|
|
def poll(self):
|
|
|
if not self.__poll:
|
|
|
if mc:
|
|
|
- if time.time()-self.pkg_time > 1:
|
|
|
- self.pkg_time = time.time()
|
|
|
- self.pkg_fps = self.pkg_fps_count/1
|
|
|
- self.pkg_fps_count = 0
|
|
|
- run_time=int((time.time()-self.start)/60)
|
|
|
- mc.set("artnet-pkg-count" , {"ArtDMX-fps":self.pkg_fps,"min":run_time})
|
|
|
+ if self.pkg_in_count.check():
|
|
|
+ self.pkg_in_count.reset()
|
|
|
+ self.pkg_in_count.update_mc()
|
|
|
|
|
|
try:
|
|
|
self.__data, self.__addr = self.sock.recvfrom(self.__port)
|
|
|
data, addr = (self.__data,self.__addr)
|
|
|
- self.pkg_fps_count += 1
|
|
|
+ self.pkg_in_count.count()
|
|
|
|
|
|
ArtPollCheck(data,addr)
|
|
|
|
|
@@ -893,6 +930,8 @@ class ArtNetNode():
|
|
|
self.dmx=[33]*512
|
|
|
self.v=0
|
|
|
self.d=1
|
|
|
+ #self.pkg_out_count = PKG_COUNT(name="out-"+str(univ))
|
|
|
+ self.pkg_counter = {}
|
|
|
|
|
|
def head(self):
|
|
|
self._header = []
|
|
@@ -935,6 +974,19 @@ class ArtNetNode():
|
|
|
self.s.sendto(c, (self.sendto, port)) # default 6454
|
|
|
else:
|
|
|
self.s.sendto(c, (self.sendto, self.portto)) # default 6454
|
|
|
+
|
|
|
+ # multicounter management !
|
|
|
+ name = "out-"+str(self.univ)
|
|
|
+ if name not in self.pkg_counter:
|
|
|
+ self.pkg_counter[name] = PKG_COUNT(name=name)
|
|
|
+
|
|
|
+ counter = self.pkg_counter[name]
|
|
|
+ counter.count()
|
|
|
+ if mc:
|
|
|
+ if counter.check():
|
|
|
+ counter.reset()
|
|
|
+ counter.update_mc()
|
|
|
+
|
|
|
return c
|
|
|
def _test_frame(self):
|
|
|
if self.test_stamp+0.1 > time.time():
|
|
@@ -1165,7 +1217,7 @@ class Main():
|
|
|
|
|
|
if not poll_flag:
|
|
|
time.sleep(.001)
|
|
|
- #screen.loop()
|
|
|
+ screen.loop()
|
|
|
finally:
|
|
|
pass
|
|
|
#screen.exit()
|