diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs
index 1fa23c8..2313953 100644
--- a/DMX-2.0/Conduite.cs
+++ b/DMX-2.0/Conduite.cs
@@ -143,6 +143,20 @@ namespace DMX2
}
}
+ public void DriversAdd (DriverDMX drv)
+ {
+ drivers.Add(drv);
+ IEventProvider evp = drv as IEventProvider;
+ if(evp!=null) eventManager.RegisterProvider(evp);
+ }
+
+ public void DriversRemove (DriverDMX drv)
+ {
+ drivers.Remove(drv);
+ IEventProvider evp = drv as IEventProvider;
+ if(evp!=null) eventManager.UnregisterProvider(evp);
+ }
+
public DriverDMX GetDriverByID(string ID){
foreach (var driver in drivers)
if(ID== driver.ID)
@@ -320,23 +334,28 @@ namespace DMX2
xmlRoot.AppendChild (xmlCircuits);
foreach (Circuit c in circuits) {
- c.Save(xmlCircuits);
+ c.Save (xmlCircuits);
}
- XmlElement xmlSequenceurs = xmlDoc.CreateElement("Sequenceurs");
- xmlRoot.AppendChild(xmlSequenceurs);
+ XmlElement xmlSequenceurs = xmlDoc.CreateElement ("Sequenceurs");
+ xmlRoot.AppendChild (xmlSequenceurs);
- foreach(Sequenceur seq in sequenceurs)
- {
- seq.Save(xmlSequenceurs);
+ foreach (Sequenceur seq in sequenceurs) {
+ seq.Save (xmlSequenceurs);
}
- XmlElement xmlUniversList = xmlDoc.CreateElement("ListeUnivers");
- xmlRoot.AppendChild(xmlUniversList);
+ XmlElement xmlUniversList = xmlDoc.CreateElement ("ListeUnivers");
+ xmlRoot.AppendChild (xmlUniversList);
- foreach(UniversDMX univ in univers)
- {
- univ.Save(xmlUniversList);
+ foreach (UniversDMX univ in univers) {
+ univ.Save (xmlUniversList);
+ }
+
+ XmlElement xmlDriverList = xmlDoc.CreateElement ("ListeDrivers");
+ xmlRoot.AppendChild (xmlDriverList);
+
+ foreach (DriverDMX drv in drivers) {
+ drv.Save(xmlDriverList);
}
XmlElement xmlMaster = xmlDoc.CreateElement("Master");
@@ -349,7 +368,7 @@ namespace DMX2
return xmlDoc;
}
- public Conduite(XmlDocument doc) : this(false)
+ public Conduite (XmlDocument doc) : this(false)
{
//TODO : Gestion d'erreurs
@@ -365,18 +384,26 @@ namespace DMX2
foreach (var xs in root["Sequenceurs"].ChildNodes) {
Sequenceur s = Sequenceur.Load (this, xs as XmlElement);
- if (s != null){
+ if (s != null) {
sequenceurs.Add (s);
s.Renamed += SequenceurRenomme;
}
}
- univers.Clear();
+ univers.Clear ();
+
foreach (var xu in root["ListeUnivers"].ChildNodes) {
- UniversDMX u = UniversDMX.Load(this,xu as XmlElement);
- if(u!=null)
- univers.Add(u);
+ UniversDMX u = UniversDMX.Load (this, xu as XmlElement);
+ if (u != null)
+ univers.Add (u);
+ }
+
+ if(root["ListeDrivers"]!=null)
+ foreach (var xd in root["ListeDrivers"].ChildNodes) {
+ DriverDMX drv = DriverDMX.Load(this,xd as XmlElement);
+ if(drv != null)
+ DriversAdd(drv);
}
XmlElement xmlMaster;
diff --git a/DMX-2.0/DriverBoitierV1.cs b/DMX-2.0/DriverBoitierV1.cs
index a30931e..0e3947d 100644
--- a/DMX-2.0/DriverBoitierV1.cs
+++ b/DMX-2.0/DriverBoitierV1.cs
@@ -1,6 +1,7 @@
using System;
using System.Threading;
using System.IO.Ports;
+using System.Xml;
namespace DMX2
{
@@ -43,7 +44,6 @@ namespace DMX2
public DriverBoitierV1 (string serialport, string id): base(id)
{
portname = serialport;
- patch = Conduite.Courante.Patches[0];
Start();
//serial = serialport;
outputbuffer[0]=27;
@@ -62,9 +62,15 @@ namespace DMX2
void Connection ()
{
+ Console.WriteLine ("DriverV1.Connection()");
if (serial != null) {
serial.Close();
serial.Dispose();
+ serial = null;
+ }
+ if (!System.IO.File.Exists (portname)) {
+ Thread.Sleep (200);
+ return;
}
serial = new SerialPort(portname, 460800,Parity.None,8,StopBits.One);
serial.DtrEnable = false;
@@ -174,7 +180,7 @@ namespace DMX2
byte b = 1; bool pressed;
for (byte i = 0; i<8; i++) {
if(!watchButtons[i]) continue;
- pressed = (inputbuffer[0] & b) != 0;
+ pressed = !((inputbuffer[0] & b) != 0);
if(buttons[i]^pressed)
{
eventsPending.Enqueue(new buttonState(i,pressed));
@@ -274,8 +280,46 @@ namespace DMX2
return "Boitier V1";
}
}
+ #endregion
+
+ #region implemented abstract members of DMX2.DriverDMX
+ public override void Save (System.Xml.XmlElement parent)
+ {
+ System.Xml.XmlElement el = parent.OwnerDocument.CreateElement ("DriverBoitierV1");
+ System.Xml.XmlElement xmlEl;
+
+ parent.AppendChild (el);
+
+ el.SetAttribute ("portname", portname.ToString ());
+ el.SetAttribute ("id", ID);
+
+ if(patch!=null) el.SetAttribute ("univers", patch.Nom);
+ }
#endregion
+ public static new DriverDMX Load(Conduite conduite, XmlElement el) {
+ //System.Xml.XmlElement xmlE;
+
+ string port = el.GetAttribute("portname");
+
+ if(! System.IO.File.Exists(port)) return null;
+
+ string id = el.GetAttribute("id");
+
+ DriverBoitierV1 drv = new DriverBoitierV1(port,id);
+
+ if(el.HasAttribute("univers"))
+ {
+ string univ = el.GetAttribute("univers");
+ foreach (UniversDMX u in conduite.Patches){
+ if(u.Nom== univ){
+ drv.patch = u;
+ break;
+ }
+ }
+ }
+ return drv;
+ }
}
}
diff --git a/DMX-2.0/DriverBoitierV1UI.cs b/DMX-2.0/DriverBoitierV1UI.cs
index f445d40..e1c56c9 100644
--- a/DMX-2.0/DriverBoitierV1UI.cs
+++ b/DMX-2.0/DriverBoitierV1UI.cs
@@ -20,17 +20,21 @@ namespace DMX2
void ConstruitCBUnivers ()
{
cbUnivers.Model = lsCbUnivers;
- var cellCbUnivers = new CellRendererText();
- cbUnivers.PackStart(cellCbUnivers,false);
- cbUnivers.SetCellDataFunc(cellCbUnivers, new CellLayoutDataFunc(RenderUniversName));
-
-
- foreach(UniversDMX u in Conduite.Courante.Patches)
- lsCbUnivers.AppendValues(u);
+ var cellCbUnivers = new CellRendererText ();
+ cbUnivers.PackStart (cellCbUnivers, false);
+ cbUnivers.SetCellDataFunc (cellCbUnivers, new CellLayoutDataFunc (RenderUniversName));
+ int indx = 0;
+ int i=0;
+ foreach (UniversDMX u in Conduite.Courante.Patches) {
+ lsCbUnivers.AppendValues (u);
+ if (u==drv.patch) indx=i;
+ i++;
+ }
TreeIter iter;
lsCbUnivers.GetIterFirst(out iter);
cbUnivers.SetActiveIter(iter);
+ cbUnivers.Active=indx;
}
@@ -49,8 +53,15 @@ namespace DMX2
drv.patch = lsCbUnivers.GetValue(iter,0) as UniversDMX;
}
+ }
+
+ protected void OnBtnValiderClicked (object sender, EventArgs e)
+ {
+ TreeIter iter;
+ if (cbUnivers.GetActiveIter (out iter)) {
+ drv.patch = lsCbUnivers.GetValue (iter, 0) as UniversDMX;
+ }
}
}
-}
-
+}
\ No newline at end of file
diff --git a/DMX-2.0/DriverBoitierV2.cs b/DMX-2.0/DriverBoitierV2.cs
index 13c3804..8ee47be 100644
--- a/DMX-2.0/DriverBoitierV2.cs
+++ b/DMX-2.0/DriverBoitierV2.cs
@@ -1,10 +1,11 @@
using System;
using System.Threading;
using System.IO.Ports;
+using System.Xml;
namespace DMX2
{
- public class DriverBoitierV2 : DriverDMX, IEventProvider
+ public class DriverBoitierV2 : DriverDMX//, IEventProvider
{
struct buttonState {
@@ -125,7 +126,7 @@ namespace DMX2
//serial.WriteTimeout = 200;
try {
serial.Open ();
- Attente(DateTime.Now.AddMilliseconds(1000));
+ Attente(DateTime.Now.AddMilliseconds(2000));
if(Synchronisation())
etat = etatAutomate.Transmission;
@@ -384,20 +385,6 @@ namespace DMX2
etat = etatAutomate.Erreur;
}
- void ProcessInput ()
- {
- byte b = 1; bool pressed;
- for (byte i = 0; i<8; i++) {
- if(!watchButtons[i]) continue;
- pressed = (inputbuffer[0] & b) != 0;
- if(buttons[i]^pressed)
- {
- eventsPending.Enqueue(new buttonState(i,pressed));
- buttons[i] = pressed;
- }
- b <<= 1;
- }
- }
public override void Dispose ()
{
@@ -419,7 +406,7 @@ namespace DMX2
}
#endregion
-
+ /*
#region IEventProvider implementation
@@ -490,7 +477,73 @@ namespace DMX2
}
}
#endregion
+*/
+ #region implemented abstract members of DMX2.DriverDMX
+ public override void Save (System.Xml.XmlElement parent)
+ {
+ System.Xml.XmlElement el = parent.OwnerDocument.CreateElement ("DriverBoitierV2");
+ System.Xml.XmlElement xmlEl;
+ parent.AppendChild (el);
+
+ el.SetAttribute ("portname", portname.ToString ());
+ el.SetAttribute ("id", ID);
+
+ if(patch1!=null) el.SetAttribute ("univers1", patch1.Nom);
+ if(patch2!=null) el.SetAttribute ("univers2", patch2.Nom);
+
+ el.SetAttribute("mab",mab.ToString());
+ el.SetAttribute("brk",brk.ToString());
+ el.SetAttribute("merge1",(flag_merge1!=0).ToString());
+ el.SetAttribute("merge2",(flag_merge2!=0).ToString());
+
+ }
+ #endregion
+
+ public static new DriverDMX Load(Conduite conduite, XmlElement el) {
+ //System.Xml.XmlElement xmlE;
+
+ string port = el.GetAttribute("portname");
+
+ if(! System.IO.File.Exists(port)) return null;
+
+ string id = el.GetAttribute("id");
+
+ DriverBoitierV2 drv = new DriverBoitierV2(port,id);
+
+ if(el.HasAttribute("univers1"))
+ {
+ string univ = el.GetAttribute("univers1");
+ foreach (UniversDMX u in conduite.Patches){
+ if(u.Nom== univ){
+ drv.patch1 = u;
+ break;
+ }
+ }
+ }
+ if(el.HasAttribute("univers2"))
+ {
+ string univ = el.GetAttribute("univers2");
+ foreach (UniversDMX u in conduite.Patches){
+ if(u.Nom== univ){
+ drv.patch2 = u;
+ break;
+ }
+ }
+ }
+
+ int mab,brk;
+ byte merge1,merge2;
+
+ mab = int.Parse(el.TryGetAttribute("mab","150"));
+ brk = int.Parse(el.TryGetAttribute("brk","50"));
+ merge1 = (byte)( bool.Parse(el.TryGetAttribute("merge1","True"))?1:0 );
+ merge2 = (byte)( bool.Parse(el.TryGetAttribute("merge2","True"))?1:0 );
+
+ drv.SetBreak(brk,mab,merge1,merge2);
+
+ return drv;
+ }
}
}
diff --git a/DMX-2.0/DriverBoitierV2UI.cs b/DMX-2.0/DriverBoitierV2UI.cs
index 335f350..7eda79b 100644
--- a/DMX-2.0/DriverBoitierV2UI.cs
+++ b/DMX-2.0/DriverBoitierV2UI.cs
@@ -20,37 +20,47 @@ namespace DMX2
ListStore lsCbUnivers2 = new ListStore(typeof(UniversDMX));
void ConstruitCBUnivers ()
{
- caseBrk.Text = drv.Break.ToString();
- caseMab.Text = drv.Mab.ToString();
+ caseBrk.Text = drv.Break.ToString ();
+ caseMab.Text = drv.Mab.ToString ();
chkMerge1.Active = drv.Flag_merge1 == 1;
chkMerge2.Active = drv.Flag_merge2 == 1;
cbUnivers1.Model = lsCbUnivers1;
- var cellCbUnivers1 = new CellRendererText();
- cbUnivers1.PackStart(cellCbUnivers1,false);
- cbUnivers1.SetCellDataFunc(cellCbUnivers1, new CellLayoutDataFunc(RenderUniversName1));
+ var cellCbUnivers1 = new CellRendererText ();
+ cbUnivers1.PackStart (cellCbUnivers1, false);
+ cbUnivers1.SetCellDataFunc (cellCbUnivers1, new CellLayoutDataFunc (RenderUniversName1));
-
- foreach(UniversDMX u in Conduite.Courante.Patches)
- lsCbUnivers1.AppendValues(u);
+ int indx = 0;
+ int i = 0;
+ foreach (UniversDMX u in Conduite.Courante.Patches) {
+ lsCbUnivers1.AppendValues (u);
+ if (u==drv.patch1) indx=i;
+ i++;
+ }
TreeIter iter;
- lsCbUnivers1.GetIterFirst(out iter);
- cbUnivers1.SetActiveIter(iter);
+ lsCbUnivers1.GetIterFirst (out iter);
+ cbUnivers1.SetActiveIter (iter);
+ cbUnivers1.Active=indx;
cbUnivers2.Model = lsCbUnivers2;
- var cellCbUnivers2 = new CellRendererText();
- cbUnivers2.PackStart(cellCbUnivers2,false);
- cbUnivers2.SetCellDataFunc(cellCbUnivers2, new CellLayoutDataFunc(RenderUniversName2));
+ var cellCbUnivers2 = new CellRendererText ();
+ cbUnivers2.PackStart (cellCbUnivers2, false);
+ cbUnivers2.SetCellDataFunc (cellCbUnivers2, new CellLayoutDataFunc (RenderUniversName2));
-
- foreach(UniversDMX u in Conduite.Courante.Patches)
- lsCbUnivers2.AppendValues(u);
+ indx = 0;
+ i = 0;
+ foreach (UniversDMX u in Conduite.Courante.Patches) {
+ lsCbUnivers2.AppendValues (u);
+ if (u==drv.patch2) indx=i;
+ i++;
+ }
//TreeIter iter;
lsCbUnivers2.GetIterFirst(out iter);
cbUnivers2.SetActiveIter(iter);
+ cbUnivers2.Active=indx;
}
@@ -68,7 +78,7 @@ namespace DMX2
(cell as Gtk.CellRendererText).Text = univers.Nom;
}
- protected void OnButton120Clicked (object sender, EventArgs e)
+ protected void OnButtonValider (object sender, EventArgs e)
{
TreeIter iter;
if (cbUnivers1.GetActiveIter (out iter)) {
diff --git a/DMX-2.0/DriverDMX.cs b/DMX-2.0/DriverDMX.cs
index 737ec57..79769c8 100644
--- a/DMX-2.0/DriverDMX.cs
+++ b/DMX-2.0/DriverDMX.cs
@@ -1,5 +1,6 @@
using System;
using System.Threading;
+using System.Xml;
namespace DMX2
{
@@ -26,6 +27,19 @@ namespace DMX2
protected bool disposed = false;
+ public static DriverDMX Load (Conduite conduite, XmlElement el)
+ {
+ switch (el.Name) {
+ case "DriverBoitierV1":
+ return DriverBoitierV1.Load(conduite, el);
+ case "DriverBoitierV2":
+ return DriverBoitierV2.Load(conduite,el);
+ }
+ return null;
+ }
+
+ public abstract void Save (XmlElement parent);
+
#region IDisposable implementation
public virtual void Dispose()
diff --git a/DMX-2.0/EventManager.cs b/DMX-2.0/EventManager.cs
index 9ad801a..d3102b7 100644
--- a/DMX-2.0/EventManager.cs
+++ b/DMX-2.0/EventManager.cs
@@ -132,6 +132,8 @@ namespace DMX2
public void RegisterProvider (IEventProvider prov)
{
providers.Add (prov);
+ foreach( var bind in bindings)
+ prov.Bind(bind.Key);
}
#region Menus
diff --git a/DMX-2.0/GestionDriversUI.cs b/DMX-2.0/GestionDriversUI.cs
index 7ad49b7..86a7d23 100644
--- a/DMX-2.0/GestionDriversUI.cs
+++ b/DMX-2.0/GestionDriversUI.cs
@@ -106,16 +106,7 @@ namespace DMX2
return;
drv = Conduite.Courante.GetDriverByID (fi.Name);
- if (drv == null) {
- btnConnect.Visible = btnConnect.Sensitive = true;
- btnDisconnect.Visible = btnDisconnect.Sensitive = false;
- comboDriver.Sensitive = true;
- comboDriver.Active=-1;
- if(frmDrvChild.Child!=null)
- frmDrvChild.Remove(frmDrvChild.Child);
- return;
- }
AfficheDriverUI();
@@ -141,11 +132,14 @@ namespace DMX2
switch (comboDriver.Active) {
case 0:
drv = new DriverBoitierV1(fi.FullName, fi.Name);
- Conduite.Courante.Drivers.Add(drv);
+ Conduite.Courante.DriversAdd(drv);
+
+
break;
case 1:
drv = new DriverBoitierV2(fi.FullName, fi.Name);
- Conduite.Courante.Drivers.Add(drv);
+ Conduite.Courante.DriversAdd(drv);
+
break;
default:
return;
@@ -159,12 +153,26 @@ namespace DMX2
{
if (drv != null) {
drv.Dispose ();
- Conduite.Courante.Drivers.Remove (drv);
+ Conduite.Courante.DriversRemove (drv);
}
-
+ drv=null;
+ AfficheDriverUI();
}
void AfficheDriverUI(){
+ if(frmDrvChild.Child!=null)
+ frmDrvChild.Remove(frmDrvChild.Child);
+ if (drv == null) {
+ btnConnect.Visible = btnConnect.Sensitive = true;
+ btnDisconnect.Visible = btnDisconnect.Sensitive = false;
+
+ comboDriver.Sensitive = true;
+ comboDriver.Active=-1;
+ listeUsb.QueueDraw();
+
+ return;
+ }
+
btnConnect.Visible = false;
comboDriver.Sensitive = false;
@@ -172,7 +180,7 @@ namespace DMX2
frmDrvChild.Child = drv.GetUI();
frmDrvChild.ShowAll();
-
+ listeUsb.QueueDraw();
}
void EffaceDriverUI(){
diff --git a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV1UI.cs b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV1UI.cs
index d439474..758efa1 100644
--- a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV1UI.cs
+++ b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV1UI.cs
@@ -11,6 +11,8 @@ namespace DMX2
private global::Gtk.Label label4;
private global::Gtk.Label label5;
private global::Gtk.Label lblEtat;
+ private global::Gtk.HBox hbox1;
+ private global::Gtk.Button btnValider;
protected virtual void Build ()
{
@@ -78,11 +80,32 @@ namespace DMX2
this.vbox2.Add (this.table1);
global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.table1]));
w6.Position = 1;
+ // Container child vbox2.Gtk.Box+BoxChild
+ this.hbox1 = new global::Gtk.HBox ();
+ this.hbox1.Name = "hbox1";
+ this.hbox1.Spacing = 6;
+ // Container child hbox1.Gtk.Box+BoxChild
+ this.btnValider = new global::Gtk.Button ();
+ this.btnValider.CanFocus = true;
+ this.btnValider.Name = "btnValider";
+ this.btnValider.UseUnderline = true;
+ this.btnValider.Label = "Valider";
+ this.hbox1.Add (this.btnValider);
+ global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnValider]));
+ w7.Position = 1;
+ w7.Expand = false;
+ w7.Fill = false;
+ this.vbox2.Add (this.hbox1);
+ global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1]));
+ w8.Position = 2;
+ w8.Expand = false;
+ w8.Fill = false;
this.Add (this.vbox2);
if ((this.Child != null)) {
this.Child.ShowAll ();
}
this.Hide ();
+ this.btnValider.Clicked += new global::System.EventHandler (this.OnBtnValiderClicked);
}
}
}
diff --git a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV2UI.cs b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV2UI.cs
index 14975ea..119dee8 100644
--- a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV2UI.cs
+++ b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV2UI.cs
@@ -21,7 +21,7 @@ namespace DMX2
private global::Gtk.Label label7;
private global::Gtk.Label label8;
private global::Gtk.HBox hbox1;
- private global::Gtk.Button button120;
+ private global::Gtk.Button btnValider;
private global::Gtk.Button btnInit;
protected virtual void Build ()
@@ -204,13 +204,13 @@ namespace DMX2
this.hbox1.Name = "hbox1";
this.hbox1.Spacing = 6;
// Container child hbox1.Gtk.Box+BoxChild
- this.button120 = new global::Gtk.Button ();
- this.button120.CanFocus = true;
- this.button120.Name = "button120";
- this.button120.UseUnderline = true;
- this.button120.Label = "Valider";
- this.hbox1.Add (this.button120);
- global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.button120]));
+ this.btnValider = new global::Gtk.Button ();
+ this.btnValider.CanFocus = true;
+ this.btnValider.Name = "btnValider";
+ this.btnValider.UseUnderline = true;
+ this.btnValider.Label = "Valider";
+ this.hbox1.Add (this.btnValider);
+ global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnValider]));
w16.Position = 1;
w16.Expand = false;
w16.Fill = false;
@@ -236,7 +236,7 @@ namespace DMX2
this.Child.ShowAll ();
}
this.Hide ();
- this.button120.Clicked += new global::System.EventHandler (this.OnButton120Clicked);
+ this.btnValider.Clicked += new global::System.EventHandler (this.OnButtonValider);
this.btnInit.Clicked += new global::System.EventHandler (this.OnBtnInitClicked);
}
}
diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic
index 8bae5ea..dfb1657 100644
--- a/DMX-2.0/gtk-gui/gui.stetic
+++ b/DMX-2.0/gtk-gui/gui.stetic
@@ -2017,7 +2017,7 @@ au sequenceur
-
+
False
@@ -2132,6 +2132,40 @@ au sequenceur
True
+
+
+
+ 6
+
+
+
+
+
+
+ True
+ TextOnly
+ Valider
+ True
+
+
+
+ 1
+ True
+ False
+ False
+
+
+
+
+
+
+
+ 2
+ True
+ False
+ False
+
+
@@ -2467,13 +2501,13 @@ au sequenceur
-
+
True
TextOnly
Valider
True
-
+
1