Esempio n. 1
0
        /// <summary>
        /// Initialises the uploader and batch client. Asks user for an Azure licence file and saves the credentials
        /// if the credentials have not previously been set.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GetCredentials(object sender, EventArgs e)
        {
            if (AzureCredentialsSetup.CredentialsExist())
            {
                // store credentials
                storageAuth = StorageCredentials.FromConfiguration();
                batchAuth   = BatchCredentials.FromConfiguration();
                poolOptions = PoolSettings.FromConfiguration();

                storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(storageAuth.Account, storageAuth.Key), true);
                uploader       = new FileUploader(storageAccount);
                var sharedCredentials = new Microsoft.Azure.Batch.Auth.BatchSharedKeyCredentials(batchAuth.Url, batchAuth.Account, batchAuth.Key);
                try
                {
                    batchCli = BatchClient.Open(sharedCredentials);
                }
                catch (UriFormatException)
                {
                    ShowErrorMessage("Error opening Azure Batch client: credentials are invalid.");
                    AzureCredentialsSetup cred = new AzureCredentialsSetup();
                    cred.Finished += GetCredentials;
                }
                catch (Exception ex)
                {
                    ShowError(ex);
                }
            }
            else
            {
                // ask user for a credentials file
                AzureCredentialsSetup cred = new AzureCredentialsSetup();
                cred.Finished += GetCredentials;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the reservoir structure configuration consisting of two interconnected pools.
        /// </summary>
        /// <param name="structName">The name of the reservoir structure.</param>
        /// <param name="pool1Name">The name of the first pool.</param>
        /// <param name="pool2Name">The name of the second pool.</param>
        private ReservoirStructureSettings CreateResStructCfg(string structName, string pool1Name, string pool2Name)
        {
            //Our pools will have the 5x5x5 cube shape each. So 125 neurons in each pool and 250 neurons in total.
            const int DimX = 5, DimY = 5, DimZ = 5;
            //Each pool will have random internal interconnection of the density = 0.05. In our case it means that
            //each neuron will receive synapses from 0.05 * 125 = 6 other randomly selected neurons.
            const double RandomInterconnectionDensity = 0.05;
            //Create pools
            PoolSettings pool1Cfg = CreateAnalogPoolCfg(pool1Name, DimX, DimY, DimZ, RandomInterconnectionDensity);
            PoolSettings pool2Cfg = CreateAnalogPoolCfg(pool2Name, DimX, DimY, DimZ, RandomInterconnectionDensity);
            //Pool to pool interconnection
            //Connections from Pool1 to Pool2. We use targetPoolDensity=1 and sourcePoolDensity=0.02, so each neuron from
            //Pool2 will be randomly connected to 125 * 0.02 = 3 neurons from Pool1
            InterPoolConnSettings pool1To2ConnCfg = new InterPoolConnSettings(pool2Name, 1d, pool1Name, 0.02d);
            //Connections from Pool2 to Pool1. We use targetPoolDensity=1 and sourcePoolDensity=0.02, so each neuron from
            //Pool1 will be randomly connected to 125 * 0.02 = 3 neurons from Pool2
            InterPoolConnSettings pool2To1ConnCfg = new InterPoolConnSettings(pool1Name, 1d, pool2Name, 0.02d);
            //Create the reservoir structure configuration
            ReservoirStructureSettings resStructCfg = new ReservoirStructureSettings(structName,
                                                                                     new PoolsSettings(pool1Cfg, pool2Cfg),
                                                                                     new InterPoolConnsSettings(pool1To2ConnCfg, pool2To1ConnCfg)
                                                                                     );

            return(resStructCfg);
        }
Esempio n. 3
0
        private PoolInformation GetPoolInfo(PoolSettings settings)
        {
            if (string.IsNullOrEmpty(settings.PoolName))
            {
                return(new PoolInformation
                {
                    AutoPoolSpecification = new AutoPoolSpecification
                    {
                        PoolLifetimeOption = PoolLifetimeOption.Job,
                        PoolSpecification = new PoolSpecification
                        {
                            MaxTasksPerComputeNode = settings.MaxTasksPerVM,

                            // This specifies the OS that our VM will be running.
                            // OS Family 5 means .NET 4.6 will be installed.
                            // For more info see https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-guestos-update-matrix#releases
                            CloudServiceConfiguration = new CloudServiceConfiguration("5"),
                            ResizeTimeout = TimeSpan.FromMinutes(15),
                            TargetDedicatedComputeNodes = settings.VMCount,
                            VirtualMachineSize = settings.VMSize,
                            TaskSchedulingPolicy = new TaskSchedulingPolicy(ComputeNodeFillType.Spread)
                        }
                    }
                });
            }
            return(new PoolInformation
            {
                PoolId = settings.PoolName
            });
        }
        public ParallelAPSIM(
            Storage.StorageCredentials storageCredentials,
            Batch.BatchCredentials batchCredentials,
            PoolSettings poolSettings)
        {
            _storageAccount = new CloudStorageAccount(
                new StorageCredentials(
                    storageCredentials.Account,
                    storageCredentials.Key),
                true);

            _batchClient = BatchClient.Open(
                new BatchSharedKeyCredentials(
                    batchCredentials.Url,
                    batchCredentials.Account,
                    batchCredentials.Key));

            _batchClient.CustomBehaviors.Add(
                RetryPolicyProvider.LinearRetryProvider(TimeSpan.FromSeconds(3), 10));

            _fileUploader       = new FileUploader(_storageAccount);
            _storageCredentials = storageCredentials;
            _batchCredentials   = batchCredentials;
            _poolSettings       = poolSettings;
        }
        private PoolInformation GetPoolInfo(PoolSettings poolSettings)
        {
            if (string.IsNullOrEmpty(poolSettings.PoolName))
            {
                return(new PoolInformation
                {
                    AutoPoolSpecification = new AutoPoolSpecification
                    {
                        PoolLifetimeOption = PoolLifetimeOption.Job,
                        PoolSpecification = new PoolSpecification
                        {
                            MaxTasksPerComputeNode = poolSettings.MaxTasksPerVM,
                            CloudServiceConfiguration = new CloudServiceConfiguration("5"),
                            ResizeTimeout = TimeSpan.FromMinutes(15),
                            TargetDedicated = poolSettings.VMCount,
                            VirtualMachineSize = poolSettings.VMSize,
                            TaskSchedulingPolicy = new TaskSchedulingPolicy(ComputeNodeFillType.Spread),
                        }
                    }
                });
            }

            return(new PoolInformation
            {
                PoolId = poolSettings.PoolName
            });
        }
Esempio n. 6
0
        public void ConvertTemperatureToPumpDuration()
        {
            var settings = new PoolSettings();

            settings.TemperatureRunTime.Clear();
            settings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 15, RunTimeHours = 1
            });
            settings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 20, RunTimeHours = 3
            });
            settings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 25, RunTimeHours = 10
            });
            settings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 30, RunTimeHours = 16
            });

            Assert.AreEqual(1, settings.GetHoursPumpingTimePerDay(10));
            Assert.AreEqual(1, settings.GetHoursPumpingTimePerDay(15));
            Assert.AreEqual(1, settings.GetHoursPumpingTimePerDay(15.2));
            Assert.AreEqual(3, settings.GetHoursPumpingTimePerDay(20));
            Assert.AreEqual(10, settings.GetHoursPumpingTimePerDay(29.9));
            Assert.AreEqual(16, settings.GetHoursPumpingTimePerDay(30));
            Assert.AreEqual(16, settings.GetHoursPumpingTimePerDay(35));
        }
Esempio n. 7
0
 private void InitAndBindPool <TItemContract, TPool>(PoolSettings poolSettings) where TPool : IMemoryPool
 {
     Container.BindMemoryPool <TItemContract, TPool>()
     .WithInitialSize(poolSettings.InitialSize)
     .FromComponentInNewPrefab(poolSettings.Prefab)
     .UnderTransformGroup(poolSettings.TransformGroup);
 }
Esempio n. 8
0
        /// <summary>
        /// Load settings and state from local files
        /// </summary>
        private void LoadSettingsAndStates()
        {
            this.logger.LogDebug($"Reading '{settingsFileName}' file");
            this.poolSettings = this.storeService.ReadPoolSettings(settingsFileName);

            this.logger.LogDebug($"Reading '{currentStateFileName}' file");
            this.systemState = this.storeService.ReadSystemState(currentStateFileName);
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PoolControlPump"/> class.
 /// </summary>
 public PoolControlPump(
     PoolSettings poolSettings,
     SystemState systemState,
     IHardwareManager hardwareManager)
 {
     this.poolSettings    = poolSettings;
     this.systemState     = systemState;
     this.hardwareManager = hardwareManager;
 }
Esempio n. 10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dispName"></param>
 /// <param name="zipFileSas"></param>
 /// <param name="packagePath"></param>
 /// <param name="packageVersion"></param>
 /// <param name="recipient"></param>
 /// <param name="batch"></param>
 /// <param name="storage"></param>
 /// <param name="pool"></param>
 public APSIMJob(string dispName, string zipFileSas, string packagePath, string packageVersion, string recipient, BatchCredentials batch, StorageCredentials storage, PoolSettings pool)
 {
     DisplayName                    = dispName;
     ModelZipFileSas                = zipFileSas;
     ApplicationPackagePath         = packagePath;
     ApsimApplicationPackageVersion = packageVersion;
     Recipient   = recipient;
     BatchAuth   = batch;
     StorageAuth = storage;
     PoolInfo    = pool;
 }
Esempio n. 11
0
    public GameObjectPool(PoolSettings _settings)
    {
        settings = _settings;

        if (poolContainer == null)
        {
            poolContainer = new GameObject(_settings.prefabs[0].name + "_Container").transform;
        }

        PreparePool();
    }
Esempio n. 12
0
 public ReplicaSetPoolManager(int count, PoolSettings poolSettings)
 {
     replicaInfos = Enumerable.Range(0, count).ToDictionary(x => x, x => new ReplicaInfo
     {
         Key    = new ReplicaKey("replica" + x),
         IsDead = false
     });
     replicaSetPool = ReplicaSetPool.Create <Item, ItemKey, ReplicaKey>(
         replicaInfos.Values.Select(x => x.Key).ToArray(),
         (x, z) => new Pool <Item>(y => CreateReplicaConnection(z, x), new SilentLog()),
         poolSettings, new SilentLog());
 }
Esempio n. 13
0
        public void ReadWritePoolSettings()
        {
            var storeService = new StoreService();

            var poolSettings = new PoolSettings();

            poolSettings.WorkingMode = PoolWorkingMode.Winter;
            poolSettings.CoverCylcleDurationInSeconds = 100;

            poolSettings.SummerPumpingCycles.Add(new PumpCycleGroupSetting()
            {
                MinimumTemperature = 0
            });
            poolSettings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime = TimeSpan.FromHours(1), PumpCycleType = PumpCycleType.StartAt
            });
            poolSettings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime = TimeSpan.FromHours(12), PumpCycleType = PumpCycleType.StopAt
            });


            poolSettings.WinterPumpingCycles.Add(new PumpCycleGroupSetting()
            {
                MinimumTemperature = 0
            });
            poolSettings.WinterPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime = TimeSpan.FromHours(15), PumpCycleType = PumpCycleType.StopAt
            });

            poolSettings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 15, RunTimeHours = 1
            });
            poolSettings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 20, RunTimeHours = 4
            });

            storeService.WritePoolSettings(poolSettings, "poolsettings.json");

            var results = storeService.ReadPoolSettings("poolsettings.json");

            Assert.AreEqual(PoolWorkingMode.Winter, results.WorkingMode);
            Assert.AreEqual(100, results.CoverCylcleDurationInSeconds);
            Assert.AreEqual(1, results.SummerPumpingCycles.Count);
            Assert.AreEqual(2, results.SummerPumpingCycles[0].PumpingCycles.Count);
            Assert.AreEqual(PumpCycleType.StartAt, results.SummerPumpingCycles[0].PumpingCycles[0].PumpCycleType);
            Assert.AreEqual(TimeSpan.FromHours(12), results.SummerPumpingCycles[0].PumpingCycles[1].DecisionTime);
            Assert.AreEqual(PumpCycleType.StopAt, results.SummerPumpingCycles[0].PumpingCycles[1].PumpCycleType);
        }
        private ReplicaSetPool <IThriftConnection, string, IPEndPoint> CreateDataConnectionPool(ICassandraClusterSettings settings)
        {
            var replicaSetPool = ReplicaSetPool.Create <IThriftConnection, string, IPEndPoint>(
                settings.Endpoints,
                (key, replicaKey) => GetDataConnectionPool(settings, replicaKey, key),
                c => ((ThriftConnectionInPoolWrapper)c).ReplicaKey,
                c => ((ThriftConnectionInPoolWrapper)c).KeyspaceName,
                settings.ConnectionIdleTimeout,
                PoolSettings.CreateDefault(),
                logger);

            return(replicaSetPool);
        }
        private ReplicaSetPool <IThriftConnection, string, IPEndPoint> CreateFierceConnectionPool(ICassandraClusterSettings settings)
        {
            var result = ReplicaSetPool.Create <IThriftConnection, string, IPEndPoint>(
                new[] { settings.EndpointForFierceCommands },
                (key, replicaKey) => CreateFiercePool(settings, replicaKey, key),
                c => ((ThriftConnectionInPoolWrapper)c).ReplicaKey,
                c => ((ThriftConnectionInPoolWrapper)c).KeyspaceName,
                settings.ConnectionIdleTimeout,
                PoolSettings.CreateDefault(),
                logger);

            return(result);
        }
Esempio n. 16
0
 //Constructor
 /// <summary>
 /// Creates an initialized instance.
 /// </summary>
 /// <param name="poolCfg">The configuration of the pool of neurons.</param>
 public PoolStat(PoolSettings poolCfg)
 {
     PoolName     = poolCfg.Name;
     NumOfNeurons = 0;
     NeuronGroups = new NeuronGroupStat[poolCfg.NeuronGroupsCfg.GroupCfgCollection.Count];
     for (int i = 0; i < poolCfg.NeuronGroupsCfg.GroupCfgCollection.Count; i++)
     {
         NeuronGroups[i] = new NeuronGroupStat(poolCfg.NeuronGroupsCfg.GroupCfgCollection[i].Name);
     }
     Synapses         = new SynapsesByRoleStat();
     NeuronsAnomalies = new NeuronsAnomaliesStat();
     return;
 }
Esempio n. 17
0
        protected T CreatePool <T>(GameObject prefab, string name, out PoolSettings settings)
            where T : Component, IPool <PoolMember>
        {
            var poolGO = new GameObject(name);

            poolGO.transform.SetParent(transform);

            var pool = poolGO.AddComponent <T>();

            settings        = defaultPoolSettings.Clone();
            settings.prefab = prefab;

            return(pool);
        }
Esempio n. 18
0
            private static PoolSettings GetPoolSettings()
            {
                var settings = new PoolSettings();

                settings.SummerPumpingCycles.Clear();

                settings.SummerPumpingCycles.Add(new PumpCycleGroupSetting());
                settings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
                {
                    DecisionTime           = TimeSpan.FromHours(8),
                    PumpCycleType          = PumpCycleType.StartAt,
                    ChlorineInhibition     = true,
                    PhRegulationInhibition = false,
                });

                settings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
                {
                    DecisionTime           = TimeSpan.FromHours(16),
                    PumpCycleType          = PumpCycleType.StartAt,
                    ChlorineInhibition     = false,
                    PhRegulationInhibition = true,
                });

                settings.WinterPumpingCycles.Clear();
                settings.WinterPumpingCycles.Add(new PumpCycleGroupSetting());
                settings.WinterPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
                {
                    DecisionTime  = TimeSpan.FromHours(5),
                    PumpCycleType = PumpCycleType.StartAt,
                });

                settings.TemperatureRunTime.Add(new TemperatureRunTime()
                {
                    Temperature = 15, RunTimeHours = 1
                });
                settings.TemperatureRunTime.Add(new TemperatureRunTime()
                {
                    Temperature = 20, RunTimeHours = 4
                });
                settings.TemperatureRunTime.Add(new TemperatureRunTime()
                {
                    Temperature = 25, RunTimeHours = 8
                });
                settings.TemperatureRunTime.Add(new TemperatureRunTime()
                {
                    Temperature = 30, RunTimeHours = 12
                });

                return(settings);
            }
Esempio n. 19
0
        public void ReadSettings()
        {
            PoolSet = FileProcessor.ReadFile(_poolSet, filePath);

            if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MiningPoolMonitor")))
            {
                try
                {
                    Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MiningPoolMonitor"));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 20
0
    // Initialization
    void Start()
    {
        poolDictionary = new Dictionary <string, Queue <GameObject> >();
        for (int i = 0; i < pools.Length; ++i)
        {
            PoolSettings       poolSettings = pools[i];
            Queue <GameObject> pool         = new Queue <GameObject>();

            for (int j = 0; j < poolSettings.size; ++j)
            {
                GameObject obj = Instantiate(poolSettings.prefab, level);
                obj.SetActive(false);
                pool.Enqueue(obj);
            }
            poolDictionary.Add(poolSettings.type, pool);
        }
    }
Esempio n. 21
0
        /// <summary>
        /// Change the settings.
        /// </summary>
        /// <returns></returns>
        public void SavePoolSettings(PoolSettings settings)
        {
            if (settings.SummerPumpingCycles.Count == 0 || settings.WinterPumpingCycles.Count == 0)
            {
                throw new ArgumentException("Invalid cycles");
            }

            this.poolSettings.CoverCylcleDurationInSeconds = settings.CoverCylcleDurationInSeconds;
            this.poolSettings.SummerPumpingCycles          = settings.SummerPumpingCycles;
            this.poolSettings.WinterPumpingCycles          = settings.WinterPumpingCycles;
            this.poolSettings.FrostProtection    = settings.FrostProtection;
            this.poolSettings.WorkingMode        = settings.WorkingMode;
            this.poolSettings.TemperatureRunTime = settings.TemperatureRunTime;
            this.storeService.WritePoolSettings(this.poolSettings, settingsFileName);

            this.poolControlLoop.ResetSettings(this.poolSettings);
        }
Esempio n. 22
0
        public void CyclesWithRatios()
        {
            var settings = new PoolSettings();

            settings.SummerPumpingCycles.Clear();
            settings.SummerPumpingCycles.Add(new PumpCycleGroupSetting());

            settings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime  = TimeSpan.FromHours(1),
                PumpCycleType = PumpCycleType.StartAt,
                Ratio         = 0,
            });

            settings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime  = TimeSpan.FromHours(11),
                PumpCycleType = PumpCycleType.StopAt,
                Ratio         = 2,
            });

            settings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime  = TimeSpan.FromHours(17),
                PumpCycleType = PumpCycleType.StartAt,
                Ratio         = 100,
            });

            // ======== SUMMER MODE ============
            settings.WorkingMode = PoolWorkingMode.Summer;
            var time = DateTime.Now.Date;

            var result = settings.GetNextPumpCycles(time.AddHours(1), 25d, TimeSpan.FromHours(4), 3).ToList();

            Assert.AreEqual(9, result.Count);

            Assert.AreEqual(time.AddHours(1), result[0].StartTime);
            Assert.AreEqual(time.AddHours(2), result[0].EndTime);

            Assert.AreEqual(time.AddHours(9), result[1].StartTime);
            Assert.AreEqual(time.AddHours(11), result[1].EndTime);

            Assert.AreEqual(time.AddHours(17), result[2].StartTime);
            Assert.AreEqual(time.AddHours(18), result[2].EndTime);
        }
Esempio n. 23
0
        /// <summary>
        /// Creates the 3D pool of analog neurons.
        /// </summary>
        /// <param name="poolName">The name of the pool.</param>
        /// <param name="dimX">Size on X dimension.</param>
        /// <param name="dimY">Size on Y dimension.</param>
        /// <param name="dimZ">Size on Z dimension.</param>
        /// <param name="randomInterconnectionDensity">The density of the random interconnection.</param>
        private PoolSettings CreateAnalogPoolCfg(string poolName, int dimX, int dimY, int dimZ, double randomInterconnectionDensity)
        {
            //Create TanH group of neurons
            AnalogNeuronGroupSettings grpCfg = CreateTanHGroup("Exc-TanH-Grp", 1);
            //We use two interconnection schemas
            //Chain schema (circle shaped). We use ratio 1 so all the neurons within the pool will be connected into the circle shaped chain.
            ChainSchemaSettings chainSchemaCfg = new ChainSchemaSettings(1d, true);
            //Random schema
            RandomSchemaSettings randomSchemaCfg = new RandomSchemaSettings(randomInterconnectionDensity);
            //Create pool configuration
            PoolSettings poolCfg = new PoolSettings(poolName,
                                                    new ProportionsSettings(dimX, dimY, dimZ),
                                                    new NeuronGroupsSettings(grpCfg),
                                                    new InterconnSettings(chainSchemaCfg, randomSchemaCfg)
                                                    );

            return(poolCfg);
        }
Esempio n. 24
0
    void Start()
    {
        //Инициализируется словарь пула и наполняется
        poolDictionary = new Dictionary <string, Queue <GameObject> >();
        for (int i = 0; i < pools.Length; ++i)
        {
            PoolSettings       poolSettings = pools[i];
            Queue <GameObject> pool         = new Queue <GameObject>();

            for (int j = 0; j < poolSettings.size; ++j)
            {
                GameObject obj = Instantiate(poolSettings.prefab, container);
                obj.SetActive(false);
                pool.Enqueue(obj);
            }
            poolDictionary.Add(poolSettings.type, pool);
        }
    }
Esempio n. 25
0
        /*! \cond UNITY */
        protected override void Awake()
        {
            base.Awake();
            name = "_CurvyGlobal_";
            transform.SetAsLastSibling();
            Object.DontDestroyOnLoad(this);
            mPoolManager = GetComponent <PoolManager>();
            var s = new PoolSettings()
            {
                MinItems          = 0,
                Threshold         = 50,
                Prewarm           = true,
                AutoCreate        = true,
                AutoEnableDisable = true
            };

            mControlPointPool = mPoolManager.CreateComponentPool <CurvySplineSegment>(s);
        }
Esempio n. 26
0
        public void JsonSerialiation()
        {
            var settings = new PoolSettings();

            settings.TemperatureRunTime.Clear();
            settings.SummerPumpingCycles.Clear();
            settings.WinterPumpingCycles.Clear();

            settings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 15, RunTimeHours = 1
            });
            settings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 20, RunTimeHours = 3
            });
            settings.TemperatureRunTime.Add(new TemperatureRunTime()
            {
                Temperature = 25, RunTimeHours = 10
            });

            settings.SummerPumpingCycles.Add(new PumpCycleGroupSetting());
            settings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime = TimeSpan.FromHours(8), PumpCycleType = PumpCycleType.StopAt
            });
            settings.SummerPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime = TimeSpan.FromHours(13), PumpCycleType = PumpCycleType.StartAt
            });

            settings.WinterPumpingCycles.Add(new PumpCycleGroupSetting());
            settings.WinterPumpingCycles[0].PumpingCycles.Add(new PumpCycleSetting()
            {
                DecisionTime = TimeSpan.FromHours(13), PumpCycleType = PumpCycleType.StartAt
            });

            var result = JsonConvert.DeserializeObject <PoolSettings>(JsonConvert.SerializeObject(settings));

            Assert.AreEqual(3, result.TemperatureRunTime.Count);
            Assert.AreEqual(1, result.SummerPumpingCycles.Count);
            Assert.AreEqual(2, result.SummerPumpingCycles[0].PumpingCycles.Count);
            Assert.AreEqual(1, result.WinterPumpingCycles.Count);
        }
Esempio n. 27
0
        /*! \cond UNITY */
        public override void Awake()
        {
            base.Awake();
            name = "_CurvyGlobal_";
            transform.SetAsLastSibling();
            // Unity 5.3 introduces bug that hides GameObject when calling this outside playmode!
            if (Application.isPlaying)
            {
                Object.DontDestroyOnLoad(this);
            }
            mPoolManager = GetComponent <PoolManager>();
            var s = new PoolSettings()
            {
                MinItems          = 0,
                Threshold         = 50,
                Prewarm           = true,
                AutoCreate        = true,
                AutoEnableDisable = true
            };

            mControlPointPool = mPoolManager.CreateComponentPool <CurvySplineSegment>(s);
        }
Esempio n. 28
0
        public static async void GetPoolData()
        {
            string filePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MiningPoolMonitor\\config.cfg");


            poolSettings = FileProcessor.ReadFile(poolSettings, filePath);

            Stats = await Task.Run(() => PoolStatusProccesor.GetPoolStats(poolSettings.MinerAddress, poolSettings.Pool));

            //if (_windowManager != null)
            //{
            //    DashboardViewModel dVm = new DashboardViewModel(Stats, poolSettings);
            //    dVm.BindPoolData(Stats);
            //}


            if (Stats != null)
            {
                ReportedHashrate = Stats.ReportedHashrate;

                if (ReportedHashrate < poolSettings.MinHeshRate)
                {
                    notifyIcon.Icon = Properties.Resources.NotReadyIcon;
                    notifyIcon.ShowBalloonTip(500, "Warning", "Low Hash-rate!", ToolTipIcon.Warning);
                }
                else
                {
                    notifyIcon.Icon = Properties.Resources.ReadyIcon;
                }
            }
            else
            {
                ReportedHashrate = 0;
                notifyIcon.Icon  = Properties.Resources.NotReadyIcon;
                notifyIcon.ShowBalloonTip(500, "Error", "No connection!", ToolTipIcon.Error);
            }
        }
Esempio n. 29
0
 public void Initialize(string ident, PoolSettings settings, params GameObject[] prefabs)
 {
     Identifier = ident;
     m_Settings = settings;
     Prefabs = new List<GameObject>(prefabs);
     mLastTime = DTTime.TimeSinceStartup + UnityEngine.Random.Range(0, Settings.Speed);
     if (Settings.Prewarm)
         Reset();
 }
Esempio n. 30
0
 private static ReplicaSetPool <TItem, TItemKey, TReplicaKey> CreatePool <TItem, TItemKey, TReplicaKey>(
     TReplicaKey[] replicas,
     Func <TItemKey, TReplicaKey, Pool <TItem> > poolFactory
     )
     where TItem : class, IDisposable, IPoolKeyContainer <TItemKey, TReplicaKey>, ILiveness
     where TItemKey : IEquatable <TItemKey>
     where TReplicaKey : IEquatable <TReplicaKey>
 {
     return(new ReplicaSetPool <TItem, TItemKey, TReplicaKey>(replicas, poolFactory, EqualityComparer <TReplicaKey> .Default, EqualityComparer <TItemKey> .Default, i => i.ReplicaKey, i => i.PoolKey, PoolSettings.CreateDefault(), new SilentLog(), null));
 }
Esempio n. 31
0
        public void TestRemoveUnusedConnection()
        {
            using (var pool = ReplicaSetPool.Create <Item, ItemKey, ReplicaKey>(new[] { new ReplicaKey("replica1") }, (x, z) => new Pool <Item>(y => new Item(x, z), new SilentLog()), PoolSettings.CreateDefault(), TimeSpan.FromMilliseconds(100), new SilentLog()))
            {
                var item1 = pool.Acquire(null);
                var item2 = pool.Acquire(null);
                pool.Release(item1);

                Thread.Sleep(500);

                pool.Release(item2);

                var item3 = pool.Acquire(null);
                var item4 = pool.Acquire(null);

                Assert.That(item3, Is.EqualTo(item2));
                Assert.That(item4, Is.Not.EqualTo(item1) & Is.Not.EqualTo(item2));
            }
        }