using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using SystemX.Net.Platform.Common.Event;
using SystemX.Net.Platform.Common.Util;
using SystemX.PLC.Interface;
using static SystemX.PLC.Interface.PLCCommDefinition;

namespace SystemX.PLC.Interface
{
    public class PLCCommManager
    {
        public PLCAddressManager AddrMgr { get; set; }
        public FunctionEventHandler EventChangeUpdate { get; set; }
        public bool OperationStarted { get; set; } = false;

        public PLCCommManager(string strPLCConnInfoXmlPath)
        {
        }

        public virtual bool OpenPLCConnection()
        {
            return false;
        }
        
        public virtual bool StartPLCOperation()
        {
            return false;
        }
        public virtual void NowScanDataArea()
        {

        }

        public virtual bool StopPLCOperation()
        {
            return false;
        }


        public virtual bool ClosePLCConnection()
        {
            return false;
        }

        public virtual void ReceivePLCEvent(string address, int value)
        {
        }

        public virtual string GetDeviceValue(PLCAddressTemplate tmplt)
        {
            return string.Empty;
        }
        public virtual string ReadDevice(string strDevice, bool bRefineWrongChar = true)
        {
            return string.Empty;
        }
        public virtual string ReadDevice(PLCAddressTemplate tmplt)
        {
            return string.Empty;
        }
        public virtual string ReadDevice(PLCAddressTemplate tmplt, bool bAsciiReverse = false)
        {
            return string.Empty;
        }
        public virtual void UpdateAll(bool bRefineWrongChar)
        {
        }
        public virtual void SelectUpdate(ePLCAreaType pat, PLCAddressTemplate tmplt, bool bRefineWrongChar)
        {
        }

        public virtual bool WriteDevice(PLCAddressTemplate tmplt, string strValue, bool bVerification = false)
        {
            return false;
        }       
        
    }
}
