Esempio n. 1
0
        public void UpdateInputFunc(string strInFunc)
        {
            //call FunctionInterpreter to give it information on our new hash fuction
            try
            {
                m_funcInputFunction = new Function_class(strInFunc, "x");
            }//try
            catch (Exception eA)
            {
                //something went wrong, tell the user
                //the next call is code mostly reused from Tom Fuller's tutorial programs
                string strMsg = String.Format("Update Input Function failed.\n\nUse of ''{0}failed: '{1}'",
                    strInFunc, eA.ToString());

                MessageBox.Show(strMsg, "cs276_bjt_11-2-2008_hashFunctions - InOutHandler - FunctionInterpreter();",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                m_funcInputFunction = null;
                throw new InvalidOperationException("Could not create new input function"); //throw new might be useful here...
            }//catch

            //check to see if the function was successfully created
            if (m_funcInputFunction.Comment != "Successful")
            {
                m_funcInputFunction = null;
                throw new ArgumentOutOfRangeException("Could not parse the function.");
            }//if

            //set min and max for function
            m_funcInputFunction.SetLimits(0, 2000000);

            //set things graph wise? set things domain wise? set domain counter?...
        }
Esempio n. 2
0
        /// <summary>
        /// We get information on a new function, m_plotGraphBuilder and m_fiHashFunction
        /// need the information so that they can do their jobs
        /// Pre: the min and max values are valid
        /// </summary>
        /// <param name="strInFunc">new hash function as a string</param>
        /// <param name="iInRangeMin">minimum value that is output by the function</param>
        /// <param name="iInRangeMax">maximum value that is output by the function</param>
        public void UpdateHash(string strInFunc, int iInRangeMin, int iInRangeMax)
        {
            //call FunctionInterpreter to give it information on our new hash fuction
            try
            {
                m_funcHashFunction = new Function_class(strInFunc, "x");
            }//try
            catch (Exception eA)
            {
                //something went wrong, tell the user
                //the next call is code mostly reused from Tom Fuller's tutorial programs
                string strMsg = String.Format("UpdateFunction failed.\n\nUse of ''{0}failed: '{1}'",
                    strInFunc, eA.ToString());

                MessageBox.Show(strMsg, "cs276_bjt_11-2-2008_hashFunctions - InOutHandler - FunctionInterpreter.UpdateFunction();",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                m_funcHashFunction = null;
                throw new InvalidOperationException("Could not create the function.");
            }//catch

            //check to see if the function was successfully created
            if (m_funcHashFunction.Comment != "Successful")
            {
                m_funcHashFunction = null;
                throw new ArgumentOutOfRangeException("Could not parse the function.");
            }//if

            //check to be sure we have an input funciton to work with
            if (m_funcInputFunction == null)
            {
                throw new ArgumentOutOfRangeException("No input function has been created!");
            }

            //set min and max for function
            m_funcHashFunction.SetLimits(iInRangeMin, iInRangeMax);

            //so that we can keep track of how many times we send a new X input
            m_iDomainCount = 0;

            //give m_plotGraphBuilder the range so it can set up for plotting
            //this should not fail, if it does there is an error in some other class
            m_plotGraphBuilder.Reset(iInRangeMin, iInRangeMax);
        }