/// <summary> /// Opens a system dialog box to request user permission to access sensor data. /// </summary> /// <param name="parentWindowHandle">The handle to a window that can act as a parent to the permissions dialog box.</param> /// <param name="modal">Specifies whether the window should be modal.</param> /// <param name="sensors">The sensors for which to request permission.</param> public static void RequestPermission(IntPtr parentWindowHandle, bool modal, SensorList <Sensor> sensors) { if (sensors == null || sensors.Count == 0) { throw new ArgumentException("LocalizedMessages.SensorManagerEmptySensorsCollection", "sensors"); } ISensorCollection sensorCollection = new SensorCollection(); foreach (Sensor sensor in sensors) { sensorCollection.Add(sensor.internalObject); } sensorManager.RequestPermissions(parentWindowHandle, sensorCollection, modal); }
/// <summary> /// Opens a system dialog box to request user permission to access sensor data. /// </summary> /// <param name="parentWindow">HWND handle to a window that can act as a parent to the permissions dialog box.</param> /// <param name="modal">Speficifies whether the window should be modal.</param> /// <param name="sensors">The sensors for which to request permission.</param> public static void RequestPermission(IntPtr parentWindow, bool modal, params Sensor[] sensors) { if (sensors == null || sensors.Length == 0) { throw new ArgumentNullException("sensors", "Sensors collection must not be null or empty."); } ISensorCollection sensorCollection = new SensorCollection(); foreach (Sensor sensor in sensors) { sensorCollection.Add((ISensor)sensor.InnerObject); } _sensorMgr.RequestPermissions(parentWindow, sensorCollection, modal); }
public SensorCollection Sniff(List <string> serials, CellCollection cells) { SensorCollection sensors = new SensorCollection(); string longSerial; string path; bool folderExists; //Search SN in every Folder foreach (string sn in serials) { folderExists = false; Sensor sensor = new Sensor(); longSerial = string.Format("SN{0}", sn); foreach (Cell cell in cells) { path = string.Format("{0}\\{1}\\", cell.Location, longSerial); if (Directory.Exists(path)) { //read sensor model Reader reader = new Reader(); sensor = reader.ReadLastTask(path, longSerial); //read SN00XXXXX.xml folderExists = true; break; } } if (!folderExists) { sensor.Sn = longSerial; sensor.Location = "In all locations"; sensor.Model = "No Folder"; } sensors.Add(sensor); } return(sensors); }
//********************************************************************************************************** //** Collect SensorCollection ** //********************************************************************************************************** public SensorCollection ReadCell(string location) { SensorCollection sensors = new SensorCollection(); string sn; if (Directory.Exists(location)) { foreach (string path in Directory.GetDirectories(location)) { sn = path.Remove(0, location.Length + 1); if (!sn.StartsWith("SN")) { continue; } string verPath = path + "\\" + sn + ".xml"; //path to main XML file Sensor sensor = new Sensor(); Regex rgx = new Regex(@"[^0-9]"); if (!File.Exists(verPath)) { sensor.Sn = -1; sensor.Model = string.Format("No file {0}.xml", sn); sensor.Location = path; } else { //sensor.Time = File.GetLastWriteTime(verPath).ToUniversalTime().ToString(); sensor.Time = File.GetLastWriteTime(verPath).ToLocalTime(); XmlDocument doc = new XmlDocument(); if (IsValidXml(verPath)) { doc.Load(verPath); XmlNodeList nodes = doc.DocumentElement.SelectNodes("/Entries/Entries/Item"); //bool f = false;// foreach (XmlNode node in nodes) { if (!node.SelectSingleNode("SensorModel").InnerText.Equals("")) { sensor.Model = node.SelectSingleNode("SensorModel").InnerText; } if (!node.SelectSingleNode("SensorId").InnerText.Equals("")) { var sntext = node.SelectSingleNode("SensorId").InnerText; //remove symbols var snnumb = rgx.Replace(sntext, ""); //remove leading zerros int number; bool result = Int32.TryParse(snnumb, out number); if (result) { sensor.Sn = number; } else { sensor.Sn = -3; } } if (node.SelectSingleNode("Type").InnerText.Equals("Initialize")) { if (node.SelectSingleNode("Values") != null) { foreach (XmlNode innerNode in node.SelectSingleNode("Values")) { if (innerNode.Name.Equals("WorkOrder")) { sensor.Wip = innerNode.InnerText; //f = true; } } } } sensor.Location = path; } } else { sensor.Sn = -2; sensor.Model = string.Format("{0}.xml is not valid", sn); sensor.Location = path; } } sensors.Add(sensor); } } return(sensors); }