%  PistonTravel.m
% Calculates how much the piston has traveled in the PTO


clear 
clc

dpath = '134.89.12.189/data/';
dataDirs = dir([dpath 'R*']);
TotalDistance = 0;



for i = 1:length(dataDirs)
  if(dataDirs(i).isdir == 1)
     ppath = [dpath dataDirs(i).name '/'];
     
     matfiles = dir([ppath 'D*.mat']);

     K = length(matfiles);
     for k = 1:K
       load([ppath matfiles(k).name]);
       DeltaDistance=diff(PistonDistance);
       TotalDistance = TotalDistance + sum(abs(DeltaDistance));
     end
  end
end