Yes, this is possible and has been performed by a few customers. You can use the 'iadsread' mex function to read data in realtime directly into a running Matlab script, perform any calculation, then use the 'iadswrite' mex function to send parameter data to the server. To start, I would suggest reading the tutorial in C:\Program Files\IADS\MatlabExtension\HowTo.m. After you become familiar with the iadsread function in post test, you can attempt to connect to a live server. See the tutorial for a simple example. When you are comfortable with that, you can use the HowToIadswrite.m file as a starting example. I don't see this example in the install, so I'll just post it here. The script at the bottom of the page. Look for "% For a working example, start here..."
See below. Let me know if you have any questions,
% This M-File documents the installation and usage of the IADS 'Mex' data interface
% for Matlab. The library or 'Mex' file that contains the code to interface to
% your existing IADS server is contained within the 'iadswrite.mexw32' for the 32 bit version
% of Matlab and the 'iadswrite.mexw64' file for the 64 bit version of Matlab.
%
% Proper installation of these files will add a function
% to Matlab called 'iadswrite', allowing you to programmatically produce data in realtime
% to an Iads server. In conjunction with the Mex function iadsread, you will then be able
% to write Matlab programs to read, compute, and write derived parameters for complex custom
% operations. In a future version of this interface, you will be able to write Iads data files in
% an offline manner, without the use of the server. That capability is still in development.
%
% If you have already installed Iads on this machine, both the 32 and 64 bit versions of iadswrite
% ('iadswrite.mexw32' and 'iadswrite.mexw64' respectively should be present in your
% C:\Program Files\IADS\MatlabExtension directory. If this is not true, you will have to copy the files
% to this directory.
%
% If Iads is not already installed, simply create a folder on your PC (i.e. C:\Program Files\Iads\MatlabExtension)
% and copy both the 'iadswrite.mexW32' and 'iadswrite.mexw64' files to this directory;
%
% Once the files are copied you will need to add this directory
% to your Matlab path. To do this, run Matlab. Under the Matlab 'File' dropdown
% choose the option 'Set Path'. A new window will appear titled 'Set Path'.
% Click on the button 'Add Folder'. When the folder browser dialog appears,
% choose the 'MatlabExtension' directory that you created in the first step.
% (i.e. C:\Program Files\Iads\MatlabExtension). Click the 'Save' button to save the
% path, and then 'Close' to close the 'Add Path' window.
% Ok! To test that the 'iadswrite' function is ready to go just type:
iadswrite
% The response is: Error using iadswrite iadswrite: A previoius call to iadsread is required before
% calling iadswrite. Please correct.
% This is correct actually. To use the iadswrite function, you must first call iadsread to get data.
% After the data in acquired from the server, you can use it to calculate the values of output parameter(s).
%
%
% If Matlab returns with "??? Undefined function or variable 'iadswrite'."
% your path is not set correctly. Make sure your path is set and saved to the directory where you copied iadswrite.mexw32/iadswrite.mexw64 files.
%
% Let's look at each argument in turn.
% Argument 1) ServerName$PortId
% This string defines the Iads data server for your Flight.
% This string is used to specify a server name and port id in the format 'ServerName$PortId' to connect iadswrite directly
% to a real-time data stream. There is example code on this subject below.
%
% Argument 2) IrigStartTime
% This string defines the Irig time value of the data to be written in the format DDD:HH:MM:
SS.MS.
% In this version of iadswrite, you must set this argument to empty string ''.
% The value of time for data update is automatically taken from the previous iadsread call to maintain
% accurate time alignment between inputs and outputs.
% Argument 3) ParameterNameList
% This string argument is a list of comma seperated parameter names that you want to
% to write data to. For example, you could import ome aircraft "Wing" parameters by
% defining a list like: 'AW0001X,AW0002X,AW0003X". Notice the name is the "Parameter"
% name defined in the config file's "ParameterDefaults Table" (usually the parameter code)
%
% Note: All filtering and nulling that was set in the ParameterDefaults entry for the
% specified parameter is applied before the data is returned to Matlab. Spike detection and wild
% point corrections are *not* applied as of this date. We may consider having this as an option.
%
% One more option is being considered for next build:
% * The DataGroupName option will allow you to access a group of parameters defined in
% your config file under the DataGroup table.
% Argument 4) MatrixOfDataToBeWritten
% This columnwise data matrix contains the data to be written to the Iads server for each parameters defined
% in argument 3 above. Each column of the matrix corresponds to, in order, the values per parameter being updated.
% For example, if argument 3 had the value of 'A,B,C', the expected matrix should contain 3 columns, with column 1
% being the value for parameter A, column 2 the values of B, and column 3, the values of C. A single parameter
% update would be of type vector. The length of the matrix or vector would be defined by the length of the matrix or
% vector obtained by the iadsread call. In other words, there should be a 1 to 1 correlation from the input data to the
% output data. In essence, each input parameter value should produce an output parameter value.
% Now, let's connect to a running Iads server on a computer named 'IADS-CDS' and get one second of data from the most current
% time for three parameters A, B, and C
abc = iadsread( 'IADS-CDS$58000', '', 1, 'A,B,C' );
% At this point, we can send the data to a Matlab function and have it return the results to be written. For simplicity
% sake, I'll just multiply the input data by 10
abc = abc * 10;
% Now, let's take that result and send it to the Iads server under the parameter names of AMatlab, BMatlab, and CMatlab'
% Before we do this, we need to make sure the server has definitions of the parameters we are about to output.
% You will need to add a parameter in the ParameterDefaults table for each listed in argument 3 below. The parameter
% should be of DataSourceType 'Iap', the ParamType "float", and the equation should call a function named External(). We can accomplish this by
% sending an update query through the iadsread function to the server. In the query below, we'll add 3 new parameters named AMatlab,
% BMatlab, and CMatlab. For the specifics on using an update query through the iadsread function, please contact customer support.
% The statement below is relatively self explanitory and can be modified to incorporate variables for the parameter name.
iadsread( 'IADS-CDS$58000', '', 0, '? update ParameterDefaults set Parameter = ''AMatlab'', ParamType = ''float'', DataSourceType = ''Iap'', DataSourceArguement = ''External()'' where Parameter = ''AMatlab''' );
iadsread( 'IADS-CDS$58000', '', 0, '? update ParameterDefaults set Parameter = ''BMatlab'', ParamType = ''float'', DataSourceType = ''Iap'', DataSourceArguement = ''External()'' where Parameter = ''BMatlab''' );
iadsread( 'IADS-CDS$58000', '', 0, '? update ParameterDefaults set Parameter = ''CMatlab'', ParamType = ''float'', DataSourceType = ''Iap'', DataSourceArguement = ''External()'' where Parameter = ''CMatlab''' );
% Now, very important, we need to 'commit' the update queries to the server. This will send them to the server so they will be
% available on all the other PCs in the room
iadsread( 'IADS-CDS$58000', '', 0, '? commit ParameterDefaults 1' );
% Please ensure that trailing 1 is present in the commit statement. This designates that the commit statment is sent to the server immediately.
% If the call doesn't exception, then we're on to the next parameter
% Likewise, you can use a client to add these parameters to the ParameterDefault table. At this time, the function External() will
% return an error in the Iads client. Ignore this error and save the ParameterDefaults table. Once the parameters are visible
% in the ParameterDefaults table, we can continue.
%
% Finally, let's write some data to the parameters
iadswrite( 'IADS-CDS$58000', '', 'AMatlab,BMatlab,CMatlab', abc )
% That's all there is to it. Now we need to put these concepts all together in an example script
% For a working example, start here...
% The following code will explain things in more detail
% Here's an example script to read data from the Iads server
% in real-time using iadsread, calculate a derived result, and write the
% results back to the server as new parameters using iadswrite.
% With this example, in theory, you could run Matlab in realtime to
% produce derived parameter results.
% First, let's add the parameters to the server that we are about to update and commit.
iadsread( 'IADS-CDS$58000', '', 0, '? update ParameterDefaults set Parameter = ''AMatlab'', ParamType = ''float'', DataSourceType = ''Iap'', DataSourceArguement = ''External()'' where Parameter = ''AMatlab''' );
iadsread( 'IADS-CDS$58000', '', 0, '? update ParameterDefaults set Parameter = ''BMatlab'', ParamType = ''float'', DataSourceType = ''Iap'', DataSourceArguement = ''External()'' where Parameter = ''BMatlab''' );
iadsread( 'IADS-CDS$58000', '', 0, '? update ParameterDefaults set Parameter = ''CMatlab'', ParamType = ''float'', DataSourceType = ''Iap'', DataSourceArguement = ''External()'' where Parameter = ''CMatlab''' );
iadsread( 'IADS-CDS$58000', '', 0, '? commit ParameterDefaults 1' );
% Now let's run in an infinite loop reading data from the Iads server, calculating results, and writing back to the Iads server.
% While this code is running, you should be able to bring up an Iads client display and view the output parameters. For debugging
% purposes, we recommend you watch the parameters in Stripcharts. Compare the input values with the results and see if they are reasonable
while ( 1 )
% Request one second of data from parameters A, B, and C from Iads server IADS-CDS on port 58000
abc = iadsread( 'IADS-CDS$58000', '', 1, 'A,B,C' );
% The iadsread function is gated to the server update cycle so there is absolutely
% no need to put any 'sleep' calls in your Matlab code. In fact, if you
% delay your processing too much, you may not be able see the data on the
% displays until you scroll back. Drop your derived parameters into a StripChart
% and if you see the value delaying or a RedX on the display, try scrolling back.
% If the data is latent, you'll need to optimize your code somehow.
% Next, run your calculation on the input data matrix from iadsread
columnwiseDataToWrite = abc * 10;
% Now, write the results back to the Iads server. For the first
% argument, we must use the same exact string as the iadsread call.
% It is important to note that you must only make one call to iadsread
% followed by a call to iadswrite. Any other combination is likely to misalign data.
% Notice the third argument is the list of parameter names to be written to the server.
% There should be one name for each column in the input matrix in argument four.
% Argument four should contain the columnwise data matrix to write to the server (or file), each column
% corresponding to a parameter listed in argument 3. The number of rows in columnwiseDataToWrite
% should correspond exactly to the number of rows in the input data (abc variable above). In
% other words, every row of the input data should output a corresponding row in your
% columnwiseDataToWrite data. If not, you will be producing data at the incorrect rate to
% the server.
iadswrite( 'IADS-CDS$58000', '', 'AMatlab,BMatlab,CMatlab', columnwiseDataToWrite )
end