function DatiElabTriggerLink = LastElab_bisTrL(conn,NodoTriggerLink,rTrL,datainiTrL,tempoiniTrL,IDcentralina,DTcatena,FileName)

text = 'LastElab_bisTrL function started';
fileID = fopen(FileName,'a');
fmt = '%s \r';
fprintf(fileID,fmt,text);

NTriggerLink = cell2mat(NodoTriggerLink(:,2));   
NodeType = 'Trigger Link';
ii = 1; % contatore
col = 3; % contatore colonne
while ii <= rTrL
      ini_col = col-2;
      nN = num2str(NTriggerLink(ii,1));
      % Scarico di dati di spostamenti - giorno X
      comando = ['select EventDate, EventTime, X from ElabDataView where EventDate = ''' ...
        datainiTrL ''' and EventTime >= ''' tempoiniTrL ''' and  UnitName = ''' IDcentralina ...
        ''' and ToolNameID = ''' DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
      curs = exec(conn,comando);
      curs = fetch(curs);
      DATnodoTrLd = curs.Data;
      % Scarico di dati di spostamenti - giorni successivi a X
      comando = ['select EventDate, EventTime, X from ElabDataView where EventDate >= ''' ...
        datainiTrL ''' and  UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ...
        ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
      curs = exec(conn,comando);
      curs = fetch(curs);
      DATnodoTrL = curs.Data;
      [~,c1] = size(DATnodoTrL);
      [~,c2] = size(DATnodoTrLd);
      if c1 == c2
          DATnodoTrL = [DATnodoTrLd; DATnodoTrL];
      elseif c1 < c2 % solo giorno di riferimento
          DATnodoTrL = DATnodoTrLd;
      end
      DatiElabTriggerLink(:,ini_col:col) = DATnodoTrL(:,:);
      col = col+3;
      ii = ii+1;
end

text = 'LastElab_bisTrL function worked correctly';
fprintf(fileID,fmt,text);
fclose(fileID);

end