diff --git a/.gitignore b/.gitignore index b24d71e22..fa4dc64ff 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,7 @@ Thumbs.db *.mov *.wmv +# Ignorar a pasta Operacoes dentro da hierarquia completa +AgroBase/AgroBase/bin/Debug/Operacoes/ +AgroBase/AgroBase/bin/Debug/Logs/ +AgroBase/AgroBase/bin/Debug/Mapas/ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/0bca1e74-6312-4548-9bb3-522de7371a01.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/0bca1e74-6312-4548-9bb3-522de7371a01.vsidx new file mode 100644 index 000000000..0f6b0a0bb Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/0bca1e74-6312-4548-9bb3-522de7371a01.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/13ce5d41-8947-4413-a471-70292de66315.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/13ce5d41-8947-4413-a471-70292de66315.vsidx new file mode 100644 index 000000000..ad4db4aad Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/13ce5d41-8947-4413-a471-70292de66315.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/5753a2dd-3ec5-4b6d-b9c8-fc1ae52d1218.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/5753a2dd-3ec5-4b6d-b9c8-fc1ae52d1218.vsidx deleted file mode 100644 index 76650524f..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/5753a2dd-3ec5-4b6d-b9c8-fc1ae52d1218.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/7a2dde50-1bc9-41f0-93d8-656ccd0ce266.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/7a2dde50-1bc9-41f0-93d8-656ccd0ce266.vsidx deleted file mode 100644 index 0ffd67b76..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/7a2dde50-1bc9-41f0-93d8-656ccd0ce266.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/7cdda6e5-245b-4334-9a31-d88554ccc5a3.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/7cdda6e5-245b-4334-9a31-d88554ccc5a3.vsidx new file mode 100644 index 000000000..43bcd4a56 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/7cdda6e5-245b-4334-9a31-d88554ccc5a3.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/85a11f0a-37a9-41fb-b64d-60dcbe9fdfb8.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/85a11f0a-37a9-41fb-b64d-60dcbe9fdfb8.vsidx new file mode 100644 index 000000000..70aef67a0 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/85a11f0a-37a9-41fb-b64d-60dcbe9fdfb8.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/aae3de45-6122-405b-9a63-90137ea133b5.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/aae3de45-6122-405b-9a63-90137ea133b5.vsidx deleted file mode 100644 index 139a3a67f..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/aae3de45-6122-405b-9a63-90137ea133b5.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/e3b8dba0-66e9-464e-9248-69b89aeb1e5b.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/e3b8dba0-66e9-464e-9248-69b89aeb1e5b.vsidx deleted file mode 100644 index 7bc106ba8..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/e3b8dba0-66e9-464e-9248-69b89aeb1e5b.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/e9968570-3189-4753-8573-a6e18929a1d8.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/e9968570-3189-4753-8573-a6e18929a1d8.vsidx new file mode 100644 index 000000000..70aef67a0 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/e9968570-3189-4753-8573-a6e18929a1d8.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/f997866a-e219-404b-992e-41957466ea6f.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/f997866a-e219-404b-992e-41957466ea6f.vsidx deleted file mode 100644 index 4b282f8a5..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/f997866a-e219-404b-992e-41957466ea6f.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/v17/.suo b/AgroBase/.vs/AgroBase/v17/.suo index 1d36ac582..a5fd6e807 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 c5a328c42..16e401f0e 100644 --- a/AgroBase/AgroBase/AgroBase.csproj +++ b/AgroBase/AgroBase/AgroBase.csproj @@ -12,7 +12,7 @@ WinExe AgroBase AgroBase - v4.7.2 + v4.8 512 10.0 true @@ -112,6 +112,10 @@ ..\packages\OpenCvSharp4.Extensions.4.10.0.20240616\lib\netstandard2.0\OpenCvSharp.Extensions.dll + + False + .\OpenHardwareMonitorLib.dll + ..\packages\OpenTK.1.1.2225.0\lib\net20\OpenTK.dll @@ -429,7 +433,6 @@ - @@ -455,9 +458,7 @@ - - diff --git a/AgroBase/AgroBase/App.config b/AgroBase/AgroBase/App.config index 0b7ea32f4..8d0c9cf33 100644 --- a/AgroBase/AgroBase/App.config +++ b/AgroBase/AgroBase/App.config @@ -1,25 +1,25 @@ - + - + - - + + - - + + - - + + - - + + diff --git a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs index 91d17711d..ed6d81df5 100644 --- a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs +++ b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; using System.Drawing; using System.Linq; using System.Windows.Forms; diff --git a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs index cd7ffe8ae..07170ee44 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.Designer.cs @@ -50,6 +50,8 @@ 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(); @@ -72,6 +74,7 @@ ((System.ComponentModel.ISupportInitialize)(this.picDiagnosticarTudo)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picIniciarDiagnostico)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picLoading)).BeginInit(); + this.tabFalhas.SuspendLayout(); this.SuspendLayout(); // // tabControl1 @@ -84,6 +87,7 @@ this.tabControl1.Controls.Add(this.tabCameras); this.tabControl1.Controls.Add(this.tabSinaleiros); this.tabControl1.Controls.Add(this.tabResultados); + this.tabControl1.Controls.Add(this.tabFalhas); this.tabControl1.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tabControl1.Location = new System.Drawing.Point(100, 12); this.tabControl1.Name = "tabControl1"; @@ -94,10 +98,10 @@ // tabPulverizador // this.tabPulverizador.Controls.Add(this.dgPulverizador); - this.tabPulverizador.Location = new System.Drawing.Point(4, 40); + this.tabPulverizador.Location = new System.Drawing.Point(4, 38); this.tabPulverizador.Name = "tabPulverizador"; this.tabPulverizador.Padding = new System.Windows.Forms.Padding(3); - this.tabPulverizador.Size = new System.Drawing.Size(904, 532); + this.tabPulverizador.Size = new System.Drawing.Size(904, 534); this.tabPulverizador.TabIndex = 0; this.tabPulverizador.Text = "Pulverizador"; this.tabPulverizador.UseVisualStyleBackColor = true; @@ -117,10 +121,10 @@ // tabMovimentacao // this.tabMovimentacao.Controls.Add(this.dgMovimentacao); - this.tabMovimentacao.Location = new System.Drawing.Point(4, 34); + this.tabMovimentacao.Location = new System.Drawing.Point(4, 38); this.tabMovimentacao.Name = "tabMovimentacao"; this.tabMovimentacao.Padding = new System.Windows.Forms.Padding(3); - this.tabMovimentacao.Size = new System.Drawing.Size(680, 418); + this.tabMovimentacao.Size = new System.Drawing.Size(904, 534); this.tabMovimentacao.TabIndex = 1; this.tabMovimentacao.Text = "Movimentação"; this.tabMovimentacao.UseVisualStyleBackColor = true; @@ -163,10 +167,10 @@ // tabSensoriamento // this.tabSensoriamento.Controls.Add(this.dgSensoriamento); - this.tabSensoriamento.Location = new System.Drawing.Point(4, 34); + this.tabSensoriamento.Location = new System.Drawing.Point(4, 38); this.tabSensoriamento.Name = "tabSensoriamento"; this.tabSensoriamento.Padding = new System.Windows.Forms.Padding(3); - this.tabSensoriamento.Size = new System.Drawing.Size(680, 418); + this.tabSensoriamento.Size = new System.Drawing.Size(904, 534); this.tabSensoriamento.TabIndex = 3; this.tabSensoriamento.Text = "Sensoriamento"; this.tabSensoriamento.UseVisualStyleBackColor = true; @@ -186,10 +190,10 @@ // tabComunicacao // this.tabComunicacao.Controls.Add(this.dgComunicacao); - this.tabComunicacao.Location = new System.Drawing.Point(4, 34); + this.tabComunicacao.Location = new System.Drawing.Point(4, 38); this.tabComunicacao.Name = "tabComunicacao"; this.tabComunicacao.Padding = new System.Windows.Forms.Padding(3); - this.tabComunicacao.Size = new System.Drawing.Size(680, 418); + this.tabComunicacao.Size = new System.Drawing.Size(904, 534); this.tabComunicacao.TabIndex = 4; this.tabComunicacao.Text = "Comunicação"; this.tabComunicacao.UseVisualStyleBackColor = true; @@ -210,10 +214,10 @@ // this.tabCameras.Controls.Add(this.picCamera); this.tabCameras.Controls.Add(this.dgCameras); - this.tabCameras.Location = new System.Drawing.Point(4, 34); + this.tabCameras.Location = new System.Drawing.Point(4, 38); this.tabCameras.Name = "tabCameras"; this.tabCameras.Padding = new System.Windows.Forms.Padding(3); - this.tabCameras.Size = new System.Drawing.Size(680, 418); + this.tabCameras.Size = new System.Drawing.Size(904, 534); this.tabCameras.TabIndex = 5; this.tabCameras.Text = "Câmeras"; this.tabCameras.UseVisualStyleBackColor = true; @@ -242,10 +246,10 @@ // tabSinaleiros // this.tabSinaleiros.Controls.Add(this.dgSinaleiros); - this.tabSinaleiros.Location = new System.Drawing.Point(4, 34); + this.tabSinaleiros.Location = new System.Drawing.Point(4, 38); this.tabSinaleiros.Name = "tabSinaleiros"; this.tabSinaleiros.Padding = new System.Windows.Forms.Padding(3); - this.tabSinaleiros.Size = new System.Drawing.Size(680, 418); + this.tabSinaleiros.Size = new System.Drawing.Size(904, 534); this.tabSinaleiros.TabIndex = 6; this.tabSinaleiros.Text = "Sinaleiros"; this.tabSinaleiros.UseVisualStyleBackColor = true; @@ -265,10 +269,10 @@ // tabResultados // this.tabResultados.Controls.Add(this.dgResultados); - this.tabResultados.Location = new System.Drawing.Point(4, 34); + this.tabResultados.Location = new System.Drawing.Point(4, 38); this.tabResultados.Name = "tabResultados"; this.tabResultados.Padding = new System.Windows.Forms.Padding(3); - this.tabResultados.Size = new System.Drawing.Size(680, 418); + this.tabResultados.Size = new System.Drawing.Size(904, 534); this.tabResultados.TabIndex = 7; this.tabResultados.Text = "Resultados"; this.tabResultados.UseVisualStyleBackColor = true; @@ -327,6 +331,27 @@ 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); @@ -365,6 +390,7 @@ ((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); } @@ -393,5 +419,7 @@ private System.Windows.Forms.DataGridView dgResultados; private System.Windows.Forms.PictureBox picCamera; private System.Windows.Forms.PictureBox picLoading; + private System.Windows.Forms.TabPage tabFalhas; + private System.Windows.Forms.TreeView tvwFalhas; } } \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs index cf2a86627..56a8a72b3 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDiagnosticos.cs @@ -6,16 +6,10 @@ using AgroBase.Models.Modules; using AgroBase.Services; using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; using System.Drawing; using System.Linq; -using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using System.Windows.Forms.DataVisualization.Charting; using static AgroBase.Models.Enums; namespace AgroBase.Forms.IHM @@ -72,6 +66,8 @@ namespace AgroBase.Forms.IHM await IniciarDiagnostico(tabControl1.SelectedIndex); tabControl1.SelectedIndex = 6; await IniciarDiagnostico(tabControl1.SelectedIndex); + tabControl1.SelectedIndex = 8; + await IniciarDiagnostico(tabControl1.SelectedIndex); FinalizarDiagnostico(); picLoading.Image = null; @@ -183,11 +179,20 @@ namespace AgroBase.Forms.IHM PreencherDadosDiagnosticoCameras(Diagnosticos.FirstOrDefault(x => x.Modulo == T_Code.Cam)); PreencherDadosDiagnosticoSinaleiros(Diagnosticos.FirstOrDefault(x => x.Modulo == T_Code.Sen)); PreencherDadosTabelaResultado(dgResultados); + OperacaoModel.PopularTreeView(tvwFalhas, Variaveis.OperacaoEmAndamento.RetornaCodigoFalha()); } private async Task IniciarDiagnostico(int idx) { bool Sucesso = false; + + if (idx == 8) + { + OperacaoModel.PopularTreeView(tvwFalhas, Variaveis.OperacaoEmAndamento.RetornaCodigoFalha()); + + return true; + } + var Diagnostico = Diagnosticos[idx]; Diagnostico.Testes.ForEach(x => { @@ -523,8 +528,8 @@ namespace AgroBase.Forms.IHM { Componente = x.Modulo_ID, Teste = "Temperatura", - ValorPadrao = 85, - ComplementoValorPadrao = "<" + ValorPadrao = 10, + ComplementoValorPadrao = ">" }, new ColunasDiagnosticoModel() { @@ -598,10 +603,10 @@ namespace AgroBase.Forms.IHM var Testes = Diagnostico.Testes; TipoMovimentoDirecional _oldTipoMovimento = Variaveis.OperacaoEmAndamento.Controle.TipoMovimento; - int _oldRPM = Variaveis.OperacaoEmAndamento.Controle.RPM_SP; + double _oldPercentualVelocidade = Variaveis.OperacaoEmAndamento.Controle.PercentualVelocidadeSP; Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = TipoMovimentoDirecional.Diagnostico; - Variaveis.OperacaoEmAndamento.Controle.RPM_SP = 20; + Variaveis.OperacaoEmAndamento.Controle.PercentualVelocidadeSP = 20; DispositivosService Dispositivo = (DispositivosService)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == Enums.T_Code.Mvd); @@ -666,7 +671,7 @@ namespace AgroBase.Forms.IHM } Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = _oldTipoMovimento; - Variaveis.OperacaoEmAndamento.Controle.RPM_SP = _oldRPM; + Variaveis.OperacaoEmAndamento.Controle.PercentualVelocidadeSP = _oldPercentualVelocidade; return true; } diff --git a/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.Designer.cs b/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.Designer.cs index 9e2a30ee9..ae25445dc 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.Designer.cs @@ -61,6 +61,10 @@ this.lblModoOperacao = new System.Windows.Forms.Label(); this.txtModoOperacao = new System.Windows.Forms.TextBox(); this.pnlSensores = new System.Windows.Forms.Panel(); + this.lblOperacaoLiberada = new System.Windows.Forms.Label(); + this.txtOperacaoLiberada = new System.Windows.Forms.TextBox(); + this.pnlOrientacao = new System.Windows.Forms.Panel(); + this.pnlInclinacao = new System.Windows.Forms.Panel(); this.lblModoControle = new System.Windows.Forms.Label(); this.cmbModoControle = new System.Windows.Forms.ComboBox(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); @@ -71,13 +75,14 @@ this.tabSensores = new System.Windows.Forms.TabPage(); this.tabControle = new System.Windows.Forms.TabPage(); this.pnlControle = new System.Windows.Forms.Panel(); - this.tkbVelocidade = new System.Windows.Forms.TrackBar(); - this.lblVelocidade = new System.Windows.Forms.Label(); + this.pnlFreio = new System.Windows.Forms.Panel(); this.lblAnguloDirecional = new System.Windows.Forms.Label(); this.tkbAnguloDirecional = new System.Windows.Forms.TrackBar(); + this.lblVelocidade = new System.Windows.Forms.Label(); + this.tkbVelocidade = new System.Windows.Forms.TrackBar(); this.picFechar = new System.Windows.Forms.PictureBox(); - this.pnlOrientacao = new System.Windows.Forms.Panel(); - this.pnlInclinacao = new System.Windows.Forms.Panel(); + this.lblCodFalha = new System.Windows.Forms.Label(); + this.btnCodFalha = new System.Windows.Forms.Button(); this.pnlMapa.SuspendLayout(); this.pnlSensores.SuspendLayout(); this.statusStrip1.SuspendLayout(); @@ -85,8 +90,8 @@ this.tabSensores.SuspendLayout(); this.tabControle.SuspendLayout(); this.pnlControle.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.tkbVelocidade)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tkbAnguloDirecional)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.tkbVelocidade)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picFechar)).BeginInit(); this.SuspendLayout(); // @@ -139,7 +144,7 @@ // txtStatusAtual // this.txtStatusAtual.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.txtStatusAtual.Location = new System.Drawing.Point(164, 37); + this.txtStatusAtual.Location = new System.Drawing.Point(164, 101); this.txtStatusAtual.Name = "txtStatusAtual"; this.txtStatusAtual.ReadOnly = true; this.txtStatusAtual.Size = new System.Drawing.Size(120, 26); @@ -149,7 +154,7 @@ // lblStatusAtual // this.lblStatusAtual.AutoSize = true; - this.lblStatusAtual.Location = new System.Drawing.Point(3, 40); + this.lblStatusAtual.Location = new System.Drawing.Point(3, 104); this.lblStatusAtual.Name = "lblStatusAtual"; this.lblStatusAtual.Size = new System.Drawing.Size(97, 20); this.lblStatusAtual.TabIndex = 5; @@ -158,7 +163,7 @@ // txtIniciadoEm // this.txtIniciadoEm.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.txtIniciadoEm.Location = new System.Drawing.Point(164, 69); + this.txtIniciadoEm.Location = new System.Drawing.Point(164, 133); this.txtIniciadoEm.Name = "txtIniciadoEm"; this.txtIniciadoEm.ReadOnly = true; this.txtIniciadoEm.Size = new System.Drawing.Size(120, 26); @@ -168,7 +173,7 @@ // lblIniciadoEm // this.lblIniciadoEm.AutoSize = true; - this.lblIniciadoEm.Location = new System.Drawing.Point(3, 72); + this.lblIniciadoEm.Location = new System.Drawing.Point(3, 136); this.lblIniciadoEm.Name = "lblIniciadoEm"; this.lblIniciadoEm.Size = new System.Drawing.Size(92, 20); this.lblIniciadoEm.TabIndex = 7; @@ -177,7 +182,7 @@ // txtConcluidoEm // this.txtConcluidoEm.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.txtConcluidoEm.Location = new System.Drawing.Point(164, 101); + this.txtConcluidoEm.Location = new System.Drawing.Point(164, 165); this.txtConcluidoEm.Name = "txtConcluidoEm"; this.txtConcluidoEm.ReadOnly = true; this.txtConcluidoEm.Size = new System.Drawing.Size(120, 26); @@ -187,7 +192,7 @@ // lblConcluidoEm // this.lblConcluidoEm.AutoSize = true; - this.lblConcluidoEm.Location = new System.Drawing.Point(3, 104); + this.lblConcluidoEm.Location = new System.Drawing.Point(3, 168); this.lblConcluidoEm.Name = "lblConcluidoEm"; this.lblConcluidoEm.Size = new System.Drawing.Size(107, 20); this.lblConcluidoEm.TabIndex = 9; @@ -196,7 +201,7 @@ // txtDistanciaPercorrida // this.txtDistanciaPercorrida.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.txtDistanciaPercorrida.Location = new System.Drawing.Point(164, 133); + this.txtDistanciaPercorrida.Location = new System.Drawing.Point(164, 197); this.txtDistanciaPercorrida.Name = "txtDistanciaPercorrida"; this.txtDistanciaPercorrida.ReadOnly = true; this.txtDistanciaPercorrida.Size = new System.Drawing.Size(120, 26); @@ -206,7 +211,7 @@ // lblDistanciaPercorrida // this.lblDistanciaPercorrida.AutoSize = true; - this.lblDistanciaPercorrida.Location = new System.Drawing.Point(3, 136); + this.lblDistanciaPercorrida.Location = new System.Drawing.Point(3, 200); this.lblDistanciaPercorrida.Name = "lblDistanciaPercorrida"; this.lblDistanciaPercorrida.Size = new System.Drawing.Size(151, 20); this.lblDistanciaPercorrida.TabIndex = 11; @@ -215,7 +220,7 @@ // txtTempoOperacao // this.txtTempoOperacao.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.txtTempoOperacao.Location = new System.Drawing.Point(164, 165); + this.txtTempoOperacao.Location = new System.Drawing.Point(164, 229); this.txtTempoOperacao.Name = "txtTempoOperacao"; this.txtTempoOperacao.ReadOnly = true; this.txtTempoOperacao.Size = new System.Drawing.Size(120, 26); @@ -225,7 +230,7 @@ // lblTempoOperacao // this.lblTempoOperacao.AutoSize = true; - this.lblTempoOperacao.Location = new System.Drawing.Point(3, 168); + this.lblTempoOperacao.Location = new System.Drawing.Point(3, 232); this.lblTempoOperacao.Name = "lblTempoOperacao"; this.lblTempoOperacao.Size = new System.Drawing.Size(154, 20); this.lblTempoOperacao.TabIndex = 13; @@ -234,7 +239,7 @@ // txtErvasIdentificadas // this.txtErvasIdentificadas.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.txtErvasIdentificadas.Location = new System.Drawing.Point(164, 197); + this.txtErvasIdentificadas.Location = new System.Drawing.Point(164, 261); this.txtErvasIdentificadas.Name = "txtErvasIdentificadas"; this.txtErvasIdentificadas.ReadOnly = true; this.txtErvasIdentificadas.Size = new System.Drawing.Size(120, 26); @@ -244,7 +249,7 @@ // lblErvasIdentificadas // this.lblErvasIdentificadas.AutoSize = true; - this.lblErvasIdentificadas.Location = new System.Drawing.Point(3, 200); + this.lblErvasIdentificadas.Location = new System.Drawing.Point(3, 264); this.lblErvasIdentificadas.Name = "lblErvasIdentificadas"; this.lblErvasIdentificadas.Size = new System.Drawing.Size(144, 20); this.lblErvasIdentificadas.TabIndex = 15; @@ -253,7 +258,7 @@ // txtHerbicidaAplicado // this.txtHerbicidaAplicado.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.txtHerbicidaAplicado.Location = new System.Drawing.Point(164, 229); + this.txtHerbicidaAplicado.Location = new System.Drawing.Point(164, 293); this.txtHerbicidaAplicado.Name = "txtHerbicidaAplicado"; this.txtHerbicidaAplicado.ReadOnly = true; this.txtHerbicidaAplicado.Size = new System.Drawing.Size(120, 26); @@ -263,7 +268,7 @@ // lblHerbicidaAplicado // this.lblHerbicidaAplicado.AutoSize = true; - this.lblHerbicidaAplicado.Location = new System.Drawing.Point(3, 232); + this.lblHerbicidaAplicado.Location = new System.Drawing.Point(3, 296); this.lblHerbicidaAplicado.Name = "lblHerbicidaAplicado"; this.lblHerbicidaAplicado.Size = new System.Drawing.Size(141, 20); this.lblHerbicidaAplicado.TabIndex = 17; @@ -272,7 +277,7 @@ // txtBateriaConsumida // this.txtBateriaConsumida.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.txtBateriaConsumida.Location = new System.Drawing.Point(164, 261); + this.txtBateriaConsumida.Location = new System.Drawing.Point(164, 325); this.txtBateriaConsumida.Name = "txtBateriaConsumida"; this.txtBateriaConsumida.ReadOnly = true; this.txtBateriaConsumida.Size = new System.Drawing.Size(120, 26); @@ -282,7 +287,7 @@ // lblBateriaConsumida // this.lblBateriaConsumida.AutoSize = true; - this.lblBateriaConsumida.Location = new System.Drawing.Point(3, 264); + this.lblBateriaConsumida.Location = new System.Drawing.Point(3, 328); this.lblBateriaConsumida.Name = "lblBateriaConsumida"; this.lblBateriaConsumida.Size = new System.Drawing.Size(144, 20); this.lblBateriaConsumida.TabIndex = 19; @@ -290,7 +295,7 @@ // // pgbReservatorio // - this.pgbReservatorio.Location = new System.Drawing.Point(164, 293); + this.pgbReservatorio.Location = new System.Drawing.Point(164, 357); this.pgbReservatorio.Name = "pgbReservatorio"; this.pgbReservatorio.Size = new System.Drawing.Size(120, 26); this.pgbReservatorio.TabIndex = 21; @@ -298,7 +303,7 @@ // lblReservatorio // this.lblReservatorio.AutoSize = true; - this.lblReservatorio.Location = new System.Drawing.Point(3, 299); + this.lblReservatorio.Location = new System.Drawing.Point(3, 363); this.lblReservatorio.Name = "lblReservatorio"; this.lblReservatorio.Size = new System.Drawing.Size(127, 20); this.lblReservatorio.TabIndex = 23; @@ -307,7 +312,7 @@ // lblBateria // this.lblBateria.AutoSize = true; - this.lblBateria.Location = new System.Drawing.Point(3, 331); + this.lblBateria.Location = new System.Drawing.Point(3, 395); this.lblBateria.Name = "lblBateria"; this.lblBateria.Size = new System.Drawing.Size(88, 20); this.lblBateria.TabIndex = 25; @@ -315,7 +320,7 @@ // // pgbBateria // - this.pgbBateria.Location = new System.Drawing.Point(164, 325); + this.pgbBateria.Location = new System.Drawing.Point(164, 389); this.pgbBateria.Name = "pgbBateria"; this.pgbBateria.Size = new System.Drawing.Size(120, 26); this.pgbBateria.TabIndex = 24; @@ -323,7 +328,7 @@ // lblOperacao // this.lblOperacao.AutoSize = true; - this.lblOperacao.Location = new System.Drawing.Point(3, 363); + this.lblOperacao.Location = new System.Drawing.Point(3, 427); this.lblOperacao.Name = "lblOperacao"; this.lblOperacao.Size = new System.Drawing.Size(107, 20); this.lblOperacao.TabIndex = 27; @@ -331,7 +336,7 @@ // // pgbOperacao // - this.pgbOperacao.Location = new System.Drawing.Point(164, 357); + this.pgbOperacao.Location = new System.Drawing.Point(164, 421); this.pgbOperacao.Name = "pgbOperacao"; this.pgbOperacao.Size = new System.Drawing.Size(120, 26); this.pgbOperacao.TabIndex = 26; @@ -339,7 +344,7 @@ // lblRuaAtual // this.lblRuaAtual.AutoSize = true; - this.lblRuaAtual.Location = new System.Drawing.Point(3, 395); + this.lblRuaAtual.Location = new System.Drawing.Point(3, 459); this.lblRuaAtual.Name = "lblRuaAtual"; this.lblRuaAtual.Size = new System.Drawing.Size(108, 20); this.lblRuaAtual.TabIndex = 29; @@ -347,7 +352,7 @@ // // pgbRuaAtual // - this.pgbRuaAtual.Location = new System.Drawing.Point(164, 389); + this.pgbRuaAtual.Location = new System.Drawing.Point(164, 453); this.pgbRuaAtual.Name = "pgbRuaAtual"; this.pgbRuaAtual.Size = new System.Drawing.Size(120, 26); this.pgbRuaAtual.TabIndex = 28; @@ -374,6 +379,10 @@ // pnlSensores // this.pnlSensores.AutoScroll = true; + this.pnlSensores.Controls.Add(this.btnCodFalha); + this.pnlSensores.Controls.Add(this.lblCodFalha); + this.pnlSensores.Controls.Add(this.lblOperacaoLiberada); + this.pnlSensores.Controls.Add(this.txtOperacaoLiberada); this.pnlSensores.Controls.Add(this.pnlOrientacao); this.pnlSensores.Controls.Add(this.pnlInclinacao); this.pnlSensores.Controls.Add(this.lblModoOperacao); @@ -409,6 +418,49 @@ this.pnlSensores.Size = new System.Drawing.Size(307, 497); this.pnlSensores.TabIndex = 32; // + // lblOperacaoLiberada + // + this.lblOperacaoLiberada.AutoSize = true; + this.lblOperacaoLiberada.Location = new System.Drawing.Point(3, 40); + this.lblOperacaoLiberada.Name = "lblOperacaoLiberada"; + this.lblOperacaoLiberada.Size = new System.Drawing.Size(145, 20); + this.lblOperacaoLiberada.TabIndex = 30; + this.lblOperacaoLiberada.Text = "Operação Liberada"; + // + // txtOperacaoLiberada + // + this.txtOperacaoLiberada.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); + this.txtOperacaoLiberada.Location = new System.Drawing.Point(164, 37); + this.txtOperacaoLiberada.Name = "txtOperacaoLiberada"; + this.txtOperacaoLiberada.ReadOnly = true; + this.txtOperacaoLiberada.Size = new System.Drawing.Size(120, 26); + this.txtOperacaoLiberada.TabIndex = 31; + this.txtOperacaoLiberada.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // pnlOrientacao + // + this.pnlOrientacao.BackColor = System.Drawing.Color.White; + this.pnlOrientacao.BackgroundImage = global::AgroBase.Properties.Resources.rosa_dos_ventos; + this.pnlOrientacao.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.pnlOrientacao.Location = new System.Drawing.Point(184, 502); + this.pnlOrientacao.Margin = new System.Windows.Forms.Padding(2); + this.pnlOrientacao.Name = "pnlOrientacao"; + this.pnlOrientacao.Size = new System.Drawing.Size(100, 100); + this.pnlOrientacao.TabIndex = 12; + this.pnlOrientacao.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlOrientacao_Paint); + // + // pnlInclinacao + // + this.pnlInclinacao.BackColor = System.Drawing.Color.White; + this.pnlInclinacao.BackgroundImage = global::AgroBase.Properties.Resources.transferidor; + this.pnlInclinacao.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.pnlInclinacao.Location = new System.Drawing.Point(7, 502); + this.pnlInclinacao.Margin = new System.Windows.Forms.Padding(2); + this.pnlInclinacao.Name = "pnlInclinacao"; + this.pnlInclinacao.Size = new System.Drawing.Size(100, 100); + this.pnlInclinacao.TabIndex = 16; + this.pnlInclinacao.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlInclinacao_Paint); + // // lblModoControle // this.lblModoControle.AutoSize = true; @@ -428,7 +480,6 @@ this.cmbModoControle.Name = "cmbModoControle"; this.cmbModoControle.Size = new System.Drawing.Size(120, 28); this.cmbModoControle.TabIndex = 30; - this.cmbModoControle.SelectedIndexChanged += new System.EventHandler(this.cmbModoControle_SelectedIndexChanged_1); // // statusStrip1 // @@ -496,6 +547,7 @@ // pnlControle // this.pnlControle.AutoScroll = true; + this.pnlControle.Controls.Add(this.pnlFreio); this.pnlControle.Controls.Add(this.lblAnguloDirecional); this.pnlControle.Controls.Add(this.tkbAnguloDirecional); this.pnlControle.Controls.Add(this.lblVelocidade); @@ -509,26 +561,13 @@ this.pnlControle.Size = new System.Drawing.Size(307, 497); this.pnlControle.TabIndex = 0; // - // tkbVelocidade + // pnlFreio // - this.tkbVelocidade.Enabled = false; - this.tkbVelocidade.Location = new System.Drawing.Point(7, 98); - this.tkbVelocidade.Maximum = 100; - this.tkbVelocidade.Name = "tkbVelocidade"; - this.tkbVelocidade.Size = new System.Drawing.Size(277, 45); - this.tkbVelocidade.TabIndex = 32; - this.tkbVelocidade.TickFrequency = 10; - this.tkbVelocidade.Value = 30; - this.tkbVelocidade.Scroll += new System.EventHandler(this.tkbVelocidade_Scroll); - // - // lblVelocidade - // - this.lblVelocidade.AutoSize = true; - this.lblVelocidade.Location = new System.Drawing.Point(3, 75); - this.lblVelocidade.Name = "lblVelocidade"; - this.lblVelocidade.Size = new System.Drawing.Size(179, 20); - this.lblVelocidade.TabIndex = 33; - this.lblVelocidade.Text = "Velocidade: 30% 5 km/h"; + this.pnlFreio.Location = new System.Drawing.Point(134, 272); + this.pnlFreio.Name = "pnlFreio"; + this.pnlFreio.Size = new System.Drawing.Size(150, 150); + this.pnlFreio.TabIndex = 36; + this.pnlFreio.Visible = false; // // lblAnguloDirecional // @@ -551,6 +590,27 @@ this.tkbAnguloDirecional.Value = 20; this.tkbAnguloDirecional.Scroll += new System.EventHandler(this.tkbAnguloDirecional_Scroll); // + // lblVelocidade + // + this.lblVelocidade.AutoSize = true; + this.lblVelocidade.Location = new System.Drawing.Point(3, 75); + this.lblVelocidade.Name = "lblVelocidade"; + this.lblVelocidade.Size = new System.Drawing.Size(179, 20); + this.lblVelocidade.TabIndex = 33; + this.lblVelocidade.Text = "Velocidade: 30% 5 km/h"; + // + // tkbVelocidade + // + this.tkbVelocidade.Enabled = false; + this.tkbVelocidade.Location = new System.Drawing.Point(7, 98); + this.tkbVelocidade.Maximum = 100; + this.tkbVelocidade.Name = "tkbVelocidade"; + this.tkbVelocidade.Size = new System.Drawing.Size(277, 45); + this.tkbVelocidade.TabIndex = 32; + this.tkbVelocidade.TickFrequency = 10; + this.tkbVelocidade.Value = 30; + this.tkbVelocidade.Scroll += new System.EventHandler(this.tkbVelocidade_Scroll); + // // picFechar // this.picFechar.Image = global::AgroBase.Properties.Resources.fechar; @@ -561,29 +621,24 @@ this.picFechar.TabIndex = 1; this.picFechar.TabStop = false; // - // pnlOrientacao + // lblCodFalha // - this.pnlOrientacao.BackColor = System.Drawing.Color.White; - this.pnlOrientacao.BackgroundImage = global::AgroBase.Properties.Resources.rosa_dos_ventos; - this.pnlOrientacao.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.pnlOrientacao.Location = new System.Drawing.Point(184, 438); - this.pnlOrientacao.Margin = new System.Windows.Forms.Padding(2); - this.pnlOrientacao.Name = "pnlOrientacao"; - this.pnlOrientacao.Size = new System.Drawing.Size(100, 100); - this.pnlOrientacao.TabIndex = 12; - this.pnlOrientacao.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlOrientacao_Paint); + this.lblCodFalha.AutoSize = true; + this.lblCodFalha.Location = new System.Drawing.Point(3, 72); + this.lblCodFalha.Name = "lblCodFalha"; + this.lblCodFalha.Size = new System.Drawing.Size(125, 20); + this.lblCodFalha.TabIndex = 32; + this.lblCodFalha.Text = "Código de Falha"; // - // pnlInclinacao + // btnCodFalha // - this.pnlInclinacao.BackColor = System.Drawing.Color.White; - this.pnlInclinacao.BackgroundImage = global::AgroBase.Properties.Resources.transferidor; - this.pnlInclinacao.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.pnlInclinacao.Location = new System.Drawing.Point(7, 438); - this.pnlInclinacao.Margin = new System.Windows.Forms.Padding(2); - this.pnlInclinacao.Name = "pnlInclinacao"; - this.pnlInclinacao.Size = new System.Drawing.Size(100, 100); - this.pnlInclinacao.TabIndex = 16; - this.pnlInclinacao.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlInclinacao_Paint); + this.btnCodFalha.Location = new System.Drawing.Point(164, 69); + this.btnCodFalha.Name = "btnCodFalha"; + this.btnCodFalha.Size = new System.Drawing.Size(120, 26); + this.btnCodFalha.TabIndex = 33; + this.btnCodFalha.Text = "0"; + this.btnCodFalha.UseVisualStyleBackColor = true; + this.btnCodFalha.Click += new System.EventHandler(this.btnCodFalha_Click); // // frmDialogoMapa // @@ -604,6 +659,8 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "frmDialogoMapa"; this.TopMost = true; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmDialogoMapa_FormClosing); + this.Load += new System.EventHandler(this.frmDialogoMapa_Load); this.pnlMapa.ResumeLayout(false); this.pnlSensores.ResumeLayout(false); this.pnlSensores.PerformLayout(); @@ -614,8 +671,8 @@ this.tabControle.ResumeLayout(false); this.pnlControle.ResumeLayout(false); this.pnlControle.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.tkbVelocidade)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tkbAnguloDirecional)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.tkbVelocidade)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picFechar)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -674,5 +731,10 @@ private System.Windows.Forms.TrackBar tkbVelocidade; private System.Windows.Forms.Label lblAnguloDirecional; private System.Windows.Forms.TrackBar tkbAnguloDirecional; + private System.Windows.Forms.Panel pnlFreio; + private System.Windows.Forms.Label lblOperacaoLiberada; + private System.Windows.Forms.TextBox txtOperacaoLiberada; + private System.Windows.Forms.Button btnCodFalha; + private System.Windows.Forms.Label lblCodFalha; } } \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.cs b/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.cs index eb1e508f8..f3baba2f4 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.cs @@ -1,15 +1,10 @@ using AgroBase.Models; -using AgroBase.Models.Modules; using AgroBase.Services; -using CefSharp.DevTools.CSS; -using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -17,7 +12,8 @@ namespace AgroBase.Forms.IHM { public partial class frmDialogoMapa : Form { - Timer tmrLeitura = new Timer() { Interval = 500 }; + System.Timers.Timer tmrLeitura = new System.Timers.Timer() { Interval = 500 }; + private ulong CodigoFalha = 0; public frmDialogoMapa() { @@ -30,9 +26,9 @@ namespace AgroBase.Forms.IHM this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); pnlJoystick.GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(pnlJoystick, new object[] { ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true }); + pnlFreio.GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(pnlFreio, new object[] { ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true }); - tmrLeitura.Tick += tmrLeitura_Tick; - tmrLeitura.Start(); + tmrLeitura.Elapsed += tmrLeitura_Elapsed; cmbModoControle.Items.Clear(); cmbModoControle.Items.AddRange(Enum.GetNames(typeof(Enums.TipoMovimentoDirecional))); @@ -60,6 +56,18 @@ namespace AgroBase.Forms.IHM }); } + private void frmDialogoMapa_Load(object sender, EventArgs e) + { + tmrLeitura.Start(); + } + + private void frmDialogoMapa_FormClosing(object sender, FormClosingEventArgs e) + { + tmrLeitura.Stop(); + tmrLeitura.Elapsed -= tmrLeitura_Elapsed; + tmrLeitura.Dispose(); + } + public async Task AtualizarRuasSelecionadas(List ruasSelecionadas) { Variaveis.OperacaoEmAndamento.AtualizaListaCameras(pnlCameraCaminho, new List(){ pnlCameraSoloE, pnlCameraSoloD }, true); @@ -70,58 +78,68 @@ namespace AgroBase.Forms.IHM public void IniciarOperacao() { - Variaveis.OperacaoEmAndamento.IniciarOperacao(); + Task.Run(async () => { + await Variaveis.OperacaoEmAndamento.IniciarOperacao(); - InicializarModoManual(); + //InicializarModoManual(); + }); } - private void tmrLeitura_Tick(object sender, EventArgs e) + private void tmrLeitura_Elapsed(object sender, EventArgs e) { - pnlOrientacao.Invalidate(); - pnlInclinacao.Invalidate(); + pnlOrientacao.Invoke((MethodInvoker)delegate { + pnlOrientacao.Invalidate(); + pnlInclinacao.Invalidate(); - var ultimaLeitura = Variaveis.OperacaoEmAndamento.CamerasSolo.OrderByDescending(x => x.Leitura.timestamp).FirstOrDefault(); - if (ultimaLeitura != null) - { - lblUltimaLeituraSolo.Text = "Última Leitura Solo: " + FuncoesGlobais.TimestampToDate(ultimaLeitura.Leitura.timestamp); - } - if (Variaveis.OperacaoEmAndamento.CameraCaminhoKinect != null) - { - lblUltimaLeituraCaminho.Text = "Última Leitura Caminho: " + FuncoesGlobais.TimestampToDate(Variaveis.OperacaoEmAndamento.CameraCaminhoKinect.Leitura.timestamp); - } - lblPerformance.Text = Variaveis.OperacaoEmAndamento.PerformanceStr; + var ultimaLeitura = Variaveis.OperacaoEmAndamento.CamerasSolo.OrderByDescending(x => x.Leitura.timestamp).FirstOrDefault(); + if (ultimaLeitura != null) + { + lblUltimaLeituraSolo.Text = "Última Leitura Solo: " + FuncoesGlobais.TimestampToDate(ultimaLeitura.Leitura.timestamp); + } + if (Variaveis.OperacaoEmAndamento.CameraCaminhoKinect != null) + { + lblUltimaLeituraCaminho.Text = "Última Leitura Caminho: " + FuncoesGlobais.TimestampToDate(Variaveis.OperacaoEmAndamento.CameraCaminhoKinect.Leitura.timestamp); + } + lblPerformance.Text = Variaveis.OperacaoEmAndamento.PerformanceStr; - txtModoOperacao.Text = Variaveis.OperacaoEmAndamento.Modo.ToString(); - txtStatusAtual.Text = Variaveis.OperacaoEmAndamento.StatusAtual.ToString(); - txtIniciadoEm.Text = new DateTime(Variaveis.OperacaoEmAndamento.TimestampInicio).ToString("dd/MM HH:mm:ss"); - txtConcluidoEm.Text = new DateTime(Variaveis.OperacaoEmAndamento.TimestampFim).ToString("dd/MM HH:mm:ss"); - txtDistanciaPercorrida.Text = Variaveis.OperacaoEmAndamento.Sensoriamento.DistanciaPercorrida.Sum().ToString("0.00") + " m"; - txtTempoOperacao.Text = Variaveis.OperacaoEmAndamento.Tempo.Hours.ToString("00") + ":" + Variaveis.OperacaoEmAndamento.Tempo.Minutes.ToString("00") + ":" + Variaveis.OperacaoEmAndamento.Tempo.Seconds.ToString("00"); - txtErvasIdentificadas.Text = Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ErvasIdentificadas.ToString("000"); - txtHerbicidaAplicado.Text = Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.HerbicidaConsumido.ToString("0.000") + " L"; - txtBateriaConsumida.Text = Variaveis.OperacaoEmAndamento.Sensoriamento.BateriaConsumida.ToString("0.00") + "%"; + lblMapaCarregado.Text = "Operação: " + Variaveis.OperacaoEmAndamento.Descricao; - FuncoesGlobais.PreencheValorProgressBar(pgbReservatorio, Variaveis.OperacaoEmAndamento.DispAtu.Dados.PercentualReservatorio); - lblReservatorio.Text = "Reservatório: " + (Variaveis.OperacaoEmAndamento.DispAtu.Dados.PercentualReservatorio < 0 ? 0 : Variaveis.OperacaoEmAndamento.DispAtu.Dados.PercentualReservatorio).ToString("0.00") + "%"; + txtModoOperacao.Text = Variaveis.OperacaoEmAndamento.Modo.ToString(); + bool opLiberada = Variaveis.OperacaoEmAndamento.OperacaoLiberada; + txtOperacaoLiberada.Text = opLiberada ? "Sim" : "Não"; + txtOperacaoLiberada.ForeColor = opLiberada ? Color.Black : Color.Red; + CodigoFalha = Variaveis.OperacaoEmAndamento.RetornaCodigoFalha(); + btnCodFalha.Text = CodigoFalha.ToString(); + txtStatusAtual.Text = Variaveis.OperacaoEmAndamento.StatusAtual.ToString(); + txtIniciadoEm.Text = Variaveis.OperacaoEmAndamento.TimestampInicio == 0 ? "Aguardando" : new DateTime(Variaveis.OperacaoEmAndamento.TimestampInicio).ToString("dd/MM HH:mm:ss"); + txtConcluidoEm.Text = Variaveis.OperacaoEmAndamento.TimestampFim == 0 ? "Aguardando" : new DateTime(Variaveis.OperacaoEmAndamento.TimestampFim).ToString("dd/MM HH:mm:ss"); + txtDistanciaPercorrida.Text = Variaveis.OperacaoEmAndamento.Sensoriamento.DistanciaPercorrida.Sum().ToString("0.00") + " m"; + txtTempoOperacao.Text = Variaveis.OperacaoEmAndamento.Tempo.Hours.ToString("00") + ":" + Variaveis.OperacaoEmAndamento.Tempo.Minutes.ToString("00") + ":" + Variaveis.OperacaoEmAndamento.Tempo.Seconds.ToString("00"); + txtErvasIdentificadas.Text = Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ErvasIdentificadas.ToString(); + txtHerbicidaAplicado.Text = Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.HerbicidaConsumido.ToString("0.000") + " L"; + txtBateriaConsumida.Text = Variaveis.OperacaoEmAndamento.Sensoriamento.BateriaConsumida.ToString("0.00") + " %"; - FuncoesGlobais.PreencheValorProgressBar(pgbBateria, Variaveis.OperacaoEmAndamento.Sensoriamento.PorcentagemBateria); - lblBateria.Text = "Bateria: " + (PZEMService.Iniciado && PZEMService.UltimaLeitura != null ? PZEMService.UltimaLeitura.Tensao.ToString("0.00") + "v " + PZEMService.UltimaLeitura.Corrente.ToString("0.00") + "A " : "") + (Variaveis.OperacaoEmAndamento.Sensoriamento.PorcentagemBateria < 0 ? 0 : Variaveis.OperacaoEmAndamento.Sensoriamento.PorcentagemBateria).ToString("0.00") + "%"; + FuncoesGlobais.PreencheValorProgressBar(pgbReservatorio, Variaveis.OperacaoEmAndamento.DispAtu.Dados.PercentualReservatorio); + lblReservatorio.Text = "Reservatório: " + (Variaveis.OperacaoEmAndamento.DispAtu.Dados.PercentualReservatorio < 0 ? 0 : Variaveis.OperacaoEmAndamento.DispAtu.Dados.PercentualReservatorio).ToString("0.00") + "%"; - FuncoesGlobais.PreencheValorProgressBar(pgbOperacao, Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoTrajeto); - lblOperacao.Text = "Operação: " + (Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoTrajeto < 0 ? 0 : Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoTrajeto).ToString("0.00") + "%"; - FuncoesGlobais.PreencheValorProgressBar(pgbRuaAtual, Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoRua); - lblRuaAtual.Text = "Rua Atual: " + (Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoRua < 0 ? 0 : Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoRua).ToString("0.00") + "%"; + FuncoesGlobais.PreencheValorProgressBar(pgbBateria, Variaveis.OperacaoEmAndamento.Sensoriamento.PorcentagemBateria); + lblBateria.Text = "Bateria: " + (PZEMService.Iniciado && PZEMService.UltimaLeitura != null ? PZEMService.UltimaLeitura.Tensao.ToString("0.00") + "v " + PZEMService.UltimaLeitura.Corrente.ToString("0.00") + "A " : "") + (Variaveis.OperacaoEmAndamento.Sensoriamento.PorcentagemBateria < 0 ? 0 : Variaveis.OperacaoEmAndamento.Sensoriamento.PorcentagemBateria).ToString("0.00") + "%"; - if (Variaveis.OperacaoEmAndamento.Modo != Enums.ModoOperacao.Manual) - { - cmbModoControle.SelectedIndex = (int)Variaveis.OperacaoEmAndamento.Controle.TipoMovimento; + FuncoesGlobais.PreencheValorProgressBar(pgbOperacao, Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoTrajeto); + lblOperacao.Text = "Operação: " + (Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoTrajeto < 0 ? 0 : Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoTrajeto).ToString("0.00") + "%"; + FuncoesGlobais.PreencheValorProgressBar(pgbRuaAtual, Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoRua); + lblRuaAtual.Text = "Rua Atual: " + (Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoRua < 0 ? 0 : Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoRua).ToString("0.00") + "%"; - double Percentual = (Variaveis.OperacaoEmAndamento.Controle.RPM_SP / (Variaveis.OperacaoEmAndamento.Controle.RPM_Max / VariaveisEquipamento.RelacaoRPM)) * 100.0; - tkbVelocidade.Value = Convert.ToInt32(Percentual); + if (Variaveis.OperacaoEmAndamento.Modo != Enums.ModoOperacao.Manual) + { + cmbModoControle.SelectedIndex = (int)Variaveis.OperacaoEmAndamento.Controle.TipoMovimento; - tkbAnguloDirecional.Value = Math.Abs(Convert.ToInt32(Variaveis.OperacaoEmAndamento.Controle.Angulo)); - } + double Percentual = (Variaveis.OperacaoEmAndamento.Controle.RPM_SP / VariaveisEquipamento.RPM_Max_Roda) * 100.0; + tkbVelocidade.Value = Convert.ToInt32(Percentual); + tkbAnguloDirecional.Value = Math.Abs(Convert.ToInt32(Variaveis.OperacaoEmAndamento.Controle.Angulo)); + } + }); } private void pnlOrientacao_Paint(object sender, PaintEventArgs e) @@ -154,6 +172,11 @@ namespace AgroBase.Forms.IHM private int joystickRadius; private Point joystickPosition; + private Point freioPosition; + private Point freioStartPosition; + private bool isDraggingFreio = false; + private bool isBrakeLocked = false; + private void AtualizarElementosModoManual() { cmbModoControle.Enabled = false; @@ -161,18 +184,19 @@ namespace AgroBase.Forms.IHM tkbVelocidade.Enabled = false; pnlJoystick.Visible = false; + cmbModoControle.SelectedIndex = (int)Variaveis.OperacaoEmAndamento.Controle.TipoMovimento; + tkbAnguloDirecional.Minimum = 0; tkbAnguloDirecional.Maximum = Convert.ToInt32(Variaveis.OperacaoEmAndamento.Controle.Angulo_Max); - tkbAnguloDirecional.Value = Convert.ToInt32(Variaveis.OperacaoEmAndamento.Controle.Angulo); + FuncoesGlobais.PreencheValorTrackBar(tkbAnguloDirecional, Variaveis.OperacaoEmAndamento.Controle.Angulo); - double Percentual = (Variaveis.OperacaoEmAndamento.Controle.RPM_SP / (Variaveis.OperacaoEmAndamento.Controle.RPM_Max / VariaveisEquipamento.RelacaoRPM)) * 100.0; - tkbVelocidade.Value = Convert.ToInt32(Percentual); + FuncoesGlobais.PreencheValorTrackBar(tkbVelocidade, Variaveis.OperacaoEmAndamento.Controle.PercentualVelocidadeSP); tkbVelocidade_Scroll(null, null); tkbAnguloDirecional_Scroll(null, null); } - private void InicializarModoManual() + public void InicializarModoManual() { AtualizarElementosModoManual(); @@ -190,9 +214,10 @@ namespace AgroBase.Forms.IHM tkbAnguloDirecional.Enabled = true; pnlJoystick.Visible = true; + pnlFreio.Visible = true; // Configurar o painel do joystick - pnlJoystick.BackColor = Color.FromArgb(128, 0, 0, 0); // Fundo semitransparente + pnlJoystick.BackColor = Color.LightGray; // Fundo semitransparente // Definir região circular para o painel System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); @@ -214,12 +239,26 @@ namespace AgroBase.Forms.IHM pnlJoystick.MouseMove += PanelJoystickBack_MouseMove; pnlJoystick.MouseUp += PanelJoystickBack_MouseUp; + pnlFreio.BackColor = Color.LightGray; + pnlFreio.BorderStyle = BorderStyle.FixedSingle; + + // Eventos de toque/pressão + pnlFreio.Paint += BrakePanel_Paint; + pnlFreio.MouseDown += BrakePanel_MouseDown; + pnlFreio.MouseMove += BrakePanel_MouseMove; + pnlFreio.MouseUp += BrakePanel_MouseUp; + + // Configuração inicial do freio + freioStartPosition = new Point(pnlFreio.Width / 2 - 20, 10); + freioPosition = freioStartPosition; + Variaveis.OperacaoEmAndamento.AtualizaListaCameras(pnlCameraCaminho, new List() { pnlCameraSoloE, pnlCameraSoloD }, true); IniciarOperacao(); } } + #region JOYSTICK private void PanelJoystickBack_Paint(object sender, PaintEventArgs e) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; @@ -300,22 +339,104 @@ namespace AgroBase.Forms.IHM } } - private void CmbModoControle_SelectedIndexChanged(object sender, EventArgs e) + #endregion + + #region FREIO + // Desenho do trilho e trava no painel do freio + private void BrakePanel_Paint(object sender, PaintEventArgs e) { - Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = (Enums.TipoMovimentoDirecional)cmbModoControle.SelectedIndex; + Panel panel = sender as Panel; + e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + + // Desenhar trilha do freio (trajetória vertical) + e.Graphics.DrawLine(new Pen(Color.Black, 5), panel.Width / 2, 10, panel.Width / 2, panel.Height - 50); + + // Desenhar a área de trava (na lateral direita) + e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), panel.Width - 30, panel.Height - 60, 20, 40); + + // Desenhar o botão de freio atual + e.Graphics.FillEllipse(Brushes.Red, freioPosition.X, freioPosition.Y, 40, 40); } - private void cmbModoControle_SelectedIndexChanged_1(object sender, EventArgs e) + // Iniciar o arraste + private void BrakePanel_MouseDown(object sender, MouseEventArgs e) + { + if (new Rectangle(freioPosition.X, freioPosition.Y, 40, 40).Contains(e.Location)) + { + isDraggingFreio = true; + } + } + + // Movimentar o botão de freio + private void BrakePanel_MouseMove(object sender, MouseEventArgs e) + { + if (isDraggingFreio) + { + // Calcula a posição ao arrastar + int deltaY = e.Y - freioPosition.Y; + int newPosX = freioPosition.X; + int newPosY = freioPosition.Y + deltaY; + + // Limitar o movimento do freio ao trilho e destravar se o usuário mover para fora da trava + if (!isBrakeLocked || (isBrakeLocked && e.X < pnlFreio.Width - 30)) + { + isBrakeLocked = false; // Destrava o freio se mover para fora + + // Restringe o movimento vertical dentro da área do trilho + if (newPosY >= 10 && newPosY <= pnlFreio.Height - 50) + { + freioPosition = new Point(newPosX, newPosY); + pnlFreio.Invalidate(); // Redesenha o painel + + // Enviar comando de freio + GeneralJoystick.EnviaComandoMotor(Keys.Space, Enums.T_Code.Mov); + } + } + + // Verifica se o usuário está na área de trava + if (freioPosition.Y >= pnlFreio.Height - 90 && e.X >= pnlFreio.Width - 30) + { + isBrakeLocked = true; // Freio travado + freioPosition = new Point(pnlFreio.Width - 40, pnlFreio.Height - 60); // Posiciona o freio na trava + pnlFreio.Invalidate(); + } + } + } + + // Soltar o botão de freio + private void BrakePanel_MouseUp(object sender, MouseEventArgs e) + { + isDraggingFreio = false; + + if (!isBrakeLocked) + { + // Se o freio não estiver travado, retorna à posição inicial + freioPosition = freioStartPosition; + pnlFreio.Invalidate(); // Redesenha o painel + + // Enviar comando para desativar o freio + GeneralJoystick.EnviaComandoMotor(Keys.Escape, Enums.T_Code.Mov); + } + else + { + // Freio travado, mantém travado + GeneralJoystick.EnviaComandoMotor(Keys.Space, Enums.T_Code.Mov); + } + } + + #endregion + + private void CmbModoControle_SelectedIndexChanged(object sender, EventArgs e) { Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = (Enums.TipoMovimentoDirecional)cmbModoControle.SelectedIndex; } private void tkbVelocidade_Scroll(object sender, EventArgs e) { - double RPM = (tkbVelocidade.Value / 100.0) * Variaveis.OperacaoEmAndamento.Controle.RPM_Max / VariaveisEquipamento.RelacaoRPM; + double RPM = (tkbVelocidade.Value / 100.0) * VariaveisEquipamento.RPM_Max_Roda; double Velocidade = MovimentacaoModel.CalculaVelocidadeRPM(RPM); - Variaveis.OperacaoEmAndamento.Controle.RPM_SP = Convert.ToInt32(RPM); + Variaveis.OperacaoEmAndamento.Controle.PercentualVelocidadeSP = tkbVelocidade.Value; lblVelocidade.Text = $"Velocidade: {tkbVelocidade.Value}% {Velocidade.ToString("0.00")} km/h"; } @@ -330,6 +451,11 @@ namespace AgroBase.Forms.IHM #endregion - + private void btnCodFalha_Click(object sender, EventArgs e) + { + string DescricaoFalha = OperacaoModel.DescricaoCodigoFalha(CodigoFalha); + MessageBox.Show($"{DescricaoFalha}", "Código de Falha", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } } diff --git a/AgroBase/AgroBase/Forms/IHM/frmIHM.Designer.cs b/AgroBase/AgroBase/Forms/IHM/frmIHM.Designer.cs index ebeaa1562..5e90df362 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmIHM.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmIHM.Designer.cs @@ -60,6 +60,8 @@ this.lblD_A05 = new System.Windows.Forms.Label(); this.lblStatus = new System.Windows.Forms.Label(); this.lblVersao = new System.Windows.Forms.Label(); + this.lblOperacaoLiberada = new System.Windows.Forms.Label(); + this.lblCodigoFalha = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picManual)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picDiagnosticos)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picOperacao)).BeginInit(); @@ -120,7 +122,7 @@ this.lblMqtt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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, 578); + this.lblMqtt.Location = new System.Drawing.Point(473, 508); this.lblMqtt.Name = "lblMqtt"; this.lblMqtt.Size = new System.Drawing.Size(114, 13); this.lblMqtt.TabIndex = 13; @@ -318,7 +320,7 @@ this.lblDesligar.AutoSize = true; this.lblDesligar.BackColor = System.Drawing.Color.Transparent; this.lblDesligar.Cursor = System.Windows.Forms.Cursors.Hand; - this.lblDesligar.Location = new System.Drawing.Point(850, 517); + this.lblDesligar.Location = new System.Drawing.Point(850, 383); this.lblDesligar.Name = "lblDesligar"; this.lblDesligar.Size = new System.Drawing.Size(102, 24); this.lblDesligar.TabIndex = 36; @@ -329,7 +331,7 @@ this.lblModoManual.AutoSize = true; this.lblModoManual.BackColor = System.Drawing.Color.Transparent; this.lblModoManual.Cursor = System.Windows.Forms.Cursors.Hand; - this.lblModoManual.Location = new System.Drawing.Point(489, 517); + this.lblModoManual.Location = new System.Drawing.Point(489, 383); this.lblModoManual.Name = "lblModoManual"; this.lblModoManual.Size = new System.Drawing.Size(153, 24); this.lblModoManual.TabIndex = 38; @@ -339,7 +341,7 @@ // this.picManual.Cursor = System.Windows.Forms.Cursors.Default; this.picManual.Image = global::AgroBase.Properties.Resources.joystick; - this.picManual.Location = new System.Drawing.Point(491, 364); + this.picManual.Location = new System.Drawing.Point(491, 230); this.picManual.Name = "picManual"; this.picManual.Size = new System.Drawing.Size(150, 150); this.picManual.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -383,7 +385,7 @@ // this.picDesligar.Cursor = System.Windows.Forms.Cursors.Default; this.picDesligar.Image = global::AgroBase.Properties.Resources.desligar; - this.picDesligar.Location = new System.Drawing.Point(827, 364); + this.picDesligar.Location = new System.Drawing.Point(827, 230); this.picDesligar.Name = "picDesligar"; this.picDesligar.Size = new System.Drawing.Size(150, 150); this.picDesligar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -416,11 +418,11 @@ this.lblStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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(933, 578); + this.lblStatus.Location = new System.Drawing.Point(473, 558); this.lblStatus.Name = "lblStatus"; - this.lblStatus.Size = new System.Drawing.Size(44, 13); + this.lblStatus.Size = new System.Drawing.Size(84, 13); this.lblStatus.TabIndex = 40; - this.lblStatus.Text = "Iniciado"; + this.lblStatus.Text = "Sistema Iniciado"; // // lblVersao // @@ -433,12 +435,37 @@ this.lblVersao.TabIndex = 41; this.lblVersao.Text = "v 0"; // + // lblOperacaoLiberada + // + this.lblOperacaoLiberada.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + 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, 481); + this.lblOperacaoLiberada.Name = "lblOperacaoLiberada"; + this.lblOperacaoLiberada.Size = new System.Drawing.Size(124, 13); + this.lblOperacaoLiberada.TabIndex = 42; + this.lblOperacaoLiberada.Text = "Operação Liberada: Não"; + // + // lblCodigoFalha + // + this.lblCodigoFalha.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + 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, 534); + this.lblCodigoFalha.Name = "lblCodigoFalha"; + this.lblCodigoFalha.Size = new System.Drawing.Size(96, 13); + this.lblCodigoFalha.TabIndex = 43; + this.lblCodigoFalha.Text = "Código de Falha: 0"; + // // 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.lblCodigoFalha); + this.Controls.Add(this.lblOperacaoLiberada); this.Controls.Add(this.lblVersao); this.Controls.Add(this.lblStatus); this.Controls.Add(this.lblD_A05); @@ -523,5 +550,7 @@ private System.Windows.Forms.Label lblD_A05; public System.Windows.Forms.Label lblStatus; public System.Windows.Forms.Label lblVersao; + private System.Windows.Forms.Label lblOperacaoLiberada; + private System.Windows.Forms.Label lblCodigoFalha; } } \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs index f5d61f696..3065fa5ee 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs @@ -1,17 +1,11 @@ -using AgroBase.Comum; -using AgroBase.Forms.Operacoes; +using AgroBase.Forms.Operacoes; using AgroBase.Models; using AgroBase.Services; using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; -using System.IO.Ports; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Timers; using System.Windows.Forms; using static AgroBase.Models.Enums; @@ -21,6 +15,7 @@ namespace AgroBase.Forms.IHM public partial class frmIHM : Form { System.Timers.Timer tmrDispositivos = new System.Timers.Timer() { Interval = 1000, Enabled = false }; + public ulong CodFalha = 0; public frmIHM() { @@ -47,8 +42,8 @@ namespace AgroBase.Forms.IHM if (Variaveis.OperacaoEmAndamento.OperacaoLiberada) { frmDialogoMapa frm = new frmDialogoMapa(); - frm.ShowDialog(); - frm.IniciarOperacao(); + frm.Show(); + frm.InicializarModoManual(); } else { @@ -76,10 +71,22 @@ namespace AgroBase.Forms.IHM lblVersao.Text = "v " + Variaveis.Versao; tmrDispositivos.Elapsed += TmrDispositivos_Elapsed; tmrDispositivos.Start(); + + lblCodigoFalha.Click += LblCodigoFalha_Click; } - private void TmrDispositivos_Elapsed(object sender, ElapsedEventArgs e) + private void LblCodigoFalha_Click(object sender, EventArgs e) { + string DescricaoFalha = OperacaoModel.DescricaoCodigoFalha(CodFalha); + MessageBox.Show($"{DescricaoFalha}", "Código de Falha", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + private async void TmrDispositivos_Elapsed(object sender, ElapsedEventArgs e) + { + ((System.Timers.Timer)sender).Stop(); + + CodFalha = Variaveis.OperacaoEmAndamento.RetornaCodigoFalha(); + Func funcao = new Func(() => { var Labels = this.Controls.OfType