public static double CountValueOfTheFunction(FactoryController factory, Specimen specimen)
        {
            double Payouts       = 0;
            double FactoryProfit = FactoryProfitCounter(factory);

            foreach (KeyValuePair <Machines, Employees> e in specimen.Genome)
            {
                double val = 0;
                for (int i = 0; i < e.Value.VectorOfAbilities.Length; i++)
                {
                    if (e.Value.VectorOfAbilities[i] == '1')
                    {
                        val++;
                    }
                }
                if (e.Key.Special == 1)
                {
                    Payouts += (val * 5) * 1.5;
                }
                else
                {
                    Payouts += (val * 5);
                }
            }

            return(FactoryProfit - Payouts);
        }
        private void ExcluirParque_Click(object sender, RoutedEventArgs e)
        {
            int index = this.dataGridParqueEolico.SelectedIndex;

            if (index == -1)
            {
                MessageBox.Show("Por favor, selecione um parque eólico.");
            }
            else
            {
                try
                {
                    if (MessageBox.Show("Tem certeza que deseja remover o parque eólico selecionado? Atenção, sua exclusão pode implicar na exclusão dos dados já importados associados a este parque.", Constants.CONFIRMATION_CAPTION, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        ParqueEolico parqueSelecionado = (ParqueEolico)this.dataGridParqueEolico.SelectedItem;
                        FactoryController.getInstance().ParqueEolicoController.Delete(parqueSelecionado);
                        this.listaParquesEolicos.Remove((ParqueEolico)this.dataGridParqueEolico.SelectedItem);

                        MessageBox.Show("Parque eólico removido com sucesso.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 3
0
        public ComptePage()
        {
            InitializeComponent();

            _viewModel     = new CompteViewModel(FactoryController.CreateLocataire());
            BindingContext = _viewModel;
        }
Esempio n. 4
0
        public SuggestionAddPage()
        {
            InitializeComponent();

            _viewModel     = new SuggestionAddViewModel(FactoryController.CreateSuggestion());
            BindingContext = _viewModel;
        }
Esempio n. 5
0
    public void populateViews(Penguin p)
    {
        penguin         = p;
        cController     = Camera.main.gameObject.GetComponent <CurrencyController>();
        fController     = Camera.main.gameObject.GetComponent <FactoryController>();
        sliderComponent = penguinProgress.GetComponent <PenguinProgressSlider>();
        updateViews();

        penguinImage.onClick.AddListener(() =>
        {
            if (!isBeingManaged)
            {
                if (!progressComplete)
                {
                    startProcess();
                }
                else
                {
                    collectIncome();
                    sliderComponent.finishTimer();
                }
            }
        });

        penguinLevelUp.onClick.AddListener(() =>
        {
            if (cController.canAfford(penguin.getCost()))
            {
                cController.spend(penguin.getCost());
                penguin.incrementLevel();
            }
        });

        populationComplete = true;
    }
Esempio n. 6
0
 public static FactoryController getInstance()
 {
     if (instance == null)
     {
         instance = new FactoryController();
     }
     return(instance);
 }
Esempio n. 7
0
        public void CreateMethod()
        {
            FactoryController Factory = FactoryController.Create();

            BAParameters.EmployeesNumber = Factory.EmployeesList.Count;
            BeesAlgorithmController Controller = new BeesAlgorithmController(BAParameters, Factory);

            Data = Plotter.Plot(Controller._iterationResults);
        }
Esempio n. 8
0
    GameObject CreateFactory(FactoryInfo factoryInfo, int index)
    {
        GameObject fObject = Instantiate(factoryPrefab);

        // Model
        FactoryController factory = fObject.GetComponent <FactoryController>();

        factory.CanvasHUD     = CanvasHUD;
        factory.EconomyObject = EconomyObject;
        factory.SetUpParams(factoryInfo);

        // View
        float invRatio = 1 / GoldenRatio;

        fObject.transform.SetParent(this.transform, false);

        float prevScale = StarterScale;

        Debug.Log(string.Format("making factory {0}", index));
        Debug.Log(string.Format("starting location {0}", fObject.transform.position));

        for (int loop = 0; loop < index; loop++)
        {
            float   newScale  = prevScale * invRatio;
            Vector3 vectorAdd = new Vector3(0, 0, 0);
            switch (loop % 4)
            {
            case 0:
                vectorAdd = new Vector3(DefaultFactorySize * (prevScale / 2 + newScale / 2),
                                        DefaultFactorySize * (prevScale / 2 - newScale / 2), 0);
                break;

            case 1:
                vectorAdd = new Vector3(DefaultFactorySize * (prevScale / 2 - newScale / 2),
                                        -DefaultFactorySize * (prevScale / 2 + newScale / 2), 0);
                break;

            case 2:
                vectorAdd = new Vector3(-DefaultFactorySize * (prevScale / 2 + newScale / 2),
                                        -DefaultFactorySize * (prevScale / 2 - newScale / 2), 0);
                break;

            case 3:
                vectorAdd = new Vector3(-DefaultFactorySize * (prevScale / 2 - newScale / 2),
                                        DefaultFactorySize * (prevScale / 2 + newScale / 2), 0);
                break;
            }
            Debug.Log(vectorAdd);
            fObject.transform.position += vectorAdd;
            prevScale = newScale;
        }
        fObject.transform.localScale = new Vector3(prevScale,
                                                   prevScale,
                                                   prevScale);
        return(fObject);
    }
Esempio n. 9
0
 private MesTachesViewModel ViewModel()
 {
     return(new MesTachesViewModel(
                new LocataireReadDto
     {
         Id = 2
     },
                FactoryController.CreateMockTache()
                ));
 }
Esempio n. 10
0
        public void CreateMethod()
        {
            FactoryController Factory = FactoryController.Create();

            Parameters.EmployeesNumber = 25;
            Parameters.PercentageOfParentsChosenToSelection = 0;
            GeneticAlgorithmController Controller = new GeneticAlgorithmController(Parameters, Factory);

            Data = Plotter.Plot(Controller._iterationResults);
        }
Esempio n. 11
0
 public DocumentService()
 {
     _test               = new TestController(this);
     _factory            = new FactoryController(this);
     _document           = new DocumentController(this);
     _page               = new PageController(this);
     _structure          = new StructureController(this);
     _statusJobConverter = new StatusJobConverterController(this);
     _annotations        = new AnnotationsController(this);
     _cache              = new CacheController(this);
     _compare            = new CompareController(this);
 }
Esempio n. 12
0
    private void Awake()
    {
        _factoryController = transform.parent.GetComponent <FactoryController>();
        _factoryController.RegisterCallback(
            NotificationType.OnFactoryProgressChanged, OnFactoryProgressChanged);

        if (_factoryController.WidthType == FactoryWidthType.Large)
        {
            _text.GetComponent <RectTransform>().sizeDelta = new Vector3(2, 1);
        }

        OnFactoryProgressChanged();
    }
        public VisualizarPrevisoes()
        {
            try
            {
                InitializeComponent();

                this.cmbBoxParquesEolicos.ItemsSource = FactoryController.getInstance().ParqueEolicoController.getAll();
            }
            catch (Exception e)
            {
                this.txtMessage.Text = Constants.ERROR_OPEN_CONNECTION;
            }
        }
Esempio n. 14
0
        public ImportacaoPrevEOL()
        {
            try
            {
                InitializeComponent();

                this.listaParquesEolicos = FactoryController.getInstance().ParqueEolicoController.getAll();
                this.LoadFiles();
            }
            catch (Exception e)
            {
                this.ShowInfoMessage(e.Message);
            }
        }
Esempio n. 15
0
    public void ShowStatsForFactory(FactoryController factory)
    {
        factoryUIPanel.SetActive(true);

        float income      = factory.Income();
        float levelUpCost = factory.CostToLevelUp();

        incomeText.text  = "Income: " + Mathf.Round(income).ToString();
        levelUpText.text = "Cost to Level: " + levelUpCost.ToString();

        selectedFactory = factory;

        CheckCanLevelUp();
    }
 public void GetObjs()
 {
     factoryController = GetComponent <FactoryController>();
     FactoryUI         = FactoryCanvas.transform.GetChild(0).gameObject;
     FactoryUI.SetActive(false);
     Board   = FactoryCanvas.transform.GetChild(0).transform.GetChild(2).gameObject;
     Content = FactoryCanvas.transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).gameObject;
     for (int i = 0; i < Content.transform.childCount; i++)
     {
         SoilderTypeCreatList.Add(Content.transform.GetChild(i).gameObject);
     }
     m_player           = GameObject.Find(PlayerNameString).gameObject;
     m_playerController = m_player.GetComponent <OLDPlayerController>();
 }
Esempio n. 17
0
        public BeesAlgorithmController(BeesAlgorithmParameters algorithmParameteres, FactoryController factory)
        {
            _employeesNumber        = algorithmParameteres.EmployeesNumber;
            _sizeOfPopulation       = algorithmParameteres.SizeOfPopulation;
            _numberOfIterations     = algorithmParameteres.NumberOfIterations;
            _numberOfEliteBees      = algorithmParameteres.NumberOfEliteBees;
            _numberOfAcceptableBees = algorithmParameteres.NumberOfAcceptableBees;
            _factory  = factory;
            _subjects = new Subjects(factory);
            _subjects.MakeSubject();
            _iterationResults = new List <double>();

            Population = new List <Bee>();
            CreateFirstPopulation(_sizeOfPopulation, _employeesNumber, _subjects);
        }
        private void UpdateDatagridRowsAndColumns(bool verTodosOsAtributos)
        {
            if (this.cmbBoxParquesEolicos.SelectedItem != null)
            {
                ParqueEolico parqueEolico = (ParqueEolico)this.cmbBoxParquesEolicos.SelectedItem;
                String       intervalo    = ((ComboBoxItem)this.cmbBoxIntervalo.SelectedItem).Tag.ToString();

                BackgroundWorker worker = new BackgroundWorker();

                worker.DoWork += (o, ea) =>
                {
                    try
                    {
                        List <ParqueEolicoImportacaoPrevEOL> listaDadosImportados = FactoryController.getInstance().
                                                                                    PrevEOL_Controller.getDadosImportados(parqueEolico.Id, this.Limit, verTodosOsAtributos,
                                                                                                                          intervalo);

                        this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            if (listaDadosImportados.Count > 0)
                            {
                                this.ShowDataGrid();
                                this.dataGridVisualizarDados.ItemsSource = listaDadosImportados;
                            }
                            else
                            {
                                this.ShowMessageEmptyData();
                            }
                        }));
                    }
                    catch (Exception e)
                    {
                        this.Dispatcher.BeginInvoke(new Action(() => { this.txtMessage.Text = e.Message; }));
                    }
                };
                worker.RunWorkerCompleted += (param, args) =>
                {
                    if (args.Error != null)
                    {
                        MessageBox.Show(args.Error.ToString());
                    }
                    this.BusyIndicatorCarregando.IsBusy = false;
                };

                BusyIndicatorCarregando.IsBusy = true;
                worker.RunWorkerAsync();
            }
        }
        public GeneticAlgorithmController(GeneticAlgorithmParameters algorithmParameteres, FactoryController factory)
        {
            _employeesNumber    = algorithmParameteres.EmployeesNumber;
            _sizeOfPopulation   = algorithmParameteres.SizeOfPopulation;
            _numberOfIterations = algorithmParameteres.NumberOfIterations;
            _mutationRate       = algorithmParameteres.MutationRate;
            _percentageOfChildrenFromPreviousGeneration = algorithmParameteres.PercentageOfChildrenFromPreviousGeneration;
            _percentageOfParentsChosenToSelection       = algorithmParameteres.PercentageOfParentsChosenToSelection;
            _factory  = factory;
            _subjects = new Subjects(factory);
            _subjects.MakeSubject();
            _iterationResults = new List <double>();

            Population = new List <Specimen>();
            CreatePopulation(_sizeOfPopulation, _employeesNumber, _subjects);
        }
        private static int FactoryProfitCounter(FactoryController factory)
        {
            int profit = 0;

            foreach (Machines m in factory.MachinesList)
            {
                if (m.Special == 0)
                {
                    profit += m.Profit_1 * m.Efficiency_1;
                }
                if (m.Special == 1 && m.Profit_2 != null)
                {
                    profit += (m.Profit_1 * m.Efficiency_1 + m.Profit_2.Value * m.Efficiency_2.Value);
                }
            }
            return(profit);
        }
Esempio n. 21
0
        public ImportacaoCPTEC()
        {
            try
            {
                InitializeComponent();
                //FactoryDAO.getInstance().CPTECDAO.importOldFile(CAMINHO_FILES + CAMINHO_ENTRADA_IMPORTACAO + @"\SaidaBV.txt", 11);
                //FactoryDAO.getInstance().CPTECDAO.importOldFile(CAMINHO_FILES + CAMINHO_ENTRADA_IMPORTACAO + @"\SaidaCQ.txt", 1);
                //FactoryDAO.getInstance().CPTECDAO.importOldFile(CAMINHO_FILES + CAMINHO_ENTRADA_IMPORTACAO + @"\SaidaEN.txt", 10);

                this.listaParquesEolicos = FactoryController.getInstance().ParqueEolicoController.getAll();
                this.LoadFiles();
            }
            catch (Exception e)
            {
                this.ShowInfoMessage(e.Message);
            }
        }
        private void CadastrarParqueEolico_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (this.txtPotenciaMaxima.Text == null || this.txtPotenciaMaxima.Text.Equals("") ||
                this.txtPotenciaMaxima.Text.Equals("0"))
            {
                this.parqueEolico.PotenciaMaxima = 1;
            }
            else
            {
                this.parqueEolico.PotenciaMaxima = Double.Parse(this.txtPotenciaMaxima.Text);
            }

            if (tipo == EnumParqueEolicoFormType.CADASTRAR)
            {
                try
                {
                    FactoryController.getInstance().ParqueEolicoController.cadastrar(this.parqueEolico);
                    //FactoryController.getInstance().PrevisorController.montarEstruturaParaPrevisao();
                    MessageBox.Show("Parque eólico cadastrado com sucesso.");

                    this.ClearAllFields();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (tipo == EnumParqueEolicoFormType.ALTERAR)
            {
                try
                {
                    FactoryController.getInstance().ParqueEolicoController.atualizar(this.parqueEolico);
                    MessageBox.Show("Parque eólico atualizado com sucesso.");

                    this.ClearAllFields();

                    Main.NavigateTo(EnumNavigateTo.PARQUE_EOLICO_SELECT, null);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            e.Handled = true;
        }
Esempio n. 23
0
    GameObject CreateFactory(FactoryInfo factoryInfo, int index)
    {
        GameObject fObject = Instantiate(factoryPrefab);

        fObject.transform.SetParent(this.transform);
        fObject.transform.position += new Vector3(index * 2, 0, 0);
        float scale = (float)Math.Pow(1 / GoldenRatio, index);

        fObject.transform.localScale = new Vector3(scale,
                                                   scale,
                                                   scale);
        FactoryController factory = fObject.GetComponent <FactoryController>();

        factory.CanvasHUD     = CanvasHUD;
        factory.EconomyObject = EconomyObject;
        factory.SetUpParams(factoryInfo);
        return(fObject);
    }
Esempio n. 24
0
        private void carregarParquesEolicos()
        {
            if (((ComboBoxItem)cmbBoxTipo.SelectedItem).Tag.Equals("PP"))
            {
                this.ListaParquesEolicos = new ObservableCollection <ParqueEolico>(FactoryController.getInstance().ParqueEolicoController.getParquesCalibrados("PP"));
            }
            else
            {
                this.ListaParquesEolicos = new ObservableCollection <ParqueEolico>(FactoryController.getInstance().ParqueEolicoController.getParquesCalibrados("TR"));
            }

            this.lstViewParquesEolicos.ItemsSource = this.ListaParquesEolicos;

            this.ListaParquesEolicosSelecionados = new ObservableCollection <ParqueEolico>();
            this.lstViewParquesEolicosSelecionados.ItemsSource = this.ListaParquesEolicosSelecionados;

            Util.Util.parquesPrevistos = this.ListaParquesEolicosSelecionados;
        }
        public ParqueEolicoSelect()
        {
            InitializeComponent();

            var worker = new BackgroundWorker();

            worker.DoWork += (sender, args) =>
            {
                try
                {
                    this.listaParquesEolicos =
                        new ObservableCollection <ParqueEolico>(FactoryController.getInstance().ParqueEolicoController.getAll());

                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        if (this.listaParquesEolicos.Count > 0)
                        {
                            this.ShowParquesEolicos();
                        }
                        else
                        {
                            this.ShowInfoMessage("Ainda não existe nenhum parque eólico cadastrado no banco de dados até o presente momento.");
                        }

                        this.dataGridParqueEolico.ItemsSource = listaParquesEolicos;
                    }));
                }
                catch (Exception e)
                {
                    this.Dispatcher.Invoke(new Action(() => { this.ShowInfoMessage(e.Message); }));
                }
            };

            worker.RunWorkerCompleted += (sender, args) =>
            {
                if (args.Error != null)
                {
                    MessageBox.Show(args.Error.ToString());
                }
                this.BusyIndicatorCarregando.IsBusy = false;
            };

            worker.RunWorkerAsync();
        }
Esempio n. 26
0
    void OnEnable()
    {
        if (factoryController == null)
        {
            factoryController = GameController.Instance.baseController.factoryController;
        }

        descriptionArea.gameObject.SetActive(false);
        buildOptionsArea.gameObject.SetActive(false);

        UIController.Instance.lockOtherInput = true;

        if (factoryController.factoryData.currentBuildTasks.Count > 0)
        {
            UpdateTaskList();
        }

        UpdateItemList();
    }
Esempio n. 27
0
        public async void Execute_Hydrate_WithoutError()
        {
            var viewModel = new MesTachesViewModel(
                new LocataireReadDto
            {
                Id = 1
            },
                FactoryController.CreateMockTache()
                );

            Assert.NotNull(viewModel.TachesData);

            await viewModel.Hydrate();

            Assert.NotEmpty(viewModel.TachesData);

            await viewModel.Hydrate();

            Assert.NotEmpty(viewModel.TachesData);
        }
        public FactoryControllerTest()
        {
            var connection = "TESTDB";
            var options    = new DbContextOptionsBuilder <SiCContext>()
                             .UseInMemoryDatabase(connection)
                             .Options;

            context = new SiCContext(options);

            List <Factory> factories = new List <Factory>();

            foreach (Factory f in context.Factory)
            {
                factories.Add(f);
            }

            if (factories.Count == 0)
            {
                City mock1 = new City("Test_City", 40.0, -8.0);
                City mock2 = new City("Second_Test_City", -40.0, 8.0);
                City mock3 = new City("Third_Test_City", -20.0, 4.0);


                Factory mock4 = new Factory();
                mock4.City        = mock1;
                mock4.Description = "Test_Factory";

                Factory mock5 = new Factory();
                mock5.City        = mock2;
                mock5.Description = "Second_Test_Factory";

                context.City.Add(mock1);
                context.City.Add(mock2);
                context.City.Add(mock3);
                context.Factory.Add(mock4);
                context.Factory.Add(mock5);
                context.SaveChanges();
            }
            controller = new FactoryController(context);
        }
        private void carregarParquesEolicos()
        {
            if (((ComboBoxItem)cmbBoxIntervalo.SelectedItem).Tag.Equals(Util.Util.DEZ_MINUTOS))
            {
                this.ListaParquesEolicos = new ObservableCollection <ParqueEolico>(FactoryController.getInstance().ParqueEolicoController.getAll_LEFT("TR"));
            }
            else
            {
                if (((ComboBoxItem)cmbBoxTipo.SelectedItem).Tag.Equals("PP"))
                {
                    this.ListaParquesEolicos = new ObservableCollection <ParqueEolico>(FactoryController.getInstance().ParqueEolicoController.getAll_LEFT("PP"));
                }
                else
                {
                    this.ListaParquesEolicos = new ObservableCollection <ParqueEolico>(FactoryController.getInstance().ParqueEolicoController.getAll_LEFT("VP"));
                }
            }
            this.lstViewParquesEolicos.ItemsSource = this.ListaParquesEolicos;

            this.ListaParquesEolicosSelecionados = new ObservableCollection <ParqueEolico>();
            this.lstViewParquesEolicosSelecionados.ItemsSource = this.ListaParquesEolicosSelecionados;
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            Console.WriteLine("*********************** Singleton *************************");
            Singleton instance = Singleton.getInstance();

            instance.PrintOutput("This is an implementation of singleton which belongs to the creational design pattern");
            instance.PrintOutput("Only single instance is created throughout the application");

            Console.WriteLine("*********************** Factory *************************");
            IEmployeeType emp;

            FactoryController.chooseType();
            try
            {
                emp = FactoryController.getEmployee(Convert.ToInt32(FactoryController.getEmployeeType().ToString()));
                emp.setEmployeeType();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }