diff --git a/CtrEditor.csproj b/CtrEditor.csproj
index 7b6fce2..6d341c5 100644
--- a/CtrEditor.csproj
+++ b/CtrEditor.csproj
@@ -15,4 +15,10 @@
+
+
+ C:\Program Files (x86)\Common Files\Siemens\PLCSIMADV\API\6.0\Siemens.Simatic.Simulation.Runtime.Api.x64.dll
+
+
+
diff --git a/MainViewModel.cs b/MainViewModel.cs
index 04b6e78..f74c6c3 100644
--- a/MainViewModel.cs
+++ b/MainViewModel.cs
@@ -14,6 +14,7 @@ using System.Windows.Media.Imaging;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Windows.Threading;
using CtrEditor.ObjetosSim;
+using CtrEditor.Siemens;
using System.IO;
// using System.Windows.Forms;
using System.Text.Json.Serialization;
@@ -32,6 +33,7 @@ namespace CtrEditor
public ObservableCollection listaImagenes { get; private set; } // Publicación de las claves del diccionario
public ObservableCollection ListaOsBase { get; } = new ObservableCollection();
private ObservableCollection _objetosSimulables = new ObservableCollection();
+ public PLCViewModel _plcViewModelData;
private SimulationManager simulationManager = new SimulationManager();
@@ -52,6 +54,9 @@ namespace CtrEditor
OpenWorkDirectoryCommand = new RelayCommand(OpenWorkDirectory);
datosDeTrabajo = new DatosDeTrabajo();
+ // Inicializa el PLCViewModel
+ _plcViewModelData = new PLCViewModel();
+
InitializeTipoSimulableList();
ItemDoubleClickCommand = new ParameterizedRelayCommand(ExecuteDoubleClick);
@@ -62,7 +67,6 @@ namespace CtrEditor
StartSimulationCommand = new RelayCommand(StartSimulation);
StopSimulationCommand = new RelayCommand(StopSimulation);
-
}
public void LoadInitialData()
@@ -161,6 +165,17 @@ namespace CtrEditor
}
}
+
+ public PLCViewModel PLCViewModel
+ {
+ get { return _plcViewModelData; }
+ set
+ {
+ _plcViewModelData = value;
+ OnPropertyChanged(nameof(PLCViewModel));
+ }
+ }
+
private string _selectedImage = null;
public string SelectedImage
{
@@ -241,7 +256,8 @@ namespace CtrEditor
var dataToSerialize = new SimulationData
{
ObjetosSimulables = ObjetosSimulables,
- UnitConverter = PixelToMeter.Instance.calc
+ UnitConverter = PixelToMeter.Instance.calc,
+ PLC_ConnectionData = PLCViewModel
};
var serializedData = JsonConvert.SerializeObject(dataToSerialize, settings);
@@ -271,9 +287,14 @@ namespace CtrEditor
var simulationData = JsonConvert.DeserializeObject(jsonString, settings);
if (simulationData != null)
{
- ObjetosSimulables = simulationData.ObjetosSimulables;
+ if (simulationData.ObjetosSimulables is not null)
+ ObjetosSimulables = simulationData.ObjetosSimulables;
+
+ if (simulationData.PLC_ConnectionData is not null)
+ PLCViewModel = simulationData.PLC_ConnectionData;
+ else
+ PLCViewModel = new PLCViewModel();
- // Restaura el UnitConverter si es necesario en otra parte de tu código
PixelToMeter.Instance.calc = simulationData.UnitConverter;
// Recorrer la colección de objetos simulables
@@ -322,6 +343,7 @@ namespace CtrEditor
{
public ObservableCollection ObjetosSimulables { get; set; }
public UnitConverter UnitConverter { get; set; }
+ public PLCViewModel PLC_ConnectionData { get; set; }
}
public class TipoSimulable
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 6de6195..08d20ac 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -1,9 +1,10 @@
-
@@ -33,8 +34,9 @@
-
+
+
@@ -44,6 +46,7 @@
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index affba3d..db1e473 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -10,6 +10,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CtrEditor.ObjetosSim;
+using CtrEditor.Siemens;
using static System.Runtime.InteropServices.JavaScript.JSType;
using Binding = System.Windows.Data.Binding;
using Label = System.Windows.Controls.Label;
diff --git a/ObjetosSim/UserControlFactory.cs b/ObjetosSim/UserControlFactory.cs
index 173e0ed..1738944 100644
--- a/ObjetosSim/UserControlFactory.cs
+++ b/ObjetosSim/UserControlFactory.cs
@@ -18,6 +18,8 @@ namespace CtrEditor.ObjetosSim
return new ucTransporteTTop();
if (tipoObjeto == typeof(osGuia))
return new ucGuia();
+ if (tipoObjeto == typeof(osTransporteGuias))
+ return new ucTransporteGuias();
// Puedes añadir más condiciones para otros tipos
@@ -32,6 +34,8 @@ namespace CtrEditor.ObjetosSim
return new osTransporteTTop();
if (tipoObjeto == typeof(osGuia))
return new osGuia();
+ if (tipoObjeto == typeof(osTransporteGuias))
+ return new osTransporteGuias();
// Puedes añadir más condiciones para otros tipos
diff --git a/ObjetosSim/ucGuia.xaml b/ObjetosSim/ucGuia.xaml
index 65e2867..a6adfff 100644
--- a/ObjetosSim/ucGuia.xaml
+++ b/ObjetosSim/ucGuia.xaml
@@ -11,7 +11,7 @@