0001 function [o,errf,msg] = phiw_arm_call(action, o, item, old_o)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 if nargin < 1
0019 error('Need action');
0020 end
0021 if nargin < 2
0022 error('Need object');
0023 end
0024 if nargin < 3
0025 error('Need item name');
0026 end
0027 if nargin < 4
0028 error('Need old object');
0029 end
0030
0031 errf = 0; msg = '';
0032
0033 item_struct = get_item_struct(o, item);
0034
0035 switch lower(action)
0036 case 'set_design'
0037
0038
0039
0040 [btn o] = save_item_data_ui(old_o, 'def_design', ...
0041 struct('ync', 1, ...
0042 'prompt_prefix','previous '));
0043 if btn == -1
0044 errf = 1;
0045 msg = 'Cancelled save of previous design';
0046 return
0047 end
0048
0049
0050 [item_struct.data errf msg] = sf_check_design(item_struct.data);
0051 if errf, o = []; return, end
0052 o = set_item_struct(o, item, item_struct);
0053
0054 case 'set_results'
0055
0056
0057
0058
0059
0060 data = item_struct.data;
0061 if isempty(data), return, end
0062
0063
0064 [btn o] = save_item_data_ui(old_o, 'est_design', ...
0065 struct('ync', 1, ...
0066 'prompt_prefix','previous '));
0067 if btn == -1
0068 errf = 1;
0069 msg = 'Cancelled save of current design';
0070 return
0071 end
0072
0073
0074 [data errf msg] = sf_check_design(data);
0075 if errf, return, end
0076 if ~is_phiw_estimated(data)
0077 error('Design has not been estimated')
0078 end
0079
0080
0081 item_struct.data = data;
0082 o = set_item_struct(o, item, item_struct);
0083
0084 otherwise
0085 error(['Peverse request for ' action]);
0086 end
0087
0088 function [d,errf,msg] = sf_check_design(d)
0089
0090 errf = 0; msg = {};
0091 d = phido(d);
0092 if ~is_valid(d)
0093 errf = 1;
0094 msg = 'This does not appear to be a valid design';
0095 end
0096 return
0097