diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/4b0c79da-8553-44d3-9669-36b42a88db71.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/4b0c79da-8553-44d3-9669-36b42a88db71.vsidx deleted file mode 100644 index d9680cf26..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/4b0c79da-8553-44d3-9669-36b42a88db71.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/58e32954-abae-4557-b2f9-f47a7f3492c9.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/98a7465a-05b4-4a21-99d5-5bbe19e9c42a.vsidx similarity index 99% rename from AgroBase/.vs/AgroBase/FileContentIndex/58e32954-abae-4557-b2f9-f47a7f3492c9.vsidx rename to AgroBase/.vs/AgroBase/FileContentIndex/98a7465a-05b4-4a21-99d5-5bbe19e9c42a.vsidx index fa564ed69..90d0a8385 100644 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/58e32954-abae-4557-b2f9-f47a7f3492c9.vsidx and b/AgroBase/.vs/AgroBase/FileContentIndex/98a7465a-05b4-4a21-99d5-5bbe19e9c42a.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/eadf1300-5fd6-484c-a7ab-eebbdb7c183f.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/eadf1300-5fd6-484c-a7ab-eebbdb7c183f.vsidx new file mode 100644 index 000000000..353015372 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/eadf1300-5fd6-484c-a7ab-eebbdb7c183f.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/ede14235-571f-4143-a198-7d55d38c903a.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/ede14235-571f-4143-a198-7d55d38c903a.vsidx new file mode 100644 index 000000000..493e20b98 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/ede14235-571f-4143-a198-7d55d38c903a.vsidx differ diff --git a/AgroBase/.vs/AgroBase/v17/.suo b/AgroBase/.vs/AgroBase/v17/.suo index 9f760820f..e2dab86b6 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 5f6da2ed8..d3aa12634 100644 --- a/AgroBase/AgroBase/AgroBase.csproj +++ b/AgroBase/AgroBase/AgroBase.csproj @@ -485,6 +485,7 @@ + diff --git a/AgroBase/AgroBase/Forms/Atuador/frmAtuCalibragem.cs b/AgroBase/AgroBase/Forms/Atuador/frmAtuCalibragem.cs index 1b87e4114..126c2d9ca 100644 --- a/AgroBase/AgroBase/Forms/Atuador/frmAtuCalibragem.cs +++ b/AgroBase/AgroBase/Forms/Atuador/frmAtuCalibragem.cs @@ -148,7 +148,7 @@ namespace AgroBase.Forms.Atuador grdSensoriamento.Rows[3].Cells[1].Value = DispAtu.Dados.BombaPressurizadora.LeituraPotencia; grdSensoriamento.Rows[4].Cells[1].Value = DispAtu.Dados.PressaoLinha.ToString("0.00000"); grdSensoriamento.Rows[5].Cells[1].Value = DispAtu.Dados.PressaoLinhaCalc.ToString("0.00000"); - grdSensoriamento.Rows[6].Cells[1].Value = DispAtu.Dados.VazaoFluxoMLpS.ToString("0.00000"); + grdSensoriamento.Rows[6].Cells[1].Value = DispAtu.Dados.VazaoFluxoMLpSMedia.ToString("0.00000"); grdSensoriamento.Rows[7].Cells[1].Value = DispAtu.Dados.MassaReservatorio.ToString("0.00000"); grdSensoriamento.Rows[8].Cells[1].Value = DispAtu.Dados.VolumeReservatorio.ToString("0.00000"); grdSensoriamento.Rows[9].Cells[1].Value = DispAtu.Dados.PercentualReservatorio.ToString("0.00"); @@ -156,18 +156,21 @@ namespace AgroBase.Forms.Atuador private void nudPressaoSP_ValueChanged(object sender, EventArgs e) { + var Bomba = Variaveis.OperacaoEmAndamento.DispAtu.Dados.BombaPressurizadora; Variaveis.OperacaoEmAndamento.Controle.PressaoLinha = Convert.ToInt32(((NumericUpDown)sender).Value); - GeneralJoystick.EnviarComandoAtuador(S_Code.sBMB, Variaveis.OperacaoEmAndamento.DispAtu.Dados.BombaPressurizadora.ComandoAtuar); + GeneralJoystick.EnviarComandoAtuador(S_Code.sBMB, Bomba.ComandoAtuar, Bomba.ID); } private void btnLigarBomba_Click(object sender, EventArgs e) { - GeneralJoystick.EnviarComandoAtuador(S_Code.sBMB, true); + var Bomba = Variaveis.OperacaoEmAndamento.DispAtu.Dados.BombaPressurizadora; + GeneralJoystick.EnviarComandoAtuador(S_Code.sBMB, true, Bomba.ID); } private void btnDesligarBomba_Click(object sender, EventArgs e) { - GeneralJoystick.EnviarComandoAtuador(S_Code.sBMB, false); + var Bomba = Variaveis.OperacaoEmAndamento.DispAtu.Dados.BombaPressurizadora; + GeneralJoystick.EnviarComandoAtuador(S_Code.sBMB, false, Bomba.ID); } private void pnlBico_Paint(object sender, PaintEventArgs e) diff --git a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs index 74b8b61a2..d49ae5075 100644 --- a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs +++ b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs @@ -111,7 +111,7 @@ namespace AgroBase.Forms { cameraSolo.camera.selectedCamera = cmbCameras.SelectedIndex > 0 ? cmbCameras.SelectedIndex : 0; cmbCameras.Items.Clear(); - cmbCameras.Items.AddRange(CameraService.AtualizaListaCameras().Keys.ToArray()); + cmbCameras.Items.AddRange(CameraService.ObterListaCameras().Keys.ToArray()); if (cmbCameras.Items.Count == 1) { cameraSolo.camera.selectedCamera = 0; diff --git a/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs b/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs index 3b8eebc5d..e6b38644f 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs @@ -204,7 +204,7 @@ namespace AgroBase.Forms.IHM cmbS1.SelectedIndexChanged += cmbCameraSolo_SelectedIndexChanged; - Cameras = CameraService.AtualizaListaCameras(); + Cameras = CameraService.ObterListaCameras(); cmbC.Items.Clear(); if (KinectService.Iniciado) diff --git a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs index 07170ee44..d3bc2e2bd 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs @@ -46,12 +46,12 @@ this.dgSinaleiros = new System.Windows.Forms.DataGridView(); this.tabResultados = new System.Windows.Forms.TabPage(); this.dgResultados = new System.Windows.Forms.DataGridView(); + this.tabFalhas = new System.Windows.Forms.TabPage(); + this.tvwFalhas = new System.Windows.Forms.TreeView(); this.picVoltar = new System.Windows.Forms.PictureBox(); this.picDiagnosticarTudo = new System.Windows.Forms.PictureBox(); this.picIniciarDiagnostico = new System.Windows.Forms.PictureBox(); this.picLoading = new System.Windows.Forms.PictureBox(); - this.tabFalhas = new System.Windows.Forms.TabPage(); - this.tvwFalhas = new System.Windows.Forms.TreeView(); this.tabControl1.SuspendLayout(); this.tabPulverizador.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgPulverizador)).BeginInit(); @@ -70,11 +70,11 @@ ((System.ComponentModel.ISupportInitialize)(this.dgSinaleiros)).BeginInit(); this.tabResultados.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgResultados)).BeginInit(); + this.tabFalhas.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picVoltar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picDiagnosticarTudo)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picIniciarDiagnostico)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picLoading)).BeginInit(); - this.tabFalhas.SuspendLayout(); this.SuspendLayout(); // // tabControl1 @@ -138,7 +138,7 @@ this.dgMovimentacao.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgMovimentacao.Location = new System.Drawing.Point(6, 6); this.dgMovimentacao.Name = "dgMovimentacao"; - this.dgMovimentacao.Size = new System.Drawing.Size(668, 406); + this.dgMovimentacao.Size = new System.Drawing.Size(892, 522); this.dgMovimentacao.TabIndex = 1; // // tabDirecional @@ -184,7 +184,7 @@ this.dgSensoriamento.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgSensoriamento.Location = new System.Drawing.Point(6, 6); this.dgSensoriamento.Name = "dgSensoriamento"; - this.dgSensoriamento.Size = new System.Drawing.Size(668, 406); + this.dgSensoriamento.Size = new System.Drawing.Size(892, 522); this.dgSensoriamento.TabIndex = 3; // // tabComunicacao @@ -207,12 +207,11 @@ this.dgComunicacao.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgComunicacao.Location = new System.Drawing.Point(6, 6); this.dgComunicacao.Name = "dgComunicacao"; - this.dgComunicacao.Size = new System.Drawing.Size(668, 406); + this.dgComunicacao.Size = new System.Drawing.Size(892, 522); this.dgComunicacao.TabIndex = 4; // // tabCameras // - this.tabCameras.Controls.Add(this.picCamera); this.tabCameras.Controls.Add(this.dgCameras); this.tabCameras.Location = new System.Drawing.Point(4, 38); this.tabCameras.Name = "tabCameras"; @@ -224,9 +223,9 @@ // // picCamera // - this.picCamera.Location = new System.Drawing.Point(574, 344); + this.picCamera.Location = new System.Drawing.Point(12, 194); this.picCamera.Name = "picCamera"; - this.picCamera.Size = new System.Drawing.Size(100, 68); + this.picCamera.Size = new System.Drawing.Size(65, 65); this.picCamera.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picCamera.TabIndex = 6; this.picCamera.TabStop = false; @@ -240,7 +239,7 @@ this.dgCameras.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgCameras.Location = new System.Drawing.Point(6, 6); this.dgCameras.Name = "dgCameras"; - this.dgCameras.Size = new System.Drawing.Size(668, 332); + this.dgCameras.Size = new System.Drawing.Size(892, 522); this.dgCameras.TabIndex = 5; // // tabSinaleiros @@ -263,7 +262,7 @@ this.dgSinaleiros.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgSinaleiros.Location = new System.Drawing.Point(6, 6); this.dgSinaleiros.Name = "dgSinaleiros"; - this.dgSinaleiros.Size = new System.Drawing.Size(668, 406); + this.dgSinaleiros.Size = new System.Drawing.Size(892, 522); this.dgSinaleiros.TabIndex = 6; // // tabResultados @@ -286,9 +285,30 @@ this.dgResultados.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgResultados.Location = new System.Drawing.Point(6, 6); this.dgResultados.Name = "dgResultados"; - this.dgResultados.Size = new System.Drawing.Size(668, 406); + this.dgResultados.Size = new System.Drawing.Size(892, 522); this.dgResultados.TabIndex = 7; // + // tabFalhas + // + this.tabFalhas.Controls.Add(this.tvwFalhas); + this.tabFalhas.Location = new System.Drawing.Point(4, 38); + this.tabFalhas.Name = "tabFalhas"; + this.tabFalhas.Padding = new System.Windows.Forms.Padding(3); + this.tabFalhas.Size = new System.Drawing.Size(904, 534); + this.tabFalhas.TabIndex = 8; + this.tabFalhas.Text = "Cód. Falhas"; + this.tabFalhas.UseVisualStyleBackColor = true; + // + // tvwFalhas + // + this.tvwFalhas.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tvwFalhas.Location = new System.Drawing.Point(6, 6); + this.tvwFalhas.Name = "tvwFalhas"; + this.tvwFalhas.Size = new System.Drawing.Size(892, 522); + this.tvwFalhas.TabIndex = 0; + // // picVoltar // this.picVoltar.Image = global::AgroBase.Properties.Resources.voltar; @@ -331,32 +351,12 @@ this.picLoading.TabIndex = 15; this.picLoading.TabStop = false; // - // tabFalhas - // - this.tabFalhas.Controls.Add(this.tvwFalhas); - this.tabFalhas.Location = new System.Drawing.Point(4, 38); - this.tabFalhas.Name = "tabFalhas"; - this.tabFalhas.Padding = new System.Windows.Forms.Padding(3); - this.tabFalhas.Size = new System.Drawing.Size(904, 534); - this.tabFalhas.TabIndex = 8; - this.tabFalhas.Text = "Cód. Falhas"; - this.tabFalhas.UseVisualStyleBackColor = true; - // - // tvwFalhas - // - this.tvwFalhas.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tvwFalhas.Location = new System.Drawing.Point(6, 6); - this.tvwFalhas.Name = "tvwFalhas"; - this.tvwFalhas.Size = new System.Drawing.Size(892, 522); - this.tvwFalhas.TabIndex = 0; - // // frmDiagnosticos // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1024, 600); + this.Controls.Add(this.picCamera); this.Controls.Add(this.picLoading); this.Controls.Add(this.picIniciarDiagnostico); this.Controls.Add(this.picDiagnosticarTudo); @@ -386,11 +386,11 @@ ((System.ComponentModel.ISupportInitialize)(this.dgSinaleiros)).EndInit(); this.tabResultados.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dgResultados)).EndInit(); + this.tabFalhas.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.picVoltar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picDiagnosticarTudo)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picIniciarDiagnostico)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picLoading)).EndInit(); - this.tabFalhas.ResumeLayout(false); this.ResumeLayout(false); } diff --git a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs index e54e43905..c70aace06 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs @@ -416,7 +416,7 @@ namespace AgroBase.Forms.IHM await EnviarComandoBico(B01, true, 1000); - double Fluxo = FluxoInicializado ? Dispositivo.Dados.VazaoFluxoMLpS : -1; + double Fluxo = FluxoInicializado ? Dispositivo.Dados.VazaoFluxoMLpSInstantanea : -1; idx = PreencheDadosLinha(grid, Testes, idx, Fluxo); bool statusB01_1 = B01 != null && B01.LeituraStatusBico; @@ -466,8 +466,9 @@ namespace AgroBase.Forms.IHM private async Task EnviarComandoBomba(bool Ligar, int Delay) { + var Bomba = Variaveis.OperacaoEmAndamento.DispAtu.Dados.BombaPressurizadora; Variaveis.OperacaoEmAndamento.Controle.PressaoLinha = 85; - GeneralJoystick.EnviarComandoAtuador(S_Code.sBMB, Ligar); + GeneralJoystick.EnviarComandoAtuador(S_Code.sBMB, Ligar, Bomba.ID); await Task.Delay(Delay); } @@ -581,13 +582,13 @@ namespace AgroBase.Forms.IHM { Componente = x.Modulo_ID + " Servo Freio", Teste = "Ativar", - ValorPadrao = VariaveisEquipamento.AnguloFreio[AcaoFreio.Ativar] + ValorPadrao = x.MovMotor.ConfigFreio.Incremental ? 15 : 165 }, new ColunasDiagnosticoModel() { Componente = x.Modulo_ID + " Servo Freio", Teste = "Desativar", - ValorPadrao = VariaveisEquipamento.AnguloFreio[AcaoFreio.Desativar] + ValorPadrao = x.MovMotor.ConfigFreio.Incremental ? 0 : 180 }, })); @@ -691,11 +692,14 @@ namespace AgroBase.Forms.IHM { await Task.Delay(500); - bool sentidoCorreto = Sentido == Direcao.Parado ? true : - Modulo.MovMotor.Sentido == - (Sentido == Enums.Direcao.Frente ? Modulo.MovMotor.ConfigSentidos[Variaveis.OperacaoEmAndamento.Controle.TipoMovimento].Frente : + Sentido sentidoMovimento = + Sentido == Enums.Direcao.Frente ? Modulo.MovMotor.ConfigSentidos[Variaveis.OperacaoEmAndamento.Controle.TipoMovimento].Frente : Sentido == Enums.Direcao.Tras ? Modulo.MovMotor.ConfigSentidos[Variaveis.OperacaoEmAndamento.Controle.TipoMovimento].Tras : - Enums.Sentido.Parado); + Enums.Sentido.Parado; + + bool sentidoCorreto = + Sentido == Direcao.Parado ? true : + Modulo.MovMotor.Sentido == sentidoMovimento; bool rpmCorreto = Teste.ComplementoValorPadrao == "<" ? Modulo.MovMotor.RPM_Roda < Teste.ValorPadrao : @@ -726,12 +730,12 @@ namespace AgroBase.Forms.IHM await Task.Delay(1000); Sucesso = - Teste.ComplementoValorPadrao == "<" ? (((FirmwareServoFreio)ServoFreio.Leitura)?.Angulo ?? 0) < Teste.ValorPadrao : - Teste.ComplementoValorPadrao == ">" ? (((FirmwareServoFreio)ServoFreio.Leitura)?.Angulo ?? 0) > Teste.ValorPadrao : - (((FirmwareServoFreio)ServoFreio.Leitura)?.Angulo ?? 0) == Teste.ValorPadrao; + Teste.ComplementoValorPadrao == "<" ? ServoFreio.LeituraAngulo < Teste.ValorPadrao : + Teste.ComplementoValorPadrao == ">" ? ServoFreio.LeituraAngulo > Teste.ValorPadrao : + ServoFreio.LeituraAngulo == Teste.ValorPadrao; } - Teste.ValorAferido = (((FirmwareServoFreio)ServoFreio.Leitura)?.Angulo ?? 0); + Teste.ValorAferido = ServoFreio.LeituraAngulo; return Sucesso; } @@ -801,9 +805,7 @@ namespace AgroBase.Forms.IHM TipoMovimentoDirecional _oldTipoMovimento = Variaveis.OperacaoEmAndamento.Controle.TipoMovimento; double _oldAngulo = Variaveis.OperacaoEmAndamento.Controle.Angulo; - - Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = TipoMovimentoDirecional.Diagnostico; - Variaveis.OperacaoEmAndamento.Controle.Angulo = 25; + double _oldVelocidadeMP = Variaveis.OperacaoEmAndamento.Controle.VelocidadeMP; DispositivosService Dispositivo = (DispositivosService)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == Enums.T_Code.Mvd); @@ -812,6 +814,10 @@ namespace AgroBase.Forms.IHM return false; } + Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = TipoMovimentoDirecional.Diagnostico; + Variaveis.OperacaoEmAndamento.Controle.Angulo = 25; + Variaveis.OperacaoEmAndamento.Controle.VelocidadeMP = 30; + foreach (var Modulo in Dispositivo.Dados.Modulos) { var Leitura = Modulo.DirMotor.Leitura; @@ -851,18 +857,18 @@ namespace AgroBase.Forms.IHM Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = _oldTipoMovimento; Variaveis.OperacaoEmAndamento.Controle.Angulo = _oldAngulo; + Variaveis.OperacaoEmAndamento.Controle.VelocidadeMP = _oldVelocidadeMP; return true; } private async Task EnviarComandoDir(ModuloMvdModel Modulo, Enums.Direcao Sentido, ColunasDiagnosticoModel Teste, int Timeout) { - Modulo.DirMotor.EnviarComandoControle(Sentido); - DateTime Inicio = DateTime.Now; bool Sucesso = false; while (!Sucesso && Inicio.AddMilliseconds(Timeout) > DateTime.Now) { + Modulo.DirMotor.EnviarComandoControle(Sentido); await Task.Delay(200); /*bool sentidoCorreto = Modulo.DirMotor.Sentido == @@ -916,7 +922,7 @@ namespace AgroBase.Forms.IHM { Componente = "PZEM", Teste = "Corrente Bateria", - ValorPadrao = 1, + ValorPadrao = 0.1, ComplementoValorPadrao = ">" }, new ColunasDiagnosticoModel() @@ -944,7 +950,7 @@ namespace AgroBase.Forms.IHM { Componente = "Módulo Sen", Teste = "Corrente Barramento 5V", - ValorPadrao = 1, + ValorPadrao = 500, ComplementoValorPadrao = ">" }, new ColunasDiagnosticoModel() @@ -958,7 +964,7 @@ namespace AgroBase.Forms.IHM { Componente = "Módulo Sen", Teste = "Corrente Barramento 12V", - ValorPadrao = 1, + ValorPadrao = 0, ComplementoValorPadrao = ">" }, new ColunasDiagnosticoModel() @@ -1036,15 +1042,15 @@ namespace AgroBase.Forms.IHM bool SenIniciado = Modulo_Sen.Conectado; idx = PreencheDadosLinha(grid, Testes, idx, SenIniciado ? 1 : 0); - var S5V = Modulo_Sen.DadosLeitura.SensoresCorrente.FirstOrDefault(x => x.ID == "AB5V"); - double Tensao5V = S5V != null ? (double)S5V.Current : -1; + var S5V = ((FirmwareSensorCorrente)Modulo_Sen.Sensores.FirstOrDefault(x => x.ID == "AB5V").Leitura); + double Tensao5V = S5V != null ? (double)S5V.BusVoltage : -1; idx = PreencheDadosLinha(grid, Testes, idx, Tensao5V); double Corrente5V = S5V != null ? (double)S5V.Current : -1; idx = PreencheDadosLinha(grid, Testes, idx, Corrente5V); - var S12V = Modulo_Sen.DadosLeitura.SensoresCorrente.FirstOrDefault(x => x.ID == "AB12V"); - double Tensao12V = S12V != null ? (double)S12V.Current : -1; + var S12V = ((FirmwareSensorCorrente)Modulo_Sen.Sensores.FirstOrDefault(x => x.ID == "AB12V").Leitura); + double Tensao12V = S12V != null ? (double)S12V.BusVoltage : -1; idx = PreencheDadosLinha(grid, Testes, idx, Tensao12V); double Corrente12V = S12V != null ? (double)S12V.Current : -1; diff --git a/AgroBase/AgroBase/Forms/IHM/frmIHM.Designer.cs b/AgroBase/AgroBase/Forms/IHM/frmIHM.Designer.cs index 21f6c3fdc..6e5b8445e 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmIHM.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmIHM.Designer.cs @@ -65,6 +65,7 @@ this.picWifi = new System.Windows.Forms.PictureBox(); this.pgbAtualizacaoArquivos = new System.Windows.Forms.ProgressBar(); this.lblProgressoAtualizacao = new System.Windows.Forms.Label(); + this.lblWifi = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picManual)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picDiagnosticos)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picOperacao)).BeginInit(); @@ -126,7 +127,7 @@ this.lblMqtt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblMqtt.AutoSize = true; this.lblMqtt.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblMqtt.Location = new System.Drawing.Point(473, 488); + this.lblMqtt.Location = new System.Drawing.Point(473, 480); this.lblMqtt.Name = "lblMqtt"; this.lblMqtt.Size = new System.Drawing.Size(114, 13); this.lblMqtt.TabIndex = 13; @@ -357,7 +358,7 @@ this.lblStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblStatus.AutoSize = true; this.lblStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblStatus.Location = new System.Drawing.Point(473, 538); + this.lblStatus.Location = new System.Drawing.Point(473, 541); this.lblStatus.Name = "lblStatus"; this.lblStatus.Size = new System.Drawing.Size(84, 13); this.lblStatus.TabIndex = 40; @@ -379,7 +380,7 @@ this.lblOperacaoLiberada.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblOperacaoLiberada.AutoSize = true; this.lblOperacaoLiberada.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblOperacaoLiberada.Location = new System.Drawing.Point(473, 461); + this.lblOperacaoLiberada.Location = new System.Drawing.Point(473, 460); this.lblOperacaoLiberada.Name = "lblOperacaoLiberada"; this.lblOperacaoLiberada.Size = new System.Drawing.Size(124, 13); this.lblOperacaoLiberada.TabIndex = 42; @@ -391,7 +392,7 @@ this.lblCodigoFalha.AutoSize = true; this.lblCodigoFalha.Cursor = System.Windows.Forms.Cursors.Hand; this.lblCodigoFalha.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblCodigoFalha.Location = new System.Drawing.Point(473, 514); + this.lblCodigoFalha.Location = new System.Drawing.Point(473, 521); this.lblCodigoFalha.Name = "lblCodigoFalha"; this.lblCodigoFalha.Size = new System.Drawing.Size(96, 13); this.lblCodigoFalha.TabIndex = 43; @@ -492,12 +493,24 @@ this.lblProgressoAtualizacao.TabIndex = 46; this.lblProgressoAtualizacao.Text = "(0,00%) Atualizando arquivos..."; // + // lblWifi + // + this.lblWifi.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lblWifi.AutoSize = true; + this.lblWifi.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblWifi.Location = new System.Drawing.Point(473, 501); + this.lblWifi.Name = "lblWifi"; + this.lblWifi.Size = new System.Drawing.Size(107, 13); + this.lblWifi.TabIndex = 47; + this.lblWifi.Text = "Wi-Fi: Desconectado"; + // // frmIHM // this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; this.ClientSize = new System.Drawing.Size(1024, 600); + this.Controls.Add(this.lblWifi); this.Controls.Add(this.lblProgressoAtualizacao); this.Controls.Add(this.pgbAtualizacaoArquivos); this.Controls.Add(this.picWifi); @@ -593,5 +606,6 @@ private System.Windows.Forms.PictureBox picWifi; public System.Windows.Forms.Label lblProgressoAtualizacao; public System.Windows.Forms.ProgressBar pgbAtualizacaoArquivos; + private System.Windows.Forms.Label lblWifi; } } \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs index 2225d13a9..98a1d750a 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs @@ -103,6 +103,7 @@ namespace AgroBase.Forms.IHM lblCodigoFalha.Click += LblCodigoFalha_Click; } + /* private async Task tmrDispositivos_Tick() { CodFalha = Variaveis.OperacaoEmAndamento.RetornaCodigoFalha(); @@ -148,12 +149,97 @@ namespace AgroBase.Forms.IHM bool mqttConectado = Variaveis.MqttService.StatusConexao(); lblMqtt.Text = "MQTT: " + (mqttConectado ? "Conectado" : "Desconectado"); lblMqtt.ForeColor = mqttConectado ? Color.Green : Color.Red; + bool wifiConectado = WifiService.WifiConectado; + bool wifiDisponivel = WifiService.WifiDisponivel; + lblWifi.Text = "Wi-Fi: " + (wifiConectado ? "Conectado" : wifiDisponivel ? "Disponível" : "Desconectado"); + lblWifi.ForeColor = wifiConectado ? Color.Green : wifiDisponivel ? Color.Yellow : Color.Red; bool opLiberada = Variaveis.OperacaoEmAndamento.OperacaoLiberada; lblOperacaoLiberada.Text = "Operação Liberada: " + (opLiberada ? "Sim" : "Não"); lblOperacaoLiberada.ForeColor = opLiberada ? Color.Green : Color.Red; lblCodigoFalha.Text = $"Código de Falha: {CodFalha}"; picWifi.Image = APIService.HasInternet ? Resources.wifi_on : Resources.wifi_off; } + */ + + + + private async Task tmrDispositivos_Tick() + { + try + { + // Atualizar controles da UI de forma segura + if (tmrDispositivos._uiControl.InvokeRequired) + { + tmrDispositivos._uiControl.Invoke(new Action(async () => await AtualizarControlesUI())); + } + else + { + await AtualizarControlesUI(); + } + } + catch (Exception ex) + { + Console.WriteLine($"Erro no tmrDispositivos_Tick: {ex.Message}"); + } + } + + private async Task AtualizarControlesUI() + { + CodFalha = Variaveis.OperacaoEmAndamento.RetornaCodigoFalha(); + + var Labels = this.Controls.OfType