Beispiel #1
0
        /// <summary>
        /// Called when the plugin is unloaded(application is terminating)
        /// </summary>
        public void onUnload(object sender, EventArgs e)
        {
            closeAllStreams();
            mIhost.CloseStandardConsole(mStdioConsole);

            //_ihost.StopSimulation -= onRestart;
            mIhost.Restart -= onRestart;
            mIhost.Unload  -= onUnload;
            mIhost.Load    -= onLoad;
        }//onUnload
        private void SetupStreams()
        {
            closeAllStreams();
            mIhost.CloseStandardConsole(mStdioConsole);

            mStdioConsole = mIhost.CreateStandardConsole("stdin/stdout/stderr");

            ARMPluginInterfaces.Preferences.IGeneralPreferences prefs = mIhost.ARMPreferences.IGeneralPreferences;
            IARMSimArguments args = mIhost.ARMSimArguments;

            ARMSimStream armSimStream = CreateInputStream(args.StdinFileName);

            if (armSimStream == null)
            {
                armSimStream = CreateInputStream(prefs.StdinFileName);
            }
            if (armSimStream == null)
            {
                armSimStream = new ARMSimConsoleStream(mStdioConsole, mIhost);
            }

            mFiles.Add(armSimStream);  // index = 0

            bool   overwrite = true;
            string filename  = null;

            if (args.StdoutFileName != null)
            {
                overwrite = true;
                filename  = args.StdoutFileName;
            }
            else if (args.StdoutAppendMode != null)
            {
                overwrite = false;
                filename  = args.StdoutAppendMode;
            }
            armSimStream = CreateOutputStream(filename, overwrite);
            if (armSimStream == null)
            {
                armSimStream = CreateOutputStream(prefs.StdoutFileName, prefs.StdoutOverwrite);
            }
            if (armSimStream == null)
            {
                armSimStream = new ARMSimConsoleStream(mStdioConsole, mIhost);
            }

            mFiles.Add(armSimStream);  // index = 1

            if (args.StderrFileName != null)
            {
                overwrite = true;
                filename  = args.StderrFileName;
            }
            else if (args.StderrAppendMode != null)
            {
                overwrite = false;
                filename  = args.StderrAppendMode;
            }
            armSimStream = CreateOutputStream(filename, overwrite);
            if (armSimStream == null)
            {
                armSimStream = CreateOutputStream(prefs.StderrFileName, prefs.StderrOverwrite);
            }
            if (armSimStream == null)
            {
                armSimStream = new ARMSimConsoleStream(mStdioConsole, mIhost);
            }

            mFiles.Add(armSimStream);  // index = 2
            mNextFileHandle = 3;
        }//SetupStreams
        }//Peek

        /// <summary>
        /// Close the standard console.
        /// </summary>
        public override void Close()
        {
            _ihost.CloseStandardConsole(_handle);
        }//Close