% % $Id: hekate_case_cashpoint-clb.pl,v 1.4 2009-11-19 16:50:22 esimon Exp $ % % File generated by HeKatE Qt Editor ver. M6_9 % % HeaRT case % % % Copyright (C) 2006-9 by the HeKatE Project % % HeaRT has been develped by the HeKatE Project, % see http://hekate.ia.agh.edu.pl % % This file is part of HeaRT. % % HeaRT is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % HeaRT is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with HeaRT. If not, see . % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %:- ensure_loaded('heart.pl'). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TYPES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%% xtype [name: boolean, base: numeric, length: 1, scale: 0, desc: boolean, domain: [0,1] ]. xtype [name: integer, base: numeric, length: 10, scale: 0, desc: integer, domain: [-2147483648 to 2147483647] ]. xtype [name: default, base: symbolic, domain: [none/1], ordered: yes ]. xtype [name: tPin, base: numeric, length: 4, scale: 0, desc: 'Represents the PIN numbers ', domain: [0 to 9999] ]. xtype [name: tPinDifference, base: numeric, length: 4, scale: 0, desc: 'Represents all the possible results of two PIN numbers subtraction ', domain: [-9999 to 9999] ]. xtype [name: tUserActions, base: symbolic, desc: 'The set of actions that user can invoke', domain: [withdraw,balance] ]. xtype [name: tCashPointActivities, base: symbolic, desc: 'The set of actions that can be executed by cashpoint', domain: [askForPIN,payOut,takeCardAway,displayBalance,msgNotEnoughFoundsInMachine,msgNotEnoughFoundsOnAccount] ]. xtype [name: tMoney, base: numeric, %Missing domain deffinition domain: [0 to 1000000], desc: 'Represents the amount of money' ]. xtype [name: tBool, base: symbolic, desc: 'The boolean values', domain: [false/0,true/1], ordered: yes ]. xtype [name: tAttempts, base: numeric, length: 1, scale: 0, desc: ' yes The type that defines the number of attempts to enter a correct PIN', domain: [0 to 3] ]. %%%%%%%%%%%%%%%%%%%%%%%%% ATTRIBUTES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%% xattr [name: authorizated, abbrev: autho, class: simple, type: tBool, comm: inter ]. xattr [name: cashPointActivity, abbrev: cashP, class: simple, type: tCashPointActivities, comm: out ]. xattr [name: cashPointAmount, abbrev: cash, class: simple, type: tMoney, comm: in, callback: [xpce_ask_numeric,[cashPointAmount]] ]. xattr [name: cdAmountDifference, abbrev: cdAmo, class: simple, type: tMoney, comm: inter ]. xattr [name: correctPin, abbrev: corre, class: simple, type: tPin, comm: in, callback: [xpce_ask_numeric,[correctPin]] ]. xattr [name: desiredAmount, abbrev: desir, class: simple, type: tMoney, comm: in, callback: [xpce_ask_numeric,[desiredAmount]] ]. xattr [name: enteredPin, abbrev: enter, class: simple, type: tPin, comm: in, callback: [xpce_ask_numeric,[enteredPin]] ]. xattr [name: failedAttempts, abbrev: faile, class: simple, type: tAttempts, comm: inter ]. xattr [name: pinDifference, abbrev: pinDi, class: simple, type: tPinDifference, comm: inter ]. xattr [name: udAmountDifference, abbrev: udAmo, class: simple, type: tMoney, comm: inter ]. xattr [name: userAccountAmount, abbrev: userA, class: simple, type: tMoney, comm: in, callback: [xpce_ask_numeric,[userAccountAmount]] ]. xattr [name: userRequestedAction, abbrev: userR, class: simple, type: tUserActions, comm: in, callback: [xpce_ask_symbolic,[userRequestedAction]] ]. %%%%%%%%%%%%%%%%%%%%%%%% TABLE SCHEMAS DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%% xschm 'Table1': [authorizated,failedAttempts,userRequestedAction,udAmountDifference,cdAmountDifference] ==> [cashPointActivity]. xschm 'Table2': [pinDifference] ==> [authorizated,failedAttempts]. xschm 'Table3': [enteredPin,correctPin] ==> [pinDifference]. xschm 'Table4': [desiredAmount,userAccountAmount] ==> [udAmountDifference]. xschm 'Table5': [cashPointAmount,desiredAmount] ==> [cdAmountDifference]. %%%%%%%%%%%%%%%%%%%%%%%%%%%% RULES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%% xrule 'Table1'/1: [authorizated eq false, failedAttempts lt 3, userRequestedAction eq any, udAmountDifference eq any, cdAmountDifference eq any] ==> [cashPointActivity set askForPIN]. xrule 'Table1'/2: [authorizated eq false, failedAttempts eq 3, userRequestedAction eq any, udAmountDifference eq any, cdAmountDifference eq any] ==> [cashPointActivity set takeCardAway]. xrule 'Table1'/3: [authorizated eq true, failedAttempts eq any, userRequestedAction eq balance, udAmountDifference eq any, cdAmountDifference eq any] ==> [cashPointActivity set displayBalance]. xrule 'Table1'/4: [authorizated eq true, failedAttempts eq any, userRequestedAction eq withdraw, udAmountDifference gte 0.0000000000, cdAmountDifference gte 0.0000000000] ==> [cashPointActivity set payOut]. xrule 'Table1'/5: [authorizated eq true, failedAttempts eq any, userRequestedAction eq withdraw, udAmountDifference eq any, cdAmountDifference lt 0.0000000000] ==> [cashPointActivity set msgNotEnoughFoundsInMachine]. xrule 'Table1'/6: [authorizated eq true, failedAttempts eq any, userRequestedAction eq withdraw, udAmountDifference lt 0.0000000000, cdAmountDifference gte 0.0000000000] ==> [cashPointActivity set msgNotEnoughFoundsOnAccount]. xrule 'Table2'/1: [pinDifference neq 0] ==> [authorizated set false, failedAttempts set (failedAttempts+1)] :'Table1'. xrule 'Table2'/2: [pinDifference eq 0] ==> [authorizated set true, failedAttempts set failedAttempts]. xrule 'Table3'/1: [enteredPin eq any, correctPin eq any] ==> [pinDifference set (correctPin-enteredPin)] :'Table2'. xrule 'Table4'/1: [desiredAmount eq any, userAccountAmount eq any] ==> [udAmountDifference set (userAccountAmount-desiredAmount)] :'Table1'. xrule 'Table5'/1: [cashPointAmount eq any, desiredAmount eq any] ==> [cdAmountDifference set (cashPointAmount-desiredAmount)] :'Table1'. %%%%%%%%%%%%%%%%%%%%%%%%% STATES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%% xstat init0: [enteredPin,1111]. xstat init0: [correctPin,1111]. xstat init0: [desiredAmount,100.0000000000]. xstat init0: [cashPointAmount,100000.0000000000]. xstat init0: [userAccountAmount,10000.0000000000]. xstat init0: [userRequestedAction,withdraw]. xstat init1: [enteredPin,1111]. xstat init1: [correctPin,1112]. xstat init1: [desiredAmount,100.0000000000]. xstat init1: [cashPointAmount,100000.0000000000]. xstat init1: [userAccountAmount,10000.0000000000]. xstat init1: [userRequestedAction,withdraw]. xstat init2: [enteredPin,1111]. xstat init2: [correctPin,1111]. xstat init2: [desiredAmount,100.0000000000]. xstat init2: [cashPointAmount,10.0000000000]. xstat init2: [userAccountAmount,10000.0000000000]. xstat init2: [userRequestedAction,withdraw]. xstat init3: [enteredPin,1111]. xstat init3: [correctPin,1111]. xstat init3: [desiredAmount,100.0000000000]. xstat init3: [cashPointAmount,1000.0000000000]. xstat init3: [userAccountAmount,10.0000000000]. xstat init3: [userRequestedAction,withdraw]. xstat init4: [enteredPin,1111]. xstat init4: [correctPin,1112]. xstat init4: [failedAttempts,2]. xstat init4: [userRequestedAction,withdraw]. xstat init5: [enteredPin,1111]. xstat init5: [correctPin,1111]. xstat init5: [desiredAmount,100.0000000000]. xstat init5: [cashPointAmount,100000.0000000000]. xstat init5: [userAccountAmount,10000.0000000000]. xstat init5: [userRequestedAction,balance]. xstat init6: [enteredPin,1111]. xstat init6: [correctPin,1112]. xstat init6: [desiredAmount,100.0000000000]. xstat init6: [cashPointAmount,100000.0000000000]. xstat init6: [userAccountAmount,10000.0000000000]. xstat init6: [userRequestedAction,balance]. xstat init7: [enteredPin,1111]. xstat init7: [correctPin,1111]. xstat init7: [desiredAmount,100.0000000000]. xstat init7: [cashPointAmount,10.0000000000]. xstat init7: [userAccountAmount,10000.0000000000]. xstat init7: [userRequestedAction,balance]. xstat init8: [enteredPin,1111]. xstat init8: [correctPin,1111]. xstat init8: [desiredAmount,100.0000000000]. xstat init8: [cashPointAmount,1000.0000000000]. xstat init8: [userAccountAmount,10.0000000000]. xstat init8: [userRequestedAction,balance]. xstat init9: [enteredPin,1111]. xstat init9: [correctPin,1112]. xstat init9: [failedAttempts,2]. xstat init9: [userRequestedAction,balance]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % File generated by HeKatE Qt Editor ver. M6_9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%% Callbacks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% xcall xpce_ask_numeric: [AttName] >>> (alsv_domain(AttName,[Min to Max],numeric), dynamic(end), new(@dialog,dialog('Select a value')), send_list(@dialog,append, [new(I,int_item(AttName,low := Min, high := Max)), new(_,button('Select',and(message(@prolog,assert,end),and(message(@prolog,alsv_new_val,AttName,I?selection),message(@dialog,destroy)))))]), send(@dialog,open), repeat, send(@display,dispatch), end,!, retractall(end)). xcall xpce_ask_symbolic: [AttName] >>> (alsv_domain(AttName,Domain,symbolic), dynamic(end), new(@dialog,dialog('Select a value')), send_list(@dialog,append, [new(I,menu(AttName,cycle)), new(_,button('Select',and(message(@prolog,assert,end),and(message(@prolog,alsv_new_val,AttName,I?selection),message(@dialog,destroy)))))]), send_list(I,append,Domain), send(@dialog,open), repeat, send(@display,dispatch), end,!, retractall(end)).