protected override Task<Driver> GetDriver(RnetDevice device) { if (device is RnetController) return GetDriver((RnetController)device); return Task.FromResult<Driver>(null); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="owner"></param> protected LogicalBusObject(RnetDevice owner) : base(owner.Bus) { Contract.Requires<ArgumentNullException>(owner != null); this.SetContainerContext(owner, owner); }
protected override Task<Driver> GetDriver(RnetDevice device) { if (device is RnetController) return Task.FromResult<Driver>(new ControllerDriver((RnetController)device)); else if (device is RnetLocalDevice) return Task.FromResult<Driver>(new LocalDeviceDriver((RnetLocalDevice)device)); else return Task.FromResult<Driver>(null); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="target"></param> protected DeviceBase(RnetDevice target) : base(target) { Contract.Requires<ArgumentNullException>(target != null); }
async Task<DeviceData> FillDeviceData(IContext context, RnetDevice o, DeviceData d) { Contract.Requires<ArgumentNullException>(o != null); Contract.Requires<ArgumentNullException>(d != null); await FillObjectData(context, o, d); d.RnetId = o.GetId(); d.DataUri = o.GetUri(context).UriCombine(Util.DATA_URI_SEGMENT); return d; }
/// <summary> /// Transforms the given <see cref="RnetDevice"/> into a <see cref="DeviceData"/> instance. /// </summary> /// <param name="d"></param> /// <returns></returns> public async Task<DeviceData> DeviceToData(IContext context, RnetDevice d) { Contract.Requires<ArgumentNullException>(d != null); if (d is RnetController) return await ControllerToData(context, (RnetController)d); else return await FillDeviceData(context, d, new DeviceData()); }