Beispiel #1
0
        public Animatroller.Framework.PhysicalDevice.DigitalOutput AddDigitalOutput(string name)
        {
            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(80, 80);

            var centerControl = new Control.CenterControl();
            moduleControl.ChildControl = centerControl;

            var control = new Animatroller.Simulator.Control.Bulb.LedBulb();
            control.On = false;
            control.Size = new System.Drawing.Size(20, 20);
            centerControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.DigitalOutput(x =>
            {
                this.UIThread(delegate
                {
                    control.On = x;
                });
            });

            return device;
        }
        public Animatroller.Framework.PhysicalDevice.DigitalInput AddDigitalInput_FlipFlop(DigitalInput2 logicalDevice, bool showOutput)
        {
            var control = new CheckBox();

            control.Text       = logicalDevice.Name;
            control.Size       = new System.Drawing.Size(80, 60);
            control.ImageAlign = ContentAlignment.TopLeft;

            var indicator = new Animatroller.Simulator.Control.Bulb.LedBulb();

            indicator.On   = false;
            indicator.Size = new System.Drawing.Size(12, 12);
            indicator.Left = 0;
            indicator.Top  = 0;
            var imageOff = new Bitmap(12, 12);

            indicator.DrawToBitmap(imageOff, new Rectangle(0, 0, 12, 12));
            var imageOn = new Bitmap(12, 12);

            indicator.On = true;
            indicator.DrawToBitmap(imageOn, new Rectangle(0, 0, 12, 12));

            flowLayoutPanelLights.Controls.Add(control);

            var device = new Animatroller.Framework.PhysicalDevice.DigitalInput();

            control.CheckedChanged += (sender, e) =>
            {
                device.Trigger((sender as CheckBox).Checked);
            };

            device.Connect(logicalDevice);

            control.Checked = logicalDevice.Value;

            logicalDevice.Output
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(x =>
            {
                control.Checked = x;

                if (showOutput)
                {
                    control.Image = x ? imageOn : imageOff;
                }
            });

            return(device);
        }
        public Animatroller.Framework.PhysicalDevice.DigitalOutput AddDigitalOutput(DigitalOutput2 logicalDevice)
        {
            var moduleControl = new Control.ModuleControl();

            moduleControl.Text = logicalDevice.Name;
            moduleControl.Size = new System.Drawing.Size(80, 80);

            var centerControl = new Control.CenterControl();

            moduleControl.ChildControl = centerControl;

            var control = new Animatroller.Simulator.Control.Bulb.LedBulb();

            control.On   = false;
            control.Size = new System.Drawing.Size(20, 20);
            centerControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.DigitalOutput(x =>
            {
                if (PendingClose)
                {
                    return;
                }

                Task.Run(() =>
                {
                    this.UIThread(delegate
                    {
                        control.On = x;
                    });
                });
            });

            device.Connect(logicalDevice);

            return(device);
        }
Beispiel #4
0
        public Animatroller.Framework.PhysicalDevice.DigitalInput AddDigitalInput_FlipFlop(DigitalInput2 logicalDevice, bool showOutput)
        {
            var control = new CheckBox();
            control.Text = logicalDevice.Name;
            control.Size = new System.Drawing.Size(80, 60);
            control.ImageAlign = ContentAlignment.TopLeft;

            var indicator = new Animatroller.Simulator.Control.Bulb.LedBulb();
            indicator.On = false;
            indicator.Size = new System.Drawing.Size(12, 12);
            indicator.Left = 0;
            indicator.Top = 0;
            var imageOff = new Bitmap(12, 12);
            indicator.DrawToBitmap(imageOff, new Rectangle(0, 0, 12, 12));
            var imageOn = new Bitmap(12, 12);
            indicator.On = true;
            indicator.DrawToBitmap(imageOn, new Rectangle(0, 0, 12, 12));

            flowLayoutPanelLights.Controls.Add(control);

            var device = new Animatroller.Framework.PhysicalDevice.DigitalInput();

            control.CheckedChanged += (sender, e) =>
            {
                device.Trigger((sender as CheckBox).Checked);
            };

            device.Connect(logicalDevice);

            control.Checked = logicalDevice.Value;

            logicalDevice.Output
                .ObserveOn(SynchronizationContext.Current)
                .Subscribe(x =>
                {
                    control.Checked = x;

                    if (showOutput)
                        control.Image = x ? imageOn : imageOff;
                });

            return device;
        }