% File: ECMI01.FF_LOAD % Author: Peter Hammond, IC, 1982. Rewritten by Peter Ross % Updated: 30 Nov 1983 % Purpose: code for loading a fault database for FAULTFINDER % This is a simple loading loop for FAULTFINDER fault description files % Top level for loading is ffload/1. % The arg can be a file name or a list of them. Items from the file are % recorded in the internal database, under the terse form of fault name % as the key. There is a check that, for each fault, only one instance % of each property appears. ffload([File|Files]) :- !, ffload(File), ffload(Files). ffload([]). ffload(File) :- seeing(Old), see(File), repeat, read(Term), \+ ffprocess(Term), !, seen, see(Old). ffprocess(end_of_file) :- !, fail. ffprocess(top_fault = Fault) :- !, abolish(top_fault, 1), assertz(top_fault(Fault)). ffprocess(Name: Properties) :- ffproperties(Name, Properties). ffproperties(Name, Prop & OtherProps) :- !, ffproperty(Name, Prop), ffproperties(Name, OtherProps). ffproperties(Name, Prop) :- ffproperty(Name, Prop). ffproperty(Name, PropName = PropVal) :- Term =.. [PropName, PropVal], GenProp =.. [PropName,_], % n.b. the properties have arity 1 erase_old(Name, GenProp), recordz(Name, Term, _). ffproperty(Name, confirmed if Answer) :- erase_old(Name, confirm(_)), recordz(Name, confirm(Answer), _).