/// <summary> /// Adds a list of drivers to the driverHash and to the equivalence tree. /// </summary> /// <param name="drivers">Objects representing the interfaces of the Drivers to be added</param> public void AddToEquivalenceTree(List <UpDriver> drivers) { int removeTries = 0; while (drivers.Count > 0) { UpDriver driver = drivers[0]; try { AddToEquivalenceTree(driver); drivers.Remove(driver); removeTries = 0; } catch (DriverNotFoundException) { drivers.Remove(driver); drivers.Add(driver); removeTries++; } if ((removeTries == drivers.Count) && (removeTries != 0)) { throw new InterfaceValidationException("The driver did not informe the complete list of equivalent drivers."); } } }
/// <summary> /// This method is responsible for informing the unknown equivalent driverss. /// </summary> /// <param name="serviceCall"></param> /// <param name="serviceResponse"></param> /// <param name="messageContext"></param> public void TellEquivalentDrivers(Call serviceCall, Response serviceResponse, CallContext messageContext) { try { string equivalentDrivers = serviceCall.GetParameterString(DRIVERS_NAME_KEY); IList <object> equivalentDriversJson = Json.Deserialize(equivalentDrivers) as IList <object>; List <object> jsonList = new List <object>(); IDictionary <string, object> responseData = new Dictionary <string, object>(); for (int i = 0; i < equivalentDriversJson.Count; i++) { string equivalentDriver = equivalentDriversJson[i] as string; UpDriver driver = gateway.driverManager.GetDriverFromEquivalanceTree(equivalentDriver); if (driver != null) { AddToEquivalanceList(jsonList, driver); } } responseData[INTERFACES_KEY] = Json.Serialize(jsonList); serviceResponse.responseData = responseData; } catch (System.Exception e) { logger.LogError("Problems on equivalent drivers. " + e.StackTrace); } }
public DriverModel(long?rowid, string id, UpDriver driver, string device) { this.rowid = rowid; this.id = id; this.driver = driver; this.device = device; }
public DriverModel(long? rowid, string id, UpDriver driver, string device) { this.rowid = rowid; this.id = id; this.driver = driver; this.device = device; }
/// <summary> /// Deploys a driver into the context. /// </summary> /// <param name="instance">Instance of the object implementing the informed Driver.</param> /// <param name="instanceId">Optional instanceId which to call this instance of the driver.</param> public void DeployDriver(UOSDriver instance, string instanceId = null) { UpDriver driver = instance.GetDriver(); if (instanceId == null) { instanceId = driver.name + IncDeployedDriversCount(); } DriverModel model = new DriverModel(instanceId, instance.GetDriver(), this.currentDevice.name); if (!driverHash.ContainsKey(driver.name)) { if (instance.GetParent() != null) { AddToEquivalenceTree(instance.GetParent()); } AddToEquivalenceTree(driver); } lock (_driverdao_lock) { driverDao.Insert(model); } instances[model.rowid] = instance; toInitialize.Add(instanceId); logger.Log("Deployed Driver : " + model.driver.name + " with id " + instanceId); }
/// <summary> /// Adds the driver to the driverHash and to the equivalence tree. /// </summary> /// <param name="driver">Object representing the interface of the Driver to be added</param> public void AddToEquivalenceTree(UpDriver driver) { TreeNode node = new TreeNode(driver); List <string> equivalentDrivers = driver.equivalentDrivers; HashSet <string> driversNotFound = new HashSet <string>(); if (equivalentDrivers != null) { foreach (string equivalentDriver in equivalentDrivers) { TreeNode parent = null; if (!driverHash.TryGetValue(equivalentDriver, out parent)) { driversNotFound.Add(equivalentDriver); } else { ValidateInterfaces(parent.driver.services, node.driver.services); ValidateInterfaces(parent.driver.events, node.driver.events); parent.AddChild(node); } } } else { tree.Add(node); } if (driversNotFound.Count > 0) { throw new DriverNotFoundException("Equivalent drivers not found.", driversNotFound); } driverHash[driver.name] = node; }
public UpWebElement SendKeys(string text) { UpDriver.WaitForPageReady(); Log.GetLogger().Info($"Sending [{text}] to element [{ElementIdentifier}]"); WrappedElement.SendKeys(text); return(this); }
public UpWebElement Click() { UpDriver.WaitForPageReady(); Log.GetLogger().Info($"Clicking element [{ElementIdentifier}]"); WrappedElement.Click(); return(this); }
public TreeNode(UpDriver driver) { if (driver == null) { throw new System.ArgumentNullException("Driver cannot be null."); } this.driver = driver; this.parent = new List <TreeNode>(); this.children = new List <TreeNode>(); }
private void AddToEquivalanceList(IList <object> jsonList, UpDriver upDriver) { IList <string> equivalentDrivers = upDriver.equivalentDrivers; if (equivalentDrivers != null) { foreach (string equivalentDriver in equivalentDrivers) { UpDriver driver = gateway.driverManager.GetDriverFromEquivalanceTree(equivalentDriver); if (driver != null) { AddToEquivalanceList(jsonList, driver); } } } jsonList.Add(upDriver.ToJSON()); }
public DeviceDriver() { driver = new UpDriver("uos.DeviceDriver"); driver.AddService("listDrivers") .AddParameter(DRIVER_NAME_KEY, UpService.ParameterType.OPTIONAL); //driver.AddService("authenticate") // .AddParameter(SECURITY_TYPE_KEY, UpService.ParameterType.MANDATORY); driver.AddService("goodbye"); driver.AddService("handshake") .AddParameter(DEVICE_KEY, UpService.ParameterType.MANDATORY); driver.AddService("tellEquivalentDriver") .AddParameter(DRIVER_NAME_KEY, UpService.ParameterType.MANDATORY); }
private void RegisterRemoteDriverInstances(UpDevice upDevice, IDictionary <string, object> driversListMap, string[] instanceIds) { foreach (string id in instanceIds) { object instance = driversListMap[id]; if (instance is string) { instance = Json.Deserialize(instance as string); } UpDriver upDriver = UpDriver.FromJSON(instance); DriverModel driverModel = new DriverModel(id, upDriver, upDevice.name); try { driverManager.Insert(driverModel); } catch (DriverNotFoundException e) { unknownDrivers.UnionWith(e.driversNames); dependents.Add(driverModel); } catch (System.Exception) { logger.LogError( "Problems occurred in the registering of driver '" + upDriver.name + "' with instanceId '" + id + "' in the device '" + upDevice.name + "' and it will not be registered."); } } if (unknownDrivers.Count > 0) { FindDrivers(unknownDrivers, upDevice); } }
private void FindDrivers(HashSet <string> unknownDrivers, UpDevice upDevice) { Call call = new Call(DEVICE_DRIVER_NAME, "tellEquivalentDrivers", null); call.AddParameter(DRIVERS_NAME_KEY, Json.Serialize(new List <string>(unknownDrivers))); try { Response equivalentDriverResponse = gateway.CallService(upDevice, call); if ((equivalentDriverResponse != null) && string.IsNullOrEmpty(equivalentDriverResponse.error)) { string interfaces = equivalentDriverResponse.GetResponseString(INTERFACES_KEY); if (interfaces != null) { List <UpDriver> drivers = new List <UpDriver>(); List <object> interfacesJson = Json.Deserialize(interfaces) as List <object>; for (int i = 0; i < interfacesJson.Count; ++i) { UpDriver upDriver = UpDriver.FromJSON(Json.Deserialize(interfacesJson[i] as string)); drivers.Add(upDriver); } try { driverManager.AddToEquivalenceTree(drivers); } catch (InterfaceValidationException) { logger.LogError("Not possible to add to equivalence tree due to wrong interface specification."); } foreach (DriverModel dependent in dependents) { try { driverManager.Insert(dependent); } catch (DriverNotFoundException) { logger.LogError( "Not possible to register driver '" + dependent.driver.name + "' due to unknown equivalent driver."); } catch (System.Exception) { logger.LogError( "Problems occurred in the registering of driver '" + dependent.driver.name + "' with instanceId '" + dependent.id + "' in the device '" + upDevice.name + "' and it will not be registered."); } } } else { logger.LogError( "Not possible to call service on device '" + upDevice.name + "' for no equivalent drivers on the service response."); } } else { logger.LogError( "Not possible to call service on device '" + upDevice.name + (equivalentDriverResponse == null ? ": null" : "': Cause : " + equivalentDriverResponse.error)); } } catch (ServiceCallException) { logger.LogError("Not possible to call service on device '" + upDevice.name); } }
public DriverModel(string id, UpDriver driver, string device) : this(null, id, driver, device) { }
public ReadOnlyCollection <UpWebElement> FindElements(By by) { UpDriver.WaitForPageReady(); Log.GetLogger().Info($"Finding elements by locator:[{by}]"); return(new ReadOnlyCollection <UpWebElement>(WrappedElement.FindElements(by).Select(el => new UpWebElement(UpDriver, el, by)).ToList())); }
public UpWebElement FindElement(By by) { UpDriver.WaitForPageReady(); Log.GetLogger().Info($"Finding element by locator:[{by}]"); return(new UpWebElement(UpDriver, WrappedElement.FindElement(by), by)); }
public string GetCssValue(string cssValue) { UpDriver.WaitForPageReady(); Log.GetLogger().Info($"Getting [{cssValue}] CssValue for element [{ElementIdentifier}]"); return(WrappedElement.GetCssValue(cssValue)); }
public string GetProperty(string propertyName) { UpDriver.WaitForPageReady(); Log.GetLogger().Info($"Getting [{propertyName}] property for element [{ElementIdentifier}]"); return(WrappedElement.GetProperty(propertyName)); }
public string GetAttribute(string attributeName) { UpDriver.WaitForPageReady(); Log.GetLogger().Info($"Getting [{attributeName}] attribute for element [{ElementIdentifier}]"); return(WrappedElement.GetAttribute(attributeName)); }
public DriverData(UpDriver driver, UpDevice device, string instanceID) { this.driver = driver; this.device = device; this.instanceID = instanceID; }
void Awake() { forwardDriver_2 = minionClone.GetComponent <ForwardDriver_2>(); upDriver = minionClone.GetComponent <UpDriver>(); }