Esempio n. 1
0
        protected List <IDestination> GetRenderers(BaseOptions options)
        {
            var renderers = new List <IDestination>();

            switch (options.Destination)
            {
            case Auto:
                renderers = GetAvailableRenderers(options);
                break;

            case PinDMDv1:
                var pinDmd1 = PinDmd1.GetInstance();
                if (pinDmd1.IsAvailable)
                {
                    renderers.Add(pinDmd1);
                    Logger.Info("Added PinDMDv1 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv1.ToString());
                }
                break;

            case PinDMDv2:
                var pinDmd2 = PinDmd2.GetInstance();
                if (pinDmd2.IsAvailable)
                {
                    renderers.Add(pinDmd2);
                    Logger.Info("Added PinDMDv2 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv2.ToString());
                }
                break;

            case PinDMDv3:
                var pinDmd3 = PinDmd3.GetInstance(options.Port);
                if (pinDmd3.IsAvailable)
                {
                    renderers.Add(pinDmd3);
                    Logger.Info("Added PinDMDv3 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv3.ToString());
                }
                break;

            case PIN2DMD:
                var pin2Dmd = Pin2Dmd.GetInstance();
                if (pin2Dmd.IsAvailable)
                {
                    renderers.Add(pin2Dmd);
                    Logger.Info("Added PIN2DMD renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PIN2DMD.ToString());
                }
                break;

            case Virtual:
                renderers.Add(ShowVirtualDmd(options));
                Logger.Info("Added VirtualDMD renderer.");

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (renderers.Count == 0)
            {
                throw new NoRenderersAvailableException();
            }

            if (!ColorUtil.IsColor(options.RenderColor))
            {
                throw new InvalidOptionException("Argument --color must be a valid RGB color. Example: \"ff0000\".");
            }
            foreach (var renderer in renderers)
            {
                var rgb24 = renderer as IRgb24Destination;
                rgb24?.SetColor(ColorUtil.ParseColor(options.RenderColor));
            }
            _options = options;
            return(renderers);
        }
Esempio n. 2
0
        protected List <IFrameDestination> GetRenderers(BaseOptions options)
        {
            var renderers = new List <IFrameDestination>();

            switch (options.Destination)
            {
            case Auto:
                renderers = GetAvailableRenderers(options);
                break;

            case PinDMDv1:
                var pinDmd1 = PinDmd1.GetInstance();
                if (pinDmd1.IsAvailable)
                {
                    renderers.Add(pinDmd1);
                    Logger.Info("Added PinDMDv1 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv1.ToString());
                }
                break;

            case PinDMDv2:
                var pinDmd2 = PinDmd2.GetInstance();
                if (pinDmd2.IsAvailable)
                {
                    renderers.Add(pinDmd2);
                    Logger.Info("Added PinDMDv2 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv2.ToString());
                }
                break;

            case PinDMDv3:
                var pinDmd3 = PinDmd3.GetInstance();
                if (pinDmd3.IsAvailable)
                {
                    renderers.Add(pinDmd3);
                    Logger.Info("Added PinDMDv3 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv3.ToString());
                }
                break;

            case PIN2DMD:
                var pin2Dmd = Pin2Dmd.GetInstance();
                if (pin2Dmd.IsAvailable)
                {
                    renderers.Add(pin2Dmd);
                    Logger.Info("Added PIN2DMD renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PIN2DMD.ToString());
                }
                break;

            case Virtual:
                renderers.Add(ShowVirtualDmd(options));
                Logger.Info("Added VirtualDMD renderer.");

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (renderers.Count == 0)
            {
                throw new NoRenderersAvailableException();
            }
            return(renderers);
        }