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); }
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); }
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(); } } }
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; }