Пример #1
0
        /// <summary>
        /// Close the log and sound off according to how the test ended.
        /// </summary>
        /// <param name="action">The disposition of the test</param>
        public void close(Disposition action)
        {
            if (!s_isClosed)
            {
                Sound snd = new Sound();
                if (action == Disposition.Pass) {
                    snd.Frequency = 800;
                    snd.Duration = 500;
                }
                else if (action == Disposition.Fail) {
                    snd.Frequency = 300;
                    snd.Duration = 1000;
                }
                else { // Hung
                    snd.Frequency = 500;
                    snd.Duration = 200;
                }

                snd.Execute(); // a tone indicating disposition

                try
                {
                    m_sw.WriteLine(@"</gtdLog>");
                    m_sw.Close();
                }
                catch (Exception e)
                {
                    Console.Out.WriteLine("Log failed: " + e.Message);
                    action = Disposition.Hung;
                }
                s_isClosed = true;
                m_init = false;
            }
        }
Пример #2
0
		/// <summary>
		/// Creates a sound instruction.
		/// </summary>
		/// <param name="xn">The XML repersentation of the instruction to be checked</param>
		/// <returns>A Sound intsruction</returns>
		static Sound CreateSound(XmlNode xn)
		{
			string frequency = XmlFiler.getAttribute(xn, "frequency");
			string duration = XmlFiler.getAttribute(xn, "duration");
			Logger.getOnly().isTrue(frequency != null && duration != null, "Sound instruction must have a frequency and duration.");
			Sound sound = new Sound(Convert.ToUInt32(frequency), Convert.ToUInt32(duration));
			string rest = XmlFiler.getAttribute(xn, "wait");
			if (rest != null) sound.Rest = Convert.ToInt32(rest);
			return sound;
		}
Пример #3
0
        /// <summary>
        /// Creates and parses a message contained in some instructions.
        /// </summary>
        /// <param name="ins"></param>
        /// <param name="body"></param>
        protected void InterpretMessage(XmlNodeList body)
        {
            if (body != null)
            {
                Message message = new Message();

                foreach (XmlNode node in body)
                {
                    switch (node.Name)
                    {
                    case "#text": // a nameless text node
                        message.AddText(node.Value);
                        break;
                    case "data":
                        message.AddDataRef(XmlFiler.getAttribute(node, "of"), this);
                        break;
                    case "beep":
                        message.AddSound(new Beep());
                        break;
                    case "sound":
                        string frequency = XmlFiler.getAttribute(node, "frequency");
                        string duration = XmlFiler.getAttribute(node, "duration");
                        m_log.isTrue(frequency != null && duration != null, makeNameTag() + "Sound instruction must have a frequency and duration.");
                        Sound sound = null;
                        try { sound = new Sound(Convert.ToUInt32(frequency), Convert.ToUInt32(duration)); }
                        catch { m_log.fail(makeNameTag() + "Sound instruction must have a frequency and duration in milliseconds."); }
                        message.AddSound(sound);
                        break;
                    }
                }
                Message = message;
            }
        }