function [t, y, err,errmsg] = OsiSendTrendData(vardesc,ConNo)
%
% OsiSendTrendData.m		Request trend data from OLGA Server
%
% The calling syntax is:
%
%   [t, y, err] = OsiSendTrendData(vardesc);
%
% Input:
%   VARDESC: String identifying the variables to be reported from olga.
%   ConNo: Connnection number (default: ConNo=1)
%
% Outputs:
%   T - Current time.
%   Y - trend data, one variable in each column.
%
% Copyright (c) 1998 by ABB Corporate Research.
% All Rights Reserved.
%
% $Revision: 1.0, 6/10-1998 by Kjetil Havre$
% $Revision: 1.1, 20/7-2005 by Espen Storkaas, ABB-EOP, included user-defined connection number$ 

  if nargin==1
      ConNo=1;
  end
  if nargin > 2|nargin==0 
     errmsg = 'OsiSendTrendData usage: [err, errmsg] = OsiSendTrendData(vardesc)';
     disp(errmsg);
     err = -1;
     return
  end

  [err, msg, ibody, rbody, errmsg] = osmi(ConNo, 'OLGA_SENDTR_NAMES', [], [], vardesc);

  
  t = []; y = []; 

  if err == 0
     t = OsiGetTime;
     nr = max(ibody);
     nc = size(ibody,1); 
     for i = 1:nc 
        y(:,i) = rbody( (i-1)*nr+1:i*nr);
     end
  end
  

    




































































































































