* DriverBoitierV2.cs: Amelioration gestion d'erreurs
* SequenceurMacro.cs: Repetition : insensible a la casse * DriverBoitierV1.cs: Reactivation
This commit is contained in:
parent
f7416f39c9
commit
07ee1ef506
3 changed files with 30 additions and 21 deletions
|
|
@ -43,8 +43,8 @@ namespace DMX2
|
||||||
public DriverBoitierV1 (string serialport, string id): base(id)
|
public DriverBoitierV1 (string serialport, string id): base(id)
|
||||||
{
|
{
|
||||||
portname = serialport;
|
portname = serialport;
|
||||||
//patch = Conduite.Courante.Patches[0];
|
patch = Conduite.Courante.Patches[0];
|
||||||
//Start();
|
Start();
|
||||||
//serial = serialport;
|
//serial = serialport;
|
||||||
outputbuffer[0]=27;
|
outputbuffer[0]=27;
|
||||||
outputbuffer[1]=68;
|
outputbuffer[1]=68;
|
||||||
|
|
|
||||||
|
|
@ -113,11 +113,16 @@ namespace DMX2
|
||||||
if (serial != null) {
|
if (serial != null) {
|
||||||
serial.Close ();
|
serial.Close ();
|
||||||
serial.Dispose ();
|
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 = new SerialPort (portname, 460800, Parity.None, 8, StopBits.One);
|
||||||
//serial.DtrEnable = false;
|
//serial.DtrEnable = false;
|
||||||
serial.ReadTimeout = 200;
|
//serial.ReadTimeout = 200;
|
||||||
serial.WriteTimeout = 200;
|
//serial.WriteTimeout = 200;
|
||||||
try {
|
try {
|
||||||
serial.Open ();
|
serial.Open ();
|
||||||
Attente(DateTime.Now.AddMilliseconds(1000));
|
Attente(DateTime.Now.AddMilliseconds(1000));
|
||||||
|
|
@ -129,8 +134,10 @@ namespace DMX2
|
||||||
etat = etatAutomate.Deconnecte;
|
etat = etatAutomate.Deconnecte;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {
|
} catch (Exception ex) {
|
||||||
etat = etatAutomate.Deconnecte;
|
etat = etatAutomate.Deconnecte;
|
||||||
|
Console.WriteLine("DriverV2:Connection : {0}",ex);
|
||||||
|
Thread.Sleep (500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,7 +148,7 @@ namespace DMX2
|
||||||
bool Synchronisation ()
|
bool Synchronisation ()
|
||||||
{
|
{
|
||||||
//return true;
|
//return true;
|
||||||
|
Console.WriteLine ("DriverV2.Synchronisation()");
|
||||||
|
|
||||||
if (serial == null)
|
if (serial == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -183,6 +190,7 @@ namespace DMX2
|
||||||
|
|
||||||
void MainLoop ()
|
void MainLoop ()
|
||||||
{
|
{
|
||||||
|
DateTime t = DateTime.Now;
|
||||||
while (etat != etatAutomate.Fin) {
|
while (etat != etatAutomate.Fin) {
|
||||||
try {
|
try {
|
||||||
switch (etat) {
|
switch (etat) {
|
||||||
|
|
@ -192,6 +200,8 @@ namespace DMX2
|
||||||
break;
|
break;
|
||||||
case etatAutomate.Transmission:
|
case etatAutomate.Transmission:
|
||||||
finAttente = DateTime.Now.AddMilliseconds (22);
|
finAttente = DateTime.Now.AddMilliseconds (22);
|
||||||
|
Console.WriteLine(DateTime.Now-t);
|
||||||
|
t = DateTime.Now;
|
||||||
EnvoiTrame ();
|
EnvoiTrame ();
|
||||||
Reception ();
|
Reception ();
|
||||||
Attente (finAttente);
|
Attente (finAttente);
|
||||||
|
|
@ -201,17 +211,10 @@ namespace DMX2
|
||||||
EnvoieReInit();
|
EnvoieReInit();
|
||||||
break;
|
break;
|
||||||
case etatAutomate.Erreur:
|
case etatAutomate.Erreur:
|
||||||
|
Console.WriteLine("DriverV2 : etatAutomate.Erreur");
|
||||||
compteErreur ++;
|
compteErreur ++;
|
||||||
if (compteErreur > 3) {
|
|
||||||
Deconnecte ();
|
Deconnecte ();
|
||||||
Attente (DateTime.Now.AddSeconds (2));
|
Attente (DateTime.Now.AddSeconds (2));
|
||||||
} else {
|
|
||||||
Attente (DateTime.Now.AddMilliseconds (250));
|
|
||||||
if (Synchronisation ())
|
|
||||||
etat = etatAutomate.Transmission;
|
|
||||||
else
|
|
||||||
compteErreur++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
// case etatAutomate.Parametrage:
|
// case etatAutomate.Parametrage:
|
||||||
// EnvoiParam();
|
// EnvoiParam();
|
||||||
|
|
@ -250,12 +253,16 @@ namespace DMX2
|
||||||
void EnvoiTrame ()
|
void EnvoiTrame ()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if(!serial.IsOpen) {
|
|
||||||
etat = etatAutomate.Erreur;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(patch1!=null) patch1.CalculUnivers(outputbuffer,2,512);
|
if(patch1!=null) patch1.CalculUnivers(outputbuffer,2,512);
|
||||||
if(patch2!=null) patch2.CalculUnivers(outputbuffer,514,512);
|
if(patch2!=null) patch2.CalculUnivers(outputbuffer,514,512);
|
||||||
|
if(!serial.IsOpen) {
|
||||||
|
etat = etatAutomate.Erreur;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (serial.BytesToWrite > 0)
|
||||||
|
Thread.Sleep(1);
|
||||||
|
|
||||||
serial.Write(outputbuffer,0,outputbuffer.Length);
|
serial.Write(outputbuffer,0,outputbuffer.Length);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Console.WriteLine("Exception Envoi {0}",ex);
|
Console.WriteLine("Exception Envoi {0}",ex);
|
||||||
|
|
@ -269,7 +276,8 @@ namespace DMX2
|
||||||
|
|
||||||
while (serial.BytesToRead < len) {
|
while (serial.BytesToRead < len) {
|
||||||
Thread.Sleep (1);
|
Thread.Sleep (1);
|
||||||
if (++wcnt > timeout) return false;
|
if (++wcnt > timeout)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -295,6 +303,7 @@ namespace DMX2
|
||||||
|
|
||||||
if(!WaitForData (inputbuffer.Length)) {
|
if(!WaitForData (inputbuffer.Length)) {
|
||||||
etat = etatAutomate.Erreur;
|
etat = etatAutomate.Erreur;
|
||||||
|
Console.WriteLine("DriverV2.Reception : attente depassee");
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ namespace DMX2
|
||||||
enCours = lignes[index];
|
enCours = lignes[index];
|
||||||
|
|
||||||
// Gestion de la Reprise
|
// Gestion de la Reprise
|
||||||
if(enCours.Circuits.Equals("R") && ligneMaitre != null)
|
if(enCours.Circuits.ToLower().Equals("r") && ligneMaitre != null)
|
||||||
enCours = ligneMaitre;
|
enCours = ligneMaitre;
|
||||||
|
|
||||||
if(enCours.Nom.Length!=0)
|
if(enCours.Nom.Length!=0)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue