ajustado referenciamento
This commit is contained in:
parent
dd63a55523
commit
91ff480bbb
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -3,16 +3,28 @@
|
|||
"WorkspaceRootPath": "C:\\ZendionINC\\agrobot_base\\AgroBase\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\models\\modules\\atuadormodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\modules\\atuadormodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\models\\operacoes\\operacaomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\operacoes\\operacaomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\models\\modules\\sensoriamentomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\modules\\sensoriamentomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\models\\modules\\movimentacaounificadomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\modules\\movimentacaounificadomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\services\\canservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\models\\modules\\direcionalmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\modules\\direcionalmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\services\\mks057dcanservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\services\\mks057dcanservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\services\\canservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\services\\canservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\models\\mks057dmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\mks057dmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
|
|
@ -22,45 +34,84 @@
|
|||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 1,
|
||||
"SelectedChildIndex": 3,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"DocumentIndex": 5,
|
||||
"Title": "MKS057DModel.cs",
|
||||
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\MKS057DModel.cs",
|
||||
"RelativeDocumentMoniker": "AgroBase\\Models\\MKS057DModel.cs",
|
||||
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\MKS057DModel.cs",
|
||||
"RelativeToolTip": "AgroBase\\Models\\MKS057DModel.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA4AAAA6AAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-04-14T22:08:11.705Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 4,
|
||||
"Title": "CANService.cs",
|
||||
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Services\\CANService.cs",
|
||||
"RelativeDocumentMoniker": "AgroBase\\Services\\CANService.cs",
|
||||
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Services\\CANService.cs",
|
||||
"RelativeToolTip": "AgroBase\\Services\\CANService.cs",
|
||||
"ViewState": "AQIAAAMAAAAAAAAAAAAAABwAAAAAAAAA",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAADoAAAAlAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-04-14T11:55:37.44Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "AtuadorModel.cs",
|
||||
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\AtuadorModel.cs",
|
||||
"RelativeDocumentMoniker": "AgroBase\\Models\\Modules\\AtuadorModel.cs",
|
||||
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\AtuadorModel.cs",
|
||||
"RelativeToolTip": "AgroBase\\Models\\Modules\\AtuadorModel.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAEgDAAAiAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-04-12T19:46:19.183Z",
|
||||
"WhenOpened": "2025-04-14T19:46:16.662Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "SensoriamentoModel.cs",
|
||||
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\SensoriamentoModel.cs",
|
||||
"RelativeDocumentMoniker": "AgroBase\\Models\\Modules\\SensoriamentoModel.cs",
|
||||
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\SensoriamentoModel.cs",
|
||||
"RelativeToolTip": "AgroBase\\Models\\Modules\\SensoriamentoModel.cs",
|
||||
"ViewState": "AQIAAIkEAAAAAAAAAAAkwM4FAAAeAAAA",
|
||||
"Title": "MovimentacaoUnificadoModel.cs",
|
||||
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\MovimentacaoUnificadoModel.cs",
|
||||
"RelativeDocumentMoniker": "AgroBase\\Models\\Modules\\MovimentacaoUnificadoModel.cs",
|
||||
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\MovimentacaoUnificadoModel.cs",
|
||||
"RelativeToolTip": "AgroBase\\Models\\Modules\\MovimentacaoUnificadoModel.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAIUBAAA9AAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-04-12T19:46:16.524Z",
|
||||
"WhenOpened": "2025-04-14T19:32:58.021Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "OperacaoModel.cs",
|
||||
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
|
||||
"RelativeDocumentMoniker": "AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
|
||||
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
|
||||
"RelativeToolTip": "AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
|
||||
"ViewState": "AQIAAAQBAAAAAAAAAAAywCwBAAAIAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-04-14T16:46:36.149Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"Title": "MKS057DCanService.cs",
|
||||
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Services\\MKS057DCanService.cs",
|
||||
"RelativeDocumentMoniker": "AgroBase\\Services\\MKS057DCanService.cs",
|
||||
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Services\\MKS057DCanService.cs",
|
||||
"RelativeToolTip": "AgroBase\\Services\\MKS057DCanService.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA0AAABRAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-04-14T16:42:11.447Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "DirecionalModel.cs",
|
||||
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\DirecionalModel.cs",
|
||||
"RelativeDocumentMoniker": "AgroBase\\Models\\Modules\\DirecionalModel.cs",
|
||||
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\DirecionalModel.cs",
|
||||
"RelativeToolTip": "AgroBase\\Models\\Modules\\DirecionalModel.cs",
|
||||
"ViewState": "AQIAAGQBAAAAAAAAAIAwwJkBAAA/AAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-04-14T16:38:57.306Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ namespace AgroBase.Forms.Operacoes
|
|||
double Angulo = Modulo.DirMotor.Angulo;
|
||||
|
||||
Label lblAngulo = pnl.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lblDir_" + ID);
|
||||
lblAngulo.Text = ID + " " + Angulo.ToString("000") + "º";
|
||||
lblAngulo.Text = ID + " " + Angulo.ToString("000") + "º (" + Modulo.DirMotor.SentidoReal.ToString() + ")";
|
||||
lblAngulo.ForeColor = Modulo.DirMotor.Inicializado ? Color.Green : Color.Red;
|
||||
|
||||
Label lblMov = pnl.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lblMov_" + ID);
|
||||
|
|
@ -474,12 +474,12 @@ namespace AgroBase.Forms.Operacoes
|
|||
gridDados.Rows[20].Cells[1].Value = _Sensoriamento.Atuador.VazaoMedia.ToString("0.00");
|
||||
gridDados.Rows[21].Cells[1].Value = _Sensoriamento.Atuador.VolumeVazaoMl.ToString("0.00");
|
||||
gridDados.Rows[22].Cells[1].Value = "";
|
||||
gridDados.Rows[23].Cells[1].Value = _SensorIMU.Roll.ToString("0.00");
|
||||
gridDados.Rows[24].Cells[1].Value = _SensorIMU.Pitch.ToString("0.00");
|
||||
gridDados.Rows[25].Cells[1].Value = _SensorIMU.Yaw.ToString("0.00");
|
||||
gridDados.Rows[26].Cells[1].Value = _SensorIMU.Temperatura.ToString("0.00");
|
||||
gridDados.Rows[27].Cells[1].Value = _SensorIMU.Pressao.ToString("0.00");
|
||||
gridDados.Rows[28].Cells[1].Value = _SensorIMU.Altitude.ToString("0.00");
|
||||
gridDados.Rows[23].Cells[1].Value = (_SensorIMU?.Roll ?? 0).ToString("0.00");
|
||||
gridDados.Rows[24].Cells[1].Value = (_SensorIMU?.Pitch ?? 0).ToString("0.00");
|
||||
gridDados.Rows[25].Cells[1].Value = (_SensorIMU?.Yaw ?? 0).ToString("0.00");
|
||||
gridDados.Rows[26].Cells[1].Value = (_SensorIMU?.Temperatura ?? 0).ToString("0.00");
|
||||
gridDados.Rows[27].Cells[1].Value = (_SensorIMU?.Pressao ?? 0).ToString("0.00");
|
||||
gridDados.Rows[28].Cells[1].Value = (_SensorIMU?.Altitude ?? 0).ToString("0.00");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
get
|
||||
{
|
||||
// Houve comandos recebidos do driver dentro dos ultimos 10 segundos
|
||||
int tempo = MKS057DCanService.UltimoReferenciamento.AddSeconds(10) > DateTime.Now || MKS057DCanService.Referenciando ? 120 : 10;
|
||||
return UltimoComandoRecebido.AddSeconds(tempo) > DateTime.Now;
|
||||
return UltimoComandoRecebido.AddSeconds(10) > DateTime.Now;
|
||||
}
|
||||
}
|
||||
public DateTime UltimoComandoRecebido { get; set; }
|
||||
|
|
|
|||
|
|
@ -54,7 +54,14 @@ namespace AgroBase.Models.Modules
|
|||
{
|
||||
get
|
||||
{
|
||||
return IN1_Atuado ? Sentido.Horario : Sentido.Antihorario;
|
||||
if (Mod_ID == "EF" || Mod_ID == "DT")
|
||||
{
|
||||
return IN1_Atuado ? Sentido.Antihorario : Sentido.Horario;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IN1_Atuado ? Sentido.Horario : Sentido.Antihorario;
|
||||
}
|
||||
}
|
||||
}
|
||||
public double Angulo
|
||||
|
|
@ -75,17 +82,17 @@ namespace AgroBase.Models.Modules
|
|||
{
|
||||
get
|
||||
{
|
||||
return (Leitura?.Entradas?[0] ?? false);
|
||||
return !(Leitura?.Entradas?[0] ?? false);
|
||||
}
|
||||
}
|
||||
public bool IN2_Atuado
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Leitura?.Entradas?[1] ?? false);
|
||||
return !(Leitura?.Entradas?[1] ?? false);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Referenciando { get; set; } = false;
|
||||
|
||||
public bool Comandar { get; set; } = false;
|
||||
public bool Inicializado
|
||||
|
|
@ -321,65 +328,72 @@ namespace AgroBase.Models.Modules
|
|||
|
||||
public async Task ReferenciaMotor()
|
||||
{
|
||||
byte Addr = EnderecoByte;
|
||||
|
||||
MKS057DCanService.IniciarReferenciamento(Addr);
|
||||
Referenciando = true;
|
||||
|
||||
await Task.Delay(1000);
|
||||
|
||||
//await MKS057DService.EnviarComandoControle(MKS057DService.MontarComandoSetZero(Addr));
|
||||
await SetZero(Addr);
|
||||
await SetZero();
|
||||
|
||||
bool Sucesso = false;
|
||||
bool EstadoInicial = IN1_Atuado;
|
||||
double AnguloEntrada = 9999;
|
||||
double AnguloSaida = 9999;
|
||||
|
||||
|
||||
DateTime TimeoutGeral = DateTime.Now.AddMinutes(2); // Timeout geral para o processo.
|
||||
|
||||
Sentido _sentido = SentidoReal == Sentido.Horario ? Sentido.Antihorario : Sentido.Horario;
|
||||
double _anguloSP = 180 * (_sentido == Sentido.Antihorario ? -1 : 1);
|
||||
double _anguloSP = 360 * (_sentido == Sentido.Antihorario ? -1 : 1);
|
||||
double _anguloSpAnterior = 0;
|
||||
|
||||
while (!Sucesso && TimeoutGeral > DateTime.Now)
|
||||
{
|
||||
int VelocidadeGiro = DefineVelocidadeReferenciamento();
|
||||
|
||||
//await MKS057DService.EnviarComandoControle(MKS057DService.MontarComandoMovimento(Addr, _angulo, VelocidadeGiro, _sentido));
|
||||
MKS057DCanService.Movimento(Addr, _anguloSP, VelocidadeGiro, _sentido);
|
||||
if (_anguloSP != _anguloSpAnterior)
|
||||
{
|
||||
MKS057DCanService.Movimento(EnderecoByte, _anguloSP, VelocidadeGiro, _sentido);
|
||||
_anguloSpAnterior = _anguloSP;
|
||||
}
|
||||
|
||||
if (IN1_Atuado != EstadoInicial && AnguloEntrada == 9999)
|
||||
{
|
||||
Console.WriteLine($"Angulo de Entrada Definido: {Angulo}");
|
||||
AnguloEntrada = Angulo;
|
||||
MKS057DCanService.Movimento(Addr, Angulo, VelocidadeGiro, _sentido);
|
||||
await SetZero(Addr);
|
||||
_sentido = SentidoReal == Sentido.Horario ? Sentido.Antihorario : Sentido.Horario;
|
||||
_anguloSP = 180 * (_sentido == Sentido.Antihorario ? -1 : 1);
|
||||
//MKS057DCanService.Movimento(Addr, Angulo, VelocidadeGiro, _sentido);
|
||||
//await Task.Delay(100);
|
||||
//await SetZero(Addr);
|
||||
//await Task.Delay(500);
|
||||
_sentido = _sentido == Sentido.Horario ? Sentido.Antihorario : Sentido.Horario;
|
||||
_anguloSP *= -1;
|
||||
Console.WriteLine($"Invertendo Sentido de Giro para {_sentido.ToString()}");
|
||||
}
|
||||
else if (IN1_Atuado == EstadoInicial && AnguloEntrada != 9999 && AnguloSaida == 9999)
|
||||
if (IN1_Atuado == EstadoInicial && AnguloEntrada != 9999 && AnguloSaida == 9999)
|
||||
{
|
||||
Console.WriteLine($"Angulo de Saída Definido: {Angulo}");
|
||||
AnguloSaida = Angulo;
|
||||
MKS057DCanService.Movimento(Addr, Angulo, VelocidadeGiro, _sentido);
|
||||
|
||||
_sentido = _sentido == Sentido.Horario ? Sentido.Antihorario : Sentido.Horario;
|
||||
Console.WriteLine($"Invertendo Sentido de Giro para {_sentido.ToString()}");
|
||||
|
||||
_sentido = SentidoReal == Sentido.Horario ? Sentido.Antihorario : Sentido.Horario;
|
||||
|
||||
_anguloSP = AnguloSaida / 2.0;
|
||||
_anguloSP = CalcularCentroCompensado(AnguloEntrada, AnguloSaida, FolgaMecanica, _sentido);
|
||||
|
||||
//await MKS057DService.EnviarComandoControle(MKS057DService.MontarComandoMovimento(Addr, _centro, 36, Sentido.Horario));
|
||||
MKS057DCanService.Movimento(Addr, _anguloSP, VelocidadeGiro, _sentido);
|
||||
await Task.Delay(2000);
|
||||
await SetZero(Addr);
|
||||
//MKS057DCanService.Movimento(EnderecoByte, _centro, VelocidadeGiro, _sentido);
|
||||
//await Task.Delay(2000);
|
||||
//await SetZero();
|
||||
}
|
||||
|
||||
Sucesso = AnguloEntrada != 9999 && AnguloSaida != 9999 && FuncoesMatematicas.ValorEstaEntre(AnguloSaida, 0, 0.5);
|
||||
Sucesso = AnguloEntrada != 9999 && AnguloSaida != 9999 && FuncoesMatematicas.ValorEstaEntre(Angulo, _anguloSP, 0.5);
|
||||
if (Sucesso)
|
||||
{
|
||||
await SetZero();
|
||||
Console.WriteLine($"Referenciamento Concluído!");
|
||||
}
|
||||
}
|
||||
|
||||
if (!Sucesso)
|
||||
{
|
||||
//await MKS057DService.EnviarComandoControle(MKS057DService.MontarComandoParada(Addr));
|
||||
MKS057DCanService.Parar(Addr);
|
||||
}
|
||||
|
||||
MKS057DCanService.FinalizarReferenciamento();
|
||||
Referenciando = false;
|
||||
}
|
||||
|
||||
private int DefineVelocidadeReferenciamento()
|
||||
|
|
@ -393,7 +407,7 @@ namespace AgroBase.Models.Modules
|
|||
double centro = (entrada + saida) / 2.0;
|
||||
|
||||
// Determina o sentido do giro baseado na diferença
|
||||
double direcao = sentido == Sentido.Horario ? 1 : -1;
|
||||
double direcao = sentido == Sentido.Horario ? -1 : 1;
|
||||
|
||||
double compensacao = (folga / 2.0) * direcao;
|
||||
|
||||
|
|
@ -404,19 +418,27 @@ namespace AgroBase.Models.Modules
|
|||
return centroCompensado;
|
||||
}
|
||||
|
||||
private async Task SetZero(byte Addr)
|
||||
private async Task SetZero()
|
||||
{
|
||||
MKS057DCanService.SetZero(EnderecoByte);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
MKS057DCanService.SetZero(Addr);
|
||||
|
||||
await Task.Delay(500);
|
||||
|
||||
if (FuncoesMatematicas.ValorEstaEntre(Angulo, 0, 1))
|
||||
{
|
||||
Console.WriteLine($"Set Zero");
|
||||
break;
|
||||
}
|
||||
|
||||
await Task.Delay(1000);
|
||||
else
|
||||
{
|
||||
MKS057DCanService.SetZero(EnderecoByte);
|
||||
}
|
||||
}
|
||||
|
||||
MKS057DCanService.Movimento(EnderecoByte, 0, 10, Sentido.Parado);
|
||||
Console.WriteLine($"Comando Angulo Zero: {Angulo}");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,21 +318,18 @@ namespace AgroBase.Models.Modules
|
|||
foreach (var Modulo in Modulos.Where(x => x.DirMotor.Inicializado))
|
||||
{
|
||||
byte modAddr = Modulo.DirMotor.EnderecoByte;
|
||||
if (!MKS057DCanService.Referenciando || (MKS057DCanService.Referenciando && MKS057DCanService.AddrRef == modAddr))
|
||||
{
|
||||
//MKS057DService.AdicionarComandoNaFila(MKS057DService.MontarComandoRequisicaoPulsos(modAddr));
|
||||
MKS057DCanService.RequisitarDado(modAddr, MKS057DCanService.MksHandler.MksFuncCode.PulsosRecebidos);
|
||||
//MKS057DService.AdicionarComandoNaFila(MKS057DService.MontarComandoRequisicaoIO(modAddr));
|
||||
MKS057DCanService.RequisitarDado(modAddr, MKS057DCanService.MksHandler.MksFuncCode.IO);
|
||||
//MKS057DService.AdicionarComandoNaFila(MKS057DService.MontarComandoRequisicaoPulsos(modAddr));
|
||||
MKS057DCanService.RequisitarDado(modAddr, MKS057DCanService.MksHandler.MksFuncCode.PulsosRecebidos);
|
||||
//MKS057DService.AdicionarComandoNaFila(MKS057DService.MontarComandoRequisicaoIO(modAddr));
|
||||
MKS057DCanService.RequisitarDado(modAddr, MKS057DCanService.MksHandler.MksFuncCode.IO);
|
||||
|
||||
// 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 (!MKS057DCanService.Referenciando && (Modulo.DirMotor.UltimoComandoEnviado.AddMilliseconds(MKS057DCanService.TaxaAmostragem) < DateTime.Now) && !Modulo.DirMotor.AtingiuAnguloSP)
|
||||
// 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 (!MKS057DCanService.Referenciando && (Modulo.DirMotor.UltimoComandoEnviado.AddMilliseconds(MKS057DCanService.TaxaAmostragem) < DateTime.Now) && !Modulo.DirMotor.AtingiuAnguloSP)
|
||||
{
|
||||
var Controle = Variaveis.OperacaoEmAndamento.Controle.TiposControle?.FirstOrDefault(x => x.Tipo == T_Code.Dir);
|
||||
if (Controle != null)
|
||||
{
|
||||
var Controle = Variaveis.OperacaoEmAndamento.Controle.TiposControle?.FirstOrDefault(x => x.Tipo == T_Code.Dir);
|
||||
if (Controle != null)
|
||||
{
|
||||
Modulo.DirMotor.EnviarComandoControle(Controle.UltimaDirecao);
|
||||
}
|
||||
Modulo.DirMotor.EnviarComandoControle(Controle.UltimaDirecao);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -397,10 +394,11 @@ namespace AgroBase.Models.Modules
|
|||
TipoMovimentoDirecional tipoControle = Variaveis.OperacaoEmAndamento.Controle.TipoMovimento;
|
||||
|
||||
Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = TipoMovimentoDirecional.Diagnostico;
|
||||
var ModsRef = Modulos.Where(x => x.DirMotor.Comandar && x.DirMotor.Inicializado && !x.DirMotor.IN1_Atuado).ToList();
|
||||
var ModsRef = Modulos.Where(x => x.DirMotor.Comandar && x.DirMotor.Inicializado).ToList();
|
||||
foreach (var Modulo in ModsRef)
|
||||
{
|
||||
await Modulo.DirMotor.ReferenciaMotor();
|
||||
Task.Run(async () => await Modulo.DirMotor.ReferenciaMotor());
|
||||
//await Modulo.DirMotor.ReferenciaMotor();
|
||||
}
|
||||
Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = tipoControle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1823,7 +1823,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
Variaveis.OperacaoEmAndamento.AtualizarDadosControle(true);
|
||||
}
|
||||
else
|
||||
else if (Variaveis.OperacaoEmAndamento.Modo == ModoOperacao.Manual && !MKS057DCanService.Referenciando)
|
||||
{
|
||||
GeneralJoystick.EnviaComandoMotor(Keys.Escape, T_Code.Mov, true);
|
||||
GeneralJoystick.EnviaComandoMotor(Keys.Escape, T_Code.Dir, true);
|
||||
|
|
@ -2373,7 +2373,7 @@ namespace AgroBase.Models
|
|||
Cod |= 0x1000; // Bit 12: Movimentação Direita inoperante
|
||||
|
||||
// Verificação de falhas específicas em `modsComFalha`
|
||||
foreach (var modFalha in modsComFalha)
|
||||
foreach (var modFalha in modsComFalha ?? new List<T_Code>())
|
||||
{
|
||||
switch (modFalha)
|
||||
{
|
||||
|
|
@ -2426,7 +2426,7 @@ namespace AgroBase.Models
|
|||
}
|
||||
|
||||
// Verificação de `atuModsFalha`
|
||||
foreach (var falha in atuModsFalha)
|
||||
foreach (var falha in atuModsFalha ?? new List<string>())
|
||||
{
|
||||
switch (falha)
|
||||
{
|
||||
|
|
@ -2458,7 +2458,7 @@ namespace AgroBase.Models
|
|||
}
|
||||
|
||||
// Verificação de `senModsFalha`
|
||||
foreach (var falha in senModsFalha)
|
||||
foreach (var falha in senModsFalha ?? new List<string>())
|
||||
{
|
||||
switch (falha)
|
||||
{
|
||||
|
|
@ -2511,7 +2511,7 @@ namespace AgroBase.Models
|
|||
}
|
||||
|
||||
// Verificação de `dirModsFalha`
|
||||
foreach (var falha in dirModsFalha)
|
||||
foreach (var falha in dirModsFalha ?? new List<string>())
|
||||
{
|
||||
switch (falha)
|
||||
{
|
||||
|
|
@ -2531,7 +2531,7 @@ namespace AgroBase.Models
|
|||
}
|
||||
|
||||
// Verificação de `movEsqModsFalha`
|
||||
foreach (var falha in movEsqModsFalha)
|
||||
foreach (var falha in movEsqModsFalha ?? new List<string>())
|
||||
{
|
||||
switch (falha)
|
||||
{
|
||||
|
|
@ -2545,7 +2545,7 @@ namespace AgroBase.Models
|
|||
}
|
||||
|
||||
// Verificação de `movDirModsFalha`
|
||||
foreach (var falha in movDirModsFalha)
|
||||
foreach (var falha in movDirModsFalha ?? new List<string>())
|
||||
{
|
||||
switch (falha)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ namespace AgroBase.Services
|
|||
{
|
||||
_PortaCAN.Write(comando);
|
||||
|
||||
Console.WriteLine($"[CAN] Frame enviado: {comando}");
|
||||
//Console.WriteLine($"[CAN] Frame enviado: {comando}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,11 @@ namespace AgroBase.Services
|
|||
return CanService.IsConnected && SerialService.DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Dir) && DadosLeitura.Any(x => x.Iniciado);
|
||||
}
|
||||
}
|
||||
public static byte AddrRef = 0x00;
|
||||
public static bool Referenciando
|
||||
{
|
||||
get
|
||||
{
|
||||
return AddrRef > 0x00;
|
||||
return Variaveis.OperacaoEmAndamento.DispMvd?.Dados?.Modulos?.Any(x => x?.DirMotor?.Referenciando ?? false) ?? false;
|
||||
}
|
||||
}
|
||||
public static DateTime UltimoReferenciamento = DateTime.MinValue;
|
||||
|
|
@ -36,7 +35,7 @@ namespace AgroBase.Services
|
|||
{
|
||||
get
|
||||
{
|
||||
return Referenciando ? 100 : 300;
|
||||
return Referenciando ? 50 : 300;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,18 +132,6 @@ namespace AgroBase.Services
|
|||
return val;
|
||||
}
|
||||
|
||||
public static void IniciarReferenciamento(byte Addr)
|
||||
{
|
||||
AddrRef = Addr;
|
||||
UltimoReferenciamento = DateTime.Now;
|
||||
}
|
||||
|
||||
public static void FinalizarReferenciamento()
|
||||
{
|
||||
AddrRef = 0x00;
|
||||
UltimoReferenciamento = DateTime.Now;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region COMANDOS
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace AgroBase.Services
|
|||
public static List<T_Code> DispositivosConexaoInicial = new List<T_Code>() { T_Code.Mvd, T_Code.Atu, T_Code.Sen };
|
||||
public static List<T_Code> DispositivosProprios = new List<T_Code>() { T_Code.Atu, T_Code.Sen };
|
||||
public static List<T_Code> DispositivosModbus = new List<T_Code>() { T_Code.Pzm, T_Code.Wit, T_Code.A05 };
|
||||
public static List<T_Code> DispositivosCan = new List<T_Code>() { T_Code.Mks, T_Code.Sen, T_Code.Atu };
|
||||
public static List<T_Code> DispositivosCan = new List<T_Code>() { T_Code.Dir, T_Code.Mks, T_Code.Sen, T_Code.Atu };
|
||||
public static List<T_Code> DispositivosMultiplos = new List<T_Code>() { T_Code.Bld, T_Code.Mks, T_Code.Mvd, T_Code.Oid, T_Code.Mov, T_Code.Dir };
|
||||
|
||||
public static List<DispositivoDetalhesModel> DispositivosMapeados = new List<DispositivoDetalhesModel>();
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -25,7 +25,7 @@
|
|||
<meta name="viewport" content="width=device-width,
|
||||
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<style>
|
||||
#map_9732a3a481e157ff8ba61a30462a8ce8 {
|
||||
#map_f39a2eeeafc2e53a380e049fb0eabbad {
|
||||
position: relative;
|
||||
width: 100.0%;
|
||||
height: 100.0%;
|
||||
|
|
@ -39,14 +39,14 @@
|
|||
<body>
|
||||
|
||||
|
||||
<div class="folium-map" id="map_9732a3a481e157ff8ba61a30462a8ce8" ></div>
|
||||
<div class="folium-map" id="map_f39a2eeeafc2e53a380e049fb0eabbad" ></div>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
|
||||
|
||||
var map_9732a3a481e157ff8ba61a30462a8ce8 = L.map(
|
||||
"map_9732a3a481e157ff8ba61a30462a8ce8",
|
||||
var map_f39a2eeeafc2e53a380e049fb0eabbad = L.map(
|
||||
"map_f39a2eeeafc2e53a380e049fb0eabbad",
|
||||
{
|
||||
center: [0.0, 0.0],
|
||||
crs: L.CRS.EPSG3857,
|
||||
|
|
@ -60,13 +60,13 @@
|
|||
|
||||
|
||||
|
||||
var tile_layer_b28cc1434b76a05db69db0ade9dd15a6 = L.tileLayer(
|
||||
var tile_layer_3f2633897e8c84372d3f03a0dd6f2143 = L.tileLayer(
|
||||
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
|
||||
);
|
||||
|
||||
|
||||
tile_layer_b28cc1434b76a05db69db0ade9dd15a6.addTo(map_9732a3a481e157ff8ba61a30462a8ce8);
|
||||
tile_layer_3f2633897e8c84372d3f03a0dd6f2143.addTo(map_f39a2eeeafc2e53a380e049fb0eabbad);
|
||||
|
||||
</script>
|
||||
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
}
|
||||
trajeto_json_add({"features": []});
|
||||
|
||||
trajeto_json.addTo(map_9732a3a481e157ff8ba61a30462a8ce8);
|
||||
trajeto_json.addTo(map_f39a2eeeafc2e53a380e049fb0eabbad);
|
||||
|
||||
function adicionarGeometria(novaGeometria) {
|
||||
trajeto_json.addData(novaGeometria);
|
||||
|
|
@ -145,7 +145,7 @@
|
|||
|
||||
var marcadorDinamico = L.marker([0, 0], {
|
||||
icon: customIcon
|
||||
}).addTo(map_9732a3a481e157ff8ba61a30462a8ce8);
|
||||
}).addTo(map_f39a2eeeafc2e53a380e049fb0eabbad);
|
||||
|
||||
// Conectar ao broker MQTT
|
||||
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
|
||||
|
|
@ -183,7 +183,7 @@
|
|||
marcadorDinamico.setRotationAngle(angulo);
|
||||
|
||||
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
||||
map_9732a3a481e157ff8ba61a30462a8ce8.setView(novaPosicao, map_9732a3a481e157ff8ba61a30462a8ce8.getZoom());
|
||||
map_f39a2eeeafc2e53a380e049fb0eabbad.setView(novaPosicao, map_f39a2eeeafc2e53a380e049fb0eabbad.getZoom());
|
||||
});
|
||||
|
||||
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -482,4 +482,4 @@ C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.GenerateR
|
|||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CoreCompileInputs.cache
|
||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.exe
|
||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.pdb
|
||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CopyComplete
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.Up2Date
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue