Beispiel #1
0
        private static void ReadConfig()
        {
            string configData = String.Empty;

            try
            {
                using (StreamReader reader = new StreamReader(ConfigFilePath))
                {
                    configData = reader.ReadToEnd();
                }

                if (String.IsNullOrEmpty(configData) != true)
                {
                    _lightsConfig = JsonConvert.DeserializeObject <LightsConfig>(configData);
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Failed to read the config file `{0}` - Reason: {1}", ConfigFilePath, e.Message);
                CrestronConsole.PrintLine("Failed to read the config file `{0}` - Reason: {1}", ConfigFilePath, e.Message);
            }
            finally { }
        }
Beispiel #2
0
 public static void CreateNewConfig(LightsConfig lightsConfig)
 {
     _lightsConfig = lightsConfig;
     WriteConfig();
     ReloadConfig();
 }
        public void Initialize()
        {
            try
            {
                if (LightsConfigManager.Initialize() != LightsConfigManager.eConfigInitializationSuccessFailureReasons.Success)
                {
                    var configObj = new LightsConfig();

                    configObj.Profiles = new Dictionary <string, DMXFixtureProfileConfig>(2)
                    {
                        { "ETC Source Four LED Studio HD", new DMXFixtureProfileConfig()
                          {
                              Id = 1, Name = "ETC Source Four LED Studio HD", DMXChannels = new Dictionary <DMXChannel, ushort>()
                              {
                                  { DMXChannel.Intensity, 1 },
                                  { DMXChannel.WhitePoint, 2 },
                              }
                          } },
                        { "Elation Satura Profile Basic", new DMXFixtureProfileConfig()
                          {
                              Id = 2, Name = "Elation Satura Profile Basic", DMXChannels = new Dictionary <DMXChannel, ushort>()
                              {
                                  { DMXChannel.Intensity, 15 },
                                  { DMXChannel.Pan, 1 },
                                  { DMXChannel.Tilt, 2 },
                                  { DMXChannel.Zoom, 20 },
                                  { DMXChannel.Iris, 18 },
                                  { DMXChannel.Focus, 19 },
                                  { DMXChannel.Blade1, 21 },
                                  { DMXChannel.Blade1Rotate, 22 },
                                  { DMXChannel.Blade2, 23 },
                                  { DMXChannel.Blade2Rotate, 24 },
                                  { DMXChannel.Blade3, 25 },
                                  { DMXChannel.Blade3Rotate, 26 },
                                  { DMXChannel.Blade4, 27 },
                                  { DMXChannel.Blade4Rotate, 28 },
                              },
                          } },
                        { "Elation Satura Profile Standard", new DMXFixtureProfileConfig()
                          {
                              Id = 3, Name = "Elation Satura Profile Standard", DMXChannels = new Dictionary <DMXChannel, ushort>()
                              {
                                  { DMXChannel.Intensity, 17 },
                                  { DMXChannel.Pan, 1 },
                                  { DMXChannel.PanFine, 2 },
                                  { DMXChannel.Tilt, 3 },
                                  { DMXChannel.TiltFine, 4 },
                                  { DMXChannel.Zoom, 22 },
                                  { DMXChannel.Iris, 20 },
                                  { DMXChannel.Focus, 21 },
                                  { DMXChannel.Blade1, 23 },
                                  { DMXChannel.Blade1Rotate, 24 },
                                  { DMXChannel.Blade2, 25 },
                                  { DMXChannel.Blade2Rotate, 26 },
                                  { DMXChannel.Blade3, 27 },
                                  { DMXChannel.Blade3Rotate, 28 },
                                  { DMXChannel.Blade4, 29 },
                                  { DMXChannel.Blade4Rotate, 30 },
                              },
                          } },
                    };

                    configObj.Lights = new Dictionary <string, List <DMXFixtureConfig> >(3)
                    {
                        { "Podium", new List <DMXFixtureConfig>(2)
                          {
                              new DMXFixtureConfig()
                              {
                                  Id = 1, Name = "South #1", Profile = configObj.Profiles["ETC Source Four LED Studio HD"], BaseDMXChannel = 11
                              },
                              new DMXFixtureConfig()
                              {
                                  Id = 2, Name = "North #4", Profile = configObj.Profiles["ETC Source Four LED Studio HD"], BaseDMXChannel = 41
                              },
                          } },
                        { "Stage", new List <DMXFixtureConfig>(4)
                          {
                              new DMXFixtureConfig()
                              {
                                  Id = 3, Name = "South #2", Profile = configObj.Profiles["ETC Source Four LED Studio HD"], BaseDMXChannel = 21
                              },
                              new DMXFixtureConfig()
                              {
                                  Id = 4, Name = "South #3", Profile = configObj.Profiles["ETC Source Four LED Studio HD"], BaseDMXChannel = 31
                              },
                              new DMXFixtureConfig()
                              {
                                  Id = 5, Name = "North #5", Profile = configObj.Profiles["ETC Source Four LED Studio HD"], BaseDMXChannel = 51
                              },
                              new DMXFixtureConfig()
                              {
                                  Id = 6, Name = "North #6", Profile = configObj.Profiles["ETC Source Four LED Studio HD"], BaseDMXChannel = 61
                              },
                          } },
                        { "PTZ", new List <DMXFixtureConfig>(2)
                          {
                              new DMXFixtureConfig()
                              {
                                  Id = 7, Name = "South", Profile = configObj.Profiles["Elation Satura Profile Standard"], BaseDMXChannel = 256,
                              },
                              new DMXFixtureConfig()
                              {
                                  Id = 8, Name = "North", Profile = configObj.Profiles["Elation Satura Profile Standard"], BaseDMXChannel = 310,
                              },
                          } },
                    };

                    LightsConfigManager.CreateNewConfig(configObj);
                }

                if (LightsPresetManager.Initialize() != LightsPresetManager.ePresetInitializationSuccessFailureReasons.Success)
                {
                    ErrorLog.Error("Failed to initialize presets");
                }

                foreach (string group in LightsConfigManager.Groups)
                {
                    //List<DMXFixture> groupDmxFixtures = new List<DMXFixture>(LightsConfigManager.GroupFixtures(group).Count);

                    LightGroup lightGroup = new LightGroup((uint)(_lightGroups.Count + 1), group);
                    _lightGroups.Add(lightGroup);

                    foreach (DMXFixtureConfig dmxFixtureConfig in LightsConfigManager.GroupFixtures(group))
                    {
                        DMXFixture dmxFixture;
                        switch (dmxFixtureConfig.Profile.Name)
                        {
                        case "ETC Source Four LED Studio HD":
                            dmxFixture = new DMXFixture(lightGroup, dmxFixtureConfig, _transport);
                            break;

                        case "Elation Satura Profile Standard":
                            dmxFixture = new DMXPTZFixture(lightGroup, dmxFixtureConfig, _transport);
                            break;

                        default:
                            dmxFixture = new DMXFixture(lightGroup, dmxFixtureConfig, _transport);
                            break;
                        }
                    }
                }

                CrestronConsole.AddNewConsoleCommand(ConsoleCommandLightGroups, "lightgroups", "List light groups. Use \"LIGHTGROUPS ?\" for more info.", ConsoleAccessLevelEnum.AccessOperator);
                CrestronConsole.AddNewConsoleCommand(ConsoleCommandLightGroup, "lightgroup", "Light master commands. Use \"LIGHTGROUP ?\" for more info.", ConsoleAccessLevelEnum.AccessOperator);
                CrestronConsole.AddNewConsoleCommand(ConsoleCommandLights, "lights", "Lighting commands. Use \"LIGHTS ?\" for more info.", ConsoleAccessLevelEnum.AccessOperator);
                CrestronConsole.AddNewConsoleCommand(ConsoleCommandTest, "test", "TEST commands. Use \"TEST ?\" for more info.", ConsoleAccessLevelEnum.AccessOperator);

                ErrorLog.Notice(">>> LightsControl: initialized successfully");
            }
            catch (Exception e)
            {
                ErrorLog.Error(">>> LightControl: Error in InitializeSystem: {0}\r\n{1}", e.Message, e.StackTrace);
            }
        }