ajuste para reducao diferente por roda direcional
This commit is contained in:
parent
566e49c844
commit
4dec95cbbb
|
|
@ -1,6 +1,7 @@
|
||||||
using AgroBase.Services;
|
using AgroBase.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using static AgroBase.Models.Enums;
|
using static AgroBase.Models.Enums;
|
||||||
|
|
||||||
namespace AgroBase.Models
|
namespace AgroBase.Models
|
||||||
|
|
@ -42,6 +43,8 @@ namespace AgroBase.Models
|
||||||
public int NumeroPulsosAbsoluto { get; set; }
|
public int NumeroPulsosAbsoluto { get; set; }
|
||||||
public double AnguloPulsosAbsoluto { get; set; }
|
public double AnguloPulsosAbsoluto { get; set; }
|
||||||
|
|
||||||
|
public double Reducao => Variaveis.OperacaoEmAndamento?.DispMvd?.Dados?.Modulos?.FirstOrDefault(x => x.DirMotor._EnderecoCAN_Tx == EnderecoTx)?.DirMotor?.Reducao ?? VariaveisEquipamento.ReducaoDirecional;
|
||||||
|
|
||||||
public int NumeroPulsosRelativo { get; set; }
|
public int NumeroPulsosRelativo { get; set; }
|
||||||
public double AnguloPulsosRelativo { get; set; }
|
public double AnguloPulsosRelativo { get; set; }
|
||||||
public double ErroAngulo { get; set; }
|
public double ErroAngulo { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace AgroBase.Models.Modules
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Convert.ToInt32(((Variaveis.OperacaoEmAndamento.Parametros?.Controle?.DirVelocidadeMovimento ?? 0) / 100.0) * Velocidade_Max);
|
return Convert.ToInt32(((Variaveis.OperacaoEmAndamento.Parametros?.Controle?.DirVelocidadeMovimento ?? 0) / 100.0) * Velocidade_Max * FatorVelocidadeReducao);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,6 +80,8 @@ namespace AgroBase.Models.Modules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public double AnguloFolgaCompensar { get; set; }
|
public double AnguloFolgaCompensar { get; set; }
|
||||||
|
public double? Reducao { get; set; }
|
||||||
|
public double FatorVelocidadeReducao => (Reducao ?? VariaveisEquipamento.ReducaoDirecional) / 20.0;
|
||||||
public double OffsetAnguloReal { get; set; }
|
public double OffsetAnguloReal { get; set; }
|
||||||
public double RPM
|
public double RPM
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using AgroBase.Models;
|
using AgroBase.Models;
|
||||||
|
using AgroBase.Models.Modules;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -496,19 +497,19 @@ namespace AgroBase.Services
|
||||||
// Utils
|
// Utils
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
||||||
private static int ConverterAnguloParaValor(double angulo, ModosControle modo)
|
private static int ConverterAnguloParaValor(double angulo, ModosControle modo, double reducao)
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
|
||||||
if (modo == ModosControle.Pulsos)
|
if (modo == ModosControle.Pulsos)
|
||||||
{
|
{
|
||||||
double pulsos = _MStep * 200.0;
|
double pulsos = _MStep * 200.0;
|
||||||
double relacao = (pulsos * VariaveisEquipamento.ReducaoDirecional) / 360.0;
|
double relacao = (pulsos * reducao) / 360.0;
|
||||||
val = Convert.ToInt32(angulo * relacao);
|
val = Convert.ToInt32(angulo * relacao);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
val = Convert.ToInt32(angulo * VariaveisEquipamento.ReducaoDirecional);
|
val = Convert.ToInt32(angulo * reducao);
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
|
|
@ -817,12 +818,14 @@ namespace AgroBase.Services
|
||||||
ModosControle modo = ModosControle.AnguloAbsoluto)
|
ModosControle modo = ModosControle.AnguloAbsoluto)
|
||||||
{
|
{
|
||||||
byte funcCode;
|
byte funcCode;
|
||||||
|
double reducao = Variaveis.OperacaoEmAndamento?.DispMvd?.Dados?.Modulos?.FirstOrDefault(x => x.DirMotor._EnderecoCAN_Tx == idTx)?.DirMotor?.Reducao ?? VariaveisEquipamento.ReducaoDirecional;
|
||||||
byte[] payload =
|
byte[] payload =
|
||||||
MontarPayloadMovimento(
|
MontarPayloadMovimento(
|
||||||
angulo,
|
angulo,
|
||||||
velocidade,
|
velocidade,
|
||||||
sentido,
|
sentido,
|
||||||
modo,
|
modo,
|
||||||
|
reducao,
|
||||||
out funcCode
|
out funcCode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -905,6 +908,7 @@ namespace AgroBase.Services
|
||||||
int velocidade,
|
int velocidade,
|
||||||
Sentido sentido,
|
Sentido sentido,
|
||||||
ModosControle modo,
|
ModosControle modo,
|
||||||
|
double reducao,
|
||||||
out byte funcCode)
|
out byte funcCode)
|
||||||
{
|
{
|
||||||
List<byte> payload = new List<byte>();
|
List<byte> payload = new List<byte>();
|
||||||
|
|
@ -918,7 +922,7 @@ namespace AgroBase.Services
|
||||||
{
|
{
|
||||||
byte sentidoByte = sentido == Sentido.Horario ? (byte)0x80 : (byte)0x00;
|
byte sentidoByte = sentido == Sentido.Horario ? (byte)0x80 : (byte)0x00;
|
||||||
|
|
||||||
uint pulsos = (uint)ConverterAnguloParaValor(angulo, modo);
|
uint pulsos = (uint)ConverterAnguloParaValor(angulo, modo, reducao);
|
||||||
byte[] pulsosBytes = BitConverter.GetBytes(pulsos);
|
byte[] pulsosBytes = BitConverter.GetBytes(pulsos);
|
||||||
|
|
||||||
velocidadeBytes[1] |= sentidoByte;
|
velocidadeBytes[1] |= sentidoByte;
|
||||||
|
|
@ -935,7 +939,7 @@ namespace AgroBase.Services
|
||||||
return payload.ToArray();
|
return payload.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = ConverterAnguloParaValor(angulo, modo);
|
int pos = ConverterAnguloParaValor(angulo, modo, reducao);
|
||||||
|
|
||||||
long absAxisText = Convert.ToInt32(pos.ToString(), 10);
|
long absAxisText = Convert.ToInt32(pos.ToString(), 10);
|
||||||
byte[] absAxis = BitConverter.GetBytes(absAxisText * 16384 / 360);
|
byte[] absAxis = BitConverter.GetBytes(absAxisText * 16384 / 360);
|
||||||
|
|
@ -1027,9 +1031,8 @@ namespace AgroBase.Services
|
||||||
ModoControlePulsos = 0xFD
|
ModoControlePulsos = 0xFD
|
||||||
}
|
}
|
||||||
|
|
||||||
private double PulsosRecebidosParaAngulo(int valor)
|
private double PulsosRecebidosParaAngulo(int valor, double reducao)
|
||||||
{
|
{
|
||||||
double reducao = VariaveisEquipamento.ReducaoDirecional;
|
|
||||||
double pulsos = _MStep * 200.0;
|
double pulsos = _MStep * 200.0;
|
||||||
double relacao = (pulsos * reducao) / 360.0;
|
double relacao = (pulsos * reducao) / 360.0;
|
||||||
|
|
||||||
|
|
@ -1235,7 +1238,7 @@ namespace AgroBase.Services
|
||||||
int pulsos = DecodeInt32BE(data, 1);
|
int pulsos = DecodeInt32BE(data, 1);
|
||||||
|
|
||||||
item.NumeroPulsos.valor = pulsos;
|
item.NumeroPulsos.valor = pulsos;
|
||||||
item.AnguloPulsos = PulsosRecebidosParaAngulo(pulsos);
|
item.AnguloPulsos = PulsosRecebidosParaAngulo(pulsos, item.Reducao);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessarIo(MKS057DModel item, byte[] data)
|
private void ProcessarIo(MKS057DModel item, byte[] data)
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue