private void InitializeState()
        {
            if (_state == null)
            {
                _state            = new CompassSensorState();
                _state.SensorPort = (NxtSensorPort)LegoNxtPort.AnySensorPort;
            }

            if (_state.PollingFrequencyMs == 0)
            {
                _state.PollingFrequencyMs = Contract.DefaultPollingFrequencyMs;
            }


            if (_state.Heading == null)
            {
                _state.Heading = new CompassReading();
            }
            else
            {
                _state.Heading.Degrees   = 0.0;
                _state.Heading.TimeStamp = DateTime.MinValue;
            }
            _state.Connected = false;
        }
Beispiel #2
0
        /// <summary>
        /// Post Configure Sensor Connection with body and return the response port.
        /// </summary>
        public virtual PortSet <DefaultUpdateResponseType, Fault> ConnectToBrick(CompassSensorState state)
        {
            ConnectToBrick op = new ConnectToBrick();

            op.Body      = new CompassConfig(state.SensorPort);
            op.Body.Name = state.Name;
            op.Body.PollingFrequencyMs = state.PollingFrequencyMs;

            this.PostUnknownType(op);
            return(op.ResponsePort);
        }