2024-05-08 08:41:26 -03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
using CtrEditor.Convertidores;
|
2024-05-11 15:55:44 -03:00
|
|
|
|
using CtrEditor.Siemens;
|
2024-05-14 03:15:54 -03:00
|
|
|
|
using CtrEditor.Simulacion;
|
2024-05-14 12:10:32 -03:00
|
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
|
|
|
|
|
namespace CtrEditor.ObjetosSim
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for ucTransporteGuias.xaml
|
|
|
|
|
/// </summary>
|
2024-05-19 16:38:57 -03:00
|
|
|
|
public class osTransporteGuias : osBase, IosBase
|
2024-05-08 08:41:26 -03:00
|
|
|
|
{
|
2024-05-10 17:17:57 -03:00
|
|
|
|
private string _nombre = "Transporte Guias";
|
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
private float _distance;
|
|
|
|
|
private float _altoGuia;
|
|
|
|
|
|
2024-05-10 17:17:57 -03:00
|
|
|
|
private float frictionCoefficient;
|
|
|
|
|
private float velMax50hz; // en metros por minuto
|
|
|
|
|
private float tiempoRampa;
|
|
|
|
|
private bool esMarcha;
|
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
private float _ancho;
|
|
|
|
|
private float _alto;
|
|
|
|
|
private float _left;
|
|
|
|
|
private float _top;
|
|
|
|
|
private float _angulo;
|
|
|
|
|
private float _velocidadActual;
|
2024-05-14 12:10:32 -03:00
|
|
|
|
private osBase _osMotor = null;
|
|
|
|
|
private string _motor;
|
2024-05-14 03:15:54 -03:00
|
|
|
|
|
2024-05-18 09:58:41 -03:00
|
|
|
|
private simTransporte? TransporteCentral;
|
|
|
|
|
private simGuia? Guia_Superior;
|
|
|
|
|
private simGuia? Guia_Inferior;
|
2024-05-10 20:40:51 -03:00
|
|
|
|
|
2024-05-10 17:17:57 -03:00
|
|
|
|
|
2024-05-19 16:38:57 -03:00
|
|
|
|
public static string NombreClase()
|
|
|
|
|
{
|
|
|
|
|
return "Transporte Guias";
|
|
|
|
|
}
|
2024-05-14 12:10:32 -03:00
|
|
|
|
public string Motor
|
|
|
|
|
{
|
|
|
|
|
get => _motor;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_motor != value)
|
|
|
|
|
{
|
|
|
|
|
_motor = value;
|
|
|
|
|
OnPropertyChanged(nameof(Motor));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 17:17:57 -03:00
|
|
|
|
public override float Left
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _left;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_left = value;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
CanvasSetLeftinMeter(value);
|
|
|
|
|
OnPropertyChanged(nameof(Left));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public override float Top
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _top;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_top = value;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
CanvasSetTopinMeter(value);
|
|
|
|
|
OnPropertyChanged(nameof(Top));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Ancho
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _ancho;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_ancho = value;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
OnPropertyChanged(nameof(Ancho));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public float Alto
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _alto;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_alto = value;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
OnPropertyChanged(nameof(Alto));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Angulo
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _angulo;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_angulo = value;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
OnPropertyChanged(nameof(Angulo));
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-14 03:15:54 -03:00
|
|
|
|
|
2024-05-10 17:17:57 -03:00
|
|
|
|
public float VelocidadActual
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _velocidadActual;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_velocidadActual = value;
|
|
|
|
|
TransporteCentral?.SetSpeed(value);
|
2024-05-10 17:17:57 -03:00
|
|
|
|
OnPropertyChanged(nameof(VelocidadActual));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
public float Distance
|
2024-05-10 20:40:51 -03:00
|
|
|
|
{
|
|
|
|
|
get { return _distance; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_distance != value)
|
|
|
|
|
{
|
|
|
|
|
_distance = value;
|
2024-05-14 03:15:54 -03:00
|
|
|
|
OnPropertyChanged(nameof(Distance));
|
2024-05-10 20:40:51 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
public float AltoGuia
|
|
|
|
|
{
|
|
|
|
|
get => _altoGuia;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_altoGuia = value;
|
|
|
|
|
OnPropertyChanged(nameof(AltoGuia));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 17:17:57 -03:00
|
|
|
|
public override string Nombre
|
|
|
|
|
{
|
|
|
|
|
get => _nombre;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_nombre != value)
|
|
|
|
|
{
|
|
|
|
|
_nombre = value;
|
|
|
|
|
OnPropertyChanged(nameof(Nombre));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 20:40:51 -03:00
|
|
|
|
private void ActualizarGeometrias()
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
if (_visualRepresentation is ucTransporteGuias uc)
|
2024-05-10 20:40:51 -03:00
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
UpdateRectangle(TransporteCentral, uc.Transporte, Alto, Ancho, Angulo);
|
|
|
|
|
UpdateOrCreateLine(Guia_Superior, uc.GuiaSuperior);
|
|
|
|
|
UpdateOrCreateLine(Guia_Inferior, uc.GuiaInferior) ;
|
2024-05-10 20:40:51 -03:00
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
TransporteCentral.Speed = VelocidadActual;
|
2024-05-10 20:40:51 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 17:17:57 -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; }
|
2024-05-14 03:15:54 -03:00
|
|
|
|
|
2024-05-10 17:17:57 -03:00
|
|
|
|
|
|
|
|
|
public osTransporteGuias()
|
|
|
|
|
{
|
|
|
|
|
Ancho = 1;
|
|
|
|
|
Alto = 0.10f;
|
2024-05-10 20:40:51 -03:00
|
|
|
|
AltoGuia = 0.03f;
|
|
|
|
|
Distance = 0.01f;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
public override void UpdateGeometryStart()
|
2024-05-10 20:40:51 -03:00
|
|
|
|
{
|
|
|
|
|
// Se llama antes de la simulacion
|
|
|
|
|
ActualizarGeometrias();
|
|
|
|
|
}
|
2024-05-14 03:15:54 -03:00
|
|
|
|
public override void UpdateGeometryStep()
|
|
|
|
|
{
|
|
|
|
|
}
|
2024-05-16 13:45:14 -03:00
|
|
|
|
public override void UpdateControl(int elapsedMilliseconds)
|
2024-05-10 17:17:57 -03:00
|
|
|
|
{
|
|
|
|
|
}
|
2024-05-15 06:20:09 -03:00
|
|
|
|
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
|
2024-05-14 12:10:32 -03:00
|
|
|
|
{
|
|
|
|
|
if (_osMotor != null)
|
|
|
|
|
{
|
|
|
|
|
if (_osMotor is osVMmotorSim motor)
|
|
|
|
|
VelocidadActual = motor.Velocidad;
|
|
|
|
|
}
|
2024-05-15 06:20:09 -03:00
|
|
|
|
else
|
|
|
|
|
_osMotor = ObtenerLink(_motor, typeof(osVMmotorSim));
|
2024-05-14 12:10:32 -03:00
|
|
|
|
}
|
2024-05-15 06:20:09 -03:00
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
public override void ucLoaded()
|
|
|
|
|
{
|
|
|
|
|
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
|
|
|
|
// crear el objeto de simulacion
|
2024-05-18 06:49:02 -03:00
|
|
|
|
ActualizarLeftTop();
|
|
|
|
|
|
2024-05-18 12:42:27 -03:00
|
|
|
|
//simulationManager.rectangles.Add(TransporteCentral);
|
|
|
|
|
//simulationManager.lines.Add(Guia_Superior);
|
|
|
|
|
//simulationManager.lines.Add(Guia_Inferior);
|
2024-05-14 03:15:54 -03:00
|
|
|
|
|
|
|
|
|
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
|
|
|
|
// crear el objeto de simulacion
|
|
|
|
|
if (_visualRepresentation is ucTransporteGuias uc)
|
|
|
|
|
{
|
|
|
|
|
TransporteCentral = AddRectangle(simulationManager, uc.Transporte, Alto, Ancho, Angulo);
|
|
|
|
|
Guia_Superior = AddLine(simulationManager, uc.GuiaSuperior);
|
|
|
|
|
Guia_Inferior = AddLine(simulationManager, uc.GuiaInferior);
|
|
|
|
|
}
|
2024-05-14 12:10:32 -03:00
|
|
|
|
Motor = Motor; // Forzar la busqueda
|
2024-05-14 03:15:54 -03:00
|
|
|
|
}
|
2024-05-18 09:58:41 -03:00
|
|
|
|
public override void ucUnLoaded()
|
|
|
|
|
{
|
|
|
|
|
// El UserControl se esta eliminando
|
|
|
|
|
// eliminar el objeto de simulacion
|
|
|
|
|
simulationManager.Remove(TransporteCentral);
|
|
|
|
|
simulationManager.Remove(Guia_Superior);
|
|
|
|
|
simulationManager.Remove(Guia_Inferior);
|
|
|
|
|
}
|
2024-05-10 17:17:57 -03:00
|
|
|
|
|
2024-05-10 20:40:51 -03:00
|
|
|
|
|
2024-05-10 17:17:57 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class ucTransporteGuias : UserControl, IDataContainer
|
|
|
|
|
{
|
|
|
|
|
public osBase? Datos { get; set; }
|
|
|
|
|
|
2024-05-08 08:41:26 -03:00
|
|
|
|
public ucTransporteGuias()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-05-14 03:15:54 -03:00
|
|
|
|
this.Loaded += OnLoaded;
|
2024-05-18 09:58:41 -03:00
|
|
|
|
this.Unloaded += OnUnloaded;
|
2024-05-14 03:15:54 -03:00
|
|
|
|
}
|
|
|
|
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Datos?.ucLoaded();
|
2024-05-08 08:41:26 -03:00
|
|
|
|
}
|
2024-05-18 09:58:41 -03:00
|
|
|
|
private void OnUnloaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Datos?.ucUnLoaded();
|
|
|
|
|
}
|
2024-05-10 17:17:57 -03:00
|
|
|
|
public void Resize(float width, float height)
|
|
|
|
|
{
|
|
|
|
|
if (Datos is osTransporteGuias datos)
|
|
|
|
|
datos.Ancho = PixelToMeter.Instance.calc.PixelsToMeters(width);
|
|
|
|
|
}
|
|
|
|
|
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 osTransporteGuias datos)
|
|
|
|
|
datos.Angulo = Angle;
|
|
|
|
|
}
|
|
|
|
|
public void Highlight(bool State) { }
|
|
|
|
|
public int ZIndex()
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-08 08:41:26 -03:00
|
|
|
|
}
|
|
|
|
|
}
|