public PostgresConnectionPool(ConnectionInfo info)
 {
     this.Info = info;
     if (!int.TryParse(ConfigurationManager.AppSettings["Database.PoolSize"], out Size))
     {
         Size = Math.Min(Environment.ProcessorCount, 20);
     }
     if (!Enum.TryParse <PoolMode>(ConfigurationManager.AppSettings["Database.PoolMode"], out Mode))
     {
         //TODO: Mono has issues with BlockingCollection. use None as default
         int p = (int)Environment.OSVersion.Platform;
         if (p == 4 || p == 6 || p == 128)
         {
             Mode = PoolMode.None;
         }
         else
         {
             Mode = PoolMode.IfAvailable;
         }
     }
     if (Mode != PoolMode.None)
     {
         if (Size < 1)
         {
             Size = 1;
         }
         for (int i = 0; i < Size; i++)
         {
             Connections.Add(info.GetConnection());
         }
     }
 }
Beispiel #2
0
 public ScopePool(
     IObjectFactory factory,
     IDatabaseQueryManager queries,
     IExtensibilityProvider extensibilityProvider)
 {
     this.Factory = factory;
     this.Queries = queries;
     if (!int.TryParse(ConfigurationManager.AppSettings["Processing.PoolSize"], out Size))
         Size = 20;
     if (!Enum.TryParse<PoolMode>(ConfigurationManager.AppSettings["Processing.PoolMode"], out Mode))
     {
         //TODO: Mono has issues with BlockingCollection. use None as default
         int p = (int)Environment.OSVersion.Platform;
         if (p == 4 || p == 6 || p == 128)
             Mode = PoolMode.None;
         else
             Mode = PoolMode.IfAvailable;
     }
     var commandTypes = extensibilityProvider.FindPlugins<IServerCommand>();
     Factory.RegisterTypes(commandTypes, InstanceScope.Context);
     if (Mode != PoolMode.None)
     {
         if (Size < 1) Size = 1;
         for (int i = 0; i < Size; i++)
             Scopes.Add(SetupReadonlyScope());
     }
 }
        /// <summary>
        /// Gets the mode of the pool (spa or pool).
        /// </summary>
        /// <param name="mode">The mode of the pool</param>
        /// <returns></returns>
        public Messages.PowerLineModemMessage.MessageResponse GetPoolMode(out PoolMode mode)
        {
            byte response;

            Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommandWithResponse(InsteonPacket.Command.PoolControl, (byte)PoolControlCommand.GetPoolMode, out response);
            mode = (PoolMode)response;
            return(ret);
        }
 public PostgresConnectionPool(ConnectionInfo info, ILogFactory logFactory)
 {
     this.Info = info;
     if (!int.TryParse(ConfigurationManager.AppSettings["Database.PoolSize"], out Size))
         Size = 20;
     if (!Enum.TryParse<PoolMode>(ConfigurationManager.AppSettings["Database.PoolMode"], out Mode))
         Mode = PoolMode.IfAvailable;
     if (Mode != PoolMode.None)
     {
         if (Size < 1) Size = 1;
         for (int i = 0; i < Size; i++)
             Connections.Add(info.GetConnection());
     }
     this.Logger = logFactory.Create("Npgsql connection manager");
 }
Beispiel #5
0
        //===================// Constructor //===================//

        public Pool()
        {
            currentPoolSetpoint = 0f;
            currentPoolTemp     = 0f;
            currentSpaSetpoint  = 0f;
            currentSpaTemp      = 0f;
            currentAmbientTemp  = 0f;

            currentAuxStatus = new bool[12];
            auxLabels        = new string[12];

            currentMode = PoolMode.Unknown;

            systemType = 0;
        }
		public PostgresConnectionPool(ConnectionInfo info)
		{
			this.Info = info;
			if (!int.TryParse(ConfigurationManager.AppSettings["Database.PoolSize"], out Size))
				Size = Math.Min(Environment.ProcessorCount, 20);
			if (!Enum.TryParse<PoolMode>(ConfigurationManager.AppSettings["Database.PoolMode"], out Mode))
			{
				//TODO: Mono has issues with BlockingCollection. use None as default
				int p = (int)Environment.OSVersion.Platform;
				if (p == 4 || p == 6 || p == 128)
					Mode = PoolMode.None;
				else
					Mode = PoolMode.IfAvailable;
			}
			if (Mode != PoolMode.None)
			{
				if (Size < 1) Size = 1;
				for (int i = 0; i < Size; i++)
					Connections.Add(info.GetConnection());
			}
		}
Beispiel #7
0
 public ScopePool(
     IObjectFactory factory,
     IDatabaseQueryManager queries,
     IExtensibilityProvider extensibilityProvider,
     ILogFactory logFactory)
 {
     this.Factory = factory;
     this.Queries = queries;
     if (!int.TryParse(ConfigurationManager.AppSettings["Processing.PoolSize"], out Size))
         Size = 20;
     if (!Enum.TryParse<PoolMode>(ConfigurationManager.AppSettings["Processing.PoolMode"], out Mode))
         Mode = PoolMode.IfAvailable;
     var commandTypes = extensibilityProvider.FindPlugins<IServerCommand>();
     Factory.RegisterTypes(commandTypes, InstanceScope.Context);
     if (Mode != PoolMode.None)
     {
         if (Size < 1) Size = 1;
         for (int i = 0; i < Size; i++)
             Scopes.Add(SetupReadonlyScope());
     }
     Logger = logFactory.Create("Scope pool");
 }
Beispiel #8
0
        public ScopePool(
            IObjectFactory factory,
            IDatabaseQueryManager queries,
            IExtensibilityProvider extensibilityProvider)
        {
            this.Factory = factory;
            this.Queries = queries;
            if (!int.TryParse(ConfigurationManager.AppSettings["Processing.PoolSize"], out Size))
            {
                Size = 20;
            }
            if (!Enum.TryParse <PoolMode>(ConfigurationManager.AppSettings["Processing.PoolMode"], out Mode))
            {
                //TODO: Mono has issues with BlockingCollection. use None as default
                int p = (int)Environment.OSVersion.Platform;
                if (p == 4 || p == 6 || p == 128)
                {
                    Mode = PoolMode.None;
                }
                else
                {
                    Mode = PoolMode.IfAvailable;
                }
            }
            var commandTypes = extensibilityProvider.FindPlugins <IServerCommand>();

            Factory.RegisterTypes(commandTypes, InstanceScope.Context);
            if (Mode != PoolMode.None)
            {
                if (Size < 1)
                {
                    Size = 1;
                }
                for (int i = 0; i < Size; i++)
                {
                    Scopes.Add(SetupReadonlyScope());
                }
            }
        }
Beispiel #9
0
        /**
         * Method: FeedbackEvent
         * Access: public
         * Description: Receive hardware feedback from S+, store in variable, and push value to subscribed Interfaces via event
         */
        public void FeedbackEvent(ushort _action, ushort _state, string _text)
        {
            PoolCommand act = (PoolCommand)_action;

            switch (act)
            {
            case PoolCommand.ModeSelect_Pool_Fb:
                if (_state == 1)
                {
                    currentMode = PoolMode.Pool;
                }
                break;

            case PoolCommand.ModeSelect_Spa_Fb:
                if (_state == 1)
                {
                    currentMode = PoolMode.Spa;
                }
                break;

            case PoolCommand.Pool_Heater_Fb:
                poolHeaterOn = _state == 1 ? true : false;
                break;

            case PoolCommand.Spa_Heater_Fb:
                spaHeaterOn = _state == 1 ? true : false;
                break;

            case PoolCommand.FilterPump_Fb:
                filterPumpOn = _state == 1 ? true : false;
                break;

            case PoolCommand.Aux_Fb:
                currentAuxStatus[int.Parse(_text)] = _state == 1 ? true : false;
                break;

            case PoolCommand.Pool_Setpoint_Fb:
                currentPoolSetpoint = float.Parse(_text);
                break;

            case PoolCommand.Pool_Temp_Fb:
                currentPoolTemp = float.Parse(_text);;
                break;

            case PoolCommand.Spa_Setpoint_Fb:
                currentSpaSetpoint = float.Parse(_text);;
                break;

            case PoolCommand.Spa_Temp_Fb:
                currentSpaTemp = float.Parse(_text);;
                break;

            case PoolCommand.Ambient_Temp_Fb:
                currentAmbientTemp = float.Parse(_text);;
                break;

            case PoolCommand.System_Type:
                systemType = _state;
                break;
            }

            // Broadcast to UpdateEvent subscribers
            if (this.UpdateEvent != null)
            {
                UpdateEvent(act, _state, _text);
            }
        }
 /// <summary>
 /// Gets the mode of the pool (spa or pool).
 /// </summary>
 /// <param name="mode">The mode of the pool</param>
 /// <returns></returns>
 public Messages.PowerLineModemMessage.MessageResponse GetPoolMode(out PoolMode mode)
 {
     byte response;
     Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommandWithResponse(InsteonPacket.Command.PoolControl, (byte)PoolControlCommand.GetPoolMode, out response);
     mode = (PoolMode)response;
     return ret;
 }