Modif telecommande pour multi-circuit

This commit is contained in:
tzim 2015-05-18 15:44:22 +00:00
parent fd61538831
commit 959acd4e3e
5 changed files with 70 additions and 33 deletions

View file

@ -229,16 +229,16 @@ namespace DMX2
} }
} }
Circuit circuitTelecomande=null; List<Circuit> circuitTelecomande=new List<Circuit>();
int circuitTelecomandeVal=0; int circuitTelecomandeVal=0;
public Circuit CircuitTelecomande { public List<Circuit> CircuitTelecomande {
get { get {
return circuitTelecomande; return circuitTelecomande;
} }
set { /*set {
circuitTelecomande = value; circuitTelecomande = value;
} }*/
} }
public int CircuitTelecomandeVal { public int CircuitTelecomandeVal {
@ -311,8 +311,6 @@ namespace DMX2
else if(master != 100){ else if(master != 100){
foreach (var c in circuits) { foreach (var c in circuits) {
int val = 0; int val = 0;
if(circuitTelecomande==c)
val = circuitTelecomandeVal;
foreach (var seq in sequenceurs) { foreach (var seq in sequenceurs) {
val = Math.Max (val, seq.ValeurCircuit (c)); val = Math.Max (val, seq.ValeurCircuit (c));
} }
@ -321,9 +319,6 @@ namespace DMX2
} else { } else {
foreach (var c in circuits) { foreach (var c in circuits) {
int val = 0; int val = 0;
if(circuitTelecomande==c)
val = circuitTelecomandeVal;
//else
foreach (var seq in sequenceurs) { foreach (var seq in sequenceurs) {
val = Math.Max (val, seq.ValeurCircuit (c)); val = Math.Max (val, seq.ValeurCircuit (c));
} }
@ -331,6 +326,12 @@ namespace DMX2
} }
} }
if (circuitTelecomande.Count > 0) {
foreach (Circuit c in circuitTelecomande) {
c.ValeurCourante = circuitTelecomandeVal * master / 100;
}
}
EventManager.ProcessEvents(); EventManager.ProcessEvents();
} }
} }

View file

@ -58,7 +58,7 @@ namespace DMX2
void HandleDestroyed (object sender, EventArgs e) void HandleDestroyed (object sender, EventArgs e)
{ {
universEdite.AllumageForce = -1; universEdite.AllumageForce.Clear();
} }
void RenderUniversName (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) void RenderUniversName (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
@ -246,7 +246,7 @@ namespace DMX2
majencour = true; majencour = true;
int id = (int)(spinDimmer.Value); int id = (int)(spinDimmer.Value);
universEdite.AllumageForce = -1; universEdite.AllumageForce.Clear();
btAllume.Active = false; btAllume.Active = false;
currDimm = id - 1; currDimm = id - 1;
@ -418,7 +418,10 @@ namespace DMX2
{ {
if (majencour) if (majencour)
return; return;
universEdite.AllumageForce = btAllume.Active?currDimm:-1; if(btAllume.Active)
universEdite.AllumageForce.Add(currDimm);
else
universEdite.AllumageForce.Clear();
universEdite.AllumageForceVal = 255; universEdite.AllumageForceVal = 255;
} }
protected void OnTxtParam1Changed (object sender, EventArgs e) protected void OnTxtParam1Changed (object sender, EventArgs e)

View file

@ -321,7 +321,9 @@ namespace DMX2
Console.WriteLine(msg.Address); Console.WriteLine(msg.Address);
foreach(var arg in msg.Args) foreach(var arg in msg.Args)
Console.WriteLine(arg.GetString()); Console.WriteLine(arg.GetString());
try{
ProcessMessage(msg,remep); ProcessMessage(msg,remep);
}catch{}
} }
} catch (SocketException ex) { } catch (SocketException ex) {
} }
@ -495,10 +497,17 @@ namespace DMX2
int dimId; int dimId;
if(!int.TryParse(toks[3],out dimId))return; if(!int.TryParse(toks[3],out dimId))return;
if( msg.Args[0].GetInt() !=0) if( msg.Args[0].GetInt() !=0)
univ.AllumageForce = dimId; if(!univ.AllumageForce.Contains(dimId))
univ.AllumageForce.Add(dimId);
break; break;
case "off": 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; break;
case "onval": case "onval":
int val = msg.Args[0].GetInt(); int val = msg.Args[0].GetInt();
@ -513,18 +522,35 @@ namespace DMX2
{ {
switch (toks [1]) { switch (toks [1]) {
case "on": 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 = int cirId;
Conduite.Courante.Circuits[cirId-1]; 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; break;
case "off": 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; break;
case "onval": case "onval":
int val = msg.Args[0].GetInt(); int val = msg.Args[0].GetInt();

View file

@ -136,7 +136,7 @@ namespace DMX2
public void EffetSuivant () public void EffetSuivant ()
{ {
lock (this) { lock (this) {
Conduite.Courante.CircuitTelecomande = null; Conduite.Courante.CircuitTelecomande.Clear();
if(lignes.Count==0) return; if(lignes.Count==0) return;
if (aSuivre == null) { if (aSuivre == null) {
if (IndexLigneEnCours + 1 < lignes.Count) if (IndexLigneEnCours + 1 < lignes.Count)

View file

@ -56,15 +56,17 @@ namespace DMX2
Dimmer[] _dimmers = new Dimmer[512]; Dimmer[] _dimmers = new Dimmer[512];
int allumageForce = -1; // int allumageForce = -1;
public int AllumageForce { List<int> allumageForce = new List<int>();
public List<int> AllumageForce {
get { get {
return allumageForce; return allumageForce;
} }
set { /*set {
allumageForce = value; allumageForce = value;
} }*/
} }
int allumageForceVal= 255; int allumageForceVal= 255;
@ -103,10 +105,10 @@ namespace DMX2
Debug.Assert(valeurs.Length == _dimmers.Length); Debug.Assert(valeurs.Length == _dimmers.Length);
for(int i = 0 ; i<count; i++) for(int i = 0 ; i<count; i++)
{ {
if(allumageForce==i) { /*if(allumageForce==i) {
valeurs[i+offset] = (byte)allumageForceVal; valeurs[i+offset] = (byte)allumageForceVal;
continue; continue;
} }*/
g= _dimmers[i]; g= _dimmers[i];
if(g.circuitAssocié !=null) { if(g.circuitAssocié !=null) {
@ -132,6 +134,11 @@ namespace DMX2
else else
valeurs[i+offset] = 0; valeurs[i+offset] = 0;
} }
if (allumageForce.Count > 0) {
foreach (int af in allumageForce) {
valeurs[af+offset] = (byte)allumageForceVal;
}
}
} }
public void Save (XmlElement parent) public void Save (XmlElement parent)