diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/05038398-ed85-46e8-8295-277da564b456.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/05038398-ed85-46e8-8295-277da564b456.vsidx new file mode 100644 index 000000000..56ba8d068 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/05038398-ed85-46e8-8295-277da564b456.vsidx 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 deleted file mode 100644 index e5eb0f6b8..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/0c05d349-67bb-4343-904d-0a334d5132f3.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/2e776a8c-1563-4357-bf37-defd42c77c61.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/2e776a8c-1563-4357-bf37-defd42c77c61.vsidx new file mode 100644 index 000000000..ea0ad9f96 Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/2e776a8c-1563-4357-bf37-defd42c77c61.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/5c30e279-b5fe-46ab-8d25-11b4a79f7250.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/5c30e279-b5fe-46ab-8d25-11b4a79f7250.vsidx new file mode 100644 index 000000000..8ea3207bc Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/5c30e279-b5fe-46ab-8d25-11b4a79f7250.vsidx differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/bc6e62e0-333c-4547-8e49-96f5c258c405.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/bc6e62e0-333c-4547-8e49-96f5c258c405.vsidx deleted file mode 100644 index 0e8ca7348..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/bc6e62e0-333c-4547-8e49-96f5c258c405.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/fe89c43d-ec1d-4780-a261-55cb0014e40c.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/fe89c43d-ec1d-4780-a261-55cb0014e40c.vsidx deleted file mode 100644 index da4b32ff3..000000000 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/fe89c43d-ec1d-4780-a261-55cb0014e40c.vsidx and /dev/null differ diff --git a/AgroBase/.vs/AgroBase/v17/.suo b/AgroBase/.vs/AgroBase/v17/.suo index 9d1998088..011642568 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 843fafbcf..2ba9773e5 100644 --- a/AgroBase/AgroBase/AgroBase.csproj +++ b/AgroBase/AgroBase/AgroBase.csproj @@ -457,6 +457,7 @@ + @@ -500,6 +501,7 @@ + diff --git a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs index 67a5099a5..a165cdf88 100644 --- a/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs +++ b/AgroBase/AgroBase/Forms/Atuador/frmAtuCamera.cs @@ -31,7 +31,7 @@ namespace AgroBase.Forms ArquivoLeitura = "ervas_T.json", browser = null, camera = new CameraService(), - CameraSelecionada = "", + DeviceID = "", combo = cmbCameras, MaxLeituras = 10, VideoPorta = (VariaveisPortas.CameraSolo + Variaveis.OperacaoEmAndamento.CamerasSolo.Count()).ToString(), @@ -76,7 +76,7 @@ namespace AgroBase.Forms else { btnSalvar.Text = "Editar"; - cameraSolo.camera.selectedCamera = cmbCameras.SelectedIndex; + cameraSolo.camera.cameraIndex = cmbCameras.SelectedIndex; } btnIniciar.Enabled = btnSalvar.Text == "Editar" && cmbCameras.SelectedIndex > 0; cmbCameras.Enabled = btnSalvar.Text == "Salvar"; @@ -95,7 +95,7 @@ namespace AgroBase.Forms ArquivoLeitura = "ervas_" + CamNome + ".json", browser = null, camera = new CameraService(), - CameraSelecionada = "123", + DeviceID = "123", combo = new ComboBox(), MaxLeituras = 1, VideoPorta = (VariaveisPortas.CameraSolo + 0).ToString(), @@ -103,7 +103,7 @@ namespace AgroBase.Forms MqttTopico = "green_objects_" + CamNome, }; CameraSolo.panel = pnlCamera; - CameraSolo.camera.selectedCamera = 1; + CameraSolo.camera.cameraIndex = 1; IniciarCameraSolo(CameraSolo); tmrLeitura = new AsyncTaskTimerModel("tmrLeitura", tmrLeitura_Tick, 200); @@ -114,7 +114,7 @@ namespace AgroBase.Forms { CameraSolo.DesligarCamera(); - if (CameraSolo.camera.selectedCamera > 0) + if (CameraSolo.camera.cameraIndex > 0) { VersaoArquivoModel ArquivoVersao = VersionamentoService.ArquivoModeloWeedDetector; @@ -166,14 +166,14 @@ namespace AgroBase.Forms private void AtualizaListaCameras() { - cameraSolo.camera.selectedCamera = cmbCameras.SelectedIndex > 0 ? cmbCameras.SelectedIndex : 0; + cameraSolo.camera.cameraIndex = cmbCameras.SelectedIndex > 0 ? cmbCameras.SelectedIndex : 0; cmbCameras.Items.Clear(); cmbCameras.Items.AddRange(CameraService.ObterListaCameras().Keys.ToArray()); if (cmbCameras.Items.Count == 1) { - cameraSolo.camera.selectedCamera = 0; + cameraSolo.camera.cameraIndex = 0; } - cmbCameras.SelectedIndex = cameraSolo.camera.selectedCamera; + cmbCameras.SelectedIndex = cameraSolo.camera.cameraIndex; } private void ListarObjetosDetectados() diff --git a/AgroBase/AgroBase/Forms/IHM/frmAjustes.Designer.cs b/AgroBase/AgroBase/Forms/IHM/frmAjustes.Designer.cs index a85053d5b..8d39fde75 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmAjustes.Designer.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmAjustes.Designer.cs @@ -29,17 +29,8 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmAjustes)); - this.pnlEsquerda = new System.Windows.Forms.Panel(); - this.picEsquerda = new System.Windows.Forms.PictureBox(); - this.lblEsquerda = new System.Windows.Forms.Label(); - this.lblDireita = new System.Windows.Forms.Label(); - this.pnlDireita = new System.Windows.Forms.Panel(); - this.picDireita = new System.Windows.Forms.PictureBox(); - this.pnlCentro = new System.Windows.Forms.Panel(); - this.picCentro = new System.Windows.Forms.PictureBox(); - this.cmbS0 = new System.Windows.Forms.ComboBox(); + this.pnlCaminho = new System.Windows.Forms.Panel(); this.cmbC = new System.Windows.Forms.ComboBox(); - this.cmbS1 = new System.Windows.Forms.ComboBox(); this.lblComunicacao = new System.Windows.Forms.Label(); this.picVoltar = new System.Windows.Forms.PictureBox(); this.picSalvar = new System.Windows.Forms.PictureBox(); @@ -63,131 +54,36 @@ this.picGravar = new System.Windows.Forms.PictureBox(); this.picAtualizar = new System.Windows.Forms.PictureBox(); this.cmbComunicacao = new System.Windows.Forms.ComboBox(); - this.btnCalibrarKinect = new System.Windows.Forms.Button(); - this.chbKinect = new System.Windows.Forms.CheckBox(); - this.trkKinect = new System.Windows.Forms.TrackBar(); + this.btnCalibrarSonar = new System.Windows.Forms.Button(); + this.chbSonarAtivado = new System.Windows.Forms.CheckBox(); this.gpbComunicacao = new System.Windows.Forms.GroupBox(); this.gpbCameras = new System.Windows.Forms.GroupBox(); - this.pnlEsquerda.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.picEsquerda)).BeginInit(); - this.pnlDireita.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.picDireita)).BeginInit(); - this.pnlCentro.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.picCentro)).BeginInit(); + this.flwCamerasSolo = new System.Windows.Forms.FlowLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.picVoltar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picSalvar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picLer)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picGravar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picAtualizar)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.trkKinect)).BeginInit(); this.gpbComunicacao.SuspendLayout(); this.gpbCameras.SuspendLayout(); this.SuspendLayout(); // - // pnlEsquerda + // pnlCaminho // - this.pnlEsquerda.Controls.Add(this.picEsquerda); - this.pnlEsquerda.Location = new System.Drawing.Point(94, 53); - this.pnlEsquerda.Name = "pnlEsquerda"; - this.pnlEsquerda.Size = new System.Drawing.Size(270, 200); - this.pnlEsquerda.TabIndex = 0; - // - // picEsquerda - // - this.picEsquerda.BackColor = System.Drawing.Color.Black; - this.picEsquerda.Dock = System.Windows.Forms.DockStyle.Fill; - this.picEsquerda.Location = new System.Drawing.Point(0, 0); - this.picEsquerda.Name = "picEsquerda"; - this.picEsquerda.Size = new System.Drawing.Size(270, 200); - this.picEsquerda.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.picEsquerda.TabIndex = 0; - this.picEsquerda.TabStop = false; - // - // lblEsquerda - // - this.lblEsquerda.AutoSize = true; - this.lblEsquerda.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.lblEsquerda.Location = new System.Drawing.Point(105, 24); - this.lblEsquerda.Name = "lblEsquerda"; - this.lblEsquerda.Size = new System.Drawing.Size(248, 20); - this.lblEsquerda.TabIndex = 3; - this.lblEsquerda.Text = "PULVERIZADOR - ESQUERDA"; - // - // lblDireita - // - this.lblDireita.AutoSize = true; - this.lblDireita.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.lblDireita.Location = new System.Drawing.Point(734, 24); - this.lblDireita.Name = "lblDireita"; - this.lblDireita.Size = new System.Drawing.Size(219, 20); - this.lblDireita.TabIndex = 5; - this.lblDireita.Text = "PULVERIZADOR - DIREITA"; - // - // pnlDireita - // - this.pnlDireita.Controls.Add(this.picDireita); - this.pnlDireita.Location = new System.Drawing.Point(716, 53); - this.pnlDireita.Name = "pnlDireita"; - this.pnlDireita.Size = new System.Drawing.Size(270, 200); - this.pnlDireita.TabIndex = 4; - // - // picDireita - // - this.picDireita.BackColor = System.Drawing.Color.Black; - this.picDireita.Dock = System.Windows.Forms.DockStyle.Fill; - this.picDireita.Location = new System.Drawing.Point(0, 0); - this.picDireita.Name = "picDireita"; - this.picDireita.Size = new System.Drawing.Size(270, 200); - this.picDireita.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.picDireita.TabIndex = 1; - this.picDireita.TabStop = false; - // - // pnlCentro - // - this.pnlCentro.Controls.Add(this.picCentro); - this.pnlCentro.Location = new System.Drawing.Point(378, 53); - this.pnlCentro.Name = "pnlCentro"; - this.pnlCentro.Size = new System.Drawing.Size(270, 200); - this.pnlCentro.TabIndex = 1; - // - // picCentro - // - this.picCentro.BackColor = System.Drawing.Color.Black; - this.picCentro.Dock = System.Windows.Forms.DockStyle.Fill; - this.picCentro.Location = new System.Drawing.Point(0, 0); - this.picCentro.Name = "picCentro"; - this.picCentro.Size = new System.Drawing.Size(270, 200); - this.picCentro.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.picCentro.TabIndex = 1; - this.picCentro.TabStop = false; - // - // cmbS0 - // - this.cmbS0.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cmbS0.FormattingEnabled = true; - this.cmbS0.Location = new System.Drawing.Point(94, 267); - this.cmbS0.Name = "cmbS0"; - this.cmbS0.Size = new System.Drawing.Size(270, 39); - this.cmbS0.TabIndex = 7; + this.pnlCaminho.Location = new System.Drawing.Point(137, 53); + this.pnlCaminho.Name = "pnlCaminho"; + this.pnlCaminho.Size = new System.Drawing.Size(320, 200); + this.pnlCaminho.TabIndex = 1; // // cmbC // - this.cmbC.Enabled = false; this.cmbC.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmbC.FormattingEnabled = true; - this.cmbC.Location = new System.Drawing.Point(378, 267); + this.cmbC.Location = new System.Drawing.Point(137, 259); this.cmbC.Name = "cmbC"; this.cmbC.Size = new System.Drawing.Size(181, 39); this.cmbC.TabIndex = 8; - // - // cmbS1 - // - this.cmbS1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cmbS1.FormattingEnabled = true; - this.cmbS1.Location = new System.Drawing.Point(716, 267); - this.cmbS1.Name = "cmbS1"; - this.cmbS1.Size = new System.Drawing.Size(270, 39); - this.cmbS1.TabIndex = 9; + this.cmbC.SelectedIndexChanged += new System.EventHandler(this.cmbCameraCaminho_SelectedIndexChanged); // // lblComunicacao // @@ -433,38 +329,31 @@ this.cmbComunicacao.TabIndex = 36; this.cmbComunicacao.SelectedIndexChanged += new System.EventHandler(this.cmbComunicacao_SelectedIndexChanged); // - // btnCalibrarKinect + // btnCalibrarSonar // - this.btnCalibrarKinect.Enabled = false; - this.btnCalibrarKinect.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.btnCalibrarKinect.Location = new System.Drawing.Point(566, 267); - this.btnCalibrarKinect.Name = "btnCalibrarKinect"; - this.btnCalibrarKinect.Size = new System.Drawing.Size(133, 39); - this.btnCalibrarKinect.TabIndex = 37; - this.btnCalibrarKinect.Text = "CALIBRAR"; - this.btnCalibrarKinect.UseVisualStyleBackColor = true; - this.btnCalibrarKinect.Click += new System.EventHandler(this.btnCalibrarKinect_Click); + this.btnCalibrarSonar.Enabled = false; + this.btnCalibrarSonar.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); + this.btnCalibrarSonar.Location = new System.Drawing.Point(324, 259); + this.btnCalibrarSonar.Name = "btnCalibrarSonar"; + this.btnCalibrarSonar.Size = new System.Drawing.Size(133, 39); + this.btnCalibrarSonar.TabIndex = 37; + this.btnCalibrarSonar.Text = "CALIBRAR"; + this.btnCalibrarSonar.UseVisualStyleBackColor = true; + this.btnCalibrarSonar.Click += new System.EventHandler(this.btnCalibrarSonar_Click); // - // chbKinect + // chbSonarAtivado // - this.chbKinect.AutoSize = true; - this.chbKinect.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); - this.chbKinect.Location = new System.Drawing.Point(451, 23); - this.chbKinect.Name = "chbKinect"; - this.chbKinect.Size = new System.Drawing.Size(165, 24); - this.chbKinect.TabIndex = 38; - this.chbKinect.Text = "SONAR ATIVADO"; - this.chbKinect.UseVisualStyleBackColor = true; - this.chbKinect.CheckedChanged += new System.EventHandler(this.chbKinect_CheckedChanged); - // - // trkKinect - // - this.trkKinect.Location = new System.Drawing.Point(654, 53); - this.trkKinect.Name = "trkKinect"; - this.trkKinect.Orientation = System.Windows.Forms.Orientation.Vertical; - this.trkKinect.Size = new System.Drawing.Size(45, 200); - this.trkKinect.TabIndex = 39; - this.trkKinect.TickFrequency = 4; + this.chbSonarAtivado.AutoSize = true; + this.chbSonarAtivado.Checked = true; + this.chbSonarAtivado.CheckState = System.Windows.Forms.CheckState.Checked; + this.chbSonarAtivado.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F); + this.chbSonarAtivado.Location = new System.Drawing.Point(210, 23); + this.chbSonarAtivado.Name = "chbSonarAtivado"; + this.chbSonarAtivado.Size = new System.Drawing.Size(165, 24); + this.chbSonarAtivado.TabIndex = 38; + this.chbSonarAtivado.Text = "SONAR ATIVADO"; + this.chbSonarAtivado.UseVisualStyleBackColor = true; + this.chbSonarAtivado.CheckedChanged += new System.EventHandler(this.chbSonarAtivado_CheckedChanged); // // gpbComunicacao // @@ -497,20 +386,14 @@ // // gpbCameras // - this.gpbCameras.Controls.Add(this.pnlEsquerda); + this.gpbCameras.Controls.Add(this.flwCamerasSolo); this.gpbCameras.Controls.Add(this.picVoltar); this.gpbCameras.Controls.Add(this.picSalvar); - this.gpbCameras.Controls.Add(this.chbKinect); + this.gpbCameras.Controls.Add(this.chbSonarAtivado); this.gpbCameras.Controls.Add(this.picAtualizar); - this.gpbCameras.Controls.Add(this.lblEsquerda); - this.gpbCameras.Controls.Add(this.trkKinect); - this.gpbCameras.Controls.Add(this.pnlDireita); - this.gpbCameras.Controls.Add(this.btnCalibrarKinect); - this.gpbCameras.Controls.Add(this.lblDireita); - this.gpbCameras.Controls.Add(this.pnlCentro); - this.gpbCameras.Controls.Add(this.cmbS0); + this.gpbCameras.Controls.Add(this.btnCalibrarSonar); + this.gpbCameras.Controls.Add(this.pnlCaminho); this.gpbCameras.Controls.Add(this.cmbC); - this.gpbCameras.Controls.Add(this.cmbS1); this.gpbCameras.Location = new System.Drawing.Point(12, 12); this.gpbCameras.Name = "gpbCameras"; this.gpbCameras.Size = new System.Drawing.Size(1000, 322); @@ -518,6 +401,13 @@ this.gpbCameras.TabStop = false; this.gpbCameras.Text = "CÂMERAS"; // + // flwCamerasSolo + // + this.flwCamerasSolo.Location = new System.Drawing.Point(463, 19); + this.flwCamerasSolo.Name = "flwCamerasSolo"; + this.flwCamerasSolo.Size = new System.Drawing.Size(531, 297); + this.flwCamerasSolo.TabIndex = 39; + // // frmAjustes // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -534,18 +424,11 @@ this.TopMost = true; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmAjustes_FormClosing); this.Load += new System.EventHandler(this.frmAjustes_Load); - this.pnlEsquerda.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.picEsquerda)).EndInit(); - this.pnlDireita.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.picDireita)).EndInit(); - this.pnlCentro.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.picCentro)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picVoltar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picSalvar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picLer)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picGravar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picAtualizar)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.trkKinect)).EndInit(); this.gpbComunicacao.ResumeLayout(false); this.gpbComunicacao.PerformLayout(); this.gpbCameras.ResumeLayout(false); @@ -555,15 +438,8 @@ } #endregion - - private System.Windows.Forms.Panel pnlEsquerda; - private System.Windows.Forms.Label lblEsquerda; - private System.Windows.Forms.Label lblDireita; - private System.Windows.Forms.Panel pnlDireita; - private System.Windows.Forms.Panel pnlCentro; - private System.Windows.Forms.ComboBox cmbS0; + private System.Windows.Forms.Panel pnlCaminho; private System.Windows.Forms.ComboBox cmbC; - private System.Windows.Forms.ComboBox cmbS1; private System.Windows.Forms.Label lblComunicacao; private System.Windows.Forms.PictureBox picVoltar; private System.Windows.Forms.PictureBox picSalvar; @@ -586,14 +462,11 @@ private System.Windows.Forms.PictureBox picLer; private System.Windows.Forms.PictureBox picGravar; private System.Windows.Forms.PictureBox picAtualizar; - private System.Windows.Forms.PictureBox picEsquerda; - private System.Windows.Forms.PictureBox picDireita; - private System.Windows.Forms.PictureBox picCentro; private System.Windows.Forms.ComboBox cmbComunicacao; - private System.Windows.Forms.Button btnCalibrarKinect; - private System.Windows.Forms.CheckBox chbKinect; - private System.Windows.Forms.TrackBar trkKinect; + private System.Windows.Forms.Button btnCalibrarSonar; + private System.Windows.Forms.CheckBox chbSonarAtivado; private System.Windows.Forms.GroupBox gpbComunicacao; private System.Windows.Forms.GroupBox gpbCameras; + private System.Windows.Forms.FlowLayoutPanel flwCamerasSolo; } } \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs b/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs index a3faedb4f..077714214 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmAjustes.cs @@ -16,7 +16,7 @@ namespace AgroBase.Forms.IHM { //LoRaParametrosModel loraParametrosBase; - Dictionary Cameras = new Dictionary(); + List Cameras = new List(); public frmAjustes() { @@ -36,12 +36,17 @@ namespace AgroBase.Forms.IHM FuncoesGlobais.DefinirEventosPicBtn(picSalvar, "Erro ao salvar parâmetros!", async () => { Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraID_Caminho = cmbC.Text; + + List cmbs = new List(); + foreach (Panel pnlCam in flwCamerasSolo.Controls) + { + cmbs.Add(pnlCam.Controls.OfType().FirstOrDefault()); + } Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraID_Solo.Clear(); - Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraID_Solo.AddRange(new string[] { cmbS0.Text, cmbS1.Text }); + Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraID_Solo.AddRange(cmbs.Select(x => x.Text).ToArray()); if (KinectService.Iniciado) { - Variaveis.OperacaoEmAndamento.Controle.SonarAtivado = chbKinect.Checked; - KinectService.Parametros.Angulo = trkKinect.Value; + Variaveis.OperacaoEmAndamento.Controle.SonarAtivado = chbSonarAtivado.Checked; KinectService.SalvarParametros(); } @@ -93,18 +98,16 @@ namespace AgroBase.Forms.IHM await AtualizarParametros(); } - chbKinect.Enabled = KinectService.Iniciado; - trkKinect.Enabled = KinectService.Iniciado; + chbSonarAtivado.Enabled = KinectService.Iniciado; if (KinectService.Iniciado) { - chbKinect.Checked = Variaveis.OperacaoEmAndamento.Controle.SonarAtivado; - KinectService.AtualizarTrackBar(trkKinect); + chbSonarAtivado.Checked = Variaveis.OperacaoEmAndamento.Controle.SonarAtivado; } } private void frmAjustes_FormClosing(object sender, FormClosingEventArgs e) { - tmrKinect?.Dispose(); + Variaveis.OperacaoEmAndamento.AtualizaListaCameras(pnlCaminho, Variaveis.OperacaoEmAndamento.CamerasSolo.Select(x => x.panel).ToList(), false); } #region COMUNICACAO @@ -191,162 +194,139 @@ namespace AgroBase.Forms.IHM #region CAMERAS - private FilterInfoCollection videoDevices; - private VideoCaptureDevice videoSourceEsquerda; - private VideoCaptureDevice videoSourceDireita; - private AsyncTaskTimerModel tmrKinect; - private void AtualizarCameras() { - Variaveis.OperacaoEmAndamento.CamerasSolo[0].combo = cmbS0; - Variaveis.OperacaoEmAndamento.CamerasSolo[1].combo = cmbS1; - - cmbC.SelectedIndexChanged -= cmbCentro_SelectedIndexChanged; - cmbC.SelectedIndexChanged += cmbCentro_SelectedIndexChanged; - cmbS0.SelectedIndexChanged -= cmbCameraSolo_SelectedIndexChanged; - cmbS0.SelectedIndexChanged += cmbCameraSolo_SelectedIndexChanged; - cmbS1.SelectedIndexChanged -= cmbCameraSolo_SelectedIndexChanged; - cmbS1.SelectedIndexChanged += cmbCameraSolo_SelectedIndexChanged; - - - Cameras = CameraService.ObterListaCameras(); + flwCamerasSolo.Controls.Clear(); + Cameras = OAKCameraService.GetConnectedCameras(); + for (int i = 0; i < Variaveis.OperacaoEmAndamento.QuantidadeCamerasSolo; i++) + { + GerarCameraSolo(i); + } cmbC.Items.Clear(); - if (KinectService.Iniciado) + cmbC.Items.AddRange(Cameras.Select(x => x.Id).ToArray()); + var cameraSelecionada = Cameras.FirstOrDefault(x => x.Id == Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraID_Caminho); + if (cameraSelecionada != null) { - cmbC.Items.Add("Sonar Frontal"); - cmbC.SelectedIndex = 0; + cmbC.SelectedIndex = Cameras.IndexOf(cameraSelecionada); } - var CamerasSolo = Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraID_Solo; - - cmbS0.Items.Clear(); - cmbS0.Items.AddRange(Cameras.Values.ToArray()); - string IDsoloE = CamerasSolo.Count() > 0 ? CamerasSolo[0] : ""; - if (Cameras.Any(x => x.Value == IDsoloE)) - { - cmbS0.SelectedIndex = cmbS0.Items.IndexOf(IDsoloE); - } - else - { - cmbS0.Text = IDsoloE; - } - - cmbS1.Items.Clear(); - cmbS1.Items.AddRange(Cameras.Values.ToArray()); - string IDsoloD = CamerasSolo.Count() > 1 ? CamerasSolo[1] : ""; - if (Cameras.Any(x => x.Value == IDsoloD)) - { - cmbS1.SelectedIndex = cmbS1.Items.IndexOf(IDsoloD); - } - else - { - cmbS1.Text = IDsoloD; - } - - IniciarCameras(); } private void IniciarCameras() { - Bitmap blackBitmap = new Bitmap(picCentro.Width, picCentro.Height); - using (Graphics g = Graphics.FromImage(blackBitmap)) - { - g.Clear(Color.Black); - } - - if (videoSourceEsquerda != null) - { - videoSourceEsquerda.Stop(); - videoSourceEsquerda = null; - picEsquerda.Image = blackBitmap; - } - if (videoSourceDireita != null) - { - videoSourceDireita.Stop(); - videoSourceDireita = null; - picDireita.Image = blackBitmap; - } - - videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); - List CamerasIDs = new List(); - foreach (FilterInfo info in videoDevices) - { - CamerasIDs.Add(info.MonikerString.ToLower()); - } - - string IDcamSoloE = cmbS0.Text; //.ToLower().Replace("\\", "#"); - if (!string.IsNullOrEmpty(IDcamSoloE) && CamerasIDs.Any(x => x.Contains(IDcamSoloE))) - { - videoSourceEsquerda = new VideoCaptureDevice(CamerasIDs.First(x => x.Contains(IDcamSoloE))); - videoSourceEsquerda.NewFrame += new NewFrameEventHandler(videoSourceEsquerda_NewFrame); - videoSourceEsquerda.Start(); - } - string IDcamSoloD = cmbS1.Text; //.ToLower().Replace("\\", "#"); - if (!string.IsNullOrEmpty(IDcamSoloD) && CamerasIDs.Any(x => x.Contains(IDcamSoloD))) - { - videoSourceDireita = new VideoCaptureDevice(CamerasIDs.First(x => x.Contains(IDcamSoloD))); - videoSourceDireita.NewFrame += new NewFrameEventHandler(videoSourceDireita_NewFrame); - videoSourceDireita.Start(); - } - } - - private async Task tmrKinect_Tick() - { - Bitmap bitmap = (Bitmap)(chbKinect.Checked ? KinectService.bitmapMap : KinectService.bitmapRGB).Clone(); - picCentro.Image = bitmap; - } - - private void videoSourceCentro_NewFrame(object sender, NewFrameEventArgs eventArgs) - { - Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone(); - picCentro.Image = bitmap; - } - - private void videoSourceEsquerda_NewFrame(object sender, NewFrameEventArgs eventArgs) - { - Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone(); - picEsquerda.Image = bitmap; - } - - private void videoSourceDireita_NewFrame(object sender, NewFrameEventArgs eventArgs) - { - Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone(); - picDireita.Image = bitmap; + Variaveis.OperacaoEmAndamento.AtualizaListaCameras(pnlCaminho, Variaveis.OperacaoEmAndamento.CamerasSolo.Select(x => x.panel).ToList(), true); } - private void cmbCentro_SelectedIndexChanged(object sender, EventArgs e) + private void cmbCameraCaminho_SelectedIndexChanged(object sender, EventArgs e) { - tmrKinect?.Dispose(); - tmrKinect = new AsyncTaskTimerModel("tmrKinect", tmrKinect_Tick, 100, this); - tmrKinect.Start(); + ComboBox cmb = (ComboBox)sender; + + CameraCaminhoModel CameraCaminho = Variaveis.OperacaoEmAndamento.CameraCaminho; + if (CameraCaminho != null) + { + CameraCaminho.combo = cmb; + CameraCaminho.panel = pnlCaminho; + CameraCaminho.panel.Tag = cmb.Text; + } + + if (CameraCaminho.combo.SelectedIndex > 0 && (Variaveis.OperacaoEmAndamento.CamerasSolo.Any(x => x.combo.SelectedIndex == CameraCaminho.combo.SelectedIndex))) + { + MessageBox.Show("Essa câmera já está sendo usada por outro processo!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); + CameraCaminho.combo.SelectedIndex = CameraCaminho.camera.cameraIndex; + return; + } + + CameraCaminho.camera.cameraIndex = CameraCaminho.combo.SelectedIndex; + IniciarCameras(); + } + + private void GerarCameraSolo(int idx) + { + Panel pnlFundo = new Panel() + { + Name = "pnlCamSolo_S" + idx, + Width = 300, + Height = 284 + }; + Label lblTitulo = new Label() + { + Name = "lblCamSolo_S" + idx, + Text = "PULVERIZADOR - " + (idx + 1).ToString(), + Width = 168, + Height = 20, + Location = new Point(66, 6), + Font = new Font("Microsoft Sans Serif", 12.25f, FontStyle.Regular) + }; + Panel pnlCamera = new Panel() + { + Name = "pnlCamSoloFundo_S" + idx, + Width = 286, + Height = 200, + Location = new Point(7, 31), + BackgroundImageLayout = ImageLayout.Stretch, + BackColor = Color.Black, + }; + ComboBox cmbCamera = new ComboBox() + { + Name = "cmbCamSolo_S" + idx, + Width = 286, + Height = 39, + Location = new Point(7, 237), + Font = new Font("Microsoft Sans Serif", 20.25f, FontStyle.Regular) + }; + cmbCamera.SelectedIndexChanged += cmbCameraSolo_SelectedIndexChanged; + + cmbCamera.Items.Clear(); + cmbCamera.Items.AddRange(Cameras.Select(x => x.Id).ToArray()); + + pnlFundo.Controls.Add(lblTitulo); + pnlFundo.Controls.Add(pnlCamera); + pnlFundo.Controls.Add(cmbCamera); + + flwCamerasSolo.Controls.Add(pnlFundo); + + string cameraSelecionada = Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraID_Solo.Count() > idx ? Variaveis.OperacaoEmAndamento.DispSen.Dados.CameraID_Solo[idx] : ""; + + if (Cameras.Any(x => x.Id == cameraSelecionada)) + { + cmbCamera.SelectedIndex = cmbCamera.Items.IndexOf(cameraSelecionada); + } + else + { + cmbCamera.Text = cameraSelecionada; + } } private void cmbCameraSolo_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cmb = (ComboBox)sender; - string CamID = cmb.Name.Replace("cmb", ""); + string CamID = cmb.Name.Replace("cmbCamSolo_", ""); CameraSoloModel CameraSolo = Variaveis.OperacaoEmAndamento.CamerasSolo.FirstOrDefault(x => x.ID == CamID); + if (CameraSolo != null) + { + CameraSolo.combo = cmb; + CameraSolo.panel = FuncoesGlobais.FindControlRecursive(flwCamerasSolo, "pnlCamSoloFundo_" + CamID); + CameraSolo.panel.Tag = cmb.Text; + } if (CameraSolo.combo.SelectedIndex > 0 && (cmbC.SelectedIndex == CameraSolo.combo.SelectedIndex || Variaveis.OperacaoEmAndamento.CamerasSolo.Any(x => x.Nome != CameraSolo.Nome && x.combo.SelectedIndex == CameraSolo.combo.SelectedIndex))) { MessageBox.Show("Essa câmera já está sendo usada por outro processo!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); - CameraSolo.combo.SelectedIndex = CameraSolo.camera.selectedCamera; + CameraSolo.combo.SelectedIndex = CameraSolo.camera.cameraIndex; return; } - CameraSolo.camera.selectedCamera = CameraSolo.combo.SelectedIndex; + CameraSolo.camera.cameraIndex = CameraSolo.combo.SelectedIndex; IniciarCameras(); } - - #endregion private async void cmbComunicacao_SelectedIndexChanged(object sender, EventArgs e) @@ -357,14 +337,14 @@ namespace AgroBase.Forms.IHM } } - private void btnCalibrarKinect_Click(object sender, EventArgs e) + private void btnCalibrarSonar_Click(object sender, EventArgs e) { - KinectService.RecalibrarSubdivisoes(); + //KinectService.RecalibrarSubdivisoes(); } - private void chbKinect_CheckedChanged(object sender, EventArgs e) + private void chbSonarAtivado_CheckedChanged(object sender, EventArgs e) { - btnCalibrarKinect.Enabled = ((CheckBox)sender).Checked; + btnCalibrarSonar.Enabled = ((CheckBox)sender).Checked; } diff --git a/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.cs b/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.cs index 5b009f999..78efa8a15 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmDialogoMapa.cs @@ -132,9 +132,9 @@ namespace AgroBase.Forms.IHM { lblUltimaLeituraSolo.Text = "Última Leitura Solo: " + FuncoesGlobais.TimestampToDate(ultimaLeitura.Leitura.timestamp); } - if (Variaveis.OperacaoEmAndamento.CameraCaminhoKinect != null) + if (Variaveis.OperacaoEmAndamento.CameraCaminho != null) { - lblUltimaLeituraCaminho.Text = "Última Leitura Caminho: " + FuncoesGlobais.TimestampToDate(Variaveis.OperacaoEmAndamento.CameraCaminhoKinect.Leitura.timestamp); + lblUltimaLeituraCaminho.Text = "Última Leitura Caminho: " + FuncoesGlobais.TimestampToDate(Variaveis.OperacaoEmAndamento.CameraCaminho.Leitura.timestamp); } lblPerformance.Text = _Sensoriamento.DadosPerformance.PerformanceStr; diff --git a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs index 4d47a823f..14d09b0d8 100644 --- a/AgroBase/AgroBase/Forms/IHM/frmIHM.cs +++ b/AgroBase/AgroBase/Forms/IHM/frmIHM.cs @@ -186,7 +186,7 @@ namespace AgroBase.Forms.IHM CodFalha = Variaveis.OperacaoEmAndamento.RetornaCodigoFalha(); var Labels = this.Controls.OfType