Example #1
0
        public void Simulate(Simulation formSimulation, SimulationDebug formDebug)
        {
            _formDebug      = formDebug;
            _formSimulation = formSimulation;
            formDebug.Show();

            //Imprimo this para saber sobre que objeto operaran las reglas
            FallasI.Simulator.ImprimirEnDebug(this);

            //Inicio la carga de drools
            formDebug.debugTxtBox.Text += "\nLoading Rule Base: ";
            formDebug.debugTxtBox.Refresh();
            PackageBuilder builder = new PackageBuilder();
            Stream         stream  = new FileStream(FallasI.Src.App.Default.PATH_ARCHIVO_REGLAS, FileMode.Open);

            formDebug.debugTxtBox.Text += "\nStream Set ";
            formDebug.debugTxtBox.Refresh();
            formDebug.debugTxtBox.Text += "\nReading DRL (Please wait... this may take a few moments...) ";
            formDebug.debugTxtBox.Refresh();

            builder.AddPackageFromDrl("FallasI.Rules.drl", stream);
            formDebug.debugTxtBox.Text += "... Finished ";
            formDebug.debugTxtBox.Refresh();
            Package pkg = builder.GetPackage();

            formDebug.debugTxtBox.Text += "\nPackage Added ";
            formDebug.debugTxtBox.Refresh();

            ruleBase = RuleBaseFactory.NewRuleBase();
            ruleBase.AddPackage(pkg);
            formDebug.debugTxtBox.Text += "\nRule Base Set ";
            formDebug.debugTxtBox.Refresh();

            workingMemory = ruleBase.NewWorkingMemory();
            workingObj    = this;
            formDebug.debugTxtBox.Text += "\nWorking Object Set ";
            formDebug.debugTxtBox.Refresh();

            //Inicio la ejecucion de drool
            formDebug.debugTxtBox.Text += "\nRule Runing... ";
            formDebug.debugTxtBox.Refresh();

            if (_currentCust == null)
            {
                _currentCust = workingMemory.assertObject(workingObj);
            }
            else
            {
                workingMemory.modifyObject(_currentCust, workingObj);
            }

            workingMemory.fireAllRules();

            formDebug.debugTxtBox.Text += "\nFin ";
            formDebug.debugTxtBox.Refresh();

            // llamo a simular
            _formSimulation.DibujarSimulacion();
            //formDebug.Close();
        }
Example #2
0
        public Simulation()
        {
            InitializeComponent();

            //Cargo los valores Por defecto:
            ServerPower     = (ServerPower == 0) ? 1 : ServerPower;
            ServerEffect    = (ServerEffect == 0) ? 2 : ServerEffect;
            ServerDirection = (ServerDirection == 0) ? 2 : ServerDirection;
            ServerHilt      = (ServerHilt == 0) ? 3 : ServerHilt;
            ServerHiltType  = (ServerHiltType == 0) ? 3 : ServerHiltType;
            ServerShotType  = (ServerShotType == 0) ? 2 : ServerShotType;

            CheckForIllegalCrossThreadCalls = false;
            SimulationDebug formDebug = new SimulationDebug();

            simulador.Simulate(this, formDebug);
        }