I want to do the following behavior in one delphi application.(10.3 )
I want a user to have the possibility to implement his own logical behavior of a program "saved in options".
Very similar with an arduino logical/program.
For example
I create a program that is keep tracking values about 10 heat sensors. But it can be anything.
The program has a timer and in the on timer event the following actions are taking places.
- read the values from sensors
- take action if needed
there are 2 types of info saved in this class.
Non Changing informations like ID name etc, and permanent changing (DATA).
here is the example of the base class that hold all the info from one sensor.
type TXXX = class
private
public
// info that are not changing ever
property ID : Integer ...
property SENSOR_NAME : String ...
// info that are constantly changing
property READ_TIMESTAMP : TDateTime ...
property CURRENT_VALUE : Double ...
property VALUE_SUPREMUM : Double ...
property VALUE_INFIMUM : Double ...
end
I need to create some sort of options of the program when a user can define his own logical that the program should respond if condition are meet.
for example a user want to say:
if CURRENT_VALUE > 5 and VALUE_INFIMUM > 0.5 then begin
"take action 1"
end
and so on...
"take action x" and all the actions are hardcoded. for example close/open a valve.
now these properties are more than 4 are like 50 or so.
anyone can point me some directions?
Regards
Razvan
CodePudding user response:
There are 2 ways how you can solve your problem.
1st: You can use some of scripting engines. That’s the direct purpose of this components. You can use something like Pascal Script For Delphi (https://www.remobjects.com/ps.aspx), Fast script (https://www.fast-report.com/en/product/fast-script/), TMS Scripter (https://www.tmssoftware.com/site/scriptstudiopro.asp), etc.
2nd: If you have limited actions and condition – you can write your own parser and GUI for it for handle all this staff. Make expressions parser, declare operants (numbers or allowed properties of your sensors, or other expression), declare mathematical operations (plus, mines...) and logical operation (Lower, higer, equal, and, not, or). It's can take a while to implement it, but you can build very user-friendly wizard to manage it.