Esempio n. 1
0
        public void When_TwoWay_Binding_Overwritten()
        {
            var oldDC = new MyDC(3);
            var newDC = new MyDC(7);

            var slider = new Slider();

            slider.SetBinding(Slider.ValueProperty, new Binding {
                Path = new PropertyPath(nameof(MyDC.MyValue)), Mode = BindingMode.TwoWay, Source = oldDC
            });

            Assert.AreEqual(3, slider.Value);

            // Should remove previous binding
            slider.SetBinding(Slider.ValueProperty, new Binding {
                Path = new PropertyPath(nameof(MyDC.MyValue)), Mode = BindingMode.TwoWay, Source = newDC
            });

            Assert.AreEqual(7, slider.Value);

            Assert.AreEqual(3, oldDC.MyValue);
            Assert.AreEqual(7, newDC.MyValue);

            slider.Value = 12;

            Assert.AreEqual(3, oldDC.MyValue);
            Assert.AreEqual(12, newDC.MyValue);
        }
Esempio n. 2
0
        public static void Main()
        {
            //create the device context to expose to the engine
            var DeviceContext = new MyDC();

            DeviceContext.OnboardLed = new OutputPort(Pins.ONBOARD_LED, false);

            DeviceContext.OutputPorts[0] = new OutputPort(Pins.GPIO_PIN_D0, false);
            DeviceContext.OutputPorts[1] = new OutputPort(Pins.GPIO_PIN_D1, false);
            DeviceContext.OutputPorts[2] = new OutputPort(Pins.GPIO_PIN_D2, false);
            DeviceContext.OutputPorts[3] = new OutputPort(Pins.GPIO_PIN_D3, false);
            DeviceContext.OutputPorts[4] = new OutputPort(Pins.GPIO_PIN_D4, false);
            DeviceContext.OutputPorts[5] = new OutputPort(Pins.GPIO_PIN_D5, false);
            DeviceContext.OutputPorts[6] = new OutputPort(Pins.GPIO_PIN_D6, false);
            DeviceContext.OutputPorts[7] = new OutputPort(Pins.GPIO_PIN_D7, false);

            DeviceContext.InputPorts[0] = new InputPort(Pins.GPIO_PIN_D8, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[1] = new InputPort(Pins.GPIO_PIN_D9, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[2] = new InputPort(Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[3] = new InputPort(Pins.GPIO_PIN_D11, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[4] = new InputPort(Pins.GPIO_PIN_D12, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[5] = new InputPort(Pins.GPIO_PIN_D13, true, Port.ResistorMode.PullUp);

            DeviceContext.AnalogPorts[0] = new AnalogInput(Pins.GPIO_PIN_A0);
            DeviceContext.AnalogPorts[1] = new AnalogInput(Pins.GPIO_PIN_A1);
            DeviceContext.AnalogPorts[2] = new AnalogInput(Pins.GPIO_PIN_A2);
            DeviceContext.AnalogPorts[3] = new AnalogInput(Pins.GPIO_PIN_A3);
            DeviceContext.AnalogPorts[4] = new AnalogInput(Pins.GPIO_PIN_A4);
            DeviceContext.AnalogPorts[5] = new AnalogInput(Pins.GPIO_PIN_A5);


            //a string representing the compiled version of the "basic" workflow
            //this string could be read from any non-volatile medium (e.g. SD, EEProm, etc)
            var data = @"uWRSWKB""1""SSvB000SAl000F059K4""2""F057l000zz";

            //decompile the string creating an activities tree
            var root = EngineContextRoot.Create(
                MicroWorkflowLookup.FunctionTable,
                data);

            //create a session holding the data of the task
            var session = new EngineSession(DeviceContext);

            //invoke the activities tree against the session
            root.Run(session);

            /**
             * NOTE: this example is minimal, with no threading, and no mutation of the running task.
             * That assumes the task will run forever, because there's no code for manage the engine.
             **/
        }
Esempio n. 3
0
        public static void Main()
        {
            //setup the board IP
            NetworkInterface.GetAllNetworkInterfaces()[0]
            .EnableStaticIP("192.168.0.99", "255.255.255.0", "192.168.0.1");

            string localip = NetworkInterface.GetAllNetworkInterfaces()[0]
                             .IPAddress;

            Debug.Print("The local IP address of your Netduino Plus is " + localip);

            //create the device context to expose to the engine
            DeviceContext = new MyDC();

            DeviceContext.OnboardLed = new OutputPort(Pins.ONBOARD_LED, false);

            DeviceContext.OutputPorts[0] = new OutputPort(Pins.GPIO_PIN_D0, false);
            DeviceContext.OutputPorts[1] = new OutputPort(Pins.GPIO_PIN_D1, false);
            DeviceContext.OutputPorts[2] = new OutputPort(Pins.GPIO_PIN_D2, false);
            DeviceContext.OutputPorts[3] = new OutputPort(Pins.GPIO_PIN_D3, false);
            DeviceContext.OutputPorts[4] = new OutputPort(Pins.GPIO_PIN_D4, false);
            DeviceContext.OutputPorts[5] = new OutputPort(Pins.GPIO_PIN_D5, false);
            DeviceContext.OutputPorts[6] = new OutputPort(Pins.GPIO_PIN_D6, false);
            DeviceContext.OutputPorts[7] = new OutputPort(Pins.GPIO_PIN_D7, false);

            DeviceContext.InputPorts[0] = new InputPort(Pins.GPIO_PIN_D8, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[1] = new InputPort(Pins.GPIO_PIN_D9, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[2] = new InputPort(Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[3] = new InputPort(Pins.GPIO_PIN_D11, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[4] = new InputPort(Pins.GPIO_PIN_D12, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[5] = new InputPort(Pins.GPIO_PIN_D13, true, Port.ResistorMode.PullUp);

            DeviceContext.AnalogPorts[0] = new AnalogInput(Pins.GPIO_PIN_A0);
            DeviceContext.AnalogPorts[1] = new AnalogInput(Pins.GPIO_PIN_A1);
            DeviceContext.AnalogPorts[2] = new AnalogInput(Pins.GPIO_PIN_A2);
            DeviceContext.AnalogPorts[3] = new AnalogInput(Pins.GPIO_PIN_A3);
            DeviceContext.AnalogPorts[4] = new AnalogInput(Pins.GPIO_PIN_A4);
            DeviceContext.AnalogPorts[5] = new AnalogInput(Pins.GPIO_PIN_A5);

            //start the listening socket
            new Thread(Listen)
            .Start();

            //do whatever

            Thread.Sleep(Timeout.Infinite);
        }