示例#1
0
        private void ProcessDemoLED(HttpRequest request, HttpResponse response)
        {
            try
            {
                if (request.Parameters.ContainsKey("state"))
                {
                    if (request.Parameters["state"].Equals("On", StringComparison.OrdinalIgnoreCase))
                    {
                        stateLed = "On";
                        _json.UpdateData("MaualLed", "On");
                        _templateDemo["maualLed"].Data = "On";
                        _ws.HttpRootManager.UpdateExtensionTemplateData("shtml", "manualLed", new TemplateAction()
                        {
                            Pattern = "MANUALLED", Data = "On"
                        });
                        //pin2.Write(GpioPinValue.High);
                        _ports.WritePin(PortNumber.PORT_TWO, true);
                    }
                    else if (request.Parameters["state"].Equals("Off", StringComparison.OrdinalIgnoreCase))
                    {
                        stateLed = "Off";
                        _json.UpdateData("MaualLed", "Off");
                        _templateDemo["maualLed"].Data = "Off";
                        _ws.HttpRootManager.UpdateExtensionTemplateData("shtml", "manualLed", new TemplateAction()
                        {
                            Pattern = "MANUALLED", Data = "Off"
                        });
                        //pin2.Write(GpioPinValue.Low);
                        _ports.WritePin(PortNumber.PORT_TWO, false);
                    }
                    Debug.WriteLineIf(_debug, "State changed to: " + stateLed);
                }

                if (stateLed.Equals("on", StringComparison.OrdinalIgnoreCase))
                {
                    _LEDControl["ledOn"].Data  = "checked";
                    _LEDControl["ledOff"].Data = string.Empty;
                }
                else
                {
                    _LEDControl["ledOn"].Data  = string.Empty;
                    _LEDControl["ledOff"].Data = "checked";
                }

                _LEDControl.ProcessAction();
                response.Write(_LEDControl.GetByte(), _ws.GetMimeType.GetMimeFromFile("/templateLED.html"));
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                response.Write(e);
            }
        }
示例#2
0
 public void TimerEvent()
 {
     try
     {
         if (enableBlink)
         {
             if (state.Equals("on", StringComparison.OrdinalIgnoreCase))
             {
                 _json.UpdateData("Led", "Off");
                 _templateDemo["led"].Data = "Off";
                 state = "Off";
                 _ws.HttpRootManager.UpdateExtensionTemplateData("shtml", "led", new TemplateAction()
                 {
                     Pattern = "LED", Data = "Off"
                 });
                 //pin.Write(GpioPinValue.Low);
                 _ports.WritePin(PortNumber.PORT_ONE, false);
             }
             else
             {
                 _json.UpdateData("Led", "On");
                 _templateDemo["led"].Data = "On";
                 state = "On";
                 _ws.HttpRootManager.UpdateExtensionTemplateData("shtml", "led", new TemplateAction()
                 {
                     Pattern = "LED", Data = "On"
                 });
                 //pin.Write(GpioPinValue.High);
                 _ports.WritePin(PortNumber.PORT_ONE, true);
             }
             Debug.WriteLineIf(_debug, "State changed to: " + state);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
     }
 }