www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgcaloutput/private/pCgcaloutputSetCalibration.m
function pCgcaloutputSetCalibration(cal, ptrlist, axisAware, pm) %PCGCALOUTPUTGETCALIBRATION Private helper function. % PCGCALOUTPUTGETCALIBRATION(CAL,PTRLIST,AXISAWARE,PM) is the workhorse % for getting cgcaloutput information PTRLIST into a calibration interface % CAL. AXISAWARE is a flag that is true for interfaces that treat axes as % items in their own right, and false for interfaces that treat axes as % properties of their parents. PM is a progress manager, used to display % the progress of the import operation. % Copyright 2000-2011 The MathWorks, Inc. % Input arguments narginchk(2,4); if nargin < 3, axisAware = true; end if nargin < 4, pm = calibrationdata.progressmanager; end pm.reset; pm.notify('Processing items'); for i = 1:length(ptrlist), thisPtr = ptrlist(i).info; if isa(thisPtr, 'cgconstant') % value % Get CAGE value properties thisValueIdentifier = getname(thisPtr); thisValueDescription = char(getdescription(thisPtr)); thisValueValue = getvalue(thisPtr); % Get external properties [thisValue, thisValueExists] = iSafeGetValue(cal, thisValueIdentifier); % Merge value properties and export thisValue.Identifier = thisValueIdentifier; thisValue.Description = thisValueDescription; thisValue.Value = thisValueValue; iSafeSetValue(cal, thisValue); elseif isa(thisPtr, 'cgnormaliser') % axis % Get CAGE axis properties thisAxisIdentifier = getname(thisPtr); thisAxisDescription = char(get(thisPtr, 'description')); thisAxisValue = get(thisPtr, 'BreakPoints'); thisAxisIndex = get(thisPtr, 'Values') + 1; % CAGE is 0-based, axis is 1-based % Get external axis properties [thisAxis, thisAxisExists] = iSafeGetAxis(cal, thisAxisIdentifier); % Merge axis properties and export thisAxis.Identifier = thisAxisIdentifier; thisAxis.Description = thisAxisDescription; thisAxis.Value = thisAxisValue; thisAxis.Index = thisAxisIndex; iSafeSetAxis(cal, thisAxis); elseif isa(thisPtr, 'cgnormfunction') % curve % Get CAGE curve properties thisCurveIdentifier = getname(thisPtr); thisCurveDescription = char(get(thisPtr, 'description')); thisCurveValue = get(thisPtr, 'values'); % Get external curve properties [thisCurve, thisCurveExists] = iSafeGetCurve(cal, thisCurveIdentifier); % Get CAGE axis properties thisXAxisIdentifier = get(thisPtr, 'xName'); thisXAxisValue = get(thisPtr, 'axes'); % Get external axis properties if axisAware && ~isa(thisPtr, 'cglookupone') % Use axis identifiers from CAGE else % Use axis identifiers from external thisXAxisIdentifier = thisCurve.XAxisIdentifier; end [thisXAxis, thisXAxisExists] = iSafeGetAxis(cal, thisXAxisIdentifier); % Merge axis properties and export if axisAware && ~isa(thisPtr, 'cglookupone') % Setting the curve axis identifier is sufficient; the axis % properties will be set via the case 'cgnormaliser' else if ~thisXAxis.ReadOnly thisXAxis.Identifier = thisXAxisIdentifier; thisXAxis.Value = thisXAxisValue; iSafeSetAxis(cal, thisXAxis); end end % Merge curve properties and export if ~thisCurve.ReadOnly thisCurve.Identifier = thisCurveIdentifier; thisCurve.Description = thisCurveDescription; thisCurve.Value = thisCurveValue; thisCurve.XAxisIdentifier = thisXAxisIdentifier; iSafeSetCurve(cal, thisCurve); end elseif isa(thisPtr, 'cglookuptwo') % map % Get CAGE map properties thisMapIdentifier = getname(thisPtr); thisMapDescription = char(get(thisPtr, 'description')); thisMapValue = get(thisPtr, 'values'); % Get external map properties [thisMap, thisMapExists] = iSafeGetMap(cal, thisMapIdentifier); % Get CAGE axis properties thisXAxisIdentifier = get(thisPtr, 'xName'); thisYAxisIdentifier = get(thisPtr, 'yName'); thisAxesValue = get(thisPtr, 'axes'); thisXAxisValue = thisAxesValue{1}; thisYAxisValue = thisAxesValue{2}; % Get external axis properties if axisAware % Use axis identifiers from CAGE else % Use axis identifiers from external thisXAxisIdentifier = thisMap.XAxisIdentifier; thisYAxisIdentifier = thisMap.YAxisIdentifier; end [thisXAxis, thisXAxisExists] = iSafeGetAxis(cal, thisXAxisIdentifier); [thisYAxis, thisYAxisExists] = iSafeGetAxis(cal, thisYAxisIdentifier); % Merge axis properties and export if axisAware % Setting the map axis identifier is sufficient; the axis % properties will be set via the case 'cgnormaliser' else if ~thisXAxis.ReadOnly thisXAxis.Identifier = thisXAxisIdentifier; thisXAxis.Value = thisXAxisValue; iSafeSetAxis(cal, thisXAxis); end if ~thisYAxis.ReadOnly thisYAxis.Identifier = thisYAxisIdentifier; thisYAxis.Value = thisYAxisValue; iSafeSetAxis(cal, thisYAxis); end end % Merge map properties and export if ~thisMap.ReadOnly thisMap.Identifier = thisMapIdentifier; thisMap.Description = thisMapDescription; thisMap.Value = thisMapValue; thisMap.XAxisIdentifier = thisXAxisIdentifier; thisMap.YAxisIdentifier = thisYAxisIdentifier; iSafeSetMap(cal, thisMap); end else % Ignore end pm.update(i/length(ptrlist)); end pm.update(1); pm.notify('Cleaning up'); % ------------------------------------------------------------------------- function [item, exists] = iSafeGetValue(cal, identifier) %ISAFEGETVALUE Get of create value. try item = cal.getValue(identifier); exists = true; catch ME item = calibrationdata.value; item.Identifier = identifier; cal.addValue(item); item = cal.getValue(identifier); exists = false; end % ------------------------------------------------------------------------- function [item, exists] = iSafeGetAxis(cal, identifier) %ISAFEGETAXIS Get or create axis. try item = cal.getAxis(identifier); exists = true; catch ME item = calibrationdata.axis; item.Identifier = identifier; cal.addAxis(item); item = cal.getAxis(identifier); exists = false; end % ------------------------------------------------------------------------- function [item, exists] = iSafeGetCurve(cal, identifier) %ISAFEGETCURVE Get or create curve. try item = cal.getCurve(identifier); exists = true; catch ME item = calibrationdata.curve; item.Identifier = identifier; cal.addCurve(item); item = cal.getCurve(identifier); exists = false; end % ------------------------------------------------------------------------- function [item, exists] = iSafeGetMap(cal, identifier) %ISAFEGETMAP Get or create map. try item = cal.getMap(identifier); exists = true; catch ME item = calibrationdata.map; item.Identifier = identifier; cal.addMap(item); item = cal.getMap(identifier); exists = false; end % ------------------------------------------------------------------------- function iSafeSetValue(cal, item) %ISAFESETVALUE Set or add value. try cal.setValue(item); catch ME fprintf(iLog, 'Warning: Could not export value ''%s''.\n%s\n', item.Identifier, ME.message); end % ------------------------------------------------------------------------- function iSafeSetAxis(cal, item) %ISAFESETAXIS Set or add axis. try cal.setAxis(item); catch ME fprintf(iLog, 'Warning: Could not export axis ''%s''.\n%s\n', item.Identifier, ME.message); end % ------------------------------------------------------------------------- function iSafeSetCurve(cal, item) %ISAFESETCURVE Set or add curve. try cal.setCurve(item); catch ME fprintf(iLog, 'Warning: Could not export curve ''%s''.\n%s\n', item.Identifier, ME.message); end % ------------------------------------------------------------------------- function iSafeSetMap(cal, item) %ISAFESETMAP Set or add map. try cal.setMap(item); catch ME fprintf(iLog, 'Warning: Could not export map ''%s''.\n%s\n', item.Identifier, ME.message); end % ------------------------------------------------------------------------- function out = iLog %ILOG File handle for messages: 0 for null, 1 for stdout, 2 for strerr. out = 2; % stderr