Empechement des sauts sur les masters
This commit is contained in:
parent
7193d20876
commit
3a63307fba
3 changed files with 67 additions and 6 deletions
|
|
@ -48,7 +48,7 @@ namespace DMX2
|
||||||
readonly SequenceurMaitre seqmaitre = new SequenceurMaitre();
|
readonly SequenceurMaitre seqmaitre = new SequenceurMaitre();
|
||||||
|
|
||||||
readonly EventManager eventManager = new EventManager(); // Gestion des fournisseurs d'evenements
|
readonly EventManager eventManager = new EventManager(); // Gestion des fournisseurs d'evenements
|
||||||
actionEventTarget masterEventTarget; // Recepteur d'evenements pour le master
|
actionEventTargetEx masterEventTarget; // Recepteur d'evenements pour le master
|
||||||
|
|
||||||
readonly MidiEventProvider midip=null;
|
readonly MidiEventProvider midip=null;
|
||||||
|
|
||||||
|
|
@ -79,11 +79,15 @@ namespace DMX2
|
||||||
// La conduite peux recevoir des evenements midi
|
// La conduite peux recevoir des evenements midi
|
||||||
midip = new MidiEventProvider (eventManager);
|
midip = new MidiEventProvider (eventManager);
|
||||||
|
|
||||||
masterEventTarget = new actionEventTarget (
|
masterEventTarget = new actionEventTargetEx (
|
||||||
delegate(EventData data) {
|
delegate(EventData data) {
|
||||||
Master = 100 * data.value / 255;
|
Master = 100 * data.value / 255;
|
||||||
return true;
|
return true;
|
||||||
}
|
},
|
||||||
|
delegate{
|
||||||
|
return master * 255 /100;
|
||||||
|
},
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
if (startthread) StartThread();
|
if (startthread) StartThread();
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,59 @@ namespace DMX2
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cible generique d'evenement.
|
||||||
|
/// </summary>
|
||||||
|
public class actionEventTargetEx : IEventTarget {
|
||||||
|
public delegate bool EventAction (EventData data);
|
||||||
|
public delegate int GetData();
|
||||||
|
EventAction action;
|
||||||
|
GetData getdata;
|
||||||
|
bool canfeedback=false , nofeedback=false;
|
||||||
|
readonly List<IFeedbackInfo> fbInfos = new List<IFeedbackInfo>();
|
||||||
|
|
||||||
|
public actionEventTargetEx(EventAction _action, GetData _getdata,bool feedback)
|
||||||
|
{
|
||||||
|
action=_action;
|
||||||
|
getdata = _getdata;
|
||||||
|
canfeedback = feedback;
|
||||||
|
}
|
||||||
|
#region IEventTarget implementation
|
||||||
|
bool IEventTarget.FireEvent (EventData data)
|
||||||
|
{
|
||||||
|
int val = getdata();
|
||||||
|
|
||||||
|
if (
|
||||||
|
(data.prev_value < val-5 && data.value < val-5) ||
|
||||||
|
(data.prev_value > val+5 && data.value > val+5)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
nofeedback=true;
|
||||||
|
bool res =action(data);
|
||||||
|
nofeedback=false;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FeedBack (byte data)
|
||||||
|
{
|
||||||
|
if (nofeedback)
|
||||||
|
return;
|
||||||
|
foreach (var info in fbInfos) {
|
||||||
|
info.FeedBack(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IEventTarget.Bind (string id){} // Rien a faire ici
|
||||||
|
void IEventTarget.Unbind (string id){}
|
||||||
|
bool IEventTarget.CanFeedback { get { return canfeedback; } }
|
||||||
|
void IEventTarget.AddFeedback (IFeedbackInfo info)
|
||||||
|
{
|
||||||
|
fbInfos.Add(info);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
public class EventManager
|
public class EventManager
|
||||||
{
|
{
|
||||||
Dictionary<string,eventBinding> bindings = new Dictionary<string,eventBinding>();
|
Dictionary<string,eventBinding> bindings = new Dictionary<string,eventBinding>();
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ namespace DMX2
|
||||||
Dictionary<Circuit,bool> valeurschangees = new Dictionary<Circuit, bool> ();
|
Dictionary<Circuit,bool> valeurschangees = new Dictionary<Circuit, bool> ();
|
||||||
Dictionary<Circuit,circuitEventTarget> targets = new Dictionary<Circuit, circuitEventTarget>();
|
Dictionary<Circuit,circuitEventTarget> targets = new Dictionary<Circuit, circuitEventTarget>();
|
||||||
|
|
||||||
actionEventTarget masterEventTarget=null;
|
actionEventTargetEx masterEventTarget=null;
|
||||||
actionEventTarget goNextEventTarget=null;
|
actionEventTarget goNextEventTarget=null;
|
||||||
actionEventTarget goBackEventTarget=null;
|
actionEventTarget goBackEventTarget=null;
|
||||||
|
|
||||||
|
|
@ -241,11 +241,15 @@ namespace DMX2
|
||||||
{
|
{
|
||||||
effetcourrant = new Effet ("",valeurscourantes , TimeSpan.Zero, TimeSpan.Zero);
|
effetcourrant = new Effet ("",valeurscourantes , TimeSpan.Zero, TimeSpan.Zero);
|
||||||
|
|
||||||
masterEventTarget = new actionEventTarget (
|
masterEventTarget = new actionEventTargetEx (
|
||||||
delegate(EventData data) {
|
delegate(EventData data) {
|
||||||
Master = 100 * data.value / 255;
|
Master = 100 * data.value / 255;
|
||||||
return true;
|
return true;
|
||||||
}
|
},
|
||||||
|
delegate{
|
||||||
|
return Master * 255 /100;
|
||||||
|
},
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
goNextEventTarget = new actionEventTarget (
|
goNextEventTarget = new actionEventTarget (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue