/// <summary> /// Clone Lego NXT Connection /// </summary> public virtual object Clone() { LegoNxtConnection target = new LegoNxtConnection(); target.Port = this.Port; target.PortOverride = this.PortOverride; return target; }
/// <summary> /// Find sensors on the brick which can be added to /// our contact sensor array. /// </summary> /// <returns></returns> private IEnumerator<ITask> FindSensors() { #region Attach to the NXT Brick LegoNxtConnection aggregate = new LegoNxtConnection(LegoNxtPort.Aggregation); aggregate.PortOverride = "Contact Sensor Array"; brick.AttachRequest attachRequest = new brick.AttachRequest( new brick.Registration( aggregate, LegoDeviceType.Aggregation, "ContactSensorArray", Contract.Identifier, ServiceInfo.Service, "ContactSensorArray")); yield return Arbiter.Choice(_legoBrickPort.AttachAndSubscribe(attachRequest, _legoBrickNotificationPort), delegate(brick.AttachResponse rsp) { }, delegate(Fault fault) { LogError("Error in LEGO NXT Contact Sensor Array while attaching to brick", fault); }); #endregion PortSet<brick.NxtBrickState, Fault> brickResponse = _legoBrickPort.Get(); yield return Arbiter.Choice( Arbiter.ReceiveWithIterator<brick.NxtBrickState>(false, brickResponse, ProcessBrickState), Arbiter.Receive<Fault>(false, brickResponse, EmptyHandler<Fault>)); yield break; }