Ejemplo n.º 1
0
        /// <summary>
        /// Starts the RNET bus.
        /// </summary>
        /// <param name="keypadId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task Start(SynchronizationContext synchronizationContext, RnetKeypadId keypadId, CancellationToken cancellationToken)
        {
            Contract.Requires<ArgumentNullException>(synchronizationContext != null);
            Contract.Requires<ArgumentNullException>(keypadId != RnetKeypadId.Null);
            Contract.Requires<ArgumentNullException>(cancellationToken != null);

            using (await lck.LockAsync(cancellationToken))
            {
                if (state == RnetBusState.Started)
                    throw new RnetException("Bus is already started or starting.");

                // our intentions are to be started
                state = RnetBusState.Started;

                // begin starting
                SetState(RnetBusState.Starting);
                this.synchronizationContext = synchronizationContext;
                Controllers.Clear();

                // generate minimal required model and insert new local device
                var c = Controllers[RnetControllerId.Root];
                var z = c.Zones[RnetZoneId.Zone1];
                var d = new RnetLocalDevice(z, keypadId);
                z.Devices[keypadId] = this.localDevice = d;

                // start client running
                await Client.Start();
                SetState(RnetBusState.Started);

                // activate the path to the local device
                d.Activate();

                // initiate device scan
                await Scan();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="path"></param>
        internal RnetLocalDataHandle(RnetLocalDevice device, RnetPath path)
            : base(device, path)
        {

        }