%%%% Knowledge base for zone operation input control
%% Last change: 20/06/91

%%%% Initialization predicate -------------------------------------
usage(initialize):-
	(
	 curr_zone(_Zone_number);
	 u_current_zone(1)
	),
	(
	 day_type(_Day_type);
	 asserta(day_type(weekday))
	),
	feedback(usage_sel).


%%%% Control predicates -------------------------------------------
b_u_airflow(on):-
	asserta(active_concept(u_airflow)),
	tell_usr(b_u_cgain,off),
	focus_concept(usage, u_airflow),
	u_airflow(initialize).

b_u_airflow(off):-
	retract(active_concept(u_airflow)),
	defocus_concept(usage),
	tell_usr(b_u_airflow,off).

b_u_cgain(on):-
	asserta(active_concept(u_cgain)),
	tell_usr(b_u_airflow,off),
	focus_concept(usage, u_cgain),
        !,
	u_cgain(initialize).

b_u_cgain(off):-
	retract(active_concept(u_cgain)),
	defocus_concept(usage),
	tell_usr(b_u_cgain,off).

b_u_dump(on):-
	curr_zone(_Zone_number),!,
	known(operation_file, _Zone_number, _File),
	tell_usr(b_u_dump,off);
	feedback(unknown_file_name),
	tell_usr(b_u_dump,off).

b_u_load(on):-
	curr_zone(_Zone_number),!,
	known(operation_file, _Zone_number, _File),
	to_bb(new_client, read_operation_file, read_operation_file, _File, _Zone_number),
	tell_usr(b_u_load,off);
	feedback(unknown_file_name),
	tell_usr(b_u_dump,off).

oper_file_name(_File):-
	curr_zone(_Zone_number),
	uset(operation_file,_Zone_number,_File).


%%%% Control button for focussing on another zone -----------------
u_current_zone(_Zone_number):-	%% for an existing zone
	zone_num(_Zone_number),
	asserta(status(old)),
	asserta(curr_zone(_Zone_number)),
	uset(curr_zone,_Zone_number),
	( active_concept(_Concept),!,
	  _Refresh =.. [_Concept,refresh],
	  _Refresh
	;
	  true
	).

u_current_zone(_Zone_number):-	%% for a new zone
	asserta(status(new)),
	assert(zone_num(_Zone_number)),
	asserta(curr_zone(_Zone_number)),
	uset(curr_zone,_Zone_number),
	uset(zone_num,_Zone_number),
	( active_concept(_Concept),!,
	  _Refresh =.. [_Concept,refresh],
	  _Refresh
	;
	  true
	).


%%%% Feedback -----------------------------------------------------
feedback(usage_sel, novice) :-
	chat_usr([
		'This button switches the focus of discussion to',
		'the occupancy patterns of the building.  Several',
		'subsidary forms will enable standard pofiles to',
		'be retrieved and edited.',
		'']).

feedback(unknown_file_name, _):-
	chat_usr([
		'Sorry, you must specify the input/output file name',
		'before dumping/loading the blackboard content!',
		'']).
