Beispiel #1
0
    static void Main()
    {
        var ledActuator = new DigitalActuator
        {
            OutputPin = Parameters.LedPin
        };

        var webServer = new HttpServer
        {
            // RelayDomain = Parameters.RelayDomain,
            // RelaySecretKey = Parameters.RelaySecretKey,
            RequestRouting =
            {
                {
                    "PUT /led/target",
                    new ManipulatedVariable
                    {
                        FromHttpRequest =
                            CSharpRepresentation.TryDeserializeBool,
                        ToActuator = ledActuator.HandlePut
                    }.HandleRequest
                },
                {
                    "GET /led/target.html",
                    HandleLedTargetHtml
                }
            }
        };

        webServer.Run();
    }
Beispiel #2
0
    public static void Main()
    {
        var thdLed = new Thread(HandleLed);
        thdLed.Start();

        var digitalSensor = new DigitalSensor { InputPin = Pins.GPIO_PIN_D12 };
        var analogSensor = new AnalogSensor { InputPin = Pins.GPIO_PIN_A1, MinValue = 0.0, MaxValue = 3.3 };
        var lowPort = new OutputPort(Pins.GPIO_PIN_A0, false);
        var highPort = new OutputPort(Pins.GPIO_PIN_A2, true);

        var ledActuator = new DigitalActuator { OutputPin = Pins.GPIO_PIN_D13 };
        //need to create HTTP PUTs!

        var webServer = new HttpServer
        {
            RelayDomain = "gsiot-bcjp-yj88",
            RelaySecretKey = "HDMvyM11hAu6H6cxIaT50dL9ALWc81MYB8H/UFhV",
            RequestRouting =
            {
                { "GET /hello*", HandleHello }, //This accepts a lot of URLs
                { "GET /on", HandleOn },
                { "GET /off", HandleOff },
                { "POST /on", HandlePostOn },
                { "POST /off", HandlePostOff },
                { "GET /d12", new MeasuredVariable{ FromSensor=digitalSensor.HandleGet}.HandleRequest},
                { "GET /a1", new MeasuredVariable{ FromSensor=analogSensor.HandleGet}.HandleRequest},
                { "PUT /d13", new ManipulatedVariable{ FromHttpRequest=CSharpRepresentation.TryDeserializeBool,ToActuator=ledActuator.HandlePut}.HandleRequest},
            }
        };
        webServer.Run();
    }