示例#1
0
        public static int Main(string[] args)
        {
            var main = new MainClass();

            // Open RaspberryPiGateway.exe.config file for device information
            try
            {
                string applicationName = "RaspberryPiGateway.exe";
                string exePath         = System.IO.Path.Combine(Environment.CurrentDirectory, applicationName);
                var    configFile      = ConfigurationManager.OpenExeConfiguration(exePath);
                var    appSettings     = ConfigurationManager.AppSettings;
                if (appSettings.Count == 0)
                {
                    logger.Info("AppSettings is empty.");
                }
                else
                {
                    foreach (var key in appSettings.AllKeys)
                    {
                        logger.Info("Key: {0} Value: {1}", key, appSettings[key]);
                    }
                }
            }
            catch (ConfigurationErrorsException)
            {
                logger.Info("Error reading app settings");
            }

            // Read a particular key from the config file
            AppSubject           = ConfigurationManager.AppSettings.Get("Subject");
            AppSensor            = ConfigurationManager.AppSettings.Get("Sensor");
            AppEdgeGateway       = ConfigurationManager.AppSettings.Get("EdgeGateway");
            AppDeviceDisplayName = ConfigurationManager.AppSettings.Get("DeviceDisplayName");
            sAppAMQPAddress      = ConfigurationManager.AppSettings.Get("AMQPAddress");
            AppAMQPAddress       = new Address(sAppAMQPAddress);
            AppEHTarget          = ConfigurationManager.AppSettings.Get("EHTarget");
            sendFrequency        = Convert.ToInt32(ConfigurationManager.AppSettings.Get("SendFrequency"));
            serialPortName       = ConfigurationManager.AppSettings.Get("serialPortName");
            bForever             = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("Forever"));
            AppKey1 = ConfigurationManager.AppSettings.Get("Key1");
            AppKey2 = ConfigurationManager.AppSettings.Get("Key2");
            AppKey3 = ConfigurationManager.AppSettings.Get("Key3");

            int result = main.Parse(args);

            if (result != 0)
            {
                return(result);
            }
            return(main.Run());
        }
示例#2
0
        /// <summary>
        /// Main function of the application
        /// </summary>
        /// <param name="args"></param>
        /// <returns>
        /// -1 when an error occured during initialization
        /// result of the run function which is a loop returning 0 when ended
        /// </returns>
        public static int Main(string[] args)
        {
            var main = new MainClass();

            // Initialize application by reading configuration file
            if (!InitAppSettings(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RaspberryPiGateway.exe"))
            {
                return(-1);
            }
            // Initializa AMQP connection
            if (!InitAMQPConnection(false))
            {
                return(-1);
            }

            // start main routine
            return(main.Run());
        }
示例#3
0
        /// <summary>
        /// Main function of the application
        /// </summary>
        /// <param name="args"></param>
        /// <returns>
        /// -1 when an error occured during initialization
        /// result of the run function which is a loop returning 0 when ended
        /// </returns>
        public static int Main(string[] args)
        {
            var main = new MainClass();

            // Initialize application by reading configuration file
            if (!InitAppSettings(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RaspberryPiGateway.exe"))
            {
                return(-1);
            }
            // Initializa AMQP connection
            if (!InitAMQPConnection(false))
            {
                return(-1);
            }

            // Get device IP
            IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
            IPAddress   ipAddress  = ipHostInfo.AddressList[0];

            deviceIP = ipAddress.ToString();

            // start main routine
            return(main.Run());
        }
示例#4
0
文件: Program.cs 项目: leestott/Beats
        /// <summary>
        /// Main function of the application
        /// </summary>
        /// <param name="args"></param>
        /// <returns>
        /// -1 when an error occured during initialization
        /// result of the run function which is a loop returning 0 when ended
        /// </returns>
        public static int Main(string[] args)
        {
            var main = new MainClass();

            // Initialize application by reading configuration file
            if (!InitAppSettings(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RaspberryPiGateway.exe")) return -1;
            // Initializa AMQP connection
            if (!InitAMQPConnection(false)) return -1;

            // start main routine
            return main.Run();
        }