public static bool GetTemperature(RequestReceivedEventArgs e, JsonArray h)
        {
            try
            {
                DateTime timeOfReading = DateTime.Now;

                JsonObject reading = new JsonObject();
                reading.Add("timeOfReading", timeOfReading.ToString());
                reading.Add("temperatureCelsius", PinManagement.temperatureCelsiusSensor.ToString("f2"));
                reading.Add("temperatureFahrenheit", PinManagement.currentTemperatureSensor.ToString("f2"));
                reading.Add("isHeating", PinManagement.isHeating.ToString());
                reading.Add("pidOutput", PinManagement.currentPIDOuput.ToString("f2"));
                reading.Add("setTemperature", PinManagement.setTemperature.ToString("f2"));

                if ((PinManagement.mashSteps != null) && (PinManagement.mashSteps.CurrentStep != null))
                {
                    reading.Add("currentMashStep", PinManagement.mashSteps.CurrentStep.StepNumber.ToString());
                    reading.Add("currentMashTemp", PinManagement.mashSteps.CurrentStep.Temperature.ToString("f2"));
                    TimeSpan timeInterval = DateTime.Now.Subtract(PinManagement.currentMashStepStartTime);
                    reading.Add("currentMashTime", timeInterval.Minutes);
                }

                h.Add(reading);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            return true;
        }
        public static bool GetSettings(RequestReceivedEventArgs e, JsonArray h)
        {
            try
            {
                Settings settings = new Settings();
                settings.loadSettings();

                JsonObject settingsValues = new JsonObject();
                settingsValues.Add("timeZoneOffset", settings.TimeZoneOffset.ToString());
                float value = settings.MinutesBetweenReadings / 60000;
                settingsValues.Add("minutesBetweenReadings", value.ToString("f2"));
                settingsValues.Add("temperatureOffset", settings.TemperatureOffset.ToString("f2"));
                settingsValues.Add("temperatureHeaterOffset", settings.TemperatureHeaterOffset.ToString("f2"));
                settingsValues.Add("historyFilename", settings.HistoryFilename);
                settingsValues.Add("ntpServerName", settings.NTPServerName);
                int tempValue = settings.MinutesBetweenNTPUpdate / 60000;
                settingsValues.Add("minutesBetweenNTPUpdate", tempValue.ToString());
                settingsValues.Add("netbiosName", settings.NetBiosName);
                settingsValues.Add("enableDHCP", settings.EnableDHCP.ToString());
                settingsValues.Add("staticIPAddress", settings.StaticIPAddress);
                settingsValues.Add("subnetMask", settings.SubnetMask);
                settingsValues.Add("defaultGateway", settings.DefaultGateway);
                settingsValues.Add("primaryDNSAddress", settings.PrimaryDNSAddress);
                settingsValues.Add("secondaryDNSAddress", settings.SecondaryDNSAddress);
                settingsValues.Add("voltageReference", settings.VoltageReference);
                settingsValues.Add("padResistance", settings.PadResistance);
                settingsValues.Add("resistanceRT", settings.ResistanceRT);
                settingsValues.Add("coefficientA", settings.CoefficientA);
                settingsValues.Add("coefficientB", settings.CoefficientB);
                settingsValues.Add("coefficientC", settings.CoefficientC);
                settingsValues.Add("coefficientD", settings.CoefficientD);
                settingsValues.Add("kpValue", settings.PIDKp);
                settingsValues.Add("kiValue", settings.PIDKi);
                settingsValues.Add("kdValue", settings.PIDKd);

                h.Add(settingsValues);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            return true;
        }
        /// <summary>
        /// Convert a value to JSON.
        /// </summary>
        /// <param name="o">The value to convert. Supported types are: Boolean, String, Byte, (U)Int16, (U)Int32, Float, Double, Decimal, JsonObject, JsonArray, Array, Object and null.</param>
        /// <returns>The JSON object as a string or null when the value type is not supported.</returns>
        /// <remarks>For objects, only public fields are converted.</remarks>
        public static string ToJson(object o)
        {
            if (o == null)
                return "null";

            Type type = o.GetType();
            switch (type.Name)
            {
                case "Boolean":
                    return (bool)o ? "true" : "false";
                case "String":
                    return "\"" + JsEncode((string)o) + "\"";
                case "Byte":
                case "Int16":
                case "UInt16":
                case "Int32":
                case "UInt32":
                case "Single":
                case "Double":
                case "Decimal":
                case "JsonObject":
                case "JsonArray":
                    return o.ToString();
            }

            if (type.IsArray)
            {
                JsonArray jsonArray = new JsonArray();
                foreach (object i in (Array)o)
                    jsonArray.Add(i);
                return jsonArray.ToString();
            }

            if (type.IsClass)
            {
                JsonObject jsonObject = new JsonObject();
                FieldInfo[] fields = type.GetFields();
                foreach (FieldInfo info in fields)
                    jsonObject.Add(info.Name, info.GetValue(o));
                return jsonObject.ToString();
            }

            return null;
        }
 /// <summary>
 /// Returns the responses added to the webserver
 /// </summary>
 /// <param name="e"></param>
 /// <param name="h"></param>
 /// <returns></returns>
 private void ResponseListJSON(Request e, JsonArray j)
 {
     JsonObject o;
     foreach ( Object k in _Responses.Keys )
     {
         if ( _Responses[k] as JSONResponse != null )
         {
             o = new JsonObject( );
             o.Add("methodURL", k);
             o.Add("methodInternalName", ( (Response)_Responses[k] ).URL);
             j.Add(o);
         }
     }
 }