User:Saheb
I am an undergraduate student from Dhirubhai Ambani Institute of Information and Communication Technology(DA-IICT),Gandhinagar,Gujarat,India.
Code branch: saheb:
Present Goal
I am currently working on implementing the feature of Adding 'smart' default units of measurement in the PyGTK GUI(bug 429). This bug comes under Student_Projects#GUI improvements.
Idea
Present: If there are no preferred units, what is used is base SI dimensions and my task is to display smart intuitive units in place of SI dimensions( i.e. N in place of kg*m/s^2). I will use the units present after the Default value in Default statements for instance in force DEFAULT defvalue{N}, and so will have to store the braced text while parsing through it. So the hierarchy after the feature gets implemented will be:
1) User Defined Units.
2) Preferred Units if present in ascend.ini.
3) Smart Intuitive Default Units.
4) Base Dimensions.
Tasks
- Understanding the working of various layers involved.
- Modify the C Layer code and modify the typedesc struct to get default unit included in it.
- Write a CUnit Code to test the initial modification of C layer code.
- Understand the C++ wrapping and SWIG tool.
- Write C++ functions to get the default unit and then pass it to the PyGTK layer.
- Modify test.py to test the final feature.
I have completed first three tasks and looking forward to quickly achieve the goal.
Working with ASCEND
Here is the first model which I created using ASCEND modelling environment.
REQUIRE "system.a4l"; REQUIRE "atoms.a4l"; ATOM cost_per_item REFINES solver_var DIMENSION C DEFAULT 1.0{USD}; lower_bound := 0.0{USD}; upper_bound := 1e50{USD}; nominal := 1.0{USD}; END cost_per_item; MODEL grocery_item; cost IS_A monetary_unit; METHODS METHOD on_load; FIX cost; cost := 80{USD}; END on_load; END grocery_item; MODEL grocery_price_item REFINES grocery_item; price_per_item IS_A cost_per_item; k IS_A factor; cost = price_per_item * k; METHODS METHOD specify_cost; FIX price_per_item; FIX k; price_per_item := 20{USD}; END specify_cost; END grocery_price_item; MODEL grocery_price_mass REFINES grocery_item; price_per_mass IS_A cost_per_mass; m IS_A mass; cost = (price_per_mass * m); METHODS METHOD specify_cost; FIX price_per_mass; FIX m; price_per_mass := 10{USD/kg}; END specify_cost; END grocery_price_mass; MODEL grocery_price_volume REFINES grocery_item; price_per_volume IS_A cost_per_volume; v IS_A volume; cost = price_per_volume * v; METHODS METHOD specify_cost; FIX price_per_volume; FIX v; price_per_volume := 30{USD/m^3}; END specify_cost; END grocery_price_volume; MODEL grocery_basket; NT IS_A integer_constant; total IS_A monetary_unit; grocery[1..NT] IS_A grocery_item; total = SUM[grocery[1..NT].cost]; METHODS METHOD on_load; FIX NT; FOR i IN [1..NT] DO RUN grocery[i].specify_cost; END FOR; END on_load; END grocery_basket; MODEL grocery_tester; g IS_A grocery_basket; g.NT :== 5; g.grocery[1], g.grocery[2] IS_REFINED_TO grocery_price_volume; g.grocery[3], g.grocery[4] IS_REFINED_TO grocery_price_mass; g.grocery[5] IS_REFINED_TO grocery_price_item; METHODS METHOD on_load; g.grocery[1].v := 10{m^3}; g.grocery[2].v := 20{m^3}; g.grocery[3].m := 5{kg}; g.grocery[4].m := 25{kg}; g.grocery[5].k := 10; RUN g.grocery[1].specify_cost; RUN g.grocery[2].specify_cost; RUN g.grocery[3].specify_cost; RUN g.grocery[4].specify_cost; RUN g.grocery[5].specify_cost; END on_load; END grocery_tester;
Screen shots of the above model while running it in ascend PyGtk gui.



