/// <summary>
        /// Initialize the Light Sensor state
        /// </summary>
        private void InitializeState()
        {
            if (_state == null)
            {
                _state = new LightSensorState();
            }

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

            _state.TimeStamp = DateTime.MinValue;
            _state.Intensity = 0;
            _state.Connected = false;


            if (_genericState == null)
            {
                _genericState = new pxanalogsensor.AnalogSensorState();
            }

            _genericState.RawMeasurementRange   = 255.0;
            _genericState.RawMeasurement        = 0.0;
            _genericState.NormalizedMeasurement = 0.0;
            _genericState.TimeStamp             = DateTime.MinValue;

            // Set the hardware identifier from the connected motor port.
            _genericState.HardwareIdentifier = NxtCommon.HardwareIdentifier(_state.SensorPort);
        }
Exemple #2
0
        /// <summary>
        /// Post Configure Sensor Connection with body and return the response port.
        /// </summary>
        public virtual PortSet <DefaultUpdateResponseType, Fault> ConnectToBrick(LightSensorState state)
        {
            ConnectToBrick op = new ConnectToBrick();

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

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