Item changed event

Sep 12, 2007 at 2:58 PM
Is there a Item changed event available in Flee. I would like to be able to hook into a Flee event that will send me the item name everytime its value changed. This will allow me to perform additional processing on a particarly item after the value has changed.

brian
Coordinator
Sep 13, 2007 at 2:24 PM
Hi Brian,

When you say "item" are you referring to the calculation engine? I'm guessing you mean that when you call Recalulate() on the calculation engine, an event should be fired everytime a node is recalculated.

Is this right or are you thinking of something else?

Eugene
Sep 20, 2007 at 7:26 PM
<PRE lang=cs id=pre8 style="MARGIN-TOP: 0px">// Create the calculation engine
CalculationEngine engine = new CalculationEngine();

// Expressions used in the calculation engine require a specific type of owner.
// The DynamicExpressionOwner is compatible with this type of owner, so we can use it.
// Add an expression to the engine as "a"
DynamicExpressionOwner ownerA = new DynamicExpressionOwner();
ownerA.DefineVariable("x", typeof(int));
ownerA.SetVariableValue<int>("x", 100);
engine.Add("x * 2", ownerA, "a");

// Add an expression to the engine as "b"
DynamicExpressionOwner ownerB = new DynamicExpressionOwner();
ownerB.DefineVariable("y", typeof(int));
ownerB.SetVariableValue<int>("y", 200);
engine.Add("y + 100", ownerB, "b");

// Add an expression that references a and b
DynamicExpressionOwner ownerC = new DynamicExpressionOwner();
engine.Add("a + b", ownerC, "c");

// Recalculate a and b (which will also recalculate c)
engine.Recalculate("a", "b");

// Get the value of c
int result = engine.GetResult<int>("c");

// Update the a expression
ownerA.SetVariableValue<int>("x", 200);

// Recalculate it
engine.Recalculate("a");

// Get the updated result
result = engine.GetResult<int>("c");
</PRE>

In your above example we would like to know if an event gets fired when "c" changes based on the recalculation of "a".

Brian

ECiloci wrote:
Hi Brian,

When you say "item" are you referring to the calculation engine? I'm guessing you mean that when you call Recalulate() on the calculation engine, an event should be fired everytime a node is recalculated.

Is this right or are you thinking of something else?

Eugene

Coordinator
Sep 21, 2007 at 1:20 AM
There isn't an event right now. I will put one in this weekend.

Eugene
Coordinator
Sep 23, 2007 at 8:51 PM
The CalculationEngine now has a NodeRecalculated event which fires for each recalculated node.

It is in the 0.9.8.0 release.
Sep 25, 2007 at 1:33 AM
Eugene,

Thanks for adding the recalculation event. I'm currently working on building an interface to your calculation library which will allow me to swap out our third party calc engine (Inacalc.Net) and replaceit with Flee. Then I can see if our application performs better with Flee.

brian
Nov 28, 2007 at 12:57 PM
Eugene,

As I indicated I was working on a replacement inface so that I could easily swap out my old calculation engine and implement the Flee calc engine to see if it was faster. I have the initial skeloton code complete but before I go any further I would like you to have a look at it. The two really important parts are the events and the Custom Function support. I have a zip file of my project but I'm not sure how to post it on codeplex. Do you have an email address I can send the zip file to.

thanks

brian
Coordinator
Nov 29, 2007 at 3:14 AM
Hi Brian,

If you are ok with the code being publicly visible, you can create an Issue and then attach your project to it.

Thanks,

Eugene
Coordinator
Dec 5, 2007 at 3:25 AM
Hi Brian,

I've looked at your code and I think you've got everything right except there are some spots where you mix the name of variables with names of expressions.

I think I need to slightly refactor the calculation engine to make it more user friendly (based on your other comment) and maybe I can use InaCalc as a reference (since there don't seem to be any other calculation engines out there).