Antes de Implementar FarseerPhysics

This commit is contained in:
Miguel 2024-05-11 20:55:44 +02:00
parent 81450e56aa
commit 2bfd83ef3b
9 changed files with 40 additions and 11 deletions

View File

@ -135,7 +135,11 @@ namespace CtrEditor
{
foreach (var objetoSimulable in ObjetosSimulables)
{
if (_plcViewModelData.IsConnected)
objetoSimulable.UpdatePLC(_plcViewModelData.PLCInterface);
objetoSimulable.UpdateGeometry();
}
simulationManager.Step((float)_timerSimulacion.Interval.TotalMilliseconds);

View File

@ -12,6 +12,7 @@ using System.Windows.Controls;
using System.Windows.Data;
using static System.Runtime.InteropServices.JavaScript.JSType;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim
{
@ -50,6 +51,7 @@ namespace CtrEditor.ObjetosSim
public abstract void ConnectSimManager(SimulationManager simulationManager);
public abstract void UpdateControl();
public abstract void UpdateGeometry();
public abstract void UpdatePLC(PLCModel plc);
[JsonIgnore]
public UserControl? VisualRepresentation

View File

@ -14,6 +14,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Numerics;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim
{
@ -106,6 +107,7 @@ namespace CtrEditor.ObjetosSim
// Se llama antes de la simulacion
}
public override void UpdatePLC(PLCModel plc) { }
public override void UpdateControl()
{

View File

@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim
{
@ -105,6 +106,9 @@ namespace CtrEditor.ObjetosSim
public override void UpdateControl()
{
}
public override void UpdatePLC(PLCModel plc) { }
}

View File

@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim
{
@ -126,6 +127,9 @@ namespace CtrEditor.ObjetosSim
public override void UpdateControl()
{
}
public override void UpdatePLC(PLCModel plc) { }
}

View File

@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim
{
@ -202,6 +203,7 @@ namespace CtrEditor.ObjetosSim
public override void UpdateControl()
{
}
public override void UpdatePLC(PLCModel plc) { }
}

View File

@ -16,6 +16,7 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Numerics;
using System.Windows.Markup;
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim
{
@ -124,6 +125,8 @@ namespace CtrEditor.ObjetosSim
// Se llama antes de la simulacion
}
public override void UpdatePLC(PLCModel plc) { }
public override void UpdateControl()
{

View File

@ -1,4 +1,5 @@
using CtrEditor.Convertidores;
using CtrEditor.Siemens;
using System;
using System.Collections.Generic;
using System.Linq;
@ -89,6 +90,7 @@ namespace CtrEditor.ObjetosSim
public osVMmotorSim()
{
Tamano = 0.30f;
PLC_NumeroMotor = 31;
}
public override void ConnectSimManager(SimulationManager simulationManager)
@ -99,9 +101,11 @@ namespace CtrEditor.ObjetosSim
// Se llama antes de la simulacion
}
public override void UpdatePLC(PLCModel plc) { }
public override void UpdateControl()
{
}
}

View File

@ -25,19 +25,21 @@ namespace CtrEditor.Siemens
/// </summary>
public class PLCViewModel : INotifyPropertyChanged
{
private readonly PLCModel _plcModel;
public readonly PLCModel PLCInterface;
private readonly DispatcherTimer _timer;
private string _cpuTime;
private string _connectionStatus = "offline";
private string _ip = "10.1.30.11";
private string _name = "PLC";
private string lastError;
public bool IsConnected { get; private set; }
public event PropertyChangedEventHandler PropertyChanged;
public PLCViewModel()
{
_plcModel = new PLCModel();
IsConnected = false;
PLCInterface = new PLCModel();
_timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) };
_timer.Tick += (s, e) => Refresh();
@ -101,38 +103,40 @@ namespace CtrEditor.Siemens
private void Connect()
{
// Implementa la conexión utilizando PLCModel
_plcModel.Instance = SimulationRuntimeManager.CreateInterface(Name);
_plcModel.Instance.OnSoftwareConfigurationChanged += Instance_OnSoftwareConfigurationChanged;
PLCInterface.Instance = SimulationRuntimeManager.CreateInterface(Name);
PLCInterface.Instance.OnSoftwareConfigurationChanged += Instance_OnSoftwareConfigurationChanged;
//_plcModel.Instance.CommunicationInterface = ECommunicationInterface.Softbus;
if (_plcModel.Instance != null)
if (PLCInterface.Instance != null)
{
_plcModel.UpdateTagList();
PLCInterface.UpdateTagList();
_timer.Start();
ConnectionStatus = "connected";
IsConnected = true;
}
}
private void Instance_OnSoftwareConfigurationChanged(IInstance instance, SOnSoftwareConfigChangedParameter event_param)
{
_plcModel.UpdateTagList();
PLCInterface.UpdateTagList();
}
private void Disconnect()
{
IsConnected = false;
_timer.Stop();
ConnectionStatus = "offline";
_plcModel.Instance = null;
PLCInterface.Instance = null;
}
private void Refresh()
{
if (_plcModel.Instance != null)
if (PLCInterface.Instance != null)
{
CpuTime = _plcModel.LeerInt16("\"DB HMI\".CPU_Scan_Time")?.ToString() ?? "N/A";
LastError = _plcModel.LastError;
CpuTime = PLCInterface.LeerInt16("\"DB HMI\".CPU_Scan_Time")?.ToString() ?? "N/A";
LastError = PLCInterface.LastError;
}
}