98 lines
2.4 KiB
C#
98 lines
2.4 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
using LibS7Adv;
|
|
using System.ComponentModel;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using CtrEditor.FuncionesBase;
|
|
|
|
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);
|
|
}
|
|
|
|
public osSensTemperatura()
|
|
{
|
|
Ancho = 0.4f;
|
|
Alto = 1f;
|
|
Max_OUT_Scaled = 27648;
|
|
Min_OUT_Scaled = 0;
|
|
}
|
|
|
|
public override void UpdatePLC(PLCViewModel 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
|
|
base.ucLoaded();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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 Highlight(bool State) { }
|
|
public ZIndexEnum ZIndex()
|
|
{
|
|
return ZIndexEnum.Estaticos;
|
|
}
|
|
|
|
}
|
|
}
|