diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/30152d68-2581-4c51-9a93-f5b65b7f3435.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/30152d68-2581-4c51-9a93-f5b65b7f3435.vsidx deleted file mode 100644 index e89be0d09..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/30152d68-2581-4c51-9a93-f5b65b7f3435.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/e963dcd0-9853-4db2-a5c1-d9b0c7d6c40e.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/e963dcd0-9853-4db2-a5c1-d9b0c7d6c40e.vsidx new file mode 100644 index 000000000..77696de6b Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/e963dcd0-9853-4db2-a5c1-d9b0c7d6c40e.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/f93f8dca-47de-46b9-92c2-f654b80fdb3b.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/f93f8dca-47de-46b9-92c2-f654b80fdb3b.vsidx new file mode 100644 index 000000000..ef79395e0 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/f93f8dca-47de-46b9-92c2-f654b80fdb3b.vsidx differ diff --git a/AgroBase/.vs/AgroBase/v17/.suo b/AgroBase/.vs/AgroBase/v17/.suo index 32de41564..21d00b8f8 100644 Binary files a/AgroBase/.vs/AgroBase/v17/.suo and b/AgroBase/.vs/AgroBase/v17/.suo differ diff --git a/AgroBase/AgroBase/AgroBase.csproj b/AgroBase/AgroBase/AgroBase.csproj index 38bf0f1b6..3dc2b8377 100644 --- a/AgroBase/AgroBase/AgroBase.csproj +++ b/AgroBase/AgroBase/AgroBase.csproj @@ -416,6 +416,7 @@ frmSonar.cs + diff --git a/AgroBase/AgroBase/Forms/Atuador/frmAtuCalibragem.cs b/AgroBase/AgroBase/Forms/Atuador/frmAtuCalibragem.cs index 24f4090fa..f68e5f1ff 100644 --- a/AgroBase/AgroBase/Forms/Atuador/frmAtuCalibragem.cs +++ b/AgroBase/AgroBase/Forms/Atuador/frmAtuCalibragem.cs @@ -1,6 +1,7 @@ using AgroBase.Comum; using AgroBase.Models; using AgroBase.Models.Modules; +using CefSharp.DevTools.Page; using Microsoft.DirectX.PrivateImplementationDetails; using System; using System.Collections.Generic; @@ -9,6 +10,7 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; +using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using static AgroBase.Models.Enums; @@ -17,7 +19,7 @@ namespace AgroBase.Forms.Atuador { public partial class frmAtuCalibragem : Form { - Timer tmrLeitura = new Timer() { Interval = 1000 }; + AsyncTaskTimerModel tmrLeitura; DispositivosService DispAtu = (DispositivosService)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Atu); CalibragemVazao _CalibragemVazao = new CalibragemVazao(); @@ -55,7 +57,7 @@ namespace AgroBase.Forms.Atuador grdSensoriamento.Rows.Add(new object[] { "Percentual", "0" }); - tmrLeitura.Tick += TmrLeitura_Tick; + tmrLeitura = new AsyncTaskTimerModel(tmrLeitura_Tick, 1000, this); tmrLeitura.Start(); } @@ -121,7 +123,7 @@ namespace AgroBase.Forms.Atuador } - private void TmrLeitura_Tick(object sender, EventArgs e) + private async Task tmrLeitura_Tick() { DispAtu = (DispositivosService)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Atu); diff --git a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs index 45508f285..f9be43796 100644 --- a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs +++ b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; +using System.Threading.Tasks; using System.Windows.Forms; using AgroBase.Models; using AgroBase.Services; @@ -13,7 +14,7 @@ namespace AgroBase.Forms public partial class frmAtuCamera : Form { private CameraSoloModel cameraSolo = new CameraSoloModel(); - private Timer tmrLeitura; + private AsyncTaskTimerModel tmrLeitura; public frmAtuCamera() { @@ -53,7 +54,7 @@ namespace AgroBase.Forms } } - private void TmrLeitura_Tick(object sender, EventArgs e) + private async Task tmrLeitura_Tick() { ListarObjetosDetectados(); } @@ -102,8 +103,7 @@ namespace AgroBase.Forms cameraSolo.tmrProcesso ); - tmrLeitura = new Timer() { Interval = 200 }; - tmrLeitura.Tick += TmrLeitura_Tick; + tmrLeitura = new AsyncTaskTimerModel(tmrLeitura_Tick, 200); tmrLeitura.Start(); } diff --git a/AgroBase/AgroBase/Forms/Direcional/frmDirConfig.Designer.cs b/AgroBase/AgroBase/Forms/Direcional/frmDirConfig.Designer.cs index 2078ba821..f7413fc6e 100644 --- a/AgroBase/AgroBase/Forms/Direcional/frmDirConfig.Designer.cs +++ b/AgroBase/AgroBase/Forms/Direcional/frmDirConfig.Designer.cs @@ -30,6 +30,8 @@ namespace AgroBase.Forms.Direcional private void InitializeComponent() { this.gpbSentido = new System.Windows.Forms.GroupBox(); + this.lblIP = new System.Windows.Forms.Label(); + this.txtIP = new System.Windows.Forms.TextBox(); this.cmbTipoMovimento = new System.Windows.Forms.ComboBox(); this.lblTipoMovimento = new System.Windows.Forms.Label(); this.btnSalvarSentido = new System.Windows.Forms.Button(); @@ -69,8 +71,6 @@ namespace AgroBase.Forms.Direcional this.cmbETEsquerda = new System.Windows.Forms.ComboBox(); this.lblETEsquerda = new System.Windows.Forms.Label(); this.lblETDireita = new System.Windows.Forms.Label(); - this.lblIP = new System.Windows.Forms.Label(); - this.txtIP = new System.Windows.Forms.TextBox(); this.gpbSentido.SuspendLayout(); this.gpbDF.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudDFOffset)).BeginInit(); @@ -102,6 +102,25 @@ namespace AgroBase.Forms.Direcional this.gpbSentido.TabStop = false; this.gpbSentido.Text = "Sentido de giro"; // + // lblIP + // + this.lblIP.AutoSize = true; + this.lblIP.Location = new System.Drawing.Point(10, 326); + this.lblIP.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblIP.Name = "lblIP"; + this.lblIP.Size = new System.Drawing.Size(17, 13); + this.lblIP.TabIndex = 143; + this.lblIP.Text = "IP"; + // + // txtIP + // + this.txtIP.Location = new System.Drawing.Point(13, 343); + this.txtIP.Margin = new System.Windows.Forms.Padding(2); + this.txtIP.Name = "txtIP"; + this.txtIP.Size = new System.Drawing.Size(85, 20); + this.txtIP.TabIndex = 142; + this.txtIP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // // cmbTipoMovimento // this.cmbTipoMovimento.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -201,6 +220,7 @@ namespace AgroBase.Forms.Direcional // // cmbDFDireita // + this.cmbDFDireita.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbDFDireita.FormattingEnabled = true; this.cmbDFDireita.Location = new System.Drawing.Point(66, 25); this.cmbDFDireita.Margin = new System.Windows.Forms.Padding(2); @@ -210,6 +230,7 @@ namespace AgroBase.Forms.Direcional // // cmbDFEsquerda // + this.cmbDFEsquerda.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbDFEsquerda.FormattingEnabled = true; this.cmbDFEsquerda.Location = new System.Drawing.Point(66, 50); this.cmbDFEsquerda.Margin = new System.Windows.Forms.Padding(2); @@ -306,6 +327,7 @@ namespace AgroBase.Forms.Direcional // // cmbEFDireita // + this.cmbEFDireita.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbEFDireita.FormattingEnabled = true; this.cmbEFDireita.Location = new System.Drawing.Point(66, 25); this.cmbEFDireita.Margin = new System.Windows.Forms.Padding(2); @@ -315,6 +337,7 @@ namespace AgroBase.Forms.Direcional // // cmbEFEsquerda // + this.cmbEFEsquerda.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbEFEsquerda.FormattingEnabled = true; this.cmbEFEsquerda.Location = new System.Drawing.Point(66, 50); this.cmbEFEsquerda.Margin = new System.Windows.Forms.Padding(2); @@ -411,6 +434,7 @@ namespace AgroBase.Forms.Direcional // // cmbDTDireita // + this.cmbDTDireita.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbDTDireita.FormattingEnabled = true; this.cmbDTDireita.Location = new System.Drawing.Point(66, 25); this.cmbDTDireita.Margin = new System.Windows.Forms.Padding(2); @@ -420,6 +444,7 @@ namespace AgroBase.Forms.Direcional // // cmbDTEsquerda // + this.cmbDTEsquerda.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbDTEsquerda.FormattingEnabled = true; this.cmbDTEsquerda.Location = new System.Drawing.Point(66, 50); this.cmbDTEsquerda.Margin = new System.Windows.Forms.Padding(2); @@ -516,6 +541,7 @@ namespace AgroBase.Forms.Direcional // // cmbETDireita // + this.cmbETDireita.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbETDireita.FormattingEnabled = true; this.cmbETDireita.Location = new System.Drawing.Point(66, 25); this.cmbETDireita.Margin = new System.Windows.Forms.Padding(2); @@ -525,6 +551,7 @@ namespace AgroBase.Forms.Direcional // // cmbETEsquerda // + this.cmbETEsquerda.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbETEsquerda.FormattingEnabled = true; this.cmbETEsquerda.Location = new System.Drawing.Point(66, 50); this.cmbETEsquerda.Margin = new System.Windows.Forms.Padding(2); @@ -552,25 +579,6 @@ namespace AgroBase.Forms.Direcional this.lblETDireita.TabIndex = 2; this.lblETDireita.Text = "Direita"; // - // lblIP - // - this.lblIP.AutoSize = true; - this.lblIP.Location = new System.Drawing.Point(10, 326); - this.lblIP.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.lblIP.Name = "lblIP"; - this.lblIP.Size = new System.Drawing.Size(17, 13); - this.lblIP.TabIndex = 143; - this.lblIP.Text = "IP"; - // - // txtIP - // - this.txtIP.Location = new System.Drawing.Point(13, 343); - this.txtIP.Margin = new System.Windows.Forms.Padding(2); - this.txtIP.Name = "txtIP"; - this.txtIP.Size = new System.Drawing.Size(85, 20); - this.txtIP.TabIndex = 142; - this.txtIP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // // frmDirConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs b/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs index 0c0f0220e..1d448a0a3 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs @@ -189,7 +189,7 @@ namespace AgroBase.Forms.IHM private FilterInfoCollection videoDevices; private VideoCaptureDevice videoSourceEsquerda; private VideoCaptureDevice videoSourceDireita; - private Timer tmrKinect; + private AsyncTaskTimerModel tmrKinect; private void AtualizarCameras() { @@ -286,7 +286,7 @@ namespace AgroBase.Forms.IHM } } - private void TmrKinect_Tick(object sender, EventArgs e) + private async Task tmrKinect_Tick() { Bitmap bitmap = (Bitmap)(chbKinect.Checked ? KinectService.bitmapMap : KinectService.bitmapRGB).Clone(); picCentro.Image = bitmap; @@ -315,10 +315,7 @@ namespace AgroBase.Forms.IHM { if (tmrKinect == null) { - tmrKinect = new Timer(); - tmrKinect.Interval = 100; - tmrKinect.Tick -= TmrKinect_Tick; - tmrKinect.Tick += TmrKinect_Tick; + tmrKinect = new AsyncTaskTimerModel(tmrKinect_Tick, 100, this); tmrKinect.Start(); } } diff --git a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs index 56a8a72b3..931ef4395 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs @@ -662,10 +662,12 @@ namespace AgroBase.Forms.IHM idx = PreencheDadosLinha(grid, Testes, idx, Inicializado ? Testes[idx].ValorAferido : -1); var ServoFreio = Modulo_Sen.Servos.FirstOrDefault(x => x.ID.Contains(Modulo.Modulo_ID) && x.Inicializado); - bool AtivarFreio = SenIniciado && ServoFreio != null ? await EnviarComandoMovFreio(Variaveis.OperacaoEmAndamento.DispSen, ServoFreio, AcaoFreio.Ativar, Testes[idx], 2000) : false; + (bool atuar, int angAtivar) = Modulo.MovMotor.ConfigFreio.AtualizarDadosFreio(true, 0, 15); + bool AtivarFreio = SenIniciado && ServoFreio != null ? await EnviarComandoMovFreio(Variaveis.OperacaoEmAndamento.DispSen, ServoFreio, angAtivar, Testes[idx], 2000) : false; idx = PreencheDadosLinha(grid, Testes, idx, ServoFreio != null ? Testes[idx].ValorAferido : -1); - bool DesativarFreio = SenIniciado && ServoFreio != null ? await EnviarComandoMovFreio(Variaveis.OperacaoEmAndamento.DispSen, ServoFreio, AcaoFreio.Desativar, Testes[idx], 2000) : false; + (bool desatuar, int angDesativar) = Modulo.MovMotor.ConfigFreio.AtualizarDadosFreio(false); + bool DesativarFreio = SenIniciado && ServoFreio != null ? await EnviarComandoMovFreio(Variaveis.OperacaoEmAndamento.DispSen, ServoFreio, angDesativar, Testes[idx], 2000) : false; idx = PreencheDadosLinha(grid, Testes, idx, ServoFreio != null ? Testes[idx].ValorAferido : -1); } @@ -708,12 +710,12 @@ namespace AgroBase.Forms.IHM return Sucesso; } - private async Task EnviarComandoMovFreio(DispositivosService Dispositivo, SensorServoModel ServoFreio, AcaoFreio Acao, ColunasDiagnosticoModel Teste, int Timeout) + private async Task EnviarComandoMovFreio(DispositivosService Dispositivo, SensorServoModel ServoFreio, int Angulo, ColunasDiagnosticoModel Teste, int Timeout) { Dispositivo.Dados.Servos.ForEach(x => x.Controlar = false); ServoFreio.Controlar = true; - GeneralJoystick.EnviarComandoSensoriamento(S_Code.sFRO, ServoFreio.ID, Acao); + GeneralJoystick.EnviarComandoSensoriamento(S_Code.sFRO, ServoFreio.ID, Angulo); //Dispositivo.AdicionarMensagemFila(Dispositivo.Dados.Modulo_ID, ServoFreio.ProtocoloComando(), true, false); DateTime Inicio = DateTime.Now; diff --git a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs index b2f9ee340..22b3f5227 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs @@ -7,7 +7,7 @@ using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; -using System.Timers; +using System.Threading.Tasks; using System.Windows.Forms; using static AgroBase.Models.Enums; @@ -15,8 +15,8 @@ namespace AgroBase.Forms.IHM { public partial class frmIHM : Form { - System.Timers.Timer tmrDispositivos = new System.Timers.Timer() { Interval = 1000, Enabled = false }; - System.Timers.Timer tmrAtualizacaoArquivos = new System.Timers.Timer() { Interval = 300, Enabled = false }; + AsyncTaskTimerModel tmrDispositivos; + AsyncTaskTimerModel tmrAtualizacaoArquivos; public ulong CodFalha = 0; public frmIHM() @@ -97,30 +97,80 @@ namespace AgroBase.Forms.IHM private void frmIHM_Load(object sender, EventArgs e) { lblVersao.Text = "v " + Variaveis.Versao; - tmrDispositivos.Elapsed += TmrDispositivos_Elapsed; + tmrDispositivos = new AsyncTaskTimerModel(tmrDispositivos_Tick, 5000, this); tmrDispositivos.Start(); - tmrAtualizacaoArquivos.Elapsed += TmrAtualizacaoArquivos_Elapsed; + tmrAtualizacaoArquivos = new AsyncTaskTimerModel(tmrAtualizacaoArquivos_Tick, 300, this); tmrAtualizacaoArquivos.Start(); lblCodigoFalha.Click += LblCodigoFalha_Click; } - private void TmrAtualizacaoArquivos_Elapsed(object sender, ElapsedEventArgs e) + private async Task tmrAtualizacaoArquivos_Tick() { - tmrAtualizacaoArquivos.Stop(); + lblProgressoAtualizacao.Text = VersionamentoService.AtualizandoArquivos ? $"({VersionamentoService.ProgressoAtualizacao.ToString("0.00")}%) Atualizando arquivos..." : VersionamentoService.ResultadoAtualizacao; + pgbAtualizacaoArquivos.Value = (int)VersionamentoService.ProgressoAtualizacao; - Func func = new Func(() => + tmrAtualizacaoArquivos.SetInterval(VersionamentoService.AtualizandoArquivos ? 300 : 5000); + } + + private async Task tmrDispositivos_Tick() + { + CodFalha = Variaveis.OperacaoEmAndamento.RetornaCodigoFalha(); + + var Labels = this.Controls.OfType