Corrections diverses serveur web
This commit is contained in:
parent
d588622879
commit
2d12b10412
6 changed files with 54 additions and 28 deletions
|
|
@ -198,6 +198,26 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Circuit circuitTelecomande=null;
|
||||||
|
int circuitTelecomandeVal=0;
|
||||||
|
|
||||||
|
public Circuit CircuitTelecomande {
|
||||||
|
get {
|
||||||
|
return circuitTelecomande;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
circuitTelecomande = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CircuitTelecomandeVal {
|
||||||
|
get {
|
||||||
|
return circuitTelecomandeVal;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
circuitTelecomandeVal = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// On utilise un thread qui boucle au lieu d'un timer.
|
// On utilise un thread qui boucle au lieu d'un timer.
|
||||||
// C'est un peu moins précis, mais ca consomme beaucoup moins de ressources
|
// C'est un peu moins précis, mais ca consomme beaucoup moins de ressources
|
||||||
|
|
@ -268,6 +288,9 @@ namespace DMX2
|
||||||
} else {
|
} else {
|
||||||
foreach (var c in circuits) {
|
foreach (var c in circuits) {
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
if(circuitTelecomande==c)
|
||||||
|
val = circuitTelecomandeVal;
|
||||||
|
//else
|
||||||
foreach (var seq in sequenceurs) {
|
foreach (var seq in sequenceurs) {
|
||||||
val = Math.Max (val, seq.ValeurCircuit (c));
|
val = Math.Max (val, seq.ValeurCircuit (c));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,6 @@
|
||||||
<EmbeddedResource Include="html\css\theme\images\ui-bg_glass_65_ffffff_1x400.png">
|
<EmbeddedResource Include="html\css\theme\images\ui-bg_glass_65_ffffff_1x400.png">
|
||||||
<LogicalName>css.theme.images.ui-bg_glass_65_ffffff_1x400.png</LogicalName>
|
<LogicalName>css.theme.images.ui-bg_glass_65_ffffff_1x400.png</LogicalName>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Conduite.cs">
|
|
||||||
<LogicalName>cs</LogicalName>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="gtk-gui\generated.cs" />
|
<Compile Include="gtk-gui\generated.cs" />
|
||||||
|
|
@ -150,6 +147,7 @@
|
||||||
<Compile Include="DriverBoitierV2UI.cs" />
|
<Compile Include="DriverBoitierV2UI.cs" />
|
||||||
<Compile Include="gtk-gui\DMX2.DriverBoitierV2UI.cs" />
|
<Compile Include="gtk-gui\DMX2.DriverBoitierV2UI.cs" />
|
||||||
<Compile Include="WebServer.cs" />
|
<Compile Include="WebServer.cs" />
|
||||||
|
<Compile Include="Conduite.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace DMX2
|
||||||
|
|
||||||
void HandleDestroyed (object sender, EventArgs e)
|
void HandleDestroyed (object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
universEdite.AllumageForce = 0;
|
universEdite.AllumageForce = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderUniversName (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
|
void RenderUniversName (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
|
||||||
|
|
@ -228,7 +228,7 @@ namespace DMX2
|
||||||
majencour = true;
|
majencour = true;
|
||||||
int id = (int)(spinDimmer.Value);
|
int id = (int)(spinDimmer.Value);
|
||||||
|
|
||||||
universEdite.AllumageForce = 0;
|
universEdite.AllumageForce = -1;
|
||||||
btAllume.Active = false;
|
btAllume.Active = false;
|
||||||
|
|
||||||
currDimm = id - 1;
|
currDimm = id - 1;
|
||||||
|
|
@ -400,7 +400,7 @@ namespace DMX2
|
||||||
{
|
{
|
||||||
if (majencour)
|
if (majencour)
|
||||||
return;
|
return;
|
||||||
universEdite.AllumageForce = btAllume.Active?currDimm:0;
|
universEdite.AllumageForce = btAllume.Active?currDimm:-1;
|
||||||
universEdite.AllumageForceVal = 255;
|
universEdite.AllumageForceVal = 255;
|
||||||
}
|
}
|
||||||
protected void OnTxtParam1Changed (object sender, EventArgs e)
|
protected void OnTxtParam1Changed (object sender, EventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ namespace DMX2
|
||||||
public void EffetSuivant ()
|
public void EffetSuivant ()
|
||||||
{
|
{
|
||||||
lock (this) {
|
lock (this) {
|
||||||
|
Conduite.Courante.CircuitTelecomande = null;
|
||||||
if(lignes.Count==0) return;
|
if(lignes.Count==0) return;
|
||||||
if (aSuivre == null) {
|
if (aSuivre == null) {
|
||||||
if (IndexLigneEnCours + 1 < lignes.Count)
|
if (IndexLigneEnCours + 1 < lignes.Count)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace DMX2
|
||||||
|
|
||||||
Dimmer[] _dimmers = new Dimmer[512];
|
Dimmer[] _dimmers = new Dimmer[512];
|
||||||
|
|
||||||
int allumageForce = 0;
|
int allumageForce = -1;
|
||||||
|
|
||||||
public int AllumageForce {
|
public int AllumageForce {
|
||||||
get {
|
get {
|
||||||
|
|
@ -86,7 +86,7 @@ namespace DMX2
|
||||||
for(int i = 0 ; i<count; i++)
|
for(int i = 0 ; i<count; i++)
|
||||||
{
|
{
|
||||||
if(allumageForce==i) {
|
if(allumageForce==i) {
|
||||||
valeurs[i+offset] = allumageForceVal;
|
valeurs[i+offset] = (byte)allumageForceVal;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ namespace DMX2
|
||||||
Console.WriteLine (context.Request.RawUrl);
|
Console.WriteLine (context.Request.RawUrl);
|
||||||
|
|
||||||
string responseString = GetResponse (context);
|
string responseString = GetResponse (context);
|
||||||
|
// TODO : gerer autrement les resources
|
||||||
byte[] buffer = System.Text.Encoding.UTF8.GetBytes (responseString);
|
byte[] buffer = System.Text.Encoding.UTF8.GetBytes (responseString);
|
||||||
context.Response.ContentLength64 = buffer.Length;
|
context.Response.ContentLength64 = buffer.Length;
|
||||||
context.Response.OutputStream.Write (buffer, 0, buffer.Length);
|
context.Response.OutputStream.Write (buffer, 0, buffer.Length);
|
||||||
|
|
@ -53,49 +54,52 @@ namespace DMX2
|
||||||
string GetResponse (HttpListenerContext ctx)
|
string GetResponse (HttpListenerContext ctx)
|
||||||
{
|
{
|
||||||
HttpListenerRequest req = ctx.Request;
|
HttpListenerRequest req = ctx.Request;
|
||||||
if (Conduite.Courante == null)
|
// Pas de conduite chargée, on renvoi un simple message
|
||||||
return "<html><body>Pas de conduite</body></html>";
|
if (Conduite.Courante == null) return "<html><body>Pas de conduite</body></html>";
|
||||||
|
|
||||||
|
// Pour les resources, on les renvoie si elles existent
|
||||||
if (req.Url.LocalPath.StartsWith ("/res/")) {
|
if (req.Url.LocalPath.StartsWith ("/res/")) {
|
||||||
string res = req.Url.LocalPath.Remove(0,5).Replace('/','.');
|
string res = req.Url.LocalPath.Remove(0,5).Replace('/','.');
|
||||||
Console.WriteLine( res);
|
|
||||||
if(res.EndsWith(".js"))
|
|
||||||
ctx.Response.ContentType= "application/javascript";
|
|
||||||
if(resources.Contains(res))
|
if(resources.Contains(res))
|
||||||
using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(res))
|
using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(res))
|
||||||
using (System.IO.TextReader reader = new System.IO.StreamReader(stream))
|
using (System.IO.TextReader reader = new System.IO.StreamReader(stream))
|
||||||
return reader.ReadToEnd();
|
return reader.ReadToEnd();
|
||||||
else return "";
|
else return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int circuit, univ, dimmer, val;
|
||||||
|
|
||||||
|
// En fonction du http://xxxxxx:yyyy/?id=
|
||||||
switch (req.QueryString["id"]) {
|
switch (req.QueryString["id"]) {
|
||||||
default:
|
default: // Par défaut, on renvoie la page
|
||||||
|
|
||||||
string univlist = ""; int i = 0;
|
string univlist = ""; int i = 0;
|
||||||
foreach (UniversDMX univ in Conduite.Courante.Patches)
|
foreach (UniversDMX univers in Conduite.Courante.Patches)
|
||||||
univlist = univlist + string.Format("<option value=\"{0}\">{1}</option>",i++,univ.Nom);
|
univlist = univlist + string.Format("<option value=\"{0}\">{1}</option>",i++,univers.Nom);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string data = page.Replace("<UNIVLIST>",univlist);
|
string data = page.Replace("<UNIVLIST>",univlist);
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
case "2" :
|
case "2" :
|
||||||
int univ, dimmer, val;
|
// id=2 > controle d'un dimmer
|
||||||
if(!int.TryParse(req.QueryString["univ"],out univ)) return "NOK";
|
if(!int.TryParse(req.QueryString["univ"],out univ)) return "NOK";
|
||||||
if(!int.TryParse(req.QueryString["dimmer"],out dimmer)) return "NOK";
|
if(!int.TryParse(req.QueryString["dimmer"],out dimmer)) return "NOK";
|
||||||
if(!int.TryParse(req.QueryString["val"],out val)) return "NOK";
|
if(!int.TryParse(req.QueryString["val"],out val)) return "NOK";
|
||||||
if(univ<0 || univ>= Conduite.Courante.Patches.Count) return "NOK";
|
if(univ<0 || univ>= Conduite.Courante.Patches.Count) return "NOK";
|
||||||
if(dimmer<=0 || dimmer > 512) return "NOK";
|
if(dimmer<=0 || dimmer > 512) return "NOK";
|
||||||
if(val <0 || val > 255) return "NOK";
|
if(val <0 || val > 255) return "NOK";
|
||||||
Conduite.Courante.Patches[univ].AllumageForce = dimmer;
|
Conduite.Courante.Patches[univ].AllumageForce = dimmer-1;
|
||||||
Conduite.Courante.Patches[univ].AllumageForceVal = val;
|
Conduite.Courante.Patches[univ].AllumageForceVal = val;
|
||||||
return "OK";
|
return "OK";
|
||||||
|
|
||||||
case "3":
|
case "3":
|
||||||
int circuit, val;
|
|
||||||
|
// id=3 > controle d'un circuit
|
||||||
if(!int.TryParse(req.QueryString["circuit"],out circuit)) return "NOK";
|
if(!int.TryParse(req.QueryString["circuit"],out circuit)) return "NOK";
|
||||||
if(!int.TryParse(req.QueryString["val"],out val)) return "NOK";
|
if(!int.TryParse(req.QueryString["val"],out val)) return "NOK";
|
||||||
if(circuit<0 || circuit>= Conduite.Courante.Circuits.Count) return "NOK";
|
if(circuit<=0 || circuit> Conduite.Courante.Circuits.Count) return "NOK";
|
||||||
if(val <0 || val > 255) return "NOK";
|
if(val <0 || val > 255) return "NOK";
|
||||||
|
Conduite.Courante.CircuitTelecomande = Conduite.Courante.Circuits[circuit-1];
|
||||||
|
Conduite.Courante.CircuitTelecomandeVal = val;
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue