
First of all, this is a great library. I want to use Flee for a small project but I’m facing some problem. This is want I want to achieve:
I have a CSV file with data from different channel:
Eg:
Speed, RPM, P1,P2, …
100,2500, 34, 657
110,2700,45, 56
…
I have another file that contains the definition of my equation
Eg:
Ch1 = Speed * P1 / P2
Ch2 = RPM * P3
…
My application load the equation definition and then I need to detect what will be the variables. I would like to be able to preevaluate the equation to be able to detect the variable.
Eg:
If my application read the equation ch1=Speed*P1/P2 then Flee will be able to tell me that my variables are Speed, P1 and P2. After that I will be able to load those values from the data file and evaluate them with Flee.
After that I will do something like
ExpressionContext MyContext2 = new ExpressionContext();
MyContext2.Imports.ImportStaticMembers(typeof(System.Math));
MyContext2.Imports.ImportStaticMembers(typeof(CustomFunctions));
MyContext2.Variables["Speed"] = SpeedArray[0];
MyContext2.Variables["P1"] P1Array[P1];
MyContext2.Variables["P2"] P2Array[P1];
IGenericExpression<double> eGeneric = ExpressionFactory.CreateGeneric<double>(" Speed*P1/P2", MyContext2);
for (int i = 0; i < SpeedArray.Length(); i++)
{
MyContext2.Variables["Speed"] = SpeedArray[0];
MyContext2.Variables["P1"] P1Array[P1];
MyContext2.Variables["P2"] P2Array[P2];
Ch1[i] = eGeneric.Evaluate();
}



I think you can use
on demand variables to solve your problem. Basically, Flee will raise an event every time it encounters a variable that isn't in the VariableCollection of the expression. Inside the event, you have access to the variable's name and type. You can then lookup
its value, set it on the event arguments, and flee will use the value when evaluating the expression.

