Example #1
0
 public RangeFinder(RangeFinderConfiguration config)
 {
     VerifyConfiguration(config);
     this.configuration = config;
     port = new SerialPort(config.Port, 19200, Parity.None, 8, StopBits.One);
     port.WriteTimeout = 1000;
     port.ReadTimeout = 1000;
 }
Example #2
0
        private static void VerifyConfiguration(RangeFinderConfiguration config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            if (String.IsNullOrWhiteSpace(config.Port))
                throw new ArgumentNullException("port");

            if (config.StartStep < MIN_STEP || config.StartStep > MAX_STEP)
                throw new ArgumentOutOfRangeException("StartStep");

            if (config.EndStep < MIN_STEP || config.EndStep > MAX_STEP)
                throw new ArgumentOutOfRangeException("EndStep");

            if (config.StartStep >= config.EndStep)
                throw new ArgumentException("EndStep must be greater than StartStep");

            if (config.ClusterCount < 0 || config.ClusterCount > 99)
                throw new ArgumentOutOfRangeException("ClusterCount");
        }