GruppeC/frontend/SmartLectureRoom/Assets/SmartRoom/Scripts/IO/CentralState.cs

120 lines
3.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
namespace SmartRoom
{
/// <summary>
/// Antwort von GET /api/unity des gemeinsamen Backends (backend/raum.js → unity()).
/// Das Backend entscheidet für Webinterface und Unity gemeinsam; Unity zeigt nur an und führt aus.
/// Das Backend liefert keine null-Werte (in "manuell" bedeutet -1 bzw. "" Automatik).
/// Die Sensorwerte ("sensor") liest <see cref="ArduinoBridge"/> separat in ein <see cref="SensorPacket"/>.
/// </summary>
[Serializable]
public class CentralState
{
public string zeit, szenario, status, detail, ton, prioritaet;
public int prioritaetNummer;
public float zielTemperatur;
public bool sensorOnline, fensterGesperrt;
public CentralCommand steuerung = new CentralCommand();
public CentralSources quellen = new CentralSources();
public CentralVetos vetos = new CentralVetos();
public CentralLimits grenzwerte = new CentralLimits();
public CentralVotes stimmen = new CentralVotes();
public CentralTimer vortrag = new CentralTimer();
public CentralManual manuell = new CentralManual();
public CentralCheck pruefung = new CentralCheck();
public string[] pfad = new string[0];
public CentralEntry[] verlauf = new CentralEntry[0];
public CentralScenario[] szenarien = new CentralScenario[0];
/// <summary>Quelle eines Sensorkanals: "sensor", "wetter", "demo" oder null.</summary>
public string SourceOf(string channel)
{
switch (channel)
{
case "t": return quellen.t;
case "co2": return quellen.co2;
case "rh": return quellen.rh;
case "tvoc": return quellen.tvoc;
case "lightpct":
case "lux": return quellen.lightpct;
case "nout": return quellen.nout;
case "tout": return quellen.tout;
case "wind": return quellen.wind;
case "sun": return quellen.sun;
case "aq": return quellen.aq;
default: return null;
}
}
}
/// <summary>Steuerbefehl, gleiches Format wie <see cref="ArduinoBridge.BuildCommand"/>.</summary>
[Serializable]
public class CentralCommand
{
public string window = "closed";
public float blind, heat, vent, light;
public int beamer;
}
[Serializable]
public class CentralSources
{
public string t, co2, rh, tvoc, lightpct, nout, tout, wind, sun, aq;
}
[Serializable]
public class CentralVetos
{
public bool co2, laerm, wind, aussenluft;
}
[Serializable]
public class CentralLimits
{
public float co2Ppm = 1000f, laermDb = 70f, windKmh = 60f;
}
[Serializable]
public class CentralVotes
{
public int kuehler, angenehm, waermer, auf, zu, gesamt;
}
[Serializable]
public class CentralTimer
{
public bool aktiv;
public int restMinuten, dauerMinuten;
}
/// <summary>Manuelle Dozenteneinstellungen aus dem Webinterface (-1 bzw. "" = Automatik).</summary>
[Serializable]
public class CentralManual
{
public bool aktiv;
public string fenster = "", bis = "";
public int jalousie = -1, licht = -1, lueftung = -1;
}
/// <summary>Prüfzyklus des Backends (alle 2 min, Zeitraffer 1×/5×/10×).</summary>
[Serializable]
public class CentralCheck
{
public int intervallSekunden = 120, zeitraffer = 1, abstandSekunden = 120, restSekunden;
public string letzteUhrzeit = "";
}
[Serializable]
public class CentralEntry
{
public string uhrzeit, titel, grund, ton;
}
[Serializable]
public class CentralScenario
{
public string id, text, beschreibung;
}
}