示例#1
0
        private void StatusRefresh_Tick(ThreadPoolTimer timer)
        {
            int      tempRed    = (int)RGBValue.MaxValue * 50 / MaxSliderValue;
            int      tempGreen  = (int)RGBValue.MaxValue * 50 / MaxSliderValue;
            int      tempBlue   = (int)RGBValue.MaxValue * 0 / MaxSliderValue;
            int      tempIntens = (int)RGBValue.MaxValue * 10 / MaxSliderValue;
            RGBValue newLEDval  = new RGBValue {
                Red = (byte)tempRed, Green = (byte)tempGreen, Blue = (byte)tempBlue, Intensity = (byte)tempIntens
            };

            StatusLED.SetLED(0, newLEDval);
            StatusLED.UpdateLEDs();
        }
示例#2
0
        //static ProtocolV1Base ProtocolV1BaseObj = new ProtocolV1Base();
        //static string ProtocolV1Marker = nameof(ProtocolV1BaseObj.MyType);

        //App_IO_Demo.IoDemoBoard ioDemoBoard = new App_IO_Demo.IoDemoBoard();
        //libCore.IOevalBoard.IoDemoBoard ioDemoBoard = new libCore.IOevalBoard.IoDemoBoard();

        //private void Server_NotifyMessageReceivedEvent(object sender, byte[] data)
        //{
        //    try
        //    {
        //        var obj = libSharedProject.ProtolV1Commands.ProtocolV1Base.ConvertJsonStingToObj(System.Text.Encoding.UTF8.GetString(data));

        //        if (obj != null)
        //        {
        //            if (obj.GetType().Equals(typeof(libSharedProject.ProtolV1Commands.IoDemoGetRequest)))
        //            {
        //                switch (((libSharedProject.ProtolV1Commands.IoDemoGetRequest)obj).Key)
        //                {
        //                    case IoDemoGetRequest.CmdValue.Adc:

        //                        this.SendText(Newtonsoft.Json.JsonConvert.SerializeObject(ioDemoBoard.GetAdc()));

        //                        break;
        //                    case IoDemoGetRequest.CmdValue.Dac:

        //                        this.SendText(Newtonsoft.Json.JsonConvert.SerializeObject(ioDemoBoard.GetDac()));

        //                        break;
        //                    case IoDemoGetRequest.CmdValue.Gpio:

        //                        this.SendText(Newtonsoft.Json.JsonConvert.SerializeObject(ioDemoBoard.GetGpio()));

        //                        break;
        //                    case IoDemoGetRequest.CmdValue.Powerstate:

        //                        this.SendText(Newtonsoft.Json.JsonConvert.SerializeObject(ioDemoBoard.GetPowerState()));

        //                        break;
        //                    case IoDemoGetRequest.CmdValue.Rgb:

        //                        this.SendText(Newtonsoft.Json.JsonConvert.SerializeObject(ioDemoBoard.GetRgb()));

        //                        break;
        //                    case IoDemoGetRequest.CmdValue.State:

        //                        this.SendText(Newtonsoft.Json.JsonConvert.SerializeObject(ioDemoBoard.GetState()));

        //                        break;
        //                    default:
        //                        break;
        //                }
        //            }
        //            else if (obj.GetType().Equals(typeof(IoDemoDac)))
        //            {
        //                ioDemoBoard.SetDac((IoDemoDac)obj);
        //            }
        //            else if (obj.GetType().Equals(typeof(IoDemoGpio)))
        //            {
        //                ioDemoBoard.SetGpio((IoDemoGpio)obj);
        //            }
        //            else if (obj.GetType().Equals(typeof(IoDemoPowerState)))
        //            {
        //                ioDemoBoard.SetPowerState((IoDemoPowerState)obj);
        //            }
        //            else if (obj.GetType().Equals(typeof(IoDemoState)))
        //            {
        //                ioDemoBoard.SetState((IoDemoState)obj);
        //            }
        //            else if (obj.GetType().Equals(typeof(IoDemoRgb)))
        //            {
        //                ioDemoBoard.SetRgb((IoDemoRgb)obj);
        //            }
        //        }
        //        else
        //        {
        //            this.AddInfoTextLine("Text:" + System.Text.Encoding.UTF8.GetString(data) + " Data:" + Converters.ConvertByteArrayToHexString(data, " "));
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        ShowMessageBox(ExceptionHandling.GetExceptionText(new System.Exception(string.Format("Exception In: {0}", CallerName()), ex)));
        //    }
        //}

        //libShared.Interfaces.IEthernetAsync server;

        //public IEthernetAsync Server
        //{
        //    get
        //    {
        //        return server;
        //    }

        //    internal set
        //    {
        //        server = value;
        //    }
        //}

        //string port = "27200";


        //public string Port
        //{
        //    get { return port; }
        //    set
        //    {
        //        port = value;
        //        this.OnPropertyChanged();
        //    }
        //}

        //string host = "localhost";

        //public string Host
        //{
        //    get { return host; }
        //    set
        //    {
        //        host = value;
        //        this.OnPropertyChanged();
        //    }
        //}

        //ObservableCollection<string> hostNames = new ObservableCollection<string>();

        //public ObservableCollection<string> HostNames
        //{
        //    get
        //    {
        //        return hostNames;
        //    }

        //    set
        //    {
        //        hostNames = value;
        //    }
        //}

        //private string valueSendText = "Test Cmd";

        //public string ValueSendText
        //{
        //    get { return valueSendText; }
        //    set
        //    {
        //        valueSendText = value;
        //        this.OnPropertyChanged();
        //    }
        //}

        //ObservableCollection<byte> valueSendData = new ObservableCollection<byte>();

        //public ObservableCollection<byte> ValueSendData
        //{
        //    get { return valueSendData; }
        //    set
        //    {
        //        valueSendData = value;
        //        this.OnPropertyChanged();
        //    }
        //}

        //public void SendText(string text)
        //{
        //    try
        //    {
        //        if (this.Server != null)
        //        {
        //            this.Server.SendText(text);
        //        }
        //        else
        //        {
        //            this.AddInfoTextLine("Server Not Running");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        //AddInfoTextLine(ExceptionHandling.GetExceptionText(new System.Exception(string.Format("Exception In: {0}", CallerName()), ex)));
        //    }
        //}

        //public void SendData(byte[] data)
        //{
        //    try
        //    {
        //        if (this.Server != null)
        //        {
        //            this.Server.SendData(data);
        //        }
        //        else
        //        {
        //            this.AddInfoTextLine("Server Not Running");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        //AddInfoTextLine(ExceptionHandling.GetExceptionText(new System.Exception(string.Format("Exception In: {0}", CallerName()), ex)));
        //    }
        //}

        #endregion
        #region Debug-Ausgaben

        ///// <summary>
        ///// Fühgt der Infotext Liste einen weiteren Eintrag hinzu
        ///// </summary>
        //public void AddInfoTextLine(string line)
        //{
        //    this.AddInfoTextLine(null, line);
        //}

        ///// <summary>
        ///// ühgt der Infotext Liste einen weiteren Eintrag hinzu
        ///// </summary>
        //public async void AddInfoTextLine(object sender, string line)
        //{
        //    //try
        //    //{
        //    //    //await this.dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        //    //    //{
        //    //    //    if (this.InfoText.Length > 1000)
        //    //    //    {
        //    //    //        this.InfoText = line + Environment.NewLine;
        //    //    //    }
        //    //    //    else
        //    //    //    {
        //    //    //        this.InfoText += line + Environment.NewLine;
        //    //    //    }

        //    //    //    Scoll1.ChangeView(null, Scoll1.ScrollableHeight, null);

        //    //        //this.InfoTextList.Add(line);
        //    //    //});
        //    //}
        //    //catch (Exception ex)
        //    //{
        //    //    //ShowMessageBox(ExceptionHandling.GetExceptionText(new System.Exception(string.Format("Exception In: {0}", CallerName()), ex)));
        //    //}
        //}

        #endregion



        private void btn_SetRGBvalues(object sender, RoutedEventArgs e)
        {
            //@todo hier auf Binding setzten

            int      tempRed    = (int)RGBValue.MaxValue * (int)RedChannel.Value / MaxSliderValue;
            int      tempGreen  = (int)RGBValue.MaxValue * (int)GreenChannel.Value / MaxSliderValue;
            int      tempBlue   = (int)RGBValue.MaxValue * (int)BlueChannel.Value / MaxSliderValue;
            int      tempIntens = (int)RGBValue.MaxValue * (int)IntensitySet.Value / MaxSliderValue;
            RGBValue newLEDval  = new RGBValue {
                Red = (byte)tempRed, Green = (byte)tempGreen, Blue = (byte)tempBlue, Intensity = (byte)tempIntens
            };

            StatusLED.SetLED(0, newLEDval);
            StatusLED.UpdateLEDs();
        }
示例#3
0
        private void ArrayTimer_Tick(object sender, object e)
        {
            RGBValue tempNewLEDval;

            StatusLED.GetLEDvalue(0, out tempNewLEDval);
            cycleCount++;

            switch (cycleCount)
            {
            case 1:
                LEDArray.SetLED(8, RGBDefines.Black);
                LEDArray.SetLED(0, tempNewLEDval);
                break;

            case 2:
                LEDArray.SetLED(0, RGBDefines.Black);
                LEDArray.SetLED(1, tempNewLEDval);
                break;

            case 3:
                LEDArray.SetLED(1, RGBDefines.Black);
                LEDArray.SetLED(2, tempNewLEDval);
                break;

            case 4:
                LEDArray.SetLED(2, RGBDefines.Black);
                LEDArray.SetLED(3, tempNewLEDval);
                break;

            case 5:
                LEDArray.SetLED(3, RGBDefines.Black);
                LEDArray.SetLED(4, tempNewLEDval);
                break;

            case 6:
                LEDArray.SetLED(4, RGBDefines.Black);
                LEDArray.SetLED(5, tempNewLEDval);
                break;

            case 7:
                LEDArray.SetLED(5, RGBDefines.Black);
                LEDArray.SetLED(6, tempNewLEDval);
                break;

            case 8:
                LEDArray.SetLED(6, RGBDefines.Black);
                LEDArray.SetLED(7, tempNewLEDval);
                break;

            case 9:
                LEDArray.SetLED(7, RGBDefines.Black);
                LEDArray.SetLED(8, tempNewLEDval);
                cycleCount = 0;
                break;

            default:
                cycleCount = 0;
                break;
            }
            LEDArray.UpdateLEDs();
        }
示例#4
0
        private void StatusTimer_Tick(object sender, object e)
        {
            RGBValue tempLEDobj;

            StatusLED.GetLEDvalue(0, out tempLEDobj);

            if (currAccenting == true)
            {
                currCount += 0x500;
            }
            else
            {
                currCount -= 0x500;
            }

            switch (statusMachineCount)
            {
            case 0:     // fading red
                tempLEDobj.Red = (byte)currCount;
                break;

            case 1:     // fading green
                tempLEDobj.Green = (byte)currCount;
                break;

            case 2:     // fading blue
                tempLEDobj.Blue = (byte)currCount;
                break;

            case 3:     // fading red
                tempLEDobj.Red   = (byte)currCount;
                tempLEDobj.Green = (byte)currCount;
                break;

            case 4:     // fading red
                tempLEDobj.Red  = (byte)currCount;
                tempLEDobj.Blue = (byte)currCount;
                break;

            case 5:     // fading red
                tempLEDobj.Green = (byte)currCount;
                tempLEDobj.Blue  = (byte)currCount;
                break;

            case 6:     // fading red
                tempLEDobj.Red   = (byte)currCount;
                tempLEDobj.Green = (byte)currCount;
                tempLEDobj.Blue  = (byte)currCount;
                break;

            case 7:     // fading red
                tempLEDobj.Red     = (byte)currCount;
                statusMachineCount = 0;
                break;

            default:
                statusMachineCount = 0;
                break;
            }
            tempLEDobj.Intensity = RGBValue.MaxValue;

            if ((currAccenting == true) && (currCount >= 0x6400))
            {
                currAccenting = false;
            }
            if ((currAccenting == false) && (currCount <= 0))
            {
                currAccenting = true;
                statusMachineCount++;
            }

            StatusLED.SetLED(0, tempLEDobj);
            StatusLED.UpdateLEDs();
        }
示例#5
0
 private void BlackoutArray()
 {
     for (int i = 0; i < 8; i++)
     {
         LEDArray.SetLED(i, RGBDefines.Black);
     }
     LEDArray.UpdateLEDs();
 }