%% gieTestSetup.m
% Set up input files for analysis of the GIE. 
% Instructions: Change the information in the config file
% gieCfgScript.m. 
% 
% This function returns 1 if it executes properly. It returns
% 0 if it has failed. 
% 
% Vivek Nadkarni
% June 10, 2004
% Trimble

function [success] = gieTestSetup
%% Initialization 
% Set up labels
BASE = 1;
ROVER = 2;
GIE = 3; 

% Store file labels
rcvrLabels{BASE} = 'base'; 
rcvrLabels{ROVER} = 'rover';
rcvrLabels{GIE} = 'gie';

% Store standard configuration file name
cfgFileName = 'gieTestSetupData';

% Start in the last run directory
if (exist([cfgFileName '.mat'],'file')) 
  load(cfgFileName, 'directoryname'); 
else
  directoryname = [];
end

% Select the configuration script file.
[cfgScriptName, cfgScriptDir, cfgFilterIdx] = ...
  uigetfile([directoryname 'gieCfgScript.m']); 

if (cfgFilterIdx == 0)
  disp('No file selected.'); 
  success = 0; 
  return;
end

if (cfgFilterIdx == 1)
  % This is a quick and dirty kludge. This will not work with
  % filenames with a '.' in them, except before the extension. 
  cfgScriptName = strtok(cfgScriptName, '.'); 
end

% Go to the script directory and execute the script. 
wd = pwd; 
cd(cfgScriptDir); 
eval(cfgScriptName);
cd(wd); 
clear wd; 

% Executable locations
% These should be modified based on the directory in which gieTools
% are installed. 
rkwinExe = 'C:\Vivek\Survey\code\GPSTools\gieTools\rkwin.exe'; 
viewdatExe = 'C:\Vivek\Survey\code\GPSTools\gieTools\ViewDAT.exe'; 

% GIE position is the same as the ROVER position
surveyPos(GIE,:) = surveyPos(ROVER,:);

% Save the configuration file in the gieTools directory. This is 
% a temporary file. 
save(cfgFileName); 

disp('gieTestSetup complete.'); 

success = 1; 
return;
