| 1 | % (c) 2009-2013 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, | |
| 2 | % Heinrich Heine Universitaet Duesseldorf | |
| 3 | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) | |
| 4 | ||
| 5 | :- module(units_conversions, [ | |
| 6 | conversion_factor/3, | |
| 7 | conversion_add/3 | |
| 8 | ]). | |
| 9 | ||
| 10 | :- use_module(library(clpfd)). | |
| 11 | ||
| 12 | :- use_module(probsrc(module_information)). | |
| 13 | :- module_info(group,plugin_units). | |
| 14 | :- module_info(description,'Units Plugin: This module lists conversion factors for different units.'). | |
| 15 | ||
| 16 | % conversion by multiplication | |
| 17 | % special cases | |
| 18 | conversion_factor([X,s,1],60,[X,mins,1]). | |
| 19 | conversion_factor([X,mins,1],60,[X,h,1]). | |
| 20 | conversion_factor([X,h,1],24,[X,d,1]). | |
| 21 | ||
| 22 | % raylway special case: half-meters | |
| 23 | conversion_factor([X,hm,1],2,[X,m,1]). | |
| 24 | ||
| 25 | % general cases | |
| 26 | conversion_factor([Factor,Unit,Power],10,[Factor2,Unit,Power]) :- | |
| 27 | Factor2 #= Factor + 1. | |
| 28 | ||
| 29 | % conversion by addition - currently only one special cases | |
| 30 | conversion_add([0,degC,1],273,[0,'K',1]). |