示例#1
0
 public void StepTest()
 {
     var j = new Job(1000, 1, 100, null);
     var c = new Cube(1000, j);
     Assert.AreEqual(c.Step(), 0);
     Assert.AreEqual(c.Step(), 0);
     Assert.IsTrue(c.Step() > 100);
 }
示例#2
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            // this should use some kind of data binding but the setup isn't obvious and this works...
            int nAnts = Int32.Parse(nAntsBox.Text);
            int nCubes = Int32.Parse(nCubesBox.Text);
            int nMaxTime = Int32.Parse(nMaxTimeBox.Text);
            int nThreads = Int32.Parse(nThreadsBox.Text);
            // TODO: input validation and error reporting

            m_runningjob = new Job(nAnts, nCubes, nMaxTime);
            ProgressField.Text = "0";
            AverageField.Text = "";
            StdDevField.Text = "";
            StartButton.Enabled = false;
            // StopButton.Enabled = true; Stop not yet implemented so don't enable yet.

            timer1.Start();
            m_runningjob.Start(nThreads);
        }
示例#3
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (m_runningjob != null)
     {
         ReportStats(m_runningjob.m_summarystats);
         double nDone = m_runningjob.m_summarystats.Mass(); // atomic internally
         if (nDone < m_runningjob.m_nCubes)
         {
             ProgressField.Text = nDone.ToString();
         }
         else
         {
             ProgressField.Text = "complete";
             m_runningjob = null;
             StartButton.Enabled = true;
             StopButton.Enabled = false;
             timer1.Stop();
         }
     }
 }
示例#4
0
        int[] m_node = { 0, 0, 0 }; // see design notes, index = rank number, val = ant population.

        #endregion Fields

        #region Constructors

        public Cube(int nAnts, Job job)
        {
            m_job = job;
            m_node[0] = nAnts;
        }