From ed53f248c2e119e3d4979c4dff51c1884d891628 Mon Sep 17 00:00:00 2001 From: tzim Date: Thu, 11 Dec 2014 16:28:06 +0000 Subject: [PATCH] modif OSC --- DMX-2.0/DMX-2.0.csproj | 4 ++ DMX-2.0/OSCServer.cs | 145 ++++++++++++++++++++++++++++++++++++++--- DMX-2.0/html/if.js | 47 +++++++++++++ 3 files changed, 188 insertions(+), 8 deletions(-) create mode 100644 DMX-2.0/html/if.js diff --git a/DMX-2.0/DMX-2.0.csproj b/DMX-2.0/DMX-2.0.csproj index 4b83913..8d79d64 100644 --- a/DMX-2.0/DMX-2.0.csproj +++ b/DMX-2.0/DMX-2.0.csproj @@ -54,6 +54,7 @@ False gstreamer-sharp-0.10 + @@ -116,6 +117,9 @@ css.theme.images.ui-bg_glass_65_ffffff_1x400.png + + if.js + diff --git a/DMX-2.0/OSCServer.cs b/DMX-2.0/OSCServer.cs index 44f9f28..e5e4c06 100644 --- a/DMX-2.0/OSCServer.cs +++ b/DMX-2.0/OSCServer.cs @@ -217,32 +217,161 @@ namespace DMX2 /// - /// /master + /// /master void ProcessMessage (OSCMessage msg) { - + if(Conduite.Courante == null) return; + string[] toks = msg.Address.Split (new char[]{'/'},StringSplitOptions.RemoveEmptyEntries); + int arg; + switch (toks [0]) { + case "master": + arg = msg.Args[0].GetInt(); + if(arg>=0 && arg<=100) + Conduite.Courante.Master = arg; + break; + case "masterseq": + switch(toks[1]){ + case "go": + if( msg.Args[0].GetInt() !=0) + Conduite.Courante.SequenceurMaitre.EffetSuivant(); + break; + case "goback": + if( msg.Args[0].GetInt() !=0) + Conduite.Courante.SequenceurMaitre.EffetPrecedent(); + break; + case "next": + arg = msg.Args[0].GetInt(); + Conduite.Courante.SequenceurMaitre.IndexLigneaSuivre = arg; + break; + case "goto": + arg = msg.Args[0].GetInt(); + Conduite.Courante.SequenceurMaitre.IndexLigneaSuivre = arg; + Conduite.Courante.SequenceurMaitre.EffetSuivant(); + break; + } + break; + case "seq": + ProcessMessageSeq(msg,toks); + break; + case "universe": + ProcessMessageUniv(msg,toks); + break; + } } + void ProcessMessageSeq (OSCMessage msg, string[] toks) + { + int seqId; + Sequenceur seq = null; + if (int.TryParse (toks [1], out seqId)) { + if (seqId < 0 || seqId > Conduite.Courante.Sequenceurs.Count) + return; + seq = Conduite.Courante.Sequenceurs [seqId-1]; + } + if (seq is SequenceurLineaire) { + SequenceurLineaire seql = seq as SequenceurLineaire; + switch(toks[2]){ + case "go": + if( msg.Args[0].GetInt() !=0) + seql.IndexEffetCourrant++; + break; + case "goback": + if( msg.Args[0].GetInt() !=0) + seql.IndexEffetCourrant--; + break; + case "goto": + int arg = msg.Args[0].GetInt(); + seql.IndexEffetCourrant = arg; + break; + case "master": + arg = msg.Args[0].GetInt(); + if(arg>=0 && arg<=100) + seql.Master = arg; + break; + case "circuit": + int cirId; + arg = msg.Args[0].GetInt(); + arg = Math.Max(0,arg); + arg = Math.Min(255,arg); + if(!int.TryParse(toks[3],out cirId)) return; + Circuit c = Conduite.Courante.GetCircuitByID (cirId); + if(seql.Circuits.Contains(c)) + seql.ChangeValeur(c,arg); + break; + } + } + if (seq is SequenceurMacro) { + SequenceurMacro seqm = seq as SequenceurMacro; + switch(toks[2]){ + case "go": + if( msg.Args[0].GetInt() !=0) + seqm.LigneSuivante(); + break; + case "goto": + int arg = msg.Args[0].GetInt(); + seqm.IndexLigneaSuivre = arg; + seqm.LigneSuivante(); + break; + case "next": + arg = msg.Args[0].GetInt(); + seqm.IndexLigneaSuivre = arg; + break; + case "master": + arg = msg.Args[0].GetInt(); + if(arg>=0 && arg<=100) + seqm.Master = arg; + break; + } + } + } + + void ProcessMessageUniv (OSCMessage msg, string[] toks) + { + int univId; + if (!int.TryParse (toks [1], out univId)) + return; + if (univId > 0 || univId >= Conduite.Courante.Patches.Count) + return; + UniversDMX univ = Conduite.Courante.Patches [univId]; + + switch (toks [2]) { + case "on": + int dimId; + if(!int.TryParse(toks[3],out dimId))return; + if( msg.Args[0].GetInt() !=0) + univ.AllumageForce = dimId; + break; + case "off": + univ.AllumageForce = -1; + break; + case "onval": + int val = msg.Args[0].GetInt(); + if(val>=0 && val<=255) + univ.AllumageForceVal = val; + break; + } + } #region IDisposable implementation diff --git a/DMX-2.0/html/if.js b/DMX-2.0/html/if.js new file mode 100644 index 0000000..f6b2d3e --- /dev/null +++ b/DMX-2.0/html/if.js @@ -0,0 +1,47 @@ +loadedInterfaceName = "Loupiottes"; + +interfaceOrientation = "landscape"; + +pages = [[ +{ + "name": "refresh", + "type": "Button", + "bounds": [.6, .9, .2, .1], + "startingValue": 0, + "isLocal": true, + "mode": "contact", + "ontouchstart": "interfaceManager.refreshInterface()", + "stroke": "#aaa", + "label": "refrsh", +}, + +{ + "name":"master", + "type":"Slider", + "bounds": [.05, .1, .1, .8], + "isVertical" : true, + "address" : "/master", + "min":0,"max":101, +}, + +{ + "name":"masters1", + "type":"Slider", + "bounds": [.20, .1, .1, .8], + "isVertical" : true, + "address" : "/seq/1/master", + "min":0,"max":101, +}, + +{ + "name":"ml1", + "type":"MultiSlider", + "bounds": [.30, .1, .5, .8], + "isVertical" : true, + "address" : "/seq/1/circuit", + "min":0,"max":256, + "numberOfSliders" : 10, +}, +] + +];