function [] = LoadIPLB(client, shotnum)
% Calculate the plasma current from IPLB data
% 

dataStruct = client.getData('CENTRAL.OS9_ADC_VME_I8.IPLB','0x0000', shotnum);
iplbData = dataStruct(1).getData;            
len = length(iplbData);

iplbOffset = mean(iplbData(200:400));

tstart = dataStruct(1).getTStart;
tend = dataStruct(1).getTEnd;
tbs = (tend.getTimeInMicros - tstart.getTimeInMicros)/len;
events = dataStruct(1).getEvents;
tevent = events(1).getTimeStamp;


delay = tstart.getTimeInMicros - tevent.getTimeInMicros;
iplbTimes = delay:tbs:delay+tbs*(len-1);
iplb = (iplbData-iplbOffset)/1000;                   % adjust the offset and convert to kA
iplbTimes=iplbTimes/1000;                            % convert to ms


figure(1);
plot(iplbTimes, iplb)
title(['Shot number ' num2str(shotnum)], 'fontsize', 16);
xlabel('time (ms)');
ylabel('IPLB (kA)');
grid on;
