50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
|
|
using AgroBase.Models;
|
|||
|
|
using AgroBase.Services;
|
|||
|
|
using OperationControl.Services;
|
|||
|
|
using OperationControl.Windows;
|
|||
|
|
using System.Diagnostics;
|
|||
|
|
|
|||
|
|
namespace OperationControl.Models
|
|||
|
|
{
|
|||
|
|
public class AppShell
|
|||
|
|
{
|
|||
|
|
private readonly System.Timers.Timer tmrComunicacao = new(1000) { AutoReset = true };
|
|||
|
|
private int tmrComunicacaoTicks = 0;
|
|||
|
|
private bool tmrComunicacaoTicking = false;
|
|||
|
|
|
|||
|
|
public MainWindow Main { get; private set; }
|
|||
|
|
|
|||
|
|
public void Inicializar()
|
|||
|
|
{
|
|||
|
|
APIService.IniciarRotinas();
|
|||
|
|
Variaveis.IniciarMQTT();
|
|||
|
|
|
|||
|
|
tmrComunicacao.Elapsed += (_, __) => tmrComunicacao_Elapsed();
|
|||
|
|
tmrComunicacao.Start();
|
|||
|
|
|
|||
|
|
Show();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Show()
|
|||
|
|
{
|
|||
|
|
// Aqui você decide qual janela é a inicial de fato
|
|||
|
|
Main = new MainWindow();
|
|||
|
|
Main.Show();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void tmrComunicacao_Elapsed()
|
|||
|
|
{
|
|||
|
|
if (tmrComunicacaoTicking) return;
|
|||
|
|
tmrComunicacaoTicking = true;
|
|||
|
|
if (tmrComunicacaoTicks % VariaveisEquipamento.TempoEntrePingsConexao == 0 && Variaveis.GpsService != null)
|
|||
|
|
{
|
|||
|
|
VariaveisControleOperacao.EnviarDadosPosicao(Variaveis.GpsService.UltimaLeitura);
|
|||
|
|
}
|
|||
|
|
VariaveisControleOperacao.AtualizarListaRoversNaRede();
|
|||
|
|
tmrComunicacaoTicks++;
|
|||
|
|
tmrComunicacaoTicking = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|