コード例 #1
0
ファイル: hacs.cs プロジェクト: devrez/hacs
        static void Main(string[] args)
        {
            #region ConsoleOutputLogger
            ConsoleOutputLogger ConsoleOutputLogger = new hacs.ConsoleOutputLogger();
            ConsoleOutputLogger.verbose      = true;
            ConsoleOutputLogger.writeLogfile = false;
            #endregion

            #region Logo
            ConsoleOutputLogger.WriteLine("home automation control server " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            ConsoleOutputLogger.WriteLine("(C) 2010-2013 Daniel Kirstenpfad - http://github.com/bietiekay/hacs");
            #endregion

            ConsoleOutputLogger.writeLogfile = true;

            TinyOnDiskStorage actor_data_store = new TinyOnDiskStorage(Properties.Settings.Default.DataDirectory + Path.DirectorySeparatorChar + "actor-data", false, hacs.Properties.Settings.Default.DataObjectCacheSize);
            ConsoleOutputLogger.WriteLine("Initialized actor-data storage: " + actor_data_store.InMemoryIndex.Count);
            TinyOnDiskStorage sensor_data_store = new TinyOnDiskStorage(Properties.Settings.Default.DataDirectory + Path.DirectorySeparatorChar + "sensor-data", false, hacs.Properties.Settings.Default.DataObjectCacheSize);
            ConsoleOutputLogger.WriteLine("Initialized sensor-data storage: " + sensor_data_store.InMemoryIndex.Count);
            TinyOnDiskStorage unknown_data_store = new TinyOnDiskStorage(Properties.Settings.Default.DataDirectory + Path.DirectorySeparatorChar + "unknown-data", false, hacs.Properties.Settings.Default.DataObjectCacheSize);
            ConsoleOutputLogger.WriteLine("Initialized unknown-data storage: " + unknown_data_store.InMemoryIndex.Count);
            TinyOnDiskStorage miataru_data_store = null;

            if (hacs.Properties.Settings.Default.MiataruEnabled)
            {
                miataru_data_store = new TinyOnDiskStorage(Properties.Settings.Default.DataDirectory + Path.DirectorySeparatorChar + "miataru-data", false, hacs.Properties.Settings.Default.DataObjectCacheSize);
                ConsoleOutputLogger.WriteLine("Initialized Miataru storage: " + miataru_data_store.InMemoryIndex.Count);
            }


            //List<Thread> LoggingThreads = new List<Thread>();
            ScriptingTimerThread _ScriptingTimerThread;

            ScriptingActorConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.ScriptingActorConfigurationFilename);
            PowerSensorConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.PowerSensorConfigurationFilename);
            ScriptingTimerConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.ScriptingTimerConfigurationFilename);
            SensorCheckIgnoreConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.SensorCheckIgnoreFile);
            HTTPProxyConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.HTTPProxyConfigurationFilename);

            if (Properties.Settings.Default.AlarmingEnabled)
            {
                AlarmingConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.AlarmingConfigurationFilename);
            }

            if (Properties.Settings.Default.MiataruEnabled)
            {
                MiataruConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.MiataruConfigurationFilename);
            }

            #region add NetworkMonitor sensors to sensorcheckignore list
            if (Properties.Settings.Default.NetworkMonitorEnabled)
            {
                NetworkMonitorConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.NetworkMonitorConfigurationFilename);

                foreach (NetworkMonitoringHost Host in NetworkMonitorConfiguration.NetworkHosts)
                {
                    SensorCheckIgnoreConfiguration.AddToIgnoreList(Host.IPAdressOrHostname);
                }
            }
            #endregion

            #region Logging and Actor Handling
            ConsoleOutputLogger.WriteLineToScreenOnly("Starting Logging for Server: " + Properties.Settings.Default.XS1);
            LoggingThread _Thread       = new LoggingThread(Properties.Settings.Default.XS1, ConsoleOutputLogger, actor_data_store, sensor_data_store, unknown_data_store, miataru_data_store, Properties.Settings.Default.Username, Properties.Settings.Default.Password, Properties.Settings.Default.ConfigurationCacheMinutes);
            Thread        LoggingThread = new Thread(new ThreadStart(_Thread.Run));
            LoggingThread.Start();
            #endregion

            #region Scripting Timer Handling
            ConsoleOutputLogger.WriteLineToScreenOnly("Starting Scripting Timer Handling.");
            _ScriptingTimerThread = new ScriptingTimerThread(_Thread, ConsoleOutputLogger);
            Thread ScriptingTThread = new Thread(new ThreadStart(_ScriptingTimerThread.Run));
            ScriptingTThread.Start();
            #endregion
        }
コード例 #2
0
ファイル: hacs.cs プロジェクト: pereritob/hacs
        static void Main(string[] args)
        {
            #region ConsoleOutputLogger
            ConsoleOutputLogger ConsoleOutputLogger = new hacs.ConsoleOutputLogger();
            ConsoleOutputLogger.verbose = true;
            ConsoleOutputLogger.writeLogfile = false;
            #endregion

            #region Logo
            ConsoleOutputLogger.WriteLine("home automation control server " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            ConsoleOutputLogger.WriteLine("(C) 2010-2013 Daniel Kirstenpfad - http://github.com/bietiekay/hacs");
            #endregion
						
            ConsoleOutputLogger.writeLogfile = true;

            TinyOnDiskStorage actor_data_store = new TinyOnDiskStorage(Properties.Settings.Default.DataDirectory + Path.DirectorySeparatorChar + "actor-data", false, hacs.Properties.Settings.Default.DataObjectCacheSize);
			ConsoleOutputLogger.WriteLine("Initialized actor-data storage: "+actor_data_store.InMemoryIndex.Count);
            TinyOnDiskStorage sensor_data_store = new TinyOnDiskStorage(Properties.Settings.Default.DataDirectory + Path.DirectorySeparatorChar + "sensor-data", false, hacs.Properties.Settings.Default.DataObjectCacheSize);
			ConsoleOutputLogger.WriteLine("Initialized sensor-data storage: "+sensor_data_store.InMemoryIndex.Count);
            TinyOnDiskStorage unknown_data_store = new TinyOnDiskStorage(Properties.Settings.Default.DataDirectory + Path.DirectorySeparatorChar + "unknown-data", false, hacs.Properties.Settings.Default.DataObjectCacheSize);
			ConsoleOutputLogger.WriteLine("Initialized unknown-data storage: "+unknown_data_store.InMemoryIndex.Count);
			TinyOnDiskStorage miataru_data_store = null;

			if (hacs.Properties.Settings.Default.MiataruEnabled)
			{
				miataru_data_store = new TinyOnDiskStorage(Properties.Settings.Default.DataDirectory + Path.DirectorySeparatorChar + "miataru-data", false, hacs.Properties.Settings.Default.DataObjectCacheSize);
				ConsoleOutputLogger.WriteLine("Initialized Miataru storage: "+miataru_data_store.InMemoryIndex.Count);
			}


            //List<Thread> LoggingThreads = new List<Thread>();
            ScriptingTimerThread _ScriptingTimerThread;

            ScriptingActorConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.ScriptingActorConfigurationFilename);
            PowerSensorConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.PowerSensorConfigurationFilename);
            ScriptingTimerConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.ScriptingTimerConfigurationFilename);
            SensorCheckIgnoreConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.SensorCheckIgnoreFile);
            HTTPProxyConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.HTTPProxyConfigurationFilename);
			
            if (Properties.Settings.Default.AlarmingEnabled)
                AlarmingConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.AlarmingConfigurationFilename);

            if (Properties.Settings.Default.MiataruEnabled)
				MiataruConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.MiataruConfigurationFilename);

			#region add NetworkMonitor sensors to sensorcheckignore list
			if (Properties.Settings.Default.NetworkMonitorEnabled)
			{
                NetworkMonitorConfiguration.ReadConfiguration(Properties.Settings.Default.ConfigurationDirectory + Path.DirectorySeparatorChar + Properties.Settings.Default.NetworkMonitorConfigurationFilename);

				foreach(NetworkMonitoringHost Host in NetworkMonitorConfiguration.NetworkHosts)
				{
					SensorCheckIgnoreConfiguration.AddToIgnoreList(Host.IPAdressOrHostname);
				}
			}
			#endregion

            #region Logging and Actor Handling
            ConsoleOutputLogger.WriteLineToScreenOnly("Starting Logging for Server: " + Properties.Settings.Default.XS1);                        
			LoggingThread _Thread = new LoggingThread(Properties.Settings.Default.XS1, ConsoleOutputLogger, actor_data_store, sensor_data_store, unknown_data_store,miataru_data_store,Properties.Settings.Default.Username,Properties.Settings.Default.Password,Properties.Settings.Default.ConfigurationCacheMinutes);
            Thread LoggingThread = new Thread(new ThreadStart(_Thread.Run));
            LoggingThread.Start();
            #endregion

            #region Scripting Timer Handling
            ConsoleOutputLogger.WriteLineToScreenOnly("Starting Scripting Timer Handling.");
            _ScriptingTimerThread = new ScriptingTimerThread(_Thread,ConsoleOutputLogger);
            Thread ScriptingTThread = new Thread(new ThreadStart(_ScriptingTimerThread.Run));
            ScriptingTThread.Start();
            #endregion
        }