Skip to content

Commit eb780c0

Browse files
FIX: Removed old CAVE2Manager configuration code. Replaced with new ConfigurationManager and added special case to ONLY set CAVE2 machine names if USING_CAVE2 to avoid potential display/cluster conflicts before fully implemented.
1 parent f7ffa74 commit eb780c0

File tree

2 files changed

+21
-91
lines changed

2 files changed

+21
-91
lines changed

CAVE2/Scripts/Managers/CAVE2Manager.cs

Lines changed: 15 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -784,32 +784,6 @@ public enum TrackerEmulationMode { Pointer, Translate, Rotate, TranslateForward,
784784
[SerializeField]
785785
int highQualitySettingIndex = -1;
786786

787-
[Header("Configuration")]
788-
[SerializeField]
789-
string configFilePath = "module-omicron/Config";
790-
791-
//[SerializeField]
792-
//bool generateConfigFile = false;
793-
794-
// Config File
795-
string configPath;
796-
bool hasConfig = false;
797-
798-
[Serializable]
799-
public class CAVE2Config
800-
{
801-
public CAVE2ManagerConfig cave2manager;
802-
}
803-
804-
[Serializable]
805-
public class CAVE2ManagerConfig
806-
{
807-
public string headNodeMachineName;
808-
public string displayNodeMachineName;
809-
}
810-
811-
CAVE2Config config;
812-
813787
public void Init()
814788
{
815789
CAVE2Manager_Instance = this;
@@ -826,67 +800,6 @@ public void Init()
826800
Debug.Log(this.GetType().Name + ">\t initialized on " + machineName);
827801

828802
UnityEngine.Random.InitState(1138);
829-
830-
CheckConfigFile();
831-
}
832-
833-
void CheckConfigFile()
834-
{
835-
string configFileDefaultName = "cave2config.cfg";
836-
837-
// Load config file:
838-
// Priority 1: User specfied as command line argument
839-
string[] cmdArgs = Environment.GetCommandLineArgs();
840-
for (int i = 0; i < cmdArgs.Length; i++)
841-
{
842-
if (cmdArgs[i].Equals("-cave2config") && i + 1 < cmdArgs.Length)
843-
{
844-
if (!hasConfig)
845-
{
846-
LoadConfigFile(Environment.CurrentDirectory + "/" + cmdArgs[i + 1]);
847-
}
848-
}
849-
}
850-
851-
// Priority 2: Check Default Path (Assets/module-omicron)
852-
// or changed in Editor Inspector for this script
853-
if (!hasConfig)
854-
{
855-
LoadConfigFile(Application.dataPath + "/" + configFilePath + "/" + configFileDefaultName);
856-
}
857-
858-
// Priority 3: Check Asset Folder Default Path
859-
if (!hasConfig)
860-
{
861-
LoadConfigFile(Application.dataPath + "/" + configFileDefaultName);
862-
}
863-
}
864-
865-
void LoadConfigFile(string configPath)
866-
{
867-
// Read from config (if it exists, else create on quit)
868-
try
869-
{
870-
StreamReader reader = new StreamReader(configPath);
871-
config = JsonUtility.FromJson<CAVE2Config>(reader.ReadToEnd());
872-
CAVE2ManagerConfig c2mConfig = config.cave2manager;
873-
874-
if (c2mConfig.headNodeMachineName != null)
875-
{
876-
CAVE2.HEAD_NODE_NAME = c2mConfig.headNodeMachineName;
877-
}
878-
if (c2mConfig.displayNodeMachineName != null)
879-
{
880-
CAVE2.DISPLAY_NODE_NAME = c2mConfig.displayNodeMachineName;
881-
}
882-
883-
Debug.Log("CAVE2Manager configration loaded from '" + configPath + "'.");
884-
hasConfig = true;
885-
}
886-
catch
887-
{
888-
889-
}
890803
}
891804

892805
void Start()
@@ -941,6 +854,21 @@ void ConfigurationLoaded(DefaultConfig config)
941854
}
942855
}
943856

857+
void CAVE2ConfigurationLoaded(DefaultConfig config)
858+
{
859+
ClusterConfig cConfig = ConfigurationManager.loadedConfig.clusterConfig;
860+
if (cConfig.headNodeName.Length > 0)
861+
{
862+
CAVE2.HEAD_NODE_NAME = cConfig.headNodeName;
863+
Debug.Log("Config: Using '" + CAVE2.HEAD_NODE_NAME + "' as head node machine name");
864+
}
865+
if (cConfig.displayNodeName.Length > 0)
866+
{
867+
CAVE2.HEAD_NODE_NAME = cConfig.displayNodeName;
868+
Debug.Log("Config: Using '" + CAVE2.HEAD_NODE_NAME + "' as display node machine name");
869+
}
870+
}
871+
944872
void Update()
945873
{
946874
if(CAVE2Manager_Instance == null)

Continuum/Scripts/ConfigurationManager.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ void Start()
9595
#if UNITY_EDITOR
9696
configSelectionPath = defaultEditorBasePath + "/" + configSelectionPath;
9797
configPath = defaultEditorBasePath + "/" + configPath;
98-
#elif USING_CAVE2
99-
// Probably should have a CAVE2 build specfic config here at some point.
100-
// Until then:
101-
return;
10298
#else
10399
configSelectionPath = Application.dataPath + "/" + configSelectionPath;
104100
configPath = Application.dataPath + "/" + configPath;
@@ -134,7 +130,13 @@ void Start()
134130

135131
Debug.Log("Loaded configuration file '" + configPath + "/" + defaultConfigFile + "':");
136132
//Debug.Log(JsonUtility.ToJson(loadedConfig, true));
133+
#if USING_CAVE2
134+
// Specific CAVE2 config function to ONLY set machine name
135+
// and not set anything else i.e. display (for now)
136+
BroadcastMessage("CAVE2ConfigurationLoaded", loadedConfig);
137+
#else
137138
BroadcastMessage("ConfigurationLoaded", loadedConfig);
139+
#endif
138140
}
139141
else
140142
{

0 commit comments

Comments
 (0)