This commit is contained in:
Diego Freitas 2025-03-25 10:20:12 -03:00
parent 9cc8bb27ec
commit e4383254c1
15 changed files with 31 additions and 230 deletions

Binary file not shown.

View File

@ -853,19 +853,6 @@ namespace AgroBase.Forms.IHM
ValorPadrao = 0 ValorPadrao = 0
}, },
new ColunasDiagnosticoModel() new ColunasDiagnosticoModel()
{
Componente = "S_POT_" + x.Modulo_ID,
Teste = "Inicializado",
ValorPadrao = 1,
ComplementoValorPadrao = ComplementosPadrao[1]
},
new ColunasDiagnosticoModel()
{
Componente = "S_POT_" + x.Modulo_ID,
Teste = "Status",
ValorPadrao = (int)StatusSensorPotenciometro.Centro
},
new ColunasDiagnosticoModel()
{ {
Componente = x.Modulo_ID, Componente = x.Modulo_ID,
Teste = "Para Esquerda", Teste = "Para Esquerda",
@ -934,14 +921,6 @@ namespace AgroBase.Forms.IHM
int.TryParse(Leitura?.Mensagem ?? "", out int CodigoErro); int.TryParse(Leitura?.Mensagem ?? "", out int CodigoErro);
idx = PreencheDadosLinha(grid, Testes, idx, Inicializado ? CodigoErro : -1); idx = PreencheDadosLinha(grid, Testes, idx, Inicializado ? CodigoErro : -1);
var SensorPot = Modulo_Sen.Sensores.FirstOrDefault(x => x.Componente == S_Code.sPOT && x.ID.Contains(Modulo.Modulo_ID));
bool PotIniciado = SensorPot != null && SensorPot.Inicializado;
idx = PreencheDadosLinha(grid, Testes, idx, PotIniciado ? 1 : 0);
int potStatus = PotIniciado ? (int)(((FirmwareSensorPotenciometro)SensorPot.Leitura)?.Status ?? StatusSensorPotenciometro.Indefinido) : -1;
idx = PreencheDadosLinha(grid, Testes, idx, potStatus);
//MKS057DService.AddrRef = Convert.ToByte(Modulo.DirMotor.Endereco, 16); //MKS057DService.AddrRef = Convert.ToByte(Modulo.DirMotor.Endereco, 16);
if (Inicializado) if (Inicializado)

View File

@ -236,17 +236,15 @@ namespace AgroBase.Forms
PictureBox pic = (PictureBox)sender; PictureBox pic = (PictureBox)sender;
string ID = pic.Name.Replace("pic", ""); 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); var Modulo = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.FirstOrDefault(m => m.Modulo_ID == ID);
Label lblA_SP = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + ID + "A_SP"); Label lblA_SP = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + ID + "A_SP");
lblA_SP.Text = "Angulo SP: " + (Modulo.DirMotor.Angulo_SP).ToString("000") + "º"; lblA_SP.Text = "Angulo SP: " + (Modulo.DirMotor.Angulo_SP).ToString("000") + "º";
Label lblA = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + ID + "A"); Label lblA = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + ID + "A");
lblA.Text = "Angulo: " + Modulo.DirMotor.Angulo.ToString("000") + "º" + (SensorPot != null ? " (" + (((FirmwareSensorPotenciometro)SensorPot.Leitura)?.Angulo ?? -999) + "º / " + (((FirmwareSensorPotenciometro)SensorPot.Leitura)?.Leitura ?? -1) + ")" : ""); lblA.Text = "Angulo: " + Modulo.DirMotor.Angulo.ToString("000") + "º";
Label lblA_SentidoSP = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + ID + "A_SentidoSP"); Label lblA_SentidoSP = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + ID + "A_SentidoSP");
lblA_SentidoSP.Text = "Sentido SP: " + Enum.GetName(typeof(Sentido), Modulo.DirMotor.Sentido_SP); lblA_SentidoSP.Text = "Sentido SP: " + Enum.GetName(typeof(Sentido), Modulo.DirMotor.Sentido_SP);
Label lblA_Sentido = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + ID + "A_Sentido"); Label lblA_Sentido = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + ID + "A_Sentido");
lblA_Sentido.Text = "Sentido: " + Enum.GetName(typeof(Sentido), Modulo.DirMotor.Sentido) + (SensorPot != null ? " (" + (((FirmwareSensorPotenciometro)SensorPot.Leitura)?.Sentido ?? Sentido.Parado) + ")" : ""); lblA_Sentido.Text = "Sentido: " + Enum.GetName(typeof(Sentido), Modulo.DirMotor.Sentido) + " (" + Modulo.DirMotor.SentidoReal.ToString() + ")";
// Use o objeto Graphics para desenhar a representação do motor // Use o objeto Graphics para desenhar a representação do motor
Graphics g = e.Graphics; Graphics g = e.Graphics;

View File

@ -43,7 +43,9 @@ namespace AgroBase.Forms
Pinout = new PinoutDataModel() Pinout = new PinoutDataModel()
{ {
ExpansorGPIO = false, ExpansorGPIO = false,
EnderecoGPIO = "", EnderecoGPIO = "0x20",
ExpansorADS = false,
EnderecoADS = "0x48",
Pinos = new List<PinoutModel>(), Pinos = new List<PinoutModel>(),
}; };
Dispositivos = new List<DispositivoDataModel>(); Dispositivos = new List<DispositivoDataModel>();
@ -179,10 +181,10 @@ namespace AgroBase.Forms
{ {
cmb.Enabled = cmb.Enabled =
(Selecionado.Barramento == TiposBarramentos.CONTROLADOR && Selecionado.Habilitado) || (Selecionado.Barramento == TiposBarramentos.CONTROLADOR && Selecionado.Habilitado) ||
(Selecionado.Barramento == TiposBarramentos.EXPANSOR_GPIO && chbMCP1.Checked) || (Selecionado.Barramento == TiposBarramentos.EXPANSOR_GPIO && chbMCP1.Checked && cmb.Name.Contains("MCP")) ||
(Selecionado.Barramento == TiposBarramentos.EXPANSOR_ADS && chbADS1.Checked); (Selecionado.Barramento == TiposBarramentos.EXPANSOR_ADS && chbADS1.Checked && cmb.Name.Contains("ADS"));
if (Selecionado.Habilitado) if (Selecionado.Habilitado && cmb.Enabled)
{ {
cmb.SelectedItem = Selecionado.ComponenteID + " " + Enum.GetName(typeof(FuncoesPinout), Selecionado.Funcao); cmb.SelectedItem = Selecionado.ComponenteID + " " + Enum.GetName(typeof(FuncoesPinout), Selecionado.Funcao);
} }
@ -276,8 +278,10 @@ namespace AgroBase.Forms
if (Novo) if (Novo)
Pinout = new PinoutDataModel() Pinout = new PinoutDataModel()
{ {
ExpansorGPIO = false, ExpansorGPIO = false,
EnderecoGPIO = "", EnderecoGPIO = "0x20",
ExpansorADS = false,
EnderecoADS = "0x48",
Pinos = PinoutModel.CarregarPinoutPadrao_S3(), Pinos = PinoutModel.CarregarPinoutPadrao_S3(),
}; };
break; break;
@ -288,8 +292,10 @@ namespace AgroBase.Forms
if (Novo) if (Novo)
Pinout = new PinoutDataModel() Pinout = new PinoutDataModel()
{ {
ExpansorGPIO = false, ExpansorGPIO = false,
EnderecoGPIO = "", EnderecoGPIO = "0x20",
ExpansorADS = false,
EnderecoADS = "0x48",
Pinos = PinoutModel.CarregarPinoutPadrao_Wrover(), Pinos = PinoutModel.CarregarPinoutPadrao_Wrover(),
}; };
break; break;
@ -305,6 +311,7 @@ namespace AgroBase.Forms
cbTipo.SelectedIndex = (int)TipoControlador; cbTipo.SelectedIndex = (int)TipoControlador;
chbMCP1.Checked = Pinout.ExpansorGPIO; chbMCP1.Checked = Pinout.ExpansorGPIO;
chbADS1.Checked = Pinout.ExpansorADS;
} }
private void chbExpansor_CheckedChanged(object sender, EventArgs e) private void chbExpansor_CheckedChanged(object sender, EventArgs e)

View File

@ -33,7 +33,7 @@ namespace AgroBase.Models
public Estado StatusTravaMotor { get; set; } public Estado StatusTravaMotor { get; set; }
public StatusComando StatusBloqueioMotor { get; set; } public StatusComando StatusBloqueioMotor { get; set; }
public StatusComando StatusMovimentoMotor { get; set; } public StatusComando StatusMovimentoMotor { get; set; }
public Sentido Direcao { get; set; } public Sentido Sentido { get; set; }
public double Velocidade { get; set; } public double Velocidade { get; set; }
public double Aceleracao { get; set; } public double Aceleracao { get; set; }
public string Mensagem { get; set; } public string Mensagem { get; set; }

View File

@ -335,23 +335,6 @@ namespace AgroBase.Models.Modules
MKS057DService.AdicionarComandoNaFila(MKS057DService.MontarComandoRequisicaoPulsos(modAddr)); MKS057DService.AdicionarComandoNaFila(MKS057DService.MontarComandoRequisicaoPulsos(modAddr));
MKS057DService.AdicionarComandoNaFila(MKS057DService.MontarComandoRequisicaoIO(modAddr)); MKS057DService.AdicionarComandoNaFila(MKS057DService.MontarComandoRequisicaoIO(modAddr));
if (false && Modulo.DirMotor.SensorAnguloAuxiliar != null && Modulo.DirMotor.SensorAnguloAuxiliar.LimiteExcedido)
{
var ReleControle = Variaveis.OperacaoEmAndamento.DispSen?.Dados?.Reles?.FirstOrDefault(x => x.ID.Contains(Modulo.DirMotor.SensorAnguloAuxiliar.ID));
if (ReleControle != null)
{
GeneralJoystick.EnviarComandoSensoriamento(S_Code.sRLE, ReleControle.ID, Estado.Desligado);
await Task.Delay(2000);
}
var _sentido = Modulo.DirMotor.SensorAnguloAuxiliar?.Sentido ?? Sentido.Parado;
Direcao direcaoContraria =
_sentido == Sentido.Horario ? Direcao.Esquerda :
_sentido == Sentido.Antihorario ? Direcao.Direita :
Direcao.Parado;
Modulo.DirMotor.EnviarComandoControle(direcaoContraria);
}
// Verifica se o angulo de set point do motor em questao e diferente do angulo atual, e se for, reenvia o comando para garantir que o motor esteja coerente com o set point // Verifica se o angulo de set point do motor em questao e diferente do angulo atual, e se for, reenvia o comando para garantir que o motor esteja coerente com o set point
if (!MKS057DService.Referenciando && (Modulo.DirMotor.UltimoComandoEnviado.AddMilliseconds(500) < DateTime.Now) && !Modulo.DirMotor.AtingiuAnguloSP) if (!MKS057DService.Referenciando && (Modulo.DirMotor.UltimoComandoEnviado.AddMilliseconds(500) < DateTime.Now) && !Modulo.DirMotor.AtingiuAnguloSP)
{ {
@ -1091,6 +1074,13 @@ namespace AgroBase.Models.Modules
Sentido.Parado; Sentido.Parado;
} }
} }
public Sentido SentidoReal
{
get
{
return IN1_Atuado ? Sentido.Horario : Sentido.Antihorario;
}
}
public double Angulo public double Angulo
{ {
get get
@ -1142,18 +1132,6 @@ namespace AgroBase.Models.Modules
_leitura = value; _leitura = value;
} }
} }
public FirmwareSensorPotenciometro SensorAnguloAuxiliar
{
get
{
var sensor = Variaveis.OperacaoEmAndamento.DispSen?.Dados?.Sensores?.FirstOrDefault(x => x.Componente == S_Code.sPOT && x.ID.Contains(Mod_ID));
if (sensor != null && sensor.Inicializado && sensor.Leitura != null)
{
return sensor.Leitura as FirmwareSensorPotenciometro;
}
return null;
}
}
public Direcao UltimaDirecao { get; set; } = Direcao.Parado; public Direcao UltimaDirecao { get; set; } = Direcao.Parado;
public DateTime UltimoComandoEnviado { get; set; } = DateTime.MinValue; public DateTime UltimoComandoEnviado { get; set; } = DateTime.MinValue;
@ -1311,9 +1289,7 @@ namespace AgroBase.Models.Modules
var _Controle = Variaveis.OperacaoEmAndamento.Controle; var _Controle = Variaveis.OperacaoEmAndamento.Controle;
int AnguloTipoMovimento = VariaveisEquipamento.AnguloMovimento[_Controle.TipoMovimento]; int AnguloTipoMovimento = VariaveisEquipamento.AnguloMovimento[_Controle.TipoMovimento];
bool limiteLateralExcedido = SensorAnguloAuxiliar?.LimiteExcedido ?? false; if (!Comandar)
if (!Comandar || limiteLateralExcedido)
{ {
Sentido_SP = Sentido.Parado; Sentido_SP = Sentido.Parado;
} }
@ -1398,9 +1374,9 @@ namespace AgroBase.Models.Modules
double anguloMinVisitado = 0; double anguloMinVisitado = 0;
Sentido _sentido = Sentido.Horario; Sentido _sentido = Sentido.Horario;
if (SensorAnguloAuxiliar != null && SensorAnguloAuxiliar.Sentido != Sentido.Parado) if (SentidoReal != Sentido.Parado)
{ {
_sentido = SensorAnguloAuxiliar.Sentido == Sentido.Horario ? Sentido.Antihorario : Sentido.Horario; _sentido = SentidoReal == Sentido.Horario ? Sentido.Antihorario : Sentido.Horario;
_angulo *= _sentido == Sentido.Antihorario ? -1 : 1; _angulo *= _sentido == Sentido.Antihorario ? -1 : 1;
} }
@ -1462,13 +1438,6 @@ namespace AgroBase.Models.Modules
if (_anguloEntrada == 9999) if (_anguloEntrada == 9999)
{ {
inverterGiro = (_angulo > 0 && Angulo >= (_angulo - 0.5)) || (_angulo < 0 && Angulo <= (_angulo + 0.5)); inverterGiro = (_angulo > 0 && Angulo >= (_angulo - 0.5)) || (_angulo < 0 && Angulo <= (_angulo + 0.5));
if (!inverterGiro && SensorAnguloAuxiliar != null)
{
if (SensorAnguloAuxiliar.Angulo < (SensorAnguloAuxiliar.LimiteMinimo / 2.0) || SensorAnguloAuxiliar.Angulo > (SensorAnguloAuxiliar.LimiteMaximo / 2.0))
{
inverterGiro = true;
}
}
} }
Sucesso = _anguloEntrada != 9999 && _anguloSaida != 9999; Sucesso = _anguloEntrada != 9999 && _anguloSaida != 9999;

View File

@ -366,103 +366,6 @@ namespace AgroBase.Models.Modules
LimiteMinimo = 40, LimiteMinimo = 40,
LimiteMaximo = 9999, LimiteMaximo = 9999,
},*/ },*/
new SensorModel()
{
ID = "POTET",
Descricao = "Potenciometro ET",
Prioridade = 24,
Componente = S_Code.sPOT,
Aferir = true,
Testando = false,
Funcoes = new List<FuncoesPinout>()
{
FuncoesPinout.Potenciometro,
},
DelayAmostragem = 500,
UnidadeMedida = "º",
Parametros = new List<string[]>()
{
new string[] { "Minimo", "-110" },
new string[] { "Meio", "0" },
new string[] { "Maximo", "110" },
new string[] { "Margem", "10" },
},
LimiteMaximo = 68,
LimiteMinimo = -110,
},
new SensorModel()
{
ID = "POTDT",
Descricao = "Potenciometro DT",
Prioridade = 24,
Componente = S_Code.sPOT,
Aferir = true,
Testando = false,
Funcoes = new List<FuncoesPinout>()
{
FuncoesPinout.Potenciometro,
},
DelayAmostragem = 500,
UnidadeMedida = "º",
Parametros = new List<string[]>()
{
new string[] { "Minimo", "-110" },
new string[] { "Meio", "0" },
new string[] { "Maximo", "110" },
new string[] { "Margem", "10" },
},
LimiteMaximo = 68,
LimiteMinimo = -110,
},
new SensorModel()
{
ID = "POTEF",
Descricao = "Potenciometro EF",
Prioridade = 24,
Componente = S_Code.sPOT,
Aferir = true,
Testando = false,
Funcoes = new List<FuncoesPinout>()
{
FuncoesPinout.Potenciometro,
},
DelayAmostragem = 500,
UnidadeMedida = "º",
Parametros = new List<string[]>()
{
new string[] { "Minimo", "-110" },
new string[] { "Meio", "0" },
new string[] { "Maximo", "110" },
new string[] { "Margem", "10" },
},
LimiteMaximo = 68,
LimiteMinimo = -110,
},
new SensorModel()
{
ID = "POTDF",
Descricao = "Potenciometro DF",
Prioridade = 24,
Componente = S_Code.sPOT,
Aferir = true,
Testando = false,
Funcoes = new List<FuncoesPinout>()
{
FuncoesPinout.Potenciometro,
},
DelayAmostragem = 500,
UnidadeMedida = "º",
Parametros = new List<string[]>()
{
new string[] { "Minimo", "-110" },
new string[] { "Meio", "0" },
new string[] { "Maximo", "110" },
new string[] { "Margem", "10" },
},
LimiteMaximo = 68,
LimiteMinimo = -110,
},
}, },
Reles = new List<SensorReleModel>() Reles = new List<SensorReleModel>()
{ {
@ -480,62 +383,6 @@ namespace AgroBase.Models.Modules
StatusControle = Estado.Desligado, StatusControle = Estado.Desligado,
ControleExterno = false, ControleExterno = false,
}, },
new SensorReleModel()
{
ID = "RLPOTET",
Descricao = "Relé alimentação Direcional ET",
Componente = S_Code.sRLE,
Controlar = true,
AtuacaoNivelAlto = true,
Funcoes = new List<FuncoesPinout>()
{
FuncoesPinout.Rele,
},
StatusControle = Estado.Desligado,
ControleExterno = true,
},
new SensorReleModel()
{
ID = "RPOTRDT",
Descricao = "Relé alimentação Direcional DT",
Componente = S_Code.sRLE,
Controlar = true,
AtuacaoNivelAlto = true,
Funcoes = new List<FuncoesPinout>()
{
FuncoesPinout.Rele,
},
StatusControle = Estado.Desligado,
ControleExterno = true,
},
new SensorReleModel()
{
ID = "RLPOTEF",
Descricao = "Relé alimentação Direcional EF",
Componente = S_Code.sRLE,
Controlar = true,
AtuacaoNivelAlto = true,
Funcoes = new List<FuncoesPinout>()
{
FuncoesPinout.Rele,
},
StatusControle = Estado.Desligado,
ControleExterno = true,
},
new SensorReleModel()
{
ID = "RLPOTDF",
Descricao = "Relé alimentação Direcional DF",
Componente = S_Code.sRLE,
Controlar = true,
AtuacaoNivelAlto = true,
Funcoes = new List<FuncoesPinout>()
{
FuncoesPinout.Rele,
},
StatusControle = Estado.Desligado,
ControleExterno = true,
},
}, },
Servos = new List<SensorServoModel>() Servos = new List<SensorServoModel>()
{ {

View File

@ -683,6 +683,7 @@ namespace AgroBase.Services
{ {
leitura.Entradas[0] = LimitIO.Get(0) ? false : true; leitura.Entradas[0] = LimitIO.Get(0) ? false : true;
} }
break; break;
case 0x32: // Velocidade atual (RPM) case 0x32: // Velocidade atual (RPM)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long