using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Siemens.Simatic;
using Siemens.Simatic.Simulation.Runtime;

namespace CtrEditor.Siemens
{
    internal class PLCSim
    {
        SIPSuite4 plcIP;
        
    }
    public class PLCConnector
    {
        // Propiedades
        public IInstance Instance { get; set; }
        private bool IsConfigured { get; set; } = false;
        private SIPSuite4 InstanceIP;

        // Constructor
        public PLCConnector(string instanceName, string pIP4)
        {
            InstanceIP = new SIPSuite4(pIP4, "255.255.255.0", "0.0.0.0");
            Instance = SimulationRuntimeManager.CreateInterface(instanceName);
        }

        // Métodos Públicos
        public void PowerOnPLCInstance()
        {
            Instance.PowerOn(60000);
            Instance.SetIPSuite(0, InstanceIP, true);
        }

        public void PowerOffPLCInstance()
        {
            Instance.PowerOff(6000);
        }

        public void RunPLCInstance()
        {
            Instance.Run(6000);
        }

        public void StopPLCInstance()
        {
            Instance.Stop(6000);
        }
    }
}
