Exemple #1
0
		public static SolarLogDataSet UpdateSolarLog(String URL)
		{
			SolarLogDataSet Output = null;

			// create a web client and get the data
			String fullURL = "http://"+URL+"/min_cur.js?nocache";

			WebClient client = new WebClient ();

			try
			{
				String SolarLogValue = client.DownloadString(fullURL);

				// hurray, we got a string!
				// let's parse it!

				String[] LbL = SolarLogValue.Replace("\r","").Split(new char[] {'\n'});

				Output = new SolarLogDataSet();

				foreach(String _line in LbL)
				{
					#region Pac
					if (_line.StartsWith("var Pac="))
					{
						Output.Pac = Convert.ToInt32(_line.Replace("var Pac=",""));
					}
					#endregion

					#region aPdc
					if (_line.StartsWith("var aPdc="))
					{
						String firstpart_removed = _line.Replace("var aPdc=new Array(","");
						Output.aPdc = Convert.ToInt32( firstpart_removed.Remove(firstpart_removed.IndexOf(',')));
					}
					#endregion
				}
			}
			catch(Exception e)
			{
				Console.WriteLine("Exception: "+e.Message);
				return null;
			}

			return Output;
		}
Exemple #2
0
        public static SolarLogDataSet UpdateSolarLog(String URL)
        {
            SolarLogDataSet Output = null;

            // create a web client and get the data
            String fullURL = "http://" + URL + "/min_cur.js?nocache";

            WebClient client = new WebClient();

            try
            {
                String SolarLogValue = client.DownloadString(fullURL);

                // hurray, we got a string!
                // let's parse it!

                String[] LbL = SolarLogValue.Replace("\r", "").Split(new char[] { '\n' });

                Output = new SolarLogDataSet();

                foreach (String _line in LbL)
                {
                    #region Pac
                    if (_line.StartsWith("var Pac="))
                    {
                        Output.Pac = Convert.ToInt32(_line.Replace("var Pac=", ""));
                    }
                    #endregion

                    #region aPdc
                    if (_line.StartsWith("var aPdc="))
                    {
                        String firstpart_removed = _line.Replace("var aPdc=new Array(", "");
                        Output.aPdc = Convert.ToInt32(firstpart_removed.Remove(firstpart_removed.IndexOf(',')));
                    }
                    #endregion
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
                return(null);
            }

            return(Output);
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("SolarLog Revere-Engineering Sample");

            SolarLogDataSet data = SolarLog.UpdateSolarLog("solarlog.fritz.box");
        }