2024-06-09 05:55:21 -03:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Windows;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
using System.Windows.Controls;
|
2024-06-04 12:33:00 -03:00
|
|
|
|
using System.Windows.Media;
|
2024-05-22 14:21:39 -03:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2024-06-28 14:47:08 -03:00
|
|
|
|
using LibS7Adv;
|
2024-05-14 03:15:54 -03:00
|
|
|
|
using CtrEditor.Simulacion;
|
2024-06-09 05:55:21 -03:00
|
|
|
|
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
|
2024-06-30 13:17:44 -03:00
|
|
|
|
using CtrEditor.FuncionesBase;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
|
|
|
|
|
namespace CtrEditor.ObjetosSim
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for ucTransporteGuias.xaml
|
|
|
|
|
/// </summary>
|
2024-05-22 14:21:39 -03:00
|
|
|
|
public partial class osTransporteGuias : osBase, IosBase
|
2024-05-08 08:41:26 -03:00
|
|
|
|
{
|
2024-06-09 05:55:21 -03:00
|
|
|
|
private osBase Motor = null;
|
2024-05-14 03:15:54 -03:00
|
|
|
|
|
2024-05-22 14:21:39 -03:00
|
|
|
|
private simTransporte? SimGeometria;
|
2024-05-18 09:58:41 -03:00
|
|
|
|
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-22 14:21:39 -03:00
|
|
|
|
private string nombre = NombreClase();
|
2024-06-09 05:55:21 -03:00
|
|
|
|
|
2024-05-22 14:21:39 -03:00
|
|
|
|
public override string Nombre
|
2024-05-10 17:17:57 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
get => nombre;
|
|
|
|
|
set => SetProperty(ref nombre, value);
|
2024-05-10 17:17:57 -03:00
|
|
|
|
}
|
2024-05-14 03:15:54 -03:00
|
|
|
|
|
2024-05-25 07:53:34 -03:00
|
|
|
|
[ObservableProperty]
|
2024-05-30 14:18:33 -03:00
|
|
|
|
public float velocidadActual;
|
2024-05-25 07:53:34 -03:00
|
|
|
|
|
|
|
|
|
partial void OnVelocidadActualChanged(float value)
|
2024-05-10 17:17:57 -03:00
|
|
|
|
{
|
2024-05-30 14:18:33 -03:00
|
|
|
|
SetSpeed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
bool invertirDireccion;
|
|
|
|
|
|
|
|
|
|
partial void OnInvertirDireccionChanged(bool value)
|
|
|
|
|
{
|
|
|
|
|
SetSpeed();
|
|
|
|
|
if (_visualRepresentation is ucTransporteGuias uc)
|
|
|
|
|
{
|
|
|
|
|
CrearAnimacionStoryBoardTrasnporte(uc.Transporte, InvertirDireccion);
|
|
|
|
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetSpeed()
|
|
|
|
|
{
|
|
|
|
|
if (InvertirDireccion)
|
|
|
|
|
SimGeometria?.SetSpeed(-VelocidadActual);
|
|
|
|
|
else
|
|
|
|
|
SimGeometria?.SetSpeed(VelocidadActual);
|
2024-05-25 07:53:34 -03:00
|
|
|
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
2024-05-10 20:40:51 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 14:18:33 -03:00
|
|
|
|
|
2024-06-04 12:33:00 -03:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
Color color = Colors.Blue;
|
|
|
|
|
|
2024-05-22 14:21:39 -03:00
|
|
|
|
[ObservableProperty]
|
2024-06-09 05:55:21 -03:00
|
|
|
|
[property: Description("Link to Motor")]
|
|
|
|
|
[property: Category("PLC link:")]
|
|
|
|
|
[property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))]
|
|
|
|
|
string id_Motor;
|
|
|
|
|
|
|
|
|
|
partial void OnId_MotorChanged(string value)
|
|
|
|
|
{
|
|
|
|
|
if (Motor != null)
|
|
|
|
|
Motor.PropertyChanged -= OnMotorPropertyChanged;
|
|
|
|
|
if (_mainViewModel != null && value != null && value.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
Motor = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osVMmotorSim && s.Nombre == value), null);
|
|
|
|
|
if (Motor != null)
|
|
|
|
|
Motor.PropertyChanged += OnMotorPropertyChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-23 14:56:14 -03:00
|
|
|
|
|
2024-06-09 05:55:21 -03:00
|
|
|
|
private void OnMotorPropertyChanged(object sender, PropertyChangedEventArgs e)
|
2024-05-23 14:56:14 -03:00
|
|
|
|
{
|
2024-06-09 05:55:21 -03:00
|
|
|
|
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
|
|
|
|
|
{
|
|
|
|
|
Id_Motor = ((osVMmotorSim)sender).Nombre;
|
|
|
|
|
}
|
2024-05-23 14:56:14 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-30 09:32:32 -03:00
|
|
|
|
public override void AltoChanged(float value)
|
2024-05-25 07:53:34 -03:00
|
|
|
|
{
|
|
|
|
|
ActualizarGeometrias();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-26 06:50:25 -03:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public bool esFreno;
|
|
|
|
|
|
|
|
|
|
partial void OnEsFrenoChanged(bool value)
|
|
|
|
|
{
|
|
|
|
|
if (SimGeometria != null)
|
|
|
|
|
SimGeometria.isBrake = value;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-22 14:21:39 -03:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public float frictionCoefficient;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public float velMax50hz;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public float tiempoRampa;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public bool esMarcha;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
private float distance;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
private float altoGuia;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
|
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-22 14:21:39 -03:00
|
|
|
|
UpdateRectangle(SimGeometria, uc.Transporte, Alto, Ancho, Angulo);
|
2024-05-14 03:15:54 -03:00
|
|
|
|
UpdateOrCreateLine(Guia_Superior, uc.GuiaSuperior);
|
2024-06-09 05:55:21 -03:00
|
|
|
|
UpdateOrCreateLine(Guia_Inferior, uc.GuiaInferior);
|
2024-05-10 20:40:51 -03:00
|
|
|
|
|
2024-06-09 05:55:21 -03:00
|
|
|
|
SimGeometria.DistanceGuide2Guide = Alto;
|
2024-05-26 06:50:25 -03:00
|
|
|
|
SimGeometria.isBrake = esFreno;
|
2024-06-04 12:33:00 -03:00
|
|
|
|
SetSpeed();
|
2024-05-10 20:40:51 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-04 06:34:19 -03:00
|
|
|
|
public override void OnMoveResizeRotate()
|
|
|
|
|
{
|
|
|
|
|
ActualizarGeometrias();
|
|
|
|
|
}
|
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;
|
2024-06-09 05:55:21 -03:00
|
|
|
|
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-22 14:21:39 -03:00
|
|
|
|
public override void SimulationStop()
|
2024-05-10 17:17:57 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
// Se llama al detener la simulacion
|
|
|
|
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
2024-05-10 17:17:57 -03:00
|
|
|
|
}
|
2024-06-28 14:47:08 -03:00
|
|
|
|
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
|
2024-05-14 12:10:32 -03:00
|
|
|
|
{
|
2024-06-09 05:55:21 -03:00
|
|
|
|
if (Motor != null)
|
|
|
|
|
if (Motor is osVMmotorSim id_motor)
|
|
|
|
|
VelocidadActual = id_motor.Velocidad;
|
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-06-09 12:33:09 -03:00
|
|
|
|
base.ucLoaded();
|
2024-05-18 06:49:02 -03:00
|
|
|
|
|
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)
|
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
SimGeometria = AddRectangle(simulationManager, uc.Transporte, Alto, Ancho, Angulo);
|
2024-05-25 07:53:34 -03:00
|
|
|
|
SimGeometria.TransportWithGuides = true;
|
|
|
|
|
SimGeometria.DistanceGuide2Guide = Alto;
|
2024-05-14 03:15:54 -03:00
|
|
|
|
Guia_Superior = AddLine(simulationManager, uc.GuiaSuperior);
|
|
|
|
|
Guia_Inferior = AddLine(simulationManager, uc.GuiaInferior);
|
2024-05-22 14:21:39 -03:00
|
|
|
|
|
2024-05-30 14:18:33 -03:00
|
|
|
|
CrearAnimacionStoryBoardTrasnporte(uc.Transporte, InvertirDireccion);
|
2024-05-14 03:15:54 -03:00
|
|
|
|
}
|
2024-06-09 05:55:21 -03:00
|
|
|
|
OnId_MotorChanged(Id_Motor); // Link Id_Motor = Motor
|
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
|
2024-05-22 14:21:39 -03:00
|
|
|
|
simulationManager.Remove(SimGeometria);
|
2024-05-18 09:58:41 -03:00
|
|
|
|
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 Highlight(bool State) { }
|
2024-06-30 13:17:44 -03:00
|
|
|
|
public ZIndexEnum ZIndex()
|
2024-05-10 17:17:57 -03:00
|
|
|
|
{
|
2024-06-30 13:17:44 -03:00
|
|
|
|
return ZIndexEnum.Estaticos;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-30 13:17:44 -03:00
|
|
|
|
|
2024-05-08 08:41:26 -03:00
|
|
|
|
}
|
|
|
|
|
}
|