% % $Id: hekate_case_thermostat-clb.pl,v 1.3 2009-11-09 11:48:21 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: weekdays, base: symbolic, desc: 'A set of days of the week', domain: ['Monday'/1,'Tuesday'/2,'Wednesday'/3,'Thursday'/4,'Friday'/5,'Saturday'/6,'Sunday'/7], ordered: yes ]. xtype [name: hours, base: numeric, length: 2, scale: 0, desc: 'Hours of a day', domain: [0 to 23] ]. xtype [name: months, base: symbolic, desc: 'All months of the year', domain: ['January'/1,'February'/2,'March'/3,'April'/4,'May'/5,'June'/6,'July'/7,'August'/8,'September'/9,'October'/10,'November'/11,'December'/12], ordered: yes ]. xtype [name: seasons, base: symbolic, desc: 'Seasons of the year', domain: ['Winter'/1,'Spring'/2,'Summer'/3,'Autumn'/4], ordered: yes ]. xtype [name: operating_hours, base: symbolic, desc: 'Office operating hours', domain: [not_during_business_hours/0,during_business_hours/1], ordered: yes ]. xtype [name: week_or_end, base: symbolic, desc: 'Weekend or weekday', domain: [workday,weekend] ]. xtype [name: thermostat_temperature, base: numeric, length: 2, scale: 0, desc: 'The temperature range of the thermostat', domain: [1 to 30] ]. %%%%%%%%%%%%%%%%%%%%%%%%% ATTRIBUTES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%% xattr [name: day, abbrev: day, class: simple, type: weekdays, comm: in, callback: [ask_symbolic_GUI,[day]], desc: 'The current day' ]. xattr [name: hour, abbrev: hour, class: simple, type: hours, comm: in, callback: [ask_numeric_GUI,[hour]], desc: 'The current hour' ]. xattr [name: month, abbrev: mth, class: simple, type: months, comm: in, callback: [ask_symbolic_GUI,[month]], desc: 'The current month' ]. xattr [name: operation, abbrev: oper, class: simple, type: operating_hours, comm: inter, desc: 'Operating hours' ]. xattr [name: season, abbrev: ssn, class: simple, type: seasons, comm: inter, desc: 'Current season' ]. xattr [name: thermostat_settings, abbrev: therm, class: simple, type: thermostat_temperature, comm: out, callback: [tell_console,[thermostat_settings]], desc: 'The therostat setting' ]. xattr [name: today, abbrev: today, class: simple, type: week_or_end, comm: inter, desc: 'Part of the week' ]. %%%%%%%%%%%%%%%%%%%%%%%% TABLE SCHEMAS DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%% xschm ms: [month] ==> [season]. xschm 'Table2': [day] ==> [today]. xschm 'Table3': [today,hour] ==> [operation]. xschm 'Table4': [season,operation] ==> [thermostat_settings]. %%%%%%%%%%%%%%%%%%%%%%%%%%%% RULES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%% xrule ms/1: [month in ['January','February','December']] ==> [season set 'Summer'] :'Table4'. xrule ms/2: [month in ['March','April','May']] ==> [season set 'Autumn']. xrule ms/3: [month in ['June','July','August']] ==> [season set 'Winter']. xrule ms/4: [month in ['September','October','November']] ==> [season set 'Spring']. xrule 'Table2'/1: [day in ['Tuesday' to 'Friday']] ==> [today set workday] :'Table3'. xrule 'Table2'/2: [day in ['Saturday','Sunday']] ==> [today set weekend]. xrule 'Table3'/1: [today eq workday, hour in [9 to 17]] ==> [operation set during_business_hours] :'Table4'. xrule 'Table3'/2: [today eq workday, hour lt 9] ==> [operation set not_during_business_hours]. xrule 'Table3'/3: [today eq workday, hour gt 17] ==> [operation set not_during_business_hours]. xrule 'Table3'/4: [today eq weekend, hour eq any] ==> [operation set not_during_business_hours]. xrule 'Table4'/1: [season eq 'Spring', operation eq during_business_hours] ==> [thermostat_settings set 20]. xrule 'Table4'/2: [season eq 'Spring', operation eq not_during_business_hours] ==> [thermostat_settings set 15]. xrule 'Table4'/3: [season eq 'Summer', operation eq during_business_hours] ==> [thermostat_settings set 24]. xrule 'Table4'/4: [season eq 'Summer', operation eq not_during_business_hours] ==> [thermostat_settings set 27]. xrule 'Table4'/5: [season eq 'Autumn', operation eq during_business_hours] ==> [thermostat_settings set 20]. xrule 'Table4'/6: [season eq 'Autumn', operation eq not_during_business_hours] ==> [thermostat_settings set 16]. xrule 'Table4'/7: [season eq 'Winter', operation eq during_business_hours] ==> [thermostat_settings set 18]. xrule 'Table4'/8: [season eq 'Winter', operation eq not_during_business_hours] ==> [thermostat_settings set 14]. %%%%%%%%%%%%%%%%%%%%%%%%% CALLBACKS %%%%%%%%%%%%%%%%%%%%%%%%%% xcall ask_symbolic_GUI : [AttName] >>> (jpl_new('skeleton.RequestInterface',[],T), alsv_domain(AttName,Domain,symbolic), Params = [AttName|Domain], term_to_atom(Params, AtomParams), jpl_call(T,request,['callbacks.input.ComboBoxFetcher',AtomParams],Answer), atom_to_term(Answer,Answer2,_), alsv_new_val(AttName,Answer2)). xcall ask_numeric_GUI : [AttName] >>> (jpl_new('skeleton.RequestInterface',[],T), alsv_domain(AttName,[Min to Max],numeric), concat_atom(['[',AttName,',',Min,',',Max,']'],Parameters), jpl_call(T,request,['callbacks.input.SliderFetcher',Parameters],Answer), atom_to_term(Answer,Answer2,_), alsv_new_val(AttName,Answer2)). xcall tell_console : [AttName] >>> (write('Attribute '), write(AttName),write(' output value is '), xstat(current:[AttName,V]), write(V),nl). %%%%%%%%%%%%%%%%%%%%%%%%% STATES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % File generated by HeKatE Qt Editor ver. M6_9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%