2039 lines
90 KiB
C#
2039 lines
90 KiB
C#
using AgroBase.Comum;
|
|
using AgroBase.Forms.Operacoes;
|
|
using AgroBase.Models.Modules;
|
|
using AgroBase.Models.Operacoes;
|
|
using AgroBase.Services;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using static AgroBase.Models.Enums;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using static AgroBase.Services.OIDCanService.OidHandler;
|
|
using AgroBase.Models.Operadores;
|
|
using AgroBase.Services.Operadores;
|
|
using AgroBase.Forms;
|
|
|
|
namespace AgroBase.Models
|
|
{
|
|
public class OperacaoModel
|
|
{
|
|
|
|
public OperacaoModel(ModoOperacao Modo)
|
|
{
|
|
this.Modo = Modo;
|
|
|
|
if (Variaveis.OperacaoEmAndamento != null)
|
|
{
|
|
tmrLogs?.Dispose();
|
|
tmrLogs = new AsyncTaskTimerModel("tmrLogs", tmrLogs_Tick, 1000);
|
|
|
|
tmrLeituras?.Dispose();
|
|
tmrLeituras = new AsyncTaskTimerModel("tmrLeitura", tmrLeituras_Tick, 500);
|
|
tmrLeituras.Start();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public ModoOperacao Modo { get; set; }
|
|
public string Descricao { get; set; }
|
|
public OperacaoControleModel Controle { get; set; } = new OperacaoControleModel();
|
|
public OperacaoControleModel ControleAnterior { get; set; } = new OperacaoControleModel();
|
|
public DispositivosService<MovimentacaoUnificadaModel> DispMvd { get; set; }
|
|
public DispositivosService<SensoriamentoModel> DispSen { get; set; }
|
|
public DispositivosService<AtuadorModel> DispAtu { get; set; }
|
|
public MapasModel Mapa { get; set; } = new MapasModel();
|
|
public TrajetoriaMapaOperacaoModel Trajetoria { get; set; }
|
|
public List<GPSModel> GPSTrajetoria { get; set; } = new List<GPSModel>();
|
|
public OperacaoSensoriamentoLogModel Sensoriamento { get; set; } = new OperacaoSensoriamentoLogModel();
|
|
public PerformanceModel DadosPerformance { get; set; } = new PerformanceModel();
|
|
public Form frmOperacao { get; set; }
|
|
|
|
#region STATUS DE CONTEXTO
|
|
public StatusOperacao StatusAtual { get; private set; } = StatusOperacao.NaoIniciado;
|
|
public bool Emergencia { get; set; } = false;
|
|
public bool OperacaoLiberada { get; private set; } = false;
|
|
public bool OperacaoConfigurada { get; private set; } = false;
|
|
public string ErroOperacaoLiberada { get; set; }
|
|
public DateTime TempoAguardando { get; private set; } = DateTime.Now;
|
|
public bool Iniciado { get; set; }
|
|
public bool Finalizando { get; set; } = false;
|
|
public bool Calibrando { get; set; } = false;
|
|
public DateTime DataInicio { get; set; } = DateTime.MinValue;
|
|
public DateTime DataFim { get; set; } = DateTime.MinValue;
|
|
public double TempoDecorridoSegs
|
|
{
|
|
get
|
|
{
|
|
return (StatusAtual == StatusOperacao.Parametrizando ? 0 : ((Variaveis.OperacaoEmAndamento.DataFim != DateTime.MinValue ? Variaveis.OperacaoEmAndamento.DataFim : DateTime.Now) - Variaveis.OperacaoEmAndamento.DataInicio).TotalSeconds);
|
|
}
|
|
}
|
|
|
|
public void AtualizarDadosContexto()
|
|
{
|
|
DateTime t0 = DateTime.Now;
|
|
HealthWorkerService.AtualizarDadosContexto();
|
|
DateTime t1 = DateTime.Now;
|
|
|
|
Variaveis.OperacaoEmAndamento.StatusAtual = (StatusOperacao)RedisService.GetField<int>(CtxKey.DadosOperacao, "status", 0);
|
|
Variaveis.OperacaoEmAndamento.OperacaoLiberada = RedisService.GetField(CtxKey.DadosOperacao, "liberado", false);
|
|
Variaveis.OperacaoEmAndamento.OperacaoConfigurada = RedisService.GetField(CtxKey.DadosOperacao, "configurado", false);
|
|
var tempoAguardando = RedisService.GetField<long>(CtxKey.DadosOperacao, "tempo_aguardando", 0);
|
|
Variaveis.OperacaoEmAndamento.TempoAguardando = DateTimeOffset.FromUnixTimeSeconds(tempoAguardando).UtcDateTime.AddSeconds(tempoAguardando % 1).ToLocalTime();
|
|
//Console.WriteLine(Variaveis.OperacaoEmAndamento.OperacaoConfigurada);
|
|
HealthWorkerService.ModulosSaude = RedisService.GetField<ManagerWorkerMessageResponseModulosPendentesModel[]>(CtxKey.DadosOperacao, "status_modulos").ToList();
|
|
Variaveis.OperacaoEmAndamento.ErroOperacaoLiberada = RedisService.GetField<string>(CtxKey.DadosOperacao, "motivo_nao_liberado");
|
|
DateTime t2 = DateTime.Now;
|
|
|
|
//Console.WriteLine($"Atualizacao de Contexto: {Math.Round((t1 - t0).TotalSeconds), 4}, Saude Modulos: {Math.Round((t2 - t1).TotalSeconds), 4}, Total: {Math.Round((t2 - t0).TotalSeconds),4}");
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public bool Treinando { get; set; } = false;
|
|
public bool Simulando { get; set; } = false;
|
|
public double SimulacaoAnguloControle { get; set; } = 0;
|
|
public double SimulacaoRpmControle { get; set; } = 0;
|
|
|
|
|
|
public List<OperacaoModulosMandatoriosModel> ModulosMandatorios { get; set; } = new List<OperacaoModulosMandatoriosModel>();
|
|
public List<OperacaoParametrosMandatoriosModel> ParametrosMandatorios { get; set; } = new List<OperacaoParametrosMandatoriosModel>();
|
|
public double CapacidadeReservatorio { get; set; } = 30;
|
|
public int QuantidadeCamerasSolo { get; set; } = 1;
|
|
public int TempoIniciarOperacao { get; set; } = 5;
|
|
public string ID { get; set; }
|
|
public double tmrLogsInterval
|
|
{
|
|
get
|
|
{
|
|
return tmrLogs.Interval;
|
|
}
|
|
set
|
|
{
|
|
tmrLogs.SetInterval((int)value);
|
|
}
|
|
}
|
|
private static AsyncTaskTimerModel tmrLogs;
|
|
private static AsyncTaskTimerModel tmrLeituras;
|
|
|
|
|
|
|
|
#region PARAMETRIZACAO
|
|
|
|
public bool SalvarParametrizacaoOperacao(
|
|
string descricao,
|
|
double capacidadeReservatorio,
|
|
double pressaoLinha,
|
|
int duracaoAtuacao,
|
|
int percentualAtuacao,
|
|
int anguloMaximo,
|
|
int velocidadeMovimento,
|
|
int velocidadeServasPercent,
|
|
int velocidadeCervasPercent,
|
|
UltrasonicA05Configuracoes ConfigUltrassom,
|
|
bool sonarAtivado,
|
|
int qtdCamerasSolo,
|
|
TiposControladorDirecional tipoControleDirecional)
|
|
{
|
|
if (string.IsNullOrEmpty(descricao))
|
|
{
|
|
MessageBox.Show("Preencha a descrição para identificação da operação!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return false;
|
|
}
|
|
|
|
if (Variaveis.OperacaoEmAndamento.ParametrosMandatorios.Any(x => x.Parametro == ParametrosOperacao.Mapa && x.Mandatorio) && string.IsNullOrEmpty(Variaveis.OperacaoEmAndamento.Mapa?.mapaService?.CaminhoMapa) && !(Variaveis.OperacaoEmAndamento.Mapa?.RuasPercorrer ?? new List<string>()).Any())
|
|
{
|
|
MessageBox.Show("Selecione o mapa da operação e selecione as ruas a serem percorridas!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return false;
|
|
}
|
|
|
|
OperacaoParametrosModel Parametros = new OperacaoParametrosModel()
|
|
{
|
|
Modo = Variaveis.OperacaoEmAndamento.Modo,
|
|
Descricao = descricao,
|
|
AtuCapacidadeReservatorio = capacidadeReservatorio,
|
|
AtuDuracaoAtuacao = duracaoAtuacao,
|
|
AtuPercentualDeteccaoVertical = percentualAtuacao,
|
|
AtuPressaoLinha = pressaoLinha,
|
|
DirAnguloMaximo = anguloMaximo,
|
|
DirVelocidadeMovimento = velocidadeMovimento,
|
|
DirTipoMovimento = tipoControleDirecional,
|
|
MovVelocidadeCErvasPercent = velocidadeCervasPercent,
|
|
MovVelocidadeSErvasPercent = velocidadeServasPercent,
|
|
ModulosMandatorios = new List<OperacaoModulosMandatoriosModel>(Variaveis.OperacaoEmAndamento.ModulosMandatorios),
|
|
ParametrosMandatorios = new List<OperacaoParametrosMandatoriosModel>(Variaveis.OperacaoEmAndamento.ParametrosMandatorios),
|
|
Mapa = Variaveis.OperacaoEmAndamento.Mapa,
|
|
ConfiguracaoUltrassom = ConfigUltrassom,
|
|
SonarAtivado = sonarAtivado,
|
|
QtdCamerasSolo = qtdCamerasSolo
|
|
};
|
|
Parametros.Mapa.LimparDados(true);
|
|
|
|
string ParametrosJson = JsonConvert.SerializeObject(Parametros, Formatting.None);
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
saveFileDialog.Filter = "Arquivo de Operação (*.opr)|*.opr";
|
|
saveFileDialog.DefaultExt = "opr";
|
|
saveFileDialog.AddExtension = true;
|
|
saveFileDialog.InitialDirectory = Variaveis.CaminhoSistema + Variaveis.CaminhoOperacoes;
|
|
saveFileDialog.FileName = descricao;
|
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
string filePath = saveFileDialog.FileName;
|
|
|
|
File.WriteAllText(filePath, ParametrosJson, Encoding.UTF8);
|
|
|
|
MessageBox.Show("Operação salva com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public (bool, List<string>) CarregarParametrizacaoOperacao(Panel pnlMapa, Label lblMapa, string opPath = "")
|
|
{
|
|
string path = Variaveis.CaminhoSistema + Variaveis.CaminhoOperacoes + MapasVariaveisModel.NomeArquivoMapaInterativoSaida;
|
|
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
openFileDialog.Filter = "Arquivo de Operação (*.opr)|*.opr";
|
|
openFileDialog.DefaultExt = "opr";
|
|
openFileDialog.AddExtension = true;
|
|
openFileDialog.InitialDirectory = Variaveis.CaminhoSistema + Variaveis.CaminhoOperacoes;
|
|
if (!string.IsNullOrEmpty(opPath) || openFileDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
string filePath = !string.IsNullOrEmpty(opPath) ? opPath : openFileDialog.FileName;
|
|
|
|
string ParametrosJson = File.ReadAllText(filePath, Encoding.UTF8);
|
|
|
|
var Parametros = JsonConvert.DeserializeObject<OperacaoParametrosModel>(ParametrosJson);
|
|
|
|
CarregarParametrosOperacaoPadrao(Parametros.Modo);
|
|
|
|
OperacaoControleModel controle = new OperacaoControleModel()
|
|
{
|
|
RPM_Max = (int)(VariaveisEquipamento.RPM_Max_Roda * (Parametros.MovVelocidadeSErvasPercent / 100.0)),
|
|
RPM_Min = (int)(VariaveisEquipamento.RPM_Max_Roda * (Parametros.MovVelocidadeCErvasPercent / 100.0)),
|
|
Angulo_Max = Parametros.DirAnguloMaximo,
|
|
Angulo_Min = Parametros.DirAnguloMaximo * -1,
|
|
VelocidadeMP = Parametros.DirVelocidadeMovimento,
|
|
TempoAtuacao = Parametros.AtuDuracaoAtuacao,
|
|
PercentualInicioPulverizacao = Parametros.AtuPercentualDeteccaoVertical / 100.0,
|
|
PressaoLinha = Parametros.AtuPressaoLinha,
|
|
Angulo = 0,
|
|
Direcao = Direcao.Parado,
|
|
PercentualVelocidadeSP = 0,
|
|
TiposControle = Variaveis.OperacaoEmAndamento.Controle.TiposControle.ToList(),
|
|
SonarAtivado = Parametros.SonarAtivado,
|
|
SegmentacaoSemantica = Parametros.Modo == ModoOperacao.MapaGPS,
|
|
TipoControleDirecional = Parametros.DirTipoMovimento,
|
|
PulverizadorAutomatico = Parametros.Modo == ModoOperacao.MapaGPS,
|
|
TipoMovimento = TipoMovimentoDirecional.RodasDianteiras,
|
|
SonarDesvioAutomatico = false,
|
|
};
|
|
|
|
Variaveis.OperacaoEmAndamento.Descricao = Parametros.Descricao;
|
|
Variaveis.OperacaoEmAndamento.QuantidadeCamerasSolo = Parametros.QtdCamerasSolo;
|
|
Variaveis.OperacaoEmAndamento.ModulosMandatorios = new List<OperacaoModulosMandatoriosModel>(Parametros.ModulosMandatorios ?? new List<OperacaoModulosMandatoriosModel>());
|
|
Variaveis.OperacaoEmAndamento.ParametrosMandatorios = new List<OperacaoParametrosMandatoriosModel>(Parametros.ParametrosMandatorios ?? new List<OperacaoParametrosMandatoriosModel>());
|
|
Variaveis.OperacaoEmAndamento.CapacidadeReservatorio = Parametros.AtuCapacidadeReservatorio;
|
|
Variaveis.OperacaoEmAndamento.Controle = controle;
|
|
if (Variaveis.OperacaoEmAndamento.DispSen == null)
|
|
{
|
|
Variaveis.OperacaoEmAndamento.DispSen = new DispositivosService<SensoriamentoModel>();
|
|
}
|
|
Variaveis.OperacaoEmAndamento.DispSen.Dados.ConfiguracaoSensorUltrassom = Parametros.ConfiguracaoUltrassom;
|
|
|
|
List<string> ruasSelecionadas = new List<string>();
|
|
if (Parametros.Mapa.mapaService.DadosMapa != null)
|
|
{
|
|
ruasSelecionadas = Parametros.Mapa.RuasPercorrer.ToList();
|
|
string geoJson = JsonConvert.SerializeObject(Parametros.Mapa.mapaService.DadosMapa, Formatting.None);
|
|
File.WriteAllText(path, geoJson, Encoding.UTF8);
|
|
Variaveis.OperacaoEmAndamento.Mapa = Parametros.Mapa;
|
|
|
|
/*Panel pnlMapa = FuncoesGlobais.FindControlRecursive<Panel>(Variaveis.OperacaoEmAndamento.frmOperacao, "pnlMapa");
|
|
Label lblMapa = FuncoesGlobais.FindControlRecursive<Label>(Variaveis.OperacaoEmAndamento.frmOperacao, "lblMapaCarregado");*/
|
|
Variaveis.OperacaoEmAndamento.Mapa.pnlMapa = pnlMapa;
|
|
Variaveis.OperacaoEmAndamento.Mapa.lblMapa = lblMapa;
|
|
|
|
Variaveis.OperacaoEmAndamento.Mapa.btnCarregar_Click(new object(), new EventArgs(), path);
|
|
|
|
//bool condicaoMapaCarregado() => Variaveis.OperacaoEmAndamento.Mapa.mapaService.Carregado;
|
|
//bool resultado = await FuncoesGlobais.AguardarCondicaoAsync(condicaoMapaCarregado, 5000, 200);
|
|
}
|
|
|
|
RedisService.AtualizarCampos(CtxKey.DadosOperacao, ("configurado", false));
|
|
|
|
return (true, ruasSelecionadas);
|
|
}
|
|
else
|
|
{
|
|
return (false, new List<string>());
|
|
}
|
|
}
|
|
|
|
|
|
public static void CarregarParametrosOperacaoPadrao(ModoOperacao Modo)
|
|
{
|
|
var SenConectado = (DispositivosService<SensoriamentoModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Sen);
|
|
var AtuConectado = (DispositivosService<AtuadorModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Atu);
|
|
var MvdConectado = (DispositivosService<MovimentacaoUnificadaModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mvd);
|
|
|
|
tmrLogs?.Stop();
|
|
|
|
Variaveis.OperacaoEmAndamento = new OperacaoModel(Modo)
|
|
{
|
|
Iniciado = false,
|
|
DataInicio = DateTime.MinValue,
|
|
DataFim = DateTime.MinValue,
|
|
DispAtu = AtuConectado,
|
|
DispSen = SenConectado,
|
|
DispMvd = MvdConectado,
|
|
Sensoriamento = new OperacaoSensoriamentoLogModel(),
|
|
QuantidadeCamerasSolo = 1,
|
|
};
|
|
|
|
switch (Modo)
|
|
{
|
|
case ModoOperacao.Manual:
|
|
Variaveis.OperacaoEmAndamento.frmOperacao = new frmOperacaoManual();
|
|
Variaveis.OperacaoEmAndamento.ControleAnterior = new OperacaoControleModel();
|
|
Variaveis.OperacaoEmAndamento.Controle = new OperacaoControleModel()
|
|
{
|
|
RPM_Max = 100,
|
|
RPM_Min = 15,
|
|
Angulo_Max = 25,
|
|
Angulo_Min = -25,
|
|
VelocidadeMP = 40,
|
|
TiposControle = new List<OperacaoControleTipoModel>()
|
|
{
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Mov,
|
|
DelayEnvioComando = 10,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Dir,
|
|
DelayEnvioComando = 10,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Atu,
|
|
DelayEnvioComando = 10,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
},
|
|
SonarAtivado = false,
|
|
SonarDesvioAutomatico = false,
|
|
SegmentacaoSemantica = false,
|
|
PulverizadorAutomatico = false,
|
|
TipoMovimento = TipoMovimentoDirecional.RodasDianteiras,
|
|
TipoControleDirecional = TiposControladorDirecional.Manual
|
|
};
|
|
Variaveis.OperacaoEmAndamento.ModulosMandatorios = new List<OperacaoModulosMandatoriosModel>()
|
|
{
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Mov,
|
|
Mandatorio = false,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Dir,
|
|
Mandatorio = false,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Atu,
|
|
Mandatorio = false,
|
|
Utilizar = true,
|
|
}
|
|
};
|
|
Variaveis.OperacaoEmAndamento.ParametrosMandatorios = new List<OperacaoParametrosMandatoriosModel>()
|
|
{
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.Joystick,
|
|
Mandatorio = false,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.LoRa,
|
|
Mandatorio = false,
|
|
Utilizar = true,
|
|
},
|
|
};
|
|
break;
|
|
case ModoOperacao.MapaGPS:
|
|
Variaveis.OperacaoEmAndamento.frmOperacao = new frmOperacaoMapaGPS();
|
|
Variaveis.OperacaoEmAndamento.ControleAnterior = new OperacaoControleModel();
|
|
Variaveis.OperacaoEmAndamento.Controle = new OperacaoControleModel()
|
|
{
|
|
RPM_Max = 50,
|
|
RPM_Min = 20,
|
|
Angulo_Max = 30,
|
|
Angulo_Min = -30,
|
|
VelocidadeMP = 50,
|
|
TiposControle = new List<OperacaoControleTipoModel>()
|
|
{
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Mov,
|
|
DelayEnvioComando = 500,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Dir,
|
|
DelayEnvioComando = 200,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Atu,
|
|
DelayEnvioComando = 500,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
},
|
|
SonarAtivado = false,
|
|
SonarDesvioAutomatico = false,
|
|
SegmentacaoSemantica = false,
|
|
PulverizadorAutomatico = true,
|
|
TipoMovimento = TipoMovimentoDirecional.RodasDianteiras,
|
|
TipoControleDirecional = TiposControladorDirecional.MPC,
|
|
};
|
|
Variaveis.OperacaoEmAndamento.ModulosMandatorios = new List<OperacaoModulosMandatoriosModel>()
|
|
{
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Mov,
|
|
Mandatorio = true,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Dir,
|
|
Mandatorio = true,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Sen,
|
|
Mandatorio = true,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Atu,
|
|
Mandatorio = true,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Gps,
|
|
Mandatorio = true,
|
|
Utilizar = true,
|
|
}
|
|
};
|
|
Variaveis.OperacaoEmAndamento.ParametrosMandatorios = new List<OperacaoParametrosMandatoriosModel>()
|
|
{
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.CameraSolo,
|
|
Mandatorio = true,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.Sonar,
|
|
Mandatorio = false,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.Mapa,
|
|
Mandatorio = true,
|
|
Utilizar = true,
|
|
},
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.LoRa,
|
|
Mandatorio = true,
|
|
Utilizar = true,
|
|
}
|
|
};
|
|
break;
|
|
case ModoOperacao.TreinamentoIA:
|
|
Variaveis.OperacaoEmAndamento.ControleAnterior = new OperacaoControleModel();
|
|
Variaveis.OperacaoEmAndamento.Controle = new OperacaoControleModel()
|
|
{
|
|
RPM_Max = 100,
|
|
RPM_Min = 20,
|
|
Angulo_Max = 30,
|
|
Angulo_Min = -30,
|
|
VelocidadeMP = 50,
|
|
TiposControle = new List<OperacaoControleTipoModel>()
|
|
{
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Mov,
|
|
DelayEnvioComando = 500,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Dir,
|
|
DelayEnvioComando = 1000,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
new OperacaoControleTipoModel()
|
|
{
|
|
Tipo = T_Code.Atu,
|
|
DelayEnvioComando = 500,
|
|
Comandos = new List<string>(),
|
|
UltimoComando = DateTime.Now
|
|
},
|
|
},
|
|
SonarAtivado = true,
|
|
SonarDesvioAutomatico = true,
|
|
SegmentacaoSemantica = true,
|
|
PulverizadorAutomatico = true,
|
|
TipoMovimento = TipoMovimentoDirecional.RodasDianteiras,
|
|
TipoControleDirecional = TiposControladorDirecional.IA,
|
|
};
|
|
Variaveis.OperacaoEmAndamento.ModulosMandatorios = new List<OperacaoModulosMandatoriosModel>()
|
|
{
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Mov,
|
|
Mandatorio = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Dir,
|
|
Mandatorio = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Atu,
|
|
Mandatorio = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Gps,
|
|
Mandatorio = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Sen,
|
|
Mandatorio = false,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Wit,
|
|
Mandatorio = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Pzm,
|
|
Mandatorio = true,
|
|
},
|
|
new OperacaoModulosMandatoriosModel()
|
|
{
|
|
Dispositivo = T_Code.Lra,
|
|
Mandatorio = true,
|
|
}
|
|
};
|
|
Variaveis.OperacaoEmAndamento.ParametrosMandatorios = new List<OperacaoParametrosMandatoriosModel>()
|
|
{
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.CameraSolo,
|
|
Mandatorio = true,
|
|
},
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.Sonar,
|
|
Mandatorio = true,
|
|
},
|
|
new OperacaoParametrosMandatoriosModel()
|
|
{
|
|
Parametro = ParametrosOperacao.Mapa,
|
|
Mandatorio = true,
|
|
}
|
|
};
|
|
break;
|
|
}
|
|
|
|
if (Variaveis.OperacaoEmAndamento.DispSen != null)
|
|
{
|
|
if (Variaveis.OperacaoEmAndamento.DispSen.Dados.ConfiguracaoSensorUltrassom == null)
|
|
{
|
|
Variaveis.OperacaoEmAndamento.DispSen.Dados.ConfiguracaoSensorUltrassom = UltrasonicA05Helper.CarregarConfiguracaoPadrao(ConfiguracaoSensorUltrassonico.NaoUtilizado);
|
|
}
|
|
|
|
if (Variaveis.OperacaoEmAndamento.DispSen.Dados.Conectado)
|
|
{
|
|
Variaveis.OperacaoEmAndamento.DispSen.Dados.Sinaleiros.ForEach(x => x.Comportamento = VariaveisEquipamento.ComportamentoPorStatus(StatusOperacao.NaoIniciado));
|
|
|
|
Variaveis.OperacaoEmAndamento.DispSen.Dados.Sinaleiros.First(x => x.ID == (Modo == ModoOperacao.Manual ? "LEDMN" : "LEDAT")).Comportamento.statusLED = StatusLED.Aceso;
|
|
Variaveis.OperacaoEmAndamento.DispSen.Dados.Sinaleiros.First(x => x.ID == "LEDOP").Comportamento = VariaveisEquipamento.ComportamentoPorStatus();
|
|
|
|
//OperacaoCarregar.DispSen.Dados.Sinaleiros.ForEach(x => OperacaoCarregar.DispSen.AdicionarMensagemFila(OperacaoCarregar.DispSen.Dados.Modulo_ID, x.ProtocoloComando(), true, false));
|
|
foreach (var Sinaleiro in Variaveis.OperacaoEmAndamento.DispSen.Dados.Sinaleiros)
|
|
{
|
|
GeneralJoystick.EnviarComandoSensoriamento(S_Code.sLED, Sinaleiro.ID, Sinaleiro.Comportamento);
|
|
}
|
|
}
|
|
}
|
|
|
|
Variaveis.OperacaoEmAndamento.Controle.Angulo = Variaveis.OperacaoEmAndamento.Controle.Angulo_Max;
|
|
Variaveis.OperacaoEmAndamento.Controle.PercentualVelocidadeSP = Variaveis.OperacaoEmAndamento.Controle.PercentualVelocidadeMin;
|
|
|
|
Variaveis.OperacaoEmAndamento.Sensoriamento.AtualizarDados();
|
|
|
|
RedisService.AtualizarCampos(CtxKey.DadosOperacao, ("configurado", false));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task IniciarOperacao()
|
|
{
|
|
tmrLogs?.Start();
|
|
|
|
Iniciado = true;
|
|
Simulando = false;
|
|
Treinando = false;
|
|
DataInicio = DateTime.Now;
|
|
DataFim = DateTime.MinValue;
|
|
idxLog = 0;
|
|
|
|
ID = DataInicio.ToString("dd_MM_yyyy_HH_mm_ss");
|
|
Directory.CreateDirectory(Variaveis.CaminhoOperacoes + ID + "/");
|
|
|
|
DispMvd?.Dados?.ReiniciarLeituras(DispMvd?.Dados);
|
|
DispAtu?.Dados?.ReiniciarLeituras(DispAtu?.Dados);
|
|
DispSen?.Dados?.ReiniciarLeituras(DispSen?.Dados);
|
|
|
|
RedisService.AtualizarCampos(CtxKey.DadosOperacao, ("configurado", false));
|
|
|
|
Sensoriamento.AtualizarDados();
|
|
|
|
Controle.Angulo = 0;
|
|
Controle.PercentualVelocidadeSP = 0;
|
|
Controle.TiposControle.ForEach(x => x.UltimaDirecao = Direcao.Parado);
|
|
Controle.TipoMovimento = TipoMovimentoDirecional.RodasDianteiras;
|
|
|
|
GPSTrajetoria = new List<GPSModel>();
|
|
|
|
await RealizarCalibragemInicialAsync();
|
|
|
|
if (Modo == ModoOperacao.Manual)
|
|
{
|
|
await Task.Run(async () =>
|
|
{
|
|
await Task.Delay(3000);
|
|
|
|
Controle.Angulo = 25;
|
|
Controle.PercentualVelocidadeSP = 25;
|
|
});
|
|
}
|
|
}
|
|
|
|
public async Task FinalizarOperacao()
|
|
{
|
|
if (Variaveis.OperacaoEmAndamento.Finalizando)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Variaveis.OperacaoEmAndamento.Finalizando = true;
|
|
|
|
Variaveis.OperacaoEmAndamento.Trajetoria?.LoopAtualizaDados();
|
|
|
|
await Task.Delay(2000);
|
|
|
|
Variaveis.OperacaoEmAndamento.Iniciado = false;
|
|
|
|
Variaveis.OperacaoEmAndamento.DataFim = DateTime.Now;
|
|
|
|
tmrLogs?.Stop();
|
|
|
|
SalvarLogs(false);
|
|
|
|
Variaveis.OperacaoEmAndamento.Finalizando = false;
|
|
}
|
|
|
|
public async Task RealizarCalibragemInicialAsync()
|
|
{
|
|
Console.WriteLine("Calibragem inicial inciada...");
|
|
Variaveis.OperacaoEmAndamento.Calibrando = true;
|
|
|
|
var DispAtu = Variaveis.OperacaoEmAndamento.DispAtu;
|
|
var DispMvd = Variaveis.OperacaoEmAndamento.DispMvd;
|
|
|
|
var tasks = new List<Task>();
|
|
if (DispAtu?.Dados != null) tasks.AddRange(DispAtu.Dados.RealizarCalibragemAsync());
|
|
if (DispMvd?.Dados != null) tasks.AddRange(DispMvd.Dados.RealizarCalibragemAsync());
|
|
|
|
if (tasks.Count == 0)
|
|
{
|
|
Console.WriteLine("Nenhuma calibragem foi iniciada.");
|
|
Variaveis.OperacaoEmAndamento.Calibrando = false;
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var allTasks = Task.WhenAll(tasks);
|
|
var completed = await Task.WhenAny(allTasks, Task.Delay(2 * 60 * 1000));
|
|
|
|
if (completed == allTasks)
|
|
{
|
|
Console.WriteLine("Calibragem finalizada com sucesso!");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Timeout na calibragem. Continuando mesmo assim.");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Erro durante calibragem: {ex.Message}");
|
|
}
|
|
|
|
Variaveis.OperacaoEmAndamento.Calibrando = false;
|
|
}
|
|
|
|
|
|
public async Task IniciarSimulacao()
|
|
{
|
|
Iniciado = true;
|
|
Simulando = true;
|
|
Treinando = false;
|
|
DataInicio = DateTime.Now;
|
|
DataFim = DateTime.MinValue;
|
|
|
|
ID = "";
|
|
|
|
DispMvd?.Dados?.ReiniciarLeituras(DispMvd.Dados);
|
|
DispAtu?.Dados?.ReiniciarLeituras(DispAtu.Dados);
|
|
DispSen?.Dados?.ReiniciarLeituras(DispSen.Dados);
|
|
|
|
await RealizarCalibragemInicialAsync();
|
|
|
|
RedisService.AtualizarCampos(CtxKey.DadosOperacao, ("configurado", false));
|
|
|
|
Sensoriamento?.AtualizarDados();
|
|
|
|
Controle.Angulo = 0;
|
|
Controle.PercentualVelocidadeSP = 0;
|
|
|
|
GPSTrajetoria = new List<GPSModel>();
|
|
}
|
|
|
|
public void ReiniciarSimulacao()
|
|
{
|
|
RedisService.AtualizarCampos(
|
|
CtxKey.DadosOperacao,
|
|
("status", StatusOperacao.Parametrizando),
|
|
("iniciado", false)
|
|
);
|
|
|
|
Variaveis.OperacaoEmAndamento.Iniciado = false;
|
|
Variaveis.OperacaoEmAndamento.Simulando = false;
|
|
Variaveis.OperacaoEmAndamento.Mapa = new MapasModel();
|
|
Variaveis.OperacaoEmAndamento.Trajetoria = new TrajetoriaMapaOperacaoModel(new List<List<GPSModel>>());
|
|
Variaveis.OperacaoEmAndamento.GPSTrajetoria = new List<GPSModel>();
|
|
|
|
var Topico = Variaveis.MqttService.Topicos.FirstOrDefault(x => x.Topico == MapasVariaveisModel.TopicoSelecaoRuasMapa);
|
|
Topico.Mensagens.Add(new MqttService.MqttTopicosMensagensModel()
|
|
{
|
|
Mensagem = "[]",
|
|
Momento = DateTime.Now
|
|
});
|
|
}
|
|
|
|
|
|
public void IniciarTreinamento()
|
|
{
|
|
Iniciado = true;
|
|
Treinando = true;
|
|
DataInicio = DateTime.Now;
|
|
DataFim = DateTime.MinValue;
|
|
|
|
ID = "";
|
|
|
|
if (DispMvd != null)
|
|
{
|
|
DispMvd.Dados.ReiniciarLeituras(DispMvd.Dados);
|
|
}
|
|
if (DispAtu != null)
|
|
{
|
|
DispAtu.Dados.ReiniciarLeituras(DispAtu.Dados);
|
|
}
|
|
if (DispSen != null)
|
|
{
|
|
DispSen.Dados.ReiniciarLeituras(DispSen.Dados);
|
|
}
|
|
|
|
Sensoriamento.AtualizarDados();
|
|
|
|
Controle.Angulo = 0;
|
|
Controle.PercentualVelocidadeSP = 0;
|
|
|
|
GPSTrajetoria = new List<GPSModel>();
|
|
}
|
|
|
|
|
|
public static string DeserializarDadosOperacao(string caminho, string arquivo)
|
|
{
|
|
string opPath = caminho.Replace("data.lgop", arquivo) + ".json";
|
|
string opStr = File.ReadAllText(opPath);
|
|
if (!opStr.EndsWith("]"))
|
|
{
|
|
opStr += "]";
|
|
}
|
|
return opStr;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region CONTROLE DA OPERACAO
|
|
|
|
public void AtualizaInformacoesControleOperacao()
|
|
{
|
|
if (Variaveis.OperacaoEmAndamento.Modo == ModoOperacao.MapaGPS)
|
|
{
|
|
Variaveis.OperacaoEmAndamento.AtualizarDadosControle(false);
|
|
}
|
|
}
|
|
|
|
public void AtualizarDadosControle(bool ForcarEnvio)
|
|
{
|
|
DateTime Agora = DateTime.Now;
|
|
|
|
var _Controle = Variaveis.OperacaoEmAndamento.Controle;
|
|
|
|
foreach (var Ctrl in _Controle.TiposControle)
|
|
{
|
|
if (ForcarEnvio || ((Agora - Ctrl.UltimoComando).TotalMilliseconds > Ctrl.DelayEnvioComando))
|
|
{
|
|
if (Ctrl.Tipo == T_Code.Atu && !_Controle.PulverizadorAutomatico)
|
|
{
|
|
return;
|
|
}
|
|
|
|
IDispositivosService disp = Ctrl.Tipo == T_Code.Atu ?
|
|
(IDispositivosService)Variaveis.OperacaoEmAndamento.DispAtu :
|
|
(IDispositivosService)Variaveis.OperacaoEmAndamento.DispMvd;
|
|
|
|
var Protocolos = EnviarProtocoloComando(disp, Ctrl.Tipo, ForcarEnvio);
|
|
Ctrl.UltimoComando = Agora;
|
|
Ctrl.Comandos.AddRange(Protocolos);
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<string> EnviarProtocoloComando(IDispositivosService Dispositivo, T_Code Tipo, bool ForcarEnvio)
|
|
{
|
|
if (Dispositivo == null || !Variaveis.OperacaoEmAndamento.Iniciado)
|
|
{
|
|
return new List<string>();
|
|
}
|
|
|
|
List<string> Protocolos = new List<string>();
|
|
|
|
var _Controle = Variaveis.OperacaoEmAndamento.Controle;
|
|
var _ControleAnterior = Variaveis.OperacaoEmAndamento.ControleAnterior;
|
|
|
|
if (Dispositivo.Dados is MovimentacaoUnificadaModel)
|
|
{
|
|
switch (Tipo)
|
|
{
|
|
case T_Code.Mov:
|
|
{
|
|
if (_Controle.RPM_SP == 0)
|
|
{
|
|
_Controle.Direcao = Direcao.Parado;
|
|
}
|
|
else if(_Controle.RPM_SP < 0)
|
|
{
|
|
_Controle.PercentualVelocidadeSP *= -1;
|
|
_Controle.Direcao = Direcao.Tras;
|
|
}
|
|
else if (_Controle.RPM_SP > 0)
|
|
{
|
|
_Controle.Direcao = Direcao.Frente;
|
|
}
|
|
|
|
if (ForcarEnvio || _Controle.RPM_SP != _ControleAnterior.RPM_SP)
|
|
{
|
|
((MovimentacaoUnificadaModel)Dispositivo.Dados).Modulos.ForEach(Mod => Mod.MovMotor.EnviarComandoControle(_Controle.Direcao));
|
|
|
|
_Controle.TiposControle.FirstOrDefault(x => x.Tipo == Tipo).UltimaDirecao = _Controle.Direcao;
|
|
}
|
|
|
|
_ControleAnterior.PercentualVelocidadeSP = _Controle.PercentualVelocidadeSP;
|
|
_ControleAnterior.Direcao = _Controle.Direcao;
|
|
break;
|
|
}
|
|
case T_Code.Dir:
|
|
{
|
|
if (_Controle.Angulo > 0)
|
|
{
|
|
_Controle.Direcao = Direcao.Direita;
|
|
}
|
|
else if (_Controle.Angulo < 0)
|
|
{
|
|
_Controle.Direcao = Direcao.Esquerda;
|
|
}
|
|
else
|
|
{
|
|
_Controle.Direcao = Direcao.Parado;
|
|
}
|
|
|
|
// Só enviar comando se a direção realmente mudou
|
|
if (ForcarEnvio || _Controle.Angulo != _ControleAnterior.Angulo)
|
|
{
|
|
((MovimentacaoUnificadaModel)Dispositivo.Dados).Modulos.ForEach(Mod => Mod.DirMotor.EnviarComandoControle(_Controle.Direcao));
|
|
|
|
_Controle.TiposControle.FirstOrDefault(x => x.Tipo == Tipo).UltimaDirecao = _Controle.Direcao;
|
|
}
|
|
|
|
_ControleAnterior.Angulo = _Controle.Angulo;
|
|
_ControleAnterior.Direcao = _Controle.Direcao;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Protocolos = new List<string>()
|
|
{
|
|
Tipo.ToString() + ";" + _Controle.Direcao.ToString() + ";" + _Controle.RPM_SP.ToString() + ";" + _Controle.Angulo.ToString()
|
|
};
|
|
|
|
}
|
|
else if (Dispositivo.Dados is AtuadorModel)
|
|
{
|
|
if (ForcarEnvio || _ControleAnterior.BicosAtuados.Count() >= _Controle.BicosAtuados.Count())
|
|
{
|
|
for (int i = 0; i < _Controle.BicosAtuados.Count; i++)
|
|
{
|
|
if (_Controle.BicosAtuados[i].ComandoAtuar != _ControleAnterior.BicosAtuados[i].ComandoAtuar)
|
|
{
|
|
GeneralJoystick.EnviarComandoAtuador(S_Code.sBIC, _Controle.BicosAtuados[i].ComandoAtuar, _Controle.BicosAtuados[i].ID);
|
|
}
|
|
}
|
|
}
|
|
|
|
_ControleAnterior.BicosAtuados = _Controle.BicosAtuados.Select(x => x.Clone()).ToList();
|
|
|
|
Protocolos = new List<string>()
|
|
{
|
|
Tipo.ToString() + ";" + string.Join(";", _Controle.BicosAtuados.Select(x => x.ComandoAtuar ? "1" : "0"))
|
|
};
|
|
}
|
|
|
|
return Protocolos;
|
|
}
|
|
|
|
private async Task tmrLeituras_Tick()
|
|
{
|
|
if (Variaveis.IsAgroMonitor)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Variaveis.OperacaoEmAndamento.Sensoriamento.AtualizarDados();
|
|
|
|
if (!Variaveis.OperacaoEmAndamento.Iniciado)
|
|
{
|
|
Variaveis.OperacaoEmAndamento.Mapa.AtualizarRuasSelecionadas();
|
|
}
|
|
}
|
|
|
|
public void ExecutaComandoDaBase(OperacaoControleBaseModel controleBase)
|
|
{
|
|
Emergencia = controleBase.Emergencia;
|
|
|
|
if (Emergencia)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var _Controle = Variaveis.OperacaoEmAndamento.Controle;
|
|
|
|
// Salvar estado anterior
|
|
double oldPercentualVelocidade = _Controle.PercentualVelocidadeSP;
|
|
double oldAngulo = _Controle.Angulo;
|
|
double oldVelocidadeMP = _Controle.VelocidadeMP;
|
|
TipoMovimentoDirecional oldTipoMovimento = _Controle.TipoMovimento;
|
|
|
|
// Atualizar estado atual com os valores do controleBase
|
|
_Controle.PercentualVelocidadeSP = controleBase.PercentualVelocidadeSP;
|
|
_Controle.Angulo = controleBase.AnguloMP;
|
|
_Controle.VelocidadeMP = controleBase.VelocidadeMP;
|
|
_Controle.TipoMovimento = controleBase.TipoMovimento;
|
|
|
|
// Enviar comando
|
|
GeneralJoystick.EnviaComandoMotor(controleBase.Tecla, controleBase.Dispositivo, true);
|
|
|
|
// Restaurar estado anterior
|
|
_Controle.PercentualVelocidadeSP = oldPercentualVelocidade;
|
|
_Controle.Angulo = oldAngulo;
|
|
_Controle.VelocidadeMP = oldVelocidadeMP;
|
|
_Controle.TipoMovimento = oldTipoMovimento;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region REGISTRO DE LOGS
|
|
|
|
private int idxLog = 0;
|
|
|
|
private async Task tmrLogs_Tick()
|
|
{
|
|
if (Variaveis.OperacaoEmAndamento.Iniciado)
|
|
{
|
|
SalvarLogs(false);
|
|
}
|
|
}
|
|
|
|
public void SalvarLogs(bool Fim)
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(Variaveis.OperacaoEmAndamento.ID))
|
|
{
|
|
DateTime Agora = DateTime.Now;
|
|
|
|
OperacaoSensoriamentoLogModel logGeral = Variaveis.OperacaoEmAndamento.Sensoriamento.Clone();
|
|
logGeral.Momento = Agora;
|
|
SalvarLog("operacao", logGeral, Fim);
|
|
|
|
GPSModel logGps = GPSService.UltimaLeitura.Clone();
|
|
logGps.Momento = Agora;
|
|
SalvarLog(T_Code.Gps.ToString(), logGps, Fim);
|
|
|
|
Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.ForEach(Modulo =>
|
|
{
|
|
MovSensoriamentoLogModel logMov = new MovSensoriamentoLogModel()
|
|
{
|
|
Momento = Agora,
|
|
Modulo_ID = Modulo.Modulo_ID,
|
|
Inicializado = Modulo.MovMotor.Inicializado,
|
|
RPM_SP = Modulo.MovMotor.RPM_SP,
|
|
RPM_Motor = Modulo.MovMotor.RPM_Motor,
|
|
RPM_Roda = Modulo.MovMotor.RPM_Roda,
|
|
Corrente_Motor = Modulo.MovMotor.Corrente_Motor,
|
|
Temperatura = Modulo.MovMotor.Temperatura,
|
|
TemperaturaDriver = Modulo.MovMotor.TemperaturaDriver,
|
|
Tensao = Modulo.MovMotor.Tensao,
|
|
Sentido_SP = Modulo.MovMotor.Sentido_SP,
|
|
Sentido = Modulo.MovMotor.Sentido,
|
|
Velocidade = Modulo.MovMotor.VelocidadeInstantanea,
|
|
CodAlarme = Modulo.MovMotor.CodigoAlarme,
|
|
AlarmeSensores = Modulo.MovMotor.AlarmeSensores,
|
|
AlarmeComando = Modulo.MovMotor.AlarmeComando,
|
|
EmFreio = Modulo.MovMotor.ConfigFreio.Leitura,
|
|
Ativado = Modulo.MovMotor.LeituraLigado,
|
|
UltimoComandoRespondido = Modulo.MovMotor.Leitura?.UltimoComandoRecebido ?? DateTime.MinValue,
|
|
Corrente_Barramento = Modulo.MovMotor.Corrente_Barramento,
|
|
Potencia = Modulo.MovMotor.Potencia,
|
|
CicloTrabalho = Modulo.MovMotor.CicloTrabalho
|
|
};
|
|
SalvarLog(T_Code.Mov.ToString(), logMov, false);
|
|
|
|
DirSensoriamentoLogModel logDir = new DirSensoriamentoLogModel()
|
|
{
|
|
Momento = Agora,
|
|
Modulo_ID = Modulo.Modulo_ID,
|
|
Inicializado = Modulo.DirMotor.Inicializado,
|
|
Angulo = Modulo.DirMotor.Angulo,
|
|
Angulo_SP = Modulo.DirMotor.Angulo_SP,
|
|
Controlar = Modulo.DirMotor.Comandar,
|
|
Sentido_SP = Modulo.DirMotor.Sentido_SP,
|
|
Sentido = Modulo.DirMotor.Sentido,
|
|
SentidoReal = Modulo.DirMotor.SentidoReal,
|
|
Velocidade = (Modulo.DirMotor.Velocidade / Modulo.DirMotor.Velocidade_Max) * 100.0,
|
|
UltimoComandoRespondido = Modulo.DirMotor.Leitura?.UltimoComandoRecebido ?? DateTime.MinValue,
|
|
};
|
|
SalvarLog(T_Code.Dir.ToString(), logDir, false);
|
|
});
|
|
|
|
AtuSensoriamentoLogModel logAtu = new AtuSensoriamentoLogModel()
|
|
{
|
|
Momento = Agora,
|
|
Inicializado = Variaveis.OperacaoEmAndamento.DispAtu.Dados.ConexaoAtiva,
|
|
QualidadeWifi = Variaveis.OperacaoEmAndamento.DispAtu.Dados.DadosLeitura.QualidadeWifi,
|
|
LatenciaLoop = Variaveis.OperacaoEmAndamento.DispAtu.Dados.DadosLeitura.LatenciaLoop,
|
|
MassaReservatorio = Variaveis.OperacaoEmAndamento.DispAtu.Dados.MassaReservatorio,
|
|
PercentualReservatorio = Variaveis.OperacaoEmAndamento.DispAtu.Dados.PercentualReservatorio,
|
|
VolumeReservatorio = Variaveis.OperacaoEmAndamento.DispAtu.Dados.VolumeReservatorio,
|
|
PressaoLinha_SP = Variaveis.OperacaoEmAndamento.Controle.PressaoLinha,
|
|
PressaoLinha = Variaveis.OperacaoEmAndamento.DispAtu.Dados.PressaoLinha,
|
|
PotenciaBomba = Variaveis.OperacaoEmAndamento.DispAtu.Dados.BombasPressurizadoras.FirstOrDefault().ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.Potencia).atual.valor ?? 0,
|
|
BombaLigada = Variaveis.OperacaoEmAndamento.DispAtu.Dados.BombasPressurizadoras.FirstOrDefault().ComandoAtuar,
|
|
VazaoFluxoMLpSInstantanea = Variaveis.OperacaoEmAndamento.DispAtu.Dados.VazaoFluxoMLpSInstantanea,
|
|
VazaoFluxoMLpSMedia = Variaveis.OperacaoEmAndamento.DispAtu.Dados.VazaoFluxoMLpSMedia,
|
|
VolumeVazaoML = Variaveis.OperacaoEmAndamento.DispAtu.Dados.VolumeVazaoML,
|
|
QuantidadeBicos = Variaveis.OperacaoEmAndamento.DispAtu.Dados.QuantidadeBicos,
|
|
TempoPulverizadorAtuado = Variaveis.OperacaoEmAndamento.DispAtu.Dados.TempoAtuado,
|
|
Bicos = Variaveis.OperacaoEmAndamento.DispAtu.Dados.BicosPulverizadores.Select(Bico => new AtuBicoSensoriamentoLogModel()
|
|
{
|
|
ID = Bico.ID,
|
|
Inicializado = Bico.Inicializado,
|
|
Comandar = Bico.Comandar,
|
|
Atuado = Bico.ComandoAtuar,
|
|
MediaNivelFluxo = Bico.MediaNivelFluxo,
|
|
Posicao = Bico.Posicao,
|
|
StatusBico = Bico.ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.EstadoLeitura).atual.valor ?? false,
|
|
Atuacoes = Bico.Atuacoes,
|
|
TempoAtuado = Bico.TempoAtuado,
|
|
}).ToList(),
|
|
UltimoComandoRespondido = Variaveis.OperacaoEmAndamento.DispAtu.Dados.DadosLeitura.Momento,
|
|
};
|
|
SalvarLog(T_Code.Atu.ToString(), logAtu, false);
|
|
|
|
var senLeitura = Variaveis.OperacaoEmAndamento.DispSen.Dados;
|
|
SensoriamentoMensagemJsonModel logSen = new SensoriamentoMensagemJsonModel()
|
|
{
|
|
Momento = Agora,
|
|
Conectado = senLeitura.DadosLeitura.Conectado,
|
|
LatenciaLoop = senLeitura.DadosLeitura.LatenciaLoop,
|
|
QualidadeWifi = senLeitura.DadosLeitura.QualidadeWifi,
|
|
Mod_ID = senLeitura.DadosLeitura.Mod_ID,
|
|
UltimoComandoRespondido = senLeitura.DadosLeitura.UltimoComandoRespondido,
|
|
Reles = new List<SensorReleModel>(senLeitura.Reles),
|
|
Sensores = new List<SensorModel>(senLeitura.Sensores),
|
|
Servos = new List<SensorServoModel>(senLeitura.Servos),
|
|
Sinaleiros = new List<SensorSinaleiroModel>(senLeitura.Sinaleiros),
|
|
};
|
|
SalvarLog(T_Code.Sen.ToString(), logSen, false);
|
|
|
|
VisualWorkerModel logSnr = Variaveis.OperacaoEmAndamento.Sensoriamento.OperadorVisual?.Clone();
|
|
logSnr.UltimaMensagem = Agora;
|
|
SalvarLog(T_Code.Snr.ToString(), logSnr, Fim);
|
|
|
|
SalvarLogCameraCaminho();
|
|
|
|
string ArquivoOp = Variaveis.CaminhoOperacoes + Variaveis.OperacaoEmAndamento.ID + "/data.lgop";
|
|
if (!File.Exists(ArquivoOp))
|
|
{
|
|
var data = new OperacaoDadosModel()
|
|
{
|
|
id = Variaveis.OperacaoEmAndamento.ID,
|
|
operacao = "operacao",
|
|
gps = T_Code.Gps.ToString(),
|
|
dir = T_Code.Dir.ToString(),
|
|
mov = T_Code.Mov.ToString(),
|
|
atu = T_Code.Atu.ToString(),
|
|
sen = T_Code.Sen.ToString(),
|
|
pzm = T_Code.Pzm.ToString(),
|
|
a05 = T_Code.A05.ToString(),
|
|
snr = T_Code.Snr.ToString(),
|
|
cam_caminho = Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraCaminho.Name,
|
|
cam_solo = Variaveis.OperacaoEmAndamento.DispSen.Dados.CamerasSolo.Select(x => x.Name).ToList(),
|
|
};
|
|
File.WriteAllText(ArquivoOp, JsonConvert.SerializeObject(data));
|
|
}
|
|
|
|
Variaveis.OperacaoEmAndamento.idxLog++;
|
|
|
|
|
|
if (Variaveis.OperacaoEmAndamento.idxLog % 5 == 0)
|
|
{
|
|
LoRaService.EnviarDadosParaBase();
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine("Erro ao salvar log: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
private void SalvarLog<T>(string Arquivo, T Objeto, bool Fim)
|
|
{
|
|
var Caminho = Variaveis.CaminhoOperacoes + Variaveis.OperacaoEmAndamento.ID;
|
|
if (!Directory.Exists(Caminho))
|
|
{
|
|
Directory.CreateDirectory(Caminho);
|
|
}
|
|
|
|
Caminho += "/" + Arquivo + ".json";
|
|
string jsonLog = JsonConvert.SerializeObject(Objeto, Formatting.None);
|
|
|
|
if (!File.Exists(Caminho))
|
|
{
|
|
File.WriteAllText(Caminho, "[" + jsonLog);
|
|
}
|
|
else
|
|
{
|
|
File.AppendAllText(Caminho, "," + jsonLog + (Fim ? "]" : ""));
|
|
}
|
|
}
|
|
|
|
private void SalvarLogCameraCaminho()
|
|
{
|
|
var Camera = Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraCaminho;
|
|
|
|
string Caminho = Variaveis.CaminhoOperacoes + Variaveis.OperacaoEmAndamento.ID + "/" + Camera.Dispositivo;
|
|
if (!Directory.Exists(Caminho))
|
|
{
|
|
Directory.CreateDirectory(Caminho);
|
|
}
|
|
|
|
string nome = Variaveis.OperacaoEmAndamento.idxLog.ToString();
|
|
|
|
Camera.SaveFrames(new List<VisualWorkerFrameType>() { VisualWorkerFrameType.Rgb, VisualWorkerFrameType.Heatmap, VisualWorkerFrameType.RadarTopDown, VisualWorkerFrameType.Segmentacao }, nome, Caminho);
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region FORMULARIO
|
|
|
|
public void AbrirForm()
|
|
{
|
|
if (Variaveis.OperacaoEmAndamento.OperacaoLiberada)
|
|
{
|
|
frmOperacao =
|
|
Modo == ModoOperacao.Manual ? new frmOperacaoManual() :
|
|
Modo == ModoOperacao.MapaGPS ? new frmOperacaoMapaGPS() :
|
|
new Form();
|
|
|
|
frmOperacao.Show();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show(Variaveis.OperacaoEmAndamento.ErroOperacaoLiberada, "Conexão de módulos pendentes", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
public string TextoFormOperacao(string ModoNome)
|
|
{
|
|
var statusAtual = Variaveis.OperacaoEmAndamento.StatusAtual;
|
|
|
|
if (statusAtual == StatusOperacao.Parametrizando)
|
|
{
|
|
return "Operação " + ModoNome + " - Parametrização";
|
|
}
|
|
else if (statusAtual == StatusOperacao.Aguardando)
|
|
{
|
|
return "Operação " + ModoNome + " - Iniciando em " + (Variaveis.OperacaoEmAndamento.TempoAguardando.AddSeconds(Variaveis.OperacaoEmAndamento.TempoIniciarOperacao) - DateTime.Now).TotalSeconds.ToString("0") + " segundo" + ((Variaveis.OperacaoEmAndamento.TempoAguardando.AddSeconds(Variaveis.OperacaoEmAndamento.TempoIniciarOperacao) - DateTime.Now).TotalSeconds < 1 ? "" : "s") + "...";
|
|
}
|
|
else if (statusAtual == StatusOperacao.Concluido)
|
|
{
|
|
return "Operação " + ModoNome + " - Concluída";
|
|
}
|
|
else if (statusAtual == StatusOperacao.EmAndamento)
|
|
{
|
|
return "Operação " + ModoNome + " - Em andamento";
|
|
}
|
|
else if (statusAtual == StatusOperacao.Parado)
|
|
{
|
|
return "Operação " + ModoNome + " - Parado";
|
|
}
|
|
else
|
|
{
|
|
return "Operação " + ModoNome;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region DIAGNOSTICO
|
|
|
|
public static void PopularTreeView(TreeView treeView, List<ManagerWorkerMessageResponseModulosPendentesModel> modulos)
|
|
{
|
|
treeView.Font = new Font("Consolas", 10);
|
|
treeView.Nodes.Clear();
|
|
|
|
foreach (var modulo in modulos)
|
|
{
|
|
string nomeModulo = $"{modulo.modulo} {modulo.status} (Saúde: {modulo.saude:0}%)";
|
|
TreeNode nodoModulo = new TreeNode(nomeModulo);
|
|
|
|
foreach (var item in modulo.saude_individual.Where(x => x.em_uso))
|
|
{
|
|
string nomeItem = $"{item.label} ({item.id}) {item.status} (Saúde: {item.saude:0}%)";
|
|
TreeNode nodoItem = new TreeNode(nomeItem);
|
|
|
|
// Adiciona os motivos normais (de saúde)
|
|
foreach (var motivo in item.motivos)
|
|
{
|
|
nodoItem.Nodes.Add(new TreeNode(motivo));
|
|
}
|
|
|
|
// Agrupamento das condições operacionais (se houver)
|
|
if (item.condicoes_operacionais != null && item.condicoes_operacionais.Count > 0)
|
|
{
|
|
TreeNode nodoCondicoes = new TreeNode("Condições Operacionais");
|
|
|
|
foreach (var cond in item.condicoes_operacionais)
|
|
{
|
|
string textoCond = $"{cond.descricao} (Valor: {cond.valor}, Severidade: {cond.severidade:0}%)";
|
|
nodoCondicoes.Nodes.Add(new TreeNode(textoCond));
|
|
}
|
|
|
|
nodoItem.Nodes.Add(nodoCondicoes);
|
|
}
|
|
|
|
nodoModulo.Nodes.Add(nodoItem);
|
|
}
|
|
|
|
treeView.Nodes.Add(nodoModulo);
|
|
}
|
|
|
|
treeView.ExpandAll();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
public class OperacaoControleModel
|
|
{
|
|
public int RPM_Max { get; set; } = 100;
|
|
public int RPM_Min { get; set; } = 20;
|
|
public double Angulo_Max { get; set; } = 30;
|
|
public double Angulo_Min { get; set; } = -30;
|
|
public double VelocidadeMP { get; set; } = 50;
|
|
|
|
private double _angulo_sp = 0.0;
|
|
public double Angulo { get; set; }
|
|
public int RPM_SP
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToInt32(VariaveisEquipamento.RPM_Max_Roda * (PercentualVelocidadeSP / 100.0));
|
|
}
|
|
}
|
|
public int RPM_Motor
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToInt32(RPM_SP * VariaveisEquipamento.RelacaoRPM);
|
|
}
|
|
}
|
|
private double _velocidade_sp = 0.0;
|
|
public double PercentualVelocidadeSP { get; set; }
|
|
public double PercentualVelocidadeMin
|
|
{
|
|
get
|
|
{
|
|
return FuncoesMatematicas.Map(RPM_Min, 0, VariaveisEquipamento.RPM_Max_Roda, 0, 100);
|
|
}
|
|
}
|
|
public double PercentualVelocidadeMax
|
|
{
|
|
get
|
|
{
|
|
return FuncoesMatematicas.Map(RPM_Max, 0, VariaveisEquipamento.RPM_Max_Roda, 0, 100);
|
|
}
|
|
}
|
|
public Direcao Direcao { get; set; } = Direcao.Parado;
|
|
private TipoMovimentoDirecional _tipoMovimento;
|
|
public TipoMovimentoDirecional TipoMovimento
|
|
{
|
|
get
|
|
{
|
|
return _tipoMovimento;
|
|
}
|
|
set
|
|
{
|
|
var DispMvd = Variaveis.OperacaoEmAndamento.DispMvd;
|
|
if (DispMvd != null)
|
|
{
|
|
if (value != _tipoMovimento)
|
|
{
|
|
switch (value)
|
|
{
|
|
case TipoMovimentoDirecional.RodasDianteiras:
|
|
DispMvd.Dados.Modulos.ForEach(x =>
|
|
{
|
|
x.MovMotor.Comandar = true;
|
|
x.DirMotor.Comandar = x.Modulo_ID.Contains("F");
|
|
});
|
|
break;
|
|
case TipoMovimentoDirecional.RodasTraseiras:
|
|
DispMvd.Dados.Modulos.ForEach(x =>
|
|
{
|
|
x.MovMotor.Comandar = true;
|
|
x.DirMotor.Comandar = x.Modulo_ID.Contains("T");
|
|
});
|
|
break;
|
|
default:
|
|
DispMvd.Dados.Modulos.ForEach(x =>
|
|
{
|
|
x.MovMotor.Comandar = true;
|
|
x.DirMotor.Comandar = true;
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
_tipoMovimento = value;
|
|
}
|
|
}
|
|
|
|
public double PercentualInicioPulverizacao { get; set; } = 0.3;
|
|
public List<AtuadorBicoModel> BicosAtuados { get; set; } = new List<AtuadorBicoModel>();
|
|
public int TempoAtuacao { get; set; } = 200;
|
|
public double PressaoLinha { get; set; } = 85;
|
|
|
|
public List<OperacaoControleTipoModel> TiposControle { get; set; }
|
|
public bool PulverizadorAutomatico { get; set; } = true;
|
|
public bool SegmentacaoSemantica { get; set; } = false;
|
|
public bool SonarAtivado { get; set; } = false;
|
|
public bool SonarDesvioAutomatico { get; set; } = false;
|
|
|
|
public TiposControladorDirecional TipoControleDirecional { get; set; } = TiposControladorDirecional.PID;
|
|
|
|
public List<MPCSimulacaoModel> SimulacaoMPC { get; set; } = new List<MPCSimulacaoModel>();
|
|
|
|
public OperacaoControleModel Clone()
|
|
{
|
|
return new OperacaoControleModel()
|
|
{
|
|
Angulo = Angulo,
|
|
Angulo_Max = Angulo_Max,
|
|
Angulo_Min = Angulo_Min,
|
|
BicosAtuados = new List<AtuadorBicoModel>(BicosAtuados),
|
|
Direcao = Direcao,
|
|
PercentualInicioPulverizacao = PercentualInicioPulverizacao,
|
|
PercentualVelocidadeSP = PercentualVelocidadeSP,
|
|
_tipoMovimento = _tipoMovimento,
|
|
PressaoLinha = PressaoLinha,
|
|
PulverizadorAutomatico = PulverizadorAutomatico,
|
|
RPM_Max = RPM_Max,
|
|
RPM_Min = RPM_Min,
|
|
SegmentacaoSemantica = SegmentacaoSemantica,
|
|
SonarAtivado = SonarAtivado,
|
|
SonarDesvioAutomatico = SonarDesvioAutomatico,
|
|
TempoAtuacao = TempoAtuacao,
|
|
TipoControleDirecional = TipoControleDirecional,
|
|
TipoMovimento = TipoMovimento,
|
|
TiposControle = new List<OperacaoControleTipoModel>(TiposControle),
|
|
VelocidadeMP = VelocidadeMP,
|
|
SimulacaoMPC = new List<MPCSimulacaoModel>(SimulacaoMPC),
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OperacaoControleTipoModel
|
|
{
|
|
public T_Code Tipo { get; set; }
|
|
public int DelayEnvioComando { get; set; }
|
|
public DateTime UltimoComando { get; set; }
|
|
public List<string> Comandos { get; set; }
|
|
public Direcao UltimaDirecao { get; set; } = Direcao.Parado;
|
|
}
|
|
|
|
public class OperacaoModulosMandatoriosModel
|
|
{
|
|
public T_Code Dispositivo { get; set; }
|
|
public bool Mandatorio { get; set; }
|
|
public bool Utilizar { get; set; }
|
|
public bool Conectado { get; set; }
|
|
public bool Liberado
|
|
{
|
|
get
|
|
{
|
|
bool _liberado = true;
|
|
|
|
if (!Mandatorio || !Utilizar) return _liberado;
|
|
|
|
var _DispMvd = Variaveis.OperacaoEmAndamento.DispMvd;
|
|
|
|
switch (Dispositivo)
|
|
{
|
|
case T_Code.Mov:
|
|
{
|
|
(bool _EsqOperante, List<string> _EsqModsInoperantes) = _DispMvd?.Dados?.StatusModulosMOV(Direcao.Esquerda) ?? (true, new List<string>());
|
|
(bool _DirOperante, List<string> _DirModsInoperantes) = _DispMvd?.Dados?.StatusModulosMOV(Direcao.Direita) ?? (true, new List<string>());
|
|
_liberado = _EsqOperante && _DirOperante;
|
|
break;
|
|
}
|
|
case T_Code.Dir:
|
|
{
|
|
(bool _MksOperante, List<string> _MksModsInoperantes) = _DispMvd?.Dados?.StatusModulosDIR(Variaveis.OperacaoEmAndamento.Controle.TipoMovimento) ?? (true, new List<string>());
|
|
_liberado = _MksOperante;
|
|
break;
|
|
}
|
|
case T_Code.Atu:
|
|
{
|
|
(bool _AtuOperante, List<string> _AtuModsInoperantes) = Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.StatusModulosATU() ?? (true, new List<string>());
|
|
_liberado = _AtuOperante;
|
|
break;
|
|
}
|
|
case T_Code.Sen:
|
|
{
|
|
(bool _SenOperante, List<string> _SenModsInoperantes) = Variaveis.OperacaoEmAndamento.DispSen?.Dados?.StatusModulosSEN() ?? (true, new List<string>());
|
|
_liberado = _SenOperante;
|
|
break;
|
|
}
|
|
case T_Code.Gps:
|
|
{
|
|
_liberado = (Variaveis.OperacaoEmAndamento.Sensoriamento.Gps?.PrecisaoCm ?? 0) < GPSService.PrecisaoMinimaCm;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return Conectado && _liberado;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class OperacaoParametrosMandatoriosModel
|
|
{
|
|
public ParametrosOperacao Parametro { get; set; }
|
|
public bool Mandatorio { get; set; }
|
|
public bool Utilizar { get; set; }
|
|
}
|
|
|
|
public class OperacaoControleBaseModel
|
|
{
|
|
public DateTime Momento { get; set; }
|
|
public Keys Tecla { get; set; }
|
|
public T_Code Dispositivo { get; set; }
|
|
public double PercentualVelocidadeSP { get; set; }
|
|
public double AnguloMP { get; set; }
|
|
public double VelocidadeMP { get; set; }
|
|
public bool Emergencia { get; set; }
|
|
public TipoMovimentoDirecional TipoMovimento { get; set; }
|
|
}
|
|
|
|
|
|
public class OperacaoDadosModel
|
|
{
|
|
public string id { get; set; }
|
|
public string operacao { get; set; }
|
|
public string gps { get; set; }
|
|
public string dir { get; set; }
|
|
public string mov { get; set; }
|
|
public string atu { get; set; }
|
|
public string sen { get; set; }
|
|
public string pzm { get; set; }
|
|
public string snr { get; set; }
|
|
public string a05 { get; set; }
|
|
public string cam_caminho { get; set; }
|
|
public List<string> cam_solo { get; set; }
|
|
}
|
|
|
|
public class OperacaoSensoriamentoLogModel
|
|
{
|
|
public DateTime Momento { get; set; }
|
|
public ulong CodigoFalha { get; set; }
|
|
public bool OperacaoLiberada { get; set; }
|
|
public StatusOperacao StatusOperacao { get; set; } = StatusOperacao.Parado;
|
|
public DateTime DataInicio { get; set; }
|
|
public DateTime DataFim { get; set; }
|
|
public double TempoDecorridoSeg { get; set; }
|
|
public DateTime TempoDecorrido
|
|
{
|
|
get
|
|
{
|
|
return new DateTime().AddSeconds(TempoDecorridoSeg);
|
|
}
|
|
}
|
|
public OperacaoSensoriamentoLogImuModel IMU { get; set; }
|
|
public OperacaoSensoriamentoLogAtuModel Atuador { get; set; }
|
|
public OperacaoSensoriamentoLogMvdModel Movimentacao { get; set; }
|
|
public OperacaoSensoriamentoLogBateriaModel Bateria { get; set; }
|
|
public OperacaoSensoriamentoLogTrajetoriaModel Trajetoria { get; set; }
|
|
public GPSModel Gps { get; set; }
|
|
public PerformanceModel DadosPerformance { get; set; } = new PerformanceModel();
|
|
public OperacaoControleModel Controle { get; set; }
|
|
public VisualWorkerModel OperadorVisual { get; set; }
|
|
|
|
|
|
|
|
public void AtualizarDados()
|
|
{
|
|
Variaveis.OperacaoEmAndamento.AtualizarDadosContexto();
|
|
VisualWorkerService.AtualizarAnalise();
|
|
|
|
var _Trajetoria = Variaveis.OperacaoEmAndamento.Trajetoria;
|
|
var _DispMvd = Variaveis.OperacaoEmAndamento.DispMvd;
|
|
var _DispAtu = Variaveis.OperacaoEmAndamento.DispAtu;
|
|
var _DispSen = Variaveis.OperacaoEmAndamento.DispSen;
|
|
var _Controle = Variaveis.OperacaoEmAndamento.Controle;
|
|
|
|
Variaveis.OperacaoEmAndamento.DadosPerformance.AtualizarDadosPerformance();
|
|
|
|
// Soma total de atuações para todas as ervas de todos os bicos
|
|
int totalAtuacoes = 0;
|
|
|
|
// Evitar divisão por zero
|
|
double HerbicidaPorErva = totalAtuacoes > 0
|
|
? _DispAtu.Dados.VolumeVazaoML / totalAtuacoes
|
|
: 0.0;
|
|
|
|
var sIMU = VisualWorkerService.DadosLeitura.Imu;
|
|
var dadosIMU = sIMU != null ? new OperacaoSensoriamentoLogImuModel()
|
|
{
|
|
Iniciado = sIMU.timestamp > 0,
|
|
InclinacaoLateral = sIMU.roll,
|
|
InclinacaoFrontal = sIMU.pitch,
|
|
Rotacao = sIMU.yaw,
|
|
RotacaoCorrigida = sIMU.yaw_fixed,
|
|
} : new OperacaoSensoriamentoLogImuModel();
|
|
|
|
var dadosAtuador = _DispAtu != null ? new OperacaoSensoriamentoLogAtuModel()
|
|
{
|
|
HerbicidaConsumido = _DispAtu.Dados.VolumeVazaoML,
|
|
PercentualErvasTerreno = _DispAtu.Dados.PercentualErvasTerreno,
|
|
HerbicidaPorErva = HerbicidaPorErva,
|
|
ErvasNoRadar = 0,
|
|
ErvasIdentificadas = new List<Dictionary<string, int>>(),
|
|
PercentualReservatorio = FuncoesMatematicas.Clamp(_DispAtu.Dados.PercentualReservatorio, 0, 100),
|
|
VolumeReservatorio = _DispAtu.Dados.VolumeReservatorio,
|
|
PressaoLinha = _DispAtu.Dados.PressaoLinha,
|
|
VazaoInstantanea = _DispAtu.Dados.VazaoFluxoMLpSInstantanea,
|
|
VazaoMedia = _DispAtu.Dados.VazaoFluxoMLpSMedia,
|
|
LeituraPotenciaBomba = FuncoesMatematicas.Clamp(_DispAtu.Dados.BombasPressurizadoras.FirstOrDefault().ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.Potencia)?.atual?.valor ?? 0, 0, 100),
|
|
VolumeVazaoMl = _DispAtu.Dados.VolumeVazaoML
|
|
} : new OperacaoSensoriamentoLogAtuModel();
|
|
|
|
var dadosMovimentacao = _DispMvd != null ? new OperacaoSensoriamentoLogMvdModel()
|
|
{
|
|
VelocidadeMedia = _DispMvd.Dados.VelocidadeMedia,
|
|
RPMMedio = _DispMvd.Dados.Modulos.Where(x => x.MovMotor.Inicializado).DefaultIfEmpty()?.Average(x => x?.MovMotor?.RPM_Roda ?? 0) ?? 0,
|
|
TempoMovimentoSegs = _DispMvd.Dados.TempoEmAtividade,
|
|
Dir_Status = _DispMvd.Dados.StatusModulosDIR(_Controle.TipoMovimento),
|
|
MovEsq_Status = _DispMvd.Dados.StatusModulosMOV(Direcao.Esquerda),
|
|
MovDir_Status = _DispMvd.Dados.StatusModulosMOV(Direcao.Direita)
|
|
} : new OperacaoSensoriamentoLogMvdModel();
|
|
|
|
var S36V = _DispSen?.Dados?.Sensores?.FirstOrDefault(x => x.ID == "AB36V");
|
|
var dadosBateria = S36V != null ? new OperacaoSensoriamentoLogBateriaModel()
|
|
{
|
|
Iniciado = S36V.Inicializado,
|
|
_dt = S36V.ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.Corrente)?.atual?.dt ?? 0,
|
|
PorcentagemBateria = FuncoesMatematicas.Clamp(_DispSen.Dados.ContadorCarga.PercentualBateria, 0, 100),
|
|
BateriaConsumida = FuncoesMatematicas.Clamp(_DispSen.Dados.ContadorCarga.PercentualConsumido, 0, 100),
|
|
TempoEstimadoRestanteMinutos = _DispSen.Dados.ContadorCarga.TempoEstimadoMinutos,
|
|
CorrenteInstantanea = (S36V.ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.Corrente)?.atual?.valor ?? 0) / 1000.0,
|
|
TensaoInstantanea = S36V.ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.Tensao)?.atual?.valor ?? 0,
|
|
PotenciaInstantanea = S36V.ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.Potencia)?.atual?.valor ?? 0,
|
|
PotenciaAcumulada = S36V.ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.Temperatura)?.atual?.valor ?? 0
|
|
} : new OperacaoSensoriamentoLogBateriaModel();
|
|
|
|
var dadosTrajetoria = new OperacaoSensoriamentoLogTrajetoriaModel()
|
|
{
|
|
StatusCarro = _Trajetoria?.StatusAtual ?? StatusCarroMapa.Parado,
|
|
DistanciaDireita = _Trajetoria?.DistanciaDireita ?? 0,
|
|
DistanciaEsquerda = _Trajetoria?.DistanciaEsquerda ?? 0,
|
|
ProgressoTrajeto = FuncoesMatematicas.Clamp(_Trajetoria?.PercentualTrajetoria ?? 0, 0, 100),
|
|
CorredorAtual = _Trajetoria?.CorredorAtual?.Clone(false) ?? new CorredorTrajetoriaModel(),
|
|
DirecaoCaminho = _Trajetoria?.DirecaoCaminho ?? DirecaoCarroRua.Parado,
|
|
AnguloCaminho = _Trajetoria?.AnguloCaminho ?? 0,
|
|
AnguloMedioCorredor = _Trajetoria?.AnguloMedioCorredor ?? 0,
|
|
DistanciaTotal = _Trajetoria?.DistanciaTotal ?? 0,
|
|
DistanciaPercorrida = _Trajetoria?.DistanciaPercorrida ?? 0,
|
|
DistanciaRestante = _Trajetoria?.DistanciaRestante ?? 0,
|
|
NaMargemDoCorredor = _Trajetoria?.NaMargemDoCorredor ?? false,
|
|
ManobrandoEntreRuas = _Trajetoria?.ManobrandoEntreRuas ?? false,
|
|
TempoEstimadoRestante = _Trajetoria?.TempoEstimadoRestante ?? "",
|
|
TempoEstimadoOperacao = _Trajetoria?.TempoEstimadoOperacao ?? "",
|
|
ProximoPonto = _Trajetoria?.ProximoPonto?.Clone() ?? new PontoTrajetoriaModel(TipoPontoRua.PosicaoRobo),
|
|
PontoMaisProximo = _Trajetoria?.PontoMaisProximo?.Clone() ?? new PontoTrajetoriaModel(TipoPontoRua.PosicaoRobo),
|
|
PontoAtual = _Trajetoria?.PontoAtual?.Clone() ?? new PontoTrajetoriaModel(TipoPontoRua.PosicaoRobo),
|
|
ErroLateralAngular = _Trajetoria?.ErroLateralAngular ?? 0,
|
|
ErroOrientacaoAngular = _Trajetoria?.ErroOrientacaoAngular ?? 0,
|
|
ErroOrientacaoAngularCombinado = _Trajetoria?.ErroOrientacaoAngularCombinado ?? 0,
|
|
ErroOrientacaoAngularCaminho = _Trajetoria?.ErroOrientacaoAngularCaminho ?? 0,
|
|
ErroOrientacaoAngularProximoPonto = _Trajetoria?.ErroOrientacaoAngularProximoPonto ?? 0
|
|
};
|
|
|
|
var dadosGps = GPSService.UltimaLeitura.Clone();
|
|
|
|
var dadosControle = _Controle.Clone();
|
|
|
|
var dadosPerformance = Variaveis.OperacaoEmAndamento.DadosPerformance.Clone();
|
|
|
|
OperacaoSensoriamentoLogModel dadosAtualizados = new OperacaoSensoriamentoLogModel()
|
|
{
|
|
Momento = DateTime.Now,
|
|
OperacaoLiberada = Variaveis.OperacaoEmAndamento.OperacaoLiberada,
|
|
StatusOperacao = Variaveis.OperacaoEmAndamento.StatusAtual,
|
|
DataInicio = Variaveis.OperacaoEmAndamento.DataInicio,
|
|
DataFim = Variaveis.OperacaoEmAndamento.DataFim,
|
|
TempoDecorridoSeg = Variaveis.OperacaoEmAndamento.TempoDecorridoSegs,
|
|
IMU = dadosIMU,
|
|
Atuador = dadosAtuador,
|
|
Movimentacao = dadosMovimentacao,
|
|
Bateria = dadosBateria,
|
|
Trajetoria = dadosTrajetoria,
|
|
Gps = dadosGps,
|
|
OperadorVisual = new VisualWorkerModel(),
|
|
Controle = dadosControle,
|
|
DadosPerformance = dadosPerformance
|
|
};
|
|
|
|
Variaveis.OperacaoEmAndamento.Sensoriamento = dadosAtualizados;
|
|
Variaveis.OperacaoEmAndamento.DispSen?.Dados?.ContadorCarga?.AtualizarConsumo();
|
|
}
|
|
|
|
public OperacaoSensoriamentoLogModel Clone(bool comSonar = false)
|
|
{
|
|
return new OperacaoSensoriamentoLogModel()
|
|
{
|
|
Momento = Momento,
|
|
CodigoFalha = CodigoFalha,
|
|
OperacaoLiberada = OperacaoLiberada,
|
|
StatusOperacao = StatusOperacao,
|
|
DataInicio = DataInicio,
|
|
DataFim = DataFim,
|
|
TempoDecorridoSeg = TempoDecorridoSeg,
|
|
Atuador = Atuador?.Clone(),
|
|
Movimentacao = Movimentacao?.Clone(),
|
|
Bateria = Bateria?.Clone(),
|
|
Trajetoria = Trajetoria?.Clone(),
|
|
Gps = Gps?.Clone(),
|
|
OperadorVisual = comSonar ? OperadorVisual?.Clone() : null,
|
|
Controle = Controle?.Clone(),
|
|
DadosPerformance = DadosPerformance?.Clone(),
|
|
IMU = IMU?.Clone(),
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OperacaoSensoriamentoLogImuModel
|
|
{
|
|
public bool Iniciado { get; set; }
|
|
public double InclinacaoLateral { get; set; }
|
|
public double InclinacaoFrontal { get; set; }
|
|
public double Rotacao { get; set; }
|
|
public double RotacaoCorrigida { get; set; }
|
|
public double Temperatura { get; set; }
|
|
public double Pressao { get; set; }
|
|
public double Altitude { get; set; }
|
|
|
|
public OperacaoSensoriamentoLogImuModel Clone()
|
|
{
|
|
return new OperacaoSensoriamentoLogImuModel()
|
|
{
|
|
Iniciado = Iniciado,
|
|
InclinacaoLateral = InclinacaoLateral,
|
|
InclinacaoFrontal = InclinacaoFrontal,
|
|
Rotacao = Rotacao,
|
|
RotacaoCorrigida = RotacaoCorrigida,
|
|
Temperatura = Temperatura,
|
|
Pressao = Pressao,
|
|
Altitude = Altitude
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OperacaoSensoriamentoLogAtuModel
|
|
{
|
|
public double HerbicidaConsumido { get; set;}
|
|
public double PercentualErvasTerreno { get; set; }
|
|
public double HerbicidaPorErva { get; set; }
|
|
public int ErvasNoRadar { get; set; }
|
|
public double PercentualReservatorio { get; set; }
|
|
public double VolumeReservatorio { get; set; }
|
|
public double PressaoLinha { get; set; }
|
|
public double VazaoInstantanea { get; set; }
|
|
public double VazaoMedia { get; set; }
|
|
public double LeituraPotenciaBomba { get; set; }
|
|
public double VolumeVazaoMl { get; set; }
|
|
public List<Dictionary<string, int>> ErvasIdentificadas { get; set; }
|
|
public int QtdErvasIdentificadas
|
|
{
|
|
get
|
|
{
|
|
int atuacoes = 0;
|
|
foreach (var bico in ErvasIdentificadas)
|
|
{
|
|
atuacoes += bico.Sum(x => x.Value);
|
|
}
|
|
return atuacoes;
|
|
}
|
|
}
|
|
|
|
public OperacaoSensoriamentoLogAtuModel Clone()
|
|
{
|
|
return new OperacaoSensoriamentoLogAtuModel()
|
|
{
|
|
ErvasIdentificadas = new List<Dictionary<string, int>>(ErvasIdentificadas),
|
|
ErvasNoRadar = ErvasNoRadar,
|
|
HerbicidaConsumido = HerbicidaConsumido,
|
|
HerbicidaPorErva = HerbicidaPorErva,
|
|
PercentualErvasTerreno = PercentualErvasTerreno,
|
|
PercentualReservatorio = PercentualReservatorio,
|
|
VolumeReservatorio = VolumeReservatorio,
|
|
PressaoLinha = PressaoLinha,
|
|
VazaoInstantanea = VazaoInstantanea,
|
|
VazaoMedia = VazaoMedia,
|
|
LeituraPotenciaBomba = LeituraPotenciaBomba,
|
|
VolumeVazaoMl = VolumeVazaoMl
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OperacaoSensoriamentoLogMvdModel
|
|
{
|
|
public double VelocidadeMedia { get; set; }
|
|
public double RPMMedio { get; set; }
|
|
public double TempoMovimentoSegs { get; set; }
|
|
public DateTime TempoMovimento
|
|
{
|
|
get
|
|
{
|
|
return new DateTime().AddSeconds(TempoMovimentoSegs);
|
|
}
|
|
}
|
|
public (bool, List<string>) Dir_Status { get; set; }
|
|
public (bool, List<string>) MovEsq_Status { get; set; }
|
|
public (bool, List<string>) MovDir_Status { get; set; }
|
|
|
|
public OperacaoSensoriamentoLogMvdModel Clone()
|
|
{
|
|
return new OperacaoSensoriamentoLogMvdModel()
|
|
{
|
|
VelocidadeMedia = VelocidadeMedia,
|
|
RPMMedio = RPMMedio,
|
|
TempoMovimentoSegs = TempoMovimentoSegs,
|
|
Dir_Status = Dir_Status,
|
|
MovEsq_Status = MovEsq_Status,
|
|
MovDir_Status = MovDir_Status,
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OperacaoSensoriamentoLogBateriaModel
|
|
{
|
|
public bool Iniciado { get; set; }
|
|
public double _dt { get; set; }
|
|
public double PorcentagemBateria { get; set; }
|
|
public double BateriaConsumida { get; set; }
|
|
public double CorrenteInstantanea { get; set; }
|
|
public double TensaoInstantanea { get; set; }
|
|
public double PotenciaInstantanea { get; set; }
|
|
public double PotenciaAcumulada { get; set; }
|
|
public double TempoEstimadoRestanteMinutos { get; set; }
|
|
|
|
public OperacaoSensoriamentoLogBateriaModel Clone()
|
|
{
|
|
return new OperacaoSensoriamentoLogBateriaModel()
|
|
{
|
|
_dt = _dt,
|
|
BateriaConsumida = BateriaConsumida,
|
|
PorcentagemBateria = PorcentagemBateria,
|
|
CorrenteInstantanea = CorrenteInstantanea,
|
|
TensaoInstantanea = TensaoInstantanea,
|
|
PotenciaInstantanea = PotenciaInstantanea,
|
|
PotenciaAcumulada = PotenciaAcumulada,
|
|
TempoEstimadoRestanteMinutos = TempoEstimadoRestanteMinutos
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OperacaoSensoriamentoLogTrajetoriaModel
|
|
{
|
|
public StatusCarroMapa StatusCarro { get; set; }
|
|
public double ProgressoTrajeto { get; set; }
|
|
public double AnguloCaminho { get; set; }
|
|
public double AnguloMedioCorredor { get; set; }
|
|
public DirecaoCarroRua DirecaoCaminho { get; set; }
|
|
public CorredorTrajetoriaModel CorredorAtual { get; set; }
|
|
public double DistanciaEsquerda { get; set; }
|
|
public double DistanciaDireita { get; set; }
|
|
public double DistanciaTotal { get; set; }
|
|
public double DistanciaPercorrida { get; set; }
|
|
public double DistanciaRestante { get; set; }
|
|
public bool NaMargemDoCorredor { get; set; }
|
|
public bool ManobrandoEntreRuas { get; set; }
|
|
public string TempoEstimadoRestante { get; set; }
|
|
public string TempoEstimadoOperacao { get; set; }
|
|
public PontoTrajetoriaModel ProximoPonto { get; set; }
|
|
public PontoTrajetoriaModel PontoAtual { get; set; }
|
|
public PontoTrajetoriaModel PontoMaisProximo { get; set; }
|
|
|
|
public double ErroOrientacaoAngular { get; set; }
|
|
public double ErroOrientacaoAngularCombinado { get; set; }
|
|
public double ErroOrientacaoAngularCaminho { get; set; }
|
|
public double ErroOrientacaoAngularProximoPonto { get; set; }
|
|
public double ErroLateralAngular { get; set; }
|
|
|
|
public OperacaoSensoriamentoLogTrajetoriaModel Clone()
|
|
{
|
|
return new OperacaoSensoriamentoLogTrajetoriaModel()
|
|
{
|
|
StatusCarro = StatusCarro,
|
|
AnguloCaminho = AnguloCaminho,
|
|
AnguloMedioCorredor = AnguloMedioCorredor,
|
|
DirecaoCaminho = DirecaoCaminho,
|
|
DistanciaDireita = DistanciaDireita,
|
|
DistanciaEsquerda = DistanciaEsquerda,
|
|
CorredorAtual = CorredorAtual.Clone(false),
|
|
ProgressoTrajeto = ProgressoTrajeto,
|
|
DistanciaTotal = DistanciaTotal,
|
|
DistanciaPercorrida = DistanciaPercorrida,
|
|
DistanciaRestante = DistanciaRestante,
|
|
NaMargemDoCorredor = NaMargemDoCorredor,
|
|
ManobrandoEntreRuas = ManobrandoEntreRuas,
|
|
TempoEstimadoRestante = TempoEstimadoRestante,
|
|
TempoEstimadoOperacao = TempoEstimadoOperacao,
|
|
ErroLateralAngular = ErroLateralAngular,
|
|
ErroOrientacaoAngularCombinado = ErroOrientacaoAngularCombinado,
|
|
ErroOrientacaoAngular = ErroOrientacaoAngular,
|
|
ErroOrientacaoAngularCaminho = ErroOrientacaoAngularCaminho,
|
|
ErroOrientacaoAngularProximoPonto = ErroOrientacaoAngularProximoPonto,
|
|
ProximoPonto = ProximoPonto.Clone(),
|
|
PontoAtual = PontoAtual.Clone(),
|
|
PontoMaisProximo = PontoMaisProximo.Clone(),
|
|
};
|
|
}
|
|
}
|
|
|
|
public class PzmSensoriamentoLogModel
|
|
{
|
|
public DateTime Momento { get; set; }
|
|
public DateTime DataHora { get; set; }
|
|
public bool Inicializado { get; set; }
|
|
public double Tensao { get; set; }
|
|
public double Corrente { get; set; }
|
|
public double Potencia { get; set; }
|
|
public double Energia { get; set; }
|
|
public bool AlarmeTensaoMax { get; set; }
|
|
public bool AlarmeTensaoMin { get; set; }
|
|
public double CargaAtualAmp { get; set; }
|
|
public double CargaConsumidaAmp { get; set; }
|
|
public double CargaConsumidaPercentual { get; set; }
|
|
public DateTime UltimoComandoRespondido { get; set; }
|
|
}
|
|
|
|
public class DirSensoriamentoLogModel
|
|
{
|
|
public DateTime Momento { get; set; }
|
|
public string Modulo_ID { get; set; }
|
|
public bool Inicializado { get; set; }
|
|
public bool Controlar { get; set; }
|
|
public double Angulo_SP { get; set; }
|
|
public double Angulo { get; set; }
|
|
public Sentido Sentido_SP { get; set; }
|
|
public Sentido Sentido { get; set; }
|
|
public Sentido SentidoReal { get; set; }
|
|
public double Velocidade { get; set; }
|
|
public DateTime UltimoComandoRespondido { get; set; }
|
|
}
|
|
|
|
public class MovSensoriamentoLogModel
|
|
{
|
|
public DateTime Momento { get; set; }
|
|
public string Modulo_ID { get; set; }
|
|
public bool Inicializado { get; set; }
|
|
public double RPM_SP { get; set; }
|
|
public double RPM_Motor { get; set; }
|
|
public double RPM_Roda { get; set; }
|
|
public double Velocidade { get; set; }
|
|
public Sentido Sentido_SP { get; set; }
|
|
public Sentido Sentido { get; set; }
|
|
public double Temperatura { get; set; }
|
|
public double TemperaturaDriver { get; set; }
|
|
public double Corrente_Motor { get; set; }
|
|
public double Corrente_Barramento { get; set; }
|
|
public double Tensao { get; set; }
|
|
public double Potencia { get; set; }
|
|
public double CicloTrabalho { get; set; }
|
|
public OidCodigoErro CodAlarme { get; set; }
|
|
public bool AlarmeSensores { get; set; }
|
|
public bool AlarmeComando { get; set; }
|
|
public bool EmFreio { get; set; }
|
|
public bool Ativado { get; set; }
|
|
public DateTime UltimoComandoRespondido { get; set; }
|
|
}
|
|
|
|
public class AtuSensoriamentoLogModel
|
|
{
|
|
public DateTime Momento { get; set; }
|
|
public bool Inicializado { get; set; }
|
|
public int QualidadeWifi { get; set; }
|
|
public int LatenciaLoop { get; set; }
|
|
public double MassaReservatorio { get; set; }
|
|
public double PressaoLinha_SP { get; set; }
|
|
public double PressaoLinha { get; set; }
|
|
public double VolumeReservatorio { get; set; }
|
|
public double PercentualReservatorio { get; set; }
|
|
public double PotenciaBomba { get; set; }
|
|
public bool BombaLigada { get; set; }
|
|
public double VazaoFluxoMLpSInstantanea { get; set; }
|
|
public double VazaoFluxoMLpSMedia { get; set; }
|
|
public double VolumeVazaoML { get; set; }
|
|
public int QuantidadeBicos { get; set; }
|
|
public double TempoPulverizadorAtuado { get; set; }
|
|
public List<AtuBicoSensoriamentoLogModel> Bicos { get; set; }
|
|
public DateTime UltimoComandoRespondido { get; set; }
|
|
}
|
|
|
|
public class AtuBicoSensoriamentoLogModel
|
|
{
|
|
public string ID { get; set; }
|
|
public int Posicao { get; set; }
|
|
public bool Atuado { get; set; }
|
|
public bool Comandar { get; set; }
|
|
public bool Inicializado { get; set; }
|
|
public bool StatusBico { get; set; }
|
|
public double MediaNivelFluxo { get; set; }
|
|
public int Atuacoes { get; set; }
|
|
public double TempoAtuado { get; set; }
|
|
}
|
|
|
|
public class CamSoloSensoriamentoLogModel
|
|
{
|
|
public DateTime Momento { get; set; }
|
|
public CameraCoordenadasFrameModel Leitura { get; set; }
|
|
}
|
|
|
|
public class CamCaminhoSensoriamentoLogModel
|
|
{
|
|
public DateTime Momento { get; set; }
|
|
public Dictionary<string, Color> ClassMap { get; set; }
|
|
public List<System.Drawing.Point> PontosExtremos { get; set; }
|
|
public double Angulo { get; set; }
|
|
public double AnguloEsquerdo { get; set; }
|
|
public double AnguloDireito { get; set; }
|
|
public CameraDeepLabV3PlusModel Leitura { get; set; }
|
|
public bool Inicializado
|
|
{
|
|
get
|
|
{
|
|
return Leitura?.device_data?.Is_Pipeline_Running ?? false;
|
|
}
|
|
}
|
|
public DateTime UltimaMensagemRecebida { get; set; }
|
|
}
|
|
|
|
}
|