コード例 #1
0
        private void bStart_Click(object sender, EventArgs e)
        {
            bStart.Enabled = false;
            bStop.Enabled  = true;
            bStart.Refresh();
            bStop.Refresh();
            logWriter = new StreamWriter("simulais_log.txt");
            logWriter.WriteLine(DateTime.Now);

            wsnSimulator = new WsnSimulatorApp();
            wsnSimulator.Initializing       += new EventHandler <ProgressEventArgs>(simulator_OnProgress);
            wsnSimulator.LogEvent           += new EventHandler <LogEventArgs>(simulator_LogEvent);
            wsnSimulator.SimulationFinished += new EventHandler <EventArgs>(simulator_SimulationFinished);
            Scheduler.Dispatching           += new Handler(Scheduler_Dispatching);

            progressFrm = new ProgressFrm();
            progressFrm.Show();
            var blockLen = 3;

            try
            {
                wsnSimulator.InitFromTrace(
                    "../../../NSTraces/Traces-2009-12-23/ntr_ex5.tr",
                    "../../../NSTraces/nm/ex6_nm4.tr",
                    blockLen,
                    1, 1, 1, int.Parse(tbNumOfAPCs.Text), int.Parse(tbNumOfTCells.Text), true);

                // initialize the simulator

                /*wsnSimulator.Init(
                 *      "../../../NSTraces/Traces-2009-12-23/ntr_ex5R.tr",		// self trace path
                 *      "../../../NSTraces/Traces-2009-12-23/ntr_ex6R.tr",		// test trace path
                 *      blockLen,												// block duration
                 *      1, 1, 1, int.Parse(tbNumOfAPCs.Text), int.Parse(tbNumOfTCells.Text), true); */
            }
            catch (Exception ex)
            {
                MessageBox.Show("Simulator initialization failed:\n\n" + ex.Message + "\n\n" + ex.StackTrace,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                progressFrm.Close();
                bStart.Enabled = true;
                bStop.Enabled  = false;
                return;
            }

            lymphNode   = wsnSimulator.LymphNodes[0];
            localTissue = wsnSimulator.LocalTissues[0];
            progressFrm.Close();
            Refresh();

            // start the simulation
            wsnSimulator.Run();
        }
コード例 #2
0
ファイル: MainFrm.cs プロジェクト: sawat80/Simulais
		private void bStart_Click(object sender, EventArgs e)
		{
			bStart.Enabled = false;
			bStop.Enabled = true;
			bStart.Refresh();
			bStop.Refresh();
			logWriter = new StreamWriter("simulais_log.txt");
			logWriter.WriteLine(DateTime.Now);

			wsnSimulator = new WsnSimulatorApp();
			wsnSimulator.Initializing += new EventHandler<ProgressEventArgs>(simulator_OnProgress);
			wsnSimulator.LogEvent += new EventHandler<LogEventArgs>(simulator_LogEvent);
			wsnSimulator.SimulationFinished += new EventHandler<EventArgs>(simulator_SimulationFinished);
			Scheduler.Dispatching += new Handler(Scheduler_Dispatching);

			progressFrm = new ProgressFrm();
			progressFrm.Show();
			var blockLen = 3;

			try
			{
				wsnSimulator.InitFromTrace(
					"../../../NSTraces/Traces-2009-12-23/ntr_ex5.tr",
					"../../../NSTraces/nm/ex6_nm4.tr", 
					blockLen,
					1, 1, 1, int.Parse(tbNumOfAPCs.Text), int.Parse(tbNumOfTCells.Text), true);

				// initialize the simulator
				/*wsnSimulator.Init(
					"../../../NSTraces/Traces-2009-12-23/ntr_ex5R.tr",		// self trace path
					"../../../NSTraces/Traces-2009-12-23/ntr_ex6R.tr",		// test trace path
					blockLen,												// block duration
					1, 1, 1, int.Parse(tbNumOfAPCs.Text), int.Parse(tbNumOfTCells.Text), true); */				 
			}
			catch (Exception ex)
			{
				MessageBox.Show("Simulator initialization failed:\n\n" + ex.Message + "\n\n" + ex.StackTrace, 
					"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				progressFrm.Close();
				bStart.Enabled = true;
				bStop.Enabled = false;
				return;
			}

			lymphNode = wsnSimulator.LymphNodes[0];
			localTissue = wsnSimulator.LocalTissues[0];
			progressFrm.Close();
			Refresh();

			// start the simulation
			wsnSimulator.Run();
		}