public Configuration(InterfaceConfiguration interfaces, TaskProcedure taskProcedure) { _globalPauseEnabled = false; _backgroundColor = Color.black; _interfaces = interfaces; _taskProcedure = taskProcedure; _maximumAllowablePauseTime = float.MaxValue; }
public ThreePhaseController(InterfaceConfiguration interfaces) { _tcpServer = new TCPServer(interfaces.TcpPort); _interfaces = interfaces; }
//Helper function that generates an InterfaceConfiguration object from a JSONClass which contains Interfaces in the appropriate format public static InterfaceConfiguration getInterfaceConfigurationFromJSON(JSONClass taskClass) { InterfaceConfiguration interfaceConfig = new InterfaceConfiguration(); if (taskClass["Interfaces"] == null) { Debug.LogError("Error: JSON does not include Interfaces object. See example JSON for help."); Application.Quit(); } else { JSONArray interfaces = taskClass["Interfaces"].AsArray; for (int i = 0; i < interfaces.Count; i++) { JSONNode iFace = interfaces[i]; int port = iFace["Port"].AsInt; JSONArray keyMap = iFace["KeyMap"].AsArray; List<string[]> map = JSONDataLoader.getKeyMapStringArraysFromKeyMapJSON(keyMap); switch (iFace["InterfaceType"]) { case "Keyboard": interfaceConfig.setKeyboardMap(map[0], map[1]); break; case "XBoxController": interfaceConfig.setXBoxControllerMap(map[0], map[1]); break; case "TCP": interfaceConfig.setTCPMap(map[0], map[1]); if (port != 0) interfaceConfig.setTCPPort(port); break; } } } if (taskClass["InterfaceMaster"] == null) { Debug.LogError("Error: JSON does not include InterfaceMaster object. See example JSON for help."); Application.Quit(); } else { switch (taskClass["InterfaceMaster"]) { case "Keyboard": interfaceConfig.setMaster(InterfaceConfiguration.InterfaceType.Keyboard); break; case "XBoxController": interfaceConfig.setMaster(InterfaceConfiguration.InterfaceType.XBoxController); break; case "TCP": interfaceConfig.setMaster(InterfaceConfiguration.InterfaceType.TCP); break; default: Debug.LogError("Error: InterfaceMaster value is not recognized. Please select either Keyboard, XBoxController, or TCP."); Application.Quit(); break; } } if (!interfaceConfig.isValidInterface()) { Debug.LogError("Error: Interface is not valid. This is likely because none of the specified interfaces in the JSON properly loaded or no interface was specified. See example JSON for help."); Application.Quit(); } return interfaceConfig; }