Agregada la funcion de crear el archivo base.png si no hay imagenes en el directorio elegido

This commit is contained in:
Miguel 2024-09-12 16:43:39 +02:00
parent 261fe679d8
commit 353b4b99e6
12 changed files with 173 additions and 94 deletions

View File

@ -130,7 +130,7 @@
<Resource Include="imagenes\motorNegro.png" /> <Resource Include="imagenes\motorNegro.png" />
<Resource Include="imagenes\motorVerde.png" /> <Resource Include="imagenes\motorVerde.png" />
<Resource Include="imagenes\tank.png" /> <Resource Include="imagenes\tank.png" />
<Resource Include="Images\base.png" /> <EmbeddedResource Include="Images\base.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,10 +1,4 @@
using System; namespace CtrEditor.FuncionesBase
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CtrEditor.FuncionesBase
{ {
public enum ZIndexEnum public enum ZIndexEnum
{ {

View File

@ -119,6 +119,15 @@ namespace CtrEditor
EstadoPersistente.Instance.GuardarEstado(); // Guardar el estado actualizado EstadoPersistente.Instance.GuardarEstado(); // Guardar el estado actualizado
DatosDeTrabajo.CargarImagenes(); DatosDeTrabajo.CargarImagenes();
ListaImagenes = new ObservableCollection<string>(DatosDeTrabajo.Imagenes.Keys); // Actualizar claves ListaImagenes = new ObservableCollection<string>(DatosDeTrabajo.Imagenes.Keys); // Actualizar claves
// Si no hay imágenes en el directorio, copiar base.png desde los recursos
if (!ListaImagenes.Any())
{
CopiarImagenBase(value);
// Recargar las imágenes después de copiar la imagen base
DatosDeTrabajo.CargarImagenes();
ListaImagenes = new ObservableCollection<string>(DatosDeTrabajo.Imagenes.Keys); // Actualizar claves nuevamente
}
SelectedImage = null; SelectedImage = null;
var x = ListaImagenes.FirstOrDefault(o => o == EstadoPersistente.Instance.imagen, null); var x = ListaImagenes.FirstOrDefault(o => o == EstadoPersistente.Instance.imagen, null);
if (EstadoPersistente.Instance.imagen != null && EstadoPersistente.Instance.imagen.Length > 0 && x != null) if (EstadoPersistente.Instance.imagen != null && EstadoPersistente.Instance.imagen.Length > 0 && x != null)
@ -132,6 +141,34 @@ namespace CtrEditor
} }
} }
// Función para copiar la imagen base desde los recursos
private void CopiarImagenBase(string directorio)
{
try
{
// Obtener el path del archivo base.png desde los recursos (dentro del ensamblado)
var assembly = Assembly.GetExecutingAssembly();
var resourcePath = "CtrEditor.Images.base.png"; // Ajusta el namespace y el path según tu proyecto
using (Stream resourceStream = assembly.GetManifestResourceStream(resourcePath))
{
if (resourceStream != null)
{
string destino = Path.Combine(directorio, "base.png");
using (FileStream fileStream = new FileStream(destino, FileMode.Create, FileAccess.Write))
{
resourceStream.CopyTo(fileStream);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show($"Error al copiar la imagen base: {ex.Message}");
}
}
[RelayCommand] [RelayCommand]
public void DebugWindow() public void DebugWindow()
{ {
@ -209,7 +246,7 @@ namespace CtrEditor
PLCViewModel = new PLCViewModel(); PLCViewModel = new PLCViewModel();
_timerPLCUpdate = new DispatcherTimer(); _timerPLCUpdate = new DispatcherTimer();
_timerPLCUpdate.Interval = TimeSpan.FromMilliseconds(100); // ajusta el intervalo según sea necesario _timerPLCUpdate.Interval = TimeSpan.FromMilliseconds(2); // ajusta el intervalo según sea necesario
_timerPLCUpdate.Tick += OnRefreshEvent; _timerPLCUpdate.Tick += OnRefreshEvent;
InitializeTipoSimulableList(); InitializeTipoSimulableList();

View File

@ -60,12 +60,7 @@ namespace CtrEditor.ObjetosSim
private float inercia_desde_simulacion; private float inercia_desde_simulacion;
[ObservableProperty] [ObservableProperty]
bool test; private bool preserve_Outside_Transport;
partial void OnTestChanged(bool value)
{
SimGeometria.Body.LinearVelocity = new Vector2(1,1);
}
[ObservableProperty] [ObservableProperty]
private float porcentaje_Traccion; private float porcentaje_Traccion;
@ -93,9 +88,8 @@ namespace CtrEditor.ObjetosSim
private void ActualizarGeometrias() private void ActualizarGeometrias()
{ {
if (SimGeometria != null) if (SimGeometria != null && !RemoverDesdeSimulacion)
{ {
SimGeometria.SetPosition(GetCentro()); SimGeometria.SetPosition(GetCentro());
} }
} }
@ -108,10 +102,13 @@ namespace CtrEditor.ObjetosSim
} }
public void UpdateAfterMove() public void UpdateAfterMove()
{
if (!RemoverDesdeSimulacion)
{ {
ActualizarGeometrias(); ActualizarGeometrias();
SimGeometria?.SetDiameter(Diametro); SimGeometria?.SetDiameter(Diametro);
} }
}
public override void UpdateGeometryStart() public override void UpdateGeometryStart()
{ {
@ -126,6 +123,7 @@ namespace CtrEditor.ObjetosSim
} }
public override void UpdateControl(int elapsedMilliseconds) public override void UpdateControl(int elapsedMilliseconds)
{ {
SetCentro(SimGeometria.Center); SetCentro(SimGeometria.Center);
if (SimGeometria.isRestricted) if (SimGeometria.isRestricted)
ColorButton_oculto = Brushes.Yellow; ColorButton_oculto = Brushes.Yellow;
@ -136,8 +134,15 @@ namespace CtrEditor.ObjetosSim
else else
ColorButton_oculto = Brushes.Gray; ColorButton_oculto = Brushes.Gray;
} }
if (SimGeometria.Descartar) // Ha sido marcada para remover
// Ha sido marcada para remover
if (SimGeometria.Descartar)
RemoverDesdeSimulacion = true; RemoverDesdeSimulacion = true;
// Eliminar la botella si esta fuera de un transporte
if (!Preserve_Outside_Transport && Porcentaje_Traccion == 0 && Math.Abs(SimGeometria.Body.LinearVelocity.X) <= 0.001 && Math.Abs(SimGeometria.Body.LinearVelocity.Y) <= 0.001)
RemoverDesdeSimulacion = true;
Velocidad_desde_simulacion = SimGeometria.Body.LinearVelocity.ToString(); Velocidad_desde_simulacion = SimGeometria.Body.LinearVelocity.ToString();
Inercia_desde_simulacion = SimGeometria.Body.Inertia; Inercia_desde_simulacion = SimGeometria.Body.Inertia;
Porcentaje_Traccion = SimGeometria.OverlapPercentage; Porcentaje_Traccion = SimGeometria.OverlapPercentage;

View File

@ -4,6 +4,7 @@ using System.Windows.Controls;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
using System.ComponentModel;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -34,9 +35,15 @@ namespace CtrEditor.ObjetosSim
[ObservableProperty] [ObservableProperty]
private float offsetTopSalida; private float offsetTopSalida;
[ObservableProperty] [ObservableProperty]
[property: Description("PLC tag for consense to run. 1 => always")]
[property: Category("Enable to Run:")]
private string tag_consenso; private string tag_consenso;
[ObservableProperty] [ObservableProperty]
[property: Description("Consense to run.")]
[property: Category("Enable to Run:")]
private bool consenso; private bool consenso;
partial void OnConsensoChanged(bool value) partial void OnConsensoChanged(bool value)
@ -44,11 +51,25 @@ namespace CtrEditor.ObjetosSim
_TON_TOFF.Senal = value; _TON_TOFF.Senal = value;
} }
[ObservableProperty] [ObservableProperty]
[property: Description("Consense is Normally close.")]
[property: Category("Enable to Run:")]
private bool consenso_NC; private bool consenso_NC;
[ObservableProperty] [ObservableProperty]
[property: Description("Enable filter.")]
[property: Category("Enable to Run:")]
private bool consenso_Filtrado; private bool consenso_Filtrado;
[ObservableProperty] [ObservableProperty]
float filtro_consenso_s; [property: Description("Time ON in s.")]
[property: Category("Enable to Run:")]
float filtro_consenso_ON_s;
[ObservableProperty]
[property: Description("Time OFF in s.")]
[property: Category("Enable to Run:")]
float filtro_consenso_OFF_s;
[ObservableProperty]
[property: Description("Filter OUT signal.")]
[property: Category("Enable to Run:")]
bool filter_Output;
[ObservableProperty] [ObservableProperty]
private float botellas_hora; private float botellas_hora;
@ -77,10 +98,11 @@ namespace CtrEditor.ObjetosSim
Ancho = 0.30f; Ancho = 0.30f;
Alto = 0.30f; Alto = 0.30f;
Angulo = 0; Angulo = 0;
Velocidad_actual_percentual = 0; Velocidad_actual_percentual = 100;
Diametro_botella = 0.1f; Diametro_botella = 0.1f;
Botellas_hora = 10000; Botellas_hora = 10000;
Filtro_consenso_s = 1; Filtro_consenso_ON_s = 1;
Filtro_consenso_OFF_s = 0.1f;
} }
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds) public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
@ -95,20 +117,22 @@ namespace CtrEditor.ObjetosSim
{ {
bool habilitado; bool habilitado;
_TON_TOFF.Tiempo_ON_s = _TON_TOFF.Tiempo_OFF_s = Filtro_consenso_s; _TON_TOFF.Tiempo_ON_s = Filtro_consenso_ON_s;
_TON_TOFF.Tiempo_OFF_s = Filtro_consenso_OFF_s;
if (Consenso_Filtrado) if (Consenso_Filtrado)
habilitado = _TON_TOFF.SenalFiltrada(); habilitado = _TON_TOFF.SenalFiltrada();
else else
habilitado = Consenso; habilitado = Consenso;
Filter_Output = habilitado;
if (habilitado && Velocidad_actual_percentual > 0) if (habilitado && Velocidad_actual_percentual > 0)
{ {
TiempoRestante -= elapsedMilliseconds / 1000.0f; TiempoRestante -= elapsedMilliseconds / 1000.0f;
if (TiempoRestante <= 0) if (TiempoRestante <= 0)
{ {
TiempoRestante += 3600 / (Botellas_hora * (Velocidad_actual_percentual / 100.0f)); bool BotellaCreada = false;
var X = Left + OffsetLeftSalida; var X = Left + OffsetLeftSalida;
var Y = Top + OffsetTopSalida; var Y = Top + OffsetTopSalida;
@ -122,21 +146,26 @@ namespace CtrEditor.ObjetosSim
((osBotella)nuevaBotella).Diametro = Diametro_botella; ((osBotella)nuevaBotella).Diametro = Diametro_botella;
nuevaBotella.AutoCreated = true; nuevaBotella.AutoCreated = true;
UltimaBotella = (osBotella)nuevaBotella; UltimaBotella = (osBotella)nuevaBotella;
BotellaCreada = true;
} }
else else
{ {
// Calcular la distancia entre el centro de la última botella y la nueva posición // Calcular la distancia entre el centro de la última botella y la nueva posición
float distancia = (float)Math.Sqrt(Math.Pow(UltimaBotella.Left - X, 2) + Math.Pow(UltimaBotella.Top - Y, 2)); float distancia = (float)Math.Sqrt(Math.Pow(UltimaBotella.Left - X, 2) + Math.Pow(UltimaBotella.Top - Y, 2));
float distanciaMinima = Diametro_botella / 2; // Asumiendo que el diámetro de la nueva botella es similar float distanciaMinima = Diametro_botella / 4; // Asumiendo que el diámetro de la nueva botella es similar
if (distancia > distanciaMinima) if (distancia > distanciaMinima)
{ {
var nuevaBotella = _mainViewModel.CrearObjetoSimulable(typeof(osBotella), X, Y); osBotella nuevaBotella = (osBotella)_mainViewModel.CrearObjetoSimulable(typeof(osBotella), X, Y);
((osBotella)nuevaBotella).Diametro = Diametro_botella; nuevaBotella.Diametro = Diametro_botella;
nuevaBotella.AutoCreated = true; nuevaBotella.AutoCreated = true;
UltimaBotella = (osBotella)nuevaBotella; UltimaBotella = nuevaBotella;
BotellaCreada = true;
} }
} }
if (BotellaCreada)
TiempoRestante += 3600 / (Botellas_hora * (Velocidad_actual_percentual / 100.0f));
} }
} }
else else

View File

@ -131,10 +131,10 @@ namespace CtrEditor.ObjetosSim
if (distancia > distanciaMinima) if (distancia > distanciaMinima)
{ {
var nuevaBotella = _mainViewModel.CrearObjetoSimulable(typeof(osBotella), X, Y); osBotella nuevaBotella = (osBotella)_mainViewModel.CrearObjetoSimulable(typeof(osBotella), X, Y);
((osBotella)nuevaBotella).Diametro = Diametro_botella; nuevaBotella.Diametro = Diametro_botella;
nuevaBotella.AutoCreated = true; nuevaBotella.AutoCreated = true;
UltimaBotella = (osBotella)nuevaBotella; UltimaBotella = nuevaBotella;
} }
} }
} }

View File

@ -1,11 +1,11 @@
 
using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.FuncionesBase;
using LibS7Adv; using LibS7Adv;
using Newtonsoft.Json;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using Newtonsoft.Json;
using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.FuncionesBase;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -45,7 +45,7 @@ namespace CtrEditor.ObjetosSim
} }
[ObservableProperty] [ObservableProperty]
public float proporcionalSpeed; public float proporcional_Speed;
[ObservableProperty] [ObservableProperty]
public float max_Speed_for_Ramp; public float max_Speed_for_Ramp;
@ -98,7 +98,7 @@ namespace CtrEditor.ObjetosSim
{ {
Tamano = 0.30f; Tamano = 0.30f;
PLC_NumeroMotor = 31; PLC_NumeroMotor = 31;
ProporcionalSpeed = 100; Proporcional_Speed = 100;
Max_Speed_for_Ramp = 100; Max_Speed_for_Ramp = 100;
TiempoRampa = 3; TiempoRampa = 3;
ImageSource_oculta = ImageFromPath("/imagenes/motor2.png"); ImageSource_oculta = ImageFromPath("/imagenes/motor2.png");
@ -112,7 +112,7 @@ namespace CtrEditor.ObjetosSim
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds) public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
{ {
motState.UpdatePLC(plc, this, elapsedMilliseconds); motState.UpdatePLC(plc, this, elapsedMilliseconds);
Velocidad = (ProporcionalSpeed / 100) * (motState.STATUS_VFD_ACT_Speed_Hz / 10); Velocidad = (Proporcional_Speed / 100) * (motState.STATUS_VFD_ACT_Speed_Hz / 10);
} }
public override void UpdateControl(int elapsedMilliseconds) public override void UpdateControl(int elapsedMilliseconds)

View File

@ -2,16 +2,12 @@
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Simulacion;
using System.IO; using System.IO;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Tesseract;
using Emgu.CV.CvEnum; using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV; using Emgu.CV;
using System.Drawing; using System.Drawing;
using Image = System.Windows.Controls.Image; using Image = System.Windows.Controls.Image;
using Point = System.Drawing.Point;
using Rectangle = System.Windows.Shapes.Rectangle; using Rectangle = System.Windows.Shapes.Rectangle;
using Size = System.Drawing.Size; using Size = System.Drawing.Size;
using Ookii.Dialogs.Wpf; using Ookii.Dialogs.Wpf;
@ -21,9 +17,7 @@ using Newtonsoft.Json;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using System.ComponentModel; using System.ComponentModel;
using ClosedXML.Excel; using ClosedXML.Excel;
using DocumentFormat.OpenXml.Spreadsheet;
using Colors = System.Windows.Media.Colors; using Colors = System.Windows.Media.Colors;
using DocumentFormat.OpenXml.Drawing.Charts;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
namespace CtrEditor.ObjetosSim.Extraccion_Datos namespace CtrEditor.ObjetosSim.Extraccion_Datos

View File

@ -1,13 +1,10 @@
using System.Windows; using ClosedXML.Excel;
using System.Windows.Controls;
using System.Windows.Navigation;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.Simulacion;
using Newtonsoft.Json;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using System.ComponentModel;
using ClosedXML.Excel;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
namespace CtrEditor.ObjetosSim.Extraccion_Datos namespace CtrEditor.ObjetosSim.Extraccion_Datos
{ {
@ -76,7 +73,8 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos
ResetTimer(); ResetTimer();
} }
public override void OnTimerAfterMovement() { public override void OnTimerAfterMovement()
{
Angulo = (float)Math.Round(Angulo / 90) * 90; Angulo = (float)Math.Round(Angulo / 90) * 90;
if (Extraer) if (Extraer)

View File

@ -39,7 +39,7 @@
VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2,2,2,2" Grid.Column="1"/> VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2,2,2,2" Grid.Column="1"/>
<Rectangle x:Name="Photocell" Grid.Column="2" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}, ConverterParameter=0.9}" <Rectangle x:Name="Photocell" Grid.Column="2" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}, ConverterParameter=0.9}"
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"> Height="{Binding Ancho_Haz_De_Luz, Converter={StaticResource MeterToPixelConverter}}">
<Rectangle.Fill> <Rectangle.Fill>
<VisualBrush x:Name="MovingPattern" TileMode="Tile" Viewport="0,0,3,3" ViewportUnits="Absolute" Viewbox="0,0,3,3" ViewboxUnits="Absolute"> <VisualBrush x:Name="MovingPattern" TileMode="Tile" Viewport="0,0,3,3" ViewportUnits="Absolute" Viewbox="0,0,3,3" ViewboxUnits="Absolute">
<VisualBrush.Visual> <VisualBrush.Visual>

View File

@ -7,7 +7,9 @@ using System.Windows.Media;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using JsonIgnoreAttribute = Newtonsoft.Json.JsonIgnoreAttribute;
using System.ComponentModel;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -33,8 +35,13 @@ namespace CtrEditor.ObjetosSim
} }
[ObservableProperty] [ObservableProperty]
[property: Description("Color")]
[property: Category("Layout:")]
Brush color; Brush color;
[ObservableProperty] [ObservableProperty]
[property: Description("Light cut")]
[property: Category("Debug:")]
bool luzCortada; bool luzCortada;
partial void OnLuzCortadaChanged(bool value) partial void OnLuzCortadaChanged(bool value)
@ -67,9 +74,18 @@ namespace CtrEditor.ObjetosSim
} }
[ObservableProperty] [ObservableProperty]
[property: Description("Size of the Light.")]
[property: Category("Setup:")]
float ancho_Haz_De_Luz;
[ObservableProperty]
[property: Description("Distance to the neck.")]
[property: Category("Debug:")]
float distancia_cuello; float distancia_cuello;
[ObservableProperty] [ObservableProperty]
[property: Description("Type of detection: Neck of the bottle or Complete bottle.")]
[property: Category("Setup:")]
bool detectarCuello; bool detectarCuello;
partial void OnDetectarCuelloChanged(bool value) partial void OnDetectarCuelloChanged(bool value)
@ -81,6 +97,8 @@ namespace CtrEditor.ObjetosSim
[ObservableProperty] [ObservableProperty]
[property: Description("Filter signal.")]
[property: Category("Setup:")]
float filter_Frecuency; float filter_Frecuency;
partial void OnFilter_FrecuencyChanged(float value) partial void OnFilter_FrecuencyChanged(float value)
@ -90,18 +108,24 @@ namespace CtrEditor.ObjetosSim
} }
[ObservableProperty] [ObservableProperty]
[property: Category("Debug:")]
float frecuency; float frecuency;
[ObservableProperty] [ObservableProperty]
[property: Category("Debug:")]
float lenght_positive_pulse; float lenght_positive_pulse;
[ObservableProperty] [ObservableProperty]
[property: Category("Debug:")]
float lenght_negative_pulse; float lenght_negative_pulse;
[ObservableProperty] [ObservableProperty]
[property: Category("Debug:")]
float lenght_FP_to_FP; float lenght_FP_to_FP;
[ObservableProperty] [ObservableProperty]
[property: Description("Type Filter signal.")]
[property: Category("Setup:")]
public bool tipo_NC; public bool tipo_NC;
partial void OnTipo_NCChanged(bool value) partial void OnTipo_NCChanged(bool value)
@ -142,13 +166,14 @@ namespace CtrEditor.ObjetosSim
private void ActualizarGeometrias() private void ActualizarGeometrias()
{ {
if (_visualRepresentation is ucPhotocell uc) if (_visualRepresentation is ucPhotocell uc)
UpdateRectangle(Simulation_Photocell, uc.Photocell, Alto, Ancho, Angulo); UpdateRectangle(Simulation_Photocell, uc.Photocell, Ancho_Haz_De_Luz, Ancho, Angulo);
} }
public osPhotocell() public osPhotocell()
{ {
Ancho = 1; Ancho = 1;
Alto = 0.03f; Alto = 0.03f;
Ancho_Haz_De_Luz = 0.01f;
Frecuency = 0; Frecuency = 0;
timer = new Stopwatch(); timer = new Stopwatch();
timer.Start(); timer.Start();

View File

@ -1,29 +1,22 @@
 using CommunityToolkit.Mvvm.ComponentModel;
using System.Text.Json.Serialization; using CtrEditor.FuncionesBase;
using System.Windows;
using LibS7Adv;
using CtrEditor.Simulacion; using CtrEditor.Simulacion;
using System.Windows.Media; using LibS7Adv;
using nkast.Aether.Physics2D.Common; using nkast.Aether.Physics2D.Common;
using Siemens.Simatic.Simulation.Runtime; using Siemens.Simatic.Simulation.Runtime;
using System.Windows.Media.Imaging;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Windows.Media.Animation;
using System.Diagnostics;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.ComponentModel; using System.ComponentModel;
using System.Configuration; using System.Diagnostics;
using System.Windows.Threading;
using System.IO; using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Tesseract; using Tesseract;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using Newtonsoft.Json;
using JsonIgnoreAttribute = Newtonsoft.Json.JsonIgnoreAttribute;
using System.Collections.ObjectModel;
using ItemCollection = Xceed.Wpf.Toolkit.PropertyGrid.Attributes.ItemCollection; using ItemCollection = Xceed.Wpf.Toolkit.PropertyGrid.Attributes.ItemCollection;
using nkast.Aether.Physics2D.Dynamics.Joints; using JsonIgnoreAttribute = Newtonsoft.Json.JsonIgnoreAttribute;
using CtrEditor.FuncionesBase;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -1068,12 +1061,12 @@ namespace CtrEditor.ObjetosSim
if (value) if (value)
{ {
ReiniciarTimer(_stopwatch_ON); ReiniciarTimer(_stopwatch_ON);
_stopwatch_OFF.Reset(); StopTimer(_stopwatch_OFF);
} }
else else
{ {
_stopwatch_ON.Reset();
ReiniciarTimer(_stopwatch_OFF); ReiniciarTimer(_stopwatch_OFF);
StopTimer(_stopwatch_ON);
} }
} }
} }
@ -1097,9 +1090,13 @@ namespace CtrEditor.ObjetosSim
void ReiniciarTimer(Stopwatch timer) void ReiniciarTimer(Stopwatch timer)
{ {
timer.Reset();
timer.Start(); timer.Start();
} }
void StopTimer(Stopwatch timer)
{
timer.Reset();
timer.Stop();
}
} }