Пример #1
0
        public M8_WebServer(Socket server, M8_TempMgr tempMgr, M8_PID pid, M8_SSR ssr)
        {
            this._server = server;

            this._tempMgr = tempMgr;
            this._ssr = ssr;
            this._pid = pid;
        }
Пример #2
0
        public M8_WebServer(Socket server, M8_TempMgr tempMgr, M8_PID pid, M8_SSR ssr)
        {
            this._server = server;

            this._tempMgr = tempMgr;
            this._ssr     = ssr;
            this._pid     = pid;
        }
Пример #3
0
        /// <summary>
        /// The constructor calls another method to handle the request, but can 
        /// optionally do so in a new thread.
        /// </summary>
        /// <param name="clientSocket"></param>
        /// <param name="asynchronously"></param>
        public M8_ClientRequest(Socket clientSocket, Boolean asynchronously, M8_TempMgr tempMgr, M8_PID pid, M8_SSR ssr)
        {
            m_clientSocket = clientSocket;
                m_ssr = ssr;
                m_pid = pid;
                m_tempMgr = tempMgr;

                if (asynchronously)
                    // Spawn a new thread to handle the request.
                    new Thread(ProcessRequest).Start();
                else ProcessRequest();
        }
Пример #4
0
        public static void Main()
        {
            M8_TempMgr tempMgr;
            M8_PID     pid;
            M8_SSR     ssr;

            M8_WebServer server;

            DateTime updateIn = new DateTime();

            // We want to update every second
            updateIn = DateTime.Now.AddMilliseconds(1000);

            pid     = new M8_PID(M8_PID.defaultPGain, M8_PID.defaultIGain, M8_PID.defaultDGain);
            ssr     = new M8_SSR((Cpu.Pin)FEZ_Pin.Digital.Di6);
            tempMgr = new M8_TempMgr((Cpu.Pin)FEZ_Pin.Digital.Di5);
            tempMgr.setPidThermometer(0);

            Debug.Print("W5100.Enable");
            WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9, false);
            //We need to give the Wiz chip some "alone time"
            Thread.Sleep(1000);

            NetworkInterface.EnableStaticIP(new byte[] { 192, 168, 1, 177 }, new byte[] { 255, 255, 255, 0 }, new byte[] { 192, 168, 1, 1 }, new byte[] { 0x90, 0xA2, 0xDA, 0x00, 0x14, 0x14 });
            NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 1, 1 });

            server = new M8_WebServer(new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp), tempMgr, pid, ssr);

            server.startServer(80);

            while (true)
            {
                //Read the temps in
                if (DateTime.Now > updateIn)
                {
                    tempMgr.update();

                    //Calculate the PID value and set it on the SSR
                    pid.calcPID(tempMgr.getTemp(), tempMgr.getError());
                    ssr.setPower(pid.getSSRValue());

                    updateIn = DateTime.Now.AddMilliseconds(1000);

                    Debug.Print("-----------------" + DateTime.Now.ToString());
                }

                //Update the SSR
                ssr.update();

                server.update();
            }
        }
Пример #5
0
        public static void Main()
        {
            M8_TempMgr tempMgr;
            M8_PID pid;
            M8_SSR ssr;

            M8_WebServer server;

            DateTime updateIn = new DateTime();

            // We want to update every second
            updateIn = DateTime.Now.AddMilliseconds(1000);

            pid = new M8_PID(M8_PID.defaultPGain, M8_PID.defaultIGain, M8_PID.defaultDGain);
            ssr = new M8_SSR((Cpu.Pin)FEZ_Pin.Digital.Di6);
            tempMgr = new M8_TempMgr((Cpu.Pin)FEZ_Pin.Digital.Di5);
            tempMgr.setPidThermometer(0);

            Debug.Print("W5100.Enable");
            WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9, false);
            //We need to give the Wiz chip some "alone time"
            Thread.Sleep(1000);

            NetworkInterface.EnableStaticIP(new byte[] { 192, 168, 1, 177 }, new byte[] { 255, 255, 255, 0 }, new byte[] { 192, 168, 1, 1 }, new byte[] { 0x90, 0xA2, 0xDA, 0x00, 0x14, 0x14 });
            NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 1, 1 });

            server = new M8_WebServer( new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp), tempMgr, pid, ssr);

            server.startServer( 80 );

            while (true)
            {
                //Read the temps in
                if (DateTime.Now > updateIn)
                {
                    tempMgr.update();

                    //Calculate the PID value and set it on the SSR
                    pid.calcPID(tempMgr.getTemp(), tempMgr.getError());
                    ssr.setPower(pid.getSSRValue());

                    updateIn = DateTime.Now.AddMilliseconds(1000);

                    Debug.Print("-----------------" + DateTime.Now.ToString());
                }

                //Update the SSR
                ssr.update();

                server.update();
            }
        }
Пример #6
0
        /// <summary>
        /// The constructor calls another method to handle the request, but can
        /// optionally do so in a new thread.
        /// </summary>
        /// <param name="clientSocket"></param>
        /// <param name="asynchronously"></param>
        public M8_ClientRequest(Socket clientSocket, Boolean asynchronously, M8_TempMgr tempMgr, M8_PID pid, M8_SSR ssr)
        {
            m_clientSocket = clientSocket;
            m_ssr          = ssr;
            m_pid          = pid;
            m_tempMgr      = tempMgr;

            if (asynchronously)
            {
                // Spawn a new thread to handle the request.
                new Thread(ProcessRequest).Start();
            }
            else
            {
                ProcessRequest();
            }
        }