/// <summary> /// This is another init method that is generally not called by the end-user. /// The purpose of the comPort argument is the same as with the string version, /// init(string baseName, string comPort). /// </summary> /// <param name="config"></param> /// <param name="comPort"></param> public static void Init(MyroConfigFiles config, string comPort) { bool isScribbler = config.BaseName.ToLower().Equals("scribbler"); // If this is a Scribbler, wait for it to start if (isScribbler) { CurrentConfig = config; LastStateChange = RobotStateChange.CONNECTING; try { // Start DSS if not started if (bank == null) { startDSS(config); createAdapters(); } connectWaitForScribbler(comPort); } catch (Exception) { LastStateChange = RobotStateChange.CONNECTING_FAILED; CurrentConfig = null; throw; } LastStateChange = RobotStateChange.CONNECTING_SUCCEEDED; } else { if (bank == null) { CurrentConfig = config; LastStateChange = RobotStateChange.CONNECTING; try { startDSS(config); createAdapters(); } catch (Exception) { LastStateChange = RobotStateChange.CONNECTING_FAILED; CurrentConfig = null; throw; } LastStateChange = RobotStateChange.CONNECTING_SUCCEEDED; } else { throw new MyroInitException("Myro is already initialized"); } } }
/// <summary> /// This is an internal helper method that starts the DSS environment, /// using the manifest file specified in the MyroConfigFiles argument. /// </summary> /// <param name="config"></param> private static void startDSS(MyroConfigFiles config) { string manifestFile = Path.Combine(Path.Combine(Params.ConfigPath, config.BaseName + ".manifest"), config.BaseName + ".manifest.xml"); Robot.httpPort = config.MyroConfiguration.HttpPort; Robot.dsspPort = config.MyroConfiguration.DsspPort; FileAttributes att = File.GetAttributes(manifestFile); if ((att & (FileAttributes.Device | FileAttributes.Directory | FileAttributes.Offline)) != 0) { throw new IOException("Manifest file is not a normal file"); } Console.Write("Starting DSS environment..."); DssEnvironment.Initialize(httpPort, dsspPort, "file://" + manifestFile); Console.WriteLine("Done"); }
/// <summary> /// This version of Init is generally not called by the end-user. It /// uses a configuation that is already found by a MyroConfigFinder class. /// </summary> /// <param name="config"></param> public static void Init(MyroConfigFiles config) { Init(config, null); }