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) foreach (var objetoSimulable in ObjetosSimulables)
{
if (_plcViewModelData.IsConnected)
objetoSimulable.UpdatePLC(_plcViewModelData.PLCInterface);
objetoSimulable.UpdateGeometry(); objetoSimulable.UpdateGeometry();
}
simulationManager.Step((float)_timerSimulacion.Interval.TotalMilliseconds); simulationManager.Step((float)_timerSimulacion.Interval.TotalMilliseconds);

View File

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

View File

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

View File

@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using CtrEditor.Convertidores; using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -105,6 +106,9 @@ namespace CtrEditor.ObjetosSim
public override void UpdateControl() 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.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using CtrEditor.Convertidores; using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -126,6 +127,9 @@ namespace CtrEditor.ObjetosSim
public override void UpdateControl() 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.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using CtrEditor.Convertidores; using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -202,6 +203,7 @@ namespace CtrEditor.ObjetosSim
public override void UpdateControl() 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.Numerics;
using System.Windows.Markup; using System.Windows.Markup;
using CtrEditor.Convertidores; using CtrEditor.Convertidores;
using CtrEditor.Siemens;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -124,6 +125,8 @@ namespace CtrEditor.ObjetosSim
// Se llama antes de la simulacion // Se llama antes de la simulacion
} }
public override void UpdatePLC(PLCModel plc) { }
public override void UpdateControl() public override void UpdateControl()
{ {

View File

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

View File

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