Ejemplo n.º 1
0
        /// <summary>
        /// Overrides settings.
        /// </summary>
        /// <param name="config">Configuration values to override with.</param>
        public void Override(MambaConfiguration config)
        {
            if (!string.IsNullOrEmpty(config.MyceliumIp))
            {
                MyceliumIp = config.MyceliumIp;
            }

            if (config.MyceliumPort > 0)
            {
                MyceliumPort = config.MyceliumPort;
            }

            if (!string.IsNullOrEmpty(config.TrellisUrl))
            {
                TrellisUrl = config.TrellisUrl;
            }

            if (!string.IsNullOrEmpty(config.Token))
            {
                Token = config.Token;
            }

            if (!string.IsNullOrEmpty(config.ExperienceId))
            {
                ExperienceId = config.ExperienceId;
            }

            if (!string.IsNullOrEmpty(config.GraphiteHost))
            {
                GraphiteHost = config.GraphiteHost;
            }

            if (!string.IsNullOrEmpty(config.GraphiteKey))
            {
                GraphiteKey = config.GraphiteKey;
            }

            if (!string.IsNullOrEmpty(config.LogglyKey))
            {
                LogglyKey = config.LogglyKey;
            }

            if (config.Kinect != null)
            {
                Kinect.Override(config.Kinect);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts the application.
        /// </summary>
        /// <param name="config">Options to run with.</param>
        /// <returns></returns>
        private static async Task Run(MambaConfiguration config)
        {
            using (var experience = new ExperienceController(new ExperienceControllerConfig
            {
                AppId = config.ExperienceId,
                TrellisToken = config.Token,
                TrellisUrl = config.TrellisUrl
            }))
            {
                ElementData elements;
                // load experience first
                try
                {
                    elements = await experience.Initialize();
                }
                catch (Exception exception)
                {
                    Log.Error($"Could not initialize experience: '{exception}'.");

                    return;
                }

                using (var network = new MyceliumController(new MyceliumControllerConfiguration
                {
                    Ip = config.MyceliumIp,
                    Port = config.MyceliumPort,
                    Token = config.Token
                }))
                {
                    using (var kinect = new KinectController(new KinectControllerConfiguration(), network, elements))
                    {
                        network.Start();
                        kinect.Start();

                        Console.ReadLine();

                        Log.Information("Shutting down.");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an AppActorConfiguration.
        /// </summary>
        /// <returns></returns>
        private static MambaConfiguration Configuration()
        {
            // construct the application config
            var config = new MambaConfiguration();

            // override defaults with app-config.json
            var src = File.ReadAllText("app-config.json");

            config.Override(JsonConvert.DeserializeObject <MambaConfiguration>(src));

            // override with environment variables
            SetFromEnvironment("EXPERIENCE_ID", ref config.ExperienceId, a => a);
            SetFromEnvironment("TRELLIS_URL", ref config.TrellisUrl, a => a);
            SetFromEnvironment("TRELLIS_TOKEN", ref config.Token, a => a);
            SetFromEnvironment("MYCELIUM_IP", ref config.MyceliumIp, a => a);
            SetFromEnvironment("MYCELIUM_PORT", ref config.MyceliumPort, int.Parse);
            SetFromEnvironment("GRAPHITE_HOST", ref config.GraphiteHost, a => a);
            SetFromEnvironment("GRAPHITE_KEY", ref config.GraphiteKey, a => a);

            return(config);
        }