예제 #1
0
        public string GetStationAlpacaFormData()
        {
            // Build the settings data, convert to JSON, and return it
            var options = new JsonStationSettingsOptions()
            {
                usezerobearing         = cumulus.UseZeroBearing,
                calcwindaverage        = cumulus.UseWind10MinAve,
                usespeedforavg         = cumulus.UseSpeedForAvgCalc,
                use100for98hum         = cumulus.Humidity98Fix,
                calculatedewpoint      = cumulus.CalculatedDP,
                calculatewindchill     = cumulus.CalculatedWC,
                syncstationclock       = cumulus.SyncTime,
                cumuluspresstrendnames = cumulus.UseCumulusPresstrendstr,
                vp1minbarupdate        = cumulus.ForceVPBarUpdate,
                extrasensors           = cumulus.LogExtraSensors,
                ignorelacrosseclock    = cumulus.WS2300IgnoreStationClock,
                roundwindspeeds        = cumulus.RoundWindSpeed,
                synchroniseforeads     = cumulus.SyncFOReads,
                debuglogging           = cumulus.logging,
                datalogging            = cumulus.DataLogging,
                stopsecondinstance     = cumulus.WarnMultiple,
                readreceptionstats     = cumulus.DavisReadReceptionStats
            };

            var units = new JsonStationSettingsUnits()
            {
                wind     = cumulus.WindUnit,
                pressure = cumulus.PressUnit,
                temp     = cumulus.TempUnit,
                rain     = cumulus.RainUnit
            };

            var tcpsettings = new JsonStationSettingsTCPsettings()
            {
                ipaddress    = cumulus.VP2IPAddr,
                tcpport      = cumulus.VP2TCPPort,
                disconperiod = cumulus.VP2PeriodicDisconnectInterval
            };

            var davisconn = new JsonStationSettingsDavisConn()
            {
                conntype = cumulus.VP2ConnectionType, tcpsettings = tcpsettings
            };

            var gw1000 = new JSonStationSettingsGw1000Conn()
            {
                ipaddress = cumulus.Gw1000IpAddress, autoDiscover = cumulus.Gw1000AutoUpdateIpAddress
            };

            var logrollover = new JsonStationSettingsLogRollover()
            {
                time = "midnight", summer10am = cumulus.Use10amInSummer
            };

            if (cumulus.RolloverHour == 9)
            {
                logrollover.time = "9am";
            }

            int    deg, min, sec;
            string hem;

            LatToDMS(cumulus.Latitude, out deg, out min, out sec, out hem);

            var Latitude = new JsonStationSettingsLatLong()
            {
                degrees = deg, minutes = min, seconds = sec, hemisphere = hem
            };

            LongToDMS(cumulus.Longitude, out deg, out min, out sec, out hem);

            var Longitude = new JsonStationSettingsLatLong()
            {
                degrees = deg, minutes = min, seconds = sec, hemisphere = hem
            };

            var Location = new JsonStationSettingsLocation()
            {
                altitude     = (int)cumulus.Altitude,
                altitudeunit = "metres",
                description  = cumulus.LocationDesc,
                Latitude     = Latitude,
                Longitude    = Longitude,
                sitename     = cumulus.LocationName
            };

            if (cumulus.AltitudeInFeet)
            {
                Location.altitudeunit = "feet";
            }

            var forecast = new JsonStationSettingsForecast()
            {
                highpressureextreme = cumulus.FChighpress,
                lowpressureextreme  = cumulus.FClowpress,
                pressureunit        = "mb/hPa",
                updatehourly        = cumulus.HourlyForecast,
                usecumulusforecast  = cumulus.UseCumulusForecast
            };

            if (!cumulus.FCpressinMB)
            {
                forecast.pressureunit = "inHg";
            }

            var solar = new JsonStationSettingsSolar()
            {
                solarmin       = cumulus.SolarMinimum,
                transfactor    = cumulus.RStransfactor,
                sunthreshold   = cumulus.SunThreshold,
                useblakelarsen = cumulus.UseBlakeLarsen,
                solarcalc      = cumulus.SolarCalc,
                turbidity      = cumulus.BrasTurbidity
            };

            var annualrainfall = new JsonStationSettingsAnnualRainfall()
            {
                rainseasonstart = cumulus.RainSeasonStart, ytdamount = cumulus.YTDrain, ytdyear = cumulus.YTDrainyear
            };

            var graphs = new JsonStationSettingsGraphs()
            {
                graphdays         = cumulus.GraphDays,
                graphhours        = cumulus.GraphHours,
                graphTempVis      = cumulus.GraphOptions.TempVisible,
                graphInTempVis    = cumulus.GraphOptions.InTempVisible,
                graphHeatIndexVis = cumulus.GraphOptions.HIVisible,
                graphDewPointVis  = cumulus.GraphOptions.DPVisible,
                graphWindChillVis = cumulus.GraphOptions.WCVisible,
                graphAppTempVis   = cumulus.GraphOptions.AppTempVisible,
                graphFeelsLikeVis = cumulus.GraphOptions.FeelsLikeVisible,
                graphHumidexVis   = cumulus.GraphOptions.HumidexVisible,
                graphHumVis       = cumulus.GraphOptions.OutHumVisible,
                graphInHumVis     = cumulus.GraphOptions.InHumVisible,
                graphUvVis        = cumulus.GraphOptions.UVVisible
            };

            var wllNetwork = new JsonStationSettingsWLLNetwork()
            {
                autoDiscover = cumulus.WLLAutoUpdateIpAddress
            };

            var wllApi = new JsonStationSettingsWLLApi()
            {
                apiKey       = cumulus.WllApiKey,
                apiSecret    = cumulus.WllApiSecret,
                apiStationId = cumulus.WllStationId
            };

            var wllPrimary = new JsonStationSettingsWllPrimary()
            {
                wind    = cumulus.WllPrimaryWind,
                temphum = cumulus.WllPrimaryTempHum,
                rain    = cumulus.WllPrimaryRain,
                solar   = cumulus.WllPrimarySolar,
                uv      = cumulus.WllPrimaryUV
            };

            var wllExtraSoilTemp = new JsonStationSettingsWllSoilTemp()
            {
                soilTempTx1  = cumulus.WllExtraSoilTempTx1,
                soilTempIdx1 = cumulus.WllExtraSoilTempIdx1,
                soilTempTx2  = cumulus.WllExtraSoilTempTx2,
                soilTempIdx2 = cumulus.WllExtraSoilTempIdx2,
                soilTempTx3  = cumulus.WllExtraSoilTempTx3,
                soilTempIdx3 = cumulus.WllExtraSoilTempIdx3,
                soilTempTx4  = cumulus.WllExtraSoilTempTx4,
                soilTempIdx4 = cumulus.WllExtraSoilTempIdx4
            };

            var wllExtraSoilMoist = new JsonStationSettingsWllSoilMoist()
            {
                soilMoistTx1  = cumulus.WllExtraSoilMoistureTx1,
                soilMoistIdx1 = cumulus.WllExtraSoilMoistureIdx1,
                soilMoistTx2  = cumulus.WllExtraSoilMoistureTx2,
                soilMoistIdx2 = cumulus.WllExtraSoilMoistureIdx2,
                soilMoistTx3  = cumulus.WllExtraSoilMoistureTx3,
                soilMoistIdx3 = cumulus.WllExtraSoilMoistureIdx3,
                soilMoistTx4  = cumulus.WllExtraSoilMoistureTx4,
                soilMoistIdx4 = cumulus.WllExtraSoilMoistureIdx4
            };

            var wllExtraLeaf = new JsonStationSettingsWllExtraLeaf()
            {
                leafTx1  = cumulus.WllExtraLeafTx1,
                leafIdx1 = cumulus.WllExtraLeafIdx1,
                leafTx2  = cumulus.WllExtraLeafTx2,
                leafIdx2 = cumulus.WllExtraLeafIdx2
            };

            var wllSoilLeaf = new JsonStationSettingsWllSoilLeaf()
            {
                extraSoilTemp  = wllExtraSoilTemp,
                extraSoilMoist = wllExtraSoilMoist,
                extraLeaf      = wllExtraLeaf
            };

            var wllExtraTemp = new JsonStationSettingsWllExtraTemp();

            for (int i = 1; i <= 8; i++)
            {
                PropertyInfo propInfo = wllExtraTemp.GetType().GetProperty("extraTempTx" + i);
                propInfo.SetValue(wllExtraTemp, Convert.ChangeType(cumulus.WllExtraTempTx[i - 1], propInfo.PropertyType), null);

                propInfo = wllExtraTemp.GetType().GetProperty("extraHumTx" + i);
                propInfo.SetValue(wllExtraTemp, Convert.ChangeType(cumulus.WllExtraHumTx[i - 1], propInfo.PropertyType), null);
            }
            ;

            var wll = new JsonStationSettingsWLL()
            {
                network   = wllNetwork,
                api       = wllApi,
                primary   = wllPrimary,
                soilLeaf  = wllSoilLeaf,
                extraTemp = wllExtraTemp
            };

            var data = new JsonStationSettingsData()
            {
                stationtype    = cumulus.StationType,
                units          = units,
                davisconn      = davisconn,
                daviswll       = wll,
                gw1000         = gw1000,
                comportname    = cumulus.ComportName,
                loginterval    = cumulus.DataLogInterval,
                logrollover    = logrollover,
                Location       = Location,
                Options        = options,
                Forecast       = forecast,
                Solar          = solar,
                AnnualRainfall = annualrainfall,
                Graphs         = graphs
            };

            return(JsonConvert.SerializeObject(data));
        }
예제 #2
0
        public string GetStationAlpacaFormData()
        {
            // Build the settings data, convert to JSON, and return it
            var options = new JsonStationSettingsOptions()
            {
                usezerobearing         = cumulus.UseZeroBearing,
                calcwindaverage        = cumulus.UseWind10MinAve,
                usespeedforavg         = cumulus.UseSpeedForAvgCalc,
                use100for98hum         = cumulus.Humidity98Fix,
                calculatedewpoint      = cumulus.CalculatedDP,
                calculatewindchill     = cumulus.CalculatedWC,
                syncstationclock       = cumulus.SyncTime,
                cumuluspresstrendnames = cumulus.UseCumulusPresstrendstr,
                vp1minbarupdate        = cumulus.ForceVPBarUpdate,
                extrasensors           = cumulus.LogExtraSensors,
                ignorelacrosseclock    = cumulus.WS2300IgnoreStationClock,
                roundwindspeeds        = cumulus.RoundWindSpeed,
                synchroniseforeads     = cumulus.SyncFOReads,
                debuglogging           = cumulus.logging,
                datalogging            = cumulus.DataLogging,
                stopsecondinstance     = cumulus.WarnMultiple,
                readreceptionstats     = cumulus.DavisReadReceptionStats
            };

            var units = new JsonStationSettingsUnits()
            {
                wind     = cumulus.WindUnit,
                pressure = cumulus.PressUnit,
                temp     = cumulus.TempUnit,
                rain     = cumulus.RainUnit
            };

            var tcpsettings = new JsonStationSettingsTCPsettings()
            {
                ipaddress    = cumulus.VP2IPAddr,
                tcpport      = cumulus.VP2TCPPort,
                disconperiod = cumulus.VP2PeriodicDisconnectInterval
            };

            var davisconn = new JsonStationSettingsDavisConn()
            {
                conntype = cumulus.VP2ConnectionType, tcpsettings = tcpsettings
            };

            var logrollover = new JsonStationSettingsLogRollover()
            {
                time = "midnight", summer10am = cumulus.Use10amInSummer
            };

            if (cumulus.RolloverHour == 9)
            {
                logrollover.time = "9am";
            }

            int    deg, min, sec;
            string hem;

            LatToDMS(cumulus.Latitude, out deg, out min, out sec, out hem);

            var Latitude = new JsonStationSettingsLatLong()
            {
                degrees = deg, minutes = min, seconds = sec, hemisphere = hem
            };

            LongToDMS(cumulus.Longitude, out deg, out min, out sec, out hem);

            var Longitude = new JsonStationSettingsLatLong()
            {
                degrees = deg, minutes = min, seconds = sec, hemisphere = hem
            };

            var Location = new JsonStationSettingsLocation()
            {
                altitude     = (int)cumulus.Altitude,
                altitudeunit = "metres",
                description  = cumulus.LocationDesc,
                Latitude     = Latitude,
                Longitude    = Longitude,
                sitename     = cumulus.LocationName
            };

            if (cumulus.AltitudeInFeet)
            {
                Location.altitudeunit = "feet";
            }

            var forecast = new JsonStationSettingsForecast()
            {
                highpressureextreme = cumulus.FChighpress,
                lowpressureextreme  = cumulus.FClowpress,
                pressureunit        = "mb/hPa",
                updatehourly        = cumulus.HourlyForecast,
                usecumulusforecast  = cumulus.UseCumulusForecast
            };

            if (!cumulus.FCpressinMB)
            {
                forecast.pressureunit = "inHg";
            }

            var solar = new JsonStationSettingsSolar()
            {
                solarmin       = cumulus.SolarMinimum,
                transfactor    = cumulus.RStransfactor,
                sunthreshold   = cumulus.SunThreshold,
                useblakelarsen = cumulus.UseBlakeLarsen,
                solarcalc      = cumulus.SolarCalc,
                turbidity      = cumulus.BrasTurbidity
            };

            var annualrainfall = new JsonStationSettingsAnnualRainfall()
            {
                rainseasonstart = cumulus.RainSeasonStart, ytdamount = cumulus.YTDrain, ytdyear = cumulus.YTDrainyear
            };

            var graphs = new JsonStationSettingsGraphs()
            {
                graphdays = cumulus.GraphDays, graphhours = cumulus.GraphHours
            };

            var data = new JsonStationSettingsData()
            {
                stationtype    = cumulus.StationType,
                units          = units,
                davisconn      = davisconn,
                comportname    = cumulus.ComportName,
                loginterval    = cumulus.DataLogInterval,
                logrollover    = logrollover,
                Location       = Location,
                Options        = options,
                Forecast       = forecast,
                Solar          = solar,
                AnnualRainfall = annualrainfall,
                Graphs         = graphs
            };

            return(JSON.ToJSON(data));
        }