Beispiel #1
0
        private void InitializeCommand(ConfigData cmdConfig, ConfiguredStationCommand cc)
        {
            StationCommand cmd = null;
            try
            {
                cmd = NewStationCommand(cmdConfig);
                if (cmd != null)
                {
                    cc.StationCommand = cmd;
                    cc.Description = cmd.Description; // allow command to provide an updated description
                    //cc.enabled = true;
                }
            }
            catch (Exception e)
            {
                cc.Error = e.Message;

                errors += "Command not available: ";
                errorsDetail += "Command not available: ";
                if (cmd != null)
                {
                    errors += cmd.ToString();
                    errorsDetail += cmd.ToString();
                }
                errors += "\n";
                errors += e.Message + "\n";

                errorsDetail += "\n";
                errorsDetail += e + "\n";
            }
        }
Beispiel #2
0
        private void ConfigureCommands(ConfigData config)
        {
            // for each command element in the configStream file,
            // create a StationCommand and add it to the Commands list
            List<ConfigData> commandConfigs = config.GetConfigSections(Constants.CommandConfig);
            int index = 0;
            foreach (ConfigData cmdConfig in commandConfigs)
            {
                ConfiguredStationCommand cc = new ConfiguredStationCommand(index++);

                cc.Description = cmdConfig.Value(Constants.CommandDescription);
                if (string.IsNullOrWhiteSpace(cc.Description))
                    cc.Description = cmdConfig.Value(Constants.CommandClassName);

                configuredCommands.Add(cc);

                InitializeCommand(cmdConfig, cc);
                //// if the Command is configured to be inactive, don't initialize
                //String active = cmdConfig.value(Constants.ACTIVE_STATION);
                //if (active == null || !active.Equals(Constants.FALSE, StringComparison.InvariantCultureIgnoreCase))
                //{
                //    InitializeCommand(cmdConfig, cc);
                //}

            }
        }