static double DisplayGetThreshold(Finch finchRobot, string alarmType)
        {
            double threshold = 0;

            DisplayScreenHeader("Threshold Value");

            switch (alarmType)
            {
            case "light":
                Console.WriteLine($"Current Light Level: {finchRobot.getLeftLightSensor()}");
                Console.Write("Enter Maximum Light Level [0 - 255]:");
                threshold = double.Parse(Console.ReadLine());
                break;

            case "temperature":
                Console.WriteLine($"Current Temperature: {finchRobot.getTemperature() * (9 / 5) + 32}\u00B0F");
                Console.Write("Enter Maximum Temperature:");
                threshold = double.Parse(Console.ReadLine());
                break;

            default:
                Console.WriteLine("Invalid input, you goober.");
                break;
            }

            DisplayContinuePrompt();

            return(threshold);
        }
Beispiel #2
0
        //--------//
        //Get Data//
        //--------//
        static double[] DataRecorderDisplayGetData(int numberOfDataPoints, double dataPointsFrequency, Finch myFinch)
        {
            double[] temperatures = new double[numberOfDataPoints];
            int      frequencyInSeconds;

            DisplayHeader("Get Data");

            Console.WriteLine($"You have {numberOfDataPoints} data points and a frequency of {dataPointsFrequency}");

            Console.WriteLine("The finch robot is ready to record temperature");
            DisplayContinuePrompt();

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = myFinch.getTemperature();
                Console.WriteLine($"Data #{index + 1}: {temperatures[index]} in celcius. {index + 1}: {(temperatures[index] * 9 / 5) + 32} in fahrenheit");
                frequencyInSeconds = (int)(dataPointsFrequency * 1000);
                myFinch.wait(frequencyInSeconds);
            }

            Console.WriteLine();
            Console.WriteLine("Current Data");
            DataRecorderDisplayTable(temperatures);

            DisplayContinuePrompt();
            DisplayDataRecorder(myFinch);
            return(temperatures);
        }
Beispiel #3
0
        /// <summary>
        /// *****************************************************************
        /// *                          Get Data                             *
        /// *****************************************************************
        /// </summary>
        /// <param name="finchRobot">finch robot object</param>
        /// <returns>Populate an array with data from the Finch's sensors</returns>
        static void DisplayGetData(int numberOfDataPoints, double dataPointFrequency, Finch finchRobot)
        {
            DisplayScreenHeader("Get Data");

            double[] temperatures = new double[numberOfDataPoints];

            double Fahrenheit = 0;

            Console.WriteLine($"Number of datapoints: {numberOfDataPoints}\nFrequency of datapoints: {dataPointFrequency}\n");

            Console.WriteLine("Ready to record data\n");

            DisplayContinuePrompt();

            for (int loop = 0; loop < numberOfDataPoints; loop++)
            {
                Fahrenheit = finchRobot.getTemperature() * 1.8 + 32;

                temperatures[loop] = Fahrenheit;
                Console.WriteLine($"Temperature: {temperatures[loop]}\n");
                Thread.Sleep((int)dataPointFrequency);
            }

            Console.WriteLine("Done recording data\n");

            DisplayContinuePrompt();
        }
        //
        // celcius temperatures
        //
        static double[] DataRecorderDisplayGetData(int numberOfDataPoints, double dataPointFrequency, Finch finchRobot)
        {
            double[] temperatures = new double[numberOfDataPoints];

            DisplayScreenHeader("Get Celcius Data");

            Console.WriteLine($"\tNumber of data points: {numberOfDataPoints}");
            Console.WriteLine($"\tData Point Frequency: {dataPointFrequency}");
            Console.WriteLine();
            Console.WriteLine("\tThe Finch Robot is ready to begin recording the temperature data.");
            DisplayContinuePrompt();

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = finchRobot.getTemperature();
                Console.WriteLine($"\tReading {index + 1}: {temperatures[index].ToString("n2")}°C");
                int waitInSeconds = (int)(dataPointFrequency * 1000);
                finchRobot.wait(waitInSeconds);

                Console.WriteLine("Data Recording is complete");
            }

            DisplayContinuePrompt();
            DisplayScreenHeader("Get Data");

            Console.WriteLine();
            Console.WriteLine("\t Table of Celcius Temperatures");
            Console.WriteLine();
            DataRecorderTableCelcius(temperatures);

            DisplayContinuePrompt();

            return(temperatures);
        }
        /// <summary>
        /// *****************************************************************
        /// *                  Connect the Finch Robot                      *
        /// *****************************************************************
        /// </summary>
        /// <param name="finchRobot">finch robot object</param>
        /// <returns>notify if the robot is connected</returns>
        static bool DisplayConnectFinchRobot(Finch finchRobot)
        {
            Console.CursorVisible = false;

            bool robotConnected;

            DisplayScreenHeader("Connect Finch Robot");

            Console.WriteLine("\tAbout to connect to Finch robot. Please be sure the USB cable is connected to the robot and computer now.");
            DisplayContinuePrompt();

            robotConnected = finchRobot.connect();

            // TODO test connection and provide user feedback - text, lights, sounds

            DisplayMenuPrompt("Main Menu");

            //
            // reset finch robot
            //
            finchRobot.setLED(0, 0, 0);
            finchRobot.noteOff();
            finchRobot.getTemperature();

            return(robotConnected);
        }
Beispiel #6
0
        static void DisplayActivateSentrybot(double lowerTempThresholdValue, Finch myfinch, double lowerLightThreshold)
        {
            double ambientTemp;
            double ambientLight;

            ambientTemp = myfinch.getTemperature();
            //ambientLight = myfinch.getRightLightSensor() + myfinch.getLeftLightSensor();
            ambientLight = myfinch.getLightSensors().Average();

            DisplayHeader("Activate Sentry Bot");
            Console.WriteLine($"The ambient temperature is {ambientTemp}");
            Console.WriteLine($"The lower Temperature Threshold is {lowerTempThresholdValue}");

            while (!TemperatureBelowThresholdValue(lowerTempThresholdValue, myfinch) && !LightAboveThresholdValue(lowerLightThreshold, myfinch))
            {
                Console.WriteLine($"light threshold{lowerLightThreshold}, light {ambientLight}, temp threshold {lowerTempThresholdValue}, temp {ambientTemp}");
                TemperatureNominalIndicator(myfinch);
            }

            //if (TemperatureBelowThresholdValue(lowerTempThresholdValue, myfinch) && LightAboveThresholdValue(lowerLightThreshold, myfinch))
            //{
            myfinch.noteOn(250);
            myfinch.setLED(255, 0, 0);
            myfinch.wait(3000);
            myfinch.noteOff();
            myfinch.setLED(0, 0, 0);
            //}

            DisplayContinuePrompt();
        }
Beispiel #7
0
        static double DisplayTempSetup(Finch sentryBot)
        {
            double lowerTempThreshold = 0;
            double ambientTemp;
            bool   validResponse;

            DisplayHeader("Sentry Bot Setup");

            do
            {
                validResponse = true;

                Console.Write("Enter desired change in Temperature: ");

                if (double.TryParse(Console.ReadLine(), out double tempDifference))
                {
                    ambientTemp = sentryBot.getTemperature();

                    lowerTempThreshold = ambientTemp - tempDifference;

                    DisplayContinue();
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Please enter a valid temperature");
                    validResponse = false;
                }
            } while (!validResponse);

            return(lowerTempThreshold);
        }
Beispiel #8
0
        /// <summary>
        /// *****************************************************************
        /// *                           Get Data                            *
        /// *****************************************************************
        /// </summary>

        private static double[] DataRecorderDisplayGetData(int numberOfDataPoints, double dataPointFrequency, Finch finchRobot)
        {
            Console.CursorVisible = false;

            DisplayScreenHeader("Data Point Number");

            double[] dataPoints = new double[numberOfDataPoints];
            double   temp;
            double   number          = dataPointFrequency * 1000;
            int      finchWaitLength = Convert.ToInt32(number);


            Console.WriteLine("\tThe Finch robot will be collecting {0} points of data at {1} second intervals.", numberOfDataPoints, dataPointFrequency);
            Console.WriteLine("\tThe Finch robot is ready to collect data.");
            DisplayContinuePrompt();

            for (int i = 0; i < numberOfDataPoints; ++i)
            {
                temp = finchRobot.getTemperature();
                Console.WriteLine("Temperature measured at {0}.", temp);
                dataPoints[i] = temp;
                finchRobot.wait(finchWaitLength);
            }

            Console.WriteLine();
            Console.Write("Data collection complete.");
            DisplayContinuePrompt();
            return(dataPoints);
        }
        /// <summary>
        /// acquire data
        /// </summary>
        static double[] DisplayAcquireDataSet(int numberOfDataPoints, double secondsBetweenDataPoints, Finch freddy)
        {
            double[] temperatures = new double[numberOfDataPoints];

            DisplayHeader("Acquire Data Set");

            //
            // pause for user
            //
            Console.WriteLine("The Finch Robot is ready. Press Enter to begin.");
            Console.ReadLine();

            //
            // acquire data
            //
            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = freddy.getTemperature();
                Console.WriteLine($"Data Point {index + 1}: {temperatures[index]}");
                freddy.wait((int)(secondsBetweenDataPoints * 1000));
            }

            DisplayDataSetList(temperatures);

            DisplayContinuePrompt();

            return(temperatures);
        }
Beispiel #10
0
 static bool SentryVersusThresholdValue(double lowerTempThreshold, Finch finch, double upperLightThreshold)
 {
     if (finch.getTemperature() <= lowerTempThreshold)
     {
         for (int i = 0; i < 5; i++)
         {
             finch.noteOn(600);
             finch.wait(50);
             finch.noteOff();
         }
         Console.WriteLine("Temperature Reached Threshold. Press Any Key To Continue.");
         Console.ReadKey();
         return(true);
     }
     else if ((finch.getLeftLightSensor() + finch.getRightLightSensor()) / 2 >= upperLightThreshold)
     {
         for (int i = 0; i < 5; i++)
         {
             finch.noteOn(600);
             finch.wait(50);
             finch.noteOff();
         }
         Console.WriteLine("Light Reached Threshold. Press Any Key To Continue.");
         Console.ReadKey();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #11
0
        static double DisplaySetup(Finch finch)
        {
            double tempDiff, lowerTempThreshold, ambientTemp;
            bool   valid;

            do
            {
                Console.Clear();
                DisplayHeader("Setup SentryBot");
                valid = true;
                Console.Write("Enter Desired Change in Temperature: ");
                if (!double.TryParse(Console.ReadLine(), out tempDiff))
                {
                    valid = false;
                    Console.WriteLine("Invalid Input. Press Any Key To Try Again.");
                    Console.ReadKey();
                }
            } while (!valid);

            ambientTemp = finch.getTemperature();

            lowerTempThreshold = ambientTemp - tempDiff;

            DisplayContinuePrompt();

            return(lowerTempThreshold);
        }
        static double[] DataRecorderDisplayGetData(int numberOfPoints, double dataPointFrequency, Finch finchRobot)
        {
            double[] temperatures = new double[numberOfPoints];
            int frequencyInSeconds;

            DisplayScreenHeader("Get Data");

            Console.WriteLine();
            Console.WriteLine($"Data Points: {numberOfPoints} and Data Point Frequency: {dataPointFrequency}");

            Console.WriteLine("The Finch Robot is ready to record temperatures.");
            DisplayContinuePrompt();

            for (int index = 0; index < numberOfPoints; index++)
            {
                temperatures[index] = finchRobot.getTemperature();
                Console.WriteLine($"Data #{index + 1}: {temperatures[index]}°C");
                frequencyInSeconds = (int)(dataPointFrequency * 1000);
                finchRobot.wait(frequencyInSeconds);
            }

            Console.WriteLine();
            Console.WriteLine("Current Data");
            DataRecorderDisplayTable(temperatures);

            Console.WriteLine();
            Console.WriteLine($"Average Temperature: {temperatures.Average()}");

            DisplayContinuePrompt();

            return temperatures;
        }
        /// <summary>
        /// monitors temperature level
        /// </summary>
        static bool MonitorCurrentTemperatureLevels(Finch ros, double threshold, int maxSeconds)
        {
            bool thresholdExceeded = false;
            double currentTempLevel;
            double seconds = 0;

            while (!thresholdExceeded && seconds <= maxSeconds)
            {
                currentTempLevel = (ros.getTemperature() * 1.8) + 32;

                DisplayScreenHeader("Monitor Temperature Levels");
                Console.WriteLine($"Maximum Temperature Level: {threshold}");
                Console.WriteLine($"Current Temperature Level: {currentTempLevel}");

                if (currentTempLevel > threshold)
                {
                    thresholdExceeded = true;
                }

                ros.wait(500);
                seconds += 0.5;
            }

            return thresholdExceeded;
        }
        static void DisplayGetTemperatureData(int numberofDataPoints, double DataPointFrequency, double[] Temperatures, Finch finchRobot)
        {
            DisplayScreenHeader("Get Data");

            //++++++++++++++++++++++++++++++++++//
            // Provide The User Info and Prompt //
            //++++++++++++++++++++++++++++++++++//

            //+++++++++++++//
            // Record Data //
            //+++++++++++++//

            for (int index = 0; index < numberofDataPoints; index++)
            {
                Temperatures[index] = finchRobot.getTemperature() * (9 / 5) + 32;
                int milliSeconds = ((int)(DataPointFrequency * 1000));
                finchRobot.wait(milliSeconds);

                //+++++++++++//
                // Echo Data //
                //+++++++++++//

                Console.WriteLine($"Temperature {index + 1}: {Temperatures[index]}\u00B0F");
            }
        }
Beispiel #15
0
        private static double[] DataRecorderDisplayGetData(int numberOfDataPoints, double dataPointFrequency, Finch fn)
        {
            Console.CursorVisible = false;
            double[] temperatures = new double[numberOfDataPoints];
            Console.WriteLine("\n\tOption C Chosen");
            DisplayHeader("\n\tOption C Chosen" + "\n\tGet Data");

            Console.WriteLine($"\tNumber of data points: {numberOfDataPoints}");
            Console.WriteLine($"\tData point frequency: {dataPointFrequency}");
            Console.WriteLine();
            Console.WriteLine("\tThe Finch robot is ready to begin recording the temperature data.");
            DisplayContinuePrompt();

            for (int i = 0; i < numberOfDataPoints; i++)
            {
                temperatures[i] = fn.getTemperature();
                Console.WriteLine($"\tReading {i + 1}: {temperatures[i]:n2} ");
                int waitInSeconds = (int)((dataPointFrequency) * 1000);
                fn.wait(waitInSeconds);
            }

            DisplayContinuePrompt();

            return(temperatures);
        }
Beispiel #16
0
        static double SetupTemp(Finch steve)
        {
            double temperatureDifference;
            double lowerTempThreshold;
            double ambientTemp;

            DisplayHeader("Setup Sentry Bot");

            Console.Write("Enter desired change in temperature: ");

            while (!double.TryParse(Console.ReadLine(), out temperatureDifference))
            {
                Console.WriteLine("Please enter a valid response.");
            }


            ambientTemp = steve.getTemperature();

            lowerTempThreshold = ambientTemp - temperatureDifference;


            DisplayContinuePrompt();

            return(lowerTempThreshold);
        }
Beispiel #17
0
        static double DisplaySetup(Finch myfinch, out double lowerLightThreshold)
        {
            double temperatureDifference;
            double lowerTempThreshold;
            double ambientTemp;
            double lightDifference;
            double ambientLight;

            DisplayHeader("Setup Sentry Bot");

            Console.Write("Enter desired change in temperature:");
            double.TryParse(Console.ReadLine(), out temperatureDifference);

            ambientTemp = myfinch.getTemperature();

            lowerTempThreshold = ambientTemp - temperatureDifference;

            Console.Write("Enter desired change in light:");
            double.TryParse(Console.ReadLine(), out lightDifference);

            ambientLight = myfinch.getLeftLightSensor() + myfinch.getRightLightSensor();

            lowerLightThreshold = ambientLight + lightDifference;

            DisplayContinuePrompt();
            return(lowerTempThreshold);
        }
Beispiel #18
0
        static void DisplayGetData(
            int numberOfDataPoints,
            double dataPointFrequency,
            double[] temperatures,
            Finch finchRobot)
        {
            DisplayScreenHeader("Get Temperatures");

            // give the user info and a prompt
            Console.WriteLine($"The Finch Robot is now going to take {numberOfDataPoints} data points.");

            finchRobot.wait(2000);
            Console.Clear();

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = finchRobot.getTemperature();
                ConvertCelsiusToFahrenheit(temperatures[index]);
                int milliseconds = (int)(dataPointFrequency * 1000);
                finchRobot.wait(milliseconds);

                Console.WriteLine($"Temperature {index + 1}: {temperatures[index]}");
            }

            DisplayContinuePrompt();
        }
Beispiel #19
0
        static void DisplayActivateSentryBot(double lowerTempThreshold, int upperLightThreshold, Finch sentryBot)
        {
            DisplayHeader("Activate Sentry Bot");

            Console.WriteLine(sentryBot.getTemperature());
            Console.WriteLine(lowerTempThreshold);
            do
            {
                NominalIndicator(sentryBot);
            } while (!TemperatureBelowThresholdValue(lowerTempThreshold, sentryBot) && !LightAboveThresholdValue(upperLightThreshold, sentryBot));

            if (TemperatureBelowThresholdValue(lowerTempThreshold, sentryBot))
            {
                Console.WriteLine();
                Console.WriteLine("The temperature has gone below the threshold value.");
                sentryBot.noteOn(500);
                sentryBot.setLED(255, 0, 0);
                DisplayContinue();
                sentryBot.noteOff();
                sentryBot.setLED(0, 0, 0);
            }
            else if (LightAboveThresholdValue(upperLightThreshold, sentryBot))
            {
                Console.WriteLine();
                Console.WriteLine("The light has exceded the threshold value.");
                sentryBot.noteOn(400);
                sentryBot.setLED(0, 0, 255);
                DisplayContinue();
                sentryBot.noteOff();
                sentryBot.setLED(0, 0, 0);
            }
        }
Beispiel #20
0
        /*static bool MonitorCurrentLightLevels(Finch finchRobot, double threshold, int maxSeconds)
         * {
         *  bool thresholdExceeded = false;
         *  int currentLightLevel;
         *  double seconds = 0;
         *
         *
         *  while (!thresholdExceeded && seconds <= maxSeconds)
         *  {
         *      finchRobot.setLED(0, 255, 0);
         *
         *      currentLightLevel = finchRobot.getLeftLightSensor();
         *
         *      DisplayScreenHeader($"Monitor Light Levels");
         *      Console.WriteLine($"Maximum Light Level: {threshold}");
         *      Console.WriteLine($"Current Light Level: {currentLightLevel}");
         *
         *      if (currentLightLevel > threshold)
         *      {
         *          thresholdExceeded = true;
         *      }
         *
         *      finchRobot.wait(500);
         *      seconds += 0.5;
         *  }
         *
         *  finchRobot.setLED(0, 0, 0);
         *  return thresholdExceeded;
         * }*/

        /*static bool MonitorCurrentTemperatureLevels(Finch finchRobot, double threshold, int maxSeconds, string alarmType)
         * {
         *  bool thresholdExceeded = false;
         *  int currentLevel;
         *  double seconds = 0;
         *
         *  while (!thresholdExceeded && seconds <= maxSeconds)
         *  {
         *      finchRobot.setLED(0, 255, 0);
         *
         *      currentLevel = (int)finchRobot.getTemperature();
         *
         *      DisplayScreenHeader($"Monitor {alarmType} Levels");
         *      Console.WriteLine($"Maximum {alarmType} Level: {threshold}");
         *      Console.WriteLine($"Current {alarmType} Level: {currentLevel}");
         *
         *      if (currentLevel > threshold)
         *      {
         *          thresholdExceeded = true;
         *      }
         *
         *      finchRobot.wait(500);
         *      seconds += 0.5;
         *  }
         *
         *  return thresholdExceeded;
         * }*/

        static bool MonitorCurrentLevels(Finch finchRobot, double threshold, int maxSeconds, string alarmType)
        {
            bool   thresholdExceeded = false;
            int    currentLevel      = 0;
            double seconds           = 0;

            while (!thresholdExceeded && seconds <= maxSeconds)
            {
                if (alarmType == "temperature")
                {
                    currentLevel = (int)finchRobot.getTemperature();
                }
                else if (alarmType == "light")
                {
                    currentLevel = (int)finchRobot.getLeftLightSensor();
                }
                finchRobot.setLED(0, 255, 0);

                DisplayScreenHeader($"Monitor {alarmType} Levels");
                Console.WriteLine($"Maximum {alarmType} Level: {threshold}");
                Console.WriteLine($"Current {alarmType} Level: {currentLevel}");

                if (currentLevel > threshold)
                {
                    thresholdExceeded = true;
                }

                finchRobot.wait(500);
                seconds += 0.5;
            }

            return(thresholdExceeded);
        }
Beispiel #21
0
        /// <summary>
        /// *****************************************************************
        /// *               Data Recorder > Display Get Data                *
        /// *****************************************************************
        /// </summary>
        /// <param name="finchRobot">finch robot object</param>

        static double[] DataRecorderDisplayGetData(int numberOfDataPoints, double dataPointFrequency, Finch finchRobot)
        {
            double[] temperatures = new double[numberOfDataPoints];
            int      frequencyInSeconds;

            DisplayScreenHeader("Get The Data");

            // echo number of data points to user

            Console.WriteLine("The Finch Robot Will Now Record Temperatures");
            DisplayContinuePrompt();

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = finchRobot.getTemperature();
                Console.WriteLine($"Data Point #{index + 1}: {temperatures[index] * 9 / 5 + 32} farenheit");
                frequencyInSeconds = (int)(dataPointFrequency * 500);
                finchRobot.wait(frequencyInSeconds);
            }

            Console.WriteLine();
            Console.WriteLine("Current Data");
            DataRecorderDisplayDataTable(temperatures);
            Console.WriteLine();
            Console.WriteLine($"Average Tempurature: {temperatures.Average()}");

            DisplayContinuePrompt();

            return(temperatures);
        }
        static int LightAlarmSetMinMaxThresholValue(string rangeType, Finch finchRobot)
        {
            int minMaxThresholdValue;
            int minMaxTempValue;

            DisplayScreenHeader("Minimum/Maximum Threshold Value");


            Console.WriteLine($"Left light senor ambient value: {finchRobot.getLeftLightSensor()}");
            Console.WriteLine($"RIght light senor ambient value: {finchRobot.getRightLightSensor()}");
            Console.WriteLine();

            // validate value
            Console.WriteLine($"Enter the {rangeType} light sensor value:");
            int.TryParse(Console.ReadLine(), out minMaxThresholdValue);
            Console.WriteLine($"You have entered {minMaxThresholdValue} as your light sensor value");
            Console.WriteLine();

            // room temperature
            Console.WriteLine($"Room temperature: {finchRobot.getTemperature()}");

            // user response
            Console.WriteLine($"Enter the {rangeType} temperature value: ");
            int.TryParse(Console.ReadLine(), out minMaxTempValue);
            Console.WriteLine($"You have entered {minMaxTempValue} as your temperature value");
            Console.WriteLine();


            DisplayMenuPrompt("Light Alarm");

            return(minMaxThresholdValue);
        }
    static double[] DisplayGetData(int numberOfDataPoints, double dataPointFrequency, Finch finchRobot)
    {
        double[] temperatures = new double[numberOfDataPoints];
        DisplayScreenHeader("Get Data");

        Console.WriteLine($"\tNumber of data points: {numberOfDataPoints}");
        Console.WriteLine($"\tData point frequency: {dataPointFrequency}");
        Console.WriteLine();
        Console.WriteLine("The Finch robot will now record the temperature data.");
        DisplayContinuePrompt();

        for (int index = 0; index < numberOfDataPoints; index++)
        {
            temperatures[index] = finchRobot.getTemperature();
            Console.WriteLine($"\tReading{index + 1}: {temperatures[index].ToString("n2")}");
            int waitInSeconds = (int)(dataPointFrequency * 1000);
            finchRobot.wait(waitInSeconds);
        }

        DisplayContinuePrompt();
        DisplayScreenHeader("Get Data");

        Console.WriteLine();
        Console.WriteLine("\tTempertures Table");
        Console.WriteLine();
        DisplayTable(temperatures);

        DisplayContinuePrompt();

        return(temperatures);
    }
Beispiel #24
0
        /// <summary>
        /// How we get the data from the user.
        /// </summary>
        /// <param name="numberOfDataPoints"></param>
        /// <param name="dataPointFrequency"></param>
        /// <param name="Reznor"></param>
        /// <returns>Temperatures</returns>
        static double[] DataRecorderDisplayGetTemperatureData(int numberOfDataPoints, double dataPointFrequency, Finch Reznor)
        {
            double[] temperatures = new double[numberOfDataPoints];

            DisplayHeader("Get Data");

            Console.WriteLine($"\tNumber of data points: {numberOfDataPoints}");
            Console.WriteLine($"\t\nData point frequency: {dataPointFrequency}");
            Console.WriteLine("\n\tReznor is ready to begin recording the temperature data.");
            DisplayContinuePromt();
            // Set up a loop that will gather the data,
            // We need to get temp reading from finch,
            // echo reading back to user,
            // add that reading to element in array,
            // put a wait in, so it doesn't fly through very quickly.

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = Reznor.getTemperature();
                Console.WriteLine($"\tReading {index + 1}: {temperatures[index].ToString("n2")}");// .ToString("n2") will make it have only 2 decimal places.
                int waitInSeconds = (int)(dataPointFrequency * 1000);
                Reznor.wait(waitInSeconds);
            }

            DisplayContinuePromt();
            DisplayHeader("Get Data");

            Console.WriteLine("\t\nTable of Temperatures\n");

            DataRecorderDisplayTable(temperatures);

            DisplayContinuePromt();

            return(temperatures);
        }
        static double[] DataRecorderDisplayGetData(int numberOfDataPoints, double dataPointFrequency, Finch myFinch)
        {
            double[] temperatures = new double[numberOfDataPoints];

            DisplayScreenHeader("Get Data");

            Console.WriteLine("\tNumber of data points:{0}", numberOfDataPoints);
            Console.WriteLine("\tFrequency of data points:{0}", dataPointFrequency);
            Console.WriteLine();
            Console.WriteLine("\tThe Finch robot is ready to begin recording the temperature data.");
            DisplayContinuePrompt();

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = myFinch.getTemperature();
                Console.WriteLine("\tReading {0}: {1}", index + 1, temperatures[index].ToString("n2"));
                int waitInSeconds = (int)(dataPointFrequency * 1000);
                myFinch.wait(waitInSeconds);
            }

            DisplayContinuePrompt();
            DisplayScreenHeader("Get Data");

            Console.WriteLine();
            Console.WriteLine("\tTable of Data");
            Console.WriteLine();
            DataRecorderDisplayTable(temperatures);

            DisplayContinuePrompt();
            return(temperatures);
        }
Beispiel #26
0
        static void DisplayGetData(
            int numberOfDataPoints,
            double dataPointFrequency,
            double[] temperatures,
            Finch finchRobot)
        {
            DisplayScreenHeader("Get Temperature Data");

            Console.WriteLine("The finch robot is going to tell you the temperature in degrees Celsius.");
            for (int index = 0; index < numberOfDataPoints; index++)
            {
                //
                // record data
                //
                temperatures[index] = finchRobot.getTemperature();
                int milliseconds = (int)(dataPointFrequency * 1000);
                finchRobot.wait(milliseconds);

                //
                // echo data
                //
                Console.WriteLine($"Temperature {index + 1}: {temperatures[index]}");
            }

            DisplayContinuePrompt();
        }
Beispiel #27
0
        static double [] DataRecorderDisplayGetData(int numberOfDataPoints, double frequencyOfDataPoints, Finch finchRobot)
        {
            double[] temperatures = new double[numberOfDataPoints]; // Instatiating a new array
            DisplayScreenHeader("\tGet Temperatures");

            Console.WriteLine($"\tNumber of Temperatures: {numberOfDataPoints}");
            Console.WriteLine($"\tTemperature Frequency: {frequencyOfDataPoints}");
            Console.WriteLine();
            Console.WriteLine("\tThe Finch is now ready to begin recording the temperature data");
            DisplayContinuePrompt();


            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = finchRobot.getTemperature() * 9 / 5 + 32;

                Console.WriteLine($"\tReading {index + 1}:      {temperatures[index].ToString("n2")} °F".PadLeft(10));

                int waitInSeconds = (int)(frequencyOfDataPoints * 1000);
                finchRobot.wait(waitInSeconds);
            }



            DisplayContinuePrompt();

            return(temperatures);
        }
Beispiel #28
0
        static bool MonitorCurrentTemperatureLevel(Finch finchRobot, double threshold, int maxSeconds)
        {
            bool   thresholdExceeded = false;
            double currentTempLevel;
            double seconds = 0;

            while (!thresholdExceeded && seconds <= maxSeconds)
            {
                currentTempLevel = finchRobot.getTemperature();

                DisplayScreenHeader("Monitoring Temp Levels");
                Console.WriteLine($"Maximum Temp Level: {threshold}");
                Console.WriteLine($"Current Temp Level: {currentTempLevel}");

                if (currentTempLevel > threshold)
                {
                    thresholdExceeded = true;
                    Console.WriteLine("Threshold has been exceeded!");
                    DisplayContinuePrompt();
                }

                finchRobot.wait(500);
                seconds += 0.5;
            }

            return(thresholdExceeded);
        }
Beispiel #29
0
        /// <summary>
        /// Data Recorder > Get the Data Points
        /// </summary>
        /// <param name="numberOfDataPoints"></param>
        /// <param name="frequencyOfDataPointsSeconds"></param>
        /// <param name="myFinch"></param>
        /// <returns></returns>
        static double[] DataRecorderDisplayGetFrequencyOfDataSet(int numberOfDataPoints, double frequencyOfDataPointsSeconds, Finch myFinch)
        {
            double[] temperatures = new double[numberOfDataPoints];

            DisplayHeader("Get Data Set");

            Console.WriteLine($"\tNumber of Data Points: {numberOfDataPoints}");
            Console.WriteLine($"\tFrequency of Data Points: {frequencyOfDataPointsSeconds}");
            Console.WriteLine();

            Console.WriteLine("\tFinch robot is ready to record temperature data.");
            Console.WriteLine("\tPress any key to begin.");
            Console.ReadKey();

            double temperature;
            int    waitVariable;

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperature = myFinch.getTemperature();
                Console.WriteLine($"Temperature Reading {index + 1}: {temperature} C");
                temperatures[index] = temperature;
                waitVariable        = (int)(frequencyOfDataPointsSeconds * 1000);
                myFinch.wait(waitVariable);
            }

            return(temperatures);
        }
        static bool MonitorCurrentTemperature(Finch finchrobot, double threshold, int maxseconds)
        {
            bool   thresholdExceeded = false;
            double currentTemperature;
            double seconds = 0;

            while (!thresholdExceeded && seconds <= maxseconds)
            {
                finchrobot.setLED(0, 255, 0);
                DisplayScreenHeader("Monitoring Temperature");
                currentTemperature = finchrobot.getTemperature() * (9 / 5) + 32;
                Console.WriteLine($"Maximum Temperature: {threshold}\u00B0F");
                Console.WriteLine($"Current Temperature: {currentTemperature}\u00B0F");

                if (currentTemperature > threshold)
                {
                    thresholdExceeded = true;
                }

                finchrobot.wait(500);
                seconds += 0.5;
            }

            return(thresholdExceeded);
        }