Verfasst am: 24.03.2010, 02:44
Titel: Funktionen vereinfachen, was mache ich falsch? Simple Frage.
Hallo Leute,
ich habe zwei M-Files aus dem DAQmx Package, aus Zeitrelevanten Gründen will ich nun ein wenig optimieren.
Ich rufe start(AI) auf.
start sieht wiefolgt aus:
Code:
function start(obj, event)
%START Start data acquisition object running.
%
% START(OBJ) starts the hardware associated with object, OBJ, executes % OBJ's StartFcn callback, then configures OBJ's Running % property to 'On'. OBJ can be either a single device object or an % array of device objects.
%
% If START is called and no channels or lines are defined for the % device object, OBJ, an error is returned.
%
% Although the device object is executing, data is not necessarily % logged for analog input objects or sent for analog output objects. % Data logging or sending is controlled with the TriggerType property. % If OBJ's TriggerType property is set to:
%
% 'Immediate' - data logging or sending occurs immediately. % 'Manual' - data logging or sending occurs upon calling TRIGGER.
%
% otherwise, data logging or sending occurs when OBJ's TriggerCondition % is met. % % OBJ will stop running only under one of the following conditions: % 1. A STOP command is issued. % 2. When the requested samples are acquired (analog input) or sent % out (analog output). For analog input, this occurs when OBJ's % SamplesAcquired equals the product of OBJ's SamplesPerTrigger % and TriggerRepeat properties. % 3. A runtime error occurs. % 4. OBJ's Timeout value is reached.
%
% The Start event is recorded in OBJ's EventLog property. % % START may be called by a data acquisition object's event callback, % e.g., obj.StopFcn = {'start'}; % % See also DAQHELP, DAQDEVICE/STOP, TRIGGER, PROPINFO, DAQDEVICE/WAIT.
%
% DTL 10-1-2004 % Copyright 1998-2004 The MathWorks, Inc. % $Revision: 1.12.2.6 $ $Date: 2004/12/18 07:34:52 $
ifnargout > 0 error('daq:start:argcheck', 'Too many output arguments.') end
% If two inputs are given, verify that the second input is the event % structure otherwise error. ifnargin == 2 if ~(isfield(event, 'Type') && isfield(event, 'Data')) error('daq:start:argcheck', 'Too many input arguments.');
end end
% Determine if an invalid handle was passed. if ~all(isvalid(obj)) error('daq:start:invalidobject', 'Data acquisition object OBJ is an invalid object.');
end
% Start the object. try
start( daqgetfield(obj,'uddobject'));
catch
rethrow(lasterror);
end
function out = daqgetfield(obj, field)
%DAQGETFIELD Set and get data acquisition internal fields.
%
% VAL = DAQGETFIELD(OBJ, FIELD) returns the value of object's, OBJ, % FIELD to VAL.
%
% This function is a helper function for the concatenation and % manipulation of device object arrays.
%
% MP 12-22-98 % Copyright 1998-2004 The MathWorks, Inc. % $Revision: 1.1.6.2 $ $Date: 2005/06/27 22:32:17 $
% Return the specified field information. switch field
case 'uddobject'
out = obj.uddobject case 'version'
out = obj.version;
case 'daqchild'
out = obj.daqchild;
otherwise error('daq:daqgetfield:invalidfield', 'Invalid field: %s', field);
end
Also ich verstehe es so, dass Bestandteil der Frage ist Standardbefehle der Data Acquisition Toolbox zu verändern. Ich sehe auch, dass der Code schon einige Jahre alt ist. Wäre es nicht zunächst einen Versuch wert zu prüfen ob aktuelle MathWorks Releases diesbezüglich besser sind? Eine Veränderung von Produktcode ist immer etwas risikoreich.
auch verwirrt mich die Bezeichnung "DAQmx Package". Ist damit etwas anderes gemeint als die Data Acquisition Toolbox?
ich kann gerade den Sinn der Funktion daqgetfield nicht so erkennen...kann man das nicht viel einfacher mit dynamic fields lösen und den ganzen Ärger umgehen?
Einstellungen und Berechtigungen
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.