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