diff --git a/AgroBase/AgroBase/AgroBase.csproj b/AgroBase/AgroBase/AgroBase.csproj index 2ea06ab92..cffaa4171 100644 --- a/AgroBase/AgroBase/AgroBase.csproj +++ b/AgroBase/AgroBase/AgroBase.csproj @@ -384,6 +384,9 @@ frmPinout.cs + + UserControl + Component @@ -396,6 +399,12 @@ UserControl + + UserControl + + + UserControl + Component @@ -408,6 +417,9 @@ UserControl + + UserControl + Component @@ -432,9 +444,15 @@ UserControl + + UserControl + Component + + UserControl + UserControl @@ -501,6 +519,30 @@ HmiCompactMetricCard.cs + + UserControl + + + ucParametrosAtuador.cs + + + UserControl + + + ucParametrosDirecional.cs + + + UserControl + + + ucParametrosMapa.cs + + + UserControl + + + ucParametrosMovimento.cs + UserControl diff --git a/AgroBase/AgroBase/Forms/IHM/Controls/HmiAgitatorModeSelector.cs b/AgroBase/AgroBase/Forms/IHM/Controls/HmiAgitatorModeSelector.cs new file mode 100644 index 000000000..94d59c16a --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Controls/HmiAgitatorModeSelector.cs @@ -0,0 +1,131 @@ +using AgroBase.Forms.IHM.Controls; +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros.Controls +{ + [DefaultEvent("SelectedModeChanged")] + public class HmiAgitatorModeSelector : UserControl + { + private readonly Button _btnSemAgitacao; + private readonly Button _btnContinuo; + private readonly Button _btnIntermitente; + + private string _selectedMode = "Continuo"; + + public event EventHandler SelectedModeChanged; + + public HmiAgitatorModeSelector() + { + DoubleBuffered = true; + BackColor = Color.Transparent; + Margin = Padding.Empty; + Padding = Padding.Empty; + MinimumSize = new Size(260, 44); + + TableLayoutPanel layout = new TableLayoutPanel + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + ColumnCount = 3, + RowCount = 1, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.33F)); + layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.33F)); + layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.34F)); + layout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + + _btnSemAgitacao = CriarBotao("Sem agitação"); + _btnContinuo = CriarBotao("Contínuo"); + _btnIntermitente = CriarBotao("Intermitente"); + + layout.Controls.Add(_btnSemAgitacao, 0, 0); + layout.Controls.Add(_btnContinuo, 1, 0); + layout.Controls.Add(_btnIntermitente, 2, 0); + + Controls.Add(layout); + + _btnSemAgitacao.Click += delegate { SelectedMode = "SemAgitacao"; }; + _btnContinuo.Click += delegate { SelectedMode = "Continuo"; }; + _btnIntermitente.Click += delegate { SelectedMode = "Intermitente"; }; + + AtualizarAparencia(); + } + + private static Button CriarBotao(string texto) + { + Button button = new Button + { + Dock = DockStyle.Fill, + BackColor = HmiTheme.SurfaceRaised, + ForeColor = HmiTheme.TextMuted, + FlatStyle = FlatStyle.Flat, + Font = new Font("Segoe UI", 7.6F, FontStyle.Bold), + Text = texto, + TextAlign = ContentAlignment.MiddleCenter, + Cursor = Cursors.Hand, + Margin = new Padding(2), + UseVisualStyleBackColor = false + }; + + button.FlatAppearance.BorderSize = 1; + button.FlatAppearance.BorderColor = HmiTheme.Border; + return button; + } + + private void AtualizarAparencia() + { + AplicarEstado(_btnSemAgitacao, _selectedMode == "SemAgitacao"); + AplicarEstado(_btnContinuo, _selectedMode == "Continuo"); + AplicarEstado(_btnIntermitente, _selectedMode == "Intermitente"); + } + + private static void AplicarEstado(Button button, bool selecionado) + { + if (selecionado) + { + button.BackColor = Color.FromArgb(31, 91, 43); + button.ForeColor = HmiTheme.Success; + button.FlatAppearance.BorderColor = HmiTheme.Success; + } + else + { + button.BackColor = HmiTheme.SurfaceRaised; + button.ForeColor = HmiTheme.TextMuted; + button.FlatAppearance.BorderColor = HmiTheme.Border; + } + } + + [Category("Dados")] + [DefaultValue("Continuo")] + public string SelectedMode + { + get { return _selectedMode; } + set + { + string novo; + + if (string.Equals(value, "SemAgitacao", StringComparison.OrdinalIgnoreCase)) + novo = "SemAgitacao"; + else if (string.Equals(value, "Intermitente", StringComparison.OrdinalIgnoreCase)) + novo = "Intermitente"; + else + novo = "Continuo"; + + if (_selectedMode == novo) + return; + + _selectedMode = novo; + AtualizarAparencia(); + + if (SelectedModeChanged != null) + SelectedModeChanged(this, EventArgs.Empty); + } + } + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Controls/HmiCompactCheckRow.cs b/AgroBase/AgroBase/Forms/IHM/Controls/HmiCompactCheckRow.cs new file mode 100644 index 000000000..c35276624 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Controls/HmiCompactCheckRow.cs @@ -0,0 +1,201 @@ +using AgroBase.Forms.IHM.Controls; +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros.Controls +{ + [DefaultEvent("CheckedChanged")] + public class HmiCompactCheckRow : UserControl + { + private readonly TableLayoutPanel _layout; + private readonly Label _lblTitulo; + private readonly CheckBox _check; + + public event EventHandler CheckedChanged; + + public HmiCompactCheckRow() + { + SetStyle( + ControlStyles.AllPaintingInWmPaint | + ControlStyles.OptimizedDoubleBuffer | + ControlStyles.ResizeRedraw | + ControlStyles.UserPaint, + true + ); + + DoubleBuffered = true; + BackColor = HmiTheme.SurfaceRaised; + Cursor = Cursors.Hand; + Height = 54; + MinimumSize = new Size(150, 44); + Margin = new Padding(3); + Padding = new Padding(9, 5, 7, 5); + + _layout = new TableLayoutPanel + { + BackColor = Color.Transparent, + ColumnCount = 2, + RowCount = 1, + Dock = DockStyle.Fill, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + _layout.ColumnStyles.Add( + new ColumnStyle(SizeType.Percent, 100F) + ); + + _layout.ColumnStyles.Add( + new ColumnStyle(SizeType.Absolute, 42F) + ); + + _layout.RowStyles.Add( + new RowStyle(SizeType.Percent, 100F) + ); + + _lblTitulo = new Label + { + AutoEllipsis = true, + AutoSize = false, + BackColor = Color.Transparent, + Cursor = Cursors.Hand, + Dock = DockStyle.Fill, + Font = new Font( + "Segoe UI", + 8F, + FontStyle.Bold + ), + ForeColor = HmiTheme.Text, + Margin = Padding.Empty, + Padding = new Padding(2, 0, 4, 0), + Text = "Parâmetro", + TextAlign = ContentAlignment.MiddleLeft + }; + + _check = CriarCheck(); + + _layout.Controls.Add(_lblTitulo, 0, 0); + _layout.Controls.Add(_check, 1, 0); + + Controls.Add(_layout); + + _check.CheckedChanged += Check_CheckedChanged; + + _lblTitulo.Click += AlternarPorClique; + _layout.Click += AlternarPorClique; + Click += AlternarPorClique; + + AtualizarAparencia(); + } + + private static CheckBox CriarCheck() + { + CheckBox check = new CheckBox + { + Anchor = AnchorStyles.None, + Appearance = Appearance.Button, + AutoSize = false, + BackColor = Color.FromArgb(30, 90, 46), + Checked = true, + Cursor = Cursors.Hand, + Dock = DockStyle.None, + FlatStyle = FlatStyle.Flat, + Font = new Font( + "Segoe UI Symbol", + 9F, + FontStyle.Bold + ), + ForeColor = HmiTheme.Success, + Height = 30, + Margin = Padding.Empty, + Padding = Padding.Empty, + Text = "✓", + TextAlign = ContentAlignment.MiddleCenter, + UseVisualStyleBackColor = false, + Width = 34 + }; + + check.FlatAppearance.BorderSize = 1; + check.FlatAppearance.BorderColor = HmiTheme.Success; + check.FlatAppearance.CheckedBackColor = + Color.FromArgb(30, 90, 46); + + check.FlatAppearance.MouseDownBackColor = + Color.FromArgb(37, 108, 55); + + check.FlatAppearance.MouseOverBackColor = + Color.FromArgb(34, 100, 51); + + return check; + } + + private void AlternarPorClique(object sender, EventArgs e) + { + _check.Checked = !_check.Checked; + } + + private void Check_CheckedChanged(object sender, EventArgs e) + { + AtualizarAparencia(); + + if (CheckedChanged != null) + CheckedChanged(this, EventArgs.Empty); + } + + private void AtualizarAparencia() + { + if (_check.Checked) + { + _check.Text = "✓"; + _check.ForeColor = HmiTheme.Success; + _check.BackColor = Color.FromArgb(30, 90, 46); + _check.FlatAppearance.BorderColor = HmiTheme.Success; + + _lblTitulo.ForeColor = HmiTheme.Text; + } + else + { + _check.Text = "×"; + _check.ForeColor = HmiTheme.Danger; + _check.BackColor = HmiTheme.Surface; + _check.FlatAppearance.BorderColor = HmiTheme.Danger; + + _lblTitulo.ForeColor = HmiTheme.TextMuted; + } + + Invalidate(); + } + + [Category("Conteúdo")] + public string Titulo + { + get { return _lblTitulo.Text; } + set { _lblTitulo.Text = value ?? string.Empty; } + } + + [Category("Dados")] + [DefaultValue(true)] + public bool Checked + { + get { return _check.Checked; } + set + { + if (_check.Checked == value) + { + AtualizarAparencia(); + return; + } + + _check.Checked = value; + } + } + + [Browsable(false)] + public CheckBox CheckBox + { + get { return _check; } + } + } +} \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/Controls/HmiCompactNumericField.cs b/AgroBase/AgroBase/Forms/IHM/Controls/HmiCompactNumericField.cs new file mode 100644 index 000000000..8cc2ff5bc --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Controls/HmiCompactNumericField.cs @@ -0,0 +1,381 @@ +using AgroBase.Forms.IHM.Controls; +using System; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros.Controls +{ + [DefaultEvent("ValueChanged")] + public class HmiCompactNumericField : UserControl + { + private readonly TableLayoutPanel _root; + private readonly Label _lblTitulo; + private readonly TableLayoutPanel _valueLayout; + private readonly Button _btnDiminuir; + private readonly TextBox _txtValor; + private readonly Button _btnAumentar; + private readonly Label _lblUnidade; + + private decimal _value; + private decimal _minimum; + private decimal _maximum = 100M; + private decimal _increment = 1M; + private int _decimalPlaces; + + public event EventHandler ValueChanged; + + public HmiCompactNumericField() + { + SetStyle( + ControlStyles.AllPaintingInWmPaint | + ControlStyles.OptimizedDoubleBuffer | + ControlStyles.ResizeRedraw | + ControlStyles.UserPaint, + true); + + DoubleBuffered = true; + BackColor = HmiTheme.SurfaceRaised; + Margin = new Padding(3); + Padding = new Padding(7, 5, 7, 5); + MinimumSize = new Size(105, 62); + + _root = new TableLayoutPanel + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + ColumnCount = 1, + RowCount = 2, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + _root.ColumnStyles.Add( + new ColumnStyle(SizeType.Percent, 100F)); + + _root.RowStyles.Add( + new RowStyle(SizeType.Absolute, 22F)); + + _root.RowStyles.Add( + new RowStyle(SizeType.Percent, 100F)); + + _lblTitulo = new Label + { + Dock = DockStyle.Fill, + AutoSize = false, + AutoEllipsis = true, + BackColor = Color.Transparent, + ForeColor = HmiTheme.TextMuted, + Font = new Font("Segoe UI", 6.8F, FontStyle.Bold), + Text = "Parâmetro", + TextAlign = ContentAlignment.MiddleLeft, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + _valueLayout = new TableLayoutPanel + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + ColumnCount = 4, + RowCount = 1, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + _valueLayout.ColumnStyles.Add( + new ColumnStyle(SizeType.Absolute, 34F)); + + _valueLayout.ColumnStyles.Add( + new ColumnStyle(SizeType.Percent, 100F)); + + _valueLayout.ColumnStyles.Add( + new ColumnStyle(SizeType.Absolute, 34F)); + + _valueLayout.ColumnStyles.Add( + new ColumnStyle(SizeType.Absolute, 34F)); + + _valueLayout.RowStyles.Add( + new RowStyle(SizeType.Percent, 100F)); + + _btnDiminuir = CriarBotaoValor("−"); + _btnAumentar = CriarBotaoValor("+"); + + _txtValor = new TextBox + { + Dock = DockStyle.Fill, + BackColor = HmiTheme.Surface, + ForeColor = HmiTheme.Text, + BorderStyle = BorderStyle.FixedSingle, + Font = new Font("Segoe UI", 9F, FontStyle.Bold), + TextAlign = HorizontalAlignment.Center, + ReadOnly = true, + ShortcutsEnabled = false, + TabStop = false, + Margin = new Padding(3, 1, 3, 1) + }; + + _lblUnidade = new Label + { + Dock = DockStyle.Fill, + AutoSize = false, + BackColor = Color.Transparent, + ForeColor = HmiTheme.TextMuted, + Font = new Font("Segoe UI", 7F, FontStyle.Bold), + Text = "%", + TextAlign = ContentAlignment.MiddleCenter, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + _valueLayout.Controls.Add(_btnDiminuir, 0, 0); + _valueLayout.Controls.Add(_txtValor, 1, 0); + _valueLayout.Controls.Add(_btnAumentar, 2, 0); + _valueLayout.Controls.Add(_lblUnidade, 3, 0); + + _root.Controls.Add(_lblTitulo, 0, 0); + _root.Controls.Add(_valueLayout, 0, 1); + + Controls.Add(_root); + + _btnDiminuir.Click += delegate + { + Value -= Increment; + }; + + _btnAumentar.Click += delegate + { + Value += Increment; + }; + + AtualizarTexto(); + AtualizarBotoes(); + } + + private static Button CriarBotaoValor(string texto) + { + Button button = new Button + { + Dock = DockStyle.Fill, + BackColor = HmiTheme.Surface, + ForeColor = HmiTheme.Info, + FlatStyle = FlatStyle.Flat, + Font = new Font("Segoe UI", 12F, FontStyle.Bold), + Text = texto, + TextAlign = ContentAlignment.MiddleCenter, + Cursor = Cursors.Hand, + Margin = new Padding(1), + Padding = Padding.Empty, + TabStop = false, + UseVisualStyleBackColor = false + }; + + button.FlatAppearance.BorderSize = 1; + button.FlatAppearance.BorderColor = HmiTheme.Border; + button.FlatAppearance.MouseOverBackColor = + Color.FromArgb(35, 52, 61); + + button.FlatAppearance.MouseDownBackColor = + Color.FromArgb(42, 67, 78); + + return button; + } + + private void DefinirValor(decimal value) + { + decimal novo = Math.Max( + Minimum, + Math.Min(Maximum, value)); + + novo = decimal.Round( + novo, + DecimalPlaces, + MidpointRounding.AwayFromZero); + + if (_value == novo) + { + AtualizarTexto(); + AtualizarBotoes(); + return; + } + + _value = novo; + + AtualizarTexto(); + AtualizarBotoes(); + + if (ValueChanged != null) + ValueChanged(this, EventArgs.Empty); + } + + private void AtualizarTexto() + { + string formato = DecimalPlaces > 0 + ? "F" + DecimalPlaces + : "F0"; + + _txtValor.Text = _value.ToString( + formato, + CultureInfo.CurrentCulture); + } + + private void AtualizarBotoes() + { + bool podeDiminuir = _value > Minimum; + bool podeAumentar = _value < Maximum; + + AplicarEstadoBotao( + _btnDiminuir, + podeDiminuir); + + AplicarEstadoBotao( + _btnAumentar, + podeAumentar); + } + + private static void AplicarEstadoBotao( + Button button, + bool habilitado) + { + button.Enabled = habilitado; + + if (habilitado) + { + button.ForeColor = HmiTheme.Info; + button.BackColor = HmiTheme.Surface; + button.FlatAppearance.BorderColor = + HmiTheme.Border; + } + else + { + button.ForeColor = HmiTheme.TextMuted; + button.BackColor = HmiTheme.SurfaceRaised; + button.FlatAppearance.BorderColor = + HmiTheme.SurfaceRaised; + } + } + + [Category("Conteúdo")] + public string Titulo + { + get { return _lblTitulo.Text; } + set { _lblTitulo.Text = value ?? string.Empty; } + } + + [Category("Conteúdo")] + public string Unidade + { + get { return _lblUnidade.Text; } + set + { + _lblUnidade.Text = value ?? string.Empty; + AtualizarLarguraUnidade(); + } + } + + private void AtualizarLarguraUnidade() + { + int largura; + + if (string.IsNullOrWhiteSpace(_lblUnidade.Text)) + largura = 4; + else if (_lblUnidade.Text.Length <= 1) + largura = 25; + else + largura = 35; + + _valueLayout.ColumnStyles[3].SizeType = + SizeType.Absolute; + + _valueLayout.ColumnStyles[3].Width = + largura; + } + + [Category("Dados")] + [DefaultValue(typeof(decimal), "0")] + public decimal Value + { + get { return _value; } + set { DefinirValor(value); } + } + + [Category("Dados")] + [DefaultValue(typeof(decimal), "0")] + public decimal Minimum + { + get { return _minimum; } + set + { + _minimum = value; + + if (_maximum < _minimum) + _maximum = _minimum; + + DefinirValor(_value); + } + } + + [Category("Dados")] + [DefaultValue(typeof(decimal), "100")] + public decimal Maximum + { + get { return _maximum; } + set + { + _maximum = value; + + if (_maximum < _minimum) + _minimum = _maximum; + + DefinirValor(_value); + } + } + + [Category("Dados")] + [DefaultValue(typeof(decimal), "1")] + public decimal Increment + { + get { return _increment; } + set + { + _increment = value > 0M + ? value + : 1M; + } + } + + [Category("Dados")] + [DefaultValue(0)] + public int DecimalPlaces + { + get { return _decimalPlaces; } + set + { + _decimalPlaces = Math.Max( + 0, + Math.Min(4, value)); + + DefinirValor(_value); + } + } + + [Browsable(false)] + public Button BotaoDiminuir + { + get { return _btnDiminuir; } + } + + [Browsable(false)] + public Button BotaoAumentar + { + get { return _btnAumentar; } + } + + [Browsable(false)] + public TextBox CampoValor + { + get { return _txtValor; } + } + } +} \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/Controls/HmiModeSelector.cs b/AgroBase/AgroBase/Forms/IHM/Controls/HmiModeSelector.cs new file mode 100644 index 000000000..c1f283de6 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Controls/HmiModeSelector.cs @@ -0,0 +1,135 @@ +using AgroBase.Forms.IHM.Controls; +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros.Controls +{ + [DefaultEvent("SelectedModeChanged")] + public class HmiModeSelector : UserControl + { + private readonly Button _btnMpc; + private readonly Button _btnPid; + private string _selectedMode = "MPC"; + + public event EventHandler SelectedModeChanged; + + public HmiModeSelector() + { + DoubleBuffered = true; + BackColor = HmiTheme.SurfaceRaised; + Padding = new Padding(8); + Margin = new Padding(3); + MinimumSize = new Size(180, 88); + + TableLayoutPanel root = new TableLayoutPanel + { + Dock = DockStyle.Fill, + ColumnCount = 2, + RowCount = 2, + BackColor = Color.Transparent, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + root.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + root.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + root.RowStyles.Add(new RowStyle(SizeType.Absolute, 26F)); + root.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + + Label title = new Label + { + Dock = DockStyle.Fill, + AutoSize = false, + BackColor = Color.Transparent, + ForeColor = HmiTheme.Text, + Font = new Font("Segoe UI", 8.2F, FontStyle.Bold), + Text = "Modo de controle", + TextAlign = ContentAlignment.MiddleLeft, + Margin = Padding.Empty + }; + + _btnMpc = CriarBotao("MPC"); + _btnPid = CriarBotao("PID"); + + root.Controls.Add(title, 0, 0); + root.SetColumnSpan(title, 2); + root.Controls.Add(_btnMpc, 0, 1); + root.Controls.Add(_btnPid, 1, 1); + + Controls.Add(root); + + _btnMpc.Click += delegate { SelectedMode = "MPC"; }; + _btnPid.Click += delegate { SelectedMode = "PID"; }; + + AtualizarAparencia(); + } + + private static Button CriarBotao(string text) + { + Button button = new Button + { + Dock = DockStyle.Fill, + BackColor = HmiTheme.Surface, + ForeColor = HmiTheme.TextMuted, + FlatStyle = FlatStyle.Flat, + Font = new Font("Segoe UI", 9F, FontStyle.Bold), + Text = text, + TextAlign = ContentAlignment.MiddleCenter, + Cursor = Cursors.Hand, + Margin = new Padding(2), + UseVisualStyleBackColor = false + }; + + button.FlatAppearance.BorderSize = 1; + button.FlatAppearance.BorderColor = HmiTheme.Border; + + return button; + } + + private void AtualizarAparencia() + { + AplicarEstado(_btnMpc, _selectedMode == "MPC"); + AplicarEstado(_btnPid, _selectedMode == "PID"); + } + + private static void AplicarEstado(Button button, bool selected) + { + if (selected) + { + button.BackColor = Color.FromArgb(31, 91, 43); + button.ForeColor = HmiTheme.Success; + button.FlatAppearance.BorderColor = HmiTheme.Success; + } + else + { + button.BackColor = HmiTheme.Surface; + button.ForeColor = HmiTheme.TextMuted; + button.FlatAppearance.BorderColor = HmiTheme.Border; + } + } + + [Category("Dados")] + [DefaultValue("MPC")] + public string SelectedMode + { + get { return _selectedMode; } + set + { + string novo = string.Equals(value, "PID", StringComparison.OrdinalIgnoreCase) + ? "PID" + : "MPC"; + + if (_selectedMode == novo) + return; + + _selectedMode = novo; + AtualizarAparencia(); + + if (SelectedModeChanged != null) + SelectedModeChanged(this, EventArgs.Empty); + } + } + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Controls/HmiNozzleCard.cs b/AgroBase/AgroBase/Forms/IHM/Controls/HmiNozzleCard.cs index aa428b6e3..e8c205bd8 100644 --- a/AgroBase/AgroBase/Forms/IHM/Controls/HmiNozzleCard.cs +++ b/AgroBase/AgroBase/Forms/IHM/Controls/HmiNozzleCard.cs @@ -3,17 +3,10 @@ using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; +using static AgroBase.Models.Enums; namespace AgroBase.Forms.IHM.Controls.Operacao { - public enum HmiNozzleState - { - Desconectado = 0, - Conectado = 1, - Falha = 2, - Alerta = 3, - Operante = 4 - } [DefaultEvent("NozzleClick")] public class HmiNozzleCard : UserControl @@ -27,7 +20,7 @@ namespace AgroBase.Forms.IHM.Controls.Operacao private bool _commandOn; private bool _readOn; - private HmiNozzleState _state = HmiNozzleState.Operante; + private StatusModulo _state = StatusModulo.Desconectado; private bool _allowCommand = true; public event EventHandler NozzleClick; @@ -178,23 +171,23 @@ namespace AgroBase.Forms.IHM.Controls.Operacao } } - private static Color GetStateColor(HmiNozzleState state) + private static Color GetStateColor(StatusModulo state) { switch (state) { - case HmiNozzleState.Desconectado: + case StatusModulo.Desconectado: return HmiTheme.TextMuted; - case HmiNozzleState.Conectado: + case StatusModulo.Conectado: return HmiTheme.Info; - case HmiNozzleState.Falha: + case StatusModulo.Falha: return HmiTheme.Danger; - case HmiNozzleState.Alerta: + case StatusModulo.Alerta: return HmiTheme.Warning; - case HmiNozzleState.Operante: + case StatusModulo.Operante: default: return HmiTheme.Success; } @@ -208,7 +201,7 @@ namespace AgroBase.Forms.IHM.Controls.Operacao } [Category("Estado")] - public HmiNozzleState State + public StatusModulo State { get { return _state; } set @@ -292,8 +285,8 @@ namespace AgroBase.Forms.IHM.Controls.Operacao [Category("Conteúdo")] public string TempoLigado { - get { return _lblTempo.Text.Replace("Tempo ", ""); } - set { _lblTempo.Text = "Tempo " + (value ?? "00:00"); } + get { return _lblTempo.Text; } + set { _lblTempo.Text = (value ?? "00:00"); } } } } diff --git a/AgroBase/AgroBase/Forms/IHM/Controls/HmiNumericParameterCard.cs b/AgroBase/AgroBase/Forms/IHM/Controls/HmiNumericParameterCard.cs new file mode 100644 index 000000000..c8ae592cf --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Controls/HmiNumericParameterCard.cs @@ -0,0 +1,185 @@ +using AgroBase.Forms.IHM.Controls; +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros.Controls +{ + [DefaultEvent("ValueChanged")] + public class HmiNumericParameterCard : UserControl + { + private readonly Label _lblTitulo; + private readonly Label _lblDescricao; + private readonly NumericUpDown _numeric; + private readonly Label _lblUnidade; + private readonly ToolTip _toolTip; + + public event EventHandler ValueChanged; + + public HmiNumericParameterCard() + { + DoubleBuffered = true; + BackColor = HmiTheme.SurfaceRaised; + Margin = new Padding(3); + Padding = new Padding(10, 7, 10, 7); + MinimumSize = new Size(180, 88); + + TableLayoutPanel root = new TableLayoutPanel + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + ColumnCount = 2, + RowCount = 3, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + root.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + root.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 42F)); + + root.RowStyles.Add(new RowStyle(SizeType.Absolute, 28F)); + root.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + + _lblTitulo = new Label + { + Dock = DockStyle.Fill, + AutoSize = false, + BackColor = Color.Transparent, + ForeColor = HmiTheme.Text, + Font = new Font("Segoe UI", 8.2F, FontStyle.Bold), + Text = "Parâmetro", + TextAlign = ContentAlignment.MiddleLeft, + AutoEllipsis = true, + Margin = Padding.Empty + }; + + _lblDescricao = new Label + { + Dock = DockStyle.Fill, + AutoSize = false, + BackColor = Color.Transparent, + ForeColor = HmiTheme.TextMuted, + Font = new Font("Segoe UI", 6.5F), + Text = "Descrição", + TextAlign = ContentAlignment.TopLeft, + AutoEllipsis = true, + Margin = Padding.Empty + }; + + _toolTip = new ToolTip(); + + _numeric = new NumericUpDown + { + Dock = DockStyle.Fill, + BackColor = HmiTheme.Surface, + ForeColor = HmiTheme.Text, + BorderStyle = BorderStyle.FixedSingle, + Font = new Font("Segoe UI", 9.5F, FontStyle.Bold), + TextAlign = HorizontalAlignment.Center, + Minimum = 0, + Maximum = 100, + DecimalPlaces = 1, + Increment = 0.5M, + Margin = new Padding(0, 3, 5, 3) + }; + + _lblUnidade = new Label + { + Dock = DockStyle.Fill, + AutoSize = false, + BackColor = Color.Transparent, + ForeColor = HmiTheme.TextMuted, + Font = new Font("Segoe UI", 8F, FontStyle.Bold), + Text = "m", + TextAlign = ContentAlignment.MiddleCenter, + Margin = new Padding(0, 3, 0, 3) + }; + + root.Controls.Add(_lblTitulo, 0, 0); + root.SetColumnSpan(_lblTitulo, 2); + root.Controls.Add(_numeric, 0, 1); + root.Controls.Add(_lblUnidade, 1, 1); + + Controls.Add(root); + + _numeric.ValueChanged += delegate + { + if (ValueChanged != null) + ValueChanged(this, EventArgs.Empty); + }; + } + + [Category("Conteúdo")] + public string Titulo + { + get { return _lblTitulo.Text; } + set { _lblTitulo.Text = value ?? string.Empty; } + } + + [Category("Conteúdo")] + public string Descricao + { + get { return _lblDescricao.Text; } + set + { + _lblDescricao.Text = value ?? string.Empty; + _toolTip.SetToolTip(this, _lblDescricao.Text); + _toolTip.SetToolTip(_lblTitulo, _lblDescricao.Text); + _toolTip.SetToolTip(_numeric, _lblDescricao.Text); + } + } + + [Category("Conteúdo")] + public string Unidade + { + get { return _lblUnidade.Text; } + set { _lblUnidade.Text = value ?? string.Empty; } + } + + [Category("Dados")] + public decimal Value + { + get { return _numeric.Value; } + set + { + decimal novo = Math.Max(_numeric.Minimum, Math.Min(_numeric.Maximum, value)); + _numeric.Value = novo; + } + } + + [Category("Dados")] + public decimal Minimum + { + get { return _numeric.Minimum; } + set { _numeric.Minimum = value; } + } + + [Category("Dados")] + public decimal Maximum + { + get { return _numeric.Maximum; } + set { _numeric.Maximum = value; } + } + + [Category("Dados")] + public decimal Increment + { + get { return _numeric.Increment; } + set { _numeric.Increment = value; } + } + + [Category("Dados")] + public int DecimalPlaces + { + get { return _numeric.DecimalPlaces; } + set { _numeric.DecimalPlaces = Math.Max(0, value); } + } + + [Browsable(false)] + public NumericUpDown Numeric + { + get { return _numeric; } + } + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Controls/HmiParameterSliderRow.cs b/AgroBase/AgroBase/Forms/IHM/Controls/HmiParameterSliderRow.cs new file mode 100644 index 000000000..42f85b4d6 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Controls/HmiParameterSliderRow.cs @@ -0,0 +1,299 @@ +using AgroBase.Forms.IHM.Controls; +using AgroBase.Forms.IHM.Controls.Operacao; +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros.Controls +{ + public enum HmiSliderValueFormat + { + PercentAndSpeed = 0, + PercentOnly = 1, + Degrees = 2 + } + + [DefaultEvent("ValueChanged")] + public class HmiParameterSliderRow : UserControl + { + private readonly Label _lblTitulo; + private readonly Label _lblValor; + private readonly Label _lblLimiteMin; + private readonly Label _lblLimiteMax; + private readonly HmiSlider _slider; + + private double _velocidadeMaximaKmh = 1.0D; + private HmiSliderValueFormat _valueFormat = HmiSliderValueFormat.PercentAndSpeed; + + private readonly TableLayoutPanel _root; + private bool _compactMode; + + public event EventHandler ValueChanged; + + public HmiParameterSliderRow() + { + DoubleBuffered = true; + BackColor = HmiTheme.SurfaceRaised; + Margin = new Padding(3); + Padding = new Padding(10, 6, 10, 5); + MinimumSize = new Size(250, 86); + + _root = new TableLayoutPanel + { + Dock = DockStyle.Fill, + ColumnCount = 2, + RowCount = 3, + BackColor = Color.Transparent, + Margin = Padding.Empty, + Padding = Padding.Empty + }; + + _root.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 58F)); + _root.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 42F)); + _root.RowStyles.Add(new RowStyle(SizeType.Absolute, 26F)); + _root.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + _root.RowStyles.Add(new RowStyle(SizeType.Absolute, 18F)); + + _lblTitulo = new Label + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + ForeColor = HmiTheme.Text, + Font = new Font("Segoe UI", 8.5F, FontStyle.Bold), + Text = "Valor", + TextAlign = ContentAlignment.MiddleLeft, + AutoEllipsis = true, + Margin = Padding.Empty + }; + + _lblValor = new Label + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + ForeColor = HmiTheme.Success, + Font = new Font("Segoe UI", 9.5F, FontStyle.Bold), + Text = "50%", + TextAlign = ContentAlignment.MiddleRight, + AutoEllipsis = true, + Margin = Padding.Empty + }; + + _slider = new HmiSlider + { + Dock = DockStyle.Fill, + Margin = new Padding(0, 3, 0, 2), + Minimum = 0, + Maximum = 100, + Value = 50, + AccentColor = HmiTheme.Success + }; + + _lblLimiteMin = new Label + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + ForeColor = HmiTheme.TextMuted, + Font = new Font("Segoe UI", 6.5F), + Text = "0%", + TextAlign = ContentAlignment.MiddleLeft, + Margin = Padding.Empty + }; + + _lblLimiteMax = new Label + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + ForeColor = HmiTheme.TextMuted, + Font = new Font("Segoe UI", 6.5F), + Text = "100%", + TextAlign = ContentAlignment.MiddleRight, + Margin = Padding.Empty + }; + + _root.Controls.Add(_lblTitulo, 0, 0); + _root.Controls.Add(_lblValor, 1, 0); + _root.Controls.Add(_slider, 0, 1); + _root.SetColumnSpan(_slider, 2); + _root.Controls.Add(_lblLimiteMin, 0, 2); + _root.Controls.Add(_lblLimiteMax, 1, 2); + + Controls.Add(_root); + + _slider.ValueChanged += Slider_ValueChanged; + AtualizarTextoValor(); + } + + private void Slider_ValueChanged(object sender, EventArgs e) + { + AtualizarTextoValor(); + + if (ValueChanged != null) + ValueChanged(this, EventArgs.Empty); + } + + private void AtualizarTextoValor() + { + if (_valueFormat == HmiSliderValueFormat.Degrees) + { + _lblValor.Text = _slider.Value + "°"; + _lblLimiteMin.Text = _slider.Minimum + "°"; + _lblLimiteMax.Text = _slider.Maximum + "°"; + return; + } + + if (_valueFormat == HmiSliderValueFormat.PercentOnly) + { + _lblValor.Text = _slider.Value + "%"; + _lblLimiteMin.Text = _slider.Minimum + "%"; + _lblLimiteMax.Text = _slider.Maximum + "%"; + return; + } + + double kmh = _velocidadeMaximaKmh * _slider.Value / 100D; + _lblValor.Text = string.Format("{0}% · {1:0.0} km/h", _slider.Value, kmh); + _lblLimiteMin.Text = _slider.Minimum + "%"; + _lblLimiteMax.Text = _slider.Maximum + "%"; + } + + [Category("Conteúdo")] + public string Titulo + { + get { return _lblTitulo.Text; } + set { _lblTitulo.Text = value ?? string.Empty; } + } + + [Category("Dados")] + public int Minimum + { + get { return _slider.Minimum; } + set + { + _slider.Minimum = value; + AtualizarTextoValor(); + } + } + + [Category("Dados")] + public int Maximum + { + get { return _slider.Maximum; } + set + { + _slider.Maximum = value; + AtualizarTextoValor(); + } + } + + [Category("Dados")] + public int Value + { + get { return _slider.Value; } + set { _slider.Value = value; } + } + + [Category("Dados")] + public double VelocidadeMaximaKmh + { + get { return _velocidadeMaximaKmh; } + set + { + _velocidadeMaximaKmh = Math.Max(0D, value); + AtualizarTextoValor(); + } + } + + [Category("Aparência")] + [DefaultValue(HmiSliderValueFormat.PercentAndSpeed)] + public HmiSliderValueFormat ValueFormat + { + get { return _valueFormat; } + set + { + _valueFormat = value; + AtualizarTextoValor(); + } + } + + [Category("Aparência")] + public Color AccentColor + { + get { return _slider.AccentColor; } + set + { + _slider.AccentColor = value; + _lblValor.ForeColor = value; + } + } + + [Category("Aparência")] + [DefaultValue(false)] + public bool CompactMode + { + get { return _compactMode; } + set + { + if (_compactMode == value) + return; + + _compactMode = value; + AtualizarModoCompacto(); + } + } + + [Browsable(false)] + public HmiSlider Slider + { + get { return _slider; } + } + + private void AtualizarModoCompacto() + { + if (_compactMode) + { + MinimumSize = new Size(80, 44); + Padding = new Padding(8, 3, 8, 3); + + _root.RowStyles[0].Height = 20F; + _root.RowStyles[1].SizeType = SizeType.Percent; + _root.RowStyles[1].Height = 100F; + _root.RowStyles[2].Height = 0F; + + _lblLimiteMin.Visible = false; + _lblLimiteMax.Visible = false; + + _lblTitulo.Font = new Font("Segoe UI", 7.4F, FontStyle.Bold); + + _lblValor.Font = new Font("Segoe UI", 7.8F, FontStyle.Bold); + + _slider.Margin = new Padding(0); + _slider.ThumbRadius = 6; + _slider.TrackHeight = 4; + } + else + { + MinimumSize = new Size(250, 86); + Padding = new Padding(10, 6, 10, 5); + + _root.RowStyles[0].Height = 26F; + _root.RowStyles[1].SizeType = SizeType.Percent; + _root.RowStyles[1].Height = 100F; + _root.RowStyles[2].Height = 18F; + + _lblLimiteMin.Visible = true; + _lblLimiteMax.Visible = true; + + _lblTitulo.Font = new Font("Segoe UI", 8.5F, FontStyle.Bold); + + _lblValor.Font = new Font("Segoe UI", 9.5F, FontStyle.Bold); + + _slider.Margin = new Padding(0, 3, 0, 2); + _slider.ThumbRadius = 8; + _slider.TrackHeight = 5; + } + + PerformLayout(); + Invalidate(); + } + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Controls/HmiWheelStatusCard.cs b/AgroBase/AgroBase/Forms/IHM/Controls/HmiWheelStatusCard.cs index 6601f6ade..e0e6e9481 100644 --- a/AgroBase/AgroBase/Forms/IHM/Controls/HmiWheelStatusCard.cs +++ b/AgroBase/AgroBase/Forms/IHM/Controls/HmiWheelStatusCard.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; +using static AgroBase.Models.Enums; namespace AgroBase.Forms.IHM.Controls.Operacao { @@ -330,6 +331,28 @@ namespace AgroBase.Forms.IHM.Controls.Operacao return check; } + public void AtualizarDados( + bool dir_em_uso, + double dir_ang_sp, + double dir_ang_at, + Sentido dir_sentido, + bool mov_em_uso, + double mov_vel_sp, + double mov_vel_at, + bool mov_freio + ) + { + CheckDir.Checked = dir_em_uso; + DirecionalSp = $"{dir_ang_sp}"; + DirecionalAtual = $"{dir_ang_at}"; + StatusDirecional = $"{dir_sentido}"; + + CheckMov.Checked = mov_em_uso; + MovimentoSp = $"{mov_vel_sp}"; + MovimentoAtual = $"{mov_vel_at}"; + StatusMovimento = mov_freio ? "Freado" : "Livre"; + } + protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosAtuador.Designer.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosAtuador.Designer.cs new file mode 100644 index 000000000..43b48e431 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosAtuador.Designer.cs @@ -0,0 +1,336 @@ +namespace AgroBase.Forms.IHM.Operacao.Parametros +{ + partial class ucParametrosAtuador + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && components != null) components.Dispose(); + base.Dispose(disposing); + } + + #region Component Designer generated code + + private void InitializeComponent() + { + this.rootLayout = new System.Windows.Forms.TableLayoutPanel(); + this.pnlAgitador = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.agitadorLayout = new System.Windows.Forms.TableLayoutPanel(); + this.lblAgitadorTitulo = new System.Windows.Forms.Label(); + this.lblAgitadorDescricao = new System.Windows.Forms.Label(); + this.seletorModoAgitador = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiAgitatorModeSelector(); + this.pidLayout = new System.Windows.Forms.TableLayoutPanel(); + this.paramKp = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.paramKi = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.paramKd = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.pnlPulverizacao = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.pulverizacaoLayout = new System.Windows.Forms.TableLayoutPanel(); + this.lblPulverizacaoTitulo = new System.Windows.Forms.Label(); + this.lblPulverizacaoDescricao = new System.Windows.Forms.Label(); + this.parametrosLayout = new System.Windows.Forms.TableLayoutPanel(); + this.paramBicosEmUso = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.paramPressaoLinha = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.paramInicioTela = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.paramAlturaArea = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.paramErvasOn = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.paramErvasOff = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField(); + this.rootLayout.SuspendLayout(); + this.pnlAgitador.SuspendLayout(); + this.agitadorLayout.SuspendLayout(); + this.pidLayout.SuspendLayout(); + this.pnlPulverizacao.SuspendLayout(); + this.pulverizacaoLayout.SuspendLayout(); + this.parametrosLayout.SuspendLayout(); + this.SuspendLayout(); + // + // rootLayout + // + this.rootLayout.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Background; + this.rootLayout.ColumnCount = 2; + this.rootLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.rootLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60F)); + this.rootLayout.Controls.Add(this.pnlAgitador, 0, 0); + this.rootLayout.Controls.Add(this.pnlPulverizacao, 1, 0); + this.rootLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.rootLayout.Location = new System.Drawing.Point(0, 0); + this.rootLayout.Margin = System.Windows.Forms.Padding.Empty; + this.rootLayout.Name = "rootLayout"; + this.rootLayout.Padding = System.Windows.Forms.Padding.Empty; + this.rootLayout.RowCount = 1; + this.rootLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.rootLayout.Size = new System.Drawing.Size(760, 286); + this.rootLayout.TabIndex = 0; + // + // pnlAgitador + // + ConfigurePanel(this.pnlAgitador, this.agitadorLayout); + this.pnlAgitador.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); + this.pnlAgitador.Name = "pnlAgitador"; + // + // agitadorLayout + // + this.agitadorLayout.ColumnCount = 1; + this.agitadorLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.agitadorLayout.Controls.Add(this.lblAgitadorTitulo, 0, 0); + this.agitadorLayout.Controls.Add(this.lblAgitadorDescricao, 0, 1); + this.agitadorLayout.Controls.Add(this.seletorModoAgitador, 0, 2); + this.agitadorLayout.Controls.Add(this.pidLayout, 0, 3); + this.agitadorLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.agitadorLayout.Location = new System.Drawing.Point(8, 8); + this.agitadorLayout.Margin = new System.Windows.Forms.Padding(0); + this.agitadorLayout.Name = "agitadorLayout"; + this.agitadorLayout.Padding = System.Windows.Forms.Padding.Empty; + this.agitadorLayout.RowCount = 4; + this.agitadorLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F)); + this.agitadorLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 34F)); + this.agitadorLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F)); + this.agitadorLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.agitadorLayout.Size = new System.Drawing.Size(282, 270); + this.agitadorLayout.TabIndex = 0; + // + // lblAgitadorTitulo + // + SetupSectionTitle(this.lblAgitadorTitulo, "AGITADOR DE CALDA"); + this.lblAgitadorTitulo.Name = "lblAgitadorTitulo"; + // + // lblAgitadorDescricao + // + SetupSectionDescription(this.lblAgitadorDescricao, "Selecione o modo e ajuste os ganhos PID usados no controle do agitador."); + this.lblAgitadorDescricao.Name = "lblAgitadorDescricao"; + // + // seletorModoAgitador + // + this.seletorModoAgitador.Dock = System.Windows.Forms.DockStyle.Fill; + this.seletorModoAgitador.Location = new System.Drawing.Point(0, 63); + this.seletorModoAgitador.Margin = new System.Windows.Forms.Padding(0, 3, 0, 5); + this.seletorModoAgitador.MinimumSize = new System.Drawing.Size(0, 40); + this.seletorModoAgitador.Name = "seletorModoAgitador"; + this.seletorModoAgitador.SelectedMode = "Continuo"; + this.seletorModoAgitador.Size = new System.Drawing.Size(282, 42); + this.seletorModoAgitador.TabIndex = 2; + // + // pidLayout + // + this.pidLayout.BackColor = System.Drawing.Color.Transparent; + this.pidLayout.ColumnCount = 1; + this.pidLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.pidLayout.Controls.Add(this.paramKp, 0, 0); + this.pidLayout.Controls.Add(this.paramKi, 0, 1); + this.pidLayout.Controls.Add(this.paramKd, 0, 2); + this.pidLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.pidLayout.Location = new System.Drawing.Point(0, 110); + this.pidLayout.Margin = new System.Windows.Forms.Padding(0); + this.pidLayout.Name = "pidLayout"; + this.pidLayout.Padding = System.Windows.Forms.Padding.Empty; + this.pidLayout.RowCount = 3; + this.pidLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); + this.pidLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); + this.pidLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.34F)); + this.pidLayout.Size = new System.Drawing.Size(282, 160); + this.pidLayout.TabIndex = 3; + // + // paramKp + // + SetupNumeric(this.paramKp, "Kp", "", 1.10M, 0M, 20M, 0.05M, 2); + this.paramKp.Margin = new System.Windows.Forms.Padding(0, 2, 0, 4); + this.paramKp.Name = "paramKp"; + // + // paramKi + // + SetupNumeric(this.paramKi, "Ki", "", 0.12M, 0M, 20M, 0.01M, 2); + this.paramKi.Margin = new System.Windows.Forms.Padding(0, 2, 0, 4); + this.paramKi.Name = "paramKi"; + // + // paramKd + // + SetupNumeric(this.paramKd, "Kd", "", 0.03M, 0M, 20M, 0.01M, 2); + this.paramKd.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0); + this.paramKd.Name = "paramKd"; + // + // pnlPulverizacao + // + ConfigurePanel(this.pnlPulverizacao, this.pulverizacaoLayout); + this.pnlPulverizacao.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0); + this.pnlPulverizacao.Name = "pnlPulverizacao"; + // + // pulverizacaoLayout + // + this.pulverizacaoLayout.ColumnCount = 1; + this.pulverizacaoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.pulverizacaoLayout.Controls.Add(this.lblPulverizacaoTitulo, 0, 0); + this.pulverizacaoLayout.Controls.Add(this.lblPulverizacaoDescricao, 0, 1); + this.pulverizacaoLayout.Controls.Add(this.parametrosLayout, 0, 2); + this.pulverizacaoLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.pulverizacaoLayout.Location = new System.Drawing.Point(8, 8); + this.pulverizacaoLayout.Margin = new System.Windows.Forms.Padding(0); + this.pulverizacaoLayout.Name = "pulverizacaoLayout"; + this.pulverizacaoLayout.Padding = System.Windows.Forms.Padding.Empty; + this.pulverizacaoLayout.RowCount = 3; + this.pulverizacaoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F)); + this.pulverizacaoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 34F)); + this.pulverizacaoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.pulverizacaoLayout.Size = new System.Drawing.Size(434, 270); + this.pulverizacaoLayout.TabIndex = 0; + // + // lblPulverizacaoTitulo + // + SetupSectionTitle(this.lblPulverizacaoTitulo, "PULVERIZAÇÃO E WEED WORKER"); + this.lblPulverizacaoTitulo.Name = "lblPulverizacaoTitulo"; + // + // lblPulverizacaoDescricao + // + SetupSectionDescription(this.lblPulverizacaoDescricao, "Defina os recursos da operação e os limites da região de atuação de cada bico."); + this.lblPulverizacaoDescricao.Name = "lblPulverizacaoDescricao"; + // + // parametrosLayout + // + this.parametrosLayout.BackColor = System.Drawing.Color.Transparent; + this.parametrosLayout.ColumnCount = 2; + this.parametrosLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.parametrosLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.parametrosLayout.Controls.Add(this.paramBicosEmUso, 0, 0); + this.parametrosLayout.Controls.Add(this.paramPressaoLinha, 1, 0); + this.parametrosLayout.Controls.Add(this.paramInicioTela, 0, 1); + this.parametrosLayout.Controls.Add(this.paramAlturaArea, 1, 1); + this.parametrosLayout.Controls.Add(this.paramErvasOn, 0, 2); + this.parametrosLayout.Controls.Add(this.paramErvasOff, 1, 2); + this.parametrosLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.parametrosLayout.Location = new System.Drawing.Point(0, 60); + this.parametrosLayout.Margin = new System.Windows.Forms.Padding(0); + this.parametrosLayout.Name = "parametrosLayout"; + this.parametrosLayout.Padding = System.Windows.Forms.Padding.Empty; + this.parametrosLayout.RowCount = 3; + this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); + this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); + this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.34F)); + this.parametrosLayout.Size = new System.Drawing.Size(434, 210); + this.parametrosLayout.TabIndex = 2; + // + // paramBicosEmUso + // + SetupNumeric(this.paramBicosEmUso, "Bicos em uso", "", 7M, 1M, 12M, 1M, 0); + this.paramBicosEmUso.Margin = new System.Windows.Forms.Padding(2, 2, 4, 4); + this.paramBicosEmUso.Name = "paramBicosEmUso"; + // + // paramPressaoLinha + // + SetupNumeric(this.paramPressaoLinha, "Pressão da linha", "psi", 18M, 0M, 120M, 1M, 0); + this.paramPressaoLinha.Margin = new System.Windows.Forms.Padding(4, 2, 2, 4); + this.paramPressaoLinha.Name = "paramPressaoLinha"; + // + // paramInicioTela + // + SetupNumeric(this.paramInicioTela, "Início da atuação", "%", 85M, 0M, 100M, 1M, 0); + this.paramInicioTela.Margin = new System.Windows.Forms.Padding(2, 2, 4, 4); + this.paramInicioTela.Name = "paramInicioTela"; + // + // paramAlturaArea + // + SetupNumeric(this.paramAlturaArea, "Altura da área", "%", 15M, 1M, 100M, 1M, 0); + this.paramAlturaArea.Margin = new System.Windows.Forms.Padding(4, 2, 2, 4); + this.paramAlturaArea.Name = "paramAlturaArea"; + // + // paramErvasOn + // + SetupNumeric(this.paramErvasOn, "Ervas para ligar", "%", 25.0M, 0M, 100M, 0.5M, 1); + this.paramErvasOn.Margin = new System.Windows.Forms.Padding(2, 2, 4, 0); + this.paramErvasOn.Name = "paramErvasOn"; + // + // paramErvasOff + // + SetupNumeric(this.paramErvasOff, "Ervas para desligar", "%", 15.0M, 0M, 100M, 0.5M, 1); + this.paramErvasOff.Margin = new System.Windows.Forms.Padding(4, 2, 2, 0); + this.paramErvasOff.Name = "paramErvasOff"; + // + // ucParametrosAtuador + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Background; + this.Controls.Add(this.rootLayout); + this.DoubleBuffered = true; + this.Margin = new System.Windows.Forms.Padding(0); + this.Name = "ucParametrosAtuador"; + this.Size = new System.Drawing.Size(760, 286); + this.rootLayout.ResumeLayout(false); + this.pnlAgitador.ResumeLayout(false); + this.agitadorLayout.ResumeLayout(false); + this.pidLayout.ResumeLayout(false); + this.pnlPulverizacao.ResumeLayout(false); + this.pulverizacaoLayout.ResumeLayout(false); + this.parametrosLayout.ResumeLayout(false); + this.ResumeLayout(false); + } + + private static void ConfigurePanel(AgroBase.Forms.IHM.Controls.HmiRoundedPanel panel, System.Windows.Forms.Control child) + { + panel.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; + panel.Controls.Add(child); + panel.CornerRadius = 9; + panel.Dock = System.Windows.Forms.DockStyle.Fill; + panel.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.Surface; + panel.Padding = new System.Windows.Forms.Padding(8); + } + + private static void SetupSectionTitle(System.Windows.Forms.Label label, string text) + { + label.AutoEllipsis = true; + label.BackColor = System.Drawing.Color.Transparent; + label.Dock = System.Windows.Forms.DockStyle.Fill; + label.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + label.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.Text; + label.Margin = System.Windows.Forms.Padding.Empty; + label.Text = text; + label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + } + + private static void SetupSectionDescription(System.Windows.Forms.Label label, string text) + { + label.AutoEllipsis = true; + label.BackColor = System.Drawing.Color.Transparent; + label.Dock = System.Windows.Forms.DockStyle.Fill; + label.Font = new System.Drawing.Font("Segoe UI", 7F); + label.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; + label.Margin = System.Windows.Forms.Padding.Empty; + label.Text = text; + label.TextAlign = System.Drawing.ContentAlignment.TopLeft; + } + + private static void SetupNumeric(AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField field, string title, string unit, decimal value, decimal minimum, decimal maximum, decimal increment, int decimalPlaces) + { + field.Dock = System.Windows.Forms.DockStyle.Fill; + field.MinimumSize = new System.Drawing.Size(0, 60); + field.Titulo = title; + field.Unidade = unit; + field.Minimum = minimum; + field.Maximum = maximum; + field.Increment = increment; + field.DecimalPlaces = decimalPlaces; + field.Value = value; + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel rootLayout; + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlAgitador; + private System.Windows.Forms.TableLayoutPanel agitadorLayout; + private System.Windows.Forms.Label lblAgitadorTitulo; + private System.Windows.Forms.Label lblAgitadorDescricao; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiAgitatorModeSelector seletorModoAgitador; + private System.Windows.Forms.TableLayoutPanel pidLayout; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramKp; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramKi; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramKd; + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlPulverizacao; + private System.Windows.Forms.TableLayoutPanel pulverizacaoLayout; + private System.Windows.Forms.Label lblPulverizacaoTitulo; + private System.Windows.Forms.Label lblPulverizacaoDescricao; + private System.Windows.Forms.TableLayoutPanel parametrosLayout; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramBicosEmUso; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramPressaoLinha; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramInicioTela; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramAlturaArea; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramErvasOn; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramErvasOff; + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosAtuador.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosAtuador.cs new file mode 100644 index 000000000..3ae00ed89 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosAtuador.cs @@ -0,0 +1,116 @@ +using System; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros +{ + public partial class ucParametrosAtuador : UserControl + { + public event EventHandler ParametrosAlterados; + + public ucParametrosAtuador() + { + InitializeComponent(); + ConfigurarEstadoInicial(); + VincularEventos(); + } + + private void ConfigurarEstadoInicial() + { + seletorModoAgitador.SelectedMode = "Continuo"; + + paramKp.Value = 1.00M; + paramKi.Value = 0.10M; + paramKd.Value = 0.00M; + + paramBicosEmUso.Value = 7M; + paramPressaoLinha.Value = 18M; + + paramInicioTela.Value = 85M; + paramAlturaArea.Value = 15M; + paramErvasOn.Value = 25M; + paramErvasOff.Value = 15M; + } + + private void VincularEventos() + { + seletorModoAgitador.SelectedModeChanged += Controle_Alterado; + + paramKp.ValueChanged += Controle_Alterado; + paramKi.ValueChanged += Controle_Alterado; + paramKd.ValueChanged += Controle_Alterado; + + paramBicosEmUso.ValueChanged += Controle_Alterado; + paramPressaoLinha.ValueChanged += Controle_Alterado; + paramInicioTela.ValueChanged += Controle_Alterado; + paramAlturaArea.ValueChanged += Controle_Alterado; + paramErvasOn.ValueChanged += Controle_Alterado; + paramErvasOff.ValueChanged += Controle_Alterado; + } + + private void Controle_Alterado(object sender, EventArgs e) + { + if (ParametrosAlterados != null) + ParametrosAlterados(this, EventArgs.Empty); + } + + public string ModoAgitador + { + get { return seletorModoAgitador.SelectedMode; } + set { seletorModoAgitador.SelectedMode = value; } + } + + public decimal KpAgitador + { + get { return paramKp.Value; } + set { paramKp.Value = value; } + } + + public decimal KiAgitador + { + get { return paramKi.Value; } + set { paramKi.Value = value; } + } + + public decimal KdAgitador + { + get { return paramKd.Value; } + set { paramKd.Value = value; } + } + + public int QuantidadeBicosEmUso + { + get { return Convert.ToInt32(paramBicosEmUso.Value); } + set { paramBicosEmUso.Value = value; } + } + + public decimal PressaoLinhaPsi + { + get { return paramPressaoLinha.Value; } + set { paramPressaoLinha.Value = value; } + } + + public int PercentualInicioTela + { + get { return Convert.ToInt32(paramInicioTela.Value); } + set { paramInicioTela.Value = value; } + } + + public int PercentualAlturaArea + { + get { return Convert.ToInt32(paramAlturaArea.Value); } + set { paramAlturaArea.Value = value; } + } + + public decimal PercentualErvasOn + { + get { return paramErvasOn.Value; } + set { paramErvasOn.Value = value; } + } + + public decimal PercentualErvasOff + { + get { return paramErvasOff.Value; } + set { paramErvasOff.Value = value; } + } + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosDirecional.Designer.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosDirecional.Designer.cs new file mode 100644 index 000000000..f86d086e5 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosDirecional.Designer.cs @@ -0,0 +1,299 @@ +namespace AgroBase.Forms.IHM.Operacao.Parametros +{ + partial class ucParametrosDirecional + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && components != null) + components.Dispose(); + + base.Dispose(disposing); + } + + #region Component Designer generated code + + private void InitializeComponent() + { + this.rootLayout = new System.Windows.Forms.TableLayoutPanel(); + + this.pnlAssistencias = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.assistenciasLayout = new System.Windows.Forms.TableLayoutPanel(); + this.lblAssistenciasTitulo = new System.Windows.Forms.Label(); + this.lblAssistenciasDescricao = new System.Windows.Forms.Label(); + this.checksLayout = new System.Windows.Forms.TableLayoutPanel(); + this.checkDirecionalAutomatico = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.checkAssistidoSonar = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.checkAssistidoImu = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.checkImuPrefereArco = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + + this.pnlControle = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.controleLayout = new System.Windows.Forms.TableLayoutPanel(); + this.lblControleTitulo = new System.Windows.Forms.Label(); + this.lblControleDescricao = new System.Windows.Forms.Label(); + this.sliderAnguloMaximo = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow(); + this.sliderVelocidadeDirecional = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow(); + + this.pnlNavegacao = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.navegacaoLayout = new System.Windows.Forms.TableLayoutPanel(); + this.lblNavegacaoTitulo = new System.Windows.Forms.Label(); + this.seletorModoControle = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiModeSelector(); + this.parametroHorizonte = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiNumericParameterCard(); + this.parametroDistanciaSaida = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiNumericParameterCard(); + + this.rootLayout.SuspendLayout(); + this.pnlAssistencias.SuspendLayout(); + this.assistenciasLayout.SuspendLayout(); + this.checksLayout.SuspendLayout(); + this.pnlControle.SuspendLayout(); + this.controleLayout.SuspendLayout(); + this.pnlNavegacao.SuspendLayout(); + this.navegacaoLayout.SuspendLayout(); + this.SuspendLayout(); + + // rootLayout + this.rootLayout.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Background; + this.rootLayout.ColumnCount = 2; + this.rootLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 42F)); + this.rootLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 58F)); + this.rootLayout.Controls.Add(this.pnlAssistencias, 0, 0); + this.rootLayout.Controls.Add(this.pnlControle, 1, 0); + this.rootLayout.Controls.Add(this.pnlNavegacao, 0, 1); + this.rootLayout.SetColumnSpan(this.pnlNavegacao, 2); + this.rootLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.rootLayout.Margin = System.Windows.Forms.Padding.Empty; + this.rootLayout.Padding = System.Windows.Forms.Padding.Empty; + this.rootLayout.RowCount = 2; + this.rootLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 58F)); + this.rootLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 42F)); + + // Assistências + ConfigurePanel(this.pnlAssistencias, this.assistenciasLayout); + this.pnlAssistencias.Margin = new System.Windows.Forms.Padding(0, 0, 3, 3); + this.pnlAssistencias.Padding = new System.Windows.Forms.Padding(8); + + this.assistenciasLayout.ColumnCount = 1; + this.assistenciasLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.assistenciasLayout.Controls.Add(this.lblAssistenciasTitulo, 0, 0); + this.assistenciasLayout.Controls.Add(this.lblAssistenciasDescricao, 0, 1); + this.assistenciasLayout.Controls.Add(this.checksLayout, 0, 2); + this.assistenciasLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.assistenciasLayout.Margin = System.Windows.Forms.Padding.Empty; + this.assistenciasLayout.Padding = System.Windows.Forms.Padding.Empty; + this.assistenciasLayout.RowCount = 3; + this.assistenciasLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F)); + this.assistenciasLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F)); + this.assistenciasLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + + SetupSectionTitle(this.lblAssistenciasTitulo, "AUTOMAÇÃO E ASSISTÊNCIAS"); + SetupSectionDescription(this.lblAssistenciasDescricao, "Defina quais recursos podem interferir no controle direcional."); + + this.checksLayout.BackColor = System.Drawing.Color.Transparent; + this.checksLayout.ColumnCount = 2; + this.checksLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.checksLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.checksLayout.Controls.Add(this.checkDirecionalAutomatico, 0, 0); + this.checksLayout.Controls.Add(this.checkAssistidoSonar, 1, 0); + this.checksLayout.Controls.Add(this.checkAssistidoImu, 0, 1); + this.checksLayout.Controls.Add(this.checkImuPrefereArco, 1, 1); + this.checksLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.checksLayout.Margin = System.Windows.Forms.Padding.Empty; + this.checksLayout.Padding = System.Windows.Forms.Padding.Empty; + this.checksLayout.RowCount = 2; + this.checksLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.checksLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + + SetupCheck(this.checkDirecionalAutomatico, "Direcional automático"); + SetupCheck(this.checkAssistidoSonar, "Assistido por sonar"); + SetupCheck(this.checkAssistidoImu, "Assistido por IMU"); + SetupCheck(this.checkImuPrefereArco, "IMU prefere arco"); + + // Controle direcional + ConfigurePanel(this.pnlControle, this.controleLayout); + this.pnlControle.Margin = new System.Windows.Forms.Padding(3, 0, 0, 3); + this.pnlControle.Padding = new System.Windows.Forms.Padding(8); + + this.controleLayout.ColumnCount = 2; + this.controleLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.controleLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.controleLayout.Controls.Add(this.lblControleTitulo, 0, 0); + this.controleLayout.SetColumnSpan(this.lblControleTitulo, 2); + this.controleLayout.Controls.Add(this.lblControleDescricao, 0, 1); + this.controleLayout.SetColumnSpan(this.lblControleDescricao, 2); + this.controleLayout.Controls.Add(this.sliderAnguloMaximo, 0, 2); + this.controleLayout.Controls.Add(this.sliderVelocidadeDirecional, 1, 2); + this.controleLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.controleLayout.Margin = System.Windows.Forms.Padding.Empty; + this.controleLayout.Padding = System.Windows.Forms.Padding.Empty; + this.controleLayout.RowCount = 3; + this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F)); + this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F)); + this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + + SetupSectionTitle(this.lblControleTitulo, "LIMITES DO DIRECIONAL"); + SetupSectionDescription(this.lblControleDescricao, "Ajuste o ângulo máximo e a velocidade usada pelos motores de passo."); + + this.sliderAnguloMaximo.Dock = System.Windows.Forms.DockStyle.Fill; + this.sliderAnguloMaximo.Margin = new System.Windows.Forms.Padding(0, 2, 3, 0); + this.sliderAnguloMaximo.MinimumSize = System.Drawing.Size.Empty; + this.sliderAnguloMaximo.Titulo = "Ângulo máximo"; + this.sliderAnguloMaximo.Minimum = 0; + this.sliderAnguloMaximo.Maximum = 90; + this.sliderAnguloMaximo.ValueFormat = AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiSliderValueFormat.Degrees; + this.sliderAnguloMaximo.Value = 45; + this.sliderAnguloMaximo.AccentColor = AgroBase.Forms.IHM.Controls.HmiTheme.Warning; + + this.sliderVelocidadeDirecional.Dock = System.Windows.Forms.DockStyle.Fill; + this.sliderVelocidadeDirecional.Margin = new System.Windows.Forms.Padding(3, 2, 0, 0); + this.sliderVelocidadeDirecional.MinimumSize = System.Drawing.Size.Empty; + this.sliderVelocidadeDirecional.Titulo = "Velocidade direcional"; + this.sliderVelocidadeDirecional.Minimum = 0; + this.sliderVelocidadeDirecional.Maximum = 100; + this.sliderVelocidadeDirecional.ValueFormat = AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiSliderValueFormat.PercentOnly; + this.sliderVelocidadeDirecional.Value = 60; + this.sliderVelocidadeDirecional.AccentColor = AgroBase.Forms.IHM.Controls.HmiTheme.Info; + + // Controle e navegação + ConfigurePanel(this.pnlNavegacao, this.navegacaoLayout); + this.pnlNavegacao.Margin = new System.Windows.Forms.Padding(0, 3, 0, 0); + this.pnlNavegacao.Padding = new System.Windows.Forms.Padding(8); + + this.navegacaoLayout.ColumnCount = 3; + this.navegacaoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.navegacaoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); + this.navegacaoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); + this.navegacaoLayout.Controls.Add(this.lblNavegacaoTitulo, 0, 0); + this.navegacaoLayout.SetColumnSpan(this.lblNavegacaoTitulo, 3); + this.navegacaoLayout.Controls.Add(this.seletorModoControle, 0, 1); + this.navegacaoLayout.Controls.Add(this.parametroHorizonte, 1, 1); + this.navegacaoLayout.Controls.Add(this.parametroDistanciaSaida, 2, 1); + this.navegacaoLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.navegacaoLayout.Margin = System.Windows.Forms.Padding.Empty; + this.navegacaoLayout.Padding = System.Windows.Forms.Padding.Empty; + this.navegacaoLayout.RowCount = 2; + this.navegacaoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22F)); + this.navegacaoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + + SetupSectionTitle(this.lblNavegacaoTitulo, "CONTROLE E NAVEGAÇÃO"); + + this.seletorModoControle.Dock = System.Windows.Forms.DockStyle.Fill; + this.seletorModoControle.Margin = new System.Windows.Forms.Padding(0, 1, 3, 0); + this.seletorModoControle.MinimumSize = System.Drawing.Size.Empty; + this.seletorModoControle.SelectedMode = "MPC"; + + this.parametroHorizonte.Dock = System.Windows.Forms.DockStyle.Fill; + this.parametroHorizonte.Margin = new System.Windows.Forms.Padding(3, 1, 3, 0); + this.parametroHorizonte.MinimumSize = System.Drawing.Size.Empty; + this.parametroHorizonte.Titulo = "Horizonte de predição"; + this.parametroHorizonte.Descricao = "Distância analisada pelo controlador"; + this.parametroHorizonte.Unidade = "m"; + this.parametroHorizonte.Minimum = 1M; + this.parametroHorizonte.Maximum = 30M; + this.parametroHorizonte.Increment = 0.5M; + this.parametroHorizonte.DecimalPlaces = 1; + this.parametroHorizonte.Value = 4M; + + this.parametroDistanciaSaida.Dock = System.Windows.Forms.DockStyle.Fill; + this.parametroDistanciaSaida.Margin = new System.Windows.Forms.Padding(3, 1, 0, 0); + this.parametroDistanciaSaida.MinimumSize = System.Drawing.Size.Empty; + this.parametroDistanciaSaida.Titulo = "Distância saída para manobra"; + this.parametroDistanciaSaida.Descricao = "Distância para iniciar a manobra entre ruas"; + this.parametroDistanciaSaida.Unidade = "m"; + this.parametroDistanciaSaida.Minimum = 0M; + this.parametroDistanciaSaida.Maximum = 20M; + this.parametroDistanciaSaida.Increment = 0.5M; + this.parametroDistanciaSaida.DecimalPlaces = 1; + this.parametroDistanciaSaida.Value = 5M; + + // ucParametrosDirecional + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Background; + this.Controls.Add(this.rootLayout); + this.DoubleBuffered = true; + this.Name = "ucParametrosDirecional"; + this.Size = new System.Drawing.Size(760, 286); + + this.rootLayout.ResumeLayout(false); + this.pnlAssistencias.ResumeLayout(false); + this.assistenciasLayout.ResumeLayout(false); + this.checksLayout.ResumeLayout(false); + this.pnlControle.ResumeLayout(false); + this.controleLayout.ResumeLayout(false); + this.pnlNavegacao.ResumeLayout(false); + this.navegacaoLayout.ResumeLayout(false); + this.ResumeLayout(false); + } + + private static void ConfigurePanel(AgroBase.Forms.IHM.Controls.HmiRoundedPanel panel, System.Windows.Forms.Control child) + { + panel.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; + panel.Controls.Add(child); + panel.CornerRadius = 9; + panel.Dock = System.Windows.Forms.DockStyle.Fill; + panel.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.Surface; + panel.Padding = new System.Windows.Forms.Padding(8); + } + + private static void SetupSectionTitle(System.Windows.Forms.Label label, string text) + { + label.AutoEllipsis = true; + label.BackColor = System.Drawing.Color.Transparent; + label.Dock = System.Windows.Forms.DockStyle.Fill; + label.Font = new System.Drawing.Font("Segoe UI", 8.5F, System.Drawing.FontStyle.Bold); + label.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.Text; + label.Margin = System.Windows.Forms.Padding.Empty; + label.Text = text; + label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + } + + private static void SetupSectionDescription(System.Windows.Forms.Label label, string text) + { + label.AutoEllipsis = true; + label.BackColor = System.Drawing.Color.Transparent; + label.Dock = System.Windows.Forms.DockStyle.Fill; + label.Font = new System.Drawing.Font("Segoe UI", 6.7F); + label.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; + label.Margin = System.Windows.Forms.Padding.Empty; + label.Text = text; + label.TextAlign = System.Drawing.ContentAlignment.TopLeft; + } + + private static void SetupCheck(AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow check, string title) + { + check.Dock = System.Windows.Forms.DockStyle.Fill; + check.Titulo = title; + check.Checked = true; + check.Margin = new System.Windows.Forms.Padding(3); + check.MinimumSize = System.Drawing.Size.Empty; + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel rootLayout; + + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlAssistencias; + private System.Windows.Forms.TableLayoutPanel assistenciasLayout; + private System.Windows.Forms.Label lblAssistenciasTitulo; + private System.Windows.Forms.Label lblAssistenciasDescricao; + private System.Windows.Forms.TableLayoutPanel checksLayout; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkDirecionalAutomatico; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkAssistidoSonar; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkAssistidoImu; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkImuPrefereArco; + + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlControle; + private System.Windows.Forms.TableLayoutPanel controleLayout; + private System.Windows.Forms.Label lblControleTitulo; + private System.Windows.Forms.Label lblControleDescricao; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow sliderAnguloMaximo; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow sliderVelocidadeDirecional; + + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlNavegacao; + private System.Windows.Forms.TableLayoutPanel navegacaoLayout; + private System.Windows.Forms.Label lblNavegacaoTitulo; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiModeSelector seletorModoControle; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiNumericParameterCard parametroHorizonte; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiNumericParameterCard parametroDistanciaSaida; + } +} \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosDirecional.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosDirecional.cs new file mode 100644 index 000000000..97cca2030 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosDirecional.cs @@ -0,0 +1,111 @@ +using System; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros +{ + public partial class ucParametrosDirecional : UserControl + { + public event EventHandler ParametrosAlterados; + + public ucParametrosDirecional() + { + InitializeComponent(); + ConfigurarEstadoInicial(); + VincularEventos(); + } + + private void ConfigurarEstadoInicial() + { + checkDirecionalAutomatico.Checked = true; + checkAssistidoSonar.Checked = true; + checkAssistidoImu.Checked = true; + checkImuPrefereArco.Checked = false; + + sliderAnguloMaximo.Value = 45; + sliderAnguloMaximo.VelocidadeMaximaKmh = 0D; + + sliderVelocidadeDirecional.Value = 60; + sliderVelocidadeDirecional.VelocidadeMaximaKmh = 0D; + + seletorModoControle.SelectedMode = "MPC"; + + parametroHorizonte.Value = 4M; + parametroDistanciaSaida.Value = 5M; + } + + private void VincularEventos() + { + checkDirecionalAutomatico.CheckedChanged += Controle_Alterado; + checkAssistidoSonar.CheckedChanged += Controle_Alterado; + checkAssistidoImu.CheckedChanged += Controle_Alterado; + checkImuPrefereArco.CheckedChanged += Controle_Alterado; + + sliderAnguloMaximo.ValueChanged += Controle_Alterado; + sliderVelocidadeDirecional.ValueChanged += Controle_Alterado; + + seletorModoControle.SelectedModeChanged += Controle_Alterado; + parametroHorizonte.ValueChanged += Controle_Alterado; + parametroDistanciaSaida.ValueChanged += Controle_Alterado; + } + + private void Controle_Alterado(object sender, EventArgs e) + { + if (ParametrosAlterados != null) + ParametrosAlterados(this, EventArgs.Empty); + } + + public bool DirecionalAutomatico + { + get { return checkDirecionalAutomatico.Checked; } + set { checkDirecionalAutomatico.Checked = value; } + } + + public bool AssistidoPorSonar + { + get { return checkAssistidoSonar.Checked; } + set { checkAssistidoSonar.Checked = value; } + } + + public bool AssistidoPorImu + { + get { return checkAssistidoImu.Checked; } + set { checkAssistidoImu.Checked = value; } + } + + public bool ImuPrefereArco + { + get { return checkImuPrefereArco.Checked; } + set { checkImuPrefereArco.Checked = value; } + } + + public int AnguloMaximo + { + get { return sliderAnguloMaximo.Value; } + set { sliderAnguloMaximo.Value = value; } + } + + public int VelocidadeDirecionalPercentual + { + get { return sliderVelocidadeDirecional.Value; } + set { sliderVelocidadeDirecional.Value = value; } + } + + public string ModoControle + { + get { return seletorModoControle.SelectedMode; } + set { seletorModoControle.SelectedMode = value; } + } + + public decimal HorizontePredicaoMetros + { + get { return parametroHorizonte.Value; } + set { parametroHorizonte.Value = value; } + } + + public decimal DistanciaSaidaCorredorMetros + { + get { return parametroDistanciaSaida.Value; } + set { parametroDistanciaSaida.Value = value; } + } + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMapa.Designer.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMapa.Designer.cs new file mode 100644 index 000000000..313b565d7 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMapa.Designer.cs @@ -0,0 +1,37 @@ +namespace AgroBase.Forms.IHM.Operacao.Parametros +{ + partial class ucParametrosMapa + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMapa.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMapa.cs new file mode 100644 index 000000000..3133c47b5 --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMapa.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros +{ + public partial class ucParametrosMapa : UserControl + { + public ucParametrosMapa() + { + InitializeComponent(); + } + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMovimento.Designer.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMovimento.Designer.cs new file mode 100644 index 000000000..ab42f797e --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMovimento.Designer.cs @@ -0,0 +1,217 @@ +namespace AgroBase.Forms.IHM.Operacao.Parametros +{ + partial class ucParametrosMovimento + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && components != null) + components.Dispose(); + + base.Dispose(disposing); + } + + #region Component Designer generated code + + private void InitializeComponent() + { + this.rootLayout = new System.Windows.Forms.TableLayoutPanel(); + this.pnlAutomacao = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.automacaoLayout = new System.Windows.Forms.TableLayoutPanel(); + this.lblAutomacaoTitulo = new System.Windows.Forms.Label(); + this.lblAutomacaoDescricao = new System.Windows.Forms.Label(); + this.checksLayout = new System.Windows.Forms.TableLayoutPanel(); + this.checkMovimentoAutomatico = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.checkAssistidoSonar = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.checkParadaObstaculo = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.checkAssistidoImu = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.checkParadaInclinacao = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.checkFrenagemParar = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow(); + this.pnlVelocidades = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.velocidadesLayout = new System.Windows.Forms.TableLayoutPanel(); + this.lblVelocidadesTitulo = new System.Windows.Forms.Label(); + this.lblVelocidadesDescricao = new System.Windows.Forms.Label(); + this.sliderSemErvas = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow(); + this.sliderComErvas = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow(); + + this.rootLayout.SuspendLayout(); + this.pnlAutomacao.SuspendLayout(); + this.automacaoLayout.SuspendLayout(); + this.checksLayout.SuspendLayout(); + this.pnlVelocidades.SuspendLayout(); + this.velocidadesLayout.SuspendLayout(); + this.SuspendLayout(); + + this.rootLayout.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Background; + this.rootLayout.ColumnCount = 2; + this.rootLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 45F)); + this.rootLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 55F)); + this.rootLayout.Controls.Add(this.pnlAutomacao, 0, 0); + this.rootLayout.Controls.Add(this.pnlVelocidades, 1, 0); + this.rootLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.rootLayout.Margin = System.Windows.Forms.Padding.Empty; + this.rootLayout.Padding = System.Windows.Forms.Padding.Empty; + this.rootLayout.RowCount = 1; + this.rootLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + + ConfigurePanel(this.pnlAutomacao, this.automacaoLayout); + this.pnlAutomacao.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); + + this.automacaoLayout.ColumnCount = 1; + this.automacaoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.automacaoLayout.Controls.Add(this.lblAutomacaoTitulo, 0, 0); + this.automacaoLayout.Controls.Add(this.lblAutomacaoDescricao, 0, 1); + this.automacaoLayout.Controls.Add(this.checksLayout, 0, 2); + this.automacaoLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.automacaoLayout.Margin = System.Windows.Forms.Padding.Empty; + this.automacaoLayout.Padding = System.Windows.Forms.Padding.Empty; + this.automacaoLayout.RowCount = 3; + this.automacaoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); + this.automacaoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F)); + this.automacaoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + + SetupSectionTitle(this.lblAutomacaoTitulo, "AUTOMAÇÃO E ASSISTÊNCIAS"); + SetupSectionDescription(this.lblAutomacaoDescricao, "Ative somente os recursos que devem participar do controle de movimento."); + + this.checksLayout.BackColor = System.Drawing.Color.Transparent; + this.checksLayout.ColumnCount = 2; + this.checksLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.checksLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.checksLayout.Controls.Add(this.checkMovimentoAutomatico, 0, 0); + this.checksLayout.Controls.Add(this.checkAssistidoSonar, 1, 0); + this.checksLayout.Controls.Add(this.checkParadaObstaculo, 0, 1); + this.checksLayout.Controls.Add(this.checkAssistidoImu, 1, 1); + this.checksLayout.Controls.Add(this.checkParadaInclinacao, 0, 2); + this.checksLayout.Controls.Add(this.checkFrenagemParar, 1, 2); + this.checksLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.checksLayout.Margin = System.Windows.Forms.Padding.Empty; + this.checksLayout.Padding = System.Windows.Forms.Padding.Empty; + this.checksLayout.RowCount = 3; + this.checksLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); + this.checksLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); + this.checksLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.34F)); + + SetupCheck(this.checkMovimentoAutomatico, "Movimento automático"); + SetupCheck(this.checkAssistidoSonar, "Assistido por sonar"); + SetupCheck(this.checkParadaObstaculo, "Parada por obstáculo"); + SetupCheck(this.checkAssistidoImu, "Assistido por IMU"); + SetupCheck(this.checkParadaInclinacao, "Parada por inclinação"); + SetupCheck(this.checkFrenagemParar, "Frenagem ao parar"); + + ConfigurePanel(this.pnlVelocidades, this.velocidadesLayout); + this.pnlVelocidades.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0); + + this.velocidadesLayout.ColumnCount = 1; + this.velocidadesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.velocidadesLayout.Controls.Add(this.lblVelocidadesTitulo, 0, 0); + this.velocidadesLayout.Controls.Add(this.lblVelocidadesDescricao, 0, 1); + this.velocidadesLayout.Controls.Add(this.sliderSemErvas, 0, 2); + this.velocidadesLayout.Controls.Add(this.sliderComErvas, 0, 3); + this.velocidadesLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.velocidadesLayout.Margin = System.Windows.Forms.Padding.Empty; + this.velocidadesLayout.Padding = System.Windows.Forms.Padding.Empty; + this.velocidadesLayout.RowCount = 4; + this.velocidadesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); + this.velocidadesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F)); + this.velocidadesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.velocidadesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + + SetupSectionTitle(this.lblVelocidadesTitulo, "LIMITES DE VELOCIDADE"); + SetupSectionDescription(this.lblVelocidadesDescricao, "A velocidade em km/h é calculada pelo percentual da velocidade máxima do equipamento."); + + this.sliderSemErvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.sliderSemErvas.Margin = new System.Windows.Forms.Padding(0, 2, 0, 3); + this.sliderSemErvas.Titulo = "Sem ervas no radar"; + this.sliderSemErvas.Value = 68; + this.sliderSemErvas.VelocidadeMaximaKmh = 5D; + this.sliderSemErvas.AccentColor = AgroBase.Forms.IHM.Controls.HmiTheme.Success; + + this.sliderComErvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.sliderComErvas.Margin = new System.Windows.Forms.Padding(0, 3, 0, 0); + this.sliderComErvas.Titulo = "Com ervas no radar"; + this.sliderComErvas.Value = 45; + this.sliderComErvas.VelocidadeMaximaKmh = 5D; + this.sliderComErvas.AccentColor = AgroBase.Forms.IHM.Controls.HmiTheme.Info; + + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Background; + this.Controls.Add(this.rootLayout); + this.DoubleBuffered = true; + this.Name = "ucParametrosMovimento"; + this.Size = new System.Drawing.Size(760, 286); + + this.rootLayout.ResumeLayout(false); + this.pnlAutomacao.ResumeLayout(false); + this.automacaoLayout.ResumeLayout(false); + this.checksLayout.ResumeLayout(false); + this.pnlVelocidades.ResumeLayout(false); + this.velocidadesLayout.ResumeLayout(false); + this.ResumeLayout(false); + } + + private static void ConfigurePanel(AgroBase.Forms.IHM.Controls.HmiRoundedPanel panel, System.Windows.Forms.Control child) + { + panel.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; + panel.Controls.Add(child); + panel.CornerRadius = 9; + panel.Dock = System.Windows.Forms.DockStyle.Fill; + panel.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.Surface; + panel.Padding = new System.Windows.Forms.Padding(10); + } + + private static void SetupSectionTitle(System.Windows.Forms.Label label, string text) + { + label.AutoEllipsis = true; + label.BackColor = System.Drawing.Color.Transparent; + label.Dock = System.Windows.Forms.DockStyle.Fill; + label.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + label.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.Text; + label.Margin = System.Windows.Forms.Padding.Empty; + label.Text = text; + label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + } + + private static void SetupSectionDescription(System.Windows.Forms.Label label, string text) + { + label.AutoEllipsis = true; + label.BackColor = System.Drawing.Color.Transparent; + label.Dock = System.Windows.Forms.DockStyle.Fill; + label.Font = new System.Drawing.Font("Segoe UI", 7F); + label.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; + label.Margin = System.Windows.Forms.Padding.Empty; + label.Text = text; + label.TextAlign = System.Drawing.ContentAlignment.TopLeft; + } + + private static void SetupCheck(AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow check, string title) + { + check.Dock = System.Windows.Forms.DockStyle.Fill; + check.Titulo = title; + check.Checked = true; + check.Margin = new System.Windows.Forms.Padding(3); + check.MinimumSize = System.Drawing.Size.Empty; + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel rootLayout; + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlAutomacao; + private System.Windows.Forms.TableLayoutPanel automacaoLayout; + private System.Windows.Forms.Label lblAutomacaoTitulo; + private System.Windows.Forms.Label lblAutomacaoDescricao; + private System.Windows.Forms.TableLayoutPanel checksLayout; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkMovimentoAutomatico; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkAssistidoSonar; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkParadaObstaculo; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkAssistidoImu; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkParadaInclinacao; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactCheckRow checkFrenagemParar; + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlVelocidades; + private System.Windows.Forms.TableLayoutPanel velocidadesLayout; + private System.Windows.Forms.Label lblVelocidadesTitulo; + private System.Windows.Forms.Label lblVelocidadesDescricao; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow sliderSemErvas; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow sliderComErvas; + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMovimento.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMovimento.cs new file mode 100644 index 000000000..a47e1923f --- /dev/null +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/Parametros/ucParametrosMovimento.cs @@ -0,0 +1,111 @@ +using AgroBase.Forms.IHM.Operacao.Parametros.Controls; +using System; +using System.Windows.Forms; + +namespace AgroBase.Forms.IHM.Operacao.Parametros +{ + public partial class ucParametrosMovimento : UserControl + { + public event EventHandler ParametrosAlterados; + + public ucParametrosMovimento() + { + InitializeComponent(); + ConfigurarEstadoInicial(); + VincularEventos(); + } + + private void ConfigurarEstadoInicial() + { + checkMovimentoAutomatico.Checked = true; + checkAssistidoSonar.Checked = true; + checkParadaObstaculo.Checked = true; + checkAssistidoImu.Checked = true; + checkParadaInclinacao.Checked = true; + checkFrenagemParar.Checked = true; + + sliderSemErvas.Value = 68; + sliderSemErvas.VelocidadeMaximaKmh = 5D; + + sliderComErvas.Value = 45; + sliderComErvas.VelocidadeMaximaKmh = 5D; + } + + private void VincularEventos() + { + checkMovimentoAutomatico.CheckedChanged += Controle_Alterado; + checkAssistidoSonar.CheckedChanged += Controle_Alterado; + checkParadaObstaculo.CheckedChanged += Controle_Alterado; + checkAssistidoImu.CheckedChanged += Controle_Alterado; + checkParadaInclinacao.CheckedChanged += Controle_Alterado; + checkFrenagemParar.CheckedChanged += Controle_Alterado; + + sliderSemErvas.ValueChanged += Controle_Alterado; + sliderComErvas.ValueChanged += Controle_Alterado; + } + + private void Controle_Alterado(object sender, EventArgs e) + { + if (ParametrosAlterados != null) + ParametrosAlterados(this, EventArgs.Empty); + } + + public bool MovimentoAutomatico + { + get { return checkMovimentoAutomatico.Checked; } + set { checkMovimentoAutomatico.Checked = value; } + } + + public bool AssistidoPorSonar + { + get { return checkAssistidoSonar.Checked; } + set { checkAssistidoSonar.Checked = value; } + } + + public bool ParadaPorObstaculo + { + get { return checkParadaObstaculo.Checked; } + set { checkParadaObstaculo.Checked = value; } + } + + public bool AssistidoPorImu + { + get { return checkAssistidoImu.Checked; } + set { checkAssistidoImu.Checked = value; } + } + + public bool ParadaPorInclinacao + { + get { return checkParadaInclinacao.Checked; } + set { checkParadaInclinacao.Checked = value; } + } + + public bool FrenagemAoParar + { + get { return checkFrenagemParar.Checked; } + set { checkFrenagemParar.Checked = value; } + } + + public int VelocidadeSemErvasPercentual + { + get { return sliderSemErvas.Value; } + set { sliderSemErvas.Value = value; } + } + + public int VelocidadeComErvasPercentual + { + get { return sliderComErvas.Value; } + set { sliderComErvas.Value = value; } + } + + public double VelocidadeMaximaEquipamentoKmh + { + get { return sliderSemErvas.VelocidadeMaximaKmh; } + set + { + sliderSemErvas.VelocidadeMaximaKmh = value; + sliderComErvas.VelocidadeMaximaKmh = value; + } + } + } +} diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoMovimentacao.Designer.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoMovimentacao.Designer.cs index 5a09f9b64..2b6c713c8 100644 --- a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoMovimentacao.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoMovimentacao.Designer.cs @@ -1,7 +1,12 @@ using AgroBase.Forms.IHM.Controls; using AgroBase.Forms.IHM.Controls.Operacao; +using AgroBase.Forms.IHM.Operacao.Parametros.Controls; +using AgroBase.Models; +using AgroBase.Models.Modules; +using System; using System.Drawing; using System.Windows.Forms; +using static AgroBase.Models.Enums; namespace AgroBase.Forms.IHM.Operacao { @@ -11,6 +16,15 @@ namespace AgroBase.Forms.IHM.Operacao protected override void Dispose(bool disposing) { + _controleDescartado = true; + + if (picCamera != null) + { + System.Drawing.Image imagemAtual = picCamera.Image; + picCamera.Image = null; + imagemAtual?.Dispose(); + } + if (disposing && components != null) components.Dispose(); @@ -29,15 +43,9 @@ namespace AgroBase.Forms.IHM.Operacao this.lblControleTitulo = new System.Windows.Forms.Label(); this.lblJoystick = new System.Windows.Forms.Label(); this.cmbJoystick = new System.Windows.Forms.ComboBox(); - this.lblVelocidadeMax = new System.Windows.Forms.Label(); - this.lblVelocidadeMaxValor = new System.Windows.Forms.Label(); - this.sliderVelocidadeMax = new AgroBase.Forms.IHM.Controls.Operacao.HmiSlider(); - this.lblAngulo = new System.Windows.Forms.Label(); - this.lblAnguloValor = new System.Windows.Forms.Label(); - this.sliderAngulo = new AgroBase.Forms.IHM.Controls.Operacao.HmiSlider(); - this.lblVelocidadeDir = new System.Windows.Forms.Label(); - this.lblVelocidadeDirValor = new System.Windows.Forms.Label(); - this.sliderVelocidadeDir = new AgroBase.Forms.IHM.Controls.Operacao.HmiSlider(); + this.sliderVelocidadeMax = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow(); + this.sliderAngulo = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow(); + this.sliderVelocidadeDir = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow(); this.lblTipoMovimento = new System.Windows.Forms.Label(); this.cmbTipoMovimento = new System.Windows.Forms.ComboBox(); this.acoesLayout = new System.Windows.Forms.TableLayoutPanel(); @@ -135,25 +143,16 @@ namespace AgroBase.Forms.IHM.Operacao this.controleLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 36F)); this.controleLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34F)); this.controleLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.controleLayout.RowCount = 11; - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 18F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 29F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 18F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 29F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 18F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 29F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 18F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F)); - this.controleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F)); - - // Joystick - this.controleLayout.RowStyles[1] = new RowStyle(SizeType.Absolute, 27F); - // Combo de tipo de movimento - this.controleLayout.RowStyles[9] = new RowStyle(SizeType.Absolute, 28F); - // Botões - this.controleLayout.RowStyles[10] = new RowStyle(SizeType.Absolute, 40F); + this.controleLayout.RowCount = 8; + this.controleLayout.RowStyles.Clear(); + this.controleLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 22F)); // título + this.controleLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 27F)); // joystick + this.controleLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 33.33F)); // vel máxima + this.controleLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 33.33F)); // ângulo + this.controleLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 33.34F)); // vel dir + this.controleLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 17F)); // tipo + this.controleLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 28F)); // combo + this.controleLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F)); // ações SetupTitle(this.lblControleTitulo, "CONTROLE DE MOVIMENTO"); this.controleLayout.Controls.Add(this.lblControleTitulo, 0, 0); @@ -168,51 +167,31 @@ namespace AgroBase.Forms.IHM.Operacao this.controleLayout.Controls.Add(this.cmbJoystick, 1, 1); this.controleLayout.SetColumnSpan(this.cmbJoystick, 2); - SetupCaption(this.lblVelocidadeMax, "Velocidade máx."); - SetupValue(this.lblVelocidadeMaxValor, "68% · 3,4 km/h", AgroBase.Forms.IHM.Controls.HmiTheme.Success); - this.controleLayout.Controls.Add(this.lblVelocidadeMax, 0, 2); - this.controleLayout.SetColumnSpan(this.lblVelocidadeMax, 2); - this.controleLayout.Controls.Add(this.lblVelocidadeMaxValor, 2, 2); - SetupSlider(this.sliderVelocidadeMax, AgroBase.Forms.IHM.Controls.HmiTheme.Success, 0, 100, 68); - this.controleLayout.Controls.Add(this.sliderVelocidadeMax, 0, 3); + SetupParameterSlider(this.sliderVelocidadeMax, "Velocidade máxima", HmiTheme.Success, 0, 100, 30, HmiSliderValueFormat.PercentAndSpeed); + this.sliderVelocidadeMax.VelocidadeMaximaKmh = FuncoesMatematicas.CalculaVelocidadeRPM(VariaveisEquipamento.RPM_Max_Roda); + this.controleLayout.Controls.Add(this.sliderVelocidadeMax, 0, 2); this.controleLayout.SetColumnSpan(this.sliderVelocidadeMax, 3); - SetupCaption(this.lblAngulo, "Ângulo direcional"); - SetupValue(this.lblAnguloValor, "+12°", AgroBase.Forms.IHM.Controls.HmiTheme.Manual); - this.controleLayout.Controls.Add(this.lblAngulo, 0, 4); - this.controleLayout.SetColumnSpan(this.lblAngulo, 2); - this.controleLayout.Controls.Add(this.lblAnguloValor, 2, 4); - SetupSlider(this.sliderAngulo, AgroBase.Forms.IHM.Controls.HmiTheme.Manual, 0, 90, 12); - this.controleLayout.Controls.Add(this.sliderAngulo, 0, 5); + SetupParameterSlider(this.sliderAngulo, "Ângulo direcional", HmiTheme.Manual, 0, 90, 12, HmiSliderValueFormat.Degrees); + this.controleLayout.Controls.Add(this.sliderAngulo, 0, 3); this.controleLayout.SetColumnSpan(this.sliderAngulo, 3); - SetupCaption(this.lblVelocidadeDir, "Velocidade direcional"); - SetupValue(this.lblVelocidadeDirValor, "55%", AgroBase.Forms.IHM.Controls.HmiTheme.Info); - this.controleLayout.Controls.Add(this.lblVelocidadeDir, 0, 6); - this.controleLayout.SetColumnSpan(this.lblVelocidadeDir, 2); - this.controleLayout.Controls.Add(this.lblVelocidadeDirValor, 2, 6); - SetupSlider(this.sliderVelocidadeDir, AgroBase.Forms.IHM.Controls.HmiTheme.Info, 0, 100, 55); - this.controleLayout.Controls.Add(this.sliderVelocidadeDir, 0, 7); + SetupParameterSlider(this.sliderVelocidadeDir, "Velocidade direcional", HmiTheme.Info, 0, 100, 55, HmiSliderValueFormat.PercentOnly); + this.controleLayout.Controls.Add(this.sliderVelocidadeDir, 0, 4); this.controleLayout.SetColumnSpan(this.sliderVelocidadeDir, 3); SetupCaption(this.lblTipoMovimento, "Tipo de movimento"); - this.controleLayout.Controls.Add(this.lblTipoMovimento, 0, 8); + this.controleLayout.Controls.Add(this.lblTipoMovimento, 0, 5); this.controleLayout.SetColumnSpan(this.lblTipoMovimento, 3); SetupCombo(this.cmbTipoMovimento); - this.cmbTipoMovimento.Items.AddRange(new object[] - { - "Rodas dianteiras", - "Rodas traseiras", - "Rotacionar no eixo", - "Movimento arco", - "Movimento lateral", - "Movimento diagonal", - "Diagnóstico" - }); - this.controleLayout.Controls.Add(this.cmbTipoMovimento, 0, 9); + this.cmbTipoMovimento.Items.AddRange(Enum.GetNames(typeof(TipoMovimentoDirecional))); + this.controleLayout.Controls.Add(this.cmbTipoMovimento, 0, 6); this.controleLayout.SetColumnSpan(this.cmbTipoMovimento, 3); + this.controleLayout.Controls.Add(this.acoesLayout, 0, 7); + this.controleLayout.SetColumnSpan(this.acoesLayout, 3); + this.acoesLayout.ColumnCount = 3; this.acoesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34F)); this.acoesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33F)); @@ -225,12 +204,9 @@ namespace AgroBase.Forms.IHM.Operacao this.acoesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.acoesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 1F)); - SetupAction(this.btnControleManual, "MANUAL", AgroBase.Forms.IHM.Controls.HmiTheme.Success); - SetupAction(this.btnReferenciar, "ZERAR", AgroBase.Forms.IHM.Controls.HmiTheme.Info); - SetupAction(this.btnFreio, "FREIO", AgroBase.Forms.IHM.Controls.HmiTheme.Danger); - - this.controleLayout.Controls.Add(this.acoesLayout, 0, 10); - this.controleLayout.SetColumnSpan(this.acoesLayout, 3); + SetupAction(this.btnControleManual, "MANUAL", AgroBase.Forms.IHM.Controls.HmiTheme.Info); + SetupAction(this.btnReferenciar, "ZERAR", AgroBase.Forms.IHM.Controls.HmiTheme.Disabled); + SetupAction(this.btnFreio, "FREIO", AgroBase.Forms.IHM.Controls.HmiTheme.Disabled); // wheels this.rodasLayout.Dock = DockStyle.Fill; @@ -448,9 +424,7 @@ namespace AgroBase.Forms.IHM.Operacao this.ResumeLayout(false); } - private static void ConfigurePanel( - AgroBase.Forms.IHM.Controls.HmiRoundedPanel panel, - System.Windows.Forms.Control child) + private static void ConfigurePanel(AgroBase.Forms.IHM.Controls.HmiRoundedPanel panel, System.Windows.Forms.Control child) { panel.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; panel.Controls.Add(child); @@ -461,9 +435,7 @@ namespace AgroBase.Forms.IHM.Operacao panel.Padding = new System.Windows.Forms.Padding(7); } - private static void SetupTitle( - System.Windows.Forms.Label label, - string text) + private static void SetupTitle(System.Windows.Forms.Label label, string text) { label.Dock = System.Windows.Forms.DockStyle.Fill; label.BackColor = System.Drawing.Color.Transparent; @@ -474,9 +446,7 @@ namespace AgroBase.Forms.IHM.Operacao label.AutoEllipsis = true; } - private static void SetupCaption( - System.Windows.Forms.Label label, - string text) + private static void SetupCaption(System.Windows.Forms.Label label, string text) { label.Dock = System.Windows.Forms.DockStyle.Fill; label.BackColor = System.Drawing.Color.Transparent; @@ -502,8 +472,7 @@ namespace AgroBase.Forms.IHM.Operacao label.Padding = Padding.Empty; } - private static void SetupCombo( - System.Windows.Forms.ComboBox combo) + private static void SetupCombo(System.Windows.Forms.ComboBox combo) { combo.Dock = System.Windows.Forms.DockStyle.Fill; combo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -514,27 +483,25 @@ namespace AgroBase.Forms.IHM.Operacao combo.Margin = new System.Windows.Forms.Padding(0, 1, 0, 1); } - private static void SetupSlider( - AgroBase.Forms.IHM.Controls.Operacao.HmiSlider slider, - System.Drawing.Color accent, - int min, - int max, - int value) + private static void SetupParameterSlider(HmiParameterSliderRow slider, string titulo, Color accent, int minimum, int maximum, int value, HmiSliderValueFormat format) { - slider.Dock = System.Windows.Forms.DockStyle.Fill; - slider.Minimum = min; - slider.Maximum = max; - slider.Value = value; + slider.CompactMode = true; + + slider.Dock = DockStyle.Fill; + slider.Margin = Padding.Empty; + slider.Padding = Padding.Empty; + slider.MinimumSize = Size.Empty; + slider.BackColor = Color.Transparent; + + slider.Titulo = titulo; + slider.Minimum = minimum; + slider.Maximum = maximum; + slider.ValueFormat = format; slider.AccentColor = accent; - slider.TrackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; - slider.ThumbColor = AgroBase.Forms.IHM.Controls.HmiTheme.Text; - slider.Margin = System.Windows.Forms.Padding.Empty; + slider.Value = value; } - private static void SetupAction( - HmiSidebarButton button, - string text, - Color accent) + private static void SetupAction(HmiSidebarButton button, string text, Color accent) { button.Dock = DockStyle.Fill; @@ -550,14 +517,13 @@ namespace AgroBase.Forms.IHM.Operacao button.MaximumSize = Size.Empty; } - private static void SetupWheel( - HmiWheelStatusCard card, - string titulo) + private static void SetupWheel(HmiWheelStatusCard card, string titulo) { card.Dock = DockStyle.Fill; card.Margin = new Padding(2, 0, 2, 0); card.MinimumSize = Size.Empty; + card.Tag = titulo; card.Titulo = titulo; card.DirecionalSp = "+0,0°"; @@ -568,7 +534,9 @@ namespace AgroBase.Forms.IHM.Operacao card.MovimentoAtual = "0 rpm"; card.StatusMovimento = "Sem freio"; + card.CheckDir.Tag = titulo; card.CheckDir.Checked = true; + card.CheckMov.Tag = titulo; card.CheckMov.Checked = true; card.CorStatusDirecional = HmiTheme.Success; @@ -577,11 +545,7 @@ namespace AgroBase.Forms.IHM.Operacao card.BringToFront(); } - private static void SetupCompactCard( - HmiCompactMetricCard card, - string titulo, - string valor, - Color cor) + private static void SetupCompactCard(HmiCompactMetricCard card, string titulo, string valor, Color cor) { card.Dock = DockStyle.Fill; card.Titulo = titulo; @@ -591,11 +555,7 @@ namespace AgroBase.Forms.IHM.Operacao card.MinimumSize = Size.Empty; } - private static void SetupTelemetry( - AgroBase.Forms.IHM.Controls.Operacao.HmiTelemetryRow row, - string icon, - string title, - string value) + private static void SetupTelemetry(AgroBase.Forms.IHM.Controls.Operacao.HmiTelemetryRow row, string icon, string title, string value) { row.Dock = System.Windows.Forms.DockStyle.Fill; row.IconText = icon; @@ -603,6 +563,7 @@ namespace AgroBase.Forms.IHM.Operacao row.Valor = value; } + #endregion private System.Windows.Forms.TableLayoutPanel rootLayout; @@ -613,15 +574,9 @@ namespace AgroBase.Forms.IHM.Operacao private System.Windows.Forms.Label lblControleTitulo; private System.Windows.Forms.Label lblJoystick; private System.Windows.Forms.ComboBox cmbJoystick; - private System.Windows.Forms.Label lblVelocidadeMax; - private System.Windows.Forms.Label lblVelocidadeMaxValor; - private AgroBase.Forms.IHM.Controls.Operacao.HmiSlider sliderVelocidadeMax; - private System.Windows.Forms.Label lblAngulo; - private System.Windows.Forms.Label lblAnguloValor; - private AgroBase.Forms.IHM.Controls.Operacao.HmiSlider sliderAngulo; - private System.Windows.Forms.Label lblVelocidadeDir; - private System.Windows.Forms.Label lblVelocidadeDirValor; - private AgroBase.Forms.IHM.Controls.Operacao.HmiSlider sliderVelocidadeDir; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow sliderVelocidadeMax; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow sliderAngulo; + private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiParameterSliderRow sliderVelocidadeDir; private System.Windows.Forms.Label lblTipoMovimento; private System.Windows.Forms.ComboBox cmbTipoMovimento; private System.Windows.Forms.TableLayoutPanel acoesLayout; diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoMovimentacao.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoMovimentacao.cs index e4b201a6d..cbb174f91 100644 --- a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoMovimentacao.cs +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoMovimentacao.cs @@ -1,10 +1,29 @@ using AgroBase.Forms.IHM.Controls; +using AgroBase.Forms.IHM.Controls.Operacao; +using AgroBase.Models; +using AgroBase.Models.Modules; +using AgroBase.Models.Operacoes; +using AgroBase.Models.Operadores; +using AgroBase.Services.Operadores; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Threading.Tasks; using System.Windows.Forms; +using static AgroBase.Models.Enums; namespace AgroBase.Forms.IHM.Operacao { public partial class ucOperacaoMovimentacao : UserControl { + private bool _modoManualAtivado = false; + private bool _freioAtivado = false; + private bool _atualizandoSlider = false; + private bool _requisitandoCameraFrame; + private bool _controleDescartado; + OperacaoModel op => Variaveis.OperacaoEmAndamento; + public ucOperacaoMovimentacao() { InitializeComponent(); @@ -21,8 +40,6 @@ namespace AgroBase.Forms.IHM.Operacao sliderAngulo.Value = 12; sliderVelocidadeDir.Value = 55; - AtualizarLabelsSliders(); - telemetryVelocidade.CorValor = HmiTheme.Info; telemetryTensao.CorValor = HmiTheme.Success; telemetryCorrente.CorValor = HmiTheme.Warning; @@ -55,39 +72,377 @@ namespace AgroBase.Forms.IHM.Operacao { sliderVelocidadeMax.ValueChanged += delegate { - AtualizarLabelsSliders(); + if (!_modoManualAtivado) + return; + + if (op?.Controle == null) + return; + + op.Controle.PercentualVelocidadeSP = sliderVelocidadeMax.Value; }; + sliderVelocidadeMax.KeyDown += delegate { _atualizandoSlider = true; }; + sliderVelocidadeMax.KeyUp += delegate { _atualizandoSlider = false; }; sliderAngulo.ValueChanged += delegate { - AtualizarLabelsSliders(); + if (!_modoManualAtivado) + return; + + if (op?.Controle == null) + return; + + op.Controle.Angulo = sliderAngulo.Value; }; + sliderAngulo.KeyDown += delegate { _atualizandoSlider = true; }; + sliderAngulo.KeyUp += delegate { _atualizandoSlider = false; }; sliderVelocidadeDir.ValueChanged += delegate { - AtualizarLabelsSliders(); + if (!_modoManualAtivado) + return; + + if (op?.Parametros?.Controle == null) + return; + + op.Parametros.Controle.DirVelocidadeMovimento = sliderVelocidadeDir.Value; }; + sliderVelocidadeDir.KeyDown += delegate { _atualizandoSlider = true; }; + sliderVelocidadeDir.KeyUp += delegate { _atualizandoSlider = false; }; + + btnControleManual.Click += BtnControleManual_Click; + btnReferenciar.Click += BtnReferenciar_Click; + btnFreio.Click += BtnFreio_Click; + + cmbTipoMovimento.SelectedIndexChanged += CmbTipoMovimento_SelectedIndexChanged; + + cardET.CheckDir.CheckedChanged += CheckDir_CheckedChanged; + cardET.CheckMov.CheckedChanged += CheckMov_CheckedChanged; + cardDT.CheckDir.CheckedChanged += CheckDir_CheckedChanged; + cardDT.CheckMov.CheckedChanged += CheckMov_CheckedChanged; + cardEF.CheckDir.CheckedChanged += CheckDir_CheckedChanged; + cardEF.CheckMov.CheckedChanged += CheckMov_CheckedChanged; + cardDF.CheckDir.CheckedChanged += CheckDir_CheckedChanged; + cardDF.CheckMov.CheckedChanged += CheckMov_CheckedChanged; } - private void AtualizarLabelsSliders() + private void CheckMov_CheckedChanged(object sender, EventArgs e) { - double velocidadeKmh = - sliderVelocidadeMax.Value * 0.05; + if (!_modoManualAtivado) + return; - lblVelocidadeMaxValor.Text = - sliderVelocidadeMax.Value + - "% · " + - velocidadeKmh.ToString("0.0") + - " km/h"; + if (!(op?.DispMvd?.Dados?.Modulos?.Any() ?? false)) + return; - lblAnguloValor.Text = - "+" + - sliderAngulo.Value + - "°"; + var chb = sender as CheckBox; - lblVelocidadeDirValor.Text = - sliderVelocidadeDir.Value + - "%"; + var mod = op?.DispMvd?.Dados?.Modulos?.FirstOrDefault(x => x.Modulo_ID == chb.Tag.ToString())?.MovMotor; + if (mod == null) + return; + + mod.Comandar = chb.Checked; } + + private void CheckDir_CheckedChanged(object sender, EventArgs e) + { + if (!_modoManualAtivado) + return; + + if (!(op?.DispMvd?.Dados?.Modulos?.Any() ?? false)) + return; + + var chb = sender as CheckBox; + + var mod = op?.DispMvd?.Dados?.Modulos?.FirstOrDefault(x => x.Modulo_ID == chb.Tag.ToString())?.DirMotor; + if (mod == null) + return; + + mod.Comandar = chb.Checked; + } + + private void CmbTipoMovimento_SelectedIndexChanged(object sender, EventArgs e) + { + if (!_modoManualAtivado) + return; + + if (op?.Controle == null) + return; + + var mods = op?.DispMvd?.Dados?.Modulos; + + op.Controle.DefinirTipoMovimento((TipoMovimentoDirecional)cmbTipoMovimento.SelectedIndex, mods); + + AtualizarDadosRodas(cardET, mods, forcar: true); + AtualizarDadosRodas(cardDT, mods, forcar: true); + AtualizarDadosRodas(cardEF, mods, forcar: true); + AtualizarDadosRodas(cardDF, mods, forcar: true); + } + + private void BtnFreio_Click(object sender, EventArgs e) + { + if (!_modoManualAtivado) + return; + + if (op?.Controle == null) + return; + + _freioAtivado = !_freioAtivado; + btnFreio.AccentColor = _freioAtivado ? HmiTheme.Danger : HmiTheme.Info; + btnFreio.BorderColor = _freioAtivado ? HmiTheme.Danger : HmiTheme.Info; + + GeneralJoystick.ProcessarDadosControle(BotoesJoystick.Bolinha, !_freioAtivado, ForcarComando: true); + } + + private void BtnReferenciar_Click(object sender, EventArgs e) + { + if (!_modoManualAtivado) + return; + + if (op?.DispMvd == null) + return; + + GeneralJoystick.ProcessarDadosControle(BotoesJoystick.R3, false, ForcarComando: true); + } + + private void BtnControleManual_Click(object sender, EventArgs e) + { + _modoManualAtivado = !_modoManualAtivado; + btnControleManual.AccentColor = _modoManualAtivado ? HmiTheme.Danger : HmiTheme.Info; + btnControleManual.BorderColor = _modoManualAtivado ? HmiTheme.Danger : HmiTheme.Info; + + btnReferenciar.AccentColor = _modoManualAtivado ? HmiTheme.Info : HmiTheme.Disabled; + btnReferenciar.BackColor = _modoManualAtivado ? HmiTheme.Info : HmiTheme.Disabled; + btnFreio.AccentColor = _modoManualAtivado ? HmiTheme.Info : HmiTheme.Disabled; + btnFreio.BackColor = _modoManualAtivado ? HmiTheme.Info : HmiTheme.Disabled; + + op.Parametros.Controle.ControleManualAcionado = _modoManualAtivado; + } + + public void AtualizarDadosTela() + { + var dados = op?.Sensoriamento; + var mods = op?.DispMvd?.Dados?.Modulos; + + AtualizarDadosControle(op?.Controle, op?.Parametros?.Controle); + + AtualizarDadosRodas(cardET, mods); + AtualizarDadosRodas(cardDT, mods); + AtualizarDadosRodas(cardEF, mods); + AtualizarDadosRodas(cardDF, mods); + + AtualizarDadosCamera(dados?.Cameras?.FirstOrDefault(x => x.dispositivo == Enums.T_Code.Snr), dados?.OperadorSaude?.ModulosSaude?.FirstOrDefault(x => x.modulo == T_Code.Snr)?.saude ?? 0); + + AtualizarDadosSonar(dados.OperadorVisual); + + AtualizarDadosImu(dados.IMU); + + AtualizarDadosTelemetria(dados); + } + + public void AtualizarDadosControle(OperacaoControleModel controle, OperacaoParametrosControleModel parametros) + { + AtualizarListaJoysticks(); + + if (_atualizandoSlider) + return; + + sliderVelocidadeMax.VelocidadeMaximaKmh = FuncoesMatematicas.CalculaVelocidadeRPM(VariaveisEquipamento.RPM_Max_Roda); + sliderVelocidadeMax.Value = (int)Limitar(controle?.PercentualVelocidadeSP ?? 0, sliderVelocidadeMax.Minimum, sliderVelocidadeMax.Maximum); + sliderAngulo.Value = (int)Limitar(controle?.Angulo ?? 0, sliderAngulo.Minimum, sliderAngulo.Maximum); + sliderVelocidadeDir.Value = (int)Limitar(parametros?.DirVelocidadeMovimento ?? 0, sliderVelocidadeDir.Minimum, sliderVelocidadeDir.Maximum); + } + + private void AtualizarListaJoysticks() + { + string joystickSelecionado = cmbJoystick.SelectedItem as string; + string[] itemsAntigos = cmbJoystick.Items.Cast().ToArray(); + GeneralJoystick.AtualizaDispositivo(); + string[] itemsNovos = GeneralJoystick.JoysticksConectados.ToArray(); + + if (itemsAntigos.SequenceEqual(itemsNovos)) + return; + + cmbJoystick.BeginUpdate(); + + try + { + cmbJoystick.Items.Clear(); + cmbJoystick.Items.AddRange(itemsNovos); + + string joystickConectado = GeneralJoystick.JoystickConectado?.Information?.InstanceName; + + int indice = -1; + + if (!string.IsNullOrWhiteSpace(joystickConectado)) + indice = cmbJoystick.Items.IndexOf(joystickConectado); + + if (indice < 0 && !string.IsNullOrWhiteSpace(joystickSelecionado)) + indice = cmbJoystick.Items.IndexOf(joystickSelecionado); + + if (indice < 0 && cmbJoystick.Items.Count > 0) + indice = 0; + + cmbJoystick.SelectedIndex = indice; + } + finally + { + cmbJoystick.EndUpdate(); + } + } + + private void AtualizarDadosRodas(HmiWheelStatusCard card, List Mods, bool forcar = false) + { + if (_modoManualAtivado && !forcar) + return; + + var Dir = Mods.FirstOrDefault(x => x.Modulo_ID == card.Tag.ToString())?.DirMotor; + var Mov = Mods.FirstOrDefault(x => x.Modulo_ID == card.Tag.ToString())?.MovMotor; + + card.AtualizarDados( + dir_em_uso: Dir?.Comandar ?? false, + dir_ang_sp: Dir?.Angulo_SP ?? 0, + dir_ang_at: Dir?.AnguloReal ?? 0, + dir_sentido: Dir?.SentidoReal ?? Sentido.Parado, + mov_em_uso: Mov?.Comandar ?? false, + mov_vel_sp: Mov?.RPM_SP ?? 0, + mov_vel_at: Mov?.RPM_Roda ?? 0, + mov_freio: Mov?.UltimoFreioSP ?? false + ); + } + + public async void AtualizarDadosCamera(CameraWorkerItemModel dados, double saude) + { + lblCameraStatus.Text = $"FPS {dados?.fps ?? 0:F0} · {dados?.stream_kbps ?? 0:F1} MB/s · Saúde {saude:F0}%"; + + if (!_requisitandoCameraFrame) + _ = RequisitarCameraFrameAsync(); + } + + private async Task RequisitarCameraFrameAsync() + { + if (_requisitandoCameraFrame || _controleDescartado) + return; + + _requisitandoCameraFrame = true; + + try + { + TipoFrameCamera tipoFrame = (TipoFrameCamera)cmbTipoFrame.SelectedIndex; + + var frame = await VisualWorkerService.GetCameraFrame(tipoFrame); + + if (_controleDescartado || frame == null) + return; + + Image imagemRecebida = frame.image(); + + if (imagemRecebida == null) + return; + + // Garante que o PictureBox receba uma imagem independente + // de streams ou buffers internos do frame. + Image imagemSegura; + + using (imagemRecebida) + { + imagemSegura = new Bitmap(imagemRecebida); + } + + AtualizarImagemPainel(picCamera, imagemSegura); + } + catch (OutOfMemoryException ex) + { + // Em System.Drawing isso também pode significar + // imagem ou stream inválido, não só falta real de RAM. + Variaveis.MostrarLog("[IHM][Câmera] Frame inválido ou erro de memória: " + ex.Message); + } + catch (Exception ex) + { + Variaveis.MostrarLog("[IHM][Câmera] Erro ao obter frame: " + ex.Message); + } + finally + { + _requisitandoCameraFrame = false; + } + } + + private void AtualizarImagemPainel(PictureBox pictureBox, Image novaImagem) + { + if (pictureBox == null) + { + novaImagem?.Dispose(); + return; + } + + if (pictureBox.IsDisposed || pictureBox.Disposing || _controleDescartado) + { + novaImagem?.Dispose(); + return; + } + + if (pictureBox.InvokeRequired) + { + try + { + pictureBox.BeginInvoke(new Action(AtualizarImagemPainel), pictureBox, novaImagem); + } + catch + { + novaImagem?.Dispose(); + } + + return; + } + + Image imagemAnterior = pictureBox.Image; + pictureBox.Image = novaImagem; + imagemAnterior?.Dispose(); + } + + private void AtualizarDadosSonar(VisualWorkerModel dados) + { + cardSonarModo.Valor = dados?.Analises?.matriz_confianca?.block?.decision?.mode ?? "N/A"; + cardSonarFator.Valor = (dados?.Analises?.matriz_confianca?.block?.decision?.v_max_sugerida_mps ?? 0f).ToString("F2") + "%"; + cardSonarProximo.Valor = (dados?.Analises?.matriz_confianca?.block?.decision?.dist_necessaria ?? 0f).ToString("F2") + " m"; + cardSonarLivreEsq.Valor = "0,00 m"; + cardSonarLivreDir.Valor = "0,00 m"; + cardSonarCorredor.Valor = (dados?.Analises?.segmentacao?.status_corredor ?? StatusCarroMapa.Indefinido).ToString(); + } + + private void AtualizarDadosImu(ModuloIMUModel dados) + { + cardImuModo.Valor = dados?.risk_level ?? "N/A"; + cardImuFator.Valor = (dados?.velocidade_factor ?? 0f).ToString("F2"); + cardImuMotivo.Valor = string.Join(", ", (dados?.motivos_risco ?? new System.Collections.Generic.List())); + + attitudeIndicator.FrontalDeg = dados.RollSeguro; + attitudeIndicator.LateralDeg = dados.PitchSeguro; + } + + private void AtualizarDadosTelemetria(OperacaoSensoriamentoConjuntoModel dados) + { + double velocidadeKmh = FuncoesMatematicas.ConverteMsParaKmh(dados?.Movimentacao?.VelocidadeMediaMs ?? 0); + TimeSpan tempoMovimento = dados?.Movimentacao?.TempoMovimento ?? TimeSpan.Zero; + double autonomiaMinutos = dados?.Bateria?.TempoEstimadoRestanteMinutos ?? 0; + TimeSpan tempoAutonomia = TimeSpan.FromMinutes(Math.Max(0, autonomiaMinutos)); + + telemetryVelocidade.Valor = $"{velocidadeKmh:F2} km/h"; + telemetryTensao.Valor = $"{dados?.Bateria?.TensaoInstantanea ?? 0:F2} V"; + telemetryCorrente.Valor = $"{dados?.Bateria?.CorrenteInstantanea ?? 0:F2} A"; + telemetryPotencia.Valor = $"{dados?.Bateria?.PotenciaInstantanea ?? 0:F2} W"; + telemetryRpm.Valor = $"{dados?.Movimentacao?.RPMRodaMedio ?? 0:F0} rpm"; + telemetryDistancia.Valor = $"{dados?.Movimentacao?.DistanciaPercorridaTotal ?? 0:F2} m"; + telemetryTempo.Valor = tempoMovimento.ToString(@"hh\:mm\:ss"); + telemetryVelMedia.Valor = $"{velocidadeKmh:F2} km/h"; + telemetryAutonomiaM.Valor = $"{dados?.Bateria?.DistanciaEstimadaRestanteMetros ?? 0:F0} m"; + telemetryAutonomiaTempo.Valor = tempoAutonomia.ToString(@"hh\:mm\:ss"); + } + + + + private static double Limitar(double valor, double minimo, double maximo) + { + return Math.Max(minimo, Math.Min(maximo, valor)); + } + } } diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoParametros.Designer.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoParametros.Designer.cs index 0c5dba637..4570398b6 100644 --- a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoParametros.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoParametros.Designer.cs @@ -6,11 +6,8 @@ protected override void Dispose(bool disposing) { - if (disposing && - components != null) - { + if (disposing && components != null) components.Dispose(); - } base.Dispose(disposing); } @@ -20,514 +17,199 @@ private void InitializeComponent() { this.rootLayout = new System.Windows.Forms.TableLayoutPanel(); - this.leftLayout = new System.Windows.Forms.TableLayoutPanel(); + this.tabsLayout = new System.Windows.Forms.TableLayoutPanel(); + this.btnAbaMovimento = new System.Windows.Forms.Button(); + this.btnAbaDirecional = new System.Windows.Forms.Button(); + this.btnAbaAtuador = new System.Windows.Forms.Button(); + this.btnAbaMapa = new System.Windows.Forms.Button(); - this.pnlGeral = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); - this.geralLayout = new System.Windows.Forms.TableLayoutPanel(); - this.lblGeralTitulo = new System.Windows.Forms.Label(); - this.lblModoOperacao = new System.Windows.Forms.Label(); - this.btnModoManual = new System.Windows.Forms.Button(); - this.btnModoMapaGps = new System.Windows.Forms.Button(); - this.toggleRegistrarDados = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); + this.pnlDescricaoAba = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.lblDescricaoAba = new System.Windows.Forms.Label(); - this.pnlMovimento = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); - this.movimentoLayout = new System.Windows.Forms.TableLayoutPanel(); - this.lblMovimentoTitulo = new System.Windows.Forms.Label(); - this.movTogglesLayout = new System.Windows.Forms.TableLayoutPanel(); - this.toggleMovAutomatico = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.toggleMovSonar = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.toggleParadaObstaculo = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.toggleMovImu = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.toggleParadaInclinacao = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.toggleFrenagemParar = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.movValuesLayout = new System.Windows.Forms.TableLayoutPanel(); - this.paramVelSemErvas = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramVelComErvas = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - - this.pnlDirecional = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); - this.direcionalLayout = new System.Windows.Forms.TableLayoutPanel(); - this.lblDirecionalTitulo = new System.Windows.Forms.Label(); - this.dirTogglesLayout = new System.Windows.Forms.TableLayoutPanel(); - this.toggleDirAutomatico = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.toggleDirSonar = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.toggleDirImu = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.toggleImuPrefereArco = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.dirValuesLayout = new System.Windows.Forms.TableLayoutPanel(); - this.paramAnguloMaximo = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramVelMovimentoDir = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.pnlTipoControle = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); - this.tipoControleLayout = new System.Windows.Forms.TableLayoutPanel(); - this.lblTipoControle = new System.Windows.Forms.Label(); - this.btnControleMpc = new System.Windows.Forms.Button(); - this.btnControlePid = new System.Windows.Forms.Button(); - - this.pnlAtuador = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); - this.atuadorLayout = new System.Windows.Forms.TableLayoutPanel(); - this.lblAtuadorTitulo = new System.Windows.Forms.Label(); - this.togglePulverizadorAutomatico = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow(); - this.cmbModoAgitador = new System.Windows.Forms.ComboBox(); - this.atuadorValuesLayout = new System.Windows.Forms.TableLayoutPanel(); - this.paramBicosEmUso = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramCapacidadeReservatorio = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramPressaoLinha = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramTelaIniciar = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramAlturaArea = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramErvasOn = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramErvasOff = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - - this.pnlMpc = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); - this.mpcLayout = new System.Windows.Forms.TableLayoutPanel(); - this.lblMpcTitulo = new System.Windows.Forms.Label(); - this.paramHorizonte = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - this.paramAnteciparFim = new AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox(); - - this.rightLayout = new System.Windows.Forms.TableLayoutPanel(); - this.pnlMapa = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); - this.mapLayout = new System.Windows.Forms.TableLayoutPanel(); - this.mapHeaderLayout = new System.Windows.Forms.TableLayoutPanel(); - this.lblMapaTitulo = new System.Windows.Forms.Label(); - this.btnMapaBonito = new System.Windows.Forms.Button(); - this.btnMapaDinamico = new System.Windows.Forms.Button(); - this.pnlMapaVisual = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); - this.lblMapaPlaceholder = new System.Windows.Forms.Label(); - this.lblMapaAjuda = new System.Windows.Forms.Label(); + this.pnlConteudo = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); + this.footerPanel = new AgroBase.Forms.IHM.Controls.HmiRoundedPanel(); this.footerLayout = new System.Windows.Forms.TableLayoutPanel(); - this.btnAplicarAtual = new AgroBase.Forms.IHM.Controls.HmiSidebarButton(); - this.btnSalvarParametros = new AgroBase.Forms.IHM.Controls.HmiSidebarButton(); + + this.lblModoOperacao = new System.Windows.Forms.Label(); + this.cmbModoOperacao = new System.Windows.Forms.ComboBox(); + + this.posProcessamentoLayout = new System.Windows.Forms.TableLayoutPanel(); + this.lblPosProcessamento = new System.Windows.Forms.Label(); + this.checkPosProcessamento = new System.Windows.Forms.CheckBox(); + + this.btnRedefinir = new AgroBase.Forms.IHM.Controls.HmiSidebarButton(); + this.btnSalvar = new AgroBase.Forms.IHM.Controls.HmiSidebarButton(); this.rootLayout.SuspendLayout(); - this.leftLayout.SuspendLayout(); - this.pnlGeral.SuspendLayout(); - this.geralLayout.SuspendLayout(); - this.pnlMovimento.SuspendLayout(); - this.movimentoLayout.SuspendLayout(); - this.movTogglesLayout.SuspendLayout(); - this.movValuesLayout.SuspendLayout(); - this.pnlDirecional.SuspendLayout(); - this.direcionalLayout.SuspendLayout(); - this.dirTogglesLayout.SuspendLayout(); - this.dirValuesLayout.SuspendLayout(); - this.pnlTipoControle.SuspendLayout(); - this.tipoControleLayout.SuspendLayout(); - this.pnlAtuador.SuspendLayout(); - this.atuadorLayout.SuspendLayout(); - this.atuadorValuesLayout.SuspendLayout(); - this.pnlMpc.SuspendLayout(); - this.mpcLayout.SuspendLayout(); - this.rightLayout.SuspendLayout(); - this.pnlMapa.SuspendLayout(); - this.mapLayout.SuspendLayout(); - this.mapHeaderLayout.SuspendLayout(); - this.pnlMapaVisual.SuspendLayout(); + this.tabsLayout.SuspendLayout(); + this.pnlDescricaoAba.SuspendLayout(); + this.footerPanel.SuspendLayout(); this.footerLayout.SuspendLayout(); + this.posProcessamentoLayout.SuspendLayout(); this.SuspendLayout(); - // root - this.rootLayout.BackColor = - AgroBase.Forms.IHM.Controls.HmiTheme.Background; + // rootLayout + this.rootLayout.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Background; + this.rootLayout.ColumnCount = 1; + this.rootLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.rootLayout.Controls.Add(this.tabsLayout, 0, 0); + this.rootLayout.Controls.Add(this.pnlDescricaoAba, 0, 1); + this.rootLayout.Controls.Add(this.pnlConteudo, 0, 2); + this.rootLayout.Controls.Add(this.footerPanel, 0, 3); + this.rootLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.rootLayout.Margin = System.Windows.Forms.Padding.Empty; + this.rootLayout.Padding = System.Windows.Forms.Padding.Empty; + this.rootLayout.RowCount = 4; + this.rootLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 45F)); + this.rootLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 28F)); + this.rootLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.rootLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 62F)); - this.rootLayout.ColumnCount = 2; + // tabsLayout + this.tabsLayout.BackColor = System.Drawing.Color.Transparent; + this.tabsLayout.ColumnCount = 4; + this.tabsLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tabsLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tabsLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tabsLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tabsLayout.Controls.Add(this.btnAbaMovimento, 0, 0); + this.tabsLayout.Controls.Add(this.btnAbaDirecional, 1, 0); + this.tabsLayout.Controls.Add(this.btnAbaAtuador, 2, 0); + this.tabsLayout.Controls.Add(this.btnAbaMapa, 3, 0); + this.tabsLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabsLayout.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3); + this.tabsLayout.Padding = System.Windows.Forms.Padding.Empty; + this.tabsLayout.RowCount = 1; + this.tabsLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.rootLayout.ColumnStyles.Add( - new System.Windows.Forms.ColumnStyle( - System.Windows.Forms.SizeType.Percent, - 52F)); + SetupTabButton(this.btnAbaMovimento, "↔ Movimento"); + SetupTabButton(this.btnAbaDirecional, "◉ Direcional"); + SetupTabButton(this.btnAbaAtuador, "♨ Atuador"); + SetupTabButton(this.btnAbaMapa, "⌖ Mapa e Navegação"); - this.rootLayout.ColumnStyles.Add( - new System.Windows.Forms.ColumnStyle( - System.Windows.Forms.SizeType.Percent, - 48F)); + // pnlDescricaoAba + this.pnlDescricaoAba.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; + this.pnlDescricaoAba.Controls.Add(this.lblDescricaoAba); + this.pnlDescricaoAba.CornerRadius = 7; + this.pnlDescricaoAba.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlDescricaoAba.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.SurfaceRaised; + this.pnlDescricaoAba.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3); + this.pnlDescricaoAba.Padding = new System.Windows.Forms.Padding(10, 0, 10, 0); - this.rootLayout.Controls.Add( - this.leftLayout, - 0, - 0); + // lblDescricaoAba + this.lblDescricaoAba.AutoEllipsis = true; + this.lblDescricaoAba.BackColor = System.Drawing.Color.Transparent; + this.lblDescricaoAba.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblDescricaoAba.Font = new System.Drawing.Font("Segoe UI", 7.2F); + this.lblDescricaoAba.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; + this.lblDescricaoAba.Margin = System.Windows.Forms.Padding.Empty; + this.lblDescricaoAba.Text = "Automação, assistências e velocidades de deslocamento"; + this.lblDescricaoAba.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.rootLayout.Controls.Add( - this.rightLayout, - 1, - 0); + // pnlConteudo + this.pnlConteudo.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; + this.pnlConteudo.CornerRadius = 9; + this.pnlConteudo.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlConteudo.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.Surface; + this.pnlConteudo.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3); + this.pnlConteudo.Padding = new System.Windows.Forms.Padding(6); - this.rootLayout.Dock = - System.Windows.Forms.DockStyle.Fill; + // footerPanel + this.footerPanel.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; + this.footerPanel.Controls.Add(this.footerLayout); + this.footerPanel.CornerRadius = 9; + this.footerPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.footerPanel.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.Surface; + this.footerPanel.Margin = System.Windows.Forms.Padding.Empty; + this.footerPanel.Padding = new System.Windows.Forms.Padding(8, 6, 8, 6); - this.rootLayout.Margin = - new System.Windows.Forms.Padding(0); - - this.rootLayout.Padding = - new System.Windows.Forms.Padding(0); - - // left - this.leftLayout.BackColor = - System.Drawing.Color.Transparent; - - this.leftLayout.ColumnCount = 1; - - this.leftLayout.ColumnStyles.Add( - new System.Windows.Forms.ColumnStyle( - System.Windows.Forms.SizeType.Percent, - 100F)); - - this.leftLayout.Controls.Add( - this.pnlGeral, - 0, - 0); - - this.leftLayout.Controls.Add( - this.pnlMovimento, - 0, - 1); - - this.leftLayout.Controls.Add( - this.pnlDirecional, - 0, - 2); - - this.leftLayout.Controls.Add( - this.pnlAtuador, - 0, - 3); - - this.leftLayout.Controls.Add( - this.pnlMpc, - 0, - 4); - - this.leftLayout.Dock = - System.Windows.Forms.DockStyle.Fill; - - this.leftLayout.Margin = - new System.Windows.Forms.Padding( - 0, - 0, - 3, - 0); - - this.leftLayout.RowCount = 5; - - this.leftLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14F)); - this.leftLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.leftLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 22F)); - this.leftLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 27F)); - this.leftLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12F)); - - ConfigurePanel(this.pnlGeral, this.geralLayout); - ConfigurePanel(this.pnlMovimento, this.movimentoLayout); - ConfigurePanel(this.pnlDirecional, this.direcionalLayout); - ConfigurePanel(this.pnlAtuador, this.atuadorLayout); - ConfigurePanel(this.pnlMpc, this.mpcLayout); - - // geral - this.geralLayout.ColumnCount = 4; - this.geralLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 23F)); - this.geralLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 19F)); - this.geralLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 19F)); - this.geralLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 39F)); - this.geralLayout.Controls.Add(this.lblGeralTitulo, 0, 0); - this.geralLayout.Controls.Add(this.lblModoOperacao, 0, 1); - this.geralLayout.Controls.Add(this.btnModoManual, 1, 1); - this.geralLayout.Controls.Add(this.btnModoMapaGps, 2, 1); - this.geralLayout.Controls.Add(this.toggleRegistrarDados, 3, 1); - this.geralLayout.SetColumnSpan(this.lblGeralTitulo, 4); - this.geralLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.geralLayout.RowCount = 2; - this.geralLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 23F)); - this.geralLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - - SetupTitle(this.lblGeralTitulo, "1 GERAL DA OPERAÇÃO"); - - this.lblModoOperacao.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblModoOperacao.Text = "Modo de operação"; - this.lblModoOperacao.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; - this.lblModoOperacao.Font = new System.Drawing.Font("Segoe UI", 7F); - this.lblModoOperacao.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - - SetupChoiceButton(this.btnModoManual, "Manual"); - SetupChoiceButton(this.btnModoMapaGps, "MapaGPS"); - - this.toggleRegistrarDados.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleRegistrarDados.Titulo = "Registrar dados para pós-processamento"; - - // movimento - this.movimentoLayout.ColumnCount = 2; - this.movimentoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 58F)); - this.movimentoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 42F)); - this.movimentoLayout.Controls.Add(this.lblMovimentoTitulo, 0, 0); - this.movimentoLayout.Controls.Add(this.movTogglesLayout, 0, 1); - this.movimentoLayout.Controls.Add(this.movValuesLayout, 1, 1); - this.movimentoLayout.SetColumnSpan(this.lblMovimentoTitulo, 2); - this.movimentoLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.movimentoLayout.RowCount = 2; - this.movimentoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 23F)); - this.movimentoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - - SetupTitle(this.lblMovimentoTitulo, "2 MOVIMENTO"); - - this.movTogglesLayout.ColumnCount = 2; - this.movTogglesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.movTogglesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.movTogglesLayout.Controls.Add(this.toggleMovAutomatico, 0, 0); - this.movTogglesLayout.Controls.Add(this.toggleMovImu, 1, 0); - this.movTogglesLayout.Controls.Add(this.toggleMovSonar, 0, 1); - this.movTogglesLayout.Controls.Add(this.toggleParadaInclinacao, 1, 1); - this.movTogglesLayout.Controls.Add(this.toggleParadaObstaculo, 0, 2); - this.movTogglesLayout.Controls.Add(this.toggleFrenagemParar, 1, 2); - this.movTogglesLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.movTogglesLayout.RowCount = 3; - this.movTogglesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); - this.movTogglesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); - this.movTogglesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.34F)); - - this.toggleMovAutomatico.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleMovAutomatico.Titulo = "Movimento automático"; - this.toggleMovSonar.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleMovSonar.Titulo = "Assistido por sonar"; - this.toggleParadaObstaculo.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleParadaObstaculo.Titulo = "Parada por obstáculo"; - this.toggleMovImu.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleMovImu.Titulo = "Assistido por IMU"; - this.toggleParadaInclinacao.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleParadaInclinacao.Titulo = "Parada por inclinação"; - this.toggleFrenagemParar.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleFrenagemParar.Titulo = "Frenagem ao parar"; - - this.movValuesLayout.ColumnCount = 1; - this.movValuesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.movValuesLayout.Controls.Add(this.paramVelSemErvas, 0, 0); - this.movValuesLayout.Controls.Add(this.paramVelComErvas, 0, 1); - this.movValuesLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.movValuesLayout.RowCount = 2; - this.movValuesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.movValuesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - - SetupValueBox(this.paramVelSemErvas, "Vel. sem ervas", "%", 50, 0, 100, 0); - SetupValueBox(this.paramVelComErvas, "Vel. com ervas", "%", 35, 0, 100, 0); - - // direcional - this.direcionalLayout.ColumnCount = 2; - this.direcionalLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 45F)); - this.direcionalLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 55F)); - this.direcionalLayout.Controls.Add(this.lblDirecionalTitulo, 0, 0); - this.direcionalLayout.Controls.Add(this.dirTogglesLayout, 0, 1); - this.direcionalLayout.Controls.Add(this.dirValuesLayout, 1, 1); - this.direcionalLayout.SetColumnSpan(this.lblDirecionalTitulo, 2); - this.direcionalLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.direcionalLayout.RowCount = 2; - this.direcionalLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 23F)); - this.direcionalLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - - SetupTitle(this.lblDirecionalTitulo, "3 DIRECIONAL"); - - this.dirTogglesLayout.ColumnCount = 1; - this.dirTogglesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.dirTogglesLayout.Controls.Add(this.toggleDirAutomatico, 0, 0); - this.dirTogglesLayout.Controls.Add(this.toggleDirSonar, 0, 1); - this.dirTogglesLayout.Controls.Add(this.toggleDirImu, 0, 2); - this.dirTogglesLayout.Controls.Add(this.toggleImuPrefereArco, 0, 3); - this.dirTogglesLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.dirTogglesLayout.RowCount = 4; - for (int i = 0; i < 4; i++) - this.dirTogglesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); - - this.toggleDirAutomatico.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleDirAutomatico.Titulo = "Direcional automático"; - this.toggleDirSonar.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleDirSonar.Titulo = "Assistido por sonar"; - this.toggleDirImu.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleDirImu.Titulo = "Assistido por IMU"; - this.toggleImuPrefereArco.Dock = System.Windows.Forms.DockStyle.Fill; - this.toggleImuPrefereArco.Titulo = "IMU prefere arco"; - this.toggleImuPrefereArco.Checked = false; - - this.dirValuesLayout.ColumnCount = 3; - this.dirValuesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); - this.dirValuesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F)); - this.dirValuesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.34F)); - this.dirValuesLayout.Controls.Add(this.paramAnguloMaximo, 0, 0); - this.dirValuesLayout.Controls.Add(this.paramVelMovimentoDir, 1, 0); - this.dirValuesLayout.Controls.Add(this.pnlTipoControle, 2, 0); - this.dirValuesLayout.Dock = System.Windows.Forms.DockStyle.Fill; - - SetupValueBox(this.paramAnguloMaximo, "Ângulo máximo", "°", 45, 0, 90, 0); - SetupValueBox(this.paramVelMovimentoDir, "Vel. movimento", "%", 60, 0, 100, 0); - - this.pnlTipoControle.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; - this.pnlTipoControle.Controls.Add(this.tipoControleLayout); - this.pnlTipoControle.CornerRadius = 7; - this.pnlTipoControle.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlTipoControle.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.SurfaceRaised; - this.pnlTipoControle.Margin = new System.Windows.Forms.Padding(2); - this.pnlTipoControle.Padding = new System.Windows.Forms.Padding(5); - - this.tipoControleLayout.ColumnCount = 2; - this.tipoControleLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tipoControleLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tipoControleLayout.Controls.Add(this.lblTipoControle, 0, 0); - this.tipoControleLayout.Controls.Add(this.btnControleMpc, 0, 1); - this.tipoControleLayout.Controls.Add(this.btnControlePid, 1, 1); - this.tipoControleLayout.SetColumnSpan(this.lblTipoControle, 2); - this.tipoControleLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.tipoControleLayout.RowCount = 2; - this.tipoControleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 23F)); - this.tipoControleLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - - this.lblTipoControle.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblTipoControle.Text = "Tipo de controle"; - this.lblTipoControle.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; - this.lblTipoControle.Font = new System.Drawing.Font("Segoe UI", 7F); - this.lblTipoControle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - - SetupChoiceButton(this.btnControleMpc, "MPC"); - SetupChoiceButton(this.btnControlePid, "PID"); - - // atuador - this.atuadorLayout.ColumnCount = 2; - this.atuadorLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 42F)); - this.atuadorLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 58F)); - this.atuadorLayout.Controls.Add(this.lblAtuadorTitulo, 0, 0); - this.atuadorLayout.Controls.Add(this.togglePulverizadorAutomatico, 1, 0); - this.atuadorLayout.Controls.Add(this.cmbModoAgitador, 0, 1); - this.atuadorLayout.Controls.Add(this.atuadorValuesLayout, 0, 2); - this.atuadorLayout.SetColumnSpan(this.atuadorValuesLayout, 2); - this.atuadorLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.atuadorLayout.RowCount = 3; - this.atuadorLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); - this.atuadorLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 34F)); - this.atuadorLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - - SetupTitle(this.lblAtuadorTitulo, "4 ATUADOR"); - - this.togglePulverizadorAutomatico.Dock = System.Windows.Forms.DockStyle.Fill; - this.togglePulverizadorAutomatico.Titulo = "Pulverizador automático"; - - this.cmbModoAgitador.Dock = System.Windows.Forms.DockStyle.Fill; - this.cmbModoAgitador.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cmbModoAgitador.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cmbModoAgitador.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.SurfaceRaised; - this.cmbModoAgitador.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.Text; - this.cmbModoAgitador.Items.AddRange(new object[] { "Sem agitação", "Contínuo", "Intermitente" }); - this.cmbModoAgitador.SelectedIndex = 1; - this.atuadorLayout.SetColumnSpan(this.cmbModoAgitador, 2); - - this.atuadorValuesLayout.ColumnCount = 4; - this.atuadorValuesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.atuadorValuesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.atuadorValuesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.atuadorValuesLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.atuadorValuesLayout.Controls.Add(this.paramBicosEmUso, 0, 0); - this.atuadorValuesLayout.Controls.Add(this.paramCapacidadeReservatorio, 1, 0); - this.atuadorValuesLayout.Controls.Add(this.paramPressaoLinha, 2, 0); - this.atuadorValuesLayout.Controls.Add(this.paramTelaIniciar, 3, 0); - this.atuadorValuesLayout.Controls.Add(this.paramAlturaArea, 0, 1); - this.atuadorValuesLayout.Controls.Add(this.paramErvasOn, 1, 1); - this.atuadorValuesLayout.Controls.Add(this.paramErvasOff, 2, 1); - this.atuadorValuesLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.atuadorValuesLayout.RowCount = 2; - this.atuadorValuesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.atuadorValuesLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - - SetupValueBox(this.paramBicosEmUso, "Bicos em uso", "", 6, 1, 12, 0); - SetupValueBox(this.paramCapacidadeReservatorio, "Capacidade reservatório", "L", 200, 50, 500, 0); - SetupValueBox(this.paramPressaoLinha, "Pressão da linha", "psi", 45, 0, 120, 0); - SetupValueBox(this.paramTelaIniciar, "% tela para iniciar", "%", 40, 0, 100, 0); - SetupValueBox(this.paramAlturaArea, "Altura da área", "%", 60, 0, 100, 0); - SetupValueBox(this.paramErvasOn, "% ervas ON", "%", 25, 0, 100, 0); - SetupValueBox(this.paramErvasOff, "% ervas OFF", "%", 15, 0, 100, 0); - - // MPC - this.mpcLayout.ColumnCount = 3; - this.mpcLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); - this.mpcLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); - this.mpcLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); - this.mpcLayout.Controls.Add(this.lblMpcTitulo, 0, 0); - this.mpcLayout.Controls.Add(this.paramHorizonte, 1, 0); - this.mpcLayout.Controls.Add(this.paramAnteciparFim, 2, 0); - this.mpcLayout.Dock = System.Windows.Forms.DockStyle.Fill; - - SetupTitle(this.lblMpcTitulo, "5 MPC E NAVEGAÇÃO"); - SetupValueBox(this.paramHorizonte, "Horizonte de predição", "m", 12, 0, 30, 1); - SetupValueBox(this.paramAnteciparFim, "Antecipar fim corredor", "m", 5, 0, 15, 1); - - // right - this.rightLayout.BackColor = System.Drawing.Color.Transparent; - this.rightLayout.ColumnCount = 1; - this.rightLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.rightLayout.Controls.Add(this.pnlMapa, 0, 0); - this.rightLayout.Controls.Add(this.footerLayout, 0, 1); - this.rightLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.rightLayout.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0); - this.rightLayout.RowCount = 2; - this.rightLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F)); - this.rightLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - - ConfigurePanel(this.pnlMapa, this.mapLayout); - - this.mapLayout.ColumnCount = 1; - this.mapLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.mapLayout.Controls.Add(this.mapHeaderLayout, 0, 0); - this.mapLayout.Controls.Add(this.pnlMapaVisual, 0, 1); - this.mapLayout.Controls.Add(this.lblMapaAjuda, 0, 2); - this.mapLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.mapLayout.RowCount = 3; - this.mapLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F)); - this.mapLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.mapLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); - - this.mapHeaderLayout.ColumnCount = 3; - this.mapHeaderLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.mapHeaderLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 82F)); - this.mapHeaderLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 90F)); - this.mapHeaderLayout.Controls.Add(this.lblMapaTitulo, 0, 0); - this.mapHeaderLayout.Controls.Add(this.btnMapaBonito, 1, 0); - this.mapHeaderLayout.Controls.Add(this.btnMapaDinamico, 2, 0); - this.mapHeaderLayout.Dock = System.Windows.Forms.DockStyle.Fill; - - SetupTitle(this.lblMapaTitulo, "6 MAPA DA OPERAÇÃO"); - SetupChoiceButton(this.btnMapaBonito, "Mapa bonito"); - SetupChoiceButton(this.btnMapaDinamico, "Mapa dinâmico"); - - this.pnlMapaVisual.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; - this.pnlMapaVisual.Controls.Add(this.lblMapaPlaceholder); - this.pnlMapaVisual.CornerRadius = 8; - this.pnlMapaVisual.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlMapaVisual.FillColor = System.Drawing.Color.FromArgb(18, 29, 22); - - this.lblMapaPlaceholder.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblMapaPlaceholder.BackColor = System.Drawing.Color.Transparent; - this.lblMapaPlaceholder.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.Success; - this.lblMapaPlaceholder.Font = new System.Drawing.Font("Consolas", 8.5F, System.Drawing.FontStyle.Bold); - this.lblMapaPlaceholder.Text = - "MAPA DA OPERAÇÃO\n\n" + - "01 02 03 04 05\n" + - "│ │ │ │ │\n" + - "│ │ │ │ │\n" + - "│ │ [ROVER] │ │\n" + - "│ │ │ │ │\n" + - "09 10 11 12\n\n" + - "8 ruas selecionadas"; - this.lblMapaPlaceholder.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - - this.lblMapaAjuda.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblMapaAjuda.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.SurfaceRaised; - this.lblMapaAjuda.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; - this.lblMapaAjuda.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Italic); - this.lblMapaAjuda.Text = "Toque nas ruas para selecionar ou desmarcar."; - this.lblMapaAjuda.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - - // footer - this.footerLayout.ColumnCount = 2; - this.footerLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 48F)); - this.footerLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 52F)); - this.footerLayout.Controls.Add(this.btnAplicarAtual, 0, 0); - this.footerLayout.Controls.Add(this.btnSalvarParametros, 1, 0); + // footerLayout + this.footerLayout.BackColor = System.Drawing.Color.Transparent; + this.footerLayout.ColumnCount = 5; + this.footerLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 55F)); + this.footerLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 128F)); + this.footerLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.footerLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 135F)); + this.footerLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 145F)); + this.footerLayout.Controls.Add(this.lblModoOperacao, 0, 0); + this.footerLayout.Controls.Add(this.cmbModoOperacao, 1, 0); + this.footerLayout.Controls.Add(this.posProcessamentoLayout, 2, 0); + this.footerLayout.Controls.Add(this.btnRedefinir, 3, 0); + this.footerLayout.Controls.Add(this.btnSalvar, 4, 0); this.footerLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.footerLayout.Margin = new System.Windows.Forms.Padding(0); + this.footerLayout.Margin = System.Windows.Forms.Padding.Empty; + this.footerLayout.Padding = System.Windows.Forms.Padding.Empty; + this.footerLayout.RowCount = 1; + this.footerLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - SetupAction(this.btnAplicarAtual, "APLICAR À OPERAÇÃO ATUAL", "▤", AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted); - SetupAction(this.btnSalvarParametros, "SALVAR PARÂMETROS", "▣", AgroBase.Forms.IHM.Controls.HmiTheme.Success); + // lblModoOperacao + SetupFooterLabel(this.lblModoOperacao, "Modo"); + this.lblModoOperacao.Padding = new System.Windows.Forms.Padding(2, 0, 0, 0); - // user control + // cmbModoOperacao + this.cmbModoOperacao.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.cmbModoOperacao.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.SurfaceRaised; + this.cmbModoOperacao.Dock = System.Windows.Forms.DockStyle.None; + this.cmbModoOperacao.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbModoOperacao.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.cmbModoOperacao.Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Bold); + this.cmbModoOperacao.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.Text; + this.cmbModoOperacao.Margin = System.Windows.Forms.Padding.Empty; + this.cmbModoOperacao.Size = new System.Drawing.Size(120, 25); + + // posProcessamentoLayout + this.posProcessamentoLayout.BackColor = System.Drawing.Color.Transparent; + this.posProcessamentoLayout.ColumnCount = 2; + this.posProcessamentoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.posProcessamentoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.posProcessamentoLayout.Controls.Add(this.lblPosProcessamento, 0, 0); + this.posProcessamentoLayout.Controls.Add(this.checkPosProcessamento, 1, 0); + this.posProcessamentoLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.posProcessamentoLayout.Margin = new System.Windows.Forms.Padding(6, 0, 8, 0); + this.posProcessamentoLayout.Padding = System.Windows.Forms.Padding.Empty; + this.posProcessamentoLayout.RowCount = 1; + this.posProcessamentoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + + // lblPosProcessamento + this.lblPosProcessamento.AutoEllipsis = true; + this.lblPosProcessamento.BackColor = System.Drawing.Color.Transparent; + this.lblPosProcessamento.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblPosProcessamento.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Bold); + this.lblPosProcessamento.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; + this.lblPosProcessamento.Margin = new System.Windows.Forms.Padding(0, 0, 5, 0); + this.lblPosProcessamento.Text = "Registrar pós-processamento"; + this.lblPosProcessamento.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + + // checkPosProcessamento + this.checkPosProcessamento.Anchor = System.Windows.Forms.AnchorStyles.None; + this.checkPosProcessamento.Appearance = System.Windows.Forms.Appearance.Button; + this.checkPosProcessamento.AutoSize = false; + this.checkPosProcessamento.BackColor = System.Drawing.Color.FromArgb(30, 90, 46); + this.checkPosProcessamento.Checked = true; + this.checkPosProcessamento.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkPosProcessamento.Cursor = System.Windows.Forms.Cursors.Hand; + this.checkPosProcessamento.Dock = System.Windows.Forms.DockStyle.None; + this.checkPosProcessamento.FlatAppearance.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Success; + this.checkPosProcessamento.FlatAppearance.BorderSize = 1; + this.checkPosProcessamento.FlatAppearance.CheckedBackColor = System.Drawing.Color.FromArgb(30, 90, 46); + this.checkPosProcessamento.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.checkPosProcessamento.Font = new System.Drawing.Font("Segoe UI Symbol", 8F, System.Drawing.FontStyle.Bold); + this.checkPosProcessamento.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.Success; + this.checkPosProcessamento.Margin = System.Windows.Forms.Padding.Empty; + this.checkPosProcessamento.Padding = System.Windows.Forms.Padding.Empty; + this.checkPosProcessamento.Size = new System.Drawing.Size(22, 22); + this.checkPosProcessamento.Text = "✓"; + this.checkPosProcessamento.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.checkPosProcessamento.UseVisualStyleBackColor = false; + + // btnRedefinir + SetupFooterAction(this.btnRedefinir, "REDEFINIR", "↻", AgroBase.Forms.IHM.Controls.HmiTheme.Warning); + + // btnSalvar + SetupFooterAction(this.btnSalvar, "SALVAR", "▣", AgroBase.Forms.IHM.Controls.HmiTheme.Success); + + // ucOperacaoParametros this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Background; this.Controls.Add(this.rootLayout); @@ -536,183 +218,81 @@ this.Size = new System.Drawing.Size(784, 435); this.rootLayout.ResumeLayout(false); - this.leftLayout.ResumeLayout(false); - this.pnlGeral.ResumeLayout(false); - this.geralLayout.ResumeLayout(false); - this.pnlMovimento.ResumeLayout(false); - this.movimentoLayout.ResumeLayout(false); - this.movTogglesLayout.ResumeLayout(false); - this.movValuesLayout.ResumeLayout(false); - this.pnlDirecional.ResumeLayout(false); - this.direcionalLayout.ResumeLayout(false); - this.dirTogglesLayout.ResumeLayout(false); - this.dirValuesLayout.ResumeLayout(false); - this.pnlTipoControle.ResumeLayout(false); - this.tipoControleLayout.ResumeLayout(false); - this.pnlAtuador.ResumeLayout(false); - this.atuadorLayout.ResumeLayout(false); - this.atuadorValuesLayout.ResumeLayout(false); - this.pnlMpc.ResumeLayout(false); - this.mpcLayout.ResumeLayout(false); - this.rightLayout.ResumeLayout(false); - this.pnlMapa.ResumeLayout(false); - this.mapLayout.ResumeLayout(false); - this.mapHeaderLayout.ResumeLayout(false); - this.pnlMapaVisual.ResumeLayout(false); + this.tabsLayout.ResumeLayout(false); + this.pnlDescricaoAba.ResumeLayout(false); + this.footerPanel.ResumeLayout(false); this.footerLayout.ResumeLayout(false); + this.posProcessamentoLayout.ResumeLayout(false); this.ResumeLayout(false); } - private static void ConfigurePanel( - AgroBase.Forms.IHM.Controls.HmiRoundedPanel panel, - System.Windows.Forms.Control child) + private static void SetupTabButton(System.Windows.Forms.Button button, string text) { - panel.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; - panel.Controls.Add(child); - panel.CornerRadius = 9; - panel.Dock = System.Windows.Forms.DockStyle.Fill; - panel.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.Surface; - panel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3); - panel.Padding = new System.Windows.Forms.Padding(7); + button.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.Surface; + button.Cursor = System.Windows.Forms.Cursors.Hand; + button.Dock = System.Windows.Forms.DockStyle.Fill; + button.FlatAppearance.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; + button.FlatAppearance.BorderSize = 1; + button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + button.Font = new System.Drawing.Font("Segoe UI", 8.5F, System.Drawing.FontStyle.Bold); + button.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; + button.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + button.Text = text; + button.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + button.UseVisualStyleBackColor = false; } - private static void SetupTitle( - System.Windows.Forms.Label label, - string text) + private static void SetupFooterLabel(System.Windows.Forms.Label label, string text) { - label.Dock = System.Windows.Forms.DockStyle.Fill; + label.AutoEllipsis = true; label.BackColor = System.Drawing.Color.Transparent; - label.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.Text; - label.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + label.Dock = System.Windows.Forms.DockStyle.Fill; + label.Font = new System.Drawing.Font("Segoe UI", 7.2F, System.Drawing.FontStyle.Bold); + label.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; + label.Margin = System.Windows.Forms.Padding.Empty; label.Text = text; label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - label.AutoEllipsis = true; } - private static void SetupChoiceButton( - System.Windows.Forms.Button button, - string text) + private static void SetupFooterAction(AgroBase.Forms.IHM.Controls.HmiSidebarButton button, string text, string icon, System.Drawing.Color accent) { - button.Dock = System.Windows.Forms.DockStyle.Fill; - button.Text = text; - button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - button.FlatAppearance.BorderColor = AgroBase.Forms.IHM.Controls.HmiTheme.Border; - button.BackColor = AgroBase.Forms.IHM.Controls.HmiTheme.SurfaceRaised; - button.ForeColor = AgroBase.Forms.IHM.Controls.HmiTheme.TextMuted; - button.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Bold); - button.Margin = new System.Windows.Forms.Padding(2); - } - - private static void SetupValueBox( - AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox control, - string title, - string unit, - decimal value, - decimal min, - decimal max, - int decimals) - { - control.Dock = System.Windows.Forms.DockStyle.Fill; - control.Titulo = title; - control.Unidade = unit; - control.Minimo = min; - control.Maximo = max; - control.CasasDecimais = decimals; - control.Valor = value; - } - - private static void SetupAction( - AgroBase.Forms.IHM.Controls.HmiSidebarButton button, - string text, - string icon, - System.Drawing.Color accent) - { - button.Dock = System.Windows.Forms.DockStyle.Fill; - button.Text = text; - button.IconText = icon; button.AccentColor = accent; button.BorderColor = accent; + button.Cursor = System.Windows.Forms.Cursors.Hand; + button.Dock = System.Windows.Forms.DockStyle.Fill; button.FillColor = AgroBase.Forms.IHM.Controls.HmiTheme.SurfaceRaised; - button.Margin = new System.Windows.Forms.Padding(3); + button.IconText = icon; + button.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0); + button.MaximumSize = System.Drawing.Size.Empty; + button.MinimumSize = System.Drawing.Size.Empty; + button.Text = text; } #endregion private System.Windows.Forms.TableLayoutPanel rootLayout; - private System.Windows.Forms.TableLayoutPanel leftLayout; + private System.Windows.Forms.TableLayoutPanel tabsLayout; + private System.Windows.Forms.Button btnAbaMovimento; + private System.Windows.Forms.Button btnAbaDirecional; + private System.Windows.Forms.Button btnAbaAtuador; + private System.Windows.Forms.Button btnAbaMapa; - private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlGeral; - private System.Windows.Forms.TableLayoutPanel geralLayout; - private System.Windows.Forms.Label lblGeralTitulo; - private System.Windows.Forms.Label lblModoOperacao; - private System.Windows.Forms.Button btnModoManual; - private System.Windows.Forms.Button btnModoMapaGps; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleRegistrarDados; + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlDescricaoAba; + private System.Windows.Forms.Label lblDescricaoAba; - private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlMovimento; - private System.Windows.Forms.TableLayoutPanel movimentoLayout; - private System.Windows.Forms.Label lblMovimentoTitulo; - private System.Windows.Forms.TableLayoutPanel movTogglesLayout; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleMovAutomatico; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleMovSonar; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleParadaObstaculo; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleMovImu; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleParadaInclinacao; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleFrenagemParar; - private System.Windows.Forms.TableLayoutPanel movValuesLayout; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramVelSemErvas; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramVelComErvas; - - private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlDirecional; - private System.Windows.Forms.TableLayoutPanel direcionalLayout; - private System.Windows.Forms.Label lblDirecionalTitulo; - private System.Windows.Forms.TableLayoutPanel dirTogglesLayout; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleDirAutomatico; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleDirSonar; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleDirImu; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow toggleImuPrefereArco; - private System.Windows.Forms.TableLayoutPanel dirValuesLayout; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramAnguloMaximo; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramVelMovimentoDir; - private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlTipoControle; - private System.Windows.Forms.TableLayoutPanel tipoControleLayout; - private System.Windows.Forms.Label lblTipoControle; - private System.Windows.Forms.Button btnControleMpc; - private System.Windows.Forms.Button btnControlePid; - - private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlAtuador; - private System.Windows.Forms.TableLayoutPanel atuadorLayout; - private System.Windows.Forms.Label lblAtuadorTitulo; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterToggleRow togglePulverizadorAutomatico; - private System.Windows.Forms.ComboBox cmbModoAgitador; - private System.Windows.Forms.TableLayoutPanel atuadorValuesLayout; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramBicosEmUso; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramCapacidadeReservatorio; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramPressaoLinha; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramTelaIniciar; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramAlturaArea; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramErvasOn; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramErvasOff; - - private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlMpc; - private System.Windows.Forms.TableLayoutPanel mpcLayout; - private System.Windows.Forms.Label lblMpcTitulo; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramHorizonte; - private AgroBase.Forms.IHM.Controls.Operacao.HmiParameterValueBox paramAnteciparFim; - - private System.Windows.Forms.TableLayoutPanel rightLayout; - private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlMapa; - private System.Windows.Forms.TableLayoutPanel mapLayout; - private System.Windows.Forms.TableLayoutPanel mapHeaderLayout; - private System.Windows.Forms.Label lblMapaTitulo; - private System.Windows.Forms.Button btnMapaBonito; - private System.Windows.Forms.Button btnMapaDinamico; - private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlMapaVisual; - private System.Windows.Forms.Label lblMapaPlaceholder; - private System.Windows.Forms.Label lblMapaAjuda; + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel pnlConteudo; + private AgroBase.Forms.IHM.Controls.HmiRoundedPanel footerPanel; private System.Windows.Forms.TableLayoutPanel footerLayout; - private AgroBase.Forms.IHM.Controls.HmiSidebarButton btnAplicarAtual; - private AgroBase.Forms.IHM.Controls.HmiSidebarButton btnSalvarParametros; + + private System.Windows.Forms.Label lblModoOperacao; + private System.Windows.Forms.ComboBox cmbModoOperacao; + + private System.Windows.Forms.TableLayoutPanel posProcessamentoLayout; + private System.Windows.Forms.Label lblPosProcessamento; + private System.Windows.Forms.CheckBox checkPosProcessamento; + + private AgroBase.Forms.IHM.Controls.HmiSidebarButton btnRedefinir; + private AgroBase.Forms.IHM.Controls.HmiSidebarButton btnSalvar; } -} +} \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoParametros.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoParametros.cs index b579ce1dd..b481958c2 100644 --- a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoParametros.cs +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoParametros.cs @@ -1,133 +1,236 @@ using AgroBase.Forms.IHM.Controls; +using AgroBase.Forms.IHM.Operacao.Parametros; using System; +using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; +using static AgroBase.Models.Enums; namespace AgroBase.Forms.IHM.Operacao { public partial class ucOperacaoParametros : UserControl { + private readonly Dictionary _abas; + private TipoAbaParametros _abaAtual; + + private readonly ucParametrosMovimento _ucMovimento; + private readonly ucParametrosDirecional _ucDirecional; + private readonly ucParametrosAtuador _ucAtuador; + private readonly ucParametrosMapa _ucMapa; + + public event EventHandler RedefinirSolicitado; + public event EventHandler SalvarSolicitado; + public event EventHandler ModoOperacaoAlterado; + public event EventHandler RegistrarPosProcessamentoAlterado; + public ucOperacaoParametros() { InitializeComponent(); + + _ucMovimento = new ucParametrosMovimento(); + _ucDirecional = new ucParametrosDirecional(); + _ucAtuador = new ucParametrosAtuador(); + _ucMapa = new ucParametrosMapa(); + + _abas = new Dictionary(); + _abas.Add(TipoAbaParametros.Movimento, _ucMovimento); + _abas.Add(TipoAbaParametros.Direcional, _ucDirecional); + _abas.Add(TipoAbaParametros.Atuador, _ucAtuador); + _abas.Add(TipoAbaParametros.Mapa, _ucMapa); + + ConfigurarSubControles(); ConfigurarEstadoInicial(); VincularEventos(); } + private void ConfigurarSubControles() + { + foreach (KeyValuePair item in _abas) + { + item.Value.Dock = DockStyle.Fill; + item.Value.Margin = Padding.Empty; + item.Value.Visible = false; + pnlConteudo.Controls.Add(item.Value); + } + } + private void ConfigurarEstadoInicial() { - btnMapaBonito.BackColor = - Color.FromArgb(31, 91, 43); + cmbModoOperacao.Items.Clear(); + cmbModoOperacao.Items.AddRange(Enum.GetNames(typeof(ModoOperacao))); - btnMapaBonito.ForeColor = - HmiTheme.Text; + if (cmbModoOperacao.Items.Count > 1) + cmbModoOperacao.SelectedIndex = 1; - btnMapaBonito.FlatAppearance.BorderColor = - HmiTheme.Success; + checkPosProcessamento.Checked = true; + AtualizarAparenciaCheck(checkPosProcessamento); - btnModoMapaGps.BackColor = - Color.FromArgb(31, 91, 43); - - btnModoMapaGps.ForeColor = - HmiTheme.Text; - - btnModoMapaGps.FlatAppearance.BorderColor = - HmiTheme.Success; - - btnControleMpc.BackColor = - Color.FromArgb(31, 91, 43); - - btnControleMpc.ForeColor = - HmiTheme.Text; - - btnControleMpc.FlatAppearance.BorderColor = - HmiTheme.Success; + AbrirAba(TipoAbaParametros.Movimento); } private void VincularEventos() { - btnModoManual.Click += delegate + btnAbaMovimento.Click += delegate { AbrirAba(TipoAbaParametros.Movimento); }; + btnAbaDirecional.Click += delegate { AbrirAba(TipoAbaParametros.Direcional); }; + btnAbaAtuador.Click += delegate { AbrirAba(TipoAbaParametros.Atuador); }; + btnAbaMapa.Click += delegate { AbrirAba(TipoAbaParametros.Mapa); }; + + btnRedefinir.Click += delegate { - SelecionarBotaoDuplo( - btnModoManual, - btnModoMapaGps); + if (RedefinirSolicitado != null) + RedefinirSolicitado(this, EventArgs.Empty); }; - btnModoMapaGps.Click += delegate + btnSalvar.Click += delegate { - SelecionarBotaoDuplo( - btnModoMapaGps, - btnModoManual); + if (SalvarSolicitado != null) + SalvarSolicitado(this, EventArgs.Empty); }; - btnControleMpc.Click += delegate + cmbModoOperacao.SelectedIndexChanged += delegate { - SelecionarBotaoDuplo( - btnControleMpc, - btnControlePid); + if (ModoOperacaoAlterado != null) + ModoOperacaoAlterado(this, EventArgs.Empty); }; - btnControlePid.Click += delegate + checkPosProcessamento.CheckedChanged += delegate { - SelecionarBotaoDuplo( - btnControlePid, - btnControleMpc); - }; + AtualizarAparenciaCheck(checkPosProcessamento); - btnMapaBonito.Click += delegate - { - SelecionarBotaoDuplo( - btnMapaBonito, - btnMapaDinamico); - }; - - btnMapaDinamico.Click += delegate - { - SelecionarBotaoDuplo( - btnMapaDinamico, - btnMapaBonito); + if (RegistrarPosProcessamentoAlterado != null) + RegistrarPosProcessamentoAlterado(this, EventArgs.Empty); }; } - private static void SelecionarBotaoDuplo( - Button selecionado, - Button outro) + private void AbrirAba(TipoAbaParametros aba) { - AplicarEstadoBotao( - selecionado, - true); + _abaAtual = aba; - AplicarEstadoBotao( - outro, - false); + foreach (KeyValuePair item in _abas) + item.Value.Visible = item.Key == aba; + + UserControl controleAtual; + if (_abas.TryGetValue(aba, out controleAtual)) + { + controleAtual.BringToFront(); + controleAtual.Visible = true; + } + + AplicarEstadoBotaoAba(btnAbaMovimento, aba == TipoAbaParametros.Movimento); + AplicarEstadoBotaoAba(btnAbaDirecional, aba == TipoAbaParametros.Direcional); + AplicarEstadoBotaoAba(btnAbaAtuador, aba == TipoAbaParametros.Atuador); + AplicarEstadoBotaoAba(btnAbaMapa, aba == TipoAbaParametros.Mapa); + + AtualizarDescricaoAba(aba); } - private static void AplicarEstadoBotao( - Button button, - bool selecionado) + private void AtualizarDescricaoAba(TipoAbaParametros aba) + { + switch (aba) + { + case TipoAbaParametros.Movimento: + lblDescricaoAba.Text = "Automação, assistências e velocidades de deslocamento"; + break; + case TipoAbaParametros.Direcional: + lblDescricaoAba.Text = "Controle direcional, assistências, ângulo e velocidade"; + break; + case TipoAbaParametros.Atuador: + lblDescricaoAba.Text = "Pulverizador, agitador, reservatório e critérios de atuação"; + break; + case TipoAbaParametros.Mapa: + lblDescricaoAba.Text = "Mapa da operação, seleção de ruas e parâmetros de navegação"; + break; + default: + lblDescricaoAba.Text = string.Empty; + break; + } + } + + private static void AplicarEstadoBotaoAba(Button button, bool selecionado) { if (selecionado) { - button.BackColor = - Color.FromArgb(31, 91, 43); - - button.ForeColor = - HmiTheme.Text; - - button.FlatAppearance.BorderColor = - HmiTheme.Success; + button.BackColor = Color.FromArgb(46, 31, 63); + button.ForeColor = Color.FromArgb(190, 121, 255); + button.FlatAppearance.BorderColor = Color.FromArgb(170, 90, 240); } else { - button.BackColor = - HmiTheme.SurfaceRaised; - - button.ForeColor = - HmiTheme.TextMuted; - - button.FlatAppearance.BorderColor = - HmiTheme.Border; + button.BackColor = HmiTheme.Surface; + button.ForeColor = HmiTheme.TextMuted; + button.FlatAppearance.BorderColor = HmiTheme.Border; } } + + private static void AtualizarAparenciaCheck(CheckBox check) + { + if (check.Checked) + { + check.Text = "✓"; + check.ForeColor = HmiTheme.Success; + check.BackColor = Color.FromArgb(30, 90, 46); + check.FlatAppearance.BorderColor = HmiTheme.Success; + } + else + { + check.Text = "×"; + check.ForeColor = HmiTheme.Danger; + check.BackColor = HmiTheme.Surface; + check.FlatAppearance.BorderColor = HmiTheme.Danger; + } + } + + public string ModoOperacaoSelecionado + { + get { return Convert.ToString(cmbModoOperacao.SelectedItem); } + set + { + if (string.IsNullOrWhiteSpace(value)) + return; + + int index = cmbModoOperacao.FindStringExact(value); + if (index >= 0) + cmbModoOperacao.SelectedIndex = index; + } + } + + public bool RegistrarPosProcessamento + { + get { return checkPosProcessamento.Checked; } + set { checkPosProcessamento.Checked = value; } + } + + public TipoAbaParametros AbaAtual + { + get { return _abaAtual; } + } + + public ucParametrosMovimento Movimento + { + get { return _ucMovimento; } + } + + public ucParametrosDirecional Direcional + { + get { return _ucDirecional; } + } + + public ucParametrosAtuador Atuador + { + get { return _ucAtuador; } + } + + public ucParametrosMapa Mapa + { + get { return _ucMapa; } + } + } + + public enum TipoAbaParametros + { + Movimento = 0, + Direcional = 1, + Atuador = 2, + Mapa = 3 } } diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoPulverizador.Designer.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoPulverizador.Designer.cs index f80cfcd1e..8e7a8ee93 100644 --- a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoPulverizador.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoPulverizador.Designer.cs @@ -402,13 +402,7 @@ button.MaximumSize = System.Drawing.Size.Empty; } - private static void SetupHealth( - AgroBase.Forms.IHM.Controls.Operacao.HmiSprayerModuleHealthRow row, - string icon, - string title, - string health, - string status, - System.Drawing.Color color) + private static void SetupHealth(AgroBase.Forms.IHM.Controls.Operacao.HmiSprayerModuleHealthRow row, string icon, string title, string health, string status, System.Drawing.Color color) { row.Dock = System.Windows.Forms.DockStyle.Fill; row.IconText = icon; @@ -430,9 +424,7 @@ combo.Margin = new System.Windows.Forms.Padding(0, 1, 0, 1); } - private static void SetupNozzle( - AgroBase.Forms.IHM.Controls.Operacao.HmiNozzleCard card, - string code) + private static void SetupNozzle(AgroBase.Forms.IHM.Controls.Operacao.HmiNozzleCard card, string code) { card.Dock = System.Windows.Forms.DockStyle.Fill; card.Codigo = code; diff --git a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoPulverizador.cs b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoPulverizador.cs index 0ddb2a28c..7138d2bff 100644 --- a/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoPulverizador.cs +++ b/AgroBase/AgroBase/Forms/IHM/Operacao/ucOperacaoPulverizador.cs @@ -1,16 +1,27 @@ using AgroBase.Forms.IHM.Controls; using AgroBase.Forms.IHM.Controls.Operacao; +using AgroBase.Models; +using AgroBase.Models.Operadores; +using AgroBase.Services.Operadores; +using Assimp.Unmanaged; using System; using System.Collections.Generic; using System.Drawing; +using System.Linq; +using System.Threading.Tasks; using System.Windows.Forms; +using static AgroBase.Models.Enums; namespace AgroBase.Forms.IHM.Operacao { public partial class ucOperacaoPulverizador : UserControl { - private readonly List _bicos = - new List(); + private bool _requisitandoCameraFrame; + private bool _controleDescartado; + + OperacaoModel op => Variaveis.OperacaoEmAndamento; + + private readonly List _bicos = new List(); public ucOperacaoPulverizador() { @@ -20,6 +31,205 @@ namespace AgroBase.Forms.IHM.Operacao VincularEventos(); } + public void AtualizarDadosTela() + { + var dados = op?.Sensoriamento; + + AtualizarDadosBomba(); + AtualizarDadosAgitador(); + AtualizarSaudeModulos(); + AtualizarDadosCamera(dados?.Cameras?.FirstOrDefault(x => x.dispositivo == Enums.T_Code.Cam), dados?.OperadorSaude?.ModulosSaude?.FirstOrDefault(x => x.modulo == T_Code.Cam)?.saude ?? 0); + AtualizarDadosBicos(dados?.Atuador?.Bicos, dados?.OperadorSaude?.ModulosSaude?.FirstOrDefault(x => x.modulo == T_Code.Atu)); + AtualizarDadosTelemetria(dados?.Atuador); + } + + private void AtualizarDadosBomba() + { + double pressaoSP = op?.Parametros?.Controle?.AtuPressaoLinha ?? 0; + bool bombaLigada = op?.Sensoriamento?.Atuador?.BombaLigada ?? false; + + cardPressaoSp.Valor = pressaoSP.ToString("F1"); + cardStatusBomba.Valor = bombaLigada ? "Ligada" : "Desligada"; + cardStatusBomba.CorValor = bombaLigada ? HmiTheme.Success : HmiTheme.Danger; + } + + private void AtualizarDadosAgitador() + { + Enums.ModoAgitadorCalda modo = op?.Parametros?.Controle?.AtuAgitadorModo ?? Enums.ModoAgitadorCalda.SemAgitacao; + bool agitadorLigado = (op?.Sensoriamento?.Atuador?.PotenciaAgitador ?? 0) > 0; + + cardModoAgitador.Valor = modo.ToString(); + cardStatusAgitador.Valor = agitadorLigado ? "Ligado" : "Desligado"; + cardStatusAgitador.CorValor = agitadorLigado ? HmiTheme.Success : HmiTheme.Danger; + } + + private void AtualizarSaudeModulos() + { + var saude_m = op?.Sensoriamento?.OperadorSaude?.ModulosSaude; + var saude_i = saude_m?.FirstOrDefault(x => x.modulo == Enums.T_Code.Atu)?.saude_individual; + + var saudeBomba = saude_i?.FirstOrDefault(x => x.label == op?.DispAtu?.Dados?.BombaPressurizadora?.ID); + var saudeAgitador = saude_i?.FirstOrDefault(x => x.label == op?.DispAtu?.Dados?.AgitadorDeCalda?.ID); + var saudeSensores = saude_i?.Where(x => op?.DispAtu?.Dados?.Sensores?.Where(y => y.Aferir)?.Select(y => y.ID).Contains(x.label) ?? false)?.ToList(); + var saudeBicos = saude_i?.Where(x => op?.DispAtu?.Dados?.BicosPulverizadores?.Where(y => y.Comandar)?.Select(y => y.ID).Contains(x.label) ?? false)?.ToList(); + var saudeCamera = saude_m?.FirstOrDefault(x => x.modulo == Enums.T_Code.Cam); + + var saudeSensoresMedia = saudeSensores?.Average(x => x.saude) ?? 0; + Enums.StatusModulo saudeSensoresStatus = + saudeSensoresMedia >= 80 ? Enums.StatusModulo.Operante : + saudeSensoresMedia <= 0 ? Enums.StatusModulo.Falha : + Enums.StatusModulo.Alerta; + + var saudeBicosMedia = saudeBicos?.Average(x => x.saude) ?? 0; + Enums.StatusModulo saudeBicosStatus = + saudeBicosMedia >= 80 ? Enums.StatusModulo.Operante : + saudeBicosMedia <= 0 ? Enums.StatusModulo.Falha : + Enums.StatusModulo.Alerta; + + void DefinirSaudeModulo(HmiSprayerModuleHealthRow card, double saude, Enums.StatusModulo status) + { + card.Saude = saude.ToString("F0") + "%"; + card.Status = status.ToString(); + card.StatusColor = + status == Enums.StatusModulo.Operante ? HmiTheme.Success : + status == Enums.StatusModulo.Alerta ? HmiTheme.Warning : + status == Enums.StatusModulo.Falha ? HmiTheme.Danger : + status == Enums.StatusModulo.Desconectado ? HmiTheme.Disabled : + status == Enums.StatusModulo.Conectado ? HmiTheme.Info : + HmiTheme.Disabled; + } + + DefinirSaudeModulo(healthBomba, saudeBomba?.saude ?? 0, saudeBomba?.status ?? Enums.StatusModulo.Desconectado); + DefinirSaudeModulo(healthAgitador, saudeAgitador?.saude ?? 0, saudeAgitador?.status ?? Enums.StatusModulo.Desconectado); + DefinirSaudeModulo(healthSensores, saudeSensoresMedia, saudeSensoresStatus); + DefinirSaudeModulo(healthBicos, saudeBicosMedia, saudeBicosStatus); + DefinirSaudeModulo(healthCamera, saudeCamera?.saude ?? 0, saudeCamera?.status ?? Enums.StatusModulo.Desconectado); + } + + public async void AtualizarDadosCamera(CameraWorkerItemModel dados, double saude) + { + lblVideoStatus.Text = $"FPS {dados?.fps ?? 0:F0} · {dados?.stream_kbps ?? 0:F1} MB/s · Saúde {saude:F0}%"; + + if (!_requisitandoCameraFrame) + _ = RequisitarCameraFrameAsync(); + } + + private async Task RequisitarCameraFrameAsync() + { + if (_requisitandoCameraFrame || _controleDescartado) + return; + + _requisitandoCameraFrame = true; + + try + { + TipoFrameCamera tipoFrame = (TipoFrameCamera)cmbTipoFrame.SelectedIndex; + + var frame = await WeedWorkerService.GetCameraFrame(tipoFrame); + + if (_controleDescartado || frame == null) + return; + + Image imagemRecebida = frame.image(); + + if (imagemRecebida == null) + return; + + // Garante que o PictureBox receba uma imagem independente + // de streams ou buffers internos do frame. + Image imagemSegura; + + using (imagemRecebida) + { + imagemSegura = new Bitmap(imagemRecebida); + } + + AtualizarImagemPainel(picVideo, imagemSegura); + } + catch (OutOfMemoryException ex) + { + // Em System.Drawing isso também pode significar + // imagem ou stream inválido, não só falta real de RAM. + Variaveis.MostrarLog("[IHM][Câmera] Frame inválido ou erro de memória: " + ex.Message); + } + catch (Exception ex) + { + Variaveis.MostrarLog("[IHM][Câmera] Erro ao obter frame: " + ex.Message); + } + finally + { + _requisitandoCameraFrame = false; + } + } + + private void AtualizarImagemPainel(PictureBox pictureBox, Image novaImagem) + { + if (pictureBox == null) + { + novaImagem?.Dispose(); + return; + } + + if (pictureBox.IsDisposed || pictureBox.Disposing || _controleDescartado) + { + novaImagem?.Dispose(); + return; + } + + if (pictureBox.InvokeRequired) + { + try + { + pictureBox.BeginInvoke(new Action(AtualizarImagemPainel), pictureBox, novaImagem); + } + catch + { + novaImagem?.Dispose(); + } + + return; + } + + Image imagemAnterior = pictureBox.Image; + pictureBox.Image = novaImagem; + imagemAnterior?.Dispose(); + } + + private void AtualizarDadosBicos(List dados, ManagerWorkerMessageResponseModulosPendentesModel saude) + { + foreach (var bico in dados) + { + var card = Bicos.FirstOrDefault(x => x.Codigo == bico.ID); + card.Atuacoes = bico.Atuacoes; + card.VazaoInstantanea = 0; + card.VazaoMedia = bico.MediaNivelFluxo; + card.TempoLigado = bico.TempoAtuado.ToString(); + + card.CommandOn = bico.Atuado; + card.ReadOn = bico.StatusBico; + card.State = saude?.saude_individual?.FirstOrDefault(x => x.label == bico.ID)?.status ?? StatusModulo.Desconectado; + } + } + + private void AtualizarDadosTelemetria(AtuadorLogModel dados) + { + TimeSpan tempoAutonomia = TimeSpan.FromMinutes(Math.Max(0, dados?.TempoEstimadoRestanteMinutos ?? 0)); + TimeSpan tempoPulverizador = TimeSpan.FromSeconds(Math.Max(0, dados?.TempoPulverizadorAtuado ?? 0)); + + telemetryReservatorio.Valor = (dados?.VolumeReservatorio ?? 0).ToString("F1") + " L"; + telemetryVazaoInstantanea.Valor = (dados?.VazaoFluxoMLpSInstantaneaCorrigida ?? 0).ToString("F0") + " mL/s"; + telemetryVazaoMedia.Valor = (dados?.VazaoFluxoMLpSMedia ?? 0).ToString("F0") + " mL/s"; + telemetryPressaoSensor.Valor = (dados?.PressaoSensor ?? 0).ToString("F1") + " psi"; + telemetryPressaoBomba.Valor = (dados?.PressaoAtualBomba ?? 0).ToString("F1") + " psi"; + telemetryAutonomiaM.Valor = (dados?.DistanciaEstimadaRestanteMetros ?? 0).ToString("F1") + " m"; + telemetryAutonomiaTempo.Valor = FormatarTempo(tempoAutonomia); + telemetryVolumeAplicado.Valor = (dados?.VolumeVazaoML ?? 0).ToString("F1") + " L"; + telemetryLitroMetro.Valor = (dados?.LPorMetro ?? 0).ToString("F1") + " L/m"; + telemetryInfestacao.Valor = (dados?.PercentualErvasTerreno ?? 0).ToString("F1") + "% · Baixa"; + telemetryTempoLigado.Valor = FormatarTempo(tempoPulverizador); + } + + private void RegistrarBicos() { _bicos.Add(nozzleB01); @@ -35,61 +245,6 @@ namespace AgroBase.Forms.IHM.Operacao { cmbTipoFrame.SelectedIndex = 0; - nozzleB01.State = HmiNozzleState.Operante; - nozzleB02.State = HmiNozzleState.Conectado; - nozzleB03.State = HmiNozzleState.Falha; - nozzleB04.State = HmiNozzleState.Alerta; - nozzleB05.State = HmiNozzleState.Operante; - nozzleB06.State = HmiNozzleState.Desconectado; - nozzleB07.State = HmiNozzleState.Operante; - - nozzleB01.CommandOn = true; - nozzleB01.ReadOn = true; - nozzleB02.CommandOn = true; - nozzleB02.ReadOn = true; - nozzleB03.CommandOn = true; - nozzleB03.ReadOn = false; - nozzleB04.CommandOn = true; - nozzleB04.ReadOn = true; - nozzleB05.CommandOn = true; - nozzleB05.ReadOn = true; - nozzleB06.CommandOn = false; - nozzleB06.ReadOn = false; - nozzleB07.CommandOn = true; - nozzleB07.ReadOn = true; - - nozzleB01.Atuacoes = 1258; - nozzleB02.Atuacoes = 1187; - nozzleB03.Atuacoes = 892; - nozzleB04.Atuacoes = 1023; - nozzleB05.Atuacoes = 1290; - nozzleB06.Atuacoes = 0; - nozzleB07.Atuacoes = 1211; - - nozzleB01.VazaoInstantanea = 980; - nozzleB02.VazaoInstantanea = 1011; - nozzleB03.VazaoInstantanea = 421; - nozzleB04.VazaoInstantanea = 727; - nozzleB05.VazaoInstantanea = 951; - nozzleB06.VazaoInstantanea = 0; - nozzleB07.VazaoInstantanea = 972; - - nozzleB01.VazaoMedia = 960; - nozzleB02.VazaoMedia = 990; - nozzleB03.VazaoMedia = 631; - nozzleB04.VazaoMedia = 701; - nozzleB05.VazaoMedia = 940; - nozzleB06.VazaoMedia = 0; - nozzleB07.VazaoMedia = 959; - - nozzleB01.TempoLigado = "12:34"; - nozzleB02.TempoLigado = "12:31"; - nozzleB03.TempoLigado = "08:47"; - nozzleB04.TempoLigado = "10:55"; - nozzleB05.TempoLigado = "12:39"; - nozzleB06.TempoLigado = "00:00"; - nozzleB07.TempoLigado = "12:17"; - telemetryReservatorio.CorValor = HmiTheme.Info; telemetryVazaoInstantanea.CorValor = HmiTheme.Success; telemetryVazaoMedia.CorValor = HmiTheme.Success; @@ -121,9 +276,7 @@ namespace AgroBase.Forms.IHM.Operacao card.CommandOn = !card.CommandOn; } - private static void AplicarEstadoPainel( - HmiRoundedPanel panel, - Color color) + private static void AplicarEstadoPainel(HmiRoundedPanel panel, Color color) { panel.BorderColor = color; panel.Invalidate(); @@ -133,5 +286,23 @@ namespace AgroBase.Forms.IHM.Operacao { get { return _bicos.AsReadOnly(); } } + + + + private static string FormatarTempo(TimeSpan tempo) + { + if (tempo < TimeSpan.Zero) + tempo = TimeSpan.Zero; + + int horasTotais = (int)tempo.TotalHours; + + return string.Format( + "{0:00}:{1:00}:{2:00}", + horasTotais, + tempo.Minutes, + tempo.Seconds + ); + } + } } diff --git a/AgroBase/AgroBase/Forms/IHM/frmAjustes.Designer.cs b/AgroBase/AgroBase/Forms/IHM/frmAjustes.Designer.cs index c2c7a9fcf..28a66badc 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmAjustes.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmAjustes.Designer.cs @@ -162,7 +162,7 @@ this.btnVoltar.Margin = new System.Windows.Forms.Padding(0, 2, 8, 2); this.btnVoltar.MinimumSize = new System.Drawing.Size(102, 36); this.btnVoltar.Name = "btnVoltar"; - this.btnVoltar.Size = new System.Drawing.Size(102, 36); + this.btnVoltar.Size = new System.Drawing.Size(102, 42); this.btnVoltar.TabIndex = 0; this.btnVoltar.Text = "VOLTAR"; // @@ -180,7 +180,7 @@ this.headerTextLayout.RowCount = 2; this.headerTextLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60F)); this.headerTextLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); - this.headerTextLayout.Size = new System.Drawing.Size(500, 46); + this.headerTextLayout.Size = new System.Drawing.Size(486, 46); this.headerTextLayout.TabIndex = 1; // // lblTitulo @@ -192,7 +192,7 @@ this.lblTitulo.Location = new System.Drawing.Point(0, 0); this.lblTitulo.Margin = new System.Windows.Forms.Padding(0); this.lblTitulo.Name = "lblTitulo"; - this.lblTitulo.Size = new System.Drawing.Size(500, 27); + this.lblTitulo.Size = new System.Drawing.Size(486, 27); this.lblTitulo.TabIndex = 0; this.lblTitulo.Text = "AJUSTES DO EQUIPAMENTO"; this.lblTitulo.TextAlign = System.Drawing.ContentAlignment.BottomLeft; @@ -206,7 +206,7 @@ this.lblSubtitulo.Location = new System.Drawing.Point(0, 27); this.lblSubtitulo.Margin = new System.Windows.Forms.Padding(0); this.lblSubtitulo.Name = "lblSubtitulo"; - this.lblSubtitulo.Size = new System.Drawing.Size(500, 19); + this.lblSubtitulo.Size = new System.Drawing.Size(486, 19); this.lblSubtitulo.TabIndex = 1; this.lblSubtitulo.Text = "Configurações físicas, câmeras e comunicação do rover"; // @@ -219,12 +219,12 @@ this.pnlRover.CornerRadius = 9; this.pnlRover.Dock = System.Windows.Forms.DockStyle.Fill; this.pnlRover.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(58)))), ((int)(((byte)(46))))); - this.pnlRover.Location = new System.Drawing.Point(607, 0); + this.pnlRover.Location = new System.Drawing.Point(593, 0); this.pnlRover.Margin = new System.Windows.Forms.Padding(5, 0, 0, 0); this.pnlRover.MinimumSize = new System.Drawing.Size(30, 30); this.pnlRover.Name = "pnlRover"; this.pnlRover.Padding = new System.Windows.Forms.Padding(8); - this.pnlRover.Size = new System.Drawing.Size(157, 46); + this.pnlRover.Size = new System.Drawing.Size(171, 46); this.pnlRover.TabIndex = 2; // // lblRover @@ -235,7 +235,7 @@ this.lblRover.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(72)))), ((int)(((byte)(210)))), ((int)(((byte)(122))))); this.lblRover.Location = new System.Drawing.Point(8, 8); this.lblRover.Name = "lblRover"; - this.lblRover.Size = new System.Drawing.Size(141, 30); + this.lblRover.Size = new System.Drawing.Size(155, 30); this.lblRover.TabIndex = 0; this.lblRover.Text = "ROVER 01\r\nConfiguração local"; this.lblRover.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -577,6 +577,7 @@ this.btnRestaurar.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(63)))), ((int)(((byte)(69))))); this.btnRestaurar.Cursor = System.Windows.Forms.Cursors.Hand; this.btnRestaurar.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41))))); + this.btnRestaurar.IconText = "●"; this.btnRestaurar.Location = new System.Drawing.Point(334, 2); this.btnRestaurar.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2); this.btnRestaurar.MinimumSize = new System.Drawing.Size(130, 36); @@ -592,6 +593,7 @@ this.btnSalvar.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(63)))), ((int)(((byte)(69))))); this.btnSalvar.Cursor = System.Windows.Forms.Cursors.Hand; this.btnSalvar.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41))))); + this.btnSalvar.IconText = "●"; this.btnSalvar.Location = new System.Drawing.Point(464, 2); this.btnSalvar.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2); this.btnSalvar.MinimumSize = new System.Drawing.Size(130, 36); @@ -607,6 +609,7 @@ this.btnTestarComunicacao.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(63)))), ((int)(((byte)(69))))); this.btnTestarComunicacao.Cursor = System.Windows.Forms.Cursors.Hand; this.btnTestarComunicacao.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41))))); + this.btnTestarComunicacao.IconText = "●"; this.btnTestarComunicacao.Location = new System.Drawing.Point(609, 2); this.btnTestarComunicacao.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2); this.btnTestarComunicacao.MinimumSize = new System.Drawing.Size(130, 36); diff --git a/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs b/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs index 639650c91..5b71df3d4 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs @@ -15,6 +15,8 @@ namespace AgroBase.Forms.IHM { public partial class frmAjustes : Form, ITelaNavegavel { + public event EventHandler VoltarSolicitado; + private List ListaCameras = new List(); private OAKCameraModel CameraCaminho = new OAKCameraModel(); private List CamerasSolo = new List(); @@ -22,8 +24,6 @@ namespace AgroBase.Forms.IHM private bool _carregando; private bool _alteracoesPendentes; - public event EventHandler VoltarSolicitado; - public frmAjustes() { InitializeComponent(); @@ -56,6 +56,11 @@ namespace AgroBase.Forms.IHM } } + public void AtualizarDadosTela() + { + + } + private void ConfigurarAparencia() { @@ -1330,5 +1335,7 @@ namespace AgroBase.Forms.IHM { ("OK", null), delegate { } } }); } + + } } diff --git a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs index 8bdd07bba..6ca65b8a4 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs @@ -219,7 +219,7 @@ this.btnVoltar.Margin = new System.Windows.Forms.Padding(0, 3, 8, 3); this.btnVoltar.MinimumSize = new System.Drawing.Size(102, 36); this.btnVoltar.Name = "btnVoltar"; - this.btnVoltar.Size = new System.Drawing.Size(102, 36); + this.btnVoltar.Size = new System.Drawing.Size(102, 40); this.btnVoltar.TabIndex = 0; this.btnVoltar.Text = "VOLTAR"; // @@ -231,7 +231,7 @@ this.headerTextLayout.Controls.Add(this.lblTitulo, 0, 0); this.headerTextLayout.Controls.Add(this.lblSubtitulo, 0, 1); this.headerTextLayout.Dock = System.Windows.Forms.DockStyle.Fill; - this.headerTextLayout.Location = new System.Drawing.Point(111, 0); + this.headerTextLayout.Location = new System.Drawing.Point(109, 0); this.headerTextLayout.Margin = new System.Windows.Forms.Padding(7, 0, 5, 0); this.headerTextLayout.Name = "headerTextLayout"; this.headerTextLayout.RowCount = 2; @@ -278,12 +278,12 @@ this.pnlHeaderImpedimento.CornerRadius = 8; this.pnlHeaderImpedimento.Dock = System.Windows.Forms.DockStyle.Fill; this.pnlHeaderImpedimento.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(35)))), ((int)(((byte)(14))))); - this.pnlHeaderImpedimento.Location = new System.Drawing.Point(471, 3); + this.pnlHeaderImpedimento.Location = new System.Drawing.Point(469, 3); this.pnlHeaderImpedimento.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.pnlHeaderImpedimento.MinimumSize = new System.Drawing.Size(30, 30); this.pnlHeaderImpedimento.Name = "pnlHeaderImpedimento"; this.pnlHeaderImpedimento.Padding = new System.Windows.Forms.Padding(7); - this.pnlHeaderImpedimento.Size = new System.Drawing.Size(177, 40); + this.pnlHeaderImpedimento.Size = new System.Drawing.Size(179, 40); this.pnlHeaderImpedimento.TabIndex = 2; // // lblImpedimentoGeral @@ -295,7 +295,7 @@ this.lblImpedimentoGeral.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(181)))), ((int)(((byte)(68))))); this.lblImpedimentoGeral.Location = new System.Drawing.Point(7, 7); this.lblImpedimentoGeral.Name = "lblImpedimentoGeral"; - this.lblImpedimentoGeral.Size = new System.Drawing.Size(163, 26); + this.lblImpedimentoGeral.Size = new System.Drawing.Size(165, 26); this.lblImpedimentoGeral.TabIndex = 0; this.lblImpedimentoGeral.Text = "⚠ Impedimento: IMU instável"; this.lblImpedimentoGeral.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -1114,6 +1114,7 @@ this.btnSalvarModulo.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(63)))), ((int)(((byte)(69))))); this.btnSalvarModulo.Cursor = System.Windows.Forms.Cursors.Hand; this.btnSalvarModulo.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41))))); + this.btnSalvarModulo.IconText = "●"; this.btnSalvarModulo.Location = new System.Drawing.Point(178, 2); this.btnSalvarModulo.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2); this.btnSalvarModulo.MinimumSize = new System.Drawing.Size(130, 36); @@ -1129,6 +1130,7 @@ this.actionsLayout.SetColumnSpan(this.btnIgnorarFalha, 3); this.btnIgnorarFalha.Cursor = System.Windows.Forms.Cursors.Hand; this.btnIgnorarFalha.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41))))); + this.btnIgnorarFalha.IconText = "●"; this.btnIgnorarFalha.Location = new System.Drawing.Point(0, 38); this.btnIgnorarFalha.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2); this.btnIgnorarFalha.MinimumSize = new System.Drawing.Size(130, 36); @@ -1472,6 +1474,7 @@ this.btnAcao1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(63)))), ((int)(((byte)(69))))); this.btnAcao1.Cursor = System.Windows.Forms.Cursors.Hand; this.btnAcao1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41))))); + this.btnAcao1.IconText = "●"; this.btnAcao1.Location = new System.Drawing.Point(0, 2); this.btnAcao1.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2); this.btnAcao1.MinimumSize = new System.Drawing.Size(130, 36); @@ -1486,6 +1489,7 @@ this.btnAcao2.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(63)))), ((int)(((byte)(69))))); this.btnAcao2.Cursor = System.Windows.Forms.Cursors.Hand; this.btnAcao2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41))))); + this.btnAcao2.IconText = "●"; this.btnAcao2.Location = new System.Drawing.Point(114, 2); this.btnAcao2.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2); this.btnAcao2.MinimumSize = new System.Drawing.Size(130, 36); @@ -1500,6 +1504,7 @@ this.btnAcao3.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(63)))), ((int)(((byte)(69))))); this.btnAcao3.Cursor = System.Windows.Forms.Cursors.Hand; this.btnAcao3.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41))))); + this.btnAcao3.IconText = "●"; this.btnAcao3.Location = new System.Drawing.Point(228, 2); this.btnAcao3.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2); this.btnAcao3.MinimumSize = new System.Drawing.Size(130, 36); diff --git a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs index 75bc06008..013bd52c3 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs @@ -1,4 +1,5 @@ using AgroBase.Forms.IHM.Controls; +using AgroBase.Models; using System; using System.Collections.Generic; using System.Drawing; @@ -8,11 +9,12 @@ namespace AgroBase.Forms.IHM { public partial class frmDiagnosticos : Form, ITelaNavegavel { + public event EventHandler VoltarSolicitado; + private readonly List _badges = new List(); private readonly Dictionary _estadoOriginalBadges = new Dictionary(); - public event EventHandler VoltarSolicitado; - + public frmDiagnosticos() { InitializeComponent(); @@ -23,6 +25,11 @@ namespace AgroBase.Forms.IHM VincularEventos(); } + public void AtualizarDadosTela() + { + + } + private void OrganizarCamadasMapa() { picRover.SendToBack(); diff --git a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs index 4a4d5b26f..65031053e 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs @@ -239,8 +239,7 @@ namespace AgroBase.Forms.IHM } catch (Exception ex) { - Console.WriteLine( - "Erro no tmrDispositivos_Tick: " + ex.Message); + Variaveis.MostrarLog("Erro no tmrDispositivos_Tick: " + ex.Message); } return Task.CompletedTask; @@ -259,239 +258,84 @@ namespace AgroBase.Forms.IHM // ========================================================= // BATERIA // ========================================================= - - double bateria = - operacao? - .Sensoriamento? - .Bateria? - .PercentualBateria ?? 0; - - double bateriaSaude = - ObterSaudeModulo( - saudeModulos, - Enums.T_Code.Bat - ); - - Color corBateria = - CorPorValorESaude( - bateria, - bateriaSaude - ); - - AtualizarBateria( - $"{Limitar(bateria, 0, 100):0}%", - corBateria - ); + double bateria = operacao?.Sensoriamento?.Bateria?.PercentualBateria ?? 0; + double bateriaSaude = ObterSaudeModulo(saudeModulos, Enums.T_Code.Bat); + Color corBateria = CorPorValorESaude(bateria, bateriaSaude); + AtualizarBateria($"{Limitar(bateria, 0, 100):0}%", corBateria); // ========================================================= // RESERVATÓRIO // ========================================================= - - double reservatorio = - operacao? - .Sensoriamento? - .Atuador? - .VolumeReservatorio ?? 0; - - double atuadorSaude = - ObterSaudeModulo( - saudeModulos, - Enums.T_Code.Atu - ); - - /* - * Estou considerando VolumeReservatorio como percentual. - * - * Se ele estiver em litros, converta antes: - * - * reservatorio = - * capacidadeLitros > 0 - * ? volumeAtualLitros / capacidadeLitros * 100 - * : 0; - */ - - Color corReservatorio = - CorPorValorESaude( - reservatorio, - atuadorSaude - ); - - AtualizarReservatorio( - $"{Limitar(reservatorio, 0, 100):0}%", - corReservatorio - ); + double reservatorio = operacao?.Sensoriamento?.Atuador?.PercentualReservatorio ?? 0; + double atuadorSaude = ObterSaudeModulo(saudeModulos, Enums.T_Code.Atu); + Color corReservatorio = CorPorValorESaude(reservatorio, atuadorSaude); + AtualizarReservatorio($"{Limitar(reservatorio, 0, 100):0}%", corReservatorio); // ========================================================= // TEMPERATURA // ========================================================= - - double temperatura = - operacao? - .Sensoriamento? - .CoolerControl? - .Temperatura ?? 0; - - double temperaturaSaude = - ObterSaudeModulo( - saudeModulos, - Enums.T_Code.Npc - ); - - Color corTemperatura = - CorTemperatura( - temperatura, - temperaturaSaude - ); - - AtualizarTemperatura( - $"{temperatura:0.#} °C", - corTemperatura - ); + double temperatura = operacao?.Sensoriamento?.CoolerControl?.Temperatura ?? 0; + double temperaturaSaude = ObterSaudeModulo(saudeModulos, Enums.T_Code.Npc); + Color corTemperatura = CorTemperatura(temperatura, temperaturaSaude); + AtualizarTemperatura($"{temperatura:0.#} °C", corTemperatura); // ========================================================= // REDE / IPB // ========================================================= - - double redeSaude = - ObterSaudeModulo( - saudeModulos, - Enums.T_Code.Ipb - ); - - Color corRede = - CorPorPercentual(redeSaude); - - AtualizarRede( - $"{Limitar(redeSaude, 0, 100):0}%", - corRede - ); + double redeSaude = ObterSaudeModulo(saudeModulos, Enums.T_Code.Ipb); + Color corRede = CorPorPercentual(redeSaude); + AtualizarRede($"{Limitar(redeSaude, 0, 100):0}%", corRede); // ========================================================= // GNSS // ========================================================= - - var gnss = - operacao? - .Sensoriamento? - .Gps; - - double gnssSaude = - ObterSaudeModulo( - saudeModulos, - Enums.T_Code.Gps - ); - - bool gnssConectado = - gnss != null && - gnssSaude > 0; - + var gnss = operacao?.Sensoriamento?.Gps; + double gnssSaude = ObterSaudeModulo(saudeModulos, Enums.T_Code.Gps); + bool gnssConectado = gnss != null && gnssSaude > 0; if (!gnssConectado) { - AtualizarGnss( - "Desconectado", - HmiTheme.Danger - ); + AtualizarGnss("Desconectado", HmiTheme.Danger); } else { - Enums.TiposCorrecaoGPS qualidadeFix = - gnss.QualidadeFix; - - double precisaoCm = - Math.Max( - 0, - gnss.PrecisaoCm - ); - - double notaGnss = - CalcularNotaGnss( - qualidadeFix, - precisaoCm, - gnssSaude - ); - - Color corGnss = - CorPorPercentual(notaGnss); - - string textoGnss = - $"{FormatarQualidadeGnss(qualidadeFix)} " + - $"{precisaoCm:0.##} cm"; - - AtualizarGnss( - textoGnss, - corGnss - ); + Enums.TiposCorrecaoGPS qualidadeFix = gnss.QualidadeFix; + double precisaoCm = Math.Max(0, gnss.PrecisaoCm); + double notaGnss = CalcularNotaGnss(qualidadeFix, precisaoCm, gnssSaude); + Color corGnss = CorPorPercentual(notaGnss); + string textoGnss = $"{FormatarQualidadeGnss(qualidadeFix)} " + $"{precisaoCm:0.##} cm"; + AtualizarGnss(textoGnss, corGnss); } // ========================================================= // BASE // ========================================================= - - bool baseConectada = - VariaveisOperacao - .PosicaoBase - .Inicializado; - + bool baseConectada = VariaveisOperacao.PosicaoBase?.Inicializado ?? false; if (!baseConectada || gnss == null) { - AtualizarDistanciaBase( - "Desconectada", - HmiTheme.Danger - ); + AtualizarDistanciaBase("Desconectada", HmiTheme.Danger); } else { - double distanciaBase = - GPSUtils.DistanciaEntrePontos( - gnss, - VariaveisOperacao.PosicaoBase - ); - - Color corBase = - CorDistanciaBase( - distanciaBase, - 1000 - ); - - string distanciaTexto = - FormatarDistancia(distanciaBase); - - AtualizarDistanciaBase( - distanciaTexto, - corBase - ); + double distanciaBase = GPSUtils.DistanciaEntrePontos(gnss, VariaveisOperacao.PosicaoBase); + Color corBase = CorDistanciaBase(distanciaBase, 1000); + string distanciaTexto = FormatarDistancia(distanciaBase); + AtualizarDistanciaBase(distanciaTexto, corBase); } // ========================================================= // BOTÕES DA OPERAÇÃO // ========================================================= - - bool operacaoPausada = - dadosOperacao?.Pausa ?? false; - - bool operacaoEmergencia = - dadosOperacao?.Emergencia ?? false; - - bool operacaoIniciada = - dadosOperacao?.OperacaoIniciada ?? false; - - AtualizarAcoesOperacao( - statusOperacao, - operacaoIniciada, - operacaoPausada, - operacaoEmergencia - ); + bool operacaoPausada = dadosOperacao?.Pausa ?? false; + bool operacaoEmergencia = dadosOperacao?.Emergencia ?? false; + bool operacaoIniciada = dadosOperacao?.OperacaoIniciada ?? false; + AtualizarAcoesOperacao(statusOperacao, operacaoIniciada, operacaoPausada, operacaoEmergencia); // ========================================================= // FORMULÁRIO FILHO ATIVO // ========================================================= - - if ( - _telaAtual != null && - !_telaAtual.IsDisposed && - _telaAtual.Name == frmMenu.Name) + if (_telaAtual != null && !_telaAtual.IsDisposed) { - frmMenu.AtualizarControlesUI(); + (_telaAtual as ITelaNavegavel).AtualizarDadosTela(); } } @@ -1040,6 +884,7 @@ namespace AgroBase.Forms.IHM public interface ITelaNavegavel { event EventHandler VoltarSolicitado; + void AtualizarDadosTela(); } } diff --git a/AgroBase/AgroBase/Forms/IHM/frmMenu.cs b/AgroBase/AgroBase/Forms/IHM/frmMenu.cs index e93c32aa4..ebeaf313e 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmMenu.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmMenu.cs @@ -13,7 +13,7 @@ using static AgroBase.Models.Enums; namespace AgroBase.Forms.IHM { - public partial class frmMenu : Form + public partial class frmMenu : Form, ITelaNavegavel { private bool _sincronizando; @@ -24,6 +24,7 @@ namespace AgroBase.Forms.IHM public event EventHandler AjustarLeverArmSolicitado; public event EventHandler TelaSolicitada; + public event EventHandler VoltarSolicitado; public frmMenu() { @@ -72,6 +73,11 @@ namespace AgroBase.Forms.IHM } + public void AtualizarDadosTela() + { + AtualizarControlesUI(); + } + public void AtualizarControlesUI() { bool mqttConectado = Variaveis.MqttServiceLocal != null && Variaveis.MqttServiceLocal.StatusConexao(); @@ -382,7 +388,8 @@ namespace AgroBase.Forms.IHM VincularCliqueRecursivo(filho, acao); } } - + + } diff --git a/AgroBase/AgroBase/Forms/IHM/frmOperacao.cs b/AgroBase/AgroBase/Forms/IHM/frmOperacao.cs index 20e4e6935..d98520ba6 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmOperacao.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmOperacao.cs @@ -1,5 +1,6 @@  using AgroBase.Forms.IHM.Operacao; +using AgroBase.Models; using System; using System.Windows.Forms; @@ -25,16 +26,18 @@ namespace AgroBase.Forms.IHM public partial class frmOperacao : Form, ITelaNavegavel { - private AbaOperacaoIHM _abaAtual; - public event EventHandler VoltarSolicitado; - public event EventHandler AbaAlterada; + private AbaOperacaoIHM _abaAtual; + public event EventHandler AbaAlterada; private readonly ucOperacaoMovimentacao _ucMovimentacao = new ucOperacaoMovimentacao { Dock = DockStyle.Fill }; private readonly ucOperacaoPulverizador _ucPulverizador = new ucOperacaoPulverizador { Dock = DockStyle.Fill }; private readonly ucOperacaoNavegacao _ucNavegacao = new ucOperacaoNavegacao { Dock = DockStyle.Fill }; private readonly ucOperacaoParametros _ucParametros = new ucOperacaoParametros { Dock = DockStyle.Fill }; + public Panel PainelConteudo { get { return pnlConteudoAba; } } + public AbaOperacaoIHM AbaAtual { get { return _abaAtual; } } + public frmOperacao() { InitializeComponent(); @@ -42,8 +45,25 @@ namespace AgroBase.Forms.IHM SelecionarAba(AbaOperacaoIHM.Movimentacao, false); } - public Panel PainelConteudo { get { return pnlConteudoAba; } } - public AbaOperacaoIHM AbaAtual { get { return _abaAtual; } } + public void AtualizarDadosTela() + { + switch (_abaAtual) + { + case AbaOperacaoIHM.Movimentacao: + _ucMovimentacao.AtualizarDadosTela(); + break; + case AbaOperacaoIHM.Pulverizador: + _ucPulverizador.AtualizarDadosTela(); + break; + case AbaOperacaoIHM.Navegacao: + break; + case AbaOperacaoIHM.Parametros: + break; + } + } + + + private void VincularEventos() { @@ -59,6 +79,7 @@ namespace AgroBase.Forms.IHM tabParametros.Click += delegate { SelecionarAba(AbaOperacaoIHM.Parametros, true); }; } + public void SelecionarAba(AbaOperacaoIHM aba) { SelecionarAba(aba, true); diff --git a/AgroBase/AgroBase/Forms/frmPrincipal.cs b/AgroBase/AgroBase/Forms/frmPrincipal.cs index 3fa05c451..93843c3c8 100644 --- a/AgroBase/AgroBase/Forms/frmPrincipal.cs +++ b/AgroBase/AgroBase/Forms/frmPrincipal.cs @@ -256,6 +256,9 @@ namespace AgroBase private void btnJoyAtt_Click(object sender, EventArgs e) { GeneralJoystick.AtualizaDispositivo(); + cmbJoysticks.Items.Clear(); + cmbJoysticks.Items.AddRange(GeneralJoystick.JoysticksConectados.ToArray()); + cmbJoysticks.SelectedIndex = GeneralJoystick.JoysticksConectados.IndexOf(GeneralJoystick.JoystickConectado.Information.InstanceName); } private void btnJoyEdt_Click(object sender, EventArgs e) diff --git a/AgroBase/AgroBase/Models/GeneralJoystick.cs b/AgroBase/AgroBase/Models/GeneralJoystick.cs index 3770c9fb4..9807bbf18 100644 --- a/AgroBase/AgroBase/Models/GeneralJoystick.cs +++ b/AgroBase/AgroBase/Models/GeneralJoystick.cs @@ -15,6 +15,7 @@ namespace AgroBase { public class GeneralJoystick { + public static List JoysticksConectados = new List(); public static Joystick JoystickConectado = null; public static int MargemAnalogico = 100; public static int MaximoAnalogico = 65534; @@ -66,17 +67,18 @@ namespace AgroBase { DispCon = Variaveis.DispositivosConectados.Where(x => x.Dados.ConexaoAtiva).ToList(); frmInstancial.frmJoystick.lblDispositivo.Text = "Dispositivos: " + (DispCon.Count == 0 ? "N/A" : string.Join(", ", DispCon.Select(x => x._Descricao + " (" + Enum.GetName(typeof(T_Code), x.Dispositivo) + ")").ToArray())); - frmInstancial.frmPrincipal.cmbJoysticks.Items.Clear(); InicializarJoysticksConectados(); return true; }); - FuncoesGlobais.ExecutarMetodoComVerificacaoCrossThread(frmInstancial.frmPrincipal.cmbJoysticks, funcAtt); + FuncoesGlobais.ExecutarMetodoComVerificacaoCrossThread(frmInstancial.frmJoystick.lblDispositivo, funcAtt); } public static void InicializarJoysticksConectados() { + JoysticksConectados = new List(); + var directInput = new DirectInput(); // Find a Joystick Guid @@ -85,7 +87,7 @@ namespace AgroBase foreach (var deviceInstance in directInput.GetDevices(DeviceType.Gamepad, DeviceEnumerationFlags.AllDevices)) { joystickGuid = deviceInstance.InstanceGuid; - frmInstancial.frmPrincipal.cmbJoysticks.Items.Add(deviceInstance.InstanceName); + JoysticksConectados.Add(deviceInstance.InstanceName); } // If Gamepad not found, look for a Joystick @@ -94,7 +96,7 @@ namespace AgroBase foreach (var deviceInstance in directInput.GetDevices(DeviceType.Joystick, DeviceEnumerationFlags.AllDevices)) { joystickGuid = deviceInstance.InstanceGuid; - frmInstancial.frmPrincipal.cmbJoysticks.Items.Add(deviceInstance.InstanceName); + JoysticksConectados.Add(deviceInstance.InstanceName); } } @@ -127,7 +129,6 @@ namespace AgroBase if (JoystickConectado != null) { tmrJoystick.Start(); - frmInstancial.frmPrincipal.cmbJoysticks.SelectedIndex = 0; } } @@ -553,13 +554,16 @@ namespace AgroBase (op.Parametros.Controle.MovimentoAutomatico && Comando.Dispositivo == T_Code.Mov) || (op.Parametros.Controle.DirecionalAutomatico && Comando.Dispositivo == T_Code.Dir); + bool bloqueioCalibragem = + op.Sensoriamento.Operacao.Calibrando; + bool bloqueioOperacional = - op.Sensoriamento.Operacao.Calibrando || !op.Sensoriamento.Operacao.OperacaoLiberada || !op.Sensoriamento.Operacao.OperacaoIniciada; bool deveInterromper = bloqueioAutomatico || + bloqueioCalibragem || !VerificaComandoValidoSonar(Comando.key) || (!ForcarComando && bloqueioOperacional); diff --git a/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs b/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs index 87e694206..3d416ced2 100644 --- a/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs +++ b/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs @@ -4938,6 +4938,14 @@ namespace AgroBase.Models public List Logs { get; set; } = new List(); // CoolerControl public CoolerControlDataModel CoolerControl { get; set; } = new CoolerControlDataModel(); + // Cameras + public List Cameras { get; set; } = new List(); + public void AtualizarCameras() + { + Cameras = CameraWorkerService.ListaCameras != null + ? new List(CameraWorkerService.ListaCameras) + : new List(); + } public DateTime UltimoRegistroLog { get; set; } = DateTime.MinValue; @@ -4988,6 +4996,7 @@ namespace AgroBase.Models AtualizarTrajetoria(agora); AtualizarGps(agora); AtualizarLivox(agora); + AtualizarCameras(); DadosPerformance.AtualizarDadosPerformance(); @@ -5031,6 +5040,7 @@ namespace AgroBase.Models var dadosHealthWorker = OperadorSaude?.Clone(); var dadosLivox = LivoxLidar?.Clone(); var dadosCooler = _Cooler?.GetResumo(agora); + var dadosCameras = new List(Cameras ?? new List()); op.Controle.Momento = agora; OperacaoSensoriamentoConjuntoModel dadosAtualizados = new OperacaoSensoriamentoConjuntoModel(op) @@ -5051,6 +5061,7 @@ namespace AgroBase.Models DadosPerformance = dadosPerformance, LivoxLidar = dadosLivox, CoolerControl = dadosCooler, + Cameras = dadosCameras, Logs = op.ListarEventosPendentes(), UltimoRegistroLog = UltimoRegistroLog, }; @@ -5078,6 +5089,7 @@ namespace AgroBase.Models IMU = IMU?.Clone(), LivoxLidar = LivoxLidar?.Clone(), CoolerControl = CoolerControl?.Clone(), + Cameras = new List(Cameras ?? new List()), Logs = new List(Logs ?? new List()), UltimoRegistroLog = UltimoRegistroLog, }; diff --git a/AgroBase/AgroBase/Models/Operacoes/OperacaoParametrosModel.cs b/AgroBase/AgroBase/Models/Operacoes/OperacaoParametrosModel.cs index 69ef7be16..a2d65c14c 100644 --- a/AgroBase/AgroBase/Models/Operacoes/OperacaoParametrosModel.cs +++ b/AgroBase/AgroBase/Models/Operacoes/OperacaoParametrosModel.cs @@ -176,6 +176,36 @@ namespace AgroBase.Models.Operacoes public class OperacaoParametrosControleModel : INotifyPropertyChanged { + private bool _controleManualAcionado; + public bool ControleManualAcionado + { + get => _controleManualAcionado; + set + { + if (_controleManualAcionado != value) + { + _controleManualAcionado = value; + OnPropertyChanged(nameof(ControleManualAcionado)); + + if (_controleManualAcionado) + { + _movimentoAutomaticoAnterior = _movimentoAutomatico; + _direcionalAutomaticoAnterior = _direcionalAutomatico; + _movimentoAutomatico = false; + _direcionalAutomatico = false; + } + else + { + if (_movimentoAutomatico != _movimentoAutomaticoAnterior) + _movimentoAutomatico = _movimentoAutomaticoAnterior; + if (_direcionalAutomatico != _direcionalAutomaticoAnterior) + _direcionalAutomatico = _direcionalAutomaticoAnterior; + } + } + } + } + + private bool _movimentoAutomaticoAnterior; private bool _movimentoAutomatico; public bool MovimentoAutomatico { @@ -190,6 +220,7 @@ namespace AgroBase.Models.Operacoes } } + private bool _direcionalAutomaticoAnterior; private bool _direcionalAutomatico; public bool DirecionalAutomatico {