Exemple #1
0
    void ProfitRate()
    {
        float f = 0;

        for (int i = 0; i < stations.Length; ++i)
        {
            f += stations[i].income[stations[i].level];
        }
        if (f != baseIncome)
        {
            baseIncome = f;
        }
        GameObject[] worker         = GameObject.FindGameObjectsWithTag("Worker");
        float        tempIncomeRate = 1;

        for (int i = 0; i < worker.Length; ++i)
        {
            WorkerObject workerObject = worker[i].GetComponent <WorkerObject>();
            workerObject.SetWorker(workerObject.id);
            tempIncomeRate += workerObject.income[workerObject.level];
        }
        if (tempIncomeRate != incomeRate)
        {
            incomeRate  = tempIncomeRate;
            baseIncome *= incomeRate;
            Debug.Log("Income Rate is " + baseIncome);
            Debug.Log("Temp is " + tempIncomeRate);
        }

        SetCashTextValue(baseIncome *= incomeRate, incomeNumber);
        SetCashTextValue(wages, wagesNumber);
        SetCashTextValue(profit, profitNumber);
    }
        public HShelfFramework(string architectural_code)
        {
            this.architectural_code = architectural_code;

            core_services             = new WorkflowCoreServices();
            platform_services         = new SAFePlatformServices();
            platform_services.Address = "http://127.0.0.1/PlatformServices.asmx";
            baseFramework             = (WorkerObject)((ManagerObject)platform_services.Session).WorkerFramework;

            workflow_handle = core_services.openWorkflowSession(architectural_code, platform_services);

            this.app_name = core_services.getAppName(workflow_handle);

            core_services.instantiate(workflow_handle, "workflow");
        }
Exemple #3
0
    void UpgradeWorker(int i, string w)
    {
        StationObject stationObject = stations[i].target.GetComponent <StationObject>();

        if (stations[i].target.GetComponent <StationObject>().workerSpawn != null)
        {
            if (!stationObject.jobFull)
            {
                GameObject   worker       = Instantiate(Resources.Load <GameObject>("Prefabs/" + w));
                WorkerObject workerObject = worker.GetComponent <WorkerObject>();
                worker.transform.position = stationObject.workerSpawn.position;
                worker.transform.parent   = stationObject.workerSpawn;
                stationObject.jobFull     = true;
                workerObject.id           = i;
                ProfitRate();
            }
        }
    }
Exemple #4
0
            private void init(string architectural_code, ProvideContracts provide_contracts)
            {
                this.architectural_code = architectural_code;

                core_services             = new WorkflowCoreServices();
                platform_services         = new SAFePlatformServices();
                platform_services.Address = "http://127.0.0.1/PlatformServices.asmx";

                workflow_handle = core_services.openWorkflowSession(architectural_code, platform_services);
                this.app_name   = core_services.getAppName(workflow_handle);

                core_services.registerContract(workflow_handle, "application", "");
                core_services.registerContract(workflow_handle, "workflow", "");
                provide_contracts();

                core_services.deploy(workflow_handle, "platform_SAFe");

                core_services.instantiate(workflow_handle, "platform_SAFe");
                core_services.instantiate(workflow_handle, "swl_port");
                core_services.instantiate(workflow_handle, "application");
                core_services.instantiate(workflow_handle, "workflow");

                baseFramework = (WorkerObject)((ManagerObject)platform_services.Session.Framework).WorkerFramework;
                Console.WriteLine(this.app_name + "-workflow");
                foreach (string k in baseFramework.UnitOf.Keys)
                {
                    Console.WriteLine("UnitOf[{0}] !", k);
                }
                ((IWorkflowKind)(baseFramework.UnitOf[this.app_name + "-workflow"])).CoreServices = core_services;

                Thread run = new Thread(new ThreadStart(delegate
                {
                    core_services.run(workflow_handle, "application");
                    core_services.run(workflow_handle, "workflow");
                }));

                run.Start();
            }
Exemple #5
0
        protected static void Reconfigure(string xml)
        {
            XmlDocument document = new XmlDocument();
            XmlNode     nodeRequest, data;

            document.Load(xml);
            nodeRequest = document.SelectSingleNode("reconfigurationRequest");
            data        = nodeRequest.SelectSingleNode("targetComponent");

            string targetComponent = data.InnerText;

            List <IConnectorImpl> connectors = new List <IConnectorImpl>();
            IConnectorImpl        connimpl;
            IUnit unit;
            int   i = 0;

            foreach (AbstractFramework ab in workers)
            {
                WorkerObject worker = (WorkerObject)ab;
                if (worker.UnitInstances.TryGetValue(targetComponent, out unit))
                {
                    if ((unit as IConnectorImpl) != null)
                    {
                        Console.WriteLine("[HPE_Run.Reconfigure] Worker {0} : Conector Encontrado!", i++);
                        connimpl = (IConnectorImpl)unit;
                        connimpl.ConfigurationPort.BuildService = worker;
                        connectors.Add(connimpl);
                    }
                    else
                    {
                        Console.WriteLine("[HPE_Run.Reconfigure] Worker {0} : O componente {1} não é um conector HCL!", i++, targetComponent);
                    }
                }
            }
            // reconfigure /home/juliano/hpe/temp/reconf1.xml
            bool sucess = true;

            foreach (IConnectorImpl conn in connectors)
            {
                Console.WriteLine("[HPE_Run.Reconfigure] Avaliando a Reconfiguração no Conector {0}", conn.Id_unit);

                if (conn.ConfigurationPort.Ready)
                {
                    //medição
                    DateTime t_initial = DateTime.Now;

                    bool result = conn.ConfigurationPort.EvaluateReconfiguration(xml);

                    //medição
                    DateTime t_end  = DateTime.Now;
                    TimeSpan t_diff = t_end.Subtract(t_initial);
                    Console.WriteLine("[HPE_Run.Reconfigure] Tempo de Avaliação: " + t_diff.Milliseconds + " ms");

                    if (!result)
                    {
                        Console.WriteLine("[HPE_Run.Reconfigure] A Reconfiguração não pode ser aplicada ao Conector {0}", conn.Id_unit);
                        Console.WriteLine("[HPE_Run.Reconfigure] O processo de reconfiguração será cancelado");
                        sucess = false;
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("[HPE_Run.Reconfigure] A Reconfiguração não pode ser aplicada ao Conector {0}", conn.Id_unit);
                    Console.WriteLine("[HPE_Run.Reconfigure] O ConfigurationManager ainda está em processo de formação.");
                    Console.WriteLine("[HPE_Run.Reconfigure] O processo de reconfiguração será cancelado");
                    sucess = false;
                    break;
                }
            }

            Console.WriteLine("[HPE_Run.Reconfigure] Finalizando o procedimento!");
            foreach (IConnectorImpl conn in connectors)
            {
                if (sucess)
                {
                    //medição
                    DateTime t_initial = DateTime.Now;

                    conn.ConfigurationPort.CommitReconfiguration();

                    //medição
                    DateTime t_end  = DateTime.Now;
                    TimeSpan t_diff = t_end.Subtract(t_initial);
                    Console.WriteLine("[HPE_Run.Reconfigure] Tempo de Commit: " + t_diff.Milliseconds + "ms");
                }
                else
                {
                    conn.ConfigurationPort.CancelReconfiguration();
                }
            }

            if (sucess)
            {
                Console.WriteLine("[HPE_Run.Reconfigure] Reconfiguração aplicada com sucesso!");
            }
            else
            {
                Console.WriteLine("[HPE_Run.Reconfigure] Não foi possível aplicar a reconfiguração em um ou mais nós. O procedimento foi abortado");
            }
        }