There’s a lot I did in the last 2 weeks and since I did not update the blog last week, this post is going to include last 2 week’s progress.
Before I begin with what I did, here’s a quick review of what I was working on and what had been done.
I started porting Cantor’s Qalculate backend to QProcess and during the first week I worked on establishing connection with Qalculate, for which we use qalc and some amount of time was spent parsing the output returned by qalc
Qalculate backend as of now uses libqalcuate API for computing the result. To successfully eliminate the direct use of API all the commands should make use qalc, but since qalc does not support all the functions of Qalculate, I had to segerate the parts depending on API from qalc. For instance, qalc does not support plotting graphs.
The version of qalc that we are using supports almost all the major functionalities of Qalculate but there are a few things for which we still depend on the API directly
I will quickly describe what depends on what
* help command
* syntax highlighter
* tab completion
* basic calculations: addition, subtraction etc
* all the math functions provided by Qalculate: sqrt(), binomial(), integrate() etc
* saving variables
Segregating part was easy. The other important thing I did was to form a queue based system for the commands that are required to be processed by qalc
Queue based system
The two important components of this system are:
1. Expression Queue :- contains the expressions to be processed
2. Command Queue:- contains commands of the expression being processed.
* The basic idea behind this system is , we compute only one expression at a time, mean while if we get more expressions from user, we store them in the queue and process them once the current expression being processed is complete.
* Another important point is , since an expression can contain multiple commands, we store all the commands for an expression in command queue and just like we process one expression at a time, we are going to process one command at a time. i.e we are going to give QProcess only one command at a time, this makes the output returned by QProcess less messy and hence it’s easier to parse
* Example: Expression1 = (10+12, sqrt(12)) : this expression has multiple commands. The command queue for the same will have two commands.
expression queue command queue
[ expression 1 ] ——————————————-> [ 10+12 ], [ sqrt(12) ]
[ expression 2] ——————————————-> [ help plot ]
We solve all the commands of expression1 , parse the output and then move on to expression2 and this goes on till the time expression queue is empty
Apart from this I worked on Variable model of Qalculate. Qalc provides a lot of variations of save command. Different commands available are:
Not every command mentioned below has been implemented but the important ones have been.
1. save(value, variable, category, title): Implemented
This function is available through the qalc interface and allows the user to define new variables or override the existing variables with the given value.
2. save/store variable : Implemented
This command allows the user to save the current result in a variable with the specified name.
Current result is the last computed result. Using qalc we can access the last result using ‘ans’, ‘answer’ and a few more variables.
3.save definitions : Not implemented
Definitions include the user defined variables, functions, units .
4. save mode: Not implemented
mode is the configuration of the user which include things like ‘angle unit’, ‘multiplication sign’ etc.
With this most of the important functionalities have been ported to qalc but there are still a few things for which we depend on the API directly. Hopefully, in the future with the newer version of qalc we will be able to remove the direct use of API from Cantor
Thanks and Happy hacking