2026-03-10 19:56:55 +00:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using Brush = System.Windows.Media.Brush;
|
|
|
|
|
|
using Brushes = System.Windows.Media.Brushes;
|
|
|
|
|
|
using ColorConverter = System.Windows.Media.ColorConverter;
|
2026-03-12 20:03:24 +00:00
|
|
|
|
using Color = System.Windows.Media.Color;
|
2026-03-12 22:16:15 +00:00
|
|
|
|
using static AgroBase.Models.Enums;
|
2026-03-20 02:03:07 +00:00
|
|
|
|
using OperationControl.Models;
|
2026-03-10 19:56:55 +00:00
|
|
|
|
|
|
|
|
|
|
namespace OperationControl.ViewModels.Views.Operacao
|
|
|
|
|
|
{
|
|
|
|
|
|
public class OperacaoTopViewModel : INotifyPropertyChanged
|
|
|
|
|
|
{
|
2026-03-12 20:03:24 +00:00
|
|
|
|
private string _contextoSelecionado = "ROVER 01";
|
2026-03-10 19:56:55 +00:00
|
|
|
|
public string ContextoSelecionado
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _contextoSelecionado;
|
2026-03-12 20:03:24 +00:00
|
|
|
|
set { _contextoSelecionado = value; OnPropertyChanged(nameof(ContextoSelecionado)); }
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 20:03:24 +00:00
|
|
|
|
private string _tituloStatus = "ROVER OPERANDO NORMALMENTE";
|
|
|
|
|
|
public string TituloStatus
|
2026-03-10 19:56:55 +00:00
|
|
|
|
{
|
2026-03-12 20:03:24 +00:00
|
|
|
|
get => _tituloStatus;
|
|
|
|
|
|
set { _tituloStatus = value; OnPropertyChanged(nameof(TituloStatus)); }
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 20:03:24 +00:00
|
|
|
|
private string _motivoPrincipal = "Todos os módulos obrigatórios e regras de controle estão OK.";
|
|
|
|
|
|
public string MotivoPrincipal
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _motivoPrincipal;
|
|
|
|
|
|
set { _motivoPrincipal = value; OnPropertyChanged(nameof(MotivoPrincipal)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string _badgeTexto = "NORMAL";
|
2026-03-10 19:56:55 +00:00
|
|
|
|
public string BadgeTexto
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _badgeTexto;
|
2026-03-12 20:03:24 +00:00
|
|
|
|
set { _badgeTexto = value; OnPropertyChanged(nameof(BadgeTexto)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string _resumoCurto = "Sistema saudável";
|
|
|
|
|
|
public string ResumoCurto
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _resumoCurto;
|
|
|
|
|
|
set { _resumoCurto = value; OnPropertyChanged(nameof(ResumoCurto)); }
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 20:03:24 +00:00
|
|
|
|
private Brush _corFundo = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#153D2C"));
|
2026-03-10 19:56:55 +00:00
|
|
|
|
public Brush CorFundo
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _corFundo;
|
2026-03-12 20:03:24 +00:00
|
|
|
|
set { _corFundo = value; OnPropertyChanged(nameof(CorFundo)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Brush _corBorda = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2C7A57"));
|
|
|
|
|
|
public Brush CorBorda
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _corBorda;
|
|
|
|
|
|
set { _corBorda = value; OnPropertyChanged(nameof(CorBorda)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Brush _corAccent = Brushes.LightGreen;
|
|
|
|
|
|
public Brush CorAccent
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _corAccent;
|
|
|
|
|
|
set { _corAccent = value; OnPropertyChanged(nameof(CorAccent)); }
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 20:03:24 +00:00
|
|
|
|
private Brush _corBadge = Brushes.LightGreen;
|
2026-03-10 19:56:55 +00:00
|
|
|
|
public Brush CorBadge
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _corBadge;
|
2026-03-12 20:03:24 +00:00
|
|
|
|
set { _corBadge = value; OnPropertyChanged(nameof(CorBadge)); }
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Brush _corTexto = Brushes.White;
|
|
|
|
|
|
public Brush CorTexto
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _corTexto;
|
2026-03-12 20:03:24 +00:00
|
|
|
|
set { _corTexto = value; OnPropertyChanged(nameof(CorTexto)); }
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 20:03:24 +00:00
|
|
|
|
private Brush _corTextoBadge = Brushes.Black;
|
|
|
|
|
|
public Brush CorTextoBadge
|
2026-03-10 19:56:55 +00:00
|
|
|
|
{
|
2026-03-12 20:03:24 +00:00
|
|
|
|
get => _corTextoBadge;
|
|
|
|
|
|
set { _corTextoBadge = value; OnPropertyChanged(nameof(CorTextoBadge)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 22:16:15 +00:00
|
|
|
|
|
2026-03-13 19:30:21 +00:00
|
|
|
|
public void AtualizarStatus(StatusModulo status, string titulo, StatusOperacao status_op, string linha1, string linha2, string status_str, string resumo)
|
2026-03-12 20:03:24 +00:00
|
|
|
|
{
|
2026-03-13 19:30:21 +00:00
|
|
|
|
ContextoSelecionado = $"{titulo} • {status_op}";
|
2026-03-12 22:16:15 +00:00
|
|
|
|
TituloStatus = linha1;
|
|
|
|
|
|
MotivoPrincipal = linha2;
|
|
|
|
|
|
BadgeTexto = status_str;
|
|
|
|
|
|
ResumoCurto = resumo;
|
|
|
|
|
|
|
|
|
|
|
|
AplicarPaletaStatus(status);
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 22:16:15 +00:00
|
|
|
|
private void AplicarPaletaStatus(StatusModulo status)
|
2026-03-10 19:56:55 +00:00
|
|
|
|
{
|
2026-03-12 22:16:15 +00:00
|
|
|
|
switch (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
case StatusModulo.Desconectado:
|
|
|
|
|
|
CorFundo = BrushFromHex("#2A2F36");
|
|
|
|
|
|
CorBorda = BrushFromHex("#4B5563");
|
|
|
|
|
|
CorAccent = BrushFromHex("#9CA3AF");
|
|
|
|
|
|
CorBadge = BrushFromHex("#9CA3AF");
|
|
|
|
|
|
CorTexto = Brushes.White;
|
|
|
|
|
|
CorTextoBadge = BrushFromHex("#111827");
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case StatusModulo.Conectado:
|
|
|
|
|
|
CorFundo = BrushFromHex("#15324A");
|
|
|
|
|
|
CorBorda = BrushFromHex("#2563EB");
|
|
|
|
|
|
CorAccent = BrushFromHex("#60A5FA");
|
|
|
|
|
|
CorBadge = BrushFromHex("#60A5FA");
|
|
|
|
|
|
CorTexto = Brushes.White;
|
|
|
|
|
|
CorTextoBadge = BrushFromHex("#0B1220");
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case StatusModulo.Falha:
|
|
|
|
|
|
CorFundo = BrushFromHex("#4A1D1D");
|
|
|
|
|
|
CorBorda = BrushFromHex("#DC2626");
|
|
|
|
|
|
CorAccent = BrushFromHex("#F87171");
|
|
|
|
|
|
CorBadge = BrushFromHex("#F87171");
|
|
|
|
|
|
CorTexto = Brushes.White;
|
|
|
|
|
|
CorTextoBadge = BrushFromHex("#1F0A0A");
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case StatusModulo.Alerta:
|
|
|
|
|
|
CorFundo = BrushFromHex("#4A3A12");
|
|
|
|
|
|
CorBorda = BrushFromHex("#D97706");
|
|
|
|
|
|
CorAccent = BrushFromHex("#FBBF24");
|
|
|
|
|
|
CorBadge = BrushFromHex("#FBBF24");
|
|
|
|
|
|
CorTexto = Brushes.White;
|
|
|
|
|
|
CorTextoBadge = BrushFromHex("#1F1400");
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case StatusModulo.Operante:
|
|
|
|
|
|
default:
|
|
|
|
|
|
CorFundo = BrushFromHex("#153D2C");
|
|
|
|
|
|
CorBorda = BrushFromHex("#2C7A57");
|
|
|
|
|
|
CorAccent = BrushFromHex("#86EFAC");
|
|
|
|
|
|
CorBadge = BrushFromHex("#86EFAC");
|
|
|
|
|
|
CorTexto = Brushes.White;
|
|
|
|
|
|
CorTextoBadge = BrushFromHex("#052E16");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 22:16:15 +00:00
|
|
|
|
private SolidColorBrush BrushFromHex(string hex)
|
2026-03-10 19:56:55 +00:00
|
|
|
|
{
|
2026-03-12 22:16:15 +00:00
|
|
|
|
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(hex));
|
2026-03-10 19:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 22:16:15 +00:00
|
|
|
|
|
2026-03-10 19:56:55 +00:00
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
|
|
private void OnPropertyChanged(string nome)
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nome));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-13 18:58:02 +00:00
|
|
|
|
|
|
|
|
|
|
public class MotivoTopBarModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public int Prioridade { get; set; }
|
|
|
|
|
|
public string Fonte { get; set; } = "";
|
|
|
|
|
|
public string Titulo { get; set; } = "";
|
|
|
|
|
|
public string Descricao { get; set; } = "";
|
|
|
|
|
|
public StatusModulo StatusVisual { get; set; }
|
|
|
|
|
|
public T_Code? Modulo { get; set; }
|
|
|
|
|
|
}
|
2026-03-20 02:03:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class LogEventoOperacaoModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public DateTime DataHora { get; set; }
|
|
|
|
|
|
public string RoverId { get; set; }
|
|
|
|
|
|
public string TipoTransicao { get; set; } // INICIO / FIM / MUDANCA
|
|
|
|
|
|
public string Fonte { get; set; }
|
|
|
|
|
|
public string Titulo { get; set; }
|
|
|
|
|
|
public string Descricao { get; set; }
|
|
|
|
|
|
public StatusModulo StatusVisual { get; set; }
|
|
|
|
|
|
public T_Code? Modulo { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string Hora => DataHora.ToString("HH:mm:ss");
|
|
|
|
|
|
public string DataHoraCompleta => DataHora.ToString("dd/MM/yyyy HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
public string Subtitulo
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var moduloTxt = Modulo?.ToString();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(moduloTxt))
|
|
|
|
|
|
return $"{Fonte} • {moduloTxt} • {RoverId}";
|
|
|
|
|
|
|
|
|
|
|
|
return $"{Fonte} • {RoverId}";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Brush CorAccent
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return StatusVisual switch
|
|
|
|
|
|
{
|
|
|
|
|
|
StatusModulo.Falha => Brushes.IndianRed,
|
|
|
|
|
|
StatusModulo.Desconectado => Brushes.DarkRed,
|
|
|
|
|
|
StatusModulo.Alerta => Brushes.Goldenrod,
|
|
|
|
|
|
StatusModulo.Operante => Brushes.ForestGreen,
|
|
|
|
|
|
StatusModulo.Conectado => Brushes.SteelBlue,
|
|
|
|
|
|
_ => Brushes.Gray
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Brush CorBadge
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return TipoTransicao switch
|
|
|
|
|
|
{
|
|
|
|
|
|
"INICIO" => Brushes.OrangeRed,
|
|
|
|
|
|
"FIM" => Brushes.SeaGreen,
|
|
|
|
|
|
"MUDANCA" => Brushes.SteelBlue,
|
|
|
|
|
|
_ => Brushes.DimGray
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class HistoricoOperacaoItemModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public DateTime DataHora { get; set; }
|
|
|
|
|
|
public string RoverId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public TipoHistoricoOperacao Tipo { get; set; } // Operacao ou Alerta
|
|
|
|
|
|
public string TipoTransicao { get; set; } // INICIO / FIM / MUDANCA
|
|
|
|
|
|
|
|
|
|
|
|
public string Fonte { get; set; } // ex: Controle, Trajetoria, AlertaModulo
|
|
|
|
|
|
public string Titulo { get; set; }
|
|
|
|
|
|
public string Descricao { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public StatusModulo? StatusVisual { get; set; } // para eventos operacionais
|
|
|
|
|
|
public SeveridadeAlerta? SeveridadeAlerta { get; set; } // para alertas
|
|
|
|
|
|
|
|
|
|
|
|
public T_Code? Modulo { get; set; }
|
|
|
|
|
|
public string? ModId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string Hora => DataHora.ToString("HH:mm:ss");
|
|
|
|
|
|
public string DataHoraCompleta => DataHora.ToString("dd/MM/yyyy HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
public string Subtitulo
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var partes = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
partes.Add(Tipo == TipoHistoricoOperacao.Alerta ? "Alerta" : "Operação");
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Fonte))
|
|
|
|
|
|
partes.Add(Fonte);
|
|
|
|
|
|
|
|
|
|
|
|
if (Modulo.HasValue)
|
|
|
|
|
|
partes.Add(Modulo.Value.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(ModId))
|
|
|
|
|
|
partes.Add(ModId);
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(RoverId))
|
|
|
|
|
|
partes.Add(RoverId);
|
|
|
|
|
|
|
|
|
|
|
|
return string.Join(" • ", partes);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Brush CorAccent
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Tipo == TipoHistoricoOperacao.Alerta)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SeveridadeAlerta switch
|
|
|
|
|
|
{
|
|
|
|
|
|
Models.SeveridadeAlerta.Warning => Brushes.Goldenrod,
|
|
|
|
|
|
Models.SeveridadeAlerta.Error => Brushes.IndianRed,
|
|
|
|
|
|
Models.SeveridadeAlerta.Critical => Brushes.DarkRed,
|
|
|
|
|
|
_ => Brushes.SteelBlue
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return StatusVisual switch
|
|
|
|
|
|
{
|
|
|
|
|
|
StatusModulo.Falha => Brushes.IndianRed,
|
|
|
|
|
|
StatusModulo.Desconectado => Brushes.DarkRed,
|
|
|
|
|
|
StatusModulo.Alerta => Brushes.Goldenrod,
|
|
|
|
|
|
StatusModulo.Operante => Brushes.ForestGreen,
|
|
|
|
|
|
StatusModulo.Conectado => Brushes.SteelBlue,
|
|
|
|
|
|
_ => Brushes.Gray
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Brush CorBadge
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return TipoTransicao switch
|
|
|
|
|
|
{
|
|
|
|
|
|
"INICIO" => Brushes.OrangeRed,
|
|
|
|
|
|
"FIM" => Brushes.SeaGreen,
|
|
|
|
|
|
"MUDANCA" => Brushes.SteelBlue,
|
|
|
|
|
|
_ => Brushes.DimGray
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum TipoHistoricoOperacao
|
|
|
|
|
|
{
|
|
|
|
|
|
Operacao = 0,
|
|
|
|
|
|
Alerta = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 20:03:24 +00:00
|
|
|
|
}
|