public static string[]                              getPLCList(bool aRomote, string aIP, int aIPPort)
        {
            SInstanceInfo[] lPLC;

            if (aRomote)
            {
                var lConnectionStr = aIP + ":" + aIPPort.ToString();
                try
                {
                    var lRRManager = SimulationRuntimeManager.RemoteConnect(lConnectionStr);
                    lPLC = lRRManager.RegisteredInstanceInfo;
                    lRRManager.Disconnect();
                    lRRManager.Dispose();
                }
                catch (SimulationRuntimeException lExc)
                {
                    throw new InvalidOperationException("Connection '" + lConnectionStr + "'. " + ErrorCodeMessage(lExc.RuntimeErrorCode), lExc);
                }
            }
            else
            {
                try
                {
                    lPLC = SimulationRuntimeManager.RegisteredInstanceInfo;
                }
                catch (SimulationRuntimeException lExc)
                {
                    throw new InvalidOperationException(ErrorCodeMessage(lExc.RuntimeErrorCode), lExc);
                }
            }

            return(lPLC.Select(x => x.Name).ToArray());
        }
        public void                                         connect()
        {
            if (mTagBrowserForm != null)
            {
                mTagBrowserForm.Dispose();
                mTagBrowserForm = null;
            }

            if (mPLC != null)
            {
                mPLC.OnConfigurationChanged  -= onConfigurationChanged;
                mPLC.OnConfigurationChanging -= onConfigurationChanging;
                mPLC.Dispose();
                mPLC = null;
            }

            if (mRRManager != null)
            {
                mRRManager.OnConnectionLost -= onRemoteConnectionLost;
                mRRManager.Disconnect();
                mRRManager.Dispose();
                mRRManager = null;
            }

            if (String.IsNullOrWhiteSpace(mPLCName))
            {
                throw new InvalidOperationException("PLC name is empty. ");
            }

            if (mRemote)
            {
                var lConnectionStr = mIP + ":" + mIPPort.ToString();
                if (String.IsNullOrWhiteSpace(lConnectionStr))
                {
                    throw new InvalidOperationException("Connection string is empty. ");
                }

                try
                {
                    mRRManager = SimulationRuntimeManager.RemoteConnect(lConnectionStr);
                }
                catch (SimulationRuntimeException lExc)
                {
                    throw new InvalidOperationException("Connection '" + lConnectionStr + "'. " + ErrorCodeMessage(lExc.RuntimeErrorCode), lExc);
                }

                try
                {
                    mPLC = mRRManager.CreateInterface(mPLCName);
                }
                catch (SimulationRuntimeException lExc)
                {
                    mRRManager.Dispose();
                    mRRManager = null;

                    throw new InvalidOperationException("PLC instance '" + mPLCName + "'. " + ErrorCodeMessage(lExc.RuntimeErrorCode), lExc);
                }

                mRRManager.OnConnectionLost += onRemoteConnectionLost;
            }
            else
            {
                try
                {
                    mPLC = SimulationRuntimeManager.CreateInterface(mPLCName);
                }
                catch (SimulationRuntimeException lExc)
                {
                    throw new InvalidOperationException("PLC instance '" + mPLCName + "'. " + ErrorCodeMessage(lExc.RuntimeErrorCode), lExc);
                }
            }

            if (mMainCycleTimer == null)
            {
                mMainCycleTimer           = new System.Timers.Timer(MiscUtils.TimeSlice);
                mMainCycleTimer.Elapsed  += new ElapsedEventHandler(MainCycle);
                mMainCycleTimer.AutoReset = false;
            }

            mPLC.UpdateTagList();

            mPLC.OnConfigurationChanged  += onConfigurationChanged;
            mPLC.OnConfigurationChanging += onConfigurationChanging;

            mConnected     = true;
            mDisconnect    = false;
            mReconnect     = false;
            mWriteRequests = 0;
            mMainCycleTimer.Start();
            raiseConnectionState();
        }