Plein de trucs

This commit is contained in:
tzim 2013-04-17 15:49:34 +00:00
parent bca2a9ca33
commit b44dbd914d
7 changed files with 66 additions and 30 deletions

View file

@ -1,12 +1,13 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
<MonoDevelop.Ide.Workbench ActiveDocument="DMX-2.0/Conduite.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="DMX-2.0/MainWindow.cs">
<Files>
<File FileName="DMX-2.0/SeqLinUI.cs" Line="127" Column="4" />
<File FileName="DMX-2.0/MainWindow.cs" Line="52" Column="51" />
<File FileName="DMX-2.0/SequenceurLineaire.cs" Line="69" Column="22" />
<File FileName="DMX-2.0/Conduite.cs" Line="20" Column="24" />
<File FileName="DMX-2.0/SeqLinUI.cs" Line="93" Column="16" />
<File FileName="DMX-2.0/SequenceurLineaire.cs" Line="73" Column="50" />
<File FileName="DMX-2.0/Conduite.cs" Line="128" Column="4" />
<File FileName="DMX-2.0/Sequenceur.cs" Line="42" Column="4" />
<File FileName="DMX-2.0/SequenceurUI.cs" Line="20" Column="42" />
<File FileName="DMX-2.0/MainWindow.cs" Line="130" Column="5" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>

View file

@ -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<Circuit> circuits = new List<Circuit>();
@ -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

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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);

View file

@ -17,7 +17,7 @@ namespace DMX2
}
}
public abstract void Update();
public abstract void Update(bool full);
}
}

View file

@ -630,7 +630,7 @@
<widget class="Gtk.VBox" id="vbox4">
<property name="MemberName" />
<child>
<widget class="Gtk.Label" id="label2">
<widget class="Gtk.Label" id="timeLabel">
<property name="MemberName" />
<property name="HeightRequest">33</property>
<property name="LabelProp" translatable="yes">&lt;big&gt;0.00&lt;/big&gt;</property>