diff --git a/DMX-2.0.userprefs b/DMX-2.0.userprefs index 1060ad9..130e36c 100644 --- a/DMX-2.0.userprefs +++ b/DMX-2.0.userprefs @@ -1,12 +1,13 @@  - + - - - - + + + + + diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index 4ff1739..be7828b 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -13,11 +13,13 @@ namespace DMX2 public static Conduite Courante = null; Timer timer = null; + DateTime lastTick; public Conduite() { timer = new Timer(new TimerCallback(TimerTick),this, - 100,100); + 10,10); + lastTick=DateTime.Now; } List circuits = new List(); @@ -103,14 +105,30 @@ namespace DMX2 void Tick () { - foreach (var c in Circuits) { + DateTime tickTime = DateTime.Now; + TimeSpan ts = tickTime-lastTick; + lastTick = tickTime; + + // 'Actionne' les sequenceurs + foreach (var seq in sequenceurs) { + seq.Tick(ts); + } + + // Mets a jour les valeurs circuits. + foreach (var c in circuits) { int val=0; foreach (var seq in Sequenceurs) { val = Math.Max(val, seq.ValeurCircuit(c)); } c.ValeurCourante=val; } + + // Cette fonction retourne quasi immédiatement, même si il y'a beaucoup a faire sur l'affichage MainWindow.Win.ScheduleUpdate(); + + + /*if( DateTime.Now - tickTime > TimeSpan.FromMilliseconds(1) ) + Console.WriteLine ("{0} {1}", DateTime.Now - tickTime,ts);*/ } #region IDisposable implementation diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index e5607a7..ba88d84 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -1,6 +1,7 @@ using System; using Gtk; using System.Collections.Generic; +using System.Diagnostics; namespace DMX2 @@ -8,6 +9,8 @@ namespace DMX2 public partial class MainWindow: Gtk.Window { static MainWindow win; + static object circuitKey = new object(); + public static MainWindow Win { get { return win; } } @@ -33,24 +36,25 @@ namespace DMX2 } - protected void MajCircuits () + protected void MajCircuits (bool full) { // Ajoute une ProgressBar par circuit, met a jour le texte si necessaire - if (vboxCircuits.Children.Length != Conduite.Courante.Circuits.Count) { + ProgressBar pb;int i = 0; + if (full) { foreach (var widget in vboxCircuits.Children) vboxCircuits.Remove (widget); foreach (var circuit in Conduite.Courante.Circuits) { - vboxCircuits.PackStart (new ProgressBar (),false,false,0); + vboxCircuits.PackStart (pb=new ProgressBar (),false,false,0); + pb.Text = (++i).ToString() + " - " + circuit.Name; + pb.HeightRequest = 22; + pb.Data[circuitKey] = circuit; } vboxCircuits.ShowAll (); } - int i = 0; + foreach (var widget in vboxCircuits.Children) { - var c = Conduite.Courante.Circuits[i++]; - ProgressBar pb = (ProgressBar)widget; - pb.Text = i.ToString() + " - " + c.Name; - pb.Fraction = (double) c.ValeurCourante / 255; - pb.HeightRequest = 22; + pb = (ProgressBar)widget; + pb.Fraction = (double) (pb.Data[circuitKey] as Circuit).ValeurCourante / 255; } } @@ -69,7 +73,7 @@ namespace DMX2 GestionCircuits gc= new GestionCircuits(this); gc.Run(); gc.Destroy(); - MajCircuits(); + NextUpdateFull(); } protected void OnNewActionActivated (object sender, EventArgs e) @@ -108,19 +112,32 @@ namespace DMX2 bool updScheduled=false; + bool fullUpdateFlag=false; + + public void NextUpdateFull () + { + fullUpdateFlag=true; + } + + public void ScheduleUpdate () { - if(updScheduled) return; + if (updScheduled) { + //Console.WriteLine("{0} Skip !",DateTime.Now); + return; + } updScheduled=true; Gtk.Application.Invoke(new EventHandler(Update)); + } void Update (object sender, EventArgs e) { foreach (var sequi in seqUiVbox.Children) { - (sequi as SequenceurUI).Update(); + (sequi as SequenceurUI).Update(fullUpdateFlag); } - MajCircuits(); + MajCircuits(fullUpdateFlag); + fullUpdateFlag=false; updScheduled=false; } } diff --git a/DMX-2.0/SeqLinUI.cs b/DMX-2.0/SeqLinUI.cs index e425fc7..7184c78 100644 --- a/DMX-2.0/SeqLinUI.cs +++ b/DMX-2.0/SeqLinUI.cs @@ -16,13 +16,14 @@ namespace DMX2 this.Build (); titreLabel.Text = s.Name; sequenceur = s; - Update(); + Update(true); } - public override void Update () + public override void Update (bool full) { - if(fullUpdFlag) FullUpdate(); + if(fullUpdFlag || full) FullUpdate(); UpdateValues(); + timeLabel.LabelProp = sequenceur.TimeStamp.ToString(); } protected void OnCircuitsActionActivated (object sender, EventArgs e) @@ -32,9 +33,7 @@ namespace DMX2 sequenceur.ChangeCircuits(dlg.GetResultList()); } dlg.Destroy(); - - //TODO : a retirer plus tard - FullUpdate(); + fullUpdFlag = true; } protected void OnCloseActionActivated (object sender, EventArgs e) @@ -52,7 +51,7 @@ namespace DMX2 tirette.HeightRequest = 150; tirette.CanFocus = true; tirette.Inverted = true; - tirette.Adjustment.Upper = 100; + tirette.Adjustment.Upper = 255; tirette.Adjustment.PageIncrement = 10; tirette.Adjustment.StepIncrement = 1; tirette.DrawValue = true; diff --git a/DMX-2.0/SequenceurLineaire.cs b/DMX-2.0/SequenceurLineaire.cs index c684665..670fded 100644 --- a/DMX-2.0/SequenceurLineaire.cs +++ b/DMX-2.0/SequenceurLineaire.cs @@ -70,6 +70,7 @@ namespace DMX2 public SequenceurLineaire () { + effetcourrant = new Effet ("",valeurscourantes , TimeSpan.Zero, TimeSpan.Zero); } public SequenceurLineaire (int id) :base (id) @@ -163,7 +164,7 @@ namespace DMX2 FinDeTransition (); } } - if (timeStamp >= effetcourrant.Duree) { + if (effetcourrant.Duree != TimeSpan.Zero && timeStamp >= effetcourrant.Duree) { int index = effets.IndexOf (effetcourrant) + 1; if (index < effets.Count) ChangeEffet (index); diff --git a/DMX-2.0/SequenceurUI.cs b/DMX-2.0/SequenceurUI.cs index 5412d37..7147792 100644 --- a/DMX-2.0/SequenceurUI.cs +++ b/DMX-2.0/SequenceurUI.cs @@ -17,7 +17,7 @@ namespace DMX2 } } - public abstract void Update(); + public abstract void Update(bool full); } } diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index d3f6de2..0078bfe 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -630,7 +630,7 @@ - + 33 <big>0.00</big>