Agregado posibilidad al Frame de moverse horizontal y verticalmente. Agregado TransporteDualInverter para que sea comandado por dos inverters seleccionables desde un tag. Agregada funcionalidad de cambio de tamaño a las curvas.
This commit is contained in:
parent
f264efd9ce
commit
304bdb06d4
|
@ -23,7 +23,7 @@
|
||||||
<xctk:EditorTemplateDefinition.EditingTemplate>
|
<xctk:EditorTemplateDefinition.EditingTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBox Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
|
<TextBox Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
|
||||||
Text="{Binding Value}" />
|
Text="{Binding Value, UpdateSourceTrigger=LostFocus}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</xctk:EditorTemplateDefinition.EditingTemplate>
|
</xctk:EditorTemplateDefinition.EditingTemplate>
|
||||||
</xctk:EditorTemplateDefinition>
|
</xctk:EditorTemplateDefinition>
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
<xctk:EditorTemplateDefinition.EditingTemplate>
|
<xctk:EditorTemplateDefinition.EditingTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<xctk:SingleUpDown Increment="0.01"
|
<xctk:SingleUpDown Increment="0.01"
|
||||||
Text="{Binding Value, Converter={StaticResource floatFormatter}}" />
|
Text="{Binding Value, Converter={StaticResource floatFormatter}, UpdateSourceTrigger=LostFocus}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</xctk:EditorTemplateDefinition.EditingTemplate>
|
</xctk:EditorTemplateDefinition.EditingTemplate>
|
||||||
</xctk:EditorTemplateDefinition>
|
</xctk:EditorTemplateDefinition>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
</xctk:EditorTemplateDefinition.TargetProperties>
|
</xctk:EditorTemplateDefinition.TargetProperties>
|
||||||
<xctk:EditorTemplateDefinition.EditingTemplate>
|
<xctk:EditorTemplateDefinition.EditingTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBox Text="{Binding Value, Converter={StaticResource doubleFormatter}}" />
|
<TextBox Text="{Binding Value, Converter={StaticResource doubleFormatter}, UpdateSourceTrigger=LostFocus}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</xctk:EditorTemplateDefinition.EditingTemplate>
|
</xctk:EditorTemplateDefinition.EditingTemplate>
|
||||||
</xctk:EditorTemplateDefinition>
|
</xctk:EditorTemplateDefinition>
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public float alto_Titulo;
|
public float alto_Titulo;
|
||||||
|
|
||||||
// Encoder
|
// Encoder X
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[property: Description("This is a link to a Encoder for X.")]
|
[property: Description("This is a link to a Encoder for X.")]
|
||||||
[property: Category("Encoders:")]
|
[property: Category("Encoders:")]
|
||||||
|
@ -73,6 +73,33 @@ namespace CtrEditor.ObjetosSim
|
||||||
[property: Category("Encoders:")]
|
[property: Category("Encoders:")]
|
||||||
public float offset_encoder_X;
|
public float offset_encoder_X;
|
||||||
|
|
||||||
|
// Encoder Y
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("This is a link to a Encoder for Y.")]
|
||||||
|
[property: Category("Encoders:")]
|
||||||
|
[property: ItemsSource(typeof(osBaseItemsSource<osEncoderMotorLineal>))]
|
||||||
|
private string encoder_Y;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("K Pulses per meter for Moving")]
|
||||||
|
[property: Category("Encoders:")]
|
||||||
|
public float k_encoder_Y;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Y in meter offset Top. Position when the encoder is 0")]
|
||||||
|
[property: Category("Encoders:")]
|
||||||
|
public float offset_encoder_Y;
|
||||||
|
|
||||||
|
partial void OnK_encoder_YChanged(float value)
|
||||||
|
{
|
||||||
|
UpdatePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void OnOffset_encoder_YChanged(float value)
|
||||||
|
{
|
||||||
|
UpdatePosition();
|
||||||
|
}
|
||||||
|
|
||||||
partial void OnK_encoder_XChanged(float value)
|
partial void OnK_encoder_XChanged(float value)
|
||||||
{
|
{
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
|
@ -86,9 +113,15 @@ namespace CtrEditor.ObjetosSim
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
private osEncoderMotorLineal EncoderX;
|
private osEncoderMotorLineal EncoderX;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
private osEncoderMotorLineal EncoderY;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
private bool isUpdatingFromEncoderX = false;
|
private bool isUpdatingFromEncoderX = false;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
private bool isUpdatingFromEncoderY = false;
|
||||||
|
|
||||||
partial void OnEncoder_XChanged(string value)
|
partial void OnEncoder_XChanged(string value)
|
||||||
{
|
{
|
||||||
if (EncoderX != null)
|
if (EncoderX != null)
|
||||||
|
@ -101,6 +134,18 @@ namespace CtrEditor.ObjetosSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void OnEncoder_YChanged(string value)
|
||||||
|
{
|
||||||
|
if (EncoderY != null)
|
||||||
|
EncoderY.PropertyChanged -= OnEncoderYPropertyChanged;
|
||||||
|
if (_mainViewModel != null && value != null && value.Length > 0)
|
||||||
|
{
|
||||||
|
EncoderY = (osEncoderMotorLineal)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osEncoderMotorLineal && s.Nombre == value), null);
|
||||||
|
if (EncoderY != null)
|
||||||
|
EncoderY.PropertyChanged += OnEncoderYPropertyChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnEncoderXPropertyChanged(object sender, PropertyChangedEventArgs e)
|
private void OnEncoderXPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!isUpdatingFromEncoderX)
|
if (!isUpdatingFromEncoderX)
|
||||||
|
@ -108,7 +153,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
isUpdatingFromEncoderX = true;
|
isUpdatingFromEncoderX = true;
|
||||||
// Actualizamos el nombre si este fue modificado
|
// Actualizamos el nombre si este fue modificado
|
||||||
if (e.PropertyName == nameof(osEncoderMotorLineal.Nombre))
|
if (e.PropertyName == nameof(osEncoderMotorLineal.Nombre))
|
||||||
Group_Panel = ((osEncoderMotorLineal)sender).Nombre;
|
Encoder_X = ((osEncoderMotorLineal)sender).Nombre;
|
||||||
|
|
||||||
if (e.PropertyName == nameof(osEncoderMotorLineal.Valor_Actual))
|
if (e.PropertyName == nameof(osEncoderMotorLineal.Valor_Actual))
|
||||||
{
|
{
|
||||||
|
@ -119,13 +164,33 @@ namespace CtrEditor.ObjetosSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEncoderYPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!isUpdatingFromEncoderY)
|
||||||
|
{
|
||||||
|
isUpdatingFromEncoderY = true;
|
||||||
|
// Actualizamos el nombre si este fue modificado
|
||||||
|
if (e.PropertyName == nameof(osEncoderMotorLineal.Nombre))
|
||||||
|
Encoder_Y = ((osEncoderMotorLineal)sender).Nombre;
|
||||||
|
|
||||||
|
if (e.PropertyName == nameof(osEncoderMotorLineal.Valor_Actual))
|
||||||
|
{
|
||||||
|
UpdatePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
isUpdatingFromEncoderY = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdatePosition()
|
public void UpdatePosition()
|
||||||
{
|
{
|
||||||
if (EncoderX == null)
|
// Update X position if encoder is available
|
||||||
return;
|
if (EncoderX != null && K_encoder_X != 0)
|
||||||
if (K_encoder_X == 0)
|
Left = (EncoderX.Valor_Actual / k_encoder_X) + offset_encoder_X;
|
||||||
return;
|
|
||||||
Left = (EncoderX.Valor_Actual / k_encoder_X) + offset_encoder_X;
|
// Update Y position if encoder is available
|
||||||
|
if (EncoderY != null && K_encoder_Y != 0)
|
||||||
|
Top = (EncoderY.Valor_Actual / k_encoder_Y) + offset_encoder_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void TopChanging(float oldValue, float newValue)
|
public override void TopChanging(float oldValue, float newValue)
|
||||||
|
@ -158,6 +223,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
base.ucLoaded();
|
base.ucLoaded();
|
||||||
// El UserControl se ha cargado
|
// El UserControl se ha cargado
|
||||||
OnEncoder_XChanged(Encoder_X);
|
OnEncoder_XChanged(Encoder_X);
|
||||||
|
OnEncoder_YChanged(Encoder_Y);
|
||||||
UpdateZIndex(Zindex_FramePlate);
|
UpdateZIndex(Zindex_FramePlate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,32 @@ namespace CtrEditor.ObjetosSim
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private float radioExterno;
|
private float radioExterno;
|
||||||
|
|
||||||
|
partial void OnRadioExternoChanged(float value)
|
||||||
|
{
|
||||||
|
// Update ancho and alto based on radioExterno
|
||||||
|
Ancho = value * 2;
|
||||||
|
Alto = value * 2;
|
||||||
|
|
||||||
|
// Ensure radioInterno maintains proper proportion if needed
|
||||||
|
if (RadioInterno >= value)
|
||||||
|
{
|
||||||
|
RadioInterno = value * 0.75f; // Default proportion
|
||||||
|
}
|
||||||
|
|
||||||
|
ActualizarGeometrias();
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private float radioInterno;
|
private float radioInterno;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Bit to enable Link to Motor")]
|
||||||
|
[property: Category("PLC link:")]
|
||||||
|
string tag_ReleActivatedMotor;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[property: Description("Link to Motor")]
|
[property: Description("Link to Motor")]
|
||||||
[property: Category("PLC link:")]
|
[property: Category("PLC link:")]
|
||||||
|
@ -130,11 +153,52 @@ namespace CtrEditor.ObjetosSim
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public bool esMarcha;
|
public bool esMarcha;
|
||||||
|
|
||||||
|
public override void OnResize(float Delta_Width, float Delta_Height)
|
||||||
|
{
|
||||||
|
// Calculate the proportional change factor
|
||||||
|
float widthChangeFactor = (Ancho + Delta_Width) / Ancho;
|
||||||
|
float heightChangeFactor = (Alto + Delta_Height) / Alto;
|
||||||
|
|
||||||
|
// Use the average or minimum change factor to maintain aspect ratio
|
||||||
|
float changeFactor = Math.Min(widthChangeFactor, heightChangeFactor);
|
||||||
|
|
||||||
|
// Save the original radiuses for calculating position adjustments
|
||||||
|
float originalRadioExterno = RadioExterno;
|
||||||
|
|
||||||
|
// Apply the change factor to both radios
|
||||||
|
RadioExterno *= changeFactor;
|
||||||
|
RadioInterno *= changeFactor;
|
||||||
|
|
||||||
|
// Calculate position adjustment to keep the component centered
|
||||||
|
float radiusDifference = RadioExterno - originalRadioExterno;
|
||||||
|
|
||||||
|
// Adjust Left and Top to maintain center position
|
||||||
|
// We move by negative half the difference because the component expands outward
|
||||||
|
Left -= radiusDifference;
|
||||||
|
Top -= radiusDifference;
|
||||||
|
|
||||||
|
// Ensure minimums
|
||||||
|
if (RadioExterno < 0.1f)
|
||||||
|
RadioExterno = 0.1f;
|
||||||
|
|
||||||
|
if (RadioInterno < 0.05f)
|
||||||
|
RadioInterno = 0.05f;
|
||||||
|
|
||||||
|
// Ensure radioInterno is always less than radioExterno
|
||||||
|
if (RadioInterno >= RadioExterno)
|
||||||
|
RadioInterno = RadioExterno * 0.75f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public osTransporteCurva()
|
public osTransporteCurva()
|
||||||
{
|
{
|
||||||
RadioExterno = 1.3f;
|
RadioExterno = 1.3f;
|
||||||
RadioInterno = 1;
|
RadioInterno = 1f;
|
||||||
|
Ancho = RadioExterno * 2; // Set initial width based on external radius
|
||||||
|
Alto = RadioExterno * 2; // Set initial height based on external radius
|
||||||
Arco_en_grados = 90;
|
Arco_en_grados = 90;
|
||||||
|
Tag_ReleActivatedMotor = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateGeometryStart()
|
public override void UpdateGeometryStart()
|
||||||
|
@ -149,7 +213,10 @@ namespace CtrEditor.ObjetosSim
|
||||||
if (Motor != null)
|
if (Motor != null)
|
||||||
{
|
{
|
||||||
if (Motor is osVMmotorSim motor)
|
if (Motor is osVMmotorSim motor)
|
||||||
VelocidadActual = motor.Velocidad;
|
if (LeerBitTag(Tag_ReleActivatedMotor))
|
||||||
|
VelocidadActual = motor.Velocidad;
|
||||||
|
else
|
||||||
|
VelocidadActual = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,11 @@ namespace CtrEditor.ObjetosSim
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
Color color = Colors.Blue;
|
Color color = Colors.Blue;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Bit to enable Link to Motor")]
|
||||||
|
[property: Category("PLC link:")]
|
||||||
|
string tag_ReleActivatedMotor;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[property: Description("Link to Motor")]
|
[property: Description("Link to Motor")]
|
||||||
[property: Category("PLC link:")]
|
[property: Category("PLC link:")]
|
||||||
|
@ -152,6 +157,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
Alto = 0.10f;
|
Alto = 0.10f;
|
||||||
AltoGuia = 0.03f;
|
AltoGuia = 0.03f;
|
||||||
Distance = 0.01f;
|
Distance = 0.01f;
|
||||||
|
Tag_ReleActivatedMotor = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateGeometryStart()
|
public override void UpdateGeometryStart()
|
||||||
|
@ -159,16 +165,21 @@ namespace CtrEditor.ObjetosSim
|
||||||
// Se llama antes de la simulacion
|
// Se llama antes de la simulacion
|
||||||
ActualizarGeometrias();
|
ActualizarGeometrias();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SimulationStop()
|
public override void SimulationStop()
|
||||||
{
|
{
|
||||||
// Se llama al detener la simulacion
|
// Se llama al detener la simulacion
|
||||||
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
|
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
|
||||||
{
|
{
|
||||||
if (Motor != null)
|
if (Motor != null)
|
||||||
if (Motor is osVMmotorSim id_motor)
|
if (Motor is osVMmotorSim id_motor)
|
||||||
VelocidadActual = id_motor.Velocidad;
|
if (LeerBitTag(Tag_ReleActivatedMotor))
|
||||||
|
VelocidadActual = id_motor.Velocidad;
|
||||||
|
else
|
||||||
|
VelocidadActual = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ucLoaded()
|
public override void ucLoaded()
|
||||||
|
|
|
@ -41,6 +41,11 @@ namespace CtrEditor.ObjetosSim
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
Color color;
|
Color color;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Bit to enable Link to Motor")]
|
||||||
|
[property: Category("PLC link:")]
|
||||||
|
string tag_ReleActivatedMotor;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[property: Description("Link to Motor A")]
|
[property: Description("Link to Motor A")]
|
||||||
[property: Category("PLC link:")]
|
[property: Category("PLC link:")]
|
||||||
|
@ -245,6 +250,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
Storyboards = new Dictionary<Rectangle, Storyboard>();
|
Storyboards = new Dictionary<Rectangle, Storyboard>();
|
||||||
TransportsDirection = new Dictionary<Rectangle, BoolReference>();
|
TransportsDirection = new Dictionary<Rectangle, BoolReference>();
|
||||||
TransportsVelocidad = new Dictionary<Rectangle, FloatReference>();
|
TransportsVelocidad = new Dictionary<Rectangle, FloatReference>();
|
||||||
|
Tag_ReleActivatedMotor = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateGeometryStart()
|
public override void UpdateGeometryStart()
|
||||||
|
@ -268,13 +274,19 @@ namespace CtrEditor.ObjetosSim
|
||||||
if (_osMotorA != null)
|
if (_osMotorA != null)
|
||||||
{
|
{
|
||||||
if (_osMotorA is osVMmotorSim motor)
|
if (_osMotorA is osVMmotorSim motor)
|
||||||
VelocidadActualA = motor.Velocidad;
|
if (LeerBitTag(Tag_ReleActivatedMotor))
|
||||||
|
VelocidadActualA = motor.Velocidad;
|
||||||
|
else
|
||||||
|
VelocidadActualA = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_osMotorB != null)
|
if (_osMotorB != null)
|
||||||
{
|
{
|
||||||
if (_osMotorB is osVMmotorSim motor)
|
if (_osMotorB is osVMmotorSim motor)
|
||||||
VelocidadActualB = motor.Velocidad;
|
if (LeerBitTag(Tag_ReleActivatedMotor))
|
||||||
|
VelocidadActualB = motor.Velocidad;
|
||||||
|
else
|
||||||
|
VelocidadActualB = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,11 @@ namespace CtrEditor.ObjetosSim
|
||||||
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Bit to enable Link to Motor")]
|
||||||
|
[property: Category("PLC link:")]
|
||||||
|
string tag_ReleActivatedMotor;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[property: Description("Link to Motor")]
|
[property: Description("Link to Motor")]
|
||||||
[property: Category("PLC link:")]
|
[property: Category("PLC link:")]
|
||||||
|
@ -131,6 +136,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
{
|
{
|
||||||
Ancho = 1;
|
Ancho = 1;
|
||||||
Alto = 0.10f;
|
Alto = 0.10f;
|
||||||
|
Tag_ReleActivatedMotor = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SimulationStop()
|
public override void SimulationStop()
|
||||||
|
@ -148,7 +154,10 @@ namespace CtrEditor.ObjetosSim
|
||||||
{
|
{
|
||||||
if (Motor != null)
|
if (Motor != null)
|
||||||
if (Motor is osVMmotorSim motor)
|
if (Motor is osVMmotorSim motor)
|
||||||
VelocidadActual = motor.Velocidad;
|
if (LeerBitTag(Tag_ReleActivatedMotor))
|
||||||
|
VelocidadActual = motor.Velocidad;
|
||||||
|
else
|
||||||
|
VelocidadActual = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ucLoaded()
|
public override void ucLoaded()
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
<UserControl x:Class="CtrEditor.ObjetosSim.ucTransporteTTopDualInverter"
|
||||||
|
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:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<!-- 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="LightGray" Width="10" Height="10" />
|
||||||
|
<Rectangle Fill="GhostWhite" Width="10" Height="10" Canvas.Left="10" />
|
||||||
|
</Canvas>
|
||||||
|
</VisualBrush.Visual>
|
||||||
|
</VisualBrush>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<UserControl.DataContext>
|
||||||
|
<vm:osTransporteTTop Ancho="2" />
|
||||||
|
</UserControl.DataContext>
|
||||||
|
|
||||||
|
<Canvas RenderTransformOrigin="0,0">
|
||||||
|
<Canvas.RenderTransform>
|
||||||
|
<TransformGroup>
|
||||||
|
<ScaleTransform />
|
||||||
|
<SkewTransform />
|
||||||
|
<RotateTransform Angle="{Binding Angulo}" />
|
||||||
|
<TranslateTransform />
|
||||||
|
</TransformGroup>
|
||||||
|
</Canvas.RenderTransform>
|
||||||
|
<Rectangle x:Name="Transporte" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}"
|
||||||
|
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"
|
||||||
|
Fill="{StaticResource BeltBrush}">
|
||||||
|
</Rectangle>
|
||||||
|
<Viewbox Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}"
|
||||||
|
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}" Stretch="Uniform">
|
||||||
|
<Label Content="{Binding Nombre}" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold"
|
||||||
|
FontSize="18" Opacity="0.9" />
|
||||||
|
</Viewbox>
|
||||||
|
</Canvas>
|
||||||
|
</UserControl>
|
|
@ -0,0 +1,267 @@
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.FuncionesBase;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using LibS7Adv;
|
||||||
|
using CtrEditor.Simulacion;
|
||||||
|
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using CtrEditor.FuncionesBase;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace CtrEditor.ObjetosSim
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for ucTransporteTTop.xaml
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
|
||||||
|
public partial class osTransporteTTopDualInverter : osBase, IosBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private simTransporte SimGeometria;
|
||||||
|
private osVMmotorSim MotorA;
|
||||||
|
private osVMmotorSim MotorB;
|
||||||
|
|
||||||
|
public static string NombreClase()
|
||||||
|
{
|
||||||
|
return "Transporte Dual Inverter";
|
||||||
|
}
|
||||||
|
private string nombre = "Transporte TTOP Dual Inverter";
|
||||||
|
|
||||||
|
[property: Category("Id:")]
|
||||||
|
public override string Nombre
|
||||||
|
{
|
||||||
|
get => nombre;
|
||||||
|
set => SetProperty(ref nombre, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Category("Simulation:")]
|
||||||
|
public float velocidadActual;
|
||||||
|
|
||||||
|
partial void OnVelocidadActualChanged(float value)
|
||||||
|
{
|
||||||
|
SetSpeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Category("Simulation:")]
|
||||||
|
bool invertirDireccion;
|
||||||
|
|
||||||
|
partial void OnInvertirDireccionChanged(bool value)
|
||||||
|
{
|
||||||
|
SetSpeed();
|
||||||
|
if (_visualRepresentation is ucTransporteTTop uc)
|
||||||
|
{
|
||||||
|
CrearAnimacionStoryBoardTrasnporte(uc.Transporte, InvertirDireccion);
|
||||||
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSpeed()
|
||||||
|
{
|
||||||
|
if (InvertirDireccion)
|
||||||
|
SimGeometria?.SetSpeed(-VelocidadActual);
|
||||||
|
else
|
||||||
|
SimGeometria?.SetSpeed(VelocidadActual);
|
||||||
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Bit to enable Link to Inverter A")]
|
||||||
|
[property: Category("PLC link:")]
|
||||||
|
string tag_ReleActivatedMotor_A;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Bit to enable Link to Inverter B")]
|
||||||
|
[property: Category("PLC link:")]
|
||||||
|
string tag_ReleActivatedMotor_B;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Link to Inverter A")]
|
||||||
|
[property: Category("PLC link:")]
|
||||||
|
[property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))]
|
||||||
|
string id_Motor_A;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Description("Link to Inverter B")]
|
||||||
|
[property: Category("PLC link:")]
|
||||||
|
[property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))]
|
||||||
|
string id_Motor_B;
|
||||||
|
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
private PropertyChangedEventHandler motorPropertyChangedHandler;
|
||||||
|
|
||||||
|
partial void OnId_Motor_AChanged(string value)
|
||||||
|
{
|
||||||
|
if (MotorA != null && motorPropertyChangedHandler != null)
|
||||||
|
MotorA.PropertyChanged -= motorPropertyChangedHandler;
|
||||||
|
|
||||||
|
if (_mainViewModel != null && !string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
MotorA = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => s is osVMmotorSim motor && motor.Nombre == value);
|
||||||
|
if (MotorA != null)
|
||||||
|
{
|
||||||
|
motorPropertyChangedHandler = (sender, e) =>
|
||||||
|
{
|
||||||
|
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
|
||||||
|
{
|
||||||
|
Id_Motor_A = ((osVMmotorSim)sender).Nombre;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MotorA.PropertyChanged += motorPropertyChangedHandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void OnId_Motor_BChanged(string value)
|
||||||
|
{
|
||||||
|
if (MotorB != null && motorPropertyChangedHandler != null)
|
||||||
|
MotorB.PropertyChanged -= motorPropertyChangedHandler;
|
||||||
|
|
||||||
|
if (_mainViewModel != null && !string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
MotorB = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => s is osVMmotorSim motor && motor.Nombre == value);
|
||||||
|
if (MotorB != null)
|
||||||
|
{
|
||||||
|
motorPropertyChangedHandler = (sender, e) =>
|
||||||
|
{
|
||||||
|
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
|
||||||
|
{
|
||||||
|
Id_Motor_B = ((osVMmotorSim)sender).Nombre;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MotorB.PropertyChanged += motorPropertyChangedHandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Category("Setup:")]
|
||||||
|
public float frictionCoefficient;
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Category("Setup:")]
|
||||||
|
public float velMax50hz;
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Category("Setup:")]
|
||||||
|
public float tiempoRampa;
|
||||||
|
[ObservableProperty]
|
||||||
|
[property: Category("Setup:")]
|
||||||
|
public bool esMarcha;
|
||||||
|
|
||||||
|
|
||||||
|
private void ActualizarGeometrias()
|
||||||
|
{
|
||||||
|
if (_visualRepresentation is ucTransporteTTop uc)
|
||||||
|
{
|
||||||
|
UpdateRectangle(SimGeometria, uc.Transporte, Alto, Ancho, Angulo);
|
||||||
|
SetSpeed();
|
||||||
|
}
|
||||||
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnMoveResizeRotate()
|
||||||
|
{
|
||||||
|
ActualizarGeometrias();
|
||||||
|
}
|
||||||
|
|
||||||
|
public osTransporteTTopDualInverter()
|
||||||
|
{
|
||||||
|
Ancho = 1;
|
||||||
|
Alto = 0.10f;
|
||||||
|
Tag_ReleActivatedMotor_A = "1";
|
||||||
|
Tag_ReleActivatedMotor_B = "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
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 UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
|
||||||
|
{
|
||||||
|
if (LeerBitTag(Tag_ReleActivatedMotor_A))
|
||||||
|
{
|
||||||
|
if (MotorA != null)
|
||||||
|
if (MotorA is osVMmotorSim motor)
|
||||||
|
VelocidadActual = motor.Velocidad;
|
||||||
|
else
|
||||||
|
VelocidadActual = 0;
|
||||||
|
}
|
||||||
|
else if (LeerBitTag(Tag_ReleActivatedMotor_B))
|
||||||
|
{
|
||||||
|
if (MotorB != null)
|
||||||
|
if (MotorB is osVMmotorSim motor)
|
||||||
|
VelocidadActual = motor.Velocidad;
|
||||||
|
else
|
||||||
|
VelocidadActual = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ucLoaded()
|
||||||
|
{
|
||||||
|
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
||||||
|
// crear el objeto de simulacion
|
||||||
|
base.ucLoaded();
|
||||||
|
OnId_Motor_AChanged(Id_Motor_A); // Link Id_Motor = Motor
|
||||||
|
OnId_Motor_BChanged(Id_Motor_B); // Link Id_Motor = Motor
|
||||||
|
|
||||||
|
if (_visualRepresentation is ucTransporteTTop uc)
|
||||||
|
{
|
||||||
|
SimGeometria = AddRectangle(simulationManager, uc.Transporte, Alto, Ancho, Angulo);
|
||||||
|
CrearAnimacionStoryBoardTrasnporte(uc.Transporte, InvertirDireccion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override void ucUnLoaded()
|
||||||
|
{
|
||||||
|
// El UserControl se esta eliminando
|
||||||
|
// eliminar el objeto de simulacion
|
||||||
|
simulationManager.Remove(SimGeometria);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class ucTransporteTTopDualInverter : UserControl, IDataContainer
|
||||||
|
{
|
||||||
|
public osBase? Datos { get; set; }
|
||||||
|
public int zIndex_fromFrames { get; set; }
|
||||||
|
|
||||||
|
public ucTransporteTTopDualInverter()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.Loaded += OnLoaded;
|
||||||
|
this.Unloaded += OnUnloaded;
|
||||||
|
}
|
||||||
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Datos?.ucLoaded();
|
||||||
|
}
|
||||||
|
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Datos?.ucUnLoaded();
|
||||||
|
}
|
||||||
|
public void Highlight(bool State) { }
|
||||||
|
public ZIndexEnum ZIndex_Base()
|
||||||
|
{
|
||||||
|
return ZIndexEnum.Estaticos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,9 @@ namespace CtrEditor.ObjetosSim
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void CargarPropiedadesosDatos(object selectedObject, PropertyGrid propertyGrid)
|
public static void CargarPropiedadesosDatos(osBase selectedObject, PropertyGrid propertyGrid)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Limpia las propiedades previas
|
// Limpia las propiedades previas
|
||||||
propertyGrid.SelectedObject = null;
|
propertyGrid.SelectedObject = null;
|
||||||
propertyGrid.PropertyDefinitions.Clear();
|
propertyGrid.PropertyDefinitions.Clear();
|
||||||
|
|
|
@ -413,7 +413,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
using (var engine = new TesseractEngine(tesseractPath, "eng", EngineMode.Default))
|
using (var engine = new TesseractEngine(tesseractPath, "eng", EngineMode.Default))
|
||||||
{
|
{
|
||||||
// Configuraciones para mejorar el OCR de una sola letra
|
// Configuraciones para mejorar el OCR de una sola letra
|
||||||
engine.SetVariable("tessedit_char_whitelist", " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-."); // Lista blanca de caracteres
|
engine.SetVariable("tessedit_char_whitelist", " ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz0123456789-."); // Lista blanca de caracteres
|
||||||
var result = engine.Process(img);
|
var result = engine.Process(img);
|
||||||
return result.GetText();
|
return result.GetText();
|
||||||
}
|
}
|
||||||
|
@ -519,6 +519,8 @@ namespace CtrEditor.ObjetosSim
|
||||||
UniqueId cloned_from;
|
UniqueId cloned_from;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
|
[JsonIgnore]
|
||||||
|
[property: Hidden]
|
||||||
private bool isSelected;
|
private bool isSelected;
|
||||||
|
|
||||||
private async void TimerCallback(object state)
|
private async void TimerCallback(object state)
|
||||||
|
|
Loading…
Reference in New Issue