{attribute 'qualified_only'}
VAR_GLOBAL
	// PLC Shift app configs, DUTs exported from PLC Shift Manager
	GF01 : GF01_GasFlow_v1_8; 
	LF01: LF01_LiquidFlow_v1_3;
	WT01: WT01_LiquidFlow_v1_3;
	
	// hold static well configurations in an array. When the user selects a 
	// well to test, pick the desired config out of this array using the
	// selected well on test as an index. 
	// demo configs are hard coded in this app and are used for 
	// demo purposes only
	DemoWellConfigurations : ARRAY [0..4] OF WellCompleteConfig;
	// Real well configurations. Use these for an actual system
	// Well configurations must be loaded before well testing
	// is possible 
	{attribute 'ac_persist' := 'PersistenceChannel'}
	RealWellConfigurations : ARRAY [0..31] OF WellCompleteConfig;
	// Track the status of real configurations
	{attribute 'ac_persist' := 'PersistenceChannel'}
	RealWellTestConfigStatus : ARRAY [0..31] OF WellTestConfigStatus;
	// whether the use demo or real configurations
	UseDemoConfigs : BOOL := TRUE;
	
	// Expose a well config externally. Use this config
	// to display internal configs from memory 
	// and to load external configs into our internal 
	// array
	ExternalWellCompleteConfig : WellCompleteConfig;
	// Use this to select the internal config to use
	// This should be in the range of the RealWellConfigurations
	// array. If the array is from 0 to 31, this should be 
	// from 1 to 32. 
	ExternalConfigNumber : INT;
	// set this value to move an internal config to 
	// the external config
	LoadConfigInternalToExternal : BOOL;
	// set this value to move an external config
	// to an internal config
	LoadConfigExternalToInternal : BOOL;
	
	// internal well on test
	WellOnTestIn : DINT := 1;
	// external well on test. Used in auto mode
	WellOnTestOut : DINT := 0;
	// state variable for main control loop
	TestState : TestStates;
	
	// manual control varaibles. HMI radio button values are 
	// mapped to these in code. 
	StartTest : BOOL; 
	StopTest : BOOL;
	StartStopTest : INT := 0; // map HMI radio buttons to an integer
	ManualAutoMode : INT :=0; // map HMI radio buttons to an integer
END_VAR