_package sw $ user:fcsi_method_manip.fcsi_copy_method(condition,:|raise()|) $ _block _if !current_package![:!ts!] _is _unset _then # this will define !ts! if necessary _global !ts! _endif _endblock $ _global !ts1! << _unset _global !ts2! << _unset _global !ts3! << _unset _global !ts4! << _unset $ condition.define_shared_variable( :fcsi_debug?, _false, :public) $ condition.define_shared_variable( :int!fcsi_trace_level, _unset, :private) $ _pragma(classify_level=debug, topic={fcsi,conditions}) condition.define_shared_variable( :fcsi_max_reports, ## Limits the number of times the the trace is shown 100, :public) $ _pragma(classify_level=debug, topic={fcsi,conditions}) condition.define_shared_variable( :fcsi_report_count, ## internally used to restrict the number of tracebacks that ## are shown. needs to be hand reset over time. 0, :public) $ _pragma(classify_level=debug, topic={fcsi,conditions}) condition.define_shared_variable( :fcsi_report_name, ## _unset, :public) $ #_pragma(classify_level=debug, topic={fcsi,conditions}) #_method condition.raise(name _gather keys_and_values) # ## Parameters : # ## Returns : # ## Function : # ## Methodology : # ## Create and trigger a condition with given name and values. # ## Example set condition.fcsi_report_name << # ## :coordinate_out_of_range will TB when this occurs when # ## condition.fcsi_trace_level > 0 # #---------------- HISTORY --------------------- # # (11/03/2008 - Mark Field, FCSI): Created. # #---------------------------------------------- # _if _self.fcsi_report_name _isnt _unset _andif # _self.fcsi_report_name _isnt name # _then # _return _self.sw!raise(name,_scatter keys_and_values) # _endif # #DEBUG show(:fcsi_debug?,_self.fcsi_debug?,:fcsi_report_name,_self.fcsi_report_name, # #DEBUG :fcsi_trace_level,_self.fcsi_trace_level) # _if _self.fcsi_debug? _is _true # _then # show(:condition_raised,name) # #DEBUG print(keys_and_values) # _if name _is :coordinate_out_of_range # _then # !traceback!(!terminal!) # _endif # _endif # _if _self.fcsi_trace_level _isnt _unset # _then # !traceback!(!terminal!,_self.fcsi_trace_level) # _endif # _return _self.sw!raise(name,_scatter keys_and_values) #_endmethod #$ #_pragma(classify_level=debug, topic={fcsi,conditions}) #_method condition.fcsi!simple_raise(name, _gather keys_and_values) # ## Parameters : # ## Returns : # ## Function : # ## Methodology : # #---------------- HISTORY --------------------- # # (2015/08/18 - Mark Field (FCSI)): Created. # #---------------------------------------------- # # #_endmethod $ _pragma(classify_level=debug, topic={fcsi,conditions}) _method condition.fcsi!raise(name, _gather keys_and_values) ## Parameters : ## Returns : ## Function : ## Methodology : ## Create and trigger a condition with given name and values. ## Example set condition.fcsi_report_name << ## :coordinate_out_of_range will TB when this occurs when ## condition.fcsi_trace_level > 0 ## Copies tracebacks to !ts1!,!ts2!,!ts3! #---------------- HISTORY --------------------- # (11/03/2008 - Mark Field, FCSI): Created. # (13/05/30 - Mark Field (FCSI)): Modified - changed logic to # use reporting and debug? in conjunction # (2014/11/07 - Mark Field (FCSI)): Modified - added !ts1...3! # (2018/03/13 - Mark Field (FCSI)): Modified - attempt to # capture something in !ts! for smallworld 5 #---------------------------------------------- #DEBUG show(:condition,:raise|()|,name,_scatter keys_and_values) #DEBUG show(:fcsi_report_name,_self.fcsi_report_name, #DEBUG :fcsi_debug?,_self.fcsi_debug?, #DEBUG :fcsi_trace_level,_self.fcsi_trace_level, #DEBUG :fcsi_max_reports,_self.fcsi_max_reports, #DEBUG :fcsi_report_count,_self.fcsi_report_count) # no need fo rthis as reporter does it # _if name _is :defining_global _andif # fcsi_method_information _isnt _unset # _then # fcsi_method_information.fcsi_record_global_definition( # keys_and_values[2].write_string) # _endif _if _self.fcsi_report_name _isnt _unset _andif _self.fcsi_report_name _isnt name _then _return _self.sw!raise(name,_scatter keys_and_values) _endif _global !ts!,!ts1!,!ts2!,!ts3!,!ts4! _if smallworld_product.release_version > 4 _then show(:condition_raised,name,_scatter keys_and_values) !ts! << property_list.new_with(_scatter keys_and_values) !ts![:fcsi_name] << name _endif _if _self.fcsi_debug? _is _true _then show(:condition_raised,name) #DEBUG print(keys_and_values) _if name _is _self.fcsi_report_name _then _if (_self.fcsi_report_count +<< 1) < _self.fcsi_max_reports _then !traceback!(!terminal!) _endif _endif _endif _local ts << get_global_value(:!ts!) _if _self.int!fcsi_trace_level _isnt _unset _andif _not _self.fcsi_useless_condition?(name,keys_and_values) _andif (_self.fcsi_report_count +<< 1) < _self.fcsi_max_reports _then _if ts _isnt _unset _then !ts4! ^<< !ts3! ^<< !ts2! ^<< !ts1! ^<< ts _endif !traceback!(!terminal!,_self.int!fcsi_trace_level) _endif _return _self.sw!raise(name,_scatter keys_and_values) _endmethod $ _pragma(classify_level=debug, topic={fcsi,conditions}) condition.define_shared_constant( :fcsi_useless_conditions, ## keyed on the condition name if element is {} then all ## condition named the key will be ignored. Otherwise the ## elements are simple vectors of simple vectors define the ## keys/values to test to where if they match theare are ignored. property_list.new_with( :binary_operator_undefined,{{2,:line_style}}, :does_not_understand,{{4,:|fcsi_label()|}}, :sys!thread_kill,{} ), _false) $ _pragma(classify_level=debug, topic={fcsi,conditions}) _method condition.fcsi_useless_condition?(name,keys_and_values) ## Parameters : name - name of condition (passed into raise()) ## keys_and_values - the arguments passed into raise() ## Returns : boolean ## Function : returns false if :binary_operator_undefined ## for a :line_style. Which is spewed during application start up ## Methodology : #---------------- HISTORY --------------------- # (2013/08/30 - Mark Field (FCSI)): Created. #---------------------------------------------- _local tests << _self.fcsi_useless_conditions[name] _if tests _is _unset _then _return _false _elif tests.empty? _then _return _true _endif _for test _over tests.fast_elements() _loop _if keys_and_values.size >= test[1] _andif keys_and_values[test[1]] = test[2] _then _return _true _endif _endloop _return _false _endmethod $ _pragma(classify_level=debug, topic={fcsi,conditions}) _method condition.fcsi_trace_level << val ## Parameters : val - unset or number for length of tb ## Returns : nothing ## Function : updates the trace_level and aligns methods ## aproproately ## Methodology : #---------------- HISTORY --------------------- # (2015/08/18 - Mark Field (FCSI)): Created. #---------------------------------------------- _self.int!fcsi_trace_level << val _if val _is _unset _then condition.define_method( :raise|()|,condition.method( :sw!raise|()|).value,_false) _else condition.define_method( :raise|()|,condition.method( :fcsi!raise|()|).value,_false) _endif _endmethod $ _pragma(classify_level=debug, topic={fcsi,conditions}) _method condition.fcsi_global_definition_reporter ## Parameters : none ## Returns : proc ## Function : returns a proc that will trigger a ## fcsi_method_information.fcsi_record_global_definition() as ## well as call standard reporter ## Methodology : #---------------- HISTORY --------------------- # (2016/12/14 - Mark Field (FCSI)): Created. #---------------------------------------------- _return _proc @fcsi_global_definition_reporter(stream,data,cond) _try user:fcsi_method_information.fcsi_record_global_definition( cond[:name]) _when error #ok... _endtry cond.std_report_helper(stream,data) _endproc _endmethod $ _pragma(classify_level=debug, topic={fcsi,conditions}) _method condition.fcsi_trace_level ## Parameters : ## Returns : int!fcsi_trace_level value ## Function : ## Methodology : #---------------- HISTORY --------------------- # (2018/02/26 - Mark Field (FCSI)): Created. #---------------------------------------------- _return _self.int!fcsi_trace_level _endmethod $ condition.change_reporter(:defining_global, condition.fcsi_global_definition_reporter) $