Esempio n. 1
0
        /// <summary>
        /// Allcoate resources, parse the config file which contains all the
        /// animations and create a list of animation objects. Subscribe to
        /// events
        /// </summary>
        /// <param name="configPath">Name of the config file for the panel</param>
        /// <returns>true on success</returns>
        public bool Init(String configPath)
        {
            bool retVal = _animationsCollection.Load(configPath);

            if (retVal)
            {
                retVal = _interpreter.LoadScripts(configPath);
            }

            if (retVal)
            {
                _switchConfig = new SwitchConfig();
                _switchConfig.Load(configPath);
            }

            if (retVal)
            {
                subscribeToInterpreterEvents();

                subscribeToActuatorEvents();
            }

            Log.Debug("returning from Anim manager init()");

            return(retVal);
        }
Esempio n. 2
0
 // --- コンストラクタ ---
 /// <summary>
 /// 静的コンストラクタ
 /// </summary>
 static LoadSwitch()
 {
     load_switch_   = new LoadSwitch();
     switch_config_ = new SwitchConfig[ALL_SWITCH];
     for (int i = 0; i < ALL_SWITCH; i++)
     {
         switch_config_[i] = new SwitchConfig();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Returns the action associated with the switch.  These actions
        /// are configured in the switch map config file. First checks the
        /// animation config file to see if there is a mapping there.  If not
        /// goes to the global mapping table
        /// </summary>
        /// <param name="switchObj">the switch object</param>
        /// <returns>associated pCode</returns>
        private PCode getOnTrigger(IActuatorSwitch switchObj)
        {
            const string defaultWidgetClass = "default";

            Log.Debug();

            if (_switchConfig == null)
            {
                return(null);
            }

            // check local switchmap first
            PCode pCode = _switchConfig.GetOnTrigger(switchObj);

            if (pCode != null)
            {
                Log.Debug("Found local pcode for " + switchObj.Name);
                return(pCode);
            }

            Log.Debug("Did not find local switchconfig.  Checking global one");

            // if this panel is a member of a 'class' of panels(configured thru
            // the subclass attribute), check if there is a switch map for the class.
            // otherwise, just use the default one.

            var widgetClass = (_currentPanel != null) ? _currentPanel.SubClass : String.Empty;

            if (String.IsNullOrEmpty(widgetClass))
            {
                widgetClass = defaultWidgetClass;
            }

            Log.Debug("widgetclass: " + widgetClass);

            SwitchConfig switchConfig = ActuatorManager.Instance.SwitchConfigMap;

            PCode retVal = switchConfig.GetOnTrigger(widgetClass, switchObj);

            if (retVal != null)
            {
                return(retVal);
            }

            if (widgetClass != defaultWidgetClass)
            {
                Log.Debug("Could not find PCode for " + widgetClass + ", trying default");
                widgetClass = defaultWidgetClass;

                retVal = switchConfig.GetOnTrigger(widgetClass, switchObj);
            }

            Log.IsNull("retval ", retVal);

            return(retVal);
        }
Esempio n. 4
0
 private void LoadConfiguration()
 {
     try {
         Configuration = ConfigurationManager.LoadConfiguration();
         EventGenerator.Configuration = Configuration;
     }
     catch (System.Exception exc) {
         throw new AudioDeviceSwitchException("Could not load the configuration. " + exc.Message, exc);
     }
 }
Esempio n. 5
0
        public SwitchConfig LoadConfiguration()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(SwitchConfig));

            StreamReader reader = new StreamReader(Path);
            SwitchConfig config = (SwitchConfig)serializer.Deserialize(reader);

            reader.Close();

            return(config);
        }
Esempio n. 6
0
        public SwitchConfig LoadConfiguration()
        {
            SwitchConfig config = new SwitchConfig();

            config.PollingIntervalMillis = 1000;
            config.TimeoutMillis         = 0;

            config.Rules.Add(new SwitchRule(true, "Netflix", "123"));

            config.Rules.Add(new SwitchRule(false, "Netflix", "456"));

            return(config);
        }
Esempio n. 7
0
        public void SaveConfiguration(SwitchConfig configuration)
        {
            XmlSerializer xsSubmit = new XmlSerializer(typeof(SwitchConfig));
            var           xml      = "";
            var           subReq   = configuration;

            using (var sww = new StringWriter())
            {
                using (XmlWriter writer = XmlWriter.Create(sww))
                {
                    xsSubmit.Serialize(writer, subReq);
                    xml = sww.ToString();

                    File.WriteAllText(Path, xml);
                }
            }
        }
Esempio n. 8
0
 public void SaveConfiguration(SwitchConfig configuration)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 9
0
 public void AddSwitchId(SwitchConfig switchConfig) => _switchHandler.AddSwitchId(switchConfig.WithPulse(_isPulseSwitch));