monitor_de_clima_sqlite
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previa | |||
| monitor_de_clima_sqlite [2026/09/07 18:00] – editor externo (Fecha desconocida) 127.0.0.1 | monitor_de_clima_sqlite [2026/09/08 16:30] (actual) – hispa | ||
|---|---|---|---|
| Línea 59: | Línea 59: | ||
| HumMax, HumMin, | HumMax, HumMin, | ||
| PresMax, PresMin: Double; | PresMax, PresMin: Double; | ||
| - | | + | |
| - | | + | |
| - | | + | |
| procedure BtnSeleccionarDBClick(Sender: | procedure BtnSeleccionarDBClick(Sender: | ||
| Línea 83: | Línea 83: | ||
| procedure FormResize(Sender: | procedure FormResize(Sender: | ||
| - | |||
| - | procedure CrearEtiquetasMaxMin; | ||
| procedure ActualizarGraficosYEstadisticas; | procedure ActualizarGraficosYEstadisticas; | ||
| Línea 101: | Línea 99: | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { FORMULARIO | + | { |
| { ========================================================= } | { ========================================================= } | ||
| Línea 116: | Línea 114: | ||
| ConfigurarConexion; | ConfigurarConexion; | ||
| ConfigurarGraficas; | ConfigurarGraficas; | ||
| - | CrearEtiquetasMaxMin; | ||
| { 2. Mover al monitor principal DESPUÉS de definir las dimensiones } | { 2. Mover al monitor principal DESPUÉS de definir las dimensiones } | ||
| Línea 130: | Línea 127: | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { CREAR INTERFAZ | + | { |
| { ========================================================= } | { ========================================================= } | ||
| Línea 136: | Línea 133: | ||
| begin | begin | ||
| Self.Caption := ' | Self.Caption := ' | ||
| - | Self.SetBounds(100, | + | Self.SetBounds(100, |
| - | { Botón seleccionar BD (las coordenadas X e Y se calculan en FormResize) | + | { Botón seleccionar BD } |
| BtnSeleccionarDB := TButton.Create(Self); | BtnSeleccionarDB := TButton.Create(Self); | ||
| BtnSeleccionarDB.Parent := Self; | BtnSeleccionarDB.Parent := Self; | ||
| Línea 207: | Línea 204: | ||
| Exit; | Exit; | ||
| - | { Limpiar series actuales } | ||
| SerieTemp.Clear; | SerieTemp.Clear; | ||
| SerieHum.Clear; | SerieHum.Clear; | ||
| Línea 216: | Línea 212: | ||
| HayPres := False; | HayPres := False; | ||
| - | { Determinar límite de fecha si se eligen las últimas 24h } | ||
| if RadioOpciones.ItemIndex = 1 then | if RadioOpciones.ItemIndex = 1 then | ||
| FiltroFechaMin := MaxFechaDataset - 1.0 | FiltroFechaMin := MaxFechaDataset - 1.0 | ||
| else | else | ||
| - | FiltroFechaMin := 0; // Sin límite inferior | + | FiltroFechaMin := 0; |
| - | { Recorrer datos y filtrar según la opción seleccionada } | ||
| for i := 0 to High(DatosMediciones) do | for i := 0 to High(DatosMediciones) do | ||
| begin | begin | ||
| Línea 237: | Línea 231: | ||
| SeriePresion.AddXY(FechaVal, | SeriePresion.AddXY(FechaVal, | ||
| - | { Calcular | + | { Temperatura |
| if not HayTemp then | if not HayTemp then | ||
| begin | begin | ||
| - | TempMax := TVal; | + | TempMax := TVal; TempMin := TVal; |
| - | | + | TempMaxFecha := FechaVal; TempMinFecha := FechaVal; |
| HayTemp := True; | HayTemp := True; | ||
| end | end | ||
| else | else | ||
| begin | begin | ||
| - | if TVal > TempMax then TempMax := TVal; | + | if TVal > TempMax then begin TempMax := TVal; TempMaxFecha := FechaVal; end; |
| - | if TVal < TempMin then TempMin := TVal; | + | if TVal < TempMin then begin TempMin := TVal; TempMinFecha := FechaVal; end; |
| end; | end; | ||
| + | { Humedad Máx y Mín } | ||
| if not HayHum then | if not HayHum then | ||
| begin | begin | ||
| - | HumMax := HVal; | + | HumMax := HVal; HumMin := HVal; |
| - | | + | HumMaxFecha := FechaVal; HumMinFecha := FechaVal; |
| HayHum := True; | HayHum := True; | ||
| end | end | ||
| else | else | ||
| begin | begin | ||
| - | if HVal > HumMax then HumMax := HVal; | + | if HVal > HumMax then begin HumMax := HVal; HumMaxFecha := FechaVal; end; |
| - | if HVal < HumMin then HumMin := HVal; | + | if HVal < HumMin then begin HumMin := HVal; HumMinFecha := FechaVal; end; |
| end; | end; | ||
| + | { Presión Máx y Mín } | ||
| if not HayPres then | if not HayPres then | ||
| begin | begin | ||
| - | PresMax := PVal; | + | PresMax := PVal; PresMin := PVal; |
| - | | + | PresMaxFecha := FechaVal; PresMinFecha := FechaVal; |
| HayPres := True; | HayPres := True; | ||
| end | end | ||
| else | else | ||
| begin | begin | ||
| - | if PVal > PresMax then PresMax := PVal; | + | if PVal > PresMax then begin PresMax := PVal; PresMaxFecha := FechaVal; end; |
| - | if PVal < PresMin then PresMin := PVal; | + | if PVal < PresMin then begin PresMin := PVal; PresMinFecha := FechaVal; end; |
| end; | end; | ||
| end; | end; | ||
| end; | end; | ||
| - | { Actualizar etiquetas | + | { |
| + | FORMATO ESTANDARIZADO DE LEYENDA (Uso de %% para imprimir el carácter % en Format) | ||
| + | Línea 1: Titular igualado a 20 caracteres visibles exactos. | ||
| + | Línea 2 y 3: Mismo formato de ancho fijo (%7.2f). | ||
| + | | ||
| if HayTemp then | if HayTemp then | ||
| - | | + | |
| + | | ||
| + | | ||
| + | | ||
| + | TempMin, FormatDateTime(' | ||
| else | else | ||
| - | | + | |
| if HayHum then | if HayHum then | ||
| - | | + | |
| + | ' Máx: %7.2f (%s)' + LineEnding + | ||
| + | ' Mín: %7.2f (%s)', | ||
| + | [HumMax, | ||
| + | | ||
| else | else | ||
| - | | + | |
| if HayPres then | if HayPres then | ||
| - | | + | |
| + | | ||
| + | | ||
| + | | ||
| + | PresMin, FormatDateTime(' | ||
| else | else | ||
| - | | + | |
| - | + | ||
| - | LabelTempMaxMin.BringToFront; | + | |
| - | LabelHumMaxMin.BringToFront; | + | |
| - | LabelPresMaxMin.BringToFront; | + | |
| ChartTemp.Invalidate; | ChartTemp.Invalidate; | ||
| Línea 302: | Línea 310: | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { CREAR ETIQUETAS MAX/ | + | { |
| - | { ========================================================= } | + | |
| - | + | ||
| - | procedure TForm1.CrearEtiquetasMaxMin; | + | |
| - | begin | + | |
| - | LabelTempMaxMin := TLabel.Create(ChartTemp); | + | |
| - | LabelTempMaxMin.Parent := ChartTemp; | + | |
| - | LabelTempMaxMin.AutoSize := True; | + | |
| - | LabelTempMaxMin.Color := clForm; | + | |
| - | LabelTempMaxMin.ParentColor := True; | + | |
| - | + | ||
| - | LabelHumMaxMin := TLabel.Create(ChartHum); | + | |
| - | LabelHumMaxMin.Parent := ChartHum; | + | |
| - | LabelHumMaxMin.AutoSize := True; | + | |
| - | LabelHumMaxMin.Color := clForm; | + | |
| - | LabelHumMaxMin.ParentColor := True; | + | |
| - | + | ||
| - | LabelPresMaxMin := TLabel.Create(ChartPres); | + | |
| - | LabelPresMaxMin.Parent := ChartPres; | + | |
| - | LabelPresMaxMin.AutoSize := True; | + | |
| - | LabelPresMaxMin.Color := clForm; | + | |
| - | LabelPresMaxMin.ParentColor := True; | + | |
| - | end; | + | |
| - | + | ||
| - | { ========================================================= } | + | |
| - | { | + | |
| { ========================================================= } | { ========================================================= } | ||
| procedure TForm1.FormResize(Sender: | procedure TForm1.FormResize(Sender: | ||
| var | var | ||
| - | AltoDisponible, | + | AltoDisponible, |
| AnchoTotalPanel, | AnchoTotalPanel, | ||
| begin | begin | ||
| - | MargenTop := 65; // Aumentado ligeramente para dar espacio a los controles centrados | + | MargenTop := 65; |
| { 1. Centrar Botón y RadioGroup en la parte superior } | { 1. Centrar Botón y RadioGroup en la parte superior } | ||
| Línea 366: | Línea 349: | ||
| ChartHum.SetBounds(10, | ChartHum.SetBounds(10, | ||
| ChartPres.SetBounds(10, | ChartPres.SetBounds(10, | ||
| - | |||
| - | PosIzquierdaEtiqueta := AnchoGrafica - 130; | ||
| - | |||
| - | if Assigned(LabelTempMaxMin) then | ||
| - | begin | ||
| - | LabelTempMaxMin.Left := PosIzquierdaEtiqueta; | ||
| - | LabelTempMaxMin.Top := 62; | ||
| - | LabelTempMaxMin.BringToFront; | ||
| - | end; | ||
| - | |||
| - | if Assigned(LabelHumMaxMin) then | ||
| - | begin | ||
| - | LabelHumMaxMin.Left := PosIzquierdaEtiqueta; | ||
| - | LabelHumMaxMin.Top := 62; | ||
| - | LabelHumMaxMin.BringToFront; | ||
| - | end; | ||
| - | |||
| - | if Assigned(LabelPresMaxMin) then | ||
| - | begin | ||
| - | LabelPresMaxMin.Left := PosIzquierdaEtiqueta; | ||
| - | LabelPresMaxMin.Top := 62; | ||
| - | LabelPresMaxMin.BringToFront; | ||
| - | end; | ||
| end; | end; | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { CONFIGURAR SQLITE | + | { |
| { ========================================================= } | { ========================================================= } | ||
| Línea 403: | Línea 363: | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { FORMATO DE HORA } | + | { |
| { ========================================================= } | { ========================================================= } | ||
| Línea 416: | Línea 376: | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { EJE DE TIEMPO | + | { |
| { ========================================================= } | { ========================================================= } | ||
| Línea 435: | Línea 395: | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { | + | { CONFIGURAR GRÁFICAS |
| { ========================================================= } | { ========================================================= } | ||
| Línea 454: | Línea 414: | ||
| SerieTemp := TLineSeries.Create(ChartTemp); | SerieTemp := TLineSeries.Create(ChartTemp); | ||
| - | SerieTemp.Title := ' | ||
| SerieTemp.SeriesColor := clRed; | SerieTemp.SeriesColor := clRed; | ||
| SerieTemp.LinePen.Width := 3; | SerieTemp.LinePen.Width := 3; | ||
| Línea 469: | Línea 428: | ||
| SerieHum := TLineSeries.Create(ChartHum); | SerieHum := TLineSeries.Create(ChartHum); | ||
| - | SerieHum.Title := ' | ||
| SerieHum.SeriesColor := clBlue; | SerieHum.SeriesColor := clBlue; | ||
| SerieHum.LinePen.Width := 3; | SerieHum.LinePen.Width := 3; | ||
| Línea 484: | Línea 442: | ||
| SeriePresion := TLineSeries.Create(ChartPres); | SeriePresion := TLineSeries.Create(ChartPres); | ||
| - | SeriePresion.Title := ' | ||
| SeriePresion.SeriesColor := clGreen; | SeriePresion.SeriesColor := clGreen; | ||
| SeriePresion.LinePen.Width := 3; | SeriePresion.LinePen.Width := 3; | ||
| Línea 491: | Línea 448: | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { SELECCIONAR BASE DE DATOS } | + | { |
| { ========================================================= } | { ========================================================= } | ||
| Línea 504: | Línea 461: | ||
| { ========================================================= } | { ========================================================= } | ||
| - | { | + | { CARGAR Y GRAFICAR DATOS } |
| { ========================================================= } | { ========================================================= } | ||
| Línea 569: | Línea 526: | ||
| SQLite3Connection1.Connected := False; | SQLite3Connection1.Connected := False; | ||
| - | { Rellenar gráficos y calcular estadísticas de manera automática } | ||
| ActualizarGraficosYEstadisticas; | ActualizarGraficosYEstadisticas; | ||
monitor_de_clima_sqlite.txt · Última modificación: por hispa
