123 lines
3.3 KiB
C#
123 lines
3.3 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
using CtrEditor.Siemens;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace CtrEditor.ObjetosSim
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for ucSensTemperatura.xaml
|
|
/// </summary>
|
|
public partial class osSensTemperatura : osBase, IosBase
|
|
{
|
|
// Otros datos y métodos relevantes para la simulación
|
|
|
|
public static string NombreClase()
|
|
{
|
|
return "Temperatura";
|
|
}
|
|
private string nombre = NombreClase();
|
|
public override string 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;
|
|
|
|
partial void OnValueChanged(float value)
|
|
{
|
|
EscribirWordTagScaled(Tag, value, 0, 100, Min_OUT_Scaled, Max_OUT_Scaled);
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public float ancho;
|
|
[ObservableProperty]
|
|
public float alto;
|
|
[ObservableProperty]
|
|
public float angulo;
|
|
|
|
public osSensTemperatura()
|
|
{
|
|
Ancho = 0.4f;
|
|
Alto = 1f;
|
|
Max_OUT_Scaled = 27648;
|
|
Min_OUT_Scaled = 0;
|
|
}
|
|
|
|
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
|
|
{
|
|
|
|
}
|
|
public override void UpdatePLCPrimerCiclo()
|
|
{
|
|
// Escribimos el valor actual al iniciar la conexion
|
|
OnValueChanged(Value);
|
|
}
|
|
|
|
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 ucSensTemperatura : UserControl, IDataContainer
|
|
{
|
|
public osBase? Datos { get; set; }
|
|
|
|
public ucSensTemperatura()
|
|
{
|
|
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)
|
|
{
|
|
if (Datos is osSensTemperatura datos)
|
|
{
|
|
datos.Ancho = PixelToMeter.Instance.calc.PixelsToMeters(width);
|
|
datos.Alto = PixelToMeter.Instance.calc.PixelsToMeters(width);
|
|
}
|
|
}
|
|
public void Move(float LeftPixels, float TopPixels)
|
|
{
|
|
if (Datos != null)
|
|
{
|
|
Datos.Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels);
|
|
Datos.Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
|
|
}
|
|
}
|
|
public void Rotate(float Angle)
|
|
{
|
|
if (Datos != null)
|
|
if (Datos is osSensTemperatura datos)
|
|
datos.Angulo = Angle;
|
|
}
|
|
public void Highlight(bool State) { }
|
|
public int ZIndex()
|
|
{
|
|
return 10;
|
|
}
|
|
}
|
|
}
|