/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="config">Web Server configuration</param>
        public MicroWebServer(MicroWebServerConfig config)
        {
            // check HTTP port
            if (config.HttpPort <= 0)
                throw new ArgumentException("Wrong HTTP port in configuration");

            // check backlog
            if (config.Backlog <= 0)
                throw new ArgumentException("Wrong Backlog in configuration");

            // if not defined, set WebRoot default directory
            if ((config.WebRoot == null) || (config.WebRoot == String.Empty))
                this.config.WebRoot = WEBROOT_DEFAULT;

            // set Web Server configuration
            this.config = config;

            // create Web Root directory if it doesn't exist
            if (!Directory.Exists(this.config.WebRoot))
                Directory.CreateDirectory(this.config.WebRoot);

            // listener thread not yet running
            this.isRunning = false;
            // create thread pool for request processing and request queue
            this.workerThreadPool = new ArrayList();
            this.requestQueue = new Queue();

            // create handlers collection and set defaults handler
            this.handlers = new Hashtable();
            this.fileSystemHandler = new FileSystemHandler();
            this.cgiHandler = new CgiHandler();
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="config">Web Server configuration</param>
        public MicroWebServer(MicroWebServerConfig config)
        {
            // check HTTP port
            if (config.HttpPort <= 0)
            {
                throw new ArgumentException("Wrong HTTP port in configuration");
            }

            // check backlog
            if (config.Backlog <= 0)
            {
                throw new ArgumentException("Wrong Backlog in configuration");
            }

            // if not defined, set WebRoot default directory
            if ((config.WebRoot == null) || (config.WebRoot == String.Empty))
            {
                this.config.WebRoot = WEBROOT_DEFAULT;
            }

            // set Web Server configuration
            this.config = config;

            // create Web Root directory if it doesn't exist
            if (!Directory.Exists(this.config.WebRoot))
            {
                Directory.CreateDirectory(this.config.WebRoot);
            }

            // listener thread not yet running
            this.isRunning = false;
            // create thread pool for request processing and request queue
            this.workerThreadPool = new ArrayList();
            this.requestQueue     = new Queue();

            // create handlers collection and set defaults handler
            this.handlers          = new Hashtable();
            this.fileSystemHandler = new FileSystemHandler();
            this.cgiHandler        = new CgiHandler();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="config">Web Server configuration</param>
 internal HttpServerUtility(MicroWebServerConfig config)
 {
     this.config = config;
 }
Example #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="config">Web Server configuration</param>
 internal HttpServerUtility(MicroWebServerConfig config)
 {
     this.config = config;
 }
Example #5
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Controller()
        {
            this.errorLogger = new LedErrorLogger(LED_ERROR_PIN);

            #if !EMULATOR
            // check for SD presence
            this.CheckSD();
            #endif

            // create sensors instances
            this.dataLogger = new SDDataLogger(SD_DATA_LOGGING);
            this.anemometer = new Anemometer(ANEMOMETER_PIN);
            this.sht1x = new SHT1X(SHT1X_DATA_PIN, SHT1X_CLK_PIN, SHT1X.Voltage.Vdd_3_5V);
            this.ldr = new Ldr(LDR_ANALOG_CHANNEL, LDR_ADC_RESOLUTION, LDR_LOAD_RESISTOR);

            // RTC
            this.rtc = Rtc.Instance;

            // configure and create Web Server
            MicroWebServerConfig uWebServerConfig =
                new MicroWebServerConfig {
                    Backlog = WS_BACKLOG,
                    HttpPort = WS_HTTP_PORT,
                    MaxWorkerThread = WS_MAX_WORKER_THREAD,
                    WebRoot = SD_WEBROOT
                };

            this.uWebServer = new MicroWebServer(uWebServerConfig);
        }