This commit is contained in:
parent
313b1df8fa
commit
21023ce2fa
9 changed files with 83 additions and 11 deletions
|
|
@ -298,7 +298,13 @@ namespace DMX2
|
|||
return "Boitier V1";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
IFeedbackInfo IEventProvider.GetFeedbackInfo (string eventId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region implemented abstract members of DMX2.DriverDMX
|
||||
public override void Save (System.Xml.XmlElement parent)
|
||||
|
|
|
|||
|
|
@ -533,6 +533,12 @@ namespace DMX2
|
|||
return "Boitier V2";
|
||||
}
|
||||
}
|
||||
|
||||
IFeedbackInfo IEventProvider.GetFeedbackInfo (string eventId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region implemented abstract members of DMX2.DriverDMX
|
||||
|
|
|
|||
|
|
@ -590,6 +590,12 @@ namespace DMX2
|
|||
return "Boitier V3";
|
||||
}
|
||||
}
|
||||
|
||||
IFeedbackInfo IEventProvider.GetFeedbackInfo (string eventId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region implemented abstract members of DMX2.DriverDMX
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace DMX2
|
|||
/// <param name='callback'>Fonction a appeler pour chaque evenement.</param>
|
||||
void ProcessEvents(EventManagerCallback callback);
|
||||
|
||||
|
||||
IFeedbackInfo GetFeedbackInfo(string eventId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -84,6 +84,13 @@ namespace DMX2
|
|||
/// <param name='id'>l'id de l'evenement</param>
|
||||
void Unbind(string id);
|
||||
|
||||
bool CanFeedback{ get; }
|
||||
void AddFeedback(IFeedbackInfo info);
|
||||
|
||||
}
|
||||
|
||||
public interface IFeedbackInfo {
|
||||
bool FeedBack(byte data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -115,16 +122,19 @@ namespace DMX2
|
|||
|
||||
void IEventTarget.Bind (string id){} // Rien a faire ici
|
||||
void IEventTarget.Unbind (string id){}
|
||||
bool IEventTarget.CanFeedback { get { return false; } }
|
||||
void IEventTarget.AddFeedback (IFeedbackInfo info)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
public class EventManager
|
||||
{
|
||||
Dictionary<string,eventBinding> bindings = new Dictionary<string,eventBinding>();
|
||||
List<IEventProvider> providers = new List<IEventProvider>();
|
||||
Dictionary<string,IEventProvider> feedbackLookup = new Dictionary<string, IEventProvider>();
|
||||
|
||||
class eventBinding
|
||||
{
|
||||
|
|
@ -155,7 +165,11 @@ namespace DMX2
|
|||
providers.Add (prov);
|
||||
foreach (var bind in bindings) {
|
||||
if (prov.Bind (bind.Key)) {
|
||||
feedbackLookup[bind.Key] = prov;
|
||||
IFeedbackInfo info = prov.GetFeedbackInfo(bind.Key);
|
||||
if(info!=null)
|
||||
foreach(IEventTarget target in bind.Value.Targets)
|
||||
if(target.CanFeedback)
|
||||
target.AddFeedback(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -219,9 +233,6 @@ namespace DMX2
|
|||
public void UnregisterProvider (IEventProvider prov)
|
||||
{
|
||||
providers.Remove(prov);
|
||||
var q = from feedback in feedbackLookup where feedback.Value == prov select feedback.Key;
|
||||
foreach(string id in q.ToArray())
|
||||
feedbackLookup.Remove(id);
|
||||
}
|
||||
|
||||
///<summary> Enregistrement d'une association id => cible
|
||||
|
|
@ -233,7 +244,10 @@ namespace DMX2
|
|||
target.Bind(eventId);
|
||||
foreach (IEventProvider prov in providers) {
|
||||
if(prov.Bind(eventId)) {
|
||||
feedbackLookup[eventId] = prov;
|
||||
if(target.CanFeedback){
|
||||
IFeedbackInfo info = prov.GetFeedbackInfo(eventId);
|
||||
if(info!=null) target.AddFeedback(info);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,17 @@ namespace DMX2
|
|||
}
|
||||
}
|
||||
|
||||
class midiFeedbackInfo : IFeedbackInfo {
|
||||
#region IFeedbackInfo implementation
|
||||
bool IFeedbackInfo.FeedBack (byte data)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Dictionary<string,internalEvent> eventlist = new Dictionary<string, internalEvent>();
|
||||
|
||||
EventData last;
|
||||
internalEvent levent=null;
|
||||
bool connected=false;
|
||||
|
|
@ -201,8 +211,13 @@ namespace DMX2
|
|||
return "Midi";
|
||||
}
|
||||
}
|
||||
|
||||
IFeedbackInfo IEventProvider.GetFeedbackInfo (string eventId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -171,6 +171,20 @@ namespace DMX2
|
|||
valeursrecues.Remove(id);
|
||||
}
|
||||
|
||||
List<IFeedbackInfo> feedbacks = new List<IFeedbackInfo>();
|
||||
|
||||
bool IEventTarget.CanFeedback { get { return false; } }
|
||||
|
||||
void IEventTarget.AddFeedback (IFeedbackInfo info)
|
||||
{
|
||||
feedbacks.Add(info);
|
||||
}
|
||||
|
||||
public void FeedBack(byte data){
|
||||
foreach (var fb in feedbacks)
|
||||
fb.FeedBack(data);
|
||||
}
|
||||
|
||||
/*IEnumerable<string> IEventTarget.IDs {
|
||||
get {
|
||||
return valeursrecues.Keys;
|
||||
|
|
@ -316,6 +330,9 @@ namespace DMX2
|
|||
{
|
||||
valeurschangees [c] = true;
|
||||
valeurscourantes [c] = value;
|
||||
lock(this)
|
||||
if(targets.ContainsKey(c))
|
||||
targets[c].FeedBack((byte)value);
|
||||
}
|
||||
|
||||
public bool EstChange (Circuit c)
|
||||
|
|
@ -357,6 +374,8 @@ namespace DMX2
|
|||
foreach (Circuit c in circuitsSeq) {
|
||||
if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey (c)) {
|
||||
valeurscourantes [c] = (int)(progression * (effetcourrant [c] - valeursinitiales [c]) + valeursinitiales [c]);
|
||||
if(targets.ContainsKey(c))
|
||||
targets[c].FeedBack((byte)valeurscourantes [c]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -380,8 +399,11 @@ namespace DMX2
|
|||
lock(this) {
|
||||
enTransition = false;
|
||||
foreach (Circuit c in circuitsSeq)
|
||||
if (!valeurschangees.ContainsKey (c))
|
||||
if (!valeurschangees.ContainsKey (c)){
|
||||
valeurscourantes [c] = effetcourrant [c];
|
||||
if(targets.ContainsKey(c))
|
||||
targets[c].FeedBack((byte)valeurscourantes [c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ namespace DMX2
|
|||
w1.Fill = false;
|
||||
// Container child vbox2.Gtk.Box+BoxChild
|
||||
this.table1 = new global::Gtk.Table (((uint)(3)), ((uint)(2)), false);
|
||||
this.table1.Name = "table1";
|
||||
this.table1.RowSpacing = ((uint)(6));
|
||||
this.table1.ColumnSpacing = ((uint)(6));
|
||||
// Container child table1.Gtk.Table+TableChild
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ namespace DMX2
|
|||
w1.Fill = false;
|
||||
// Container child vbox2.Gtk.Box+BoxChild
|
||||
this.table1 = new global::Gtk.Table (((uint)(4)), ((uint)(5)), false);
|
||||
this.table1.Name = "table1";
|
||||
this.table1.RowSpacing = ((uint)(6));
|
||||
this.table1.ColumnSpacing = ((uint)(6));
|
||||
// Container child table1.Gtk.Table+TableChild
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ namespace DMX2
|
|||
w1.Fill = false;
|
||||
// Container child vbox2.Gtk.Box+BoxChild
|
||||
this.table1 = new global::Gtk.Table (((uint)(5)), ((uint)(4)), false);
|
||||
this.table1.Name = "table1";
|
||||
this.table1.RowSpacing = ((uint)(6));
|
||||
this.table1.ColumnSpacing = ((uint)(6));
|
||||
// Container child table1.Gtk.Table+TableChild
|
||||
|
|
|
|||
Loading…
Reference in a new issue