2024-05-31 10:06:49 -03:00
|
|
|
|
|
2024-05-23 14:56:14 -03:00
|
|
|
|
using CtrEditor.Siemens;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2024-05-25 07:53:34 -03:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
2024-05-23 14:56:14 -03:00
|
|
|
|
|
2024-05-25 07:53:34 -03:00
|
|
|
|
namespace CtrEditor.ObjetosSim
|
2024-05-23 14:56:14 -03:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for ucBoolTag.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
public partial class osBoolTag : osBase, IosBase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Otros datos y métodos relevantes para la simulación
|
|
|
|
|
|
|
|
|
|
public static string NombreClase()
|
|
|
|
|
{
|
|
|
|
|
return "Bool Tag";
|
|
|
|
|
}
|
|
|
|
|
private string nombre = NombreClase();
|
|
|
|
|
public override string Nombre
|
|
|
|
|
{
|
|
|
|
|
get => nombre;
|
|
|
|
|
set => SetProperty(ref nombre, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
private Brush color_oculto;
|
|
|
|
|
|
2024-05-25 07:53:34 -03:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public bool estado;
|
|
|
|
|
|
2024-05-23 14:56:14 -03:00
|
|
|
|
partial void OnEstadoChanged(bool value)
|
|
|
|
|
{
|
2024-05-25 07:53:34 -03:00
|
|
|
|
EscribirBitTag(Tag, value);
|
2024-05-23 14:56:14 -03:00
|
|
|
|
if (value)
|
|
|
|
|
Color_oculto = Brushes.LightGreen;
|
|
|
|
|
else
|
|
|
|
|
Color_oculto = Brushes.Transparent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public float tamano;
|
|
|
|
|
[ObservableProperty]
|
2024-05-25 07:53:34 -03:00
|
|
|
|
[NotifyPropertyChangedFor(nameof(Estado))]
|
2024-05-23 14:56:14 -03:00
|
|
|
|
public string tag;
|
2024-05-25 07:53:34 -03:00
|
|
|
|
|
2024-05-23 14:56:14 -03:00
|
|
|
|
[ObservableProperty]
|
2024-05-25 07:53:34 -03:00
|
|
|
|
public string descripcion;
|
2024-05-23 14:56:14 -03:00
|
|
|
|
|
|
|
|
|
public osBoolTag()
|
|
|
|
|
{
|
|
|
|
|
Tamano = 0.30f;
|
|
|
|
|
tag = "%M50.0";
|
|
|
|
|
Descripcion = "Nombre del Tag";
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 05:34:20 -03:00
|
|
|
|
public override void UpdatePLCPrimerCiclo()
|
|
|
|
|
{
|
|
|
|
|
// Escribimos el valor actual al iniciar la conexion
|
|
|
|
|
OnEstadoChanged(Estado);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-23 14:56:14 -03:00
|
|
|
|
public override void ucLoaded()
|
|
|
|
|
{
|
|
|
|
|
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
|
|
|
|
// crear el objeto de simulacion
|
|
|
|
|
ActualizarLeftTop();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class ucBoolTag : UserControl, IDataContainer
|
|
|
|
|
{
|
|
|
|
|
public osBase? Datos { get; set; }
|
|
|
|
|
|
|
|
|
|
public ucBoolTag()
|
|
|
|
|
{
|
|
|
|
|
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 Resize(float width, float height) { }
|
|
|
|
|
public void Move(float LeftPixels, float TopPixels)
|
|
|
|
|
{
|
|
|
|
|
if (Datos != null)
|
|
|
|
|
{
|
|
|
|
|
Datos.Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels);
|
|
|
|
|
Datos.Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Rotate(float Angle) { }
|
|
|
|
|
public void Highlight(bool State) { }
|
|
|
|
|
public int ZIndex()
|
|
|
|
|
{
|
|
|
|
|
return 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|