/// <summary>
        /// Populates this dialog with specific composition.
        /// </summary>
        /// <param name="composition">Composition to be used for dialog.</param>
        /// <param name="initialTriggerInvokeTime">
        /// If <c>true</c>, the <see cref="CompositionManager.TriggerInvokeTime">CompositionManager.TriggerInvokeTime</see>
        /// is set to latest overlapping time of time horizons of all models. Typically this is used
        /// when this dialog is showed for the first time.</param>
        public void PopulateDialog( CompositionManager composition, bool initialTriggerInvokeTime )
        {
            _composition = composition;

            Debug.Assert( _composition.HasTrigger() );
            Debug.Assert( _composition.Models.Count > 1 );

            // fill dialog according to composition
            if( _composition.LogToFile == null )
            {
                checkBoxLogToFile.Checked = false;
                textLogToFile.Text = "CompositionRun.log";
            }
            else
            {
                checkBoxLogToFile.Checked = true;
                textLogToFile.Text = _composition.LogToFile;
            }

            for( int i=0; i<(int)EventType.NUM_OF_EVENT_TYPES; i++ )
                checkboxesEventTypes[i].Checked = _composition.ListenedEventTypes[i];

            if( initialTriggerInvokeTime )
            {
                buttonTimeLatestOverlapping_Click(null, null);
            }
            else
            {
                textTriggerInvokeTime.Text = _composition.TriggerInvokeTime.ToString( );
            }

            checkBoxEventsToListbox.Checked = _composition.ShowEventsInListbox;

            checkBoxNoMultithreading.Checked = _composition.RunInSameThread;

            runIt = false;
        }
예제 #2
0
		private static void RunApplication( object data )
		{
			try
			{
				bool verboseOff = (bool)( (object[]) data )[0];
				string oprFilename = (string) ( (object[]) data )[1];

				// check whether opr file exists
				if( oprFilename==null )
				{
					Console.WriteLine( "Error: -r switch was not specified." );
					_exitCode = 3;
					return;
				}

				FileInfo fileInfo = new FileInfo( oprFilename );
				if( !fileInfo.Exists )
				{
					Console.WriteLine( "Error: cannot find input file "+oprFilename );
					_exitCode = 4;
					return;
				}


				// open OPR
				CompositionManager composition = new CompositionManager();

				if( !verboseOff )
					Console.WriteLine( "Loading project file "+fileInfo.FullName+"..." );
				composition.LoadFromFile( fileInfo.FullName );


				// prepare listeners
				if( !verboseOff )
					Console.WriteLine( "Preparing listener(s)..." );
				ArrayList listOfListeners = new ArrayList();

				// logfile listener
				if( composition.LogToFile!=null && composition.LogToFile!="" )
				{
					// get composition file's directory to logfile is saved in same directory
					string logFileName = Utils.GetFileInfo( fileInfo.DirectoryName, composition.LogToFile ).FullName;
					LogFileListener logFileListener = new LogFileListener( composition.ListenedEventTypes, logFileName );
					listOfListeners.Add( logFileListener );
				}

				// console listener
				if( !verboseOff )
				{
					ConsoleListener consoleListener = new ConsoleListener( composition.ListenedEventTypes );
					listOfListeners.Add( consoleListener );
				}

				// create proxy listener
				ProxyListener proxyListener = new ProxyListener();
				proxyListener.Initialize( listOfListeners );

				// run simulation
				if( !verboseOff )
					Console.WriteLine( "Starting composition run..." );
				composition.Run( proxyListener, true );

				if( !verboseOff )
					Console.WriteLine( "Closing composition..." );
				composition.Release();

				_exitCode = 0;
			}
			catch( Exception e )
			{
				Console.WriteLine( "Exception occured: " + e.ToString() );
				_exitCode = -2;
				return;
			}
		}
        /// <summary>
        /// Creates a new instance of <see cref="MainForm">MainForm</see> window.
        /// </summary>
        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //

            _compositionBoxPositionInArea = new Point(0,0);

            InitializeComponent();

            _composition = new CompositionManager();

            _prevMouse = new Point(0,0);

            _sourceCursor = new Cursor(GetType(), "Source.cur");
            _targetCursor = new Cursor(GetType(), "Target.cur");

            // create dialogs
            _modelDialog = new ModelDialog();
            _connectionDialog = new ConnectionDialog();
            _aboutBox = new AboutBox();
            _runProperties = new RunProperties();
            _runBox = new RunBox();

            menuRegisterExtensions.Checked = Utils.AreFileExtensionsRegistered( Application.ExecutablePath );
        }
예제 #4
0
		/// <summary>
		/// Populates this dialog with specified composition and proxy listener.
		/// </summary>
		/// <param name="composition">Composition which simulation is to be run.</param>
		/// <param name="listener">Listener which is used for monitoring simulation.</param>
		/// <remarks>
		/// Simulation is fired after this dialog is showed. That's because if
		/// simulation runs in same thread we won't be able to show it another way.
		/// We determine whether simulation runs in same thread using
		/// <see cref="CompositionManager.RunInSameThread">CompositionManager.RunInSameThread</see> property.
		/// </remarks>
		public void PopuplateDialog( CompositionManager composition, IListener listener )
		{
			_composition        = composition;
			_listener           = listener;			
			_finished           = false;
			_started            = false;
			buttonClose.Enabled = !composition.RunInSameThread;
			buttonStop.Enabled  = !composition.RunInSameThread;			

			progressBarRun.Value = 0;
			progressBarRun.Enabled = true;

			labelInfo.Text = "Running...";

			listViewEvents.Items.Clear();
		}