refinado regras para liberacao da operacao
This commit is contained in:
parent
58162c62f9
commit
f85e1dc915
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -211,7 +211,7 @@ namespace AgroBase.Forms.IHM
|
||||||
txtDF.Text = (ModDF?.MovMotor?.Corrente_Motor ?? 0).ToString("0.00");
|
txtDF.Text = (ModDF?.MovMotor?.Corrente_Motor ?? 0).ToString("0.00");
|
||||||
lblDF.ForeColor = (ModDF?.Conectado ?? false) ? Color.Green : Color.Red;
|
lblDF.ForeColor = (ModDF?.Conectado ?? false) ? Color.Green : Color.Red;
|
||||||
|
|
||||||
if (frmInstancial.DebugMode)
|
if (!Variaveis.Producao)
|
||||||
{
|
{
|
||||||
AtualizarMapaDinamico();
|
AtualizarMapaDinamico();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace AgroBase.Forms.IHM
|
||||||
);
|
);
|
||||||
if (res == DialogResult.Yes)
|
if (res == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
if (frmInstancial.DebugMode)
|
if (!Variaveis.Producao)
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,6 @@ namespace AgroBase.Forms
|
||||||
{
|
{
|
||||||
public partial class frmInstancial : Form
|
public partial class frmInstancial : Form
|
||||||
{
|
{
|
||||||
public static bool DebugMode = true;
|
|
||||||
public static bool Fechando = false;
|
|
||||||
|
|
||||||
public static AsyncTaskTimerModel tmrVarreduraDispositivos;
|
public static AsyncTaskTimerModel tmrVarreduraDispositivos;
|
||||||
|
|
||||||
public static frmPrincipal frmPrincipal = new frmPrincipal();
|
public static frmPrincipal frmPrincipal = new frmPrincipal();
|
||||||
|
|
@ -45,7 +42,7 @@ namespace AgroBase.Forms
|
||||||
|
|
||||||
private void frmInstancial_Shown(object sender, EventArgs e)
|
private void frmInstancial_Shown(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (DebugMode)
|
if (!Variaveis.Producao)
|
||||||
{
|
{
|
||||||
frmIHM.FormClosing += FrmIHM_FormClosing;
|
frmIHM.FormClosing += FrmIHM_FormClosing;
|
||||||
frmPrincipal.FormClosing += frmPrincipal_FormClosing;
|
frmPrincipal.FormClosing += frmPrincipal_FormClosing;
|
||||||
|
|
@ -68,7 +65,7 @@ namespace AgroBase.Forms
|
||||||
IniciarConexaoMqtt();
|
IniciarConexaoMqtt();
|
||||||
|
|
||||||
Control control = new Control();
|
Control control = new Control();
|
||||||
if (DebugMode)
|
if (!Variaveis.Producao)
|
||||||
{
|
{
|
||||||
control = frmPrincipal;
|
control = frmPrincipal;
|
||||||
}
|
}
|
||||||
|
|
@ -93,9 +90,9 @@ namespace AgroBase.Forms
|
||||||
|
|
||||||
public static async Task EncerrarProcessos()
|
public static async Task EncerrarProcessos()
|
||||||
{
|
{
|
||||||
Fechando = true;
|
Variaveis.Fechando = true;
|
||||||
|
|
||||||
EthernetService.ConfigurarIP(false, false);
|
await EthernetService.ConfigurarIP(false, false);
|
||||||
|
|
||||||
AsyncTaskTimerModel.PararTimers();
|
AsyncTaskTimerModel.PararTimers();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ namespace AgroBase
|
||||||
this.btnContornos = new System.Windows.Forms.Button();
|
this.btnContornos = new System.Windows.Forms.Button();
|
||||||
this.btnAtuCalibragem = new System.Windows.Forms.Button();
|
this.btnAtuCalibragem = new System.Windows.Forms.Button();
|
||||||
this.gpbOperacao = new System.Windows.Forms.GroupBox();
|
this.gpbOperacao = new System.Windows.Forms.GroupBox();
|
||||||
|
this.chbWifi = new System.Windows.Forms.CheckBox();
|
||||||
this.btnIHM = new System.Windows.Forms.Button();
|
this.btnIHM = new System.Windows.Forms.Button();
|
||||||
this.btnConfigurarOperacao = new System.Windows.Forms.Button();
|
this.btnConfigurarOperacao = new System.Windows.Forms.Button();
|
||||||
this.chbDebugMode = new System.Windows.Forms.CheckBox();
|
this.chbDebugMode = new System.Windows.Forms.CheckBox();
|
||||||
|
|
@ -827,6 +828,7 @@ namespace AgroBase
|
||||||
//
|
//
|
||||||
// gpbOperacao
|
// gpbOperacao
|
||||||
//
|
//
|
||||||
|
this.gpbOperacao.Controls.Add(this.chbWifi);
|
||||||
this.gpbOperacao.Controls.Add(this.btnIHM);
|
this.gpbOperacao.Controls.Add(this.btnIHM);
|
||||||
this.gpbOperacao.Controls.Add(this.btnConfigurarOperacao);
|
this.gpbOperacao.Controls.Add(this.btnConfigurarOperacao);
|
||||||
this.gpbOperacao.Controls.Add(this.chbDebugMode);
|
this.gpbOperacao.Controls.Add(this.chbDebugMode);
|
||||||
|
|
@ -842,6 +844,17 @@ namespace AgroBase
|
||||||
this.gpbOperacao.TabStop = false;
|
this.gpbOperacao.TabStop = false;
|
||||||
this.gpbOperacao.Text = "Operação";
|
this.gpbOperacao.Text = "Operação";
|
||||||
//
|
//
|
||||||
|
// chbWifi
|
||||||
|
//
|
||||||
|
this.chbWifi.AutoSize = true;
|
||||||
|
this.chbWifi.Location = new System.Drawing.Point(296, 35);
|
||||||
|
this.chbWifi.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.chbWifi.Name = "chbWifi";
|
||||||
|
this.chbWifi.Size = new System.Drawing.Size(148, 17);
|
||||||
|
this.chbWifi.TabIndex = 17;
|
||||||
|
this.chbWifi.Text = "Conexão WiFi Automática";
|
||||||
|
this.chbWifi.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// btnIHM
|
// btnIHM
|
||||||
//
|
//
|
||||||
this.btnIHM.Location = new System.Drawing.Point(296, 58);
|
this.btnIHM.Location = new System.Drawing.Point(296, 58);
|
||||||
|
|
@ -855,7 +868,7 @@ namespace AgroBase
|
||||||
//
|
//
|
||||||
// btnConfigurarOperacao
|
// btnConfigurarOperacao
|
||||||
//
|
//
|
||||||
this.btnConfigurarOperacao.Location = new System.Drawing.Point(121, 58);
|
this.btnConfigurarOperacao.Location = new System.Drawing.Point(134, 58);
|
||||||
this.btnConfigurarOperacao.Margin = new System.Windows.Forms.Padding(2);
|
this.btnConfigurarOperacao.Margin = new System.Windows.Forms.Padding(2);
|
||||||
this.btnConfigurarOperacao.Name = "btnConfigurarOperacao";
|
this.btnConfigurarOperacao.Name = "btnConfigurarOperacao";
|
||||||
this.btnConfigurarOperacao.Size = new System.Drawing.Size(122, 33);
|
this.btnConfigurarOperacao.Size = new System.Drawing.Size(122, 33);
|
||||||
|
|
@ -1091,6 +1104,7 @@ namespace AgroBase
|
||||||
private System.Windows.Forms.TextBox txtCodErro;
|
private System.Windows.Forms.TextBox txtCodErro;
|
||||||
private System.Windows.Forms.Button btnOID;
|
private System.Windows.Forms.Button btnOID;
|
||||||
private System.Windows.Forms.Button btnTreinamentoIA;
|
private System.Windows.Forms.Button btnTreinamentoIA;
|
||||||
|
public System.Windows.Forms.CheckBox chbWifi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,9 @@ namespace AgroBase
|
||||||
bool opLiberada = Variaveis.OperacaoEmAndamento.OperacaoLiberada;
|
bool opLiberada = Variaveis.OperacaoEmAndamento.OperacaoLiberada;
|
||||||
lblStripOperacaoLiberada.Text = "Operação Liberada: " + (opLiberada ? "Sim" : "Não");
|
lblStripOperacaoLiberada.Text = "Operação Liberada: " + (opLiberada ? "Sim" : "Não");
|
||||||
lblStripOperacaoLiberada.ForeColor = opLiberada ? Color.Green : Color.Red;
|
lblStripOperacaoLiberada.ForeColor = opLiberada ? Color.Green : Color.Red;
|
||||||
|
|
||||||
|
Variaveis.DebugMode = chbDebugMode.Checked;
|
||||||
|
Variaveis.ForcarWifi = chbWifi.Checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AtualizaDadosGerais()
|
public void AtualizaDadosGerais()
|
||||||
|
|
@ -513,7 +516,5 @@ namespace AgroBase
|
||||||
MessageBox.Show(desc);
|
MessageBox.Show(desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,23 +28,28 @@ namespace AgroBase.Models
|
||||||
|
|
||||||
public void btnCarregar_Click(object sender, EventArgs e, string caminhoArquivo = "", bool monitoramento = false)
|
public void btnCarregar_Click(object sender, EventArgs e, string caminhoArquivo = "", bool monitoramento = false)
|
||||||
{
|
{
|
||||||
var opcoes = Enum.GetValues(typeof(TipoMapaOperacao))
|
TipoMapaOperacao? _tipoMapa = TipoMapaOperacao.Indefinido;
|
||||||
|
|
||||||
|
if (!monitoramento && string.IsNullOrEmpty(caminhoArquivo))
|
||||||
|
{
|
||||||
|
var opcoes = Enum.GetValues(typeof(TipoMapaOperacao))
|
||||||
.Cast<TipoMapaOperacao>()
|
.Cast<TipoMapaOperacao>()
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
valor => (valor.ToString(), (TipoMapaOperacao?)valor),
|
valor => (valor.ToString(), (TipoMapaOperacao?)valor),
|
||||||
valor => (Action)null
|
valor => (Action)null
|
||||||
);
|
);
|
||||||
|
|
||||||
var tipoMapa = CustomDialog.ShowDialog(
|
_tipoMapa = CustomDialog.ShowDialog(
|
||||||
"Tipo de Mapa",
|
"Tipo de Mapa",
|
||||||
"Qual o tipo de mapa está sendo carregado?",
|
"Qual o tipo de mapa está sendo carregado?",
|
||||||
MessageBoxIcon.Question,
|
MessageBoxIcon.Question,
|
||||||
opcoes
|
opcoes
|
||||||
);
|
);
|
||||||
|
|
||||||
if (tipoMapa == null)
|
if (_tipoMapa == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mapaService.Carregado = false;
|
mapaService.Carregado = false;
|
||||||
|
|
@ -69,7 +74,7 @@ namespace AgroBase.Models
|
||||||
pnlMapa.Controls.Add(picLoading);
|
pnlMapa.Controls.Add(picLoading);
|
||||||
}
|
}
|
||||||
|
|
||||||
TipoMapa = tipoMapa.Value;
|
TipoMapa = _tipoMapa.Value;
|
||||||
|
|
||||||
tmrCarregamento?.Dispose();
|
tmrCarregamento?.Dispose();
|
||||||
tmrCarregamento = new AsyncTaskTimerModel("tmrCarregamento", tmrCarregamento_Tick, 500, pnlMapa);
|
tmrCarregamento = new AsyncTaskTimerModel("tmrCarregamento", tmrCarregamento_Tick, 500, pnlMapa);
|
||||||
|
|
|
||||||
|
|
@ -556,6 +556,11 @@ namespace AgroBase.Models.Modules
|
||||||
|
|
||||||
public async Task tmrRegistrador_Tick()
|
public async Task tmrRegistrador_Tick()
|
||||||
{
|
{
|
||||||
|
if (Variaveis.Fechando)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Variaveis.OperacaoEmAndamento?.DispAtu != null)
|
if (Variaveis.OperacaoEmAndamento?.DispAtu != null)
|
||||||
{
|
{
|
||||||
await Variaveis.OperacaoEmAndamento.DispAtu.GerenciarMqttTopicos();
|
await Variaveis.OperacaoEmAndamento.DispAtu.GerenciarMqttTopicos();
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,15 @@ namespace AgroBase.Models.Modules
|
||||||
.Where(Mod =>
|
.Where(Mod =>
|
||||||
!Mod.MovMotor.Inicializado ||
|
!Mod.MovMotor.Inicializado ||
|
||||||
Mod.MovMotor.CodigoAlarme != 0 ||
|
Mod.MovMotor.CodigoAlarme != 0 ||
|
||||||
Mod.MovMotor.AlarmeSensores
|
Mod.MovMotor.AlarmeSensores ||
|
||||||
|
(Mod.MovMotor.ComandoLigado && !Mod.MovMotor.LeituraLigado && Mod.MovMotor.Sentido != Sentido.Parado)
|
||||||
)
|
)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
bool _operante = ModsComFalha.Count() < Mods.Count();
|
int total = Mods.Count;
|
||||||
|
int falhas = ModsComFalha.Count;
|
||||||
|
bool _operante = falhas < total;
|
||||||
|
|
||||||
List<string> ModsInoperantes = ModsComFalha.Select(x => x.Modulo_ID).ToList();
|
List<string> ModsInoperantes = ModsComFalha.Select(x => x.Modulo_ID).ToList();
|
||||||
|
|
||||||
return (_operante, ModsInoperantes);
|
return (_operante, ModsInoperantes);
|
||||||
|
|
@ -263,6 +267,11 @@ namespace AgroBase.Models.Modules
|
||||||
|
|
||||||
private async Task tmrRegistradorMOV_Tick()
|
private async Task tmrRegistradorMOV_Tick()
|
||||||
{
|
{
|
||||||
|
if (Variaveis.Fechando)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!OIDService.Iniciado && SerialService.DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Mov))
|
if (!OIDService.Iniciado && SerialService.DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Mov))
|
||||||
{
|
{
|
||||||
await OIDService.InicializarEthernetService();
|
await OIDService.InicializarEthernetService();
|
||||||
|
|
@ -314,6 +323,11 @@ namespace AgroBase.Models.Modules
|
||||||
|
|
||||||
private async Task tmrRegistradorDIR_Tick()
|
private async Task tmrRegistradorDIR_Tick()
|
||||||
{
|
{
|
||||||
|
if (Variaveis.Fechando)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!MKS057DService.Iniciado && SerialService.DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Mks))
|
if (!MKS057DService.Iniciado && SerialService.DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Mks))
|
||||||
{
|
{
|
||||||
await MKS057DService.InicializarEthernetService();
|
await MKS057DService.InicializarEthernetService();
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace AgroBase.Models.Modules
|
||||||
return _MensagemConexaoRecebida;
|
return _MensagemConexaoRecebida;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int _TaxaAmostragem { get; set; } = 1000;
|
public static int _TaxaAmostragem { get; set; } = 500;
|
||||||
public static int PingsConsiderarConexao { get; set; } = 5;
|
public static int PingsConsiderarConexao { get; set; } = 5;
|
||||||
public static int TempoLimiteConexao
|
public static int TempoLimiteConexao
|
||||||
{
|
{
|
||||||
|
|
@ -730,6 +730,11 @@ namespace AgroBase.Models.Modules
|
||||||
|
|
||||||
public async Task tmrRegistrador_Tick()
|
public async Task tmrRegistrador_Tick()
|
||||||
{
|
{
|
||||||
|
if (Variaveis.Fechando)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Variaveis.OperacaoEmAndamento?.DispSen != null)
|
if (Variaveis.OperacaoEmAndamento?.DispSen != null)
|
||||||
{
|
{
|
||||||
await Variaveis.OperacaoEmAndamento.DispSen.GerenciarMqttTopicos();
|
await Variaveis.OperacaoEmAndamento.DispSen.GerenciarMqttTopicos();
|
||||||
|
|
|
||||||
|
|
@ -134,113 +134,111 @@ namespace AgroBase.Models
|
||||||
|
|
||||||
StatusAtual = etapaAtual;
|
StatusAtual = etapaAtual;
|
||||||
}
|
}
|
||||||
public (bool, List<T_Code>) ModulosConectados
|
public (bool, List<T_Code>) ModulosConectados { get; private set; }
|
||||||
|
public void AtualizarModulosConectados()
|
||||||
{
|
{
|
||||||
get
|
Variaveis.OperacaoEmAndamento.ModulosMandatorios.ForEach(Modulo =>
|
||||||
{
|
{
|
||||||
Variaveis.OperacaoEmAndamento.ModulosMandatorios.ForEach(Modulo =>
|
Modulo.Conectado = SerialService.DispositivosMapeados.Any(x => x.Dispositivo == Modulo.Dispositivo && x.Conectado);
|
||||||
{
|
});
|
||||||
Modulo.Conectado = SerialService.DispositivosMapeados.Any(x => x.Dispositivo == Modulo.Dispositivo && x.Conectado);
|
|
||||||
});
|
|
||||||
|
|
||||||
bool _modulosConectados =
|
List<T_Code> _modsComFalha = Variaveis.OperacaoEmAndamento.ModulosMandatorios.Where(x => x.Mandatorio && !x.Conectado).Select(x => x.Dispositivo).ToList();
|
||||||
(Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Mandatorio) && Variaveis.OperacaoEmAndamento.ModulosMandatorios.Where(x => x.Mandatorio).All(x => x.Conectado)) ||
|
|
||||||
(Variaveis.OperacaoEmAndamento.ModulosMandatorios.All(x => !x.Mandatorio) && Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Conectado));
|
|
||||||
|
|
||||||
List<T_Code> _modsComFalha = Variaveis.OperacaoEmAndamento.ModulosMandatorios.Where(x => x.Mandatorio && !x.Conectado).Select(x => x.Dispositivo).ToList();
|
ModulosConectados = (!_modsComFalha.Any(), _modsComFalha);
|
||||||
|
|
||||||
return (_modulosConectados, _modsComFalha);
|
ErroOperacaoLiberada = GerarMensagemErroModulos();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public bool DispositivosIndividuaisConectados
|
public bool DispositivosIndividuaisConectados { get; private set; }
|
||||||
|
public void AtualizarDispositiviosIndividuaisConectados()
|
||||||
{
|
{
|
||||||
get
|
// Verificação dos componentes MOV
|
||||||
|
if (Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Mov && x.Conectado))
|
||||||
{
|
{
|
||||||
bool _dispositivosConectados = true;
|
(bool _EsqOperante, List<string> _EsqModsInoperantes) = Variaveis.OperacaoEmAndamento.DispMvd.Dados.StatusModulosMOV(Direcao.Esquerda);
|
||||||
|
(bool _DirOperante, List<string> _DirModsInoperantes) = Variaveis.OperacaoEmAndamento.DispMvd.Dados.StatusModulosMOV(Direcao.Direita);
|
||||||
|
|
||||||
// Verificação dos motores BLDC
|
// Se qualquer lado estiver completamente inoperante, o robô não pode operar corretamente
|
||||||
if (Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Mov && x.Conectado))
|
if (!_EsqOperante || !_DirOperante)
|
||||||
{
|
{
|
||||||
(bool _EsqOperante, List<string> _EsqModsInoperantes) = Variaveis.OperacaoEmAndamento.DispMvd.Dados.StatusModulosMOV(Direcao.Esquerda);
|
DispositivosIndividuaisConectados = false;
|
||||||
(bool _DirOperante, List<string> _DirModsInoperantes) = Variaveis.OperacaoEmAndamento.DispMvd.Dados.StatusModulosMOV(Direcao.Direita);
|
return;
|
||||||
|
|
||||||
// Se qualquer lado estiver completamente inoperante, o robô não pode operar corretamente
|
|
||||||
if (!_EsqOperante || !_DirOperante)
|
|
||||||
{
|
|
||||||
_dispositivosConectados = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificação dos motores MKS
|
|
||||||
if (Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Dir && x.Conectado))
|
|
||||||
{
|
|
||||||
(bool _MksOperante, List<string> _MksModsInoperantes) = Variaveis.OperacaoEmAndamento.DispMvd.Dados.StatusModulosDIR(Variaveis.OperacaoEmAndamento.Controle.TipoMovimento);
|
|
||||||
|
|
||||||
if (!_MksOperante)
|
|
||||||
{
|
|
||||||
_dispositivosConectados = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verificação dos componentes ATU
|
|
||||||
if (Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Atu && x.Conectado))
|
|
||||||
{
|
|
||||||
(bool _AtuOperante, List<string> _AtuModsInoperantes) = Variaveis.OperacaoEmAndamento.DispAtu.Dados.StatusModulosATU();
|
|
||||||
|
|
||||||
if (!_AtuOperante)
|
|
||||||
{
|
|
||||||
_dispositivosConectados = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verificação dos componentes SEN
|
|
||||||
if (Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Sen && x.Conectado))
|
|
||||||
{
|
|
||||||
(bool _SenOperante, List<string> _SenModsInoperantes) = Variaveis.OperacaoEmAndamento.DispSen.Dados.StatusModulosSEN();
|
|
||||||
|
|
||||||
if (!_SenOperante)
|
|
||||||
{
|
|
||||||
_dispositivosConectados = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _dispositivosConectados;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verificação dos componentes DIR
|
||||||
|
if (Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Dir && x.Conectado))
|
||||||
|
{
|
||||||
|
(bool _MksOperante, List<string> _MksModsInoperantes) = Variaveis.OperacaoEmAndamento.DispMvd.Dados.StatusModulosDIR(Variaveis.OperacaoEmAndamento.Controle.TipoMovimento);
|
||||||
|
|
||||||
|
if (!_MksOperante)
|
||||||
|
{
|
||||||
|
DispositivosIndividuaisConectados = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verificação dos componentes ATU
|
||||||
|
if (Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Atu && x.Conectado))
|
||||||
|
{
|
||||||
|
(bool _AtuOperante, List<string> _AtuModsInoperantes) = Variaveis.OperacaoEmAndamento.DispAtu.Dados.StatusModulosATU();
|
||||||
|
|
||||||
|
if (!_AtuOperante)
|
||||||
|
{
|
||||||
|
DispositivosIndividuaisConectados = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verificação dos componentes SEN
|
||||||
|
if (Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Sen && x.Conectado))
|
||||||
|
{
|
||||||
|
(bool _SenOperante, List<string> _SenModsInoperantes) = Variaveis.OperacaoEmAndamento.DispSen.Dados.StatusModulosSEN();
|
||||||
|
|
||||||
|
if (!_SenOperante)
|
||||||
|
{
|
||||||
|
DispositivosIndividuaisConectados = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DispositivosIndividuaisConectados = true;
|
||||||
}
|
}
|
||||||
public bool Emergencia { get; set; } = false;
|
public bool Emergencia { get; set; } = false;
|
||||||
public bool OperacaoLiberada
|
public bool OperacaoLiberada { get; private set; }
|
||||||
|
public void AtualizarOperacaoLiberada()
|
||||||
{
|
{
|
||||||
get
|
(bool _modsConectados, List<T_Code> _modsComFalha) = Variaveis.OperacaoEmAndamento.ModulosConectados;
|
||||||
|
|
||||||
|
bool _operacaoLiberada = _modsConectados;
|
||||||
|
|
||||||
|
if (_operacaoLiberada)
|
||||||
{
|
{
|
||||||
(bool _modsConectados, List<T_Code> _modsComFalha) = Variaveis.OperacaoEmAndamento.ModulosConectados;
|
var parametrosMandatorios = Variaveis.OperacaoEmAndamento.ParametrosMandatorios;
|
||||||
|
if (parametrosMandatorios.Any(x => x.Mandatorio && x.Parametro == ParametrosOperacao.CameraSolo) && Variaveis.OperacaoEmAndamento.CamerasSolo.Count(x => x.Iniciada) < Variaveis.OperacaoEmAndamento.QuantidadeCamerasSolo) _operacaoLiberada = false;
|
||||||
bool _operacaoLiberada = _modsConectados;
|
if (parametrosMandatorios.Any(x => x.Mandatorio && x.Parametro == ParametrosOperacao.Kinect) && (!KinectService.Iniciado || KinectService.Leitura == null)) _operacaoLiberada = false;
|
||||||
|
if (parametrosMandatorios.Any(x => x.Mandatorio && x.Parametro == ParametrosOperacao.Mapa) && !Variaveis.OperacaoEmAndamento.Mapa.mapaService.Carregado) _operacaoLiberada = false;
|
||||||
if (_operacaoLiberada && Variaveis.OperacaoEmAndamento.ParametrosMandatorios.Any(x => x.Parametro == ParametrosOperacao.CameraSolo && x.Mandatorio) && Variaveis.OperacaoEmAndamento.CamerasSolo.Count(x => x.Iniciada) < Variaveis.OperacaoEmAndamento.QuantidadeCamerasSolo) _operacaoLiberada = false;
|
if (parametrosMandatorios.Any(x => x.Mandatorio && x.Parametro == ParametrosOperacao.Joystick) && GeneralJoystick.JoystickConectado == null) _operacaoLiberada = false;
|
||||||
if (_operacaoLiberada && Variaveis.OperacaoEmAndamento.ParametrosMandatorios.Any(x => x.Parametro == ParametrosOperacao.Kinect && x.Mandatorio) && (!KinectService.Iniciado || KinectService.Leitura == null)) _operacaoLiberada = false;
|
if (!Variaveis.OperacaoEmAndamento.DispositivosIndividuaisConectados) _operacaoLiberada = false;
|
||||||
if (_operacaoLiberada && Variaveis.OperacaoEmAndamento.ParametrosMandatorios.Any(x => x.Parametro == ParametrosOperacao.Mapa && x.Mandatorio) && !Variaveis.OperacaoEmAndamento.Mapa.mapaService.Carregado) _operacaoLiberada = false;
|
|
||||||
if (_operacaoLiberada && Variaveis.OperacaoEmAndamento.ParametrosMandatorios.Any(x => x.Parametro == ParametrosOperacao.Joystick && x.Mandatorio && GeneralJoystick.JoystickConectado == null)) _operacaoLiberada = false;
|
|
||||||
if (_operacaoLiberada && !Variaveis.OperacaoEmAndamento.DispositivosIndividuaisConectados) _operacaoLiberada = false;
|
|
||||||
|
|
||||||
if (frmInstancial.frmPrincipal.chbDebugMode.Checked) _operacaoLiberada = true;
|
|
||||||
|
|
||||||
if (Variaveis.OperacaoEmAndamento.Emergencia) _operacaoLiberada = false;
|
|
||||||
|
|
||||||
return _operacaoLiberada;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Variaveis.DebugMode) _operacaoLiberada = true;
|
||||||
|
|
||||||
|
if (Variaveis.OperacaoEmAndamento.Emergencia) _operacaoLiberada = false;
|
||||||
|
|
||||||
|
OperacaoLiberada = _operacaoLiberada;
|
||||||
}
|
}
|
||||||
public string ErroOperacaoLiberada
|
public string ErroOperacaoLiberada { get; private set; }
|
||||||
|
private string GerarMensagemErroModulos()
|
||||||
{
|
{
|
||||||
get
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine($"Para iniciar a operação {Modo}, é necessário que todos os módulos mandatórios estejam devidamente conectados ao equipamento, ou pelo menos um dos módulos:");
|
||||||
|
|
||||||
|
ModulosMandatorios.ForEach(mod =>
|
||||||
{
|
{
|
||||||
string MensagemErro = "Para iniciar a operação " + Enum.GetName(typeof(ModoOperacao), Modo) +
|
sb.AppendLine($"{mod.Dispositivo,-20}: ( {(mod.Conectado ? "OK" : " ")} ) - Mandatório: {(mod.Mandatorio ? "Sim" : "Não")}");
|
||||||
", é necessário que todos os módulos mandatórios estejam devidamente conectados ao equipamento, ou pelo menos um dos módulos:\r\n";
|
});
|
||||||
ModulosMandatorios.ForEach(Modulo =>
|
|
||||||
{
|
return sb.ToString();
|
||||||
MensagemErro += Enum.GetName(typeof(T_Code), Modulo.Dispositivo) + ": ( " + (Modulo.Conectado ? "OK" : " ") + " ) - Mandatório: " + (Modulo.Mandatorio ? "Sim" : "Não") + "\r\n";
|
|
||||||
});
|
|
||||||
return MensagemErro;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public bool Iniciado { get; set; }
|
public bool Iniciado { get; set; }
|
||||||
public bool Simulando { get; set; } = false;
|
public bool Simulando { get; set; } = false;
|
||||||
|
|
@ -797,6 +795,17 @@ namespace AgroBase.Models
|
||||||
GPSTrajetoria = new List<GPSModel>();
|
GPSTrajetoria = new List<GPSModel>();
|
||||||
|
|
||||||
await RealizarCalibragemInicialAsync();
|
await RealizarCalibragemInicialAsync();
|
||||||
|
|
||||||
|
if (Modo == ModoOperacao.Manual)
|
||||||
|
{
|
||||||
|
await Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(3000);
|
||||||
|
|
||||||
|
Controle.Angulo = 25;
|
||||||
|
Controle.PercentualVelocidadeSP = 25;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinalizarOperacao()
|
public void FinalizarOperacao()
|
||||||
|
|
@ -1671,7 +1680,7 @@ namespace AgroBase.Models
|
||||||
bool atualizandoGrafico = false;
|
bool atualizandoGrafico = false;
|
||||||
private void AtualizarGrafico()
|
private void AtualizarGrafico()
|
||||||
{
|
{
|
||||||
if (atualizandoGrafico || !frmInstancial.DebugMode)
|
if (atualizandoGrafico || !Variaveis.DebugMode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2980,6 +2989,10 @@ namespace AgroBase.Models
|
||||||
var _DispAtu = Variaveis.OperacaoEmAndamento.DispAtu;
|
var _DispAtu = Variaveis.OperacaoEmAndamento.DispAtu;
|
||||||
var _Controle = Variaveis.OperacaoEmAndamento.Controle;
|
var _Controle = Variaveis.OperacaoEmAndamento.Controle;
|
||||||
|
|
||||||
|
Variaveis.OperacaoEmAndamento.AtualizarDispositiviosIndividuaisConectados();
|
||||||
|
Variaveis.OperacaoEmAndamento.AtualizarModulosConectados();
|
||||||
|
Variaveis.OperacaoEmAndamento.AtualizarOperacaoLiberada();
|
||||||
|
|
||||||
Variaveis.OperacaoEmAndamento.AtualizarStatusAtual();
|
Variaveis.OperacaoEmAndamento.AtualizarStatusAtual();
|
||||||
|
|
||||||
Variaveis.OperacaoEmAndamento.DadosPerformance.AtualizarDadosPerformance();
|
Variaveis.OperacaoEmAndamento.DadosPerformance.AtualizarDadosPerformance();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,11 @@ namespace AgroBase.Models
|
||||||
{
|
{
|
||||||
public class Variaveis
|
public class Variaveis
|
||||||
{
|
{
|
||||||
|
public static bool Producao { get; set; } = false;
|
||||||
|
public static bool DebugMode { get; set; } = true;
|
||||||
|
public static bool ForcarWifi { get; set; } = false;
|
||||||
|
public static bool Fechando { get; set; } = false;
|
||||||
|
|
||||||
public static string CaminhoSistema { get; set; } = AppDomain.CurrentDomain.BaseDirectory;
|
public static string CaminhoSistema { get; set; } = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
public static string NomeAplicacao
|
public static string NomeAplicacao
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace AgroBase.Services
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return frmInstancial.DebugMode ? "http://localhost:1337/agrobase/" : "https://zendioninc.com.br/api/agrobase/";
|
return !Variaveis.Producao ? "http://localhost:1337/agrobase/" : "https://zendioninc.com.br/api/agrobase/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static string UrlDownloadArquivos
|
private static string UrlDownloadArquivos
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ public class EthernetService
|
||||||
return "Nenhuma interface de rede ativa encontrada";
|
return "Nenhuma interface de rede ativa encontrada";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task DefinirIpDinamico(string interfaceName, bool response)
|
public static async Task<bool> DefinirIpDinamico(string interfaceName, bool response)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -466,6 +466,8 @@ public class EthernetService
|
||||||
{
|
{
|
||||||
MessageBox.Show("IP dinamico definido com sucesso!", "Configuração de IP", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("IP dinamico definido com sucesso!", "Configuração de IP", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -473,10 +475,12 @@ public class EthernetService
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Erro ao definir IP dinamico: {ex.Message}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show($"Erro ao definir IP dinamico: {ex.Message}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task DefinirIpFixo(string nomeInterface, string ipAddress, string subnetMask, string gateway, bool response)
|
public static async Task<bool> DefinirIpFixo(string nomeInterface, string ipAddress, string subnetMask, string gateway, bool response)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -492,6 +496,8 @@ public class EthernetService
|
||||||
{
|
{
|
||||||
MessageBox.Show("IP fixo definido com sucesso!", "Configuração de IP", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("IP fixo definido com sucesso!", "Configuração de IP", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -499,6 +505,8 @@ public class EthernetService
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Erro ao definir IP fixo: {ex.Message}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show($"Erro ao definir IP fixo: {ex.Message}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -566,8 +574,10 @@ public class EthernetService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConfigurarIP(bool fixo, bool response)
|
public static async Task<bool> ConfigurarIP(bool fixo, bool response)
|
||||||
{
|
{
|
||||||
|
bool sucesso = false;
|
||||||
|
|
||||||
var interfaces = ObterNomesInterfaces();
|
var interfaces = ObterNomesInterfaces();
|
||||||
|
|
||||||
string _Interface = interfaces.FirstOrDefault(x => x.ToLower().Contains("wi-fi") && x.ToLower().Contains("ativa"));
|
string _Interface = interfaces.FirstOrDefault(x => x.ToLower().Contains("wi-fi") && x.ToLower().Contains("ativa"));
|
||||||
|
|
@ -579,18 +589,17 @@ public class EthernetService
|
||||||
string ip = Variaveis.IP_Host;
|
string ip = Variaveis.IP_Host;
|
||||||
string submask = ObterSubnetMaskAtual(_Interface);
|
string submask = ObterSubnetMaskAtual(_Interface);
|
||||||
|
|
||||||
Task.Run(async () =>
|
if (fixo)
|
||||||
{
|
{
|
||||||
if (fixo)
|
sucesso = await DefinirIpFixo(_Interface, ip, submask, gateway, response);
|
||||||
{
|
}
|
||||||
await DefinirIpFixo(_Interface, ip, submask, gateway, response);
|
else
|
||||||
}
|
{
|
||||||
else
|
sucesso = await DefinirIpDinamico(_Interface, response);
|
||||||
{
|
}
|
||||||
await DefinirIpDinamico(_Interface, response);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return sucesso;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ namespace AgroBase.Services
|
||||||
|
|
||||||
private static async Task tmrLoopComandos_Tick()
|
private static async Task tmrLoopComandos_Tick()
|
||||||
{
|
{
|
||||||
if (EnvioLiberado && !Verificando && !frmInstancial.Fechando)
|
if (EnvioLiberado && !Verificando && !Variaveis.Fechando)
|
||||||
{
|
{
|
||||||
EnvioLiberado = false;
|
EnvioLiberado = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ namespace AgroBase.Services
|
||||||
|
|
||||||
public static async Task RealizarVarreduraPortasUSB()
|
public static async Task RealizarVarreduraPortasUSB()
|
||||||
{
|
{
|
||||||
if (VarreduraEmAndamento || frmInstancial.Fechando)
|
if (VarreduraEmAndamento || Variaveis.Fechando)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace AgroBase.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nao executa a verificacao se estiver em ambiente de teste
|
// Nao executa a verificacao se estiver em ambiente de teste
|
||||||
if (frmInstancial.DebugMode && !frmInstancial.frmPrincipal.chbDebugMode.Checked)
|
if (!Variaveis.Producao)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -357,7 +357,7 @@ namespace AgroBase.Services
|
||||||
ResultadoAtualizacao = "Arquivos carregados!";
|
ResultadoAtualizacao = "Arquivos carregados!";
|
||||||
|
|
||||||
// Nao executa a verificacao se estiver em ambiente de teste
|
// Nao executa a verificacao se estiver em ambiente de teste
|
||||||
if (frmInstancial.DebugMode && !frmInstancial.frmPrincipal.chbDebugMode.Checked && false)
|
if (!Variaveis.Producao)
|
||||||
{
|
{
|
||||||
AtualizandoArquivos = false;
|
AtualizandoArquivos = false;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using AgroBase.Models;
|
using AgroBase.Forms;
|
||||||
|
using AgroBase.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
@ -15,104 +16,84 @@ namespace AgroBase.Services
|
||||||
public static bool WifiDisponivel { get; set; } = false;
|
public static bool WifiDisponivel { get; set; } = false;
|
||||||
public static bool WifiConectado { get; set; } = false;
|
public static bool WifiConectado { get; set; } = false;
|
||||||
public static bool Conectando { get; set; } = false;
|
public static bool Conectando { get; set; } = false;
|
||||||
|
private static string InterfaceAtual { get; set; } = "";
|
||||||
|
|
||||||
public static void IniciarRotinas()
|
public static void IniciarRotinas()
|
||||||
{
|
{
|
||||||
tmrMonitoramento?.Dispose();
|
tmrMonitoramento?.Dispose();
|
||||||
tmrMonitoramento = new AsyncTaskTimerModel("tmrMonitoramento", tmrMonitoramento_Tick, 10000);
|
tmrMonitoramento = new AsyncTaskTimerModel("tmrMonitoramento", tmrMonitoramento_Tick, 10000);
|
||||||
tmrMonitoramento.Start();
|
tmrMonitoramento.Start();
|
||||||
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
PerfilExiste = await PerfilWiFiExisteAsync(Variaveis.NomeRedeWifiEquipamento);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task tmrMonitoramento_Tick()
|
private static async Task tmrMonitoramento_Tick()
|
||||||
{
|
{
|
||||||
WifiDisponivel = await VerificarRedeDisponivelAsync(Variaveis.NomeRedeWifiEquipamento);
|
if (!Variaveis.ForcarWifi)
|
||||||
|
|
||||||
if (WifiDisponivel)
|
|
||||||
{
|
{
|
||||||
string _ssid = await ObterNomeRedeWifiAtual();
|
return;
|
||||||
|
}
|
||||||
WifiConectado = _ssid == Variaveis.NomeRedeWifiEquipamento;
|
|
||||||
|
|
||||||
if (!WifiConectado)
|
string nomeRede = Variaveis.NomeRedeWifiEquipamento;
|
||||||
|
|
||||||
|
if (!PerfilExiste)
|
||||||
|
{
|
||||||
|
PerfilExiste = await PerfilWiFiExisteAsync(nomeRede);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PerfilExiste)
|
||||||
|
{
|
||||||
|
if (!WifiConectado || !WifiDisponivel)
|
||||||
{
|
{
|
||||||
Conectando = true;
|
WifiDisponivel = await VerificarRedeDisponivelAsync(nomeRede);
|
||||||
await VerificarConectarComSenhaAsync(Variaveis.NomeRedeWifiEquipamento, Variaveis.SenhaRedeWifiEquipamento);
|
|
||||||
Conectando = false;
|
|
||||||
}
|
}
|
||||||
if (WifiConectado)
|
|
||||||
|
if (WifiDisponivel)
|
||||||
{
|
{
|
||||||
string _interface = "";
|
string _ssid = await ObterNomeRedeWifiAtual();
|
||||||
VerificaInterfaceConectada(out _interface);
|
|
||||||
var ip = EthernetService.ObterIpAtual(_interface);
|
WifiConectado = _ssid == nomeRede;
|
||||||
if (ip != Variaveis.IP_Host)
|
|
||||||
|
if (!WifiConectado)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
Conectando = true;
|
||||||
|
await ConectarRedeWifiAsync(nomeRede);
|
||||||
|
Conectando = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WifiConectado)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(InterfaceAtual))
|
||||||
{
|
{
|
||||||
EthernetService.ConfigurarIP(true, false);
|
string _interface = "";
|
||||||
|
VerificaInterfaceConectada(out _interface);
|
||||||
|
InterfaceAtual = _interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ip = EthernetService.ObterIpAtual(InterfaceAtual);
|
||||||
|
if (!string.IsNullOrEmpty(ip) && ip != Variaveis.IP_Host)
|
||||||
|
{
|
||||||
|
bool configurado = await EthernetService.ConfigurarIP(true, false);
|
||||||
foreach (var topico in Variaveis.MqttService.Topicos.Where(x => x.Inscrever))
|
foreach (var topico in Variaveis.MqttService.Topicos.Where(x => x.Inscrever))
|
||||||
{
|
{
|
||||||
await Variaveis.MqttService.UnsubscribeAsync(topico);
|
await Variaveis.MqttService.UnsubscribeAsync(topico);
|
||||||
}
|
}
|
||||||
Variaveis.MqttService.Topicos.Clear();
|
Variaveis.MqttService.Topicos.Clear();
|
||||||
Variaveis.MqttService = new MqttService("localhost", 1883);
|
Variaveis.MqttService = new MqttService("localhost", 1883);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WifiConectado = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WifiConectado = false;
|
WifiConectado = false;
|
||||||
Conectando = false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<bool> VerificarConectarComSenhaAsync(string nomeRede, string senha)
|
if (!WifiConectado)
|
||||||
{
|
|
||||||
string xmlPerfil = $@"<?xml version=""1.0""?>
|
|
||||||
<WLANProfile xmlns=""http://www.microsoft.com/networking/WLAN/profile/v1"">
|
|
||||||
<name>{nomeRede}</name>
|
|
||||||
<SSIDConfig>
|
|
||||||
<SSID>
|
|
||||||
<name>{nomeRede}</name>
|
|
||||||
</SSID>
|
|
||||||
<nonBroadcast>false</nonBroadcast>
|
|
||||||
</SSIDConfig>
|
|
||||||
<connectionType>ESS</connectionType>
|
|
||||||
<connectionMode>auto</connectionMode>
|
|
||||||
<MSM>
|
|
||||||
<security>
|
|
||||||
<authEncryption>
|
|
||||||
<authentication>WPA2PSK</authentication>
|
|
||||||
<encryption>AES</encryption>
|
|
||||||
<useOneX>false</useOneX>
|
|
||||||
</authEncryption>
|
|
||||||
<sharedKey>
|
|
||||||
<keyType>passPhrase</keyType>
|
|
||||||
<protected>false</protected>
|
|
||||||
<keyMaterial>{senha}</keyMaterial>
|
|
||||||
</sharedKey>
|
|
||||||
</security>
|
|
||||||
</MSM>
|
|
||||||
</WLANProfile>";
|
|
||||||
|
|
||||||
if (!PerfilExiste)
|
|
||||||
{
|
{
|
||||||
PerfilExiste = await AdicionarPerfilWiFiAsync(nomeRede, xmlPerfil);
|
InterfaceAtual = "";
|
||||||
}
|
|
||||||
|
|
||||||
if (PerfilExiste)
|
|
||||||
{
|
|
||||||
return await ConectarRedeWifiAsync(nomeRede);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Não foi possível adicionar o perfil para a rede {nomeRede}.");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,10 +119,43 @@ namespace AgroBase.Services
|
||||||
string output = await process.StandardOutput.ReadToEndAsync();
|
string output = await process.StandardOutput.ReadToEndAsync();
|
||||||
await Task.Run(() => process.WaitForExit());
|
await Task.Run(() => process.WaitForExit());
|
||||||
|
|
||||||
bool existente = output.Contains($"All User Profile : {nomePerfil}");
|
PerfilExiste = output.Contains(nomePerfil);
|
||||||
|
|
||||||
|
if (!PerfilExiste)
|
||||||
|
{
|
||||||
|
string nomeRede = Variaveis.NomeRedeWifiEquipamento;
|
||||||
|
string xmlPerfil = $@"<?xml version=""1.0""?>
|
||||||
|
<WLANProfile xmlns=""http://www.microsoft.com/networking/WLAN/profile/v1"">
|
||||||
|
<name>{nomeRede}</name>
|
||||||
|
<SSIDConfig>
|
||||||
|
<SSID>
|
||||||
|
<name>{nomeRede}</name>
|
||||||
|
</SSID>
|
||||||
|
<nonBroadcast>false</nonBroadcast>
|
||||||
|
</SSIDConfig>
|
||||||
|
<connectionType>ESS</connectionType>
|
||||||
|
<connectionMode>auto</connectionMode>
|
||||||
|
<MSM>
|
||||||
|
<security>
|
||||||
|
<authEncryption>
|
||||||
|
<authentication>WPA2PSK</authentication>
|
||||||
|
<encryption>AES</encryption>
|
||||||
|
<useOneX>false</useOneX>
|
||||||
|
</authEncryption>
|
||||||
|
<sharedKey>
|
||||||
|
<keyType>passPhrase</keyType>
|
||||||
|
<protected>false</protected>
|
||||||
|
<keyMaterial>{nomeRede}</keyMaterial>
|
||||||
|
</sharedKey>
|
||||||
|
</security>
|
||||||
|
</MSM>
|
||||||
|
</WLANProfile>";
|
||||||
|
|
||||||
|
PerfilExiste = await AdicionarPerfilWiFiAsync(nomeRede, xmlPerfil);
|
||||||
|
}
|
||||||
|
|
||||||
// Verifica se o perfil está listado na saída
|
// Verifica se o perfil está listado na saída
|
||||||
return existente;
|
return PerfilExiste;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -201,6 +215,21 @@ namespace AgroBase.Services
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ProcessStartInfo psi0 = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "netsh",
|
||||||
|
Arguments = "wlan disconnect",
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = true
|
||||||
|
};
|
||||||
|
|
||||||
|
using (Process process = Process.Start(psi0))
|
||||||
|
{
|
||||||
|
string output = await process.StandardOutput.ReadToEndAsync();
|
||||||
|
await Task.Run(() => process.WaitForExit());
|
||||||
|
}
|
||||||
|
|
||||||
ProcessStartInfo psi = new ProcessStartInfo
|
ProcessStartInfo psi = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "netsh",
|
FileName = "netsh",
|
||||||
|
|
@ -247,7 +276,11 @@ namespace AgroBase.Services
|
||||||
string output = await process.StandardOutput.ReadToEndAsync();
|
string output = await process.StandardOutput.ReadToEndAsync();
|
||||||
await Task.Run(() => process.WaitForExit());
|
await Task.Run(() => process.WaitForExit());
|
||||||
|
|
||||||
WifiConectado = output.Contains("successfully");
|
await Task.Delay(3000); // tempo para o sistema conectar de fato
|
||||||
|
string ssidDepois = await ObterNomeRedeWifiAtual();
|
||||||
|
WifiConectado = ssidDepois == Variaveis.NomeRedeWifiEquipamento;
|
||||||
|
|
||||||
|
//WifiConectado = output.Contains("successfully");
|
||||||
|
|
||||||
return WifiConectado;
|
return WifiConectado;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -25,7 +25,7 @@
|
||||||
<meta name="viewport" content="width=device-width,
|
<meta name="viewport" content="width=device-width,
|
||||||
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
<style>
|
<style>
|
||||||
#map_4ac4b2d3da6e664d85c4f5f845318314 {
|
#map_4dc97fc09c9d854200d7c2c2c172f38c {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100.0%;
|
width: 100.0%;
|
||||||
height: 100.0%;
|
height: 100.0%;
|
||||||
|
|
@ -39,14 +39,14 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
<div class="folium-map" id="map_4ac4b2d3da6e664d85c4f5f845318314" ></div>
|
<div class="folium-map" id="map_4dc97fc09c9d854200d7c2c2c172f38c" ></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
var map_4ac4b2d3da6e664d85c4f5f845318314 = L.map(
|
var map_4dc97fc09c9d854200d7c2c2c172f38c = L.map(
|
||||||
"map_4ac4b2d3da6e664d85c4f5f845318314",
|
"map_4dc97fc09c9d854200d7c2c2c172f38c",
|
||||||
{
|
{
|
||||||
center: [0.0, 0.0],
|
center: [0.0, 0.0],
|
||||||
crs: L.CRS.EPSG3857,
|
crs: L.CRS.EPSG3857,
|
||||||
|
|
@ -60,13 +60,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var tile_layer_86fe229ea141da637faf9c51d4655afc = L.tileLayer(
|
var tile_layer_6738fc8123300741b57de1603aa02199 = L.tileLayer(
|
||||||
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||||
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
|
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
tile_layer_86fe229ea141da637faf9c51d4655afc.addTo(map_4ac4b2d3da6e664d85c4f5f845318314);
|
tile_layer_6738fc8123300741b57de1603aa02199.addTo(map_4dc97fc09c9d854200d7c2c2c172f38c);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
}
|
}
|
||||||
trajeto_json_add({"features": []});
|
trajeto_json_add({"features": []});
|
||||||
|
|
||||||
trajeto_json.addTo(map_4ac4b2d3da6e664d85c4f5f845318314);
|
trajeto_json.addTo(map_4dc97fc09c9d854200d7c2c2c172f38c);
|
||||||
|
|
||||||
function adicionarGeometria(novaGeometria) {
|
function adicionarGeometria(novaGeometria) {
|
||||||
trajeto_json.addData(novaGeometria);
|
trajeto_json.addData(novaGeometria);
|
||||||
|
|
@ -145,7 +145,7 @@
|
||||||
|
|
||||||
var marcadorDinamico = L.marker([0, 0], {
|
var marcadorDinamico = L.marker([0, 0], {
|
||||||
icon: customIcon
|
icon: customIcon
|
||||||
}).addTo(map_4ac4b2d3da6e664d85c4f5f845318314);
|
}).addTo(map_4dc97fc09c9d854200d7c2c2c172f38c);
|
||||||
|
|
||||||
// Conectar ao broker MQTT
|
// Conectar ao broker MQTT
|
||||||
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
|
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
marcadorDinamico.setRotationAngle(angulo);
|
marcadorDinamico.setRotationAngle(angulo);
|
||||||
|
|
||||||
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
||||||
map_4ac4b2d3da6e664d85c4f5f845318314.setView(novaPosicao, map_4ac4b2d3da6e664d85c4f5f845318314.getZoom());
|
map_4dc97fc09c9d854200d7c2c2c172f38c.setView(novaPosicao, map_4dc97fc09c9d854200d7c2c2c172f38c.getZoom());
|
||||||
});
|
});
|
||||||
|
|
||||||
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
|
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -482,4 +482,4 @@ C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.GenerateR
|
||||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CoreCompileInputs.cache
|
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CoreCompileInputs.cache
|
||||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.exe
|
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.exe
|
||||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.pdb
|
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.pdb
|
||||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.Up2Date
|
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CopyComplete
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue