function DatiElabDebrisLink = LastElab_bisDL(conn,NodoDebrisLink,rDL,datainiDL,...
    tempoiniDL,IDcentralina,DTcatena,FileName)

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

NDebrisLink = cell2mat(NodoDebrisLink(:,2));   
NodeType = 'Debris Link';
ii = 1; % contatore
col = 11; % contatore colonne
while ii <= rDL
      ini_col = col-10;
      nN = num2str(NDebrisLink(ii,1));
      % Scarico di dati di spostamenti - giorno X
      comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, T_node, AlfaX, AlfaY from ElabDataView where EventDate = ''' ...
        datainiDL ''' and EventTime >= ''' tempoiniDL ''' and  UnitName = ''' IDcentralina ...
        ''' and ToolNameID = ''' DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
      curs = exec(conn,comando);
      curs = fetch(curs);
      DATnodoDLd = curs.Data;
      % Scarico di dati di spostamenti - giorni successivi a X
      comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, T_node, AlfaX, AlfaY from ElabDataView where EventDate >= ''' ...
        datainiDL ''' and  UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ...
        ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
      curs = exec(conn,comando);
      curs = fetch(curs);
      DATnodoDL = curs.Data;
      [~,c1] = size(DATnodoDL);
      [~,c2] = size(DATnodoDLd);
      if c1 == c2
          DATnodoDL = [DATnodoDLd; DATnodoDL];
      elseif c1 < c2 % solo giorno di riferimento
          DATnodoDL = DATnodoDLd;
      end
      DatiElabDebrisLink(:,ini_col:col) = DATnodoDL(:,:);
      col = col+11;
      ii = ii+1;
end

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

end