View Single Post
Unread 05-09-2012, 06:47 PM   #17
palmtreefrb
Full Fledged Farker

 
palmtreefrb's Avatar
 
Join Date: 01-22-11
Location: Buena Park, CA
Downloads: 0
Uploads: 0
Default

Ok, here you go. I'm terrible at documentation, code is worth a thousand words

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.IO;
using System.Xml.Linq;

namespace CyberQWifi
{

/// <summary>
/// Summary description for CyberQData
/// </summary>
///

public class CyberQObjectModel
{
public decimal OUTPUT_PERCENT { get; set; }
public TimeSpan TIMER_CURR { get; set; }
public int COOK_TEMP { get; set; }
public int FOOD1_TEMP { get; set; }
public int FOOD2_TEMP { get; set; }
public int FOOD3_TEMP { get; set; }
public int COOK_STATUS { get; set; }
public int FOOD1_STATUS { get; set; }
public int FOOD2_STATUS { get; set; }
public int FOOD3_STATUS { get; set; }
public int TIMER_STATUS { get; set; }
public int DEG_UNITS { get; set; }
public int COOK_PROPBAND { get; set; }
public int COOK_RAMP { get; set; }

public CyberQObjectModel()
{
OUTPUT_PERCENT = 0m;
TIMER_CURR = TimeSpan.Zero;
COOK_TEMP = 0;
FOOD1_TEMP = 0;
FOOD2_TEMP = 0;
FOOD3_TEMP = 0;
COOK_STATUS = 0;
FOOD1_STATUS = 0;
FOOD2_STATUS = 0;
FOOD3_STATUS = 0;
TIMER_STATUS = 0;
DEG_UNITS = 0;
COOK_PROPBAND = 0;
COOK_RAMP = 0;

}
}

public class CyberQData
{
public CyberQData() { }

public static CyberQObjectModel GetCyberQData(string url)
{
var xdocTimeInfo = XDocument.Load(url);
var dt = (from ti in xdocTimeInfo.Descendants("nutcstatus")
select new
{
OUTPUT_PERCENT = ti.Element("OUTPUT_PERCENT").Value,
TIMER_CURR = ti.Element("TIMER_CURR").Value,

COOK_TEMP = ti.Element("COOK_TEMP").Value,
FOOD1_TEMP = ti.Element("FOOD1_TEMP").Value,
FOOD2_TEMP = ti.Element("FOOD2_TEMP").Value,
FOOD3_TEMP = ti.Element("FOOD3_TEMP").Value,

COOK_STATUS = ti.Element("COOK_STATUS").Value,
FOOD1_STATUS = ti.Element("FOOD1_STATUS").Value,
FOOD2_STATUS = ti.Element("FOOD2_STATUS").Value,
FOOD3_STATUS = ti.Element("FOOD3_STATUS").Value,

TIMER_STATUS = ti.Element("TIMER_STATUS").Value,
DEG_UNITS = ti.Element("DEG_UNITS").Value,
COOK_PROPBAND = ti.Element("COOK_PROPBAND").Value,
COOK_RAMP = ti.Element("COOK_RAMP").Value

}).FirstOrDefault();
var cyberQom = new CyberQObjectModel
{
COOK_PROPBAND = dt.COOK_PROPBAND.SafeReadObject<int>(0),
COOK_RAMP = dt.COOK_RAMP.SafeReadObject<int>(0),
COOK_STATUS = dt.COOK_STATUS.SafeReadObject<int>(0),
COOK_TEMP = dt.COOK_TEMP.SafeReadObject<int>(0),
DEG_UNITS = dt.DEG_UNITS.SafeReadObject<int>(0),
FOOD1_STATUS = dt.FOOD1_STATUS.SafeReadObject<int>(0),
FOOD1_TEMP = dt.FOOD1_TEMP.SafeReadObject<int>(0),
FOOD2_STATUS = dt.FOOD2_STATUS.SafeReadObject<int>(0),
FOOD2_TEMP = dt.FOOD2_TEMP.SafeReadObject<int>(0),
FOOD3_STATUS = dt.FOOD3_STATUS.SafeReadObject<int>(0),
FOOD3_TEMP = dt.FOOD3_TEMP.SafeReadObject<int>(0),
OUTPUT_PERCENT = dt.OUTPUT_PERCENT.SafeReadObject<decimal>(0m),
TIMER_CURR = TimeSpan.Parse(dt.TIMER_CURR).SafeReadObject<TimeS pan>(TimeSpan.Zero),
TIMER_STATUS = dt.TIMER_STATUS.SafeReadObject<int>(0)
};

return cyberQom;
}
}
}

And here is the implementation... YAY WE HAVE DATA



Ill start working on charting next and a way to save the chart for future reference.
palmtreefrb is offline   Reply With Quote