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

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

            if (_state.Tilt == null)
            {
                _state.Tilt = new AccelerometerReading();
            }
            else
            {
                _state.Tilt.X         = 0.0;
                _state.Tilt.Y         = 0.0;
                _state.Tilt.Z         = 0.0;
                _state.Tilt.TimeStamp = DateTime.MinValue;
            }
            _state.Connected = false;
        }
        /// <summary>
        /// Post Configure Sensor Connection with body and return the response port.
        /// </summary>
        public virtual PortSet <DefaultUpdateResponseType, Fault> ConnectToBrick(AccelerometerState state)
        {
            ConnectToBrick op = new ConnectToBrick();

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

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