Jelajahi Sumber

add: DMX-FINE PAN/TILT ... test ok

micha 2 tahun lalu
induk
melakukan
059045e5b6
2 mengubah file dengan 104 tambahan dan 19 penghapusan
  1. 19 11
      _LibreLightDesk.py
  2. 85 8
      _console.py

+ 19 - 11
_LibreLightDesk.py

@@ -374,18 +374,20 @@ def jclient_send(data):
                 cprint("-----",color="red")
         elif "DMX" in jdata:
             try:
-                # find dmx-fine channel
-                #jdata["DMX-FINE"] = 0
-                fix = jdata["FIX"]
-                attr = jdata["ATTR"]
-                jdata["DMX-FINE"] = FIXTURES.get_dmx(fix,attr+"-FINE")
-                if int(jdata["DMX"]) >= 1: # ignore DMX lower one
-                     jdatas.append(jdata)
+                dmx = int(jdata["DMX"])
+                if int(dmx) >= 1: # ignore DMX lower one
+                    if "FIX" in jdata and "ATTR" in jdata:    
+                        fix = jdata["FIX"]
+                        attr = jdata["ATTR"]
+                        # find dmx-fine channel
+                        jdata["DMX-FINE"] = FIXTURES.get_dmx(fix,attr+"-FINE")
+                    jdatas.append(jdata)
                 else:
-                     cprint("jclient_send, ignore DMX ",jdata["DMX"],color="red")
+                    cprint("jclient_send, ignore DMX ",jdata["DMX"],color="red")
             except Exception as e:
                 cprint("jclient_send, Exception DMX ",color="red")
                 cprint("",jdata,color="red")
+                cprint(e,color="red")
                 cprint("-----",color="red")
             
     jtxt = jdatas
@@ -521,7 +523,7 @@ def reshape_preset(data ,value=None,xfade=0,flash=0,ptfade=0):
     out = []
     delay=0
     for row in data:
-        cprint("reshape_preset",row)
+        cprint("reshape_preset in:",row)
         line = {}
         line["DELAY"]=delay
         if type(value) is float:
@@ -537,6 +539,11 @@ def reshape_preset(data ,value=None,xfade=0,flash=0,ptfade=0):
         if row["FX2"]:
             line["FX2"] = row["FX2"]
 
+        if row["FIX"]:
+            line["FIX"] = row["FIX"]
+        if row["ATTR"]:
+            line["ATTR"] = row["ATTR"]
+
 
         if row["VALUE"] is not None:
             if value is None: 
@@ -564,7 +571,7 @@ def reshape_preset(data ,value=None,xfade=0,flash=0,ptfade=0):
         
         if 0:
             cprint("reshape_preset j",line,color="red") 
-        cprint("reshape_preset",line)
+        cprint("reshape_preset out:",line)
         out.append(line)
         if DELAY._is():
             delay+=DELAY.val()/100 #0.02
@@ -2400,7 +2407,8 @@ class GUI():
             if value == "off":
                 if "FX2" in vcmd:
                     vcmd[i]["FX2"]["TYPE"] = value
-
+            if "FIX" in fcmd:
+                vcmd[i]["FIX"] = fcmd["FIX"]
             if DMX and vcmd[i]:
                 vcmd[i]["DMX"] = DMX
 

+ 85 - 8
_console.py

@@ -356,7 +356,7 @@ class FX():
         return self._exec_id
 
     def _get_info(self):
-        print(self.__offset)
+        #print("self.__offset",self.__offset)
         return {"offset":self.__offset,"xtype":self.__xtype}
         #return self.next(),self.__xtype, self.__size,self.__speed,self.__angel, self.__base,self.__clock_curr,self.run 
     def __str__(self):
@@ -545,6 +545,7 @@ class DMXCH(object):
         self._fx_value = 0
 
         self._dmx = dmx
+        self._dmx_fine = 0
 
         self._flash    = None
         self._flash_fx = None
@@ -564,7 +565,7 @@ class DMXCH(object):
             except Exception as e:
                 print( "Except:fade",e,target,ftime,clock)
         self.next(clock)
-        print("init",self)
+        #print("init fade",self)
 
     def fx(self,xtype="sinus",size=40,speed=40,invert=0,width=100,start=0,offset=0,base="", clock=0,master=None):
         print([self,xtype,size,speed,start,offset,base, clock])
@@ -582,7 +583,7 @@ class DMXCH(object):
             self._fx[1].exec_id(self._exec_id)
 
         self.next(clock)
-        print("init",self)
+        print("init fx",self)
 
     def flash(self,target,ftime=0,clock=0,delay=0):
         if str(target).lower() == "off":
@@ -594,7 +595,7 @@ class DMXCH(object):
             except Exception as e:
                 print( "Except:flash",target,ftime,clock,__name__,e,)
         self.next(clock)
-        print("init",self)
+        #print("init flush",self)
 
     def flash_fx(self,xtype="sinus",size=40,speed=40,invert=0,width=100,start=0,offset=0,base="",clock=0,master=None):
         if str(xtype).lower() == "off":
@@ -605,7 +606,7 @@ class DMXCH(object):
             self._flash_fx = FX(xtype=xtype,size=size,speed=speed,invert=invert,width=width,start=start,offset=offset,base=base,clock=clock,master=master,master_id=0)
             self._flash_fx.exec_id(self._exec_id)
         self.next(clock)
-        print("init",self)
+        #print("init flash_fx",self)
 
     def fx_ctl(self,cmd=""): #start,stop,off
         pass
@@ -618,7 +619,7 @@ class DMXCH(object):
         return self._exec_id
 
     def __repr__(self):
-        return "<BUFFER {} v:{:0.2f} EXEC:{}> fx:[{}] fd:{}".format(self._dmx, self._last_val,self._exec_id,self._fx,self._fade)
+        return "<BUFFER {} {} v:{:0.2f} EXEC:{}> fx:[{}] fd:{}".format(self._dmx,self._dmx_fine, self._last_val,self._exec_id,self._fx,self._fade)
     
     def fade_ctl(self,cmd=""): #start,stop,backw,fwd,bounce
         pass
@@ -807,17 +808,38 @@ class Main():
         xx = [0]*512
         #artnet = self.artnet["0"]
         #artnet.dmx = xx# [:] #dmx #[0]*512
+        ii = 0
         old_univ = -1
+        xx = [0]*512
+        for ii,dmxch in enumerate(Bdmx):
+            i = ii%512
+            univ = ii//512
+            if str(univ) not in self.artnet:
+                print("add uiv",univ)
+                self.artnet[str(univ)] = ANN.ArtNetNode(to="10.10.10.255",univ=univ)
+                #self.artnet[str(univ)].dmx[512-1] = 100+univ
+
+            if univ != old_univ:
+                old_univ = univ
+                #print("UNIV",ii/512)
+                try:
+                    artnet.next()
+                except:pass
+                artnet = self.artnet[str(univ)]
+                artnet.dmx = [0]*512
+
         while 1:
             t = clock.time()
             ii = 0
+            old_univ = -1
+            xx = [0]*512
             for ii,dmxch in enumerate(Bdmx):
                 i = ii%512
                 univ = ii//512
                 if str(univ) not in self.artnet:
                     print("add uiv",univ)
                     self.artnet[str(univ)] = ANN.ArtNetNode(to="10.10.10.255",univ=univ)
-                    self.artnet[str(univ)].dmx[512-1] = 100+univ
+                    #self.artnet[str(univ)].dmx[512-1] = 100+univ
 
                 if univ != old_univ:
                     old_univ = univ
@@ -826,12 +848,63 @@ class Main():
                         artnet.next()
                     except:pass
                     artnet = self.artnet[str(univ)]
-                    artnet.dmx = xx
+                    #artnet.dmx = xx
+
+            old_univ = -1
+            xx = [0]*512
+            for ii,dmxch in enumerate(Bdmx):
+                i = ii%512
+                univ = ii//512
+
+                if univ != old_univ:
+                    old_univ = univ
+                    artnet = self.artnet[str(univ)]
+                    xx = artnet.dmx 
+
                 
                 v = dmxch.next(t)
                 vv = vdmx.by_dmx(clock=i,dmx=ii+1)
                 v = v*vv # disable v-master
+
                 xx[i] = int(v)
+
+            old_univ = -1
+            xx = [0]*512
+            for ii,dmxch in enumerate(Bdmx): #fine loop
+                i = ii%512
+                univ = ii//512
+
+                if univ != old_univ:
+                    artnet = self.artnet[str(univ)]
+                    xx = artnet.dmx# = xx
+                
+                v = dmxch.next(t)
+                vv = vdmx.by_dmx(clock=i,dmx=ii+1)
+                v = v*vv # disable v-master
+
+                #xx[i] = int(v)
+                dmx_fine =  dmxch._dmx_fine
+                if dmx_fine > 0:
+                    vf = int(v%1*255)
+                    #print(dmx_fine,end=" ")
+                    dmx_fine = dmx_fine%512
+                    #print(dmx_fine,end=" ")
+                    #print(int(v),end=" ")
+                    #print(vf,end=" ")
+                    #print()
+                    #univ = ii//512
+                    try:
+                        #xx[dmx_fine+1] = 9# int(v%1*255)
+                        if v >= 255:
+                            xx[dmx_fine-1] = 255
+                        elif v < 0:
+                            xx[dmx_fine-1] = 0
+                        else:
+                            xx[dmx_fine-1] = int(v%1*255)
+                    except Exception as e:
+                        print("E dmx_fine",e,dmx_fine)
+
+
             try:    
                 artnet.next()
             except:pass
@@ -915,6 +988,10 @@ def JCB(data): #json client input
                         delay = x["DELAY"]
                     else:delay=0
 
+                    if "DMX-FINE" in x:
+                        Bdmx[DMX]._dmx_fine = int(x["DMX-FINE"])
+                        #cprint("DMX-FINE",Bdmx[DMX],color="blue") 
+
                     if len(Bdmx) < DMX:
                         continue