コード例 #1
0
        static void Main(string[] args)
        {
            ICompressionMechanism p = new Pump();

            IIndicator GreenLED = new LED("Green");
            IIndicator RedLED   = new LED("Red");
            IIndicator VMotor   = new VibrationMotor();

            var            compressionStockingstocking = new StockingCtrl(new StubCompressionCtrl(p, 5, 2, GreenLED, RedLED, VMotor));
            ConsoleKeyInfo consoleKeyInfo;

            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    compressionStockingstocking.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    compressionStockingstocking.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
コード例 #2
0
        private void GetStatusUI(DeviceStatusCache result, ref LED led)
        {
            if (result.Color == StatusColor.Green)
            {
                led.TrueBrush = Brushes.LightGreen;
            }
            else if (result.Color == StatusColor.Yellow)
            {
                led.TrueBrush = Brushes.Yellow;
            }
            else if (result.Color == StatusColor.Red)
            {
                led.TrueBrush = Brushes.Red;
            }

            ToolTipDeviceStatus toolTipDeviceStatus = new ToolTipDeviceStatus();

            toolTipDeviceStatus.IPAddress   = result.IPAddress;
            toolTipDeviceStatus.Status      = result.Status;
            toolTipDeviceStatus.Description = result.Description;

            led.ToolTip = toolTipDeviceStatus;

            led.Value = true;
        }
コード例 #3
0
        private void AddChannelEnableLed(TabPage tabPage)
        {
            //
            // led_channelEnable
            //
            LED led_channelEnable = new LED();

            led_channelEnable.BlinkColor    = System.Drawing.Color.Lime;
            led_channelEnable.BlinkInterval = 1000;
            led_channelEnable.BlinkOn       = false;
            led_channelEnable.Cursor        = System.Windows.Forms.Cursors.Arrow;
            led_channelEnable.Interacton    = SeeSharpTools.JY.GUI.LED.InteractionStyle.Indicator;
            led_channelEnable.Location      = new System.Drawing.Point(72, 11);
            led_channelEnable.Name          = "led_channelEnable";
            led_channelEnable.OffColor      = System.Drawing.Color.Black;
            led_channelEnable.OnColor       = System.Drawing.Color.Green;
            led_channelEnable.Size          = new System.Drawing.Size(43, 33);
            led_channelEnable.Style         = SeeSharpTools.JY.GUI.LED.LedStyle.Rectangular3D;
            led_channelEnable.TabIndex      = 11;
            led_channelEnable.Value         = false;

            led_channelEnable.Click += LedChannelEnableOnClick;

            tabPage.Controls.Add(led_channelEnable);
        }
コード例 #4
0
 public void BeginSendInfo()
 {
     Task.Run(async() =>
     {
         while (true)
         {
             for (int i = 0; i < LEDs.Count(); i++)
             {
                 await Task.Delay(500);
                 if (LEDs[i] != null)
                 {
                     if (MQs.TryGetValue(LEDs[i].LEDIP, out Queue <string> mq))
                     {
                         if (mq.Count > 0)
                         {
                             string msg = mq.Dequeue();
                             int n      = LEDs[i].SendLedInfo(msg);
                             if (i != 0)
                             {
                                 var option = Options.FirstOrDefault(t => t.IP == LEDs[i].LEDIP);
                                 if (option != null)
                                 {
                                     LEDs[i] = new LED(option.IP, option.Port, option.Timesec);
                                     LEDs[i].SendLedInfo(msg);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     });
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: code560/3d_led_cube
        static void Main(string[] args)
        {
            var test   = AppDomain.CurrentDomain.BaseDirectory;
            var libDir = Directory.GetParent(test).Parent.Parent.Parent.Parent;

            SetDllDirectory(Path.Combine(libDir.FullName, "00_lib"));

            var canvas = new LED3DCanvas();
            //            var filter = new LED3DWaveCanvasFilter(canvas);
//            var filter = new LED3DSurfaceCanvasFilter(canvas);
            var filter = new LED3DWaveCanvasFilter(new LED3DHsvColorFilter(canvas));

//            filter = null;

            int testcase  = 5;
            var showCases = new List <IShowCase>();

            showCases.Add(new CircleOnCube());
            showCases.Add(new RectangleOnCube());
            showCases.Add(new RippleOnCube());
            showCases.Add(new AtFieldOnCube());
            showCases.Add(new AngelOnCube());
            showCases.Add(new RippleOnWaveCube());

            showCases[testcase].SetUp(canvas, filter);
            showCases[testcase].Run(canvas, filter);

            while (true)
            {
                canvas.Show();
                LED.Wait(10);
            }
        }
コード例 #6
0
        private static void InitializeComponents()
        {
            var ground      = new Ground();
            var powerSource = new PowerSource
            {
                Voltage = 5
            };

            var resistor = new Resistor
            {
                Resistance = 220
            };

            var led = new LED
            {
                Current = 20,
                Voltage = 2
            };

            var powerToResistorConnection = new Connection(powerSource, resistor);

            resistor.InputConnection = powerToResistorConnection;
            var resistorToLedConnection = new Connection(resistor, led);

            resistor.OutputConnection = resistorToLedConnection;
            led.AnodeConnection       = resistorToLedConnection;
            var ledToGroundConnection = new Connection(led, ground);

            led.CathodeConnection = ledToGroundConnection;

            _components.Add(ground);
            _components.Add(powerSource);
            _components.Add(resistor);
            _components.Add(led);
        }
コード例 #7
0
    Wire oldHookup(Junction source, Junction target, Direction dirToTarget, WireType wireType, LED.clr color)
    {
        LED led = (LED)oldHookup(source, target, dirToTarget, wireType);

        led.SetColor(color);
        return(led);
    }
コード例 #8
0
        private bool Send(LED LEDIndex, string data)
        {
            try
            {
                string signal = data;
                if (LEDIndex == LED.LED1)
                {
                    signal = data;
                }
                else if (LEDIndex == LED.LED2)
                {
                    signal = ((char)(data.First() + 17)).ToString();
                }
                else
                {
                    signal = ((char)(data.First() + 49)).ToString();
                }

                SendByte(signal);

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #9
0
        public static void Main()
        {
            int DacValue1 = 10;
            int DacValue2 = 10;

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

            // ADC
            AnalogInput ADC0 = new AnalogInput(ADC.PA1);
            AnalogInput ADC1 = new AnalogInput(ADC.PA2);
            AnalogInput ADC2 = new AnalogInput(ADC.PA3);
            AnalogInput ADC3 = new AnalogInput(ADC.PB0); // PB0 = PA0 ???

            //DAC
            AnalogOutput DAC0 = new AnalogOutput(Cpu.AnalogOutputChannel.ANALOG_OUTPUT_0);
            AnalogOutput DAC1 = new AnalogOutput(Cpu.AnalogOutputChannel.ANALOG_OUTPUT_1);

            DAC0.Scale = 1;
            DAC0.Write(0.8);

            DAC1.Scale = 1;
            DAC1.Write(0.1);

            /* Initialize LEDs */
            LED.LEDInit();
            LED.GreenLedToggle();
            while (true)
            {
                /* Display the ADC converted value */
                //int AdcValue = (ADC0.ReadRaw() * 1);
                //string str = AdcValue.ToString();
                Debug.Print("ADC0 (pin " + ADC0.Pin + ") = " + (ADC0.ReadRaw()));
                Debug.Print("ADC1 (pin " + ADC1.Pin + ") = " + (ADC1.ReadRaw()));
                Debug.Print("ADC2 (pin " + ADC2.Pin + ") = " + (ADC2.ReadRaw()));
                Debug.Print("ADC3 (pin " + ADC3.Pin + ") = " + (ADC3.ReadRaw()));

                Debug.Print("\r\n--------------------------------\r\n");

                /* Wait for 1s */
                Thread.Sleep(250);

                /* Toggle Green LED */
                LED.GreenLedToggle();
                LED.RedLedToggle();

                DacValue1 += 100;
                if (DacValue1 > 4000)
                {
                    DacValue1 = 0;
                }
                DAC0.WriteRaw(DacValue1);

                DacValue2 += 100;
                if (DacValue2 > 4000)
                {
                    DacValue2 = 0;
                }
                DAC1.WriteRaw(DacValue2);
            }
        }
コード例 #10
0
ファイル: RGBWWLEDControl.cs プロジェクト: georgemihaila/IOT
 /// <summary>
 /// Sets an LED's duty cycle.
 /// </summary>
 /// <param name="led">The name of the LED.</param>
 /// <param name="value">The duty cycle of the LED.</param>
 /// <returns></returns>
 public async Task <string> SetLEDValueAsync(LED led, int value)
 {
     if (value < 0 || value > 1023)
     {
         throw new ArgumentOutOfRangeException("The value must be a number between 0 and 1023.");
     }
     return(await DeviceRequestAsync("pwm?" + led.ToString().ToLower() + "=" + value));
 }
コード例 #11
0
ファイル: LEDTest.cs プロジェクト: Rob2K2/KataLCD
        public void ShowNumberNineWithFormat()
        {
            string nine = LED._MIDL + '\n' + LED._FULL + '\n' + LED._MDLT;

            string nineResponse = LED.ToLCD(9);

            Assert.AreEqual(nine, nineResponse);
        }
コード例 #12
0
ファイル: LEDTest.cs プロジェクト: Rob2K2/KataLCD
        public void ShowNumberEightWithFormat()
        {
            string eight = LED._MIDL + '\n' + LED._FULL + '\n' + LED._FULL;

            string eightResponse = LED.ToLCD(8);

            Assert.AreEqual(eight, eightResponse);
        }
コード例 #13
0
ファイル: LEDTest.cs プロジェクト: Rob2K2/KataLCD
        public void ShowNumberZeroWithFormat()
        {
            string zero = LED._MIDL + '\n' + LED._BOTH + '\n' + LED._FULL;

            string zeroResponse = LED.ToLCD(0);

            Assert.AreEqual(zero, zeroResponse);
        }
コード例 #14
0
ファイル: LEDTest.cs プロジェクト: Rob2K2/KataLCD
        public void ShowNumberFiveWithFormat()
        {
            string five = LED._MIDL + '\n' + LED._MDRT + '\n' + LED._MDLT;

            string fiveResponse = LED.ToLCD(5);

            Assert.AreEqual(five, fiveResponse);
        }
コード例 #15
0
        public void TestLED()
        {
            IWattCalculator test = new Breadboard();

            Assert.AreEqual(3.50, test.Measure());
            test = new LED(test);
            Assert.AreEqual(12.36, test.Measure() - 3.50);
        }
コード例 #16
0
 public static ILEDController Get(LED led, byte modernTypeID)
 {
     if (!ledControllers.ContainsKey(modernTypeID))
         return null;
     ILEDController ledController = (ILEDController)ledControllers[modernTypeID].Invoke(new object[0]);
     ledController.AssignFrom(led);
     return ledController;
 }
コード例 #17
0
ファイル: LEDTests.cs プロジェクト: Landrash/ZoneLighting
        public void SetColor_Works()
        {
            var color = A.Dummy <Color>();
            var led   = new LED();

            led.SetColor(color);
            Assert.AreEqual(led.Color, color);
        }
コード例 #18
0
        static void Main(string[] args)
        {
            try
            {
                //Initialize the LED object
                led = new LED();

                //Hook the basic event handlers
                led.Attach += new AttachEventHandler(led_Attach);
                led.Detach += new DetachEventHandler(led_Detach);
                led.Error  += new ErrorEventHandler(led_Error);

                //Open the LED object for LED Phidget connections
                led.open();

                //Wait for a Phidget LED to be attached
                Console.WriteLine("Waiting for a LED phidget to be attached...");
                led.waitForAttachment();

                //For this example, I had a Phidget LED with 6 leds plugged in to
                //slots 0-5 respectively
                //We'll cyle through each led slowly raising the brightness from 0-100
                int i;
                int j;
                for (i = 0; i < 6; i++)
                {
                    for (j = 0; j <= 100; j++)
                    {
                        Thread.Sleep(10);
                        led.leds[i] = j;
                    }
                }

                //Turn off each led that we turned on
                for (i = 0; i < 6; i++)
                {
                    Thread.Sleep(10);
                    led.leds[i] = 0;
                }

                //Prompt the user for input to end the program
                Console.WriteLine("Press any key to end...");
                Console.Read();

                //User input was rad so we can terminate, close the LED object
                led.close();

                //Set the object to null to get it out of memory
                led = null;

                //If no excpetions were thrown at this point everything is ok
                Console.WriteLine("ok");
            }
            catch (PhidgetException ex)
            {
                Console.WriteLine(ex.Description);
            }
        }
コード例 #19
0
        static void Main(string[] args)
        {
            try
            {
                //Initialize the LED object
                led = new LED();

                //Hook the basic event handlers
                led.Attach += new AttachEventHandler(led_Attach);
                led.Detach += new DetachEventHandler(led_Detach);
                led.Error += new ErrorEventHandler(led_Error);

                //Open the LED object for LED Phidget connections
                led.open();

                //Wait for a Phidget LED to be attached
                Console.WriteLine("Waiting for a LED phidget to be attached...");
                led.waitForAttachment();

                //For this example, I had a Phidget LED with 6 leds plugged in to
                //slots 0-5 respectively
                //We'll cyle through each led slowly raising the brightness from 0-100
                int i;
                int j;
                for (i = 0; i < 6; i++)
                {
                    for(j = 0; j <= 100; j++)
                    {
                        Thread.Sleep(10);
                        led.leds[i] = j;
                    }
                }

                //Turn off each led that we turned on
                for (i = 0; i < 6; i++)
                {
                    Thread.Sleep(10);
                    led.leds[i] = 0;
                }

                //Prompt the user for input to end the program
                Console.WriteLine("Press any key to end...");
                Console.Read();

                //User input was rad so we can terminate, close the LED object
                led.close();

                //Set the object to null to get it out of memory
                led = null;

                //If no excpetions were thrown at this point everything is ok
                Console.WriteLine("ok");
            }
            catch (PhidgetException ex)
            {
                Console.WriteLine(ex.Description);
            }
        }
コード例 #20
0
 public string DisplayLEDOnScreen(string ledNo)
 {
     if (LED.ContainsKey(ledNo))
     {
         LED[ledNo] = (LED[ledNo] == $"[{OnSymbol}]") ? $"[{OffSymbol}]" : $"[{OnSymbol}]";
     }
     SetDisplayLED();
     return(DisplayLED);
 }
コード例 #21
0
ファイル: LEDTests.cs プロジェクト: Landrash/ZoneLighting
        public void GetColor_Works()
        {
            var color = A.Dummy <Color>();
            var led   = new LED {
                Color = color
            };

            Assert.AreEqual(led.GetColor(), color);
        }
コード例 #22
0
 public void Attach()
 {
     if (_serialNumber > 0 && _ledBoard == null)
     {
         _ledBoard         = new LED();
         _ledBoard.Attach += LedBoard_Attach;
         _ledBoard.open(_serialNumber);
     }
 }
コード例 #23
0
        private void vibratePlayThread()
        {
            LED.SetLedStatus(5, LED.LedFlags.STATE_ON);

            //Vibrate(0, IntPtr.Zero, true, INFINITE);
            System.Threading.Thread.Sleep(_vibration_duration);
            //VibrateStop();
            LED.SetLedStatus(5, LED.LedFlags.STATE_OFF);
        }
コード例 #24
0
ファイル: FingerLED.cs プロジェクト: gianluca-r/HandGestures
        public static FingerLED FromLED(LED led, Rectangle lightBox)
        {
            FingerLED res = new FingerLED();

            res.HaloBox    = led.HaloBox;
            res.LightBox   = lightBox;
            res.HaloColor  = led.HaloColor;
            res.LightColor = led.LightColor;
            return(res);
        }
コード例 #25
0
 private void callLED(int timeout)
 {
     try {
         Application.Current.Dispatcher.BeginInvoke(new Action(() => {
             led = new LED(timeout);
             led.ShowDialog();
         }));
     }
     catch { }
 }
コード例 #26
0
ファイル: LEDTests.cs プロジェクト: Landrash/ZoneLighting
        public void MapFadeCandyPixel_Works()
        {
            byte channel       = 1;      //A.Dummy<byte>();
            int  physicalIndex = 1;      //A.Dummy<int>();
            var  led           = new LED(pixelType: PixelType.FadeCandyWS2812Pixel);

            led.MapFadeCandyPixel(channel, physicalIndex);

            Assert.AreEqual(led.FadeCandyPixel.Channel, channel);
            Assert.AreEqual(led.FadeCandyPixel.PhysicalIndex, physicalIndex);
        }
コード例 #27
0
        static void Main(string[] args)
        {
            IVehicle ivCar = new Car();

            ivCar.Fill();
            IVehicle ivTruck = new Truck();

            ivTruck.Running();
            Screen s = new LED();

            s.PowerOn();
        }
コード例 #28
0
 /// <summary>
 /// Send a request to permanently change into a specified color
 /// </summary>
 /// <param name="color">The color the light should become</param>
 /// <param name="led">The LEDs that should change color</param>
 public void SendColor(System.Drawing.Color color, LED led = LED.All)
 {
     byte[] colorBytes = ColorHelpers.ColorToBytes(color, this.Brightness);
     // TODO: actually flash and return to previous color
     SendBytes((byte)LightCommand.ComplexColor, new byte[]
     {
         (byte)led,
         colorBytes[0],
         colorBytes[1],
         colorBytes[2],
     });
 }
コード例 #29
0
 private void SetLED(int note, LED led, bool force = false)
 {
     if (led == LED.Off)
     {
         NoteOn(note, 0);
         NoteOff(note);
     }
     else
     {
         NoteOn(note, (int)led);
     }
 }
コード例 #30
0
        private void LedChannelEnableOnClick(object sender, EventArgs eventArgs)
        {
            LED led = sender as LED;

            led.Value = !led.Value;
            int selectedIndex = _parentControl.SelectedIndex;

            if (selectedIndex < _configData.Count)
            {
                _configData[selectedIndex].Enabled = led.Value;
                _globalInfo.ApplyConfigInRunTime.Invoke();
            }
        }
コード例 #31
0
 public BHTController()
 {
     try
     {
         MyBeep = new Beep();
         MyLed  = new LED();
     }
     catch (Exception ex)
     {
         MyScanner = (Scanner)null;
         MessageBox.Show("Error: Please make sure kbif software is not running " + ex.Message, "Scan Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
     }
 }
        public void hid_setLedOff(LED a)
        {
            //check if LED is already off
            if ((byte)((byte)(((uint)a << 1) & HIDBuffer[11])) != 0)
            {
                //set the LED into the write buffer
                HIDBuffer[11] = (byte)((byte)(((uint)a & 0x0f) << 1) ^ HIDBuffer[11]);

                HID_Command(HIDBuffer, PS3Controller.OUTPUT_REPORT_BUFFER.Length + 2);
            }
        }
コード例 #33
0
ファイル: Form1.cs プロジェクト: souryavaranasi/launch-tower
        //Create and initialize an LED object to control an attached LED.  Hook the event handlers to the object and open.
        private void Form1_Load(object sender, EventArgs e)
        {
            ledIndexCmb.Enabled = false;
            ledTrk.Enabled = false;
            ledTrk.SetRange(0, 100);

            led = new LED();

            led.Attach += new AttachEventHandler(led_Attach);
            led.Detach += new DetachEventHandler(led_Detach);
            led.Error += new ErrorEventHandler(led_Error);

            openCmdLine(led);
        }
コード例 #34
0
ファイル: Driver.cs プロジェクト: JeremyCBrooks/blinkenlights
        public bool EnableLED(LED led)
        {
			return writeValue(((int)led).ToString());
        }
コード例 #35
0
ファイル: PhidgetLEDBoard.cs プロジェクト: Heliflyer/helios
 public void Attach()
 {
     if (_serialNumber > 0 && _ledBoard == null)
     {
         _ledBoard = new LED();
         _ledBoard.Attach += LedBoard_Attach;
         _ledBoard.open(_serialNumber);
     }
 }
コード例 #36
0
ファイル: PhidgetLEDBoard.cs プロジェクト: Heliflyer/helios
        public void Detach()
        {
            if (_ledBoard != null && _ledBoard.Attached)
            {
                try
                {
                    for (int i = 0; i < _ledBoard.leds.Count; i++)
                    {
                        _ledBoard.leds[i] = 0;
                    }

                    _ledBoard.close();
                    _ledBoard = null;
                }
                catch (PhidgetException e)
                {
                    ConfigManager.LogManager.LogError("Error closing led board", e);
                }
            }
        }
コード例 #37
0
ファイル: Light.cs プロジェクト: JetDeveloper/Radiators
 /**
  * Расчет таблицы для расчета освещенности для каждого полярного угла
  * гамма при смещении плоскости на определенный азимутальный угол С0
  * (см. Светотехнический расчет)
  */
 public LED[] getFirstTable(LED[] table, double F)
 {
     for (int i = 0; i < table.Length; i++)
     {
         if (table[i].isON)
             table[i].I0 = F / Math.PI;
         else
             table[i].I0 = 0;
     }
     return table;
 }
        public void hid_setLedOn(LED a)
        {
            HIDBuffer[11] = (byte)((byte)(((uint)a & 0x0f) << 1) | HIDBuffer[11]);

            HID_Command(HIDBuffer, PS3Controller.OUTPUT_REPORT_BUFFER.Length + 2);
        }