#!/bin/perl

do "parameters.pl";


# Open the file for reading.
open DATA, "Iplasma_dp.csv" or die "can't open file $!";
my @data = <DATA>;
close (DATA);

$PlasmaStartRow=`cat PlasmaStartRow`;
$PlasmaEndRow=`cat PlasmaEndRow`;
$PlasmaTimeLength=`cat PlasmaTimeLength`;


$TotalCharge=0;
for ($i = $PlasmaStartRow; $i < $PlasmaEndRow; ++$i)  
{
    @row = split(';',$data[$i]);$Ipl=$row[1];
    $TotalCharge+=$row[1]*$DeltaTs;    
}

open RESULT, ">PlasmaTotalCharge";
    printf RESULT "%4.1f", $TotalCharge;
close RESULT;
open RESULT, ">MeanPlasmaCurrent";
    printf RESULT "%4.1f", $TotalCharge/$PlasmaTimeLength;
close RESULT;



#system ("echo $TotalCharge > PlasmaTotalCharge");



