Actualizado a CommunityToolkit.Mvvm.ComponentModel para todos los UserControl

This commit is contained in:
Miguel 2024-05-22 19:21:39 +02:00
parent 260362dc24
commit 0e174fc308
29 changed files with 629 additions and 1562 deletions

View File

@ -11,25 +11,6 @@ using System.Windows.Media;
namespace CtrEditor.Convertidores
{
public class SpeedAndWidthToDurationConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length == 2 && values[0] is double speed && values[1] is double width && speed > 0)
{
// Convert speed (meters per minute) to duration (seconds)
double durationInSeconds = (width * 60) / speed;
return new Duration(TimeSpan.FromSeconds(durationInSeconds));
}
return DependencyProperty.UnsetValue;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class HalfWidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

View File

@ -11,7 +11,6 @@
<ItemGroup>
<Compile Remove="ObjetosSim\ucBasicExample.xaml.cs" />
<Compile Remove="ObjetosSim\ucTransporteCurva.xaml.cs" />
<Compile Remove="ObjetosSim\UserControls\ucBasicExample.xaml.cs" />
<Compile Remove="Simulacion\GeometrySimulator.cs" />
</ItemGroup>
@ -44,12 +43,9 @@
<ItemGroup>
<Page Remove="ObjetosSim\ucBasicExample.xaml" />
<Page Remove="ObjetosSim\ucTransporteCurva.xaml" />
<Page Remove="ObjetosSim\UserControls\ucBasicExample.xaml" />
</ItemGroup>
<ItemGroup>
<None Include="ObjetosSim\UserControls\ucBasicExample.xaml" />
<None Include="ObjetosSim\UserControls\ucBasicExample.xaml.cs" />
<None Include="Simulacion\GeometrySimulator.cs" />
</ItemGroup>

View File

@ -389,6 +389,8 @@ namespace CtrEditor
private void StartSimulation()
{
IsSimulationRunning = true;
foreach (var objetoSimulable in ObjetosSimulables)
objetoSimulable.UpdateGeometryStart();
@ -399,11 +401,15 @@ namespace CtrEditor
_timerSimulacion.Start();
simulationManager.stopwatch.Start();
stopwatch_SimRefresh.Start();
IsSimulationRunning = true;
}
private void StopSimulation()
{
IsSimulationRunning = false;
foreach (var objetoSimulable in ObjetosSimulables)
objetoSimulable.SimulationStop();
if (Debug_SimulacionCreado)
{
simulationManager.Debug_ClearSimulationShapes();
@ -412,7 +418,6 @@ namespace CtrEditor
_timerSimulacion.Stop();
simulationManager.stopwatch.Stop();
stopwatch_SimRefresh.Stop();
IsSimulationRunning = false;
}
private void OnTickSimulacion(object sender, EventArgs e)

View File

@ -1,17 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
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;
namespace CtrEditor.ObjetosSim.UserControls
{

View File

@ -5,20 +5,33 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
mc:Ignorable="d"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osBasicExample />
</UserControl.DataContext>
<Grid>
<Image Source="/motor2.png"
Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}"
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"
Stretch="Uniform">
<Image.RenderTransform>
<RotateTransform Angle="{Binding Angulo}" />
</Image.RenderTransform>
</Image>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{Binding Nombre}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
Foreground="Black"/>
<Image Grid.Row="1" Source="{Binding ImageSource_oculta}"
Width="{Binding Tamano, Converter={StaticResource MeterToPixelConverter}}"
Height="{Binding Tamano, Converter={StaticResource MeterToPixelConverter}}"
Stretch="Uniform"/>
</Grid>
</UserControl>

View File

@ -1,134 +1,103 @@
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
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;
using Newtonsoft.Json;
using CommunityToolkit.Mvvm.ComponentModel;
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucBasicExample.xaml
/// </summary>
public class osBasicExample : osBase, IosBase
///
public partial class osBasicExample : osBase, IosBase
{
// Otros datos y métodos relevantes para la simulación
private string _nombre = "Ejemplo";
private float _ancho;
private float _alto;
private float _angulo;
private float _left;
private float _top;
public override float Left
public static string NombreClase()
{
get => _left;
set
{
_left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
return "Ejemplo";
}
public override float Top
{
get => _top;
set
{
_top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public float Ancho
{
get => _ancho;
set
{
_ancho = value;
OnPropertyChanged(nameof(Ancho));
}
}
public float Alto
{
get => _alto;
set
{
_alto = value;
OnPropertyChanged(nameof(Alto));
}
}
public float Angulo
{
get => _angulo;
set
{
_angulo = value;
OnPropertyChanged(nameof(Angulo));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
get => nombre;
set => SetProperty(ref nombre, value);
}
[JsonIgnore]
[ObservableProperty]
public ImageSource imageSource_oculta;
[ObservableProperty]
public float tamano;
[ObservableProperty]
public float maxRatedHz;
[ObservableProperty]
public float tiempoRampa;
partial void OnTiempoRampaChanged(float value)
{
if (value < 0.1f)
value = 0.1f;
tiempoRampa = value;
}
[ObservableProperty]
public bool encendido;
[ObservableProperty]
public int pLC_NumeroMotor;
[ObservableProperty]
public float ratio;
[ObservableProperty]
public float velocidad;
partial void OnVelocidadChanged(float value)
{
if (value > 0)
ImageSource_oculta = ImageFromPath("/imagenes/motorVerde.png");
else
ImageSource_oculta = ImageFromPath("/imagenes/motorNegro.png");
}
public osBasicExample()
{
Ancho = 0.30f;
Alto = 0.30f;
Tamano = 0.30f;
PLC_NumeroMotor = 31;
MaxRatedHz = 100;
TiempoRampa = 3;
ImageSource_oculta = ImageFromPath("/imagenes/motor2.png");
}
public override void UpdateGeometryStart()
{
// Se llama antes de la simulacion
}
public override void UpdateGeometryStep()
{
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
{
}
public override void UpdateControl(int elapsedMilliseconds)
{
// Calculamos la velocidad
}
public override void ucLoaded()
{
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
// crear el objeto de simulacion
ActualizarLeftTop();
}
public override void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
}
}
}
public partial class ucBasicExample : UserControl, IDataContainer
@ -149,13 +118,7 @@ namespace CtrEditor.ObjetosSim
{
Datos?.ucUnLoaded();
}
public void Resize(float width, float height) {
if (Datos is osBasicExample datos)
{
datos.Ancho = PixelToMeter.Instance.calc.PixelsToMeters(width);
datos.Alto = PixelToMeter.Instance.calc.PixelsToMeters(width);
}
}
public void Resize(float width, float height) { }
public void Move(float LeftPixels, float TopPixels)
{
if (Datos != null)
@ -164,12 +127,7 @@ namespace CtrEditor.ObjetosSim
Datos.Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
}
}
public void Rotate(float Angle)
{
if (Datos != null)
if (Datos is osBasicExample datos)
datos.Angulo = Angle;
}
public void Rotate(float Angle) { }
public void Highlight(bool State) { }
public int ZIndex()
{

View File

@ -1,22 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
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;
using Microsoft.Xna.Framework;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using CtrEditor.Simulacion;
using Newtonsoft.Json.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
namespace CtrEditor.ObjetosSim
{
@ -25,13 +13,9 @@ namespace CtrEditor.ObjetosSim
/// </summary>
///
public class osBotella : osBase, IosBase
public partial class osBotella : osBase, IosBase
{
private float _diametro;
private float _mass;
private Vector2 _centro = new Vector2(); // Centro
private string _nombre = NombreClase();
private simBotella Simulacion_Botella;
private simBotella SimGeometria;
// Otros datos y métodos relevantes para la simulación
@ -39,92 +23,48 @@ namespace CtrEditor.ObjetosSim
{
return "Botella";
}
public float Diametro {
get => _diametro;
set
{
_diametro = value;
Simulacion_Botella?.SetDiameter(Diametro);
OnPropertyChanged(nameof(Diametro));
}
private string nombre = NombreClase();
public override string Nombre
{
get => nombre;
set => SetProperty(ref nombre, value);
}
public float Mass {
get => _mass;
set
{
_mass = value;
Simulacion_Botella?.SetMass(value);
OnPropertyChanged(nameof(Mass));
}
[ObservableProperty]
private float diametro;
partial void OnDiametroChanged(float value)
{
SimGeometria?.SetDiameter(Diametro);
}
public override float Left
[ObservableProperty]
private float mass;
partial void OnMassChanged(float value)
{
get => _centro.X-Diametro/2;
set
{
_centro.X = value+Diametro/2;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(CenterX));
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _centro.Y - Diametro / 2;
set
{
_centro.Y = value + Diametro / 2;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(Top));
}
SimGeometria?.SetMass(value);
}
public float CenterX
public Vector2 GetCentro()
{
get => _centro.X;
set
{
_centro.X = value;
CanvasSetLeftinMeter(Left);
OnPropertyChanged(nameof(CenterX));
OnPropertyChanged(nameof(Left));
}
return new Vector2 (Left+Diametro/2,Top+Diametro/2);
}
public float CenterY
{
get => _centro.Y;
set
{
_centro.Y = value;
CanvasSetTopinMeter(Top);
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(Top));
}
public void SetCentro(float x, float y)
{ Left = x; Top = y; }
public void SetCentro(Vector2 centro)
{
Left = centro.X - Diametro / 2;
Top = centro.Y - Diametro / 2;
}
private void ActualizarGeometrias()
{
if (Simulacion_Botella != null)
if (SimGeometria != null)
{
Simulacion_Botella.SetDiameter(Diametro);
Simulacion_Botella.SetPosition(CenterX, CenterY);
}
}
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
SimGeometria.SetDiameter(Diametro);
SimGeometria.SetPosition(GetCentro());
}
}
@ -139,6 +79,11 @@ namespace CtrEditor.ObjetosSim
// Se llama antes de la simulacion
ActualizarGeometrias();
}
public override void SimulationStop()
{
// Se llama al detener la simulacion. Util para detener Storyboards
}
public override void UpdateGeometryStep()
{
// Se llama antes de la simulacion
@ -149,10 +94,9 @@ namespace CtrEditor.ObjetosSim
public override void UpdateControl(int elapsedMilliseconds)
{
CenterX = Simulacion_Botella.CenterX;
CenterY = Simulacion_Botella.CenterY;
SetCentro(SimGeometria.Center);
if (Simulacion_Botella.Descartar) // Ha sido marcada para remover
if (SimGeometria.Descartar) // Ha sido marcada para remover
RemoverDesdeSimulacion = true;
}
@ -161,13 +105,13 @@ namespace CtrEditor.ObjetosSim
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
// crear el objeto de simulacion
ActualizarLeftTop();
Simulacion_Botella = simulationManager.AddCircle(Diametro, _centro, Mass);
SimGeometria = simulationManager.AddCircle(Diametro, GetCentro(), Mass);
}
public override void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
simulationManager.Remove(Simulacion_Botella);
simulationManager.Remove(SimGeometria);
}
}

View File

@ -6,12 +6,17 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
mc:Ignorable="d">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osBoton Color="#FFADE6C0" ColorButton_oculto="#FFC72323"/>
</UserControl.DataContext>
<Grid>
<Border x:Name="BackgroundRectangle"
BorderBrush="Black"
@ -22,7 +27,7 @@
VerticalAlignment="Top"
HorizontalAlignment="Left"
Background="Gray"/>
<Ellipse Fill="{Binding ColorButton}"
<Ellipse Fill="{Binding ColorButton_oculto}"
Stroke="Black"
StrokeThickness="2"
Width="{Binding Tamano, Converter={StaticResource MeterToPixelConverter}}"

View File

@ -1,4 +1,5 @@
using CtrEditor.Convertidores;
using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using System.Windows;
using System.Windows.Controls;
@ -10,114 +11,41 @@ namespace CtrEditor.ObjetosSim
/// <summary>
/// Interaction logic for ucBoton.xaml
/// </summary>
public class osBoton : osBase, IosBase
public partial class osBoton : osBase, IosBase
{
// Otros datos y métodos relevantes para la simulación
private string _nombre = "Boton";
private float _tamano;
private float _left;
private float _top;
private bool _estado;
private string _tag;
private Brush _color;
private Brush _colorButton;
public static string NombreClase()
{
return "Boton";
}
public Brush Color
{
get => _color;
set
{
_color = value;
OnPropertyChanged(nameof(Color));
}
}
[Hidden]
public Brush ColorButton
{
get => _colorButton;
set
{
_colorButton = value;
OnPropertyChanged(nameof(ColorButton));
}
}
public override float Left
{
get => _left;
set
{
_left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _top;
set
{
_top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public float Tamano
{
get => _tamano;
set
{
_tamano = value;
OnPropertyChanged(nameof(Tamano));
}
}
public bool Estado
{
get => _estado;
set
{
_estado = value;
if (value)
ColorButton = Brushes.LightGreen;
else
ColorButton = Color;
OnPropertyChanged(nameof(Estado));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
get => nombre;
set => SetProperty(ref nombre, value);
}
public string Tag
[ObservableProperty]
private Brush color;
[ObservableProperty]
private Brush colorButton_oculto;
[ObservableProperty]
public float tamano;
[ObservableProperty]
public bool estado;
partial void OnEstadoChanged(bool value)
{
get => _tag;
set
{
if (_tag != value)
{
_tag = value;
OnPropertyChanged(nameof(Tag));
}
}
if (value)
ColorButton_oculto = Brushes.LightGreen;
else
ColorButton_oculto = Color;
}
[ObservableProperty]
public string tag;
public void ButtonDownCommand()
{
Estado = true;
@ -140,13 +68,10 @@ namespace CtrEditor.ObjetosSim
{
// Se llama antes de la simulacion
}
public override void UpdateGeometryStep()
{
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
{
plc.EscribirTagBool(_tag, Estado);
plc.EscribirTagBool(Tag, Estado);
}
public override void UpdateControl(int elapsedMilliseconds)

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
mc:Ignorable="d"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
@ -20,6 +21,10 @@
</Storyboard>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osDescarte/>
</UserControl.DataContext>
<Grid>
<Ellipse
Height="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"

View File

@ -5,101 +5,67 @@ using System.Windows;
using System.Windows.Controls;
using Microsoft.Xna.Framework;
using System.Windows.Media.Animation;
using CommunityToolkit.Mvvm.ComponentModel;
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucDescarte.xaml
/// </summary>
public class osDescarte : osBase, IosBase
public partial class osDescarte : osBase, IosBase
{
// Otros datos y métodos relevantes para la simulación
private simDescarte SimGeometria;
private string _nombre = "Descarte";
private float _diametro;
private Vector2 _centro = new Vector2(); // Centro
private simDescarte AreaDeDescarte;
public static string NombreClase()
{
return "Descarte";
}
public override float Left
{
get => _centro.X - Diametro / 2;
set
{
_centro.X = value + Diametro / 2;
ActualizarGeometrias();
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(CenterX));
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _centro.Y - Diametro / 2;
set
{
_centro.Y = value + Diametro / 2;
ActualizarGeometrias();
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(Top));
}
}
public float CenterX
{
get => _centro.X;
set
{
_centro.X = value;
CanvasSetLeftinMeter(Left);
OnPropertyChanged(nameof(CenterX));
OnPropertyChanged(nameof(Left));
}
}
public float CenterY
{
get => _centro.Y;
set
{
_centro.Y = value;
CanvasSetTopinMeter(Top);
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(Top));
}
}
public float Diametro
{
get => _diametro;
set
{
_diametro = value;
AreaDeDescarte?.SetDiameter(Diametro);
OnPropertyChanged(nameof(Diametro));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
get => nombre;
set => SetProperty(ref nombre, value);
}
[ObservableProperty]
private float diametro;
partial void OnDiametroChanged(float value)
{
SimGeometria?.SetDiameter(Diametro);
}
public Vector2 GetCentro()
{
return new Vector2(Left + Diametro / 2, Top + Diametro / 2);
}
public void SetCentro(float x, float y)
{ Left = x; Top = y; }
public void SetCentro(Vector2 centro)
{
Left = centro.X - Diametro / 2;
Top = centro.Y - Diametro / 2;
}
public override void LeftChanged(float value)
{
ActualizarGeometrias();
}
public override void TopChanged(float value)
{
ActualizarGeometrias();
}
private void ActualizarGeometrias()
{
if (AreaDeDescarte != null)
if (SimGeometria != null)
{
AreaDeDescarte.SetDiameter(Diametro);
AreaDeDescarte.SetPosition(CenterX, CenterY);
SimGeometria.SetDiameter(Diametro);
SimGeometria.SetPosition(GetCentro());
}
}
@ -129,13 +95,13 @@ namespace CtrEditor.ObjetosSim
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
// crear el objeto de simulacion
ActualizarLeftTop();
AreaDeDescarte = simulationManager.AddDescarte(Diametro, _centro);
SimGeometria = simulationManager.AddDescarte(Diametro, GetCentro());
}
public override void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
simulationManager.Remove(AreaDeDescarte);
simulationManager.Remove(SimGeometria);
}
}

View File

@ -5,12 +5,17 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
mc:Ignorable="d"
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osFiller/>
</UserControl.DataContext>
<Grid>
<Image Source="/imagenes/filler.png"
Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}"

View File

@ -1,180 +1,53 @@
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using CtrEditor.Simulacion;
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;
using Microsoft.Xna.Framework;
using CommunityToolkit.Mvvm.ComponentModel;
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucFiller.xaml
/// </summary>
public class osFiller : osBase, IosBase
public partial class osFiller : osBase, IosBase
{
// Otros datos y métodos relevantes para la simulación
private string _nombre = "Filler";
private float _ancho;
private float _alto;
private float _left;
private float _top;
private float _angulo;
private float _botellas_hora;
private float _velocidad_actual;
private float _diametro_botella;
private string _tag_consenso;
private bool _consenso;
private float TiempoRestante;
private float _leftSalida;
private float _topSalida;
private osBotella UltimaBotella;
public static string NombreClase()
{
return "Filler";
}
public float OffsetLeftSalida
{
get => _leftSalida;
set
{
_leftSalida = value;
OnPropertyChanged(nameof(OffsetLeftSalida));
}
}
public float OffsetTopSalida
{
get => _topSalida;
set
{
_topSalida = value;
OnPropertyChanged(nameof(OffsetTopSalida));
}
}
public bool Consenso
{
get => _consenso;
set
{
_consenso = value;
OnPropertyChanged(nameof(Consenso));
}
}
public float Botellas_hora
{
get => _botellas_hora;
set
{
_botellas_hora = value;
OnPropertyChanged(nameof(Botellas_hora));
}
}
public float Velocidad_actual_percentual
{
get => _velocidad_actual;
set
{
_velocidad_actual = value;
OnPropertyChanged(nameof(Velocidad_actual_percentual));
}
}
public float Diametro_botella
{
get => _diametro_botella;
set
{
_diametro_botella = value;
OnPropertyChanged(nameof(Diametro_botella));
}
}
public string Tag_consenso
{
get => _tag_consenso;
set
{
_tag_consenso = value;
OnPropertyChanged(nameof(Tag_consenso));
}
}
public override float Left
{
get => _left;
set
{
_left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _top;
set
{
_top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public float Ancho
{
get => _ancho;
set
{
_ancho = value;
OnPropertyChanged(nameof(Ancho));
}
}
public float Alto
{
get => _alto;
set
{
_alto = value;
OnPropertyChanged(nameof(Alto));
}
}
public float Angulo
{
get => _angulo;
set
{
_angulo = value;
OnPropertyChanged(nameof(Angulo));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
get => nombre;
set => SetProperty(ref nombre, value);
}
[ObservableProperty]
public float offsetLeftSalida;
[ObservableProperty]
public float offsetTopSalida;
[ObservableProperty]
public bool consenso;
[ObservableProperty]
public float botellas_hora;
[ObservableProperty]
public float velocidad_actual_percentual;
[ObservableProperty]
public float diametro_botella;
[ObservableProperty]
public string tag_consenso;
[ObservableProperty]
public float ancho;
[ObservableProperty]
public float alto;
[ObservableProperty]
public float angulo;
public osFiller()
{
Ancho = 0.30f;
@ -185,14 +58,6 @@ namespace CtrEditor.ObjetosSim
Botellas_hora = 10000;
}
public override void UpdateGeometryStart()
{
// Se llama antes de la simulacion
}
public override void UpdateGeometryStep()
{
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
{
Consenso = LeerBitTag(plc, Tag_consenso);
@ -249,11 +114,6 @@ namespace CtrEditor.ObjetosSim
// crear el objeto de simulacion
ActualizarLeftTop();
}
public override void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
}
}

View File

@ -1,24 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
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;
using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using CtrEditor.Simulacion;
using FarseerPhysics.Dynamics;
using Microsoft.Xna.Framework;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace CtrEditor.ObjetosSim
{
@ -39,26 +24,6 @@ namespace CtrEditor.ObjetosSim
get => nombre;
set => SetProperty(ref nombre, value);
}
private float left;
public override float Left
{
get => left;
set
{
CanvasSetLeftinMeter(value);
SetProperty(ref left, value);
}
}
private float top;
public override float Top
{
get => top;
set
{
CanvasSetTopinMeter(value);
SetProperty(ref top, value);
}
}
[ObservableProperty]
public float ancho;

View File

@ -5,12 +5,17 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
mc:Ignorable="d"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim.UserControls"
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osPhotocell Color="#FFCA1C1C"/>
</UserControl.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
@ -26,8 +31,10 @@
</Grid.RenderTransform>
<!-- Label en la primera columna -->
<Label Content="{Binding Nombre}" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="0"/>
<Label Content="{Binding Nombre}" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="0" Foreground="{Binding Color}" >
</Label>
<Image Source="/Icons/fotocelula.png"
Width="{Binding Alto, Converter={StaticResource MeterToPixelConverter}, ConverterParameter=3}"
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}, ConverterParameter=3}"

View File

@ -4,6 +4,7 @@ using CtrEditor.Siemens;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using CommunityToolkit.Mvvm.ComponentModel;
namespace CtrEditor.ObjetosSim.UserControls
@ -11,145 +12,73 @@ namespace CtrEditor.ObjetosSim.UserControls
/// <summary>
/// Interaction logic for ucPhotocell.xaml
/// </summary>
public class osPhotocell : osBase, IosBase
public partial class osPhotocell : osBase, IosBase
{
private float _ancho;
private float _altoPhotocell;
private float _left;
private float _top;
private float _angulo;
private string _nombre = NombreClase();
private bool _luzCortada;
private string _tagPhotocellOUT;
private bool _tipoNC;
private Brush _color;
private simBarrera Simulation_Photocell;
public static string NombreClase()
{
return "Photocell";
}
public Brush Color
{
get => _color;
set
{
_color = value;
OnPropertyChanged(nameof(Color));
}
}
public bool LuzCortada
{
get => _luzCortada;
set
{
if (_luzCortada != value)
{
_luzCortada = value;
if (_luzCortada)
Color = Brushes.Blue;
else
Color = Brushes.Green;
OnPropertyChanged(nameof(LuzCortada));
}
}
}
public bool Tipo_NC
{
get => _tipoNC;
set
{
if (_tipoNC != value)
{
_tipoNC = value;
OnPropertyChanged(nameof(Tipo_NC));
}
}
}
public string TagPhotocell_OUT
{
get => _tagPhotocellOUT;
set
{
if (_tagPhotocellOUT != value)
{
_tagPhotocellOUT = value;
OnPropertyChanged(nameof(TagPhotocell_OUT));
}
}
}
public override float Left
{
get => _left;
set
{
_left = value;
ActualizarGeometrias();
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _top;
set
{
_top = value;
ActualizarGeometrias();
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public float Ancho
{
get => _ancho;
set
{
_ancho = value;
ActualizarGeometrias();
OnPropertyChanged(nameof(Ancho));
}
}
public float Alto
{
get => _altoPhotocell;
set
{
_altoPhotocell = value;
ActualizarGeometrias();
OnPropertyChanged(nameof(Alto));
}
}
public float Angulo
{
get => _angulo;
set
{
_angulo = value;
ActualizarGeometrias();
OnPropertyChanged(nameof(Angulo));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
get => nombre;
set => SetProperty(ref nombre, value);
}
[ObservableProperty]
public Brush color;
[ObservableProperty]
public bool luzCortada;
partial void OnLuzCortadaChanged(bool value)
{
if (LuzCortada)
Color = Brushes.Blue;
else
Color = Brushes.Green;
}
[ObservableProperty]
public bool tipo_NC;
[ObservableProperty]
public string tagPhotocell_OUT;
public override void LeftChanged(float value)
{
ActualizarGeometrias();
}
public override void TopChanged(float value)
{
ActualizarGeometrias();
}
[ObservableProperty]
public float ancho;
partial void OnAnchoChanged(float value)
{
ActualizarGeometrias();
}
[ObservableProperty]
public float alto;
partial void OnAltoChanged(float value)
{
ActualizarGeometrias();
}
[ObservableProperty]
public float angulo;
partial void OnAnguloChanged(float value)
{
ActualizarGeometrias();
}
private void ActualizarGeometrias()

View File

@ -5,11 +5,17 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
mc:Ignorable="d"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osSensTemperatura />
</UserControl.DataContext>
<Grid>
<Border x:Name="BackgroundRectangle"
BorderBrush="Black"

View File

@ -1,149 +1,44 @@
using CtrEditor.Convertidores;
using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using Siemens.Simatic.Simulation.Runtime;
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;
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucSensTemperatura.xaml
/// </summary>
public class osSensTemperatura : osBase, IosBase
public partial class osSensTemperatura : osBase, IosBase
{
// Otros datos y métodos relevantes para la simulación
private string _nombre = "Temperatura";
private float _ancho;
private float _alto;
private float _left;
private float _top;
private float _angulo;
private string _tag;
private float _value;
private float _max_OUT_Scaled;
private float _min_OUT_Scaled;
public static string NombreClase()
{
return "Temperatura";
}
public string Tag
{
get => _tag;
set
{
if (_tag != value)
{
_tag = value;
OnPropertyChanged(nameof(Tag));
}
}
}
public float Min_OUT_Scaled
{
get => _min_OUT_Scaled;
set
{
_min_OUT_Scaled = value;
OnPropertyChanged(nameof(Min_OUT_Scaled));
}
}
public float Max_OUT_Scaled
{
get => _max_OUT_Scaled;
set
{
_max_OUT_Scaled = value;
OnPropertyChanged(nameof(Max_OUT_Scaled));
}
}
public float Value
{
get => _value;
set
{
_value = value;
OnPropertyChanged(nameof(Value));
}
}
public override float Left
{
get => _left;
set
{
_left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _top;
set
{
_top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public float Ancho
{
get => _ancho;
set
{
_ancho = value;
OnPropertyChanged(nameof(Ancho));
}
}
public float Alto
{
get => _alto;
set
{
_alto = value;
OnPropertyChanged(nameof(Alto));
}
}
public float Angulo
{
get => _angulo;
set
{
_angulo = value;
OnPropertyChanged(nameof(Angulo));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
get => nombre;
set => SetProperty(ref nombre, value);
}
[ObservableProperty]
public string tag;
[ObservableProperty]
public float min_OUT_Scaled;
[ObservableProperty]
public float max_OUT_Scaled;
[ObservableProperty]
public float value;
[ObservableProperty]
public float ancho;
[ObservableProperty]
public float alto;
[ObservableProperty]
public float angulo;
public osSensTemperatura()
{
Ancho = 0.4f;
@ -152,23 +47,11 @@ namespace CtrEditor.ObjetosSim
Min_OUT_Scaled = 0;
}
public override void UpdateGeometryStart()
{
// Se llama antes de la simulacion
}
public override void UpdateGeometryStep()
{
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
{
EscribirWordTagScaled(plc, Tag, Value, 0, 100, Min_OUT_Scaled, Max_OUT_Scaled);
}
public override void UpdateControl(int elapsedMilliseconds)
{
}
public override void ucLoaded()
{
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
@ -176,11 +59,6 @@ namespace CtrEditor.ObjetosSim
ActualizarLeftTop();
}
public override void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
}
}

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
mc:Ignorable="d"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
<UserControl.Resources>
@ -13,6 +14,10 @@
<convert:WidthPercentageConverter x:Key="WidthPercentageConverter"/>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osTanque Alto="1" Ancho="1" Angulo="-4" />
</UserControl.DataContext>
<Grid>
<Image x:Name="TankImage"
Source="/imagenes/tank.png"

View File

@ -1,253 +1,58 @@
using CtrEditor.Convertidores;
using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using Newtonsoft.Json.Linq;
using Siemens.Simatic.Simulation.Runtime;
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;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucTanque.xaml
/// </summary>
public class osTanque : osBase, IosBase
public partial class osTanque : osBase, IosBase
{
// Otros datos y métodos relevantes para la simulación
private string _nombre = "Tanque";
private float _ancho;
private float _alto;
private float _left;
private float _top;
private float _angulo;
private float _level;
private string _tagNivel_Word;
private float _max_OUT_Scaled;
private float _min_OUT_Scaled;
private float _velocidadIngreso;
private float _velocidadSalida;
private string _tagIngresoAbierto_Bool;
private string _tagSalidaAbierta_Bool;
private bool _IngresoAbierto_Bool;
private bool _SalidaAbierta_Bool;
private float _capacidadLitros;
public static string NombreClase()
{
return "Tanque";
}
public float Capacidad_Litros
{
get => _capacidadLitros;
set
{
if (_capacidadLitros != value)
{
_capacidadLitros = value;
OnPropertyChanged(nameof(Capacidad_Litros));
}
}
}
public bool Ingreso_Abierto
{
get => _IngresoAbierto_Bool;
set
{
if (_IngresoAbierto_Bool != value)
{
_IngresoAbierto_Bool = value;
OnPropertyChanged(nameof(Ingreso_Abierto));
}
}
}
public bool Salida_Abierta
{
get => _SalidaAbierta_Bool;
set
{
if (_SalidaAbierta_Bool != value)
{
_SalidaAbierta_Bool = value;
OnPropertyChanged(nameof(Salida_Abierta));
}
}
}
public string TagNivel_Word
{
get => _tagNivel_Word;
set
{
if (_tagNivel_Word != value)
{
_tagNivel_Word = value;
OnPropertyChanged(nameof(TagNivel_Word));
}
}
}
public string TagIngresoAbierto_Bool
{
get => _tagIngresoAbierto_Bool;
set
{
if (_tagIngresoAbierto_Bool != value)
{
_tagIngresoAbierto_Bool = value;
OnPropertyChanged(nameof(TagIngresoAbierto_Bool));
}
}
}
public string TagSalidaAbierta_Bool
{
get => _tagSalidaAbierta_Bool;
set
{
if (_tagSalidaAbierta_Bool != value)
{
_tagSalidaAbierta_Bool = value;
OnPropertyChanged(nameof(TagSalidaAbierta_Bool));
}
}
}
public float Velocidad_Ingreso
{
get => _velocidadIngreso;
set
{
if (_velocidadIngreso != value)
{
_velocidadIngreso = value;
OnPropertyChanged(nameof(Velocidad_Ingreso));
}
}
}
public float Velocidad_Salida
{
get => _velocidadSalida;
set
{
if (_velocidadSalida != value)
{
_velocidadSalida = value;
OnPropertyChanged(nameof(Velocidad_Salida));
}
}
}
public float Min_OUT_Scaled
{
get => _min_OUT_Scaled;
set
{
_min_OUT_Scaled = value;
OnPropertyChanged(nameof(Min_OUT_Scaled));
}
}
public float Max_OUT_Scaled
{
get => _max_OUT_Scaled;
set
{
_max_OUT_Scaled = value;
OnPropertyChanged(nameof(Max_OUT_Scaled));
}
}
public float Level
{
get => _level;
set
{
_level = value;
OnPropertyChanged(nameof(Level));
}
}
public override float Left
{
get => _left;
set
{
_left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _top;
set
{
_top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public float Ancho
{
get => _ancho;
set
{
_ancho = value;
OnPropertyChanged(nameof(Ancho));
}
}
public float Alto
{
get => _alto;
set
{
_alto = value;
OnPropertyChanged(nameof(Alto));
}
}
public float Angulo
{
get => _angulo;
set
{
_angulo = value;
OnPropertyChanged(nameof(Angulo));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
get => nombre;
set => SetProperty(ref nombre, value);
}
[ObservableProperty]
public float capacidad_Litros;
[ObservableProperty]
public bool ingreso_Abierto;
[ObservableProperty]
public bool salida_Abierta;
[ObservableProperty]
public string tagNivel_Word;
[ObservableProperty]
public string tagIngresoAbierto_Bool;
[ObservableProperty]
public string tagSalidaAbierta_Bool;
[ObservableProperty]
public float velocidad_Ingreso;
[ObservableProperty]
public float velocidad_Salida;
[ObservableProperty]
public float min_OUT_Scaled;
[ObservableProperty]
public float max_OUT_Scaled;
[ObservableProperty]
public float level;
[ObservableProperty]
public float ancho;
[ObservableProperty]
public float alto;
[ObservableProperty]
public float angulo;
public osTanque()
{
Ancho = 0.30f;
@ -256,20 +61,11 @@ namespace CtrEditor.ObjetosSim
Min_OUT_Scaled = 0;
}
public override void UpdateGeometryStart()
{
// Se llama antes de la simulacion
}
public override void UpdateGeometryStep()
{
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
{
EscribirWordTagScaled(plc, TagNivel_Word, Level, 0, 100, Min_OUT_Scaled, Max_OUT_Scaled);
Ingreso_Abierto = LeerBitTag(plc, _tagIngresoAbierto_Bool);
Salida_Abierta = LeerBitTag(plc, _tagSalidaAbierta_Bool);
Ingreso_Abierto = LeerBitTag(plc, TagIngresoAbierto_Bool);
Salida_Abierta = LeerBitTag(plc, TagSalidaAbierta_Bool);
}
public override void UpdateControl(int elapsedMilliseconds)
@ -294,12 +90,6 @@ namespace CtrEditor.ObjetosSim
ActualizarLeftTop();
}
public override void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
}
}
public partial class ucTanque : UserControl, IDataContainer

View File

@ -1,5 +1,4 @@
using System.Configuration;
using System.Windows;
using System.Windows;
using System.Windows.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Convertidores;
@ -36,27 +35,6 @@ namespace CtrEditor.ObjetosSim
set => SetProperty(ref nombre, value);
}
private float left;
public override float Left
{
get => left;
set
{
CanvasSetLeftinMeter(value);
SetProperty(ref left, value);
}
}
private float top;
public override float Top
{
get => top;
set
{
CanvasSetTopinMeter(value);
SetProperty(ref top, value);
}
}
[ObservableProperty]
private float radioExterno;
[ObservableProperty]
@ -115,9 +93,6 @@ namespace CtrEditor.ObjetosSim
// Se llama antes de la simulacion
ActualizarGeometrias();
}
public override void UpdateGeometryStep()
{
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
{
if (_osMotor != null)
@ -129,9 +104,6 @@ namespace CtrEditor.ObjetosSim
_osMotor = ObtenerLink(_motor, typeof(osVMmotorSim));
}
public override void UpdateControl(int elapsedMilliseconds)
{
}
public override void ucLoaded()
{
// El UserControl ya se ha cargado y podemos obtener las coordenadas para

View File

@ -3,14 +3,34 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
mc:Ignorable="d">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
<convert:DistanceToMarginConverter x:Key="DistanceToMarginConverter"/>
<!-- Define the VisualBrush for the conveyor belt pattern -->
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
<VisualBrush.Transform>
<TransformGroup>
<TranslateTransform/>
</TransformGroup>
</VisualBrush.Transform>
<VisualBrush.Visual>
<Canvas>
<Rectangle Fill="Gray" Width="10" Height="10"/>
<Rectangle Fill="DarkGray" Width="10" Height="10" Canvas.Left="10"/>
</Canvas>
</VisualBrush.Visual>
</VisualBrush>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osTransporteGuias/>
</UserControl.DataContext>
<Grid>
<Canvas>
<StackPanel x:Name="RectanglesContainer">
@ -19,8 +39,9 @@
</StackPanel.RenderTransform>
<Rectangle x:Name="GuiaSuperior" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}" Height="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}" Fill="Blue"
Margin="{Binding Distance, Converter={StaticResource DistanceToMarginConverter}}"/>
<Rectangle x:Name="Transporte" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}" Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}" Fill="Gray"
Margin="{Binding Distance, Converter={StaticResource DistanceToMarginConverter}}"/>
<Rectangle x:Name="Transporte" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}" Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"
Margin="{Binding Distance, Converter={StaticResource DistanceToMarginConverter}}"
Fill="{StaticResource BeltBrush}"/>
<Rectangle x:Name="GuiaInferior" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}" Height="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}" Fill="Blue"/>
</StackPanel>
</Canvas>

View File

@ -1,49 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
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;
using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using CtrEditor.Simulacion;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucTransporteGuias.xaml
/// </summary>
public class osTransporteGuias : osBase, IosBase
public partial class osTransporteGuias : osBase, IosBase
{
private string _nombre = "Transporte Guias";
private float _distance;
private float _altoGuia;
private float frictionCoefficient;
private float velMax50hz; // en metros por minuto
private float tiempoRampa;
private bool esMarcha;
private float _ancho;
private float _alto;
private float _left;
private float _top;
private float _angulo;
private float _velocidadActual;
private osBase _osMotor = null;
private string _motor;
private simTransporte? TransporteCentral;
private simTransporte? SimGeometria;
private simGuia? Guia_Superior;
private simGuia? Guia_Inferior;
@ -52,133 +23,63 @@ namespace CtrEditor.ObjetosSim
{
return "Transporte Guias";
}
public string Motor
{
get => _motor;
set
{
if (_motor != value)
{
_motor = value;
OnPropertyChanged(nameof(Motor));
}
}
}
public override float Left
{
get => _left;
set
{
_left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _top;
set
{
_top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public float Ancho
{
get => _ancho;
set
{
_ancho = value;
OnPropertyChanged(nameof(Ancho));
}
}
public float Alto
{
get => _alto;
set
{
_alto = value;
OnPropertyChanged(nameof(Alto));
}
}
public float Angulo
{
get => _angulo;
set
{
_angulo = value;
OnPropertyChanged(nameof(Angulo));
}
}
public float VelocidadActual
{
get => _velocidadActual;
set
{
_velocidadActual = value;
TransporteCentral?.SetSpeed(value);
OnPropertyChanged(nameof(VelocidadActual));
}
}
public float Distance
{
get { return _distance; }
set
{
if (_distance != value)
{
_distance = value;
OnPropertyChanged(nameof(Distance));
}
}
}
public float AltoGuia
{
get => _altoGuia;
set
{
_altoGuia = value;
OnPropertyChanged(nameof(AltoGuia));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
get => nombre;
set => SetProperty(ref nombre, value);
}
private float velocidadActual;
public float VelocidadActual
{
get => velocidadActual;
set
{
if (_nombre != value)
if (value != velocidadActual)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
velocidadActual = value;
SimGeometria?.SetSpeed(value);
SetProperty(ref velocidadActual, value);
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
}
}
}
[ObservableProperty]
public string motor;
[ObservableProperty]
public float ancho;
[ObservableProperty]
public float alto;
[ObservableProperty]
public float angulo;
[ObservableProperty]
public float frictionCoefficient;
[ObservableProperty]
public float velMax50hz;
[ObservableProperty]
public float tiempoRampa;
[ObservableProperty]
public bool esMarcha;
[ObservableProperty]
private float distance;
[ObservableProperty]
private float altoGuia;
private void ActualizarGeometrias()
{
if (_visualRepresentation is ucTransporteGuias uc)
{
UpdateRectangle(TransporteCentral, uc.Transporte, Alto, Ancho, Angulo);
UpdateRectangle(SimGeometria, uc.Transporte, Alto, Ancho, Angulo);
UpdateOrCreateLine(Guia_Superior, uc.GuiaSuperior);
UpdateOrCreateLine(Guia_Inferior, uc.GuiaInferior) ;
TransporteCentral.Speed = VelocidadActual;
SimGeometria.Speed = VelocidadActual;
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
}
}
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 osTransporteGuias()
{
@ -193,11 +94,10 @@ namespace CtrEditor.ObjetosSim
// Se llama antes de la simulacion
ActualizarGeometrias();
}
public override void UpdateGeometryStep()
{
}
public override void UpdateControl(int elapsedMilliseconds)
public override void SimulationStop()
{
// Se llama al detener la simulacion
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
{
@ -207,7 +107,7 @@ namespace CtrEditor.ObjetosSim
VelocidadActual = motor.Velocidad;
}
else
_osMotor = ObtenerLink(_motor, typeof(osVMmotorSim));
_osMotor = ObtenerLink(Motor, typeof(osVMmotorSim));
}
public override void ucLoaded()
@ -216,17 +116,15 @@ namespace CtrEditor.ObjetosSim
// crear el objeto de simulacion
ActualizarLeftTop();
//simulationManager.rectangles.Add(TransporteCentral);
//simulationManager.lines.Add(Guia_Superior);
//simulationManager.lines.Add(Guia_Inferior);
// 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);
SimGeometria = AddRectangle(simulationManager, uc.Transporte, Alto, Ancho, Angulo);
Guia_Superior = AddLine(simulationManager, uc.GuiaSuperior);
Guia_Inferior = AddLine(simulationManager, uc.GuiaInferior);
CrearAnimacionStoryBoardTrasnporte(uc.Transporte);
}
Motor = Motor; // Forzar la busqueda
}
@ -234,7 +132,7 @@ namespace CtrEditor.ObjetosSim
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
simulationManager.Remove(TransporteCentral);
simulationManager.Remove(SimGeometria);
simulationManager.Remove(Guia_Superior);
simulationManager.Remove(Guia_Inferior);
}

View File

@ -1,21 +1,22 @@
<UserControl x:Class="CtrEditor.ObjetosSim.ucTransporteTTop"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
<convert:SpeedAndWidthToDurationConverter x:Key="SpeedAndWidthToDurationConverter"/>
<!-- Define the VisualBrush for the conveyor belt pattern -->
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,0.1,1" ViewportUnits="RelativeToBoundingBox" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
<VisualBrush.Transform>
<TranslateTransform x:Name="BrushTransform"/>
<TransformGroup>
<TranslateTransform/>
</TransformGroup>
</VisualBrush.Transform>
<VisualBrush.Visual>
<Canvas>
@ -38,28 +39,6 @@
<Rectangle.RenderTransform>
<RotateTransform Angle="{Binding Angulo}"/>
</Rectangle.RenderTransform>
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(Rectangle.Fill).(VisualBrush.Transform).(TranslateTransform.X)"
From="0" To="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}">
<DoubleAnimation.Duration>
<MultiBinding Converter="{StaticResource SpeedAndWidthToDurationConverter}">
<Binding Path="VelocidadActual"/>
<Binding Path="Ancho"/>
</MultiBinding>
</DoubleAnimation.Duration>
<DoubleAnimation.RepeatBehavior>Forever</DoubleAnimation.RepeatBehavior>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</Canvas>
</UserControl>
</UserControl>

View File

@ -6,6 +6,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using CtrEditor.Simulacion;
using System.Windows.Input;
namespace CtrEditor.ObjetosSim
@ -19,7 +20,7 @@ namespace CtrEditor.ObjetosSim
{
private osBase _osMotor = null;
private simTransporte Simulation_Transporte;
private simTransporte SimGeometria;
public static string NombreClase()
{
@ -32,36 +33,19 @@ namespace CtrEditor.ObjetosSim
set => SetProperty(ref nombre, value);
}
private float left;
public override float Left
{
get => left;
set
{
CanvasSetLeftinMeter(value);
SetProperty(ref left, value);
}
}
private float top;
public override float Top
{
get => top;
set
{
CanvasSetTopinMeter(value);
SetProperty(ref top, value);
}
}
private float velocidadActual;
public float VelocidadActual
{
get => velocidadActual;
set
{
velocidadActual = value;
Simulation_Transporte?.SetSpeed(value);
SetProperty(ref velocidadActual, value);
if (value != velocidadActual)
{
velocidadActual = value;
SimGeometria?.SetSpeed(value);
SetProperty(ref velocidadActual, value);
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
}
}
}
@ -82,30 +66,34 @@ namespace CtrEditor.ObjetosSim
[ObservableProperty]
public bool esMarcha;
private void ActualizarGeometrias()
{
if (_visualRepresentation is ucTransporteTTop uc)
{
UpdateRectangle(Simulation_Transporte, uc.Transporte,Alto,Ancho,Angulo);
Simulation_Transporte.Speed = VelocidadActual;
UpdateRectangle(SimGeometria, uc.Transporte,Alto,Ancho,Angulo);
SimGeometria.Speed = VelocidadActual;
}
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
}
public osTransporteTTop()
{
{
Ancho = 1;
Alto = 0.10f;
}
public override void SimulationStop()
{
// Se llama al detener la simulacion
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
}
public override void UpdateGeometryStart()
{
// Se llama antes de la simulacion
ActualizarGeometrias();
}
public override void UpdateGeometryStep()
{
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
{
if (_osMotor != null)
@ -117,9 +105,6 @@ namespace CtrEditor.ObjetosSim
_osMotor = ObtenerLink(Motor, typeof(osVMmotorSim));
}
public override void UpdateControl(int elapsedMilliseconds)
{
}
public override void ucLoaded()
{
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
@ -127,13 +112,16 @@ namespace CtrEditor.ObjetosSim
ActualizarLeftTop();
if (_visualRepresentation is ucTransporteTTop uc)
Simulation_Transporte = AddRectangle(simulationManager, uc.Transporte, Alto, Ancho, Angulo);
{
SimGeometria = AddRectangle(simulationManager, uc.Transporte, Alto, Ancho, Angulo);
CrearAnimacionStoryBoardTrasnporte(uc.Transporte);
}
}
public override void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
simulationManager.Remove(Simulation_Transporte);
simulationManager.Remove(SimGeometria);
}
}

View File

@ -5,17 +5,33 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
mc:Ignorable="d"
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
<UserControl.Resources>
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
</UserControl.Resources>
<UserControl.DataContext>
<vm:osVMmotorSim ImageSource_oculta="/imagenes/motorNegro.png" />
</UserControl.DataContext>
<Grid>
<Image Source="{Binding ImageSource}"
Width="{Binding Tamano, Converter={StaticResource MeterToPixelConverter}}"
Height="{Binding Tamano, Converter={StaticResource MeterToPixelConverter}}"
Stretch="Uniform"/>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{Binding Nombre}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
Foreground="Black"/>
<Image Grid.Row="1" Source="{Binding ImageSource_oculta}"
Width="{Binding Tamano, Converter={StaticResource MeterToPixelConverter}}"
Height="{Binding Tamano, Converter={StaticResource MeterToPixelConverter}}"
Stretch="Uniform"/>
</Grid>
</UserControl>

View File

@ -1,21 +1,10 @@
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
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;
using CtrEditor.Simulacion;
using Newtonsoft.Json;
using CommunityToolkit.Mvvm.ComponentModel;
namespace CtrEditor.ObjetosSim
{
@ -24,148 +13,59 @@ namespace CtrEditor.ObjetosSim
/// </summary>
///
public class osVMmotorSim : osBase, IosBase
public partial class osVMmotorSim : osBase, IosBase
{
// Otros datos y métodos relevantes para la simulación
private string _nombre = NombreClase();
private float _tamano;
private float _left;
private float _top;
private int _numeroMotor;
private float _ratio;
private float _velocidad;
private bool _encendido;
private float _rampaSegundos;
private float _maxHz;
private ImageSource _imageSource;
private VMSimMotor motState = new VMSimMotor();
public static string NombreClase()
{
return "VetroMeccanica Motor";
}
[Hidden]
[JsonIgnore]
public ImageSource ImageSource
{
get { return _imageSource; }
set
{
_imageSource = value;
OnPropertyChanged(nameof(ImageSource));
}
}
public float Tamano
{
get => _tamano;
set
{
_tamano = value;
OnPropertyChanged(nameof(Tamano));
}
}
public float MaxRatedHz
{
get => _maxHz;
set
{
_maxHz = value;
OnPropertyChanged(nameof(Tamano));
}
}
public float TiempoRampa
{
get => _rampaSegundos;
set
{
if (value < 0.1f)
value = 0.1f;
_rampaSegundos = value;
OnPropertyChanged(nameof(Tamano));
}
}
public bool Encendido
{
get => _encendido;
set
{
_encendido = value;
OnPropertyChanged(nameof(Encendido));
}
}
public int PLC_NumeroMotor
{
get => _numeroMotor;
set
{
_numeroMotor = value;
OnPropertyChanged(nameof(PLC_NumeroMotor));
}
}
public override float Left
{
get => _left;
set
{
_left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => _top;
set
{
_top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
private string nombre = NombreClase();
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
get => nombre;
set => SetProperty(ref nombre, value);
}
public float Ratio {
get => _ratio;
set {
_ratio = value;
OnPropertyChanged(nameof(Ratio));
}
[JsonIgnore]
[ObservableProperty]
public ImageSource imageSource_oculta;
[ObservableProperty]
public float tamano;
[ObservableProperty]
public float maxRatedHz;
[ObservableProperty]
public float tiempoRampa;
partial void OnTiempoRampaChanged(float value)
{
if (value < 0.1f)
value = 0.1f;
tiempoRampa = value;
}
public float Velocidad {
get => _velocidad;
set {
_velocidad = value;
if (value > 0)
ImageSource = ImageFromPath("/imagenes/motorVerde.png");
else
ImageSource = ImageFromPath("/imagenes/motorNegro.png");
[ObservableProperty]
public bool encendido;
[ObservableProperty]
public int pLC_NumeroMotor;
[ObservableProperty]
public float ratio;
OnPropertyChanged(nameof(Velocidad));
}
[ObservableProperty]
public float velocidad;
partial void OnVelocidadChanged(float value)
{
if (value > 0)
ImageSource_oculta = ImageFromPath("/imagenes/motorVerde.png");
else
ImageSource_oculta = ImageFromPath("/imagenes/motorNegro.png");
}
public osVMmotorSim()
@ -174,16 +74,13 @@ namespace CtrEditor.ObjetosSim
PLC_NumeroMotor = 31;
MaxRatedHz = 100;
TiempoRampa = 3;
ImageSource = ImageFromPath("/imagenes/motor2.png");
ImageSource_oculta = ImageFromPath("/imagenes/motor2.png");
}
public override void UpdateGeometryStart()
{
// Se llama antes de la simulacion
}
public override void UpdateGeometryStep()
{
}
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds) {
@ -206,11 +103,6 @@ namespace CtrEditor.ObjetosSim
ActualizarLeftTop();
}
public override void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
}
}
public partial class ucVMmotorSim : UserControl, IDataContainer

View File

@ -21,6 +21,7 @@ using Siemens.Simatic.Simulation.Runtime;
using System.Windows.Media.Imaging;
using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Windows.Media.Animation;
namespace CtrEditor.ObjetosSim
{
@ -65,12 +66,33 @@ namespace CtrEditor.ObjetosSim
}
public abstract class osBase : ObservableObject
public abstract partial class osBase : ObservableObject
{
public virtual string Nombre { get; set; } = "osBase";
[JsonIgnore]
private Storyboard _storyboard;
[ObservableProperty]
private float left;
partial void OnLeftChanged(float value)
{
CanvasSetLeftinMeter(value);
LeftChanged(value);
}
public virtual void LeftChanged(float value) { }
[ObservableProperty]
private float top;
partial void OnTopChanged(float value)
{
CanvasSetTopinMeter(value);
TopChanged(value);
}
public virtual void TopChanged(float value) { }
public abstract float Left { get; set; }
public abstract float Top { get; set; }
public bool Inicializado = false;
public bool AutoCreated = false;
@ -82,12 +104,25 @@ namespace CtrEditor.ObjetosSim
[JsonIgnore]
protected UserControl? _visualRepresentation = null;
public abstract void UpdateControl(int elapsedMilliseconds);
public abstract void UpdateGeometryStart();
public abstract void UpdateGeometryStep();
public abstract void UpdatePLC(PLCModel plc, int elapsedMilliseconds);
public abstract void ucLoaded();
public abstract void ucUnLoaded();
public virtual void UpdateControl(int elapsedMilliseconds) { }
public virtual void UpdateGeometryStart()
{
// Se llama antes de la simulacion
}
public virtual void SimulationStop() { }
public virtual void UpdateGeometryStep() { }
public virtual void UpdatePLC(PLCModel plc, int elapsedMilliseconds) { }
public virtual void ucLoaded()
{
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
// crear el objeto de simulacion
ActualizarLeftTop();
}
public virtual void ucUnLoaded()
{
// El UserControl se esta eliminando
// eliminar el objeto de simulacion
}
[JsonIgnore]
public MainViewModel _mainViewModel;
@ -129,10 +164,41 @@ namespace CtrEditor.ObjetosSim
return null;
}
protected void CrearAnimacionStoryBoardTrasnporte(System.Windows.Shapes.Rectangle transporte)
{
if (_visualRepresentation == null) return;
if (transporte == null) return;
_storyboard = new Storyboard();
var animation = new DoubleAnimation
{
From = 0,
To = 20, // Total Pixels Brush
Duration = TimeSpan.FromSeconds(PixelToMeter.Instance.calc.PixelsToMeters(20) * 60),
RepeatBehavior = RepeatBehavior.Forever
};
Storyboard.SetTarget(animation, transporte);
Storyboard.SetTargetProperty(animation, new PropertyPath("(Rectangle.Fill).(VisualBrush.Transform).(TransformGroup.Children)[0].(TranslateTransform.X)"));
_storyboard.Children.Add(animation);
_storyboard.Begin();
_storyboard.SetSpeedRatio(0);
}
protected void ActualizarAnimacionStoryBoardTransporte(float velocidadActual)
{
if (_visualRepresentation == null) return;
if (_storyboard == null) return;
if (!_mainViewModel.IsSimulationRunning)
_storyboard.SetSpeedRatio(0);
else
_storyboard.SetSpeedRatio(velocidadActual);
}
public void ActualizarLeftTop()
{
Left = Left;
Top = Top;
CanvasSetLeftinMeter(Left);
CanvasSetTopinMeter(Top);
}
public bool LeerBitTag(PLCModel plc, string Tag)

View File

@ -34,7 +34,10 @@ namespace CtrEditor.Simulacion
{
Body.SetTransform(new Vector2(x, y), Body.Rotation);
}
public void SetPosition(Vector2 centro)
{
Body.SetTransform(centro, Body.Rotation);
}
}
public class simCurve : simBase