From 959acd4e3e318c3bbe09e6f57ef25c8d1be209db Mon Sep 17 00:00:00 2001 From: tzim Date: Mon, 18 May 2015 15:44:22 +0000 Subject: [PATCH] Modif telecommande pour multi-circuit --- DMX-2.0/Conduite.cs | 25 +++++++++---------- DMX-2.0/EditionUnivers.cs | 9 ++++--- DMX-2.0/OSCServer.cs | 48 ++++++++++++++++++++++++++++--------- DMX-2.0/SequenceurMaitre.cs | 2 +- DMX-2.0/UniversDMX.cs | 19 ++++++++++----- 5 files changed, 70 insertions(+), 33 deletions(-) diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index b97ed75..f57b240 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -229,16 +229,16 @@ namespace DMX2 } } - Circuit circuitTelecomande=null; + List circuitTelecomande=new List(); int circuitTelecomandeVal=0; - public Circuit CircuitTelecomande { + public List CircuitTelecomande { get { return circuitTelecomande; } - set { + /*set { circuitTelecomande = value; - } + }*/ } public int CircuitTelecomandeVal { @@ -311,8 +311,6 @@ namespace DMX2 else if(master != 100){ foreach (var c in circuits) { int val = 0; - if(circuitTelecomande==c) - val = circuitTelecomandeVal; foreach (var seq in sequenceurs) { val = Math.Max (val, seq.ValeurCircuit (c)); } @@ -321,16 +319,19 @@ namespace DMX2 } else { foreach (var c in circuits) { int val = 0; - if(circuitTelecomande==c) - val = circuitTelecomandeVal; - //else - foreach (var seq in sequenceurs) { - val = Math.Max (val, seq.ValeurCircuit (c)); - } + foreach (var seq in sequenceurs) { + val = Math.Max (val, seq.ValeurCircuit (c)); + } c.ValeurCourante = val; } } + if (circuitTelecomande.Count > 0) { + foreach (Circuit c in circuitTelecomande) { + c.ValeurCourante = circuitTelecomandeVal * master / 100; + } + } + EventManager.ProcessEvents(); } } diff --git a/DMX-2.0/EditionUnivers.cs b/DMX-2.0/EditionUnivers.cs index d206772..588085d 100644 --- a/DMX-2.0/EditionUnivers.cs +++ b/DMX-2.0/EditionUnivers.cs @@ -58,7 +58,7 @@ namespace DMX2 void HandleDestroyed (object sender, EventArgs e) { - universEdite.AllumageForce = -1; + universEdite.AllumageForce.Clear(); } void RenderUniversName (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) @@ -246,7 +246,7 @@ namespace DMX2 majencour = true; int id = (int)(spinDimmer.Value); - universEdite.AllumageForce = -1; + universEdite.AllumageForce.Clear(); btAllume.Active = false; currDimm = id - 1; @@ -418,7 +418,10 @@ namespace DMX2 { if (majencour) return; - universEdite.AllumageForce = btAllume.Active?currDimm:-1; + if(btAllume.Active) + universEdite.AllumageForce.Add(currDimm); + else + universEdite.AllumageForce.Clear(); universEdite.AllumageForceVal = 255; } protected void OnTxtParam1Changed (object sender, EventArgs e) diff --git a/DMX-2.0/OSCServer.cs b/DMX-2.0/OSCServer.cs index 7f74fc2..d831ad9 100644 --- a/DMX-2.0/OSCServer.cs +++ b/DMX-2.0/OSCServer.cs @@ -321,7 +321,9 @@ namespace DMX2 Console.WriteLine(msg.Address); foreach(var arg in msg.Args) Console.WriteLine(arg.GetString()); - ProcessMessage(msg,remep); + try{ + ProcessMessage(msg,remep); + }catch{} } } catch (SocketException ex) { } @@ -495,10 +497,17 @@ namespace DMX2 int dimId; if(!int.TryParse(toks[3],out dimId))return; if( msg.Args[0].GetInt() !=0) - univ.AllumageForce = dimId; + if(!univ.AllumageForce.Contains(dimId)) + univ.AllumageForce.Add(dimId); break; case "off": - univ.AllumageForce = -1; + if(!int.TryParse(toks[3],out dimId))return; + //if( msg.Args[0].GetInt() !=0) + if(univ.AllumageForce.Contains(dimId)) + univ.AllumageForce.Remove(dimId); + break; + case "alloff": + univ.AllumageForce.Clear(); break; case "onval": int val = msg.Args[0].GetInt(); @@ -513,18 +522,35 @@ namespace DMX2 { switch (toks [1]) { case "on": - int cirId; - if(!int.TryParse(toks[2],out cirId))return; - if( msg.Args[0].GetInt() !=0){ - if(cirId>0 && cirId <= Conduite.Courante.Circuits.Count) - { - Conduite.Courante.CircuitTelecomande = - Conduite.Courante.Circuits[cirId-1]; + { + int cirId; + if (!int.TryParse (toks [2], out cirId)) + return; + if (msg.Args [0].GetInt () != 0) { + if (cirId > 0 && cirId <= Conduite.Courante.Circuits.Count) { + Circuit c = Conduite.Courante.Circuits [cirId - 1]; + if (!Conduite.Courante.CircuitTelecomande.Contains (c)) + Conduite.Courante.CircuitTelecomande.Add (c); + } } } break; case "off": - Conduite.Courante.CircuitTelecomande= null; + { + int cirId; + if (!int.TryParse (toks [2], out cirId)) + return; + //if (msg.Args [0].GetInt () != 0) { + if (cirId > 0 && cirId <= Conduite.Courante.Circuits.Count) { + Circuit c = Conduite.Courante.Circuits [cirId - 1]; + if (Conduite.Courante.CircuitTelecomande.Contains (c)) + Conduite.Courante.CircuitTelecomande.Remove (c); + } + //} + } + break; + case "alloff": + Conduite.Courante.CircuitTelecomande.Clear(); break; case "onval": int val = msg.Args[0].GetInt(); diff --git a/DMX-2.0/SequenceurMaitre.cs b/DMX-2.0/SequenceurMaitre.cs index f7ab20e..81810b7 100644 --- a/DMX-2.0/SequenceurMaitre.cs +++ b/DMX-2.0/SequenceurMaitre.cs @@ -136,7 +136,7 @@ namespace DMX2 public void EffetSuivant () { lock (this) { - Conduite.Courante.CircuitTelecomande = null; + Conduite.Courante.CircuitTelecomande.Clear(); if(lignes.Count==0) return; if (aSuivre == null) { if (IndexLigneEnCours + 1 < lignes.Count) diff --git a/DMX-2.0/UniversDMX.cs b/DMX-2.0/UniversDMX.cs index ebe3438..51b01e4 100644 --- a/DMX-2.0/UniversDMX.cs +++ b/DMX-2.0/UniversDMX.cs @@ -56,15 +56,17 @@ namespace DMX2 Dimmer[] _dimmers = new Dimmer[512]; - int allumageForce = -1; + // int allumageForce = -1; - public int AllumageForce { + List allumageForce = new List(); + + public List AllumageForce { get { return allumageForce; } - set { + /*set { allumageForce = value; - } + }*/ } int allumageForceVal= 255; @@ -103,10 +105,10 @@ namespace DMX2 Debug.Assert(valeurs.Length == _dimmers.Length); for(int i = 0 ; i 0) { + foreach (int af in allumageForce) { + valeurs[af+offset] = (byte)allumageForceVal; + } + } } public void Save (XmlElement parent)