Пример #1
0
        public static void Main()
        {
            // MFTestApp.Mountaineer.Run();
            OutputPort LED = new OutputPort(Pins.GPIO_PIN_B_8, true);


            InterruptPort button = new InterruptPort(Pins.GPIO_PIN_G_8, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);

            button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);


            Debug.Print(
                Resources.GetString(Resources.StringResources.String1));

            Debug.Print(Debug.GC(true).ToString());
            Microsoft.SPOT.Hardware.Utility.SetLocalTime(new DateTime(2012, 4, 20));


            ExtendedWeakReferences.Run();
            SerialPortExt uart    = new SerialPortExt("COM2", 115200);
            int           counter = 0;

            uart.Open();
            uart.WriteLine(Resources.StringResources.String1.ToString());

            Thread threadToggleLed = new Thread(ToggleThread);

            threadToggleLed.Start();

            /*VolumeInfo[] vis = VolumeInfo.GetVolumes();
             * foreach (var volumeInfo in vis)
             * {
             *  Debug.Print(volumeInfo.TotalSize.ToString());
             * }*/



            Ds1624 tempSens = new Ds1624();

            tempSens.Init();
            tempSens.TemperatureEvent +=
                delegate(double temperature)
            {
                uart.WriteLine("temperature: " + temperature.ToString());
            };
            tempSens.StartConversion();

            SocketServer socketServer = new SocketServer(new HtmlTempDataProvider(tempSens));

            CreateHttpClients();

            while (true)
            {
                Thread.Sleep(500);
                LED.Write(false);
                Thread.Sleep(500);
                LED.Write(true);
                if (counter < 2)
                {
                    uart.WriteLine("Count: " + counter.ToString() + "\r\n");
                    counter++;

                    NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
                    foreach (var allNetworkInterface in allNetworkInterfaces)
                    {
                        uart.WriteLine(allNetworkInterface.NetworkInterfaceType.ToString());
                        uart.WriteLine(allNetworkInterface.IPAddress);

                        /*if (allNetworkInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
                         * {
                         *  allNetworkInterface.EnableDhcp();
                         * }*/
                    }
                }
                //AnalogInput analogInput = new AnalogInput(Cpu.AnalogChannel.ANALOG_4);
                //Debug.Print("a: " + analogInput.Read().ToString());
            }
        }
Пример #2
0
 public HtmlTempDataProvider(Ds1624 tempSensor)
 {
     this.tempSensor = tempSensor;
 }
Пример #3
0
        public static void Main()
        {
           // MFTestApp.Mountaineer.Run();
            OutputPort LED = new OutputPort(Pins.GPIO_PIN_B_8, true);


            InterruptPort button = new InterruptPort(Pins.GPIO_PIN_G_8, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
            button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);
            

            Debug.Print(
                Resources.GetString(Resources.StringResources.String1));

            Debug.Print(Debug.GC(true).ToString());
            Microsoft.SPOT.Hardware.Utility.SetLocalTime(new DateTime(2012, 4, 20));


            ExtendedWeakReferences.Run();
            SerialPortExt uart = new SerialPortExt("COM2", 115200);
            int counter = 0;
            uart.Open();
            uart.WriteLine(Resources.StringResources.String1.ToString());

            Thread threadToggleLed = new Thread(ToggleThread);
            threadToggleLed.Start();

            /*VolumeInfo[] vis = VolumeInfo.GetVolumes();
            foreach (var volumeInfo in vis)
            {
                Debug.Print(volumeInfo.TotalSize.ToString());
            }*/
            
            

            Ds1624 tempSens = new Ds1624();
            tempSens.Init();
            tempSens.TemperatureEvent +=
                delegate(double temperature)
                    {                       
                        uart.WriteLine("temperature: " + temperature.ToString());
                    };
            tempSens.StartConversion();

            SocketServer socketServer = new SocketServer(new HtmlTempDataProvider(tempSens));

            CreateHttpClients();

            while (true)
            {
                Thread.Sleep(500);
                LED.Write(false);
                Thread.Sleep(500);
                LED.Write(true);
                if (counter < 2)
                {
                    uart.WriteLine("Count: " + counter.ToString() + "\r\n");
                    counter++;
                
                    NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
                    foreach (var allNetworkInterface in allNetworkInterfaces)
                    {
                        uart.WriteLine(allNetworkInterface.NetworkInterfaceType.ToString());
                        uart.WriteLine(allNetworkInterface.IPAddress);
                        /*if (allNetworkInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
                        {
                            allNetworkInterface.EnableDhcp();
                        }*/
                    }
                }
                //AnalogInput analogInput = new AnalogInput(Cpu.AnalogChannel.ANALOG_4);
                //Debug.Print("a: " + analogInput.Read().ToString());
            }
        }
Пример #4
0
 public HtmlTempDataProvider(Ds1624 tempSensor)
 {
     this.tempSensor = tempSensor;
 }