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(); }
//********************************************************** // workingObj is set by the button click method //********************************************************** private void TestRules(RuleBase ruleBase, Form1 F1) { F1.debugOutput.Text += "\nRule Run: "; if (_currentCust == null) { _currentCust = F1.workingMemory.assertObject(workingObj); } else { F1.workingMemory.modifyObject(_currentCust, workingObj); } if (secondWorkingObj != null) { F1.workingMemory.assertObject(secondWorkingObj); } F1.workingMemory.fireAllRules(); CustomerRecord customer = (CustomerRecord)F1.workingMemory.getObject(_currentCust); F1.debugOutput.Text += "\nCustomer: " + customer.Id + " | Qty: " + customer.Value + " | STATUS: " + customer.Status; if (secondWorkingObj != null) { F1.debugOutput.Text += "\n 2nd Customer: " + secondWorkingObj.Id + " | Qty: " + secondWorkingObj.Value + " | STATUS: " + secondWorkingObj.Status; } }
static void TestRules(RuleBase ruleBase, CustomerRecord workingObj) { if (workingMemory == null) { workingMemory = ruleBase.NewWorkingMemory(); } if (_currentCust == null) { _currentCust = workingMemory.assertObject(workingObj); } else { workingMemory.modifyObject(_currentCust, workingObj); } workingMemory.fireAllRules(); }