2024-05-22 14:21:39 -03:00
|
|
|
|
using System.Windows;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
using System.Windows.Controls;
|
2024-05-21 07:52:44 -03:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
using CtrEditor.Convertidores;
|
2024-05-11 15:55:44 -03:00
|
|
|
|
using CtrEditor.Siemens;
|
2024-05-21 07:52:44 -03:00
|
|
|
|
using CtrEditor.Simulacion;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
|
2024-05-18 18:14:46 -03:00
|
|
|
|
|
2024-05-21 07:52:44 -03:00
|
|
|
|
namespace CtrEditor.ObjetosSim
|
2024-05-11 11:58:55 -03:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for ucTransporteCurva.xaml
|
|
|
|
|
/// </summary>
|
2024-05-21 07:52:44 -03:00
|
|
|
|
public partial class osTransporteCurva : osBase, IosBase
|
2024-05-11 11:58:55 -03:00
|
|
|
|
{
|
|
|
|
|
private float frictionCoefficient;
|
|
|
|
|
private float velMax50hz; // en metros por minuto
|
|
|
|
|
private float tiempoRampa;
|
|
|
|
|
private bool esMarcha;
|
|
|
|
|
|
2024-05-22 06:19:31 -03:00
|
|
|
|
private float _velocidadActual;
|
2024-05-21 07:52:44 -03:00
|
|
|
|
private osBase _osMotor = null;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
|
2024-05-22 06:19:31 -03:00
|
|
|
|
private simCurve Simulation_TransporteCurva;
|
2024-05-21 07:52:44 -03:00
|
|
|
|
|
|
|
|
|
public static string NombreClase()
|
2024-05-11 11:58:55 -03:00
|
|
|
|
{
|
2024-05-21 07:52:44 -03:00
|
|
|
|
return "Transporte Curva 90";
|
2024-05-11 11:58:55 -03:00
|
|
|
|
}
|
2024-05-22 06:19:31 -03:00
|
|
|
|
private string nombre = "Transporte Curva 90";
|
|
|
|
|
public override string Nombre
|
2024-05-11 11:58:55 -03:00
|
|
|
|
{
|
2024-05-22 06:19:31 -03:00
|
|
|
|
get => nombre;
|
|
|
|
|
set => SetProperty(ref nombre, value);
|
2024-05-11 11:58:55 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-21 07:52:44 -03:00
|
|
|
|
[ObservableProperty]
|
2024-05-22 06:19:31 -03:00
|
|
|
|
private float radioExterno;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
private float radioInterno;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
private string motor;
|
2024-05-21 07:52:44 -03:00
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
2024-05-22 06:19:31 -03:00
|
|
|
|
[NotifyPropertyChangedFor(nameof(AnguloFinal))]
|
|
|
|
|
public float angulo;
|
2024-05-21 07:52:44 -03:00
|
|
|
|
|
2024-05-22 06:19:31 -03:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
[NotifyPropertyChangedFor(nameof(AnguloFinal))]
|
|
|
|
|
private float arco_en_grados;
|
|
|
|
|
|
|
|
|
|
[Hidden]
|
|
|
|
|
public float AnguloFinal
|
|
|
|
|
{
|
|
|
|
|
get => Angulo+Arco_en_grados;
|
|
|
|
|
}
|
2024-05-21 07:52:44 -03:00
|
|
|
|
|
2024-05-11 11:58:55 -03:00
|
|
|
|
public float VelocidadActual
|
|
|
|
|
{
|
2024-05-21 07:52:44 -03:00
|
|
|
|
get => _velocidadActual;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-21 07:52:44 -03:00
|
|
|
|
_velocidadActual = value;
|
2024-05-22 06:19:31 -03:00
|
|
|
|
Simulation_TransporteCurva?.SetSpeed(value);
|
2024-05-11 11:58:55 -03:00
|
|
|
|
OnPropertyChanged(nameof(VelocidadActual));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-21 07:52:44 -03:00
|
|
|
|
private void ActualizarGeometrias()
|
|
|
|
|
{
|
|
|
|
|
if (_visualRepresentation is ucTransporteCurva uc)
|
2024-05-11 11:58:55 -03:00
|
|
|
|
{
|
2024-05-22 06:19:31 -03:00
|
|
|
|
UpdateCurve(Simulation_TransporteCurva, RadioInterno, RadioExterno, Angulo, Angulo+Arco_en_grados);
|
|
|
|
|
Simulation_TransporteCurva.Speed = VelocidadActual;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float FrictionCoefficient { get => frictionCoefficient; set => frictionCoefficient = value; }
|
|
|
|
|
public float VelMax50hz { get => velMax50hz; set => velMax50hz = value; }
|
|
|
|
|
public float TiempoRampa { get => tiempoRampa; set => tiempoRampa = value; }
|
|
|
|
|
public bool EsMarcha { get => esMarcha; set => esMarcha = value; }
|
|
|
|
|
|
|
|
|
|
public osTransporteCurva()
|
|
|
|
|
{
|
2024-05-22 06:19:31 -03:00
|
|
|
|
RadioExterno = 1.3f;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
RadioInterno = 1;
|
2024-05-22 06:19:31 -03:00
|
|
|
|
Arco_en_grados = 90;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-21 07:52:44 -03:00
|
|
|
|
public override void UpdateGeometryStart()
|
2024-05-11 11:58:55 -03:00
|
|
|
|
{
|
2024-05-21 07:52:44 -03:00
|
|
|
|
// Se llama antes de la simulacion
|
|
|
|
|
ActualizarGeometrias();
|
2024-05-11 11:58:55 -03:00
|
|
|
|
}
|
2024-05-21 07:52:44 -03:00
|
|
|
|
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
|
2024-05-11 11:58:55 -03:00
|
|
|
|
{
|
2024-05-21 07:52:44 -03:00
|
|
|
|
if (_osMotor != null)
|
|
|
|
|
{
|
|
|
|
|
if (_osMotor is osVMmotorSim motor)
|
|
|
|
|
VelocidadActual = motor.Velocidad;
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-05-25 07:53:34 -03:00
|
|
|
|
_osMotor = ObtenerLink(Motor, typeof(osVMmotorSim));
|
2024-05-11 11:58:55 -03:00
|
|
|
|
}
|
2024-05-11 15:55:44 -03:00
|
|
|
|
|
2024-05-21 07:52:44 -03:00
|
|
|
|
public override void ucLoaded()
|
|
|
|
|
{
|
|
|
|
|
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
|
|
|
|
// crear el objeto de simulacion
|
|
|
|
|
ActualizarLeftTop();
|
2024-05-11 15:55:44 -03:00
|
|
|
|
|
2024-05-22 06:19:31 -03:00
|
|
|
|
if (_visualRepresentation is ucTransporteCurva uc)
|
|
|
|
|
Simulation_TransporteCurva = AddCurve(RadioInterno,RadioExterno, Angulo, Angulo + Arco_en_grados);
|
|
|
|
|
|
|
|
|
|
// AddCurve(float innerRadius, float outerRadius, float startAngle, float endAngle, Vector2 position)
|
2024-05-21 07:52:44 -03:00
|
|
|
|
}
|
|
|
|
|
public override void ucUnLoaded()
|
|
|
|
|
{
|
|
|
|
|
// El UserControl se esta eliminando
|
|
|
|
|
// eliminar el objeto de simulacion
|
2024-05-22 06:19:31 -03:00
|
|
|
|
simulationManager?.Remove(Simulation_TransporteCurva);
|
2024-05-21 07:52:44 -03:00
|
|
|
|
}
|
2024-05-11 11:58:55 -03:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class ucTransporteCurva : UserControl, IDataContainer
|
|
|
|
|
{
|
|
|
|
|
public osBase? Datos { get; set; }
|
|
|
|
|
|
|
|
|
|
public ucTransporteCurva()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-05-21 07:52:44 -03:00
|
|
|
|
this.Loaded += OnLoaded;
|
|
|
|
|
this.Unloaded += OnUnloaded;
|
|
|
|
|
}
|
|
|
|
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Datos?.ucLoaded();
|
|
|
|
|
}
|
|
|
|
|
private void OnUnloaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Datos?.ucUnLoaded();
|
2024-05-11 11:58:55 -03:00
|
|
|
|
}
|
2024-05-22 06:19:31 -03:00
|
|
|
|
public void Resize(float RadioExterno, float RadioInterno)
|
2024-05-11 11:58:55 -03:00
|
|
|
|
{
|
|
|
|
|
if (Datos is osTransporteCurva datos)
|
2024-05-22 06:19:31 -03:00
|
|
|
|
{
|
|
|
|
|
if (RadioExterno > RadioInterno && RadioExterno > 0 && RadioInterno >= 0)
|
|
|
|
|
{
|
|
|
|
|
datos.RadioExterno = PixelToMeter.Instance.calc.PixelsToMeters(RadioExterno);
|
|
|
|
|
datos.RadioInterno = PixelToMeter.Instance.calc.PixelsToMeters(RadioInterno);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-11 11:58:55 -03:00
|
|
|
|
}
|
|
|
|
|
public void Move(float LeftPixels, float TopPixels)
|
|
|
|
|
{
|
|
|
|
|
if (Datos != null)
|
|
|
|
|
{
|
|
|
|
|
Datos.Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels);
|
|
|
|
|
Datos.Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Rotate(float Angle)
|
|
|
|
|
{
|
|
|
|
|
if (Datos != null)
|
|
|
|
|
if (Datos is osTransporteCurva datos)
|
|
|
|
|
datos.Angulo = Angle;
|
|
|
|
|
}
|
|
|
|
|
public void Highlight(bool State) { }
|
|
|
|
|
public int ZIndex()
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|