764 lines
34 KiB
C#
764 lines
34 KiB
C#
using AgroBase.Models;
|
|
using AgroBase.Properties;
|
|
using AgroBase.Services;
|
|
using CefSharp.DevTools.Page;
|
|
using Emgu.CV;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.DataVisualization.Charting;
|
|
|
|
namespace AgroBase.Forms.Operacoes
|
|
{
|
|
public partial class frmResultadosOperacao : Form
|
|
{
|
|
List<OperacaoSensoriamentoLogModel> LogsOperacao = new List<OperacaoSensoriamentoLogModel>();
|
|
List<GPSModel> LogsGPS = new List<GPSModel>();
|
|
List<DirSensoriamentoLogModel> LogsDirecional = new List<DirSensoriamentoLogModel>();
|
|
List<MovSensoriamentoLogModel> LogsMovimentacao = new List<MovSensoriamentoLogModel>();
|
|
List<AtuSensoriamentoLogModel> LogsAtuador = new List<AtuSensoriamentoLogModel>();
|
|
List<SenSensoriamentoLogModel> LogsSensoriamento = new List<SenSensoriamentoLogModel>();
|
|
List<PzmSensoriamentoLogModel> LogsPzem = new List<PzmSensoriamentoLogModel>();
|
|
string pathImagensCaminho = "";
|
|
string pathImagensSoloE = "";
|
|
string pathImagensSoloD = "";
|
|
DateTime MomentoAtual = DateTime.Now;
|
|
Timer tmrPlay = new Timer() { Interval = 1000 };
|
|
MapasModel Mapa = new MapasModel();
|
|
private int idxMomentoAtual
|
|
{
|
|
get
|
|
{
|
|
return LogsOperacao.IndexOf(LogsOperacao.FirstOrDefault(x => x.Momento == MomentoAtual));
|
|
}
|
|
}
|
|
private int idxMomentoFiltro = 0;
|
|
private List<int> idxValoresFiltro = new List<int>();
|
|
|
|
private string[] cmbItemsBuscaPor = new string[] { "Pico Máximo", "Pico Mínimo" };
|
|
|
|
GraficoInterativoModel graficoMovGeral;
|
|
GraficoInterativoModel graficoMovTemperatura;
|
|
GraficoInterativoModel graficoMovPotencia;
|
|
GraficoInterativoModel graficoMovVelocidade;
|
|
GraficoInterativoModel graficoAtu;
|
|
GraficoInterativoModel graficoSen;
|
|
|
|
|
|
public frmResultadosOperacao()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void frmResultadosOperacao_Load(object sender, EventArgs e)
|
|
{
|
|
tmrPlay.Tick += TmrPlay_Tick;
|
|
|
|
picDIR_DF.Image = FuncoesGlobais.EspelharImagemHorizontalmente(Resources.roda_superior);
|
|
picDIR_DT.Image = FuncoesGlobais.EspelharImagemHorizontalmente(Resources.roda_superior);
|
|
}
|
|
|
|
private void TmrPlay_Tick(object sender, EventArgs e)
|
|
{
|
|
if (trbMomento.Value < trbMomento.Maximum)
|
|
{
|
|
trbMomento.Value++;
|
|
}
|
|
else
|
|
{
|
|
tmrPlay.Stop();
|
|
}
|
|
}
|
|
|
|
private void trbMomento_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
MomentoAtual = LogsOperacao.Skip(trbMomento.Value).FirstOrDefault().Momento;
|
|
AtualizarDadosMomento();
|
|
}
|
|
|
|
private void btnPlay_Click(object sender, EventArgs e)
|
|
{
|
|
tmrPlay.Enabled = !tmrPlay.Enabled;
|
|
btnPlay.Text = tmrPlay.Enabled ? "Pause" : "Pay";
|
|
}
|
|
|
|
private void btnCarregarOperacao_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
ofd.Filter = "Arquivos de Operação|*.lgop";
|
|
ofd.InitialDirectory = Application.StartupPath + Variaveis.CaminhoOperacoes;
|
|
if (ofd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
OperacaoDadosModel data = JsonConvert.DeserializeObject<OperacaoDadosModel>(File.ReadAllText(ofd.FileName));
|
|
|
|
LogsOperacao = JsonConvert.DeserializeObject<OperacaoSensoriamentoLogModel[]>(DeserializarDadosOperacao(ofd.FileName, data.operacao)).ToList();
|
|
LogsGPS = JsonConvert.DeserializeObject<GPSModel[]>(DeserializarDadosOperacao(ofd.FileName, data.gps)).ToList();
|
|
LogsDirecional = JsonConvert.DeserializeObject<DirSensoriamentoLogModel[]>(DeserializarDadosOperacao(ofd.FileName, data.dir)).ToList();
|
|
LogsMovimentacao = JsonConvert.DeserializeObject<MovSensoriamentoLogModel[]>(DeserializarDadosOperacao(ofd.FileName, data.mov)).ToList();
|
|
LogsAtuador = JsonConvert.DeserializeObject<AtuSensoriamentoLogModel[]>(DeserializarDadosOperacao(ofd.FileName, data.atu)).ToList();
|
|
LogsSensoriamento = JsonConvert.DeserializeObject<SenSensoriamentoLogModel[]>(DeserializarDadosOperacao(ofd.FileName, data.sen)).ToList();
|
|
LogsPzem = JsonConvert.DeserializeObject<PzmSensoriamentoLogModel[]>(DeserializarDadosOperacao(ofd.FileName, data.pzm)).ToList();
|
|
pathImagensCaminho = ofd.FileName.Replace("data.lgop", data.caminho + "/");
|
|
pathImagensSoloE = ofd.FileName.Replace("data.lgop", data.soloE + "/");
|
|
pathImagensSoloD = ofd.FileName.Replace("data.lgop", data.soloD + "/");
|
|
|
|
Mapa = new MapasModel()
|
|
{
|
|
pnlMapa = pnlMapa
|
|
};
|
|
MapasService.CriarArquivoMapa(new List<List<GPSModel>>() { LogsGPS }, 1517, data.id);
|
|
Mapa.btnCarregar_Click(sender, e, Variaveis.CaminhoSistema + "/" + Variaveis.CaminhoMapasConvertidos + data.id + ".json");
|
|
|
|
trbMomento.Maximum = LogsOperacao.Count - 1;
|
|
trbMomento.Minimum = 0;
|
|
trbMomento.Value = 0;
|
|
|
|
MomentoAtual = LogsOperacao[0].Momento;
|
|
|
|
this.Text = "Resultados da Operação " + LogsOperacao[0].Momento.ToString("dd/MM/yyyy");
|
|
|
|
|
|
InicializarGraficos();
|
|
InicializarCombosBusca();
|
|
|
|
|
|
AtualizarDadosMomento();
|
|
}
|
|
}
|
|
|
|
private void InicializarGraficos()
|
|
{
|
|
var Momentos = LogsOperacao.Select(x => x.Momento.ToString("mm:ss:fff")).ToList();
|
|
|
|
graficoMovGeral = new GraficoInterativoModel(chartMovGeral, Momentos, new List<GraficoInterativoSerieModel>()
|
|
{
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "RPM SP",
|
|
Valores = LogsMovimentacao.GroupBy(x => new {ID = x.Modulo_ID, Momento = x.Momento}).Select(x => x.Average(y => y.RPM_SP)).ToList(),
|
|
Visivel = true,
|
|
MostrarValor = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "EF",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "EF").Select(x => x.RPM).ToList(),
|
|
Visivel = true,
|
|
MostrarValor = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "ET",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "ET").Select(x => x.RPM).ToList(),
|
|
Visivel = true,
|
|
MostrarValor = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "DT",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "DT").Select(x => x.RPM).ToList(),
|
|
Visivel = true,
|
|
MostrarValor = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "DF",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "DF").Select(x => x.RPM).ToList(),
|
|
Visivel = true,
|
|
MostrarValor = true
|
|
},
|
|
});
|
|
|
|
graficoMovTemperatura = new GraficoInterativoModel(chartMovTemperatura, Momentos, new List<GraficoInterativoSerieModel>()
|
|
{
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "EF",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "EF").Select(x => x.Temperatura).ToList(),
|
|
Visivel = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "ET",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "ET").Select(x => x.Temperatura).ToList(),
|
|
Visivel = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "DT",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "DT").Select(x => x.Temperatura).ToList(),
|
|
Visivel = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "DF",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "DF").Select(x => x.Temperatura).ToList(),
|
|
Visivel = true
|
|
},
|
|
});
|
|
|
|
graficoMovVelocidade = new GraficoInterativoModel(chartMovVelocidade, Momentos, new List<GraficoInterativoSerieModel>()
|
|
{
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "EF",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "EF").Select(x => x.Velocidade).ToList(),
|
|
Visivel = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "ET",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "ET").Select(x => x.Velocidade).ToList(),
|
|
Visivel = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "DT",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "DT").Select(x => x.Velocidade).ToList(),
|
|
Visivel = true
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "DF",
|
|
Valores = LogsMovimentacao.Where(x => x.Modulo_ID == "DF").Select(x => x.Velocidade).ToList(),
|
|
Visivel = true
|
|
},
|
|
});
|
|
|
|
graficoAtu = new GraficoInterativoModel(chartAtuador, Momentos, new List<GraficoInterativoSerieModel>()
|
|
{
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "Pressão SP",
|
|
Valores = LogsAtuador.Select(x => x?.PressaoLinha_SP ?? 0).ToList(),
|
|
Visivel = false,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "Pressão",
|
|
Valores = LogsAtuador.Select(x => x?.PressaoLinha ?? 0).ToList(),
|
|
Visivel = true,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "Potência",
|
|
Valores = LogsAtuador.Select(x => x?.PotenciaBomba ?? 0).ToList(),
|
|
Visivel = true,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "Volume",
|
|
Valores = LogsAtuador.Select(x => x?.VolumeReservatorio ?? 0).ToList(),
|
|
Visivel = true,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "Percentual",
|
|
Valores = LogsAtuador.Select(x => x?.PercentualReservatorio ?? 0).ToList(),
|
|
Visivel = true,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "Vazão",
|
|
Valores = LogsAtuador.Select(x => x?.VazaoFluxoMLpS ?? 0).ToList(),
|
|
Visivel = true,
|
|
}
|
|
});
|
|
|
|
graficoSen = new GraficoInterativoModel(chartSensoriamento, Momentos, new List<GraficoInterativoSerieModel>()
|
|
{
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "V 3v3",
|
|
Valores = LogsSensoriamento.Select(x => x?.Barramento3v3Tensao ?? 0).ToList(),
|
|
Visivel = false,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "A 3v3",
|
|
Valores = LogsSensoriamento.Select(x => x?.Barramento3v3Corrente ?? 0).ToList(),
|
|
Visivel = false,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "V 5v0",
|
|
Valores = LogsSensoriamento.Select(x => x?.Barramento5vTensao ?? 0).ToList(),
|
|
Visivel = false,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "A 5v0",
|
|
Valores = LogsSensoriamento.Select(x => x?.Barramento5vCorrente ?? 0).ToList(),
|
|
Visivel = false,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "V 7v2",
|
|
Valores = LogsSensoriamento.Select(x => x?.Barramento7v2Tensao ?? 0).ToList(),
|
|
Visivel = false,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "A 7v2",
|
|
Valores = LogsSensoriamento.Select(x => x?.Barramento7v2Corrente ?? 0).ToList(),
|
|
Visivel = false,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "V 12v",
|
|
Valores = LogsSensoriamento.Select(x => x?.Barramento12vTensao ?? 0).ToList(),
|
|
Visivel = true,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "A 12v",
|
|
Valores = LogsSensoriamento.Select(x => x?.Barramento12vCorrente ?? 0).ToList(),
|
|
Visivel = true,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "V Bat",
|
|
Valores = LogsPzem.Select(x => x?.Tensao ?? 0).ToList(),
|
|
Visivel = true,
|
|
},
|
|
new GraficoInterativoSerieModel()
|
|
{
|
|
Titulo = "A Bat",
|
|
Valores = LogsPzem.Select(x => x?.Corrente ?? 0).ToList(),
|
|
Visivel = true,
|
|
}
|
|
});
|
|
}
|
|
|
|
private void InicializarCombosBusca()
|
|
{
|
|
CarregarInformacoesBusca(gpbMOV_Geral_Filtro, graficoMovGeral.Series.Select(x => x.Titulo).ToArray());
|
|
CarregarInformacoesBusca(gpbSEN_Filtro, graficoSen.Series.Select(x => x.Titulo).ToArray());
|
|
}
|
|
|
|
private void CarregarInformacoesBusca(GroupBox gpb, string[] Componentes)
|
|
{
|
|
ComboBox cmbFiltro = gpb.Controls.OfType<ComboBox>().FirstOrDefault(x => x.Name.Contains("Filtro"));
|
|
cmbFiltro.Items.Clear();
|
|
cmbFiltro.Items.AddRange(cmbItemsBuscaPor);
|
|
ComboBox cmbComponente = gpb.Controls.OfType<ComboBox>().FirstOrDefault(x => x.Name.Contains("Componente"));
|
|
cmbComponente.Items.Clear();
|
|
cmbComponente.Items.AddRange(Componentes);
|
|
cmbComponente.SelectedIndexChanged += cmbComponente_SelectedIndexChanged;
|
|
Button btnRedefinir = gpb.Controls.OfType<Button>().FirstOrDefault(x => x.Name.Contains("Redefinir"));
|
|
btnRedefinir.Click += btnRedefinirBusca_Click;
|
|
Button btnBuscar = gpb.Controls.OfType<Button>().FirstOrDefault(x => x.Name.Contains("Buscar"));
|
|
btnBuscar.Click += btnBuscarMomento_Click;
|
|
Button btnAnterior = gpb.Controls.OfType<Button>().FirstOrDefault(x => x.Name.Contains("Anterior"));
|
|
btnAnterior.Click += btnAnteriorFiltro_Click; ;
|
|
Button btnProximo = gpb.Controls.OfType<Button>().FirstOrDefault(x => x.Name.Contains("Proximo"));
|
|
btnProximo.Click += btnProximoFiltro_Click; ;
|
|
}
|
|
|
|
private void btnAnteriorFiltro_Click(object sender, EventArgs e)
|
|
{
|
|
if (idxValoresFiltro.Any() && idxMomentoFiltro > 0)
|
|
{
|
|
idxMomentoFiltro--;
|
|
trbMomento.Value = idxValoresFiltro[idxMomentoFiltro];
|
|
AtualizarDadosMomento();
|
|
}
|
|
}
|
|
|
|
private void btnProximoFiltro_Click(object sender, EventArgs e)
|
|
{
|
|
if (idxValoresFiltro.Any() && idxMomentoFiltro < idxValoresFiltro.Count() - 1)
|
|
{
|
|
idxMomentoFiltro++;
|
|
trbMomento.Value = idxValoresFiltro[idxMomentoFiltro];
|
|
AtualizarDadosMomento();
|
|
}
|
|
}
|
|
|
|
private void cmbComponente_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
AtualizarDadosMomento();
|
|
}
|
|
|
|
private void btnRedefinirBusca_Click(object sender, EventArgs e)
|
|
{
|
|
GroupBox gpb = (GroupBox)((Button)sender).Parent;
|
|
ComboBox cmbFiltro = gpb.Controls.OfType<ComboBox>().FirstOrDefault(x => x.Name.Contains("Filtro"));
|
|
cmbFiltro.SelectedIndex = -1;
|
|
ComboBox cmbComponente = gpb.Controls.OfType<ComboBox>().FirstOrDefault(x => x.Name.Contains("Componente"));
|
|
cmbComponente.SelectedIndex = -1;
|
|
idxMomentoFiltro = 0;
|
|
idxValoresFiltro = new List<int>();
|
|
|
|
AtualizarDadosMomento();
|
|
}
|
|
|
|
private void btnBuscarMomento_Click(object sender, EventArgs e)
|
|
{
|
|
GroupBox gpb = (GroupBox)((Button)sender).Parent;
|
|
ComboBox cmbFiltro = gpb.Controls.OfType<ComboBox>().FirstOrDefault(x => x.Name.Contains("Filtro"));
|
|
if (cmbFiltro.SelectedIndex < 0)
|
|
{
|
|
return;
|
|
}
|
|
ComboBox cmbComponente = gpb.Controls.OfType<ComboBox>().FirstOrDefault(x => x.Name.Contains("Componente"));
|
|
if (cmbComponente.SelectedIndex < 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
GraficoInterativoModel grafico = null;
|
|
|
|
if (gpb.Name.Contains("SEN"))
|
|
{
|
|
grafico = graficoSen;
|
|
}
|
|
else if (gpb.Name.Contains("MOV_Geral"))
|
|
{
|
|
grafico = graficoMovGeral;
|
|
}
|
|
if (grafico != null)
|
|
{
|
|
var Dados = grafico.Series.FirstOrDefault(x => x.Titulo == cmbComponente.Text).Valores.Select((x, i) => new { valor = x, idx = i }).ToList();
|
|
if (cmbFiltro.SelectedIndex == 0)
|
|
{
|
|
Dados = Dados.OrderByDescending(x => x.valor).ToList();
|
|
}
|
|
else if (cmbFiltro.SelectedIndex == 1)
|
|
{
|
|
Dados = Dados.OrderBy(x => x.valor).ToList();
|
|
}
|
|
|
|
idxValoresFiltro = Dados.Select(x => x.idx).ToList();
|
|
idxMomentoFiltro = 0;
|
|
|
|
trbMomento.Value = idxValoresFiltro[idxMomentoFiltro];
|
|
}
|
|
}
|
|
|
|
private string DeserializarDadosOperacao(string caminho, string arquivo)
|
|
{
|
|
string opPath = caminho.Replace("data.lgop", arquivo) + ".json";
|
|
string opStr = File.ReadAllText(opPath) + "]";
|
|
return opStr;
|
|
}
|
|
|
|
private void CarregarImagemCamera(PictureBox pic, string Caminho)
|
|
{
|
|
if (File.Exists(Caminho + trbMomento.Value + ".jpg"))
|
|
{
|
|
pic.Image = Image.FromFile(Caminho + trbMomento.Value + ".jpg");
|
|
}
|
|
else
|
|
{
|
|
Bitmap frame = new Bitmap(1, 1);
|
|
using (Graphics g = Graphics.FromImage(frame))
|
|
{
|
|
g.Clear(Color.Black);
|
|
}
|
|
pic.Image = frame;
|
|
}
|
|
}
|
|
|
|
private void AtualizarDadosMomento()
|
|
{
|
|
if (!LogsOperacao.Any())
|
|
{
|
|
return;
|
|
}
|
|
|
|
txtMomento.Text = LogsOperacao.FirstOrDefault(x => x.Momento == MomentoAtual).Momento.ToString("HH:mm:ss");
|
|
|
|
AtualizarInformacoesOperacao();
|
|
|
|
AtualizarInformacoesCameras();
|
|
|
|
AtualizarInformacoesGPS();
|
|
|
|
AtualizarInformacoesDirecional();
|
|
|
|
AtualizarInformacoesMovimentacao();
|
|
|
|
AtualizarInformacoesAtuador();
|
|
|
|
AtualizarInformacoesSensoriamento();
|
|
}
|
|
|
|
private void AtualizarInformacoesOperacao()
|
|
{
|
|
var Log = LogsOperacao[idxMomentoAtual];
|
|
FuncoesGlobais.PreencheValorProgressBar(pgbPercentualBateria, Log.PorcentagemBateria);
|
|
FuncoesGlobais.PreencheValorProgressBar(pgbBateriaConsumida, Log.BateriaConsumida);
|
|
txtTempoMovimento.Text = FuncoesGlobais.ConverterSegundosParaHHmmss((int)Log.TempoMovimento);
|
|
txtDistanciaPercorrida.Text = Log.DistanciaPercorrida.Sum().ToString("0.00");
|
|
txtHerbicidaConsumido.Text = Log.HerbicidaConsumido.ToString("0.00");
|
|
txtStatusOperacao.Text = Log.StatusOperacao.ToString();
|
|
txtStatusCarro.Text = Log.StatusCarro.ToString();
|
|
txtHerbicidaPorErva.Text = Log.HerbicidaPorErva.ToString("0.00");
|
|
txtDentroRua.Text = Log.DentroDaRua ? "Sim" : "Não";
|
|
txtDirecaoCarro.Text = Log.Direcao.ToString();
|
|
txtErvasNoRadar.Text = Log.ErvasNoRadar.ToString();
|
|
|
|
pnlOrientacaoCaminho.Invalidate();
|
|
pnlOrientacaoDif.Invalidate();
|
|
}
|
|
|
|
private void AtualizarInformacoesCameras()
|
|
{
|
|
CarregarImagemCamera(picCameraCaminho, pathImagensCaminho);
|
|
CarregarImagemCamera(picCameraSoloE, pathImagensSoloE);
|
|
CarregarImagemCamera(picCameraSoloD, pathImagensSoloD);
|
|
}
|
|
|
|
private void AtualizarInformacoesGPS()
|
|
{
|
|
var Log = LogsGPS.FirstOrDefault(x => x.Momento == MomentoAtual);
|
|
txtGPS_Altitude.Text = (Log?.Altitude ?? 0).ToString();
|
|
txtGPS_Data.Text = (Log?.DataHora ?? MomentoAtual).ToString("dd/MM HH:mm:ss");
|
|
txtGPS_Latitude.Text = (Log?.Latitude ?? 0).ToString();
|
|
txtGPS_Longitude.Text = (Log?.Longitude ?? 0).ToString();
|
|
txtGPS_Orientacao.Text = (Log?.Orientacao ?? 0).ToString();
|
|
txtGPS_Precisao.Text = (Log?.PrecisaoHorizontal ?? 0).ToString();
|
|
txtGPS_Satelites.Text = (Log?.NumeroSatelites ?? 0).ToString();
|
|
txtGPS_Velocidade.Text = (Log?.Velocidade ?? 0).ToString();
|
|
|
|
GPSService.EnviarCoordenadasParaMapa(Log?.Latitude ?? 0, Log?.Longitude ?? 0, Log?.Orientacao ?? 0);
|
|
|
|
pnlOrientacaoGPS.Invalidate();
|
|
}
|
|
|
|
private void AtualizarInformacoesDirecional()
|
|
{
|
|
AtualizarInformacoesMotorDirecional("DF");
|
|
AtualizarInformacoesMotorDirecional("DT");
|
|
AtualizarInformacoesMotorDirecional("EF");
|
|
AtualizarInformacoesMotorDirecional("ET");
|
|
|
|
pnlOrientacaoDirecional.Invalidate();
|
|
}
|
|
|
|
private void AtualizarInformacoesMotorDirecional(string ID)
|
|
{
|
|
var Log = LogsDirecional.Where(x => x.Modulo_ID == ID).FirstOrDefault(x => x.Momento == MomentoAtual);
|
|
|
|
double Angulo = Log?.Angulo ?? 0;
|
|
double Multiplicador = (Log?.Sentido ?? Enuns.Sentido.Parado) == Enuns.Sentido.Horario ? 1 : -1;
|
|
Image img = Resources.roda_superior;
|
|
if (ID.StartsWith("D"))
|
|
{
|
|
img = FuncoesGlobais.EspelharImagemHorizontalmente(img);
|
|
}
|
|
|
|
PictureBox pic = FuncoesGlobais.FindControlRecursive<PictureBox>(tabDirecional, "picDIR_" + ID);
|
|
pic.Image = FuncoesGlobais.RotacionarImagem(img, Angulo * Multiplicador);
|
|
|
|
Label lbl = FuncoesGlobais.FindControlRecursive<Label>(tabDirecional, "lblDIR_" + ID);
|
|
lbl.ForeColor = Log.Inicializado ? Color.Green : Color.Red;
|
|
|
|
TextBox txtAnguloSP = FuncoesGlobais.FindControlRecursive<TextBox>(tabDirecional, "txtDIR_AnguloSP_" + ID);
|
|
txtAnguloSP.Text = (Log?.Angulo_SP ?? 0).ToString();
|
|
TextBox txtAngulo = FuncoesGlobais.FindControlRecursive<TextBox>(tabDirecional, "txtDIR_Angulo_" + ID);
|
|
txtAngulo.Text = (Log?.Angulo ?? 0).ToString();
|
|
TextBox txtSentidoSP = FuncoesGlobais.FindControlRecursive<TextBox>(tabDirecional, "txtDIR_SentidoSP_" + ID);
|
|
txtSentidoSP.Text = (Log?.Sentido_SP ?? Enuns.Sentido.Parado).ToString();
|
|
TextBox txtSentido = FuncoesGlobais.FindControlRecursive<TextBox>(tabDirecional, "txtDIR_Sentido_" + ID);
|
|
txtSentido.Text = (Log?.Sentido ?? Enuns.Sentido.Parado).ToString();
|
|
TextBox txtVelocidade = FuncoesGlobais.FindControlRecursive<TextBox>(tabDirecional, "txtDIR_Velocidade_" + ID);
|
|
txtVelocidade.Text = (Log?.Velocidade ?? 0).ToString();
|
|
TextBox txtControlar = FuncoesGlobais.FindControlRecursive<TextBox>(tabDirecional, "txtDIR_Controlar_" + ID);
|
|
txtControlar.Text = (Log?.Controlar ?? false) ? "Sim" : "Não";
|
|
}
|
|
|
|
private void AtualizarInformacoesMovimentacao()
|
|
{
|
|
var Logs = LogsMovimentacao.Where(x => x.Momento == MomentoAtual).ToList();
|
|
|
|
graficoMovGeral.AtualizarDados(idxMomentoAtual);
|
|
graficoMovTemperatura.AtualizarDados(idxMomentoAtual);
|
|
//graficoMovPotencia.AtualizarDados(idxMomentoAtual);
|
|
graficoMovVelocidade.AtualizarDados(idxMomentoAtual);
|
|
|
|
AtulizarDadosMotorMovimentacao("DF");
|
|
AtulizarDadosMotorMovimentacao("DT");
|
|
AtulizarDadosMotorMovimentacao("EF");
|
|
AtulizarDadosMotorMovimentacao("ET");
|
|
}
|
|
|
|
private void AtulizarDadosMotorMovimentacao(string ID)
|
|
{
|
|
var Log = LogsMovimentacao.FirstOrDefault(x => x.Momento == MomentoAtual && x.Modulo_ID == ID);
|
|
|
|
GroupBox gpbRpm = FuncoesGlobais.FindControlRecursive<GroupBox>(tabMovGreal, "gpbMOV_Geral_" + ID);
|
|
CheckBox chbAlm = FuncoesGlobais.FindControlRecursive<CheckBox>(gpbRpm, "chbMOV_Alm_" + ID);
|
|
chbAlm.Checked = Log.CodAlarme > 0;
|
|
TextBox txtSentidoSP = FuncoesGlobais.FindControlRecursive<TextBox>(gpbRpm, "txtMOV_SentidoSP_" + ID);
|
|
txtSentidoSP.Text = Log.Sentido_SP.ToString();
|
|
TextBox txtSentido = FuncoesGlobais.FindControlRecursive<TextBox>(gpbRpm, "txtMOV_Sentido_" + ID);
|
|
txtSentido.Text = Log.Sentido.ToString();
|
|
|
|
GroupBox gpbTmp = FuncoesGlobais.FindControlRecursive<GroupBox>(tabMovTemperatura, "gpbMOV_Temperatura_" + ID);
|
|
TextBox txtAtual = FuncoesGlobais.FindControlRecursive<TextBox>(gpbTmp, "txtMOV_TemperaturaAt_" + ID);
|
|
txtAtual.Text = Log.Temperatura.ToString();
|
|
TextBox txtMinima = FuncoesGlobais.FindControlRecursive<TextBox>(gpbTmp, "txtMOV_TemperaturaMn_" + ID);
|
|
txtMinima.Text = LogsMovimentacao.Where(x => x.Momento <= MomentoAtual && x.Modulo_ID == ID).Min(x => x.Temperatura).ToString("0.00");
|
|
TextBox txtMaxima = FuncoesGlobais.FindControlRecursive<TextBox>(gpbTmp, "txtMOV_TemperaturaMx_" + ID);
|
|
txtMaxima.Text = LogsMovimentacao.Where(x => x.Momento <= MomentoAtual && x.Modulo_ID == ID).Max(x => x.Temperatura).ToString("0.00");
|
|
|
|
txtMOV_Temperatura_Media.Text = LogsMovimentacao.Where(x => x.Momento <= MomentoAtual).Average(x => x.Temperatura).ToString("0.00");
|
|
txtMOV_Temperatura_Mediana.Text = FuncoesMatematicas.CalcularMediana(LogsMovimentacao.Where(x => x.Momento <= MomentoAtual).Select(x => x.Temperatura).ToList()).ToString("0.00");
|
|
txtMOV_Temperatura_Moda.Text = FuncoesMatematicas.CalcularModa(LogsMovimentacao.Where(x => x.Momento <= MomentoAtual).Select(x => x.Temperatura).ToList()).ToString("0.00");
|
|
}
|
|
|
|
private void AtualizarInformacoesAtuador()
|
|
{
|
|
graficoAtu.AtualizarDados(idxMomentoAtual);
|
|
|
|
FuncoesGlobais.PreencheValorProgressBar(pgbPercentualReservatorio, LogsAtuador[idxMomentoAtual].PercentualReservatorio);
|
|
|
|
pnlAtuadores.Invalidate();
|
|
}
|
|
|
|
private void AtualizarInformacoesSensoriamento()
|
|
{
|
|
graficoSen.AtualizarDados(idxMomentoAtual);
|
|
|
|
if (cmbSen_Componente.SelectedIndex > -1)
|
|
{
|
|
var Valores = graficoSen.Series.FirstOrDefault(x => x.Titulo == cmbSen_Componente.Text).Valores.Take(idxMomentoAtual + 1).ToList();
|
|
txtSen_Atual.Text = Valores[idxMomentoAtual].ToString("0.00");
|
|
txtSen_Media.Text = Valores.Average().ToString("0.00");
|
|
txtSen_Mediana.Text = FuncoesMatematicas.CalcularMediana(Valores).ToString("0.00");
|
|
txtSen_Moda.Text = FuncoesMatematicas.CalcularModa(Valores).ToString("0.00");
|
|
txtSen_Minimo.Text = Valores.Min().ToString("0.00");
|
|
txtSen_Maximo.Text = Valores.Max().ToString("0.00");
|
|
}
|
|
|
|
pnlOrientacaoMagnetometro.Invalidate();
|
|
}
|
|
|
|
|
|
|
|
private void pnlOrientacaoDirecional_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
var Logs = LogsDirecional.Where(x => x.Momento == MomentoAtual).ToList();
|
|
double Angulo = Logs.Any() ? Logs.Average(x => x.Angulo_SP) : 0;
|
|
FuncoesGlobais.DesenharInclinacao((Panel)sender, e, (float)Angulo, 90);
|
|
}
|
|
|
|
private void pnlOrientacaoGPS_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
var Log = LogsGPS.FirstOrDefault(x => x.Momento == MomentoAtual);
|
|
double Angulo = Log?.Orientacao ?? 0;
|
|
FuncoesGlobais.DesenharInclinacao((Panel)sender, e, (float)Angulo, -90);
|
|
}
|
|
|
|
private void pnlOrientacaoMagnetometro_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
var Log = LogsSensoriamento.FirstOrDefault(x => x.Momento == MomentoAtual);
|
|
double Angulo = Log?.OrientacaoMagnetica ?? 0;
|
|
FuncoesGlobais.DesenharInclinacao((Panel)sender, e, (float)Angulo, -90);
|
|
}
|
|
|
|
private void pnlOrientacaoCaminho_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
var Log = LogsOperacao.FirstOrDefault(x => x.Momento == MomentoAtual);
|
|
double Angulo = Log?.AnguloRua ?? 0;
|
|
FuncoesGlobais.DesenharInclinacao((Panel)sender, e, (float)Angulo, -90);
|
|
}
|
|
|
|
private void pnlOrientacaoDif_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
var Logs = LogsOperacao.Where(x => x.Momento == MomentoAtual).ToList();
|
|
double Angulo = Logs.Any() ? Logs.Average(x => x.AnguloDif) : 0;
|
|
FuncoesGlobais.DesenharInclinacao((Panel)sender, e, (float)Angulo, 90);
|
|
}
|
|
|
|
private void pnlAtuadores_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
var Log = LogsAtuador.FirstOrDefault(x => x.Momento == MomentoAtual);
|
|
if (Log == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Graphics g = e.Graphics;
|
|
Panel myPanel = (Panel)sender;
|
|
int panelWidth = myPanel.Width;
|
|
int circleDiameter = 40; // Diâmetro dos círculos grandes
|
|
int smallCircleDiameter = circleDiameter / 2; // Diâmetro dos círculos pequenos
|
|
int spaceBetweenCircles = (panelWidth - (circleDiameter * Log.QuantidadeBicos)) / (Log.QuantidadeBicos + 1);
|
|
int yPosition = (myPanel.Height - circleDiameter) / 3; // Centralizado verticalmente
|
|
|
|
|
|
for (int i = 0; i < Log.QuantidadeBicos; i++)
|
|
{
|
|
// Calcula a posição x do círculo
|
|
int xPosition = spaceBetweenCircles + (i * (circleDiameter + spaceBetweenCircles));
|
|
// Desenha o contorno do círculo
|
|
g.DrawEllipse(Pens.Red, xPosition, yPosition, circleDiameter, circleDiameter);
|
|
// Se o bico estiver aceso, preenche o círculo
|
|
if (Log.Bicos[i].Atuado)
|
|
{
|
|
g.FillEllipse(Brushes.Red, xPosition, yPosition, circleDiameter, circleDiameter);
|
|
}
|
|
|
|
// Define a string que representa o número do bico
|
|
string bicoNumero = Log.Bicos[i].ID;
|
|
// Define a fonte para o texto
|
|
Font font = new Font("Arial", 10, FontStyle.Bold);
|
|
// Mede o tamanho do texto
|
|
SizeF stringSize = g.MeasureString(bicoNumero, font);
|
|
// Calcula as posições x e y para centralizar o texto no círculo
|
|
float textXPosition = xPosition + (circleDiameter - stringSize.Width) / 2;
|
|
float textYPosition = yPosition + (circleDiameter - stringSize.Height) / 2;
|
|
// Desenha o número do bico
|
|
g.DrawString(bicoNumero, font, Brushes.Black, textXPosition, textYPosition);
|
|
|
|
|
|
// Define a string que representa a atuacao do bico
|
|
string bicoAtuacao = Log.Bicos[i].Atuacoes.ToString("000");
|
|
// Define a fonte para o texto
|
|
Font fontA = new Font("Arial", 8, FontStyle.Bold);
|
|
// Mede o tamanho do texto
|
|
SizeF stringSizeA = g.MeasureString(bicoAtuacao, fontA);
|
|
// Calcula as posições x e y para centralizar o texto no círculo
|
|
float textXPositionA = xPosition + (circleDiameter - stringSizeA.Width) / 2;
|
|
float textYPositionA = circleDiameter + yPosition + 5;
|
|
// Desenha as atuacoes do bico
|
|
g.DrawString(bicoAtuacao, fontA, Brushes.Black, textXPositionA, textYPositionA);
|
|
|
|
|
|
// Calcula a posição x e y do círculo pequeno
|
|
int smallCircleXPosition = Convert.ToInt32(xPosition + circleDiameter - smallCircleDiameter / 1.3);
|
|
int smallCircleYPosition = Convert.ToInt32(yPosition + circleDiameter - smallCircleDiameter / 1.3);
|
|
|
|
// Define a cor de contorno e preenchimento para o círculo pequeno
|
|
Pen smallCirclePen = Pens.Blue; // Cor do contorno
|
|
Brush smallCircleBrush = Brushes.Transparent; // Cor de preenchimento padrão
|
|
|
|
// Se o status do bico for true, altera a cor de preenchimento para azul
|
|
if (Log.Bicos[i].StatusBico)
|
|
{
|
|
smallCircleBrush = Brushes.Blue;
|
|
}
|
|
|
|
// Desenha o contorno do círculo pequeno
|
|
g.DrawEllipse(smallCirclePen, smallCircleXPosition, smallCircleYPosition, smallCircleDiameter, smallCircleDiameter);
|
|
// Preenche o círculo pequeno se o status do bico for true
|
|
g.FillEllipse(smallCircleBrush, smallCircleXPosition, smallCircleYPosition, smallCircleDiameter, smallCircleDiameter);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|