% % $Id: thermostat.pl,v 1.4 2009-11-18 11:06:45 esimon Exp $ % % File generated by HeKatE Qt Editor ver. M6_5 % % 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: 9, scale: 0, desc: integer, domain: [-999999999 to 999999999] ]. xtype [name: day, base: symbolic, domain: [mon/1,tue/2,wed/3,thu/4,fri/5,sat/6,sun/7], ordered: yes ]. xtype [name: hour, base: numeric, domain: [0 to 23] ]. xtype [name: month, base: numeric, domain: [1 to 12] ]. xtype [name: operation, base: symbolic, domain: [bizhrs,nbizhrs], ordered: yes ]. xtype [name: season, base: symbolic, domain: [spring,summer,fall,winter], ordered: yes ]. xtype [name: thermostat_settings, base: numeric, domain: [14,15,16,18,20,24,27] ]. xtype [name: today, base: symbolic, domain: [workday,weekend], ordered: yes ]. %%%%%%%%%%%%%%%%%%%%%%%%% ATTRIBUTES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%% xattr [name: day, abbrev: day, class: simple, type: day, comm: in, callback: [ask_console,[day]] ]. xattr [name: hour, abbrev: hour, class: simple, type: hour, comm: in, callback: [ask_console,[hour]] ]. xattr [name: month, abbrev: month, class: simple, type: month, comm: in, callback: [ask_console,[month]] ]. xattr [name: operation, abbrev: oper, class: simple, type: operation, comm: inter ]. xattr [name: season, abbrev: seaso, class: simple, type: season, comm: inter ]. xattr [name: thermostat_settings, abbrev: tset, class: simple, type: thermostat_settings, comm: out, callback: [tell_console,[thermostat_settings]] ]. xattr [name: today, abbrev: today, class: simple, type: today, comm: inter ]. %%%%%%%%%%%%%%%%%%%%%%%%% STATES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%% xstat 'Table3': [month,2.0000000000]. xstat init: [day,wed]. xstat init: [hour,3.0000000000]. %%%%%%%%%%%%%%%%%%%%%%%% TABLE SCHEMAS DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%% xschm ms: [month] ==> [season]. xschm dt: [day] ==> [today]. xschm th: [today,hour] ==> [operation]. xschm os: [operation,season] ==> [thermostat_settings]. %%%%%%%%%%%%%%%%%%%%%%%%%%%% RULES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%% xrule ms/1: [month in [1,2,12]] ==> [season set winter] :os/5. xrule ms/2: [month in [3,4,5]] ==> [season set spring] :os/3. xrule ms/3: [month in [6,7,8]] ==> [season set summer] :os/1. xrule ms/4: [month in [9,10,11]] ==> [season set fall] :os/7. xrule dt/1: [day in [mon to fri]] ==> [today set workday] :th/1. xrule dt/2: [day in [sat,sun]] ==> [today set weekend] :th/1. xrule th/1: [today eq workday, hour gt 17] ==> [operation set nbizhrs] :os/1. xrule th/2: [today eq weekend, hour eq 20] ==> [operation set nbizhrs] :os/1. xrule th/3: [today eq workday, hour lt 2] ==> [operation set nbizhrs] :os/1. xrule th/4: [today eq workday, hour in [9 to 17]] ==> [operation set bizhrs] :os/1. xrule os/1: [operation eq nbizhrs, season eq summer] ==> [thermostat_settings set 27]. xrule os/2: [operation eq bizhrs, season eq summer] ==> [thermostat_settings set 24]. xrule os/3: [operation eq nbizhrs, season eq spring] ==> [thermostat_settings set 15]. xrule os/4: [operation eq bizhrs, season eq spring] ==> [thermostat_settings set 20]. xrule os/5: [operation eq bizhrs, season eq winter] ==> [thermostat_settings set 18]. xrule os/6: [operation eq nbizhrs, season eq winter] ==> [thermostat_settings set 14]. xrule os/7: [operation eq nbizhrs, season eq fall] ==> [thermostat_settings set 16]. xrule os/8: [operation eq bizhrs, season eq fall] ==> [thermostat_settings set 20]. xcall ask_console : [AttName] >>> (write('Type value for attribute: '), write(AttName),nl, read(Answer), alsv_new_val(AttName,Answer)). xcall tell_console : [AttName] >>> (write('Attribute '),write(AttName),write(' output value is '), xstat(current:[AttName,V]), write(V),nl). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % File generated by HeKatE Qt Editor ver. M6_5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%