function [DatiElabTriggerLink,DatiElabShockSensor,DatiElabDebrisLink] = checkdata(...
    yesTrL,yesSS,yesDL,DatiElabTriggerLink,DatiElabShockSensor,DatiElabDebrisLink,...
    datainiTrL,datainiSS,datainiDL,rTrL,rSS,rDL,tempoiniTrL,tempoiniSS,tempoiniDL,...
    NodoTriggerLink,NodoShockSensor,NodoDebrisLink,NuovoZeroTrL,NuovoZeroSS,NuovoZeroDL,...
    IDcentralina,DTcatena,conn,FileName)

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

%% Trigger Link
if yesTrL == 1 % Trigger Link
    if NuovoZeroTrL == 1
        data1 = datenum([char(DatiElabTriggerLink(1,1)) ' ' char(DatiElabTriggerLink(1,2))]);
        data2 = datenum([datainiTrL(1,1:10) ' ' tempoiniTrL]);
        if data1 ~= data2 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiTrL = datestr(data2,'yyyy-mm-dd');
            tempoiniTrL = datestr(data2,'HH:MM:SS');
            DatiElabTriggerLink = LastElab_bisTrL(conn,NodoTriggerLink,rTrL,...
                datainiTrL,tempoiniTrL,IDcentralina,DTcatena,FileName);
        end
    end
end

%% Shock Sensor
if yesSS == 1 % 
    if NuovoZeroSS == 1
        data1 = datenum([char(DatiElabShockSensor(1,1)) ' ' char(DatiElabShockSensor(1,2))]);
        data2 = datenum([datainiSS(1,1:10) ' ' tempoiniSS]);
        if data1 ~= data2 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiSS = datestr(data2,'yyyy-mm-dd');
            tempoiniSS = datestr(data2,'HH:MM:SS');
            DatiElabShockSensor = LastElab_bisSS(conn,NodoShockSensor,rSS,datainiSS,...
                tempoiniSS,IDcentralina,DTcatena,FileName);
        end
    end
end

%% Debris Link
if yesDL == 1 % Debris Link
    if NuovoZeroDL == 1
        data1 = datenum([char(DatiElabDebrisLink(1,1)) ' ' char(DatiElabDebrisLink(1,2))]);
        data2 = datenum([datainiDL(1,1:10) ' ' tempoiniDL]);
        if data1 ~= data2 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiDL = datestr(data2,'yyyy-mm-dd');
            tempoiniDL = datestr(data2,'HH:MM:SS');
            DatiElabDebrisLink = LastElab_bisDL(conn,NodoDebrisLink,rDL,...
                datainiDL,tempoiniDL,IDcentralina,DTcatena,FileName);
        end
    end
end

text = 'checkdata function worked correctly';
fileID = fopen(FileName,'a');
fmt = '%s \r';
fprintf(fileID,fmt,text);
fclose(fileID);

end