diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/010e50a5-b17f-470f-b7b2-bccdd4b779d1.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/010e50a5-b17f-470f-b7b2-bccdd4b779d1.vsidx deleted file mode 100644 index 0a6466b95..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/010e50a5-b17f-470f-b7b2-bccdd4b779d1.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/0c05d349-67bb-4343-904d-0a334d5132f3.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/0c05d349-67bb-4343-904d-0a334d5132f3.vsidx new file mode 100644 index 000000000..e5eb0f6b8 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/0c05d349-67bb-4343-904d-0a334d5132f3.vsidx differ diff --git a/AgroBase/.vs/AgroBase/v17/.suo b/AgroBase/.vs/AgroBase/v17/.suo index ab1e9a845..9d1998088 100644 Binary files a/AgroBase/.vs/AgroBase/v17/.suo and b/AgroBase/.vs/AgroBase/v17/.suo differ diff --git a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.Designer.cs b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.Designer.cs index d302a5857..c9be182b2 100644 --- a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.Designer.cs +++ b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.Designer.cs @@ -44,9 +44,10 @@ namespace AgroBase.Forms this.pnlCamera.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.pnlCamera.Location = new System.Drawing.Point(12, 12); + this.pnlCamera.Location = new System.Drawing.Point(9, 10); + this.pnlCamera.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pnlCamera.Name = "pnlCamera"; - this.pnlCamera.Size = new System.Drawing.Size(600, 600); + this.pnlCamera.Size = new System.Drawing.Size(450, 488); this.pnlCamera.TabIndex = 0; // // pnlLeituras @@ -54,9 +55,10 @@ namespace AgroBase.Forms this.pnlLeituras.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.pnlLeituras.AutoScroll = true; - this.pnlLeituras.Location = new System.Drawing.Point(618, 147); + this.pnlLeituras.Location = new System.Drawing.Point(464, 119); + this.pnlLeituras.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pnlLeituras.Name = "pnlLeituras"; - this.pnlLeituras.Size = new System.Drawing.Size(188, 465); + this.pnlLeituras.Size = new System.Drawing.Size(141, 378); this.pnlLeituras.TabIndex = 6; // // gpbCameras @@ -66,19 +68,21 @@ namespace AgroBase.Forms this.gpbCameras.Controls.Add(this.btnAtualizar); this.gpbCameras.Controls.Add(this.btnSalvar); this.gpbCameras.Controls.Add(this.cmbCameras); - this.gpbCameras.Location = new System.Drawing.Point(618, 12); + this.gpbCameras.Location = new System.Drawing.Point(464, 10); + this.gpbCameras.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.gpbCameras.Name = "gpbCameras"; - this.gpbCameras.Size = new System.Drawing.Size(188, 129); + this.gpbCameras.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.gpbCameras.Size = new System.Drawing.Size(141, 105); this.gpbCameras.TabIndex = 7; this.gpbCameras.TabStop = false; this.gpbCameras.Text = "Cameras"; // // btnIniciar // - this.btnIniciar.Enabled = false; - this.btnIniciar.Location = new System.Drawing.Point(6, 89); + this.btnIniciar.Location = new System.Drawing.Point(4, 72); + this.btnIniciar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.btnIniciar.Name = "btnIniciar"; - this.btnIniciar.Size = new System.Drawing.Size(176, 28); + this.btnIniciar.Size = new System.Drawing.Size(132, 23); this.btnIniciar.TabIndex = 3; this.btnIniciar.Text = "Iniciar"; this.btnIniciar.UseVisualStyleBackColor = true; @@ -86,9 +90,10 @@ namespace AgroBase.Forms // // btnAtualizar // - this.btnAtualizar.Location = new System.Drawing.Point(6, 55); + this.btnAtualizar.Location = new System.Drawing.Point(4, 45); + this.btnAtualizar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.btnAtualizar.Name = "btnAtualizar"; - this.btnAtualizar.Size = new System.Drawing.Size(85, 28); + this.btnAtualizar.Size = new System.Drawing.Size(64, 23); this.btnAtualizar.TabIndex = 2; this.btnAtualizar.Text = "Atualizar"; this.btnAtualizar.UseVisualStyleBackColor = true; @@ -96,9 +101,10 @@ namespace AgroBase.Forms // // btnSalvar // - this.btnSalvar.Location = new System.Drawing.Point(97, 55); + this.btnSalvar.Location = new System.Drawing.Point(73, 45); + this.btnSalvar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.btnSalvar.Name = "btnSalvar"; - this.btnSalvar.Size = new System.Drawing.Size(85, 28); + this.btnSalvar.Size = new System.Drawing.Size(64, 23); this.btnSalvar.TabIndex = 1; this.btnSalvar.Text = "Editar"; this.btnSalvar.UseVisualStyleBackColor = true; @@ -109,19 +115,21 @@ namespace AgroBase.Forms this.cmbCameras.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbCameras.Enabled = false; this.cmbCameras.FormattingEnabled = true; - this.cmbCameras.Location = new System.Drawing.Point(6, 25); + this.cmbCameras.Location = new System.Drawing.Point(4, 20); + this.cmbCameras.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.cmbCameras.Name = "cmbCameras"; - this.cmbCameras.Size = new System.Drawing.Size(176, 24); + this.cmbCameras.Size = new System.Drawing.Size(133, 21); this.cmbCameras.TabIndex = 0; // // frmAtuCamera // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(818, 625); + this.ClientSize = new System.Drawing.Size(614, 508); this.Controls.Add(this.gpbCameras); this.Controls.Add(this.pnlLeituras); this.Controls.Add(this.pnlCamera); + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Name = "frmAtuCamera"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Identificação do solo"; diff --git a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs index d49ae5075..67a5099a5 100644 --- a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs +++ b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using AgroBase.Models; using AgroBase.Services; +using CefSharp.WinForms; using Newtonsoft.Json; using static MqttService; @@ -45,7 +46,7 @@ namespace AgroBase.Forms { try { - cameraSolo.camera.pythonProcess.Kill(); + cameraSolo.camera.pythonProcess?.Kill(); Variaveis.MqttService.UnsubscribeAsync(cameraSolo.camera._mqttTopico).ConfigureAwait(false); } catch (Exception ex) @@ -85,26 +86,82 @@ namespace AgroBase.Forms { VersaoArquivoModel ArquivoVersao = VersionamentoService.ArquivoModeloWeedDetector; - cameraSolo.camera.IniciarCamera( - Variaveis.OperacaoEmAndamento.DispAtu.Dados.ScriptDeteccaoErvas, - new string[] { - cameraSolo.MaxLeituras.ToString(), - cameraSolo.VideoPorta, - cameraSolo.VideoUrl, - cameraSolo.ArquivoLeitura, - "1", - cameraSolo.MqttTopico, - ArquivoVersao.Diretorio, - ArquivoVersao.Versao - }, - cameraSolo.VideoPorta, - cameraSolo.VideoUrl, - cameraSolo.MqttTopico - ); + string CamNome = "Cam_Solo_0"; + CameraSoloModel CameraSolo = new CameraSoloModel() + { + ID = "S0", + Nome = CamNome, + Posicao = 0, + ArquivoLeitura = "ervas_" + CamNome + ".json", + browser = null, + camera = new CameraService(), + CameraSelecionada = "123", + combo = new ComboBox(), + MaxLeituras = 1, + VideoPorta = (VariaveisPortas.CameraSolo + 0).ToString(), + VideoUrl = "green_objects_" + CamNome, + MqttTopico = "green_objects_" + CamNome, + }; + CameraSolo.panel = pnlCamera; + CameraSolo.camera.selectedCamera = 1; + IniciarCameraSolo(CameraSolo); tmrLeitura = new AsyncTaskTimerModel("tmrLeitura", tmrLeitura_Tick, 200); tmrLeitura.Start(); } + + public void IniciarCameraSolo(CameraSoloModel CameraSolo) + { + CameraSolo.DesligarCamera(); + + if (CameraSolo.camera.selectedCamera > 0) + { + VersaoArquivoModel ArquivoVersao = VersionamentoService.ArquivoModeloWeedDetector; + + //CameraSolo.IniciarRotinaProcesso(); + + CameraSolo.camera.IniciarCamera( + Variaveis.OperacaoEmAndamento.DispAtu.Dados.ScriptDeteccaoErvas, + new string[] { + CameraSolo.MaxLeituras.ToString(), + CameraSolo.VideoPorta, + CameraSolo.VideoUrl, + CameraSolo.ArquivoLeitura, + "0", + CameraSolo.MqttTopico, + ArquivoVersao.Diretorio, + ArquivoVersao.Versao, + }, + CameraSolo.VideoPorta, + CameraSolo.VideoUrl, + CameraSolo.MqttTopico, + async (Mensagem) => + { + if (Mensagem.Momento > CameraSolo.camera.IniciadoEm && Mensagem.Mensagem == "OK") + { + CameraSolo.camera.ProntoEm = Mensagem.Momento; + + if (CameraSolo.browser == null) + { + CameraSolo.Iniciada = true; + CameraSolo.browser = new ChromiumWebBrowser(CameraSolo.camera.URLcamera); + CameraSolo.browser.Dock = DockStyle.Fill; + + CameraSolo.panel.Invoke(new Action(() => + { + CameraSolo.panel.Controls.Add(CameraSolo.browser); + CameraSolo.panel.Refresh(); + })); + } + } + } + ); + } + else + { + Console.Write("Camera " + CameraSolo.Nome + " não foi configurada!"); + } + } private void AtualizaListaCameras() @@ -126,6 +183,12 @@ namespace AgroBase.Forms //var coordenadas = cameraService.AferirDadosCamera(); var MqttTopico = Variaveis.MqttService.Topicos.FirstOrDefault(x => x.Topico == cameraSolo.MqttTopico); + + if (MqttTopico == null) + { + return; + } + CameraCoordenadasFrameModel leitura = null; List msgs = new List(MqttTopico.Mensagens); var Mensagem = msgs.LastOrDefault(x => x.Momento > cameraSolo.camera.IniciadoEm); diff --git a/AgroBase/AgroBase/Forms/Sensoriamento/frmSenCamera.cs b/AgroBase/AgroBase/Forms/Sensoriamento/frmSenCamera.cs index 0a586b5e9..43bea8ea6 100644 --- a/AgroBase/AgroBase/Forms/Sensoriamento/frmSenCamera.cs +++ b/AgroBase/AgroBase/Forms/Sensoriamento/frmSenCamera.cs @@ -35,7 +35,7 @@ namespace AgroBase.Forms.Sensoriamento try { Variaveis.MqttService.UnsubscribeAsync(cameraService._mqttTopico).GetAwaiter().GetResult(); - cameraService.pythonProcess.Kill(); + cameraService.pythonProcess?.Kill(); } catch (Exception ex) { diff --git a/AgroBase/AgroBase/Forms/frmAcompanhamento.cs b/AgroBase/AgroBase/Forms/frmAcompanhamento.cs index 22490cbd7..d5b868e0b 100644 --- a/AgroBase/AgroBase/Forms/frmAcompanhamento.cs +++ b/AgroBase/AgroBase/Forms/frmAcompanhamento.cs @@ -229,15 +229,17 @@ namespace AgroBase.Forms PictureBox pic = (PictureBox)sender; string ID = pic.Name.Replace("pic", ""); + var SensorPot = Variaveis.OperacaoEmAndamento.DispSen.Dados.Sensores.FirstOrDefault(s => s.ID == "POT" + ID); + var Modulo = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.FirstOrDefault(m => m.Modulo_ID == ID); Label lblA_SP = pnlFundo.Controls.OfType