// Query additional status parameters public List <statusParameter> getSystemParams(string systemParams) { // Capture status parameters not available in systemstatus.xml // System variables are taken directly from HDX profile so they can be retrieved even if no // "get" command exists in the API. Variables are in the form "config.variableName" var status = new List <statusParameter>(); var url = "http://" + ipAddress + "/querystatus.cgi?variables=" + systemParams; var request = prepareRequest(url); try { var xr = XmlReader.Create(request.GetResponse().GetResponseStream()); var state = new List <string>(); while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element & xr.Name == "variable") { var paramName = xr.GetAttribute("name").Replace("config.", "").ToUpper(); // Queries do not return "up" or "down", so this has to be manually determined xr.Read(); if (xr.Value.ToLower().Equals("connected") | xr.Value.ToLower().Equals("true")) { state.Add("up"); } else { state.Add("down"); } var newParam = new statusParameter { label = paramName, state = state.ToArray() }; status.Add(newParam); state.Clear(); } } xr.Close(); } catch (Exception ex) { throw; } return(status); }
// Collect all status indicators from "systemstatus.xml" public override List <string> getStatus() { var status = new List <statusParameter>(); var url = "http://" + ipAddress + "/systemstatus.xml"; try { var request = prepareRequest(url); var xelement = XElement.Load(request.GetResponse().GetResponseStream()); foreach (XElement element in xelement.Elements()) { var param = new statusParameter(); var stateList = new List <string>(); // Read element name into statusParameter label property param.label = element.Name.ToString(); // There may be more than one "state" value, so get them all foreach (string item in element.Elements("STATE")) { stateList.Add(item); } // Converty ArrayList to String() for the statusParameter state property param.state = stateList.ToArray(); // Add complete statusParameter object to list status.Add(param); } // Add additional status queries not available in systemstatus.xml status.AddRange(getSystemParams("config.touchpanelstatus;config.remotesyslogenable")); } catch (Exception ex) { throw; } var statusList = toStringList(status); return(statusList); }