コード例 #1
0
ファイル: Form1.cs プロジェクト: locodarwin/Pharaoh
 private void butLogout_Click(object sender, EventArgs e)
 {
     if (Globals.iInUniv == false)
     {
         Status("Not in universe. Aborted.");
         return;
     }
     _instance.Dispose();
     Status("Logged out.");
     toolLoggedIn.BackColor = System.Drawing.Color.Green;
     toolLoggedIn.Text      = "Logged Out";
     butLogin.Enabled       = true;
     butConfig.Enabled      = true;
     butLogout.Enabled      = false;
     Globals.iInUniv        = false;
     Globals.iInWorld       = false;
 }
コード例 #2
0
        private void butLogOut_Click(object sender, EventArgs e)
        {
            // Check for login state
            if (Globals.iInUniv == false)
            {
                Stat(1, "Error", "Not in universe. Aborted.", "red");
                return;
            }

            // Turn off & kill timer (if it's on)
            aTimer.Stop();

            // Turn off & kill Cadence (if running)
            if (Globals.iCadenceOn == true)
            {
                aCadence.Stop();
                //aCadence.Change(Timeout.Infinite, Timeout.Infinite);
                Stat(1, "Cadence", "Cadence turned off", "black");
                Globals.iCadenceOn = false;
            }


            // Dispose of the API instance, reset all flags
            m_bot.HudClear(0);
            m_bot.Dispose();
            Utility.Wait(0);
            Stat(1, "Logout", "Logged out.", "black");
            Globals.iInUniv  = false;
            Globals.iInWorld = false;
            Globals.iSimRun  = false;

            // Disable all buttons except universe login
            butLoginUniv.Enabled   = true;
            butLoginWorld.Enabled  = false;
            butLogOut.Enabled      = false;
            butMove2Coords.Enabled = false;
            butSendChat.Enabled    = false;
            butSimConfig.Enabled   = false;
            butSimStart.Enabled    = false;
            butSimStatus.Enabled   = false;
            butSimStop.Enabled     = false;
        }
コード例 #3
0
        private void butLogOut_Click(object sender, RoutedEventArgs e)
        {
            if (Globals.iInUniv == false)
            {
                Status("Not in universe. Aborted.");
                return;
            }

            _instance.Dispose();
            Status("Logged out.");
            toolStatus.Background = Brushes.Salmon;
            toolStatus.Content    = "Logged Out";
            butLogIn.IsEnabled    = true;
            butConfig.IsEnabled   = true;
            butLogOut.IsEnabled   = false;
            butChange.IsEnabled   = false;
            butMoveTo.IsEnabled   = false;

            Globals.iInUniv  = false;
            Globals.iInWorld = false;
        }
コード例 #4
0
 public virtual void Dispose()
 {
     _timer.Dispose();
     DisconnectBots();
     _instance.Dispose();
 }
コード例 #5
0
ファイル: Form1.cs プロジェクト: locodarwin/Pharaoh
        private void m_LoginDoWork(object sender, DoWorkEventArgs e)
        {
            // Check universe login state and abort if we're already logged in
            if (Globals.iInUniv == true)
            {
                m_Login.ReportProgress(0, "Already logged into universe!");
                return;
            }

            // Initalize the AW API?
            m_Login.ReportProgress(0, "Initializing the API instance.");
            _instance = new Instance();

            // Install events & callbacks
            m_Login.ReportProgress(0, "Installing events and callbacks.");
            //_instance.EventAvatarAdd += OnEventAvatarAdd;
            _instance.EventChat += OnEventChat;

            // Set universe login parameters
            _instance.Attributes.LoginName              = Globals.sBotName;
            _instance.Attributes.LoginOwner             = Globals.iCitNum;
            _instance.Attributes.LoginPrivilegePassword = Globals.sPassword;
            //_instance.Attributes.LoginApplication = Globals.sBotDesc;

            // Log into universe
            //m_Login.ReportProgress(0, "Entering universe.");
            var rc = _instance.Login();

            if (rc != Result.Success)
            {
                m_Login.ReportProgress(0, "Unable to log in to universe (reason:" + rc + ").");
                return;
            }
            else
            {
                m_Login.ReportProgress(0, "Universe entry successful.");
                Globals.iInUniv = true;
            }

            // Enter world

            // Prepare for Caretaker mode if the option has been enabled
            if (Globals.iCaretaker == true)
            {
                _instance.Attributes.EnterGlobal = true;
                m_Login.ReportProgress(0, "Caretaker mode requested.");
            }

            //m_Login.ReportProgress(0, "Logging into world " + Globals.sWorld + ".");
            rc = _instance.Enter(Globals.sWorld);
            if (rc != Result.Success)
            {
                m_Login.ReportProgress(0, "Failed to log into world" + Globals.sWorld + " (reason:" + rc + ").");
                _instance.Dispose();
                Globals.iInUniv = false;
                return;
            }
            else
            {
                m_Login.ReportProgress(0, "Entered world " + Globals.sWorld + ".");
                Globals.iInWorld = true;
            }

            // Test caretaker mode (if requested)
            if (Globals.iCaretaker == true)
            {
                if (_instance.Attributes.WorldCaretakerCapability == true)
                {
                    m_Login.ReportProgress(0, "Caretaker mode confirmed.");
                }
                else
                {
                    m_Login.ReportProgress(0, "Caretaker mode denied.");
                }
            }

            // Commit the positioning and become visible
            m_Login.ReportProgress(0, "Changing position in world.");
            _instance.Attributes.MyX    = Globals.iXPos;
            _instance.Attributes.MyY    = Globals.iYPos;
            _instance.Attributes.MyZ    = Globals.iZPos;
            _instance.Attributes.MyYaw  = Globals.iYaw;
            _instance.Attributes.MyType = Globals.iAV;
            Globals.Dest.x   = Globals.iXPos;
            Globals.Dest.y   = Globals.iYPos;
            Globals.Dest.z   = Globals.iZPos;
            Globals.Dest.yaw = Globals.iYaw;

            rc = _instance.StateChange();
            if (rc == Result.Success)
            {
                m_Login.ReportProgress(0, "Movement successful.");
            }
            else
            {
                m_Login.ReportProgress(0, "Movement aborted (reason: " + rc + ").");
            }
        }
コード例 #6
0
        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();
        }