/// <summary> /// Specifies whether an existing instance of the application be used or a new one created. /// The application version must be specified and, optionally, a maximum version. If a version /// greater than that specified in <i>version</i>, but less than or equal to that specified by <i>maximumVersion</i> is found, /// then this will be used. Should <i>maximumVersion</i> be unspecified, only the absolute version specified /// <i>in version</i> will be used. /// </summary> /// <param name="InstanceReuse">Specifies re-use or new instance.</param> /// <param name="version">Nominal application version to use.</param> /// <param name="maximumVersion">Maximum application version to use.</param> protected void Initialise(InstanceReuse InstanceReuse, Version version, Version maximumVersion) { _version = version; this.InstanceReuse = InstanceReuse; // Either connect to an existing instance or create a new one switch (this.InstanceReuse) { case InstanceReuse.UseExistingInstance: // Use an existing instance UseExistingInstance(version, maximumVersion); break; case InstanceReuse.CreateNewInstance: // Create a new instance CreateNewInstance(version, maximumVersion); break; case InstanceReuse.CreateSingleInstance: // Close all other instances and create a new one CreateSingleInstance(version, maximumVersion); break; } _isGUIVisible = true; }
/// <summary> /// Specifies whether an existing instance of the application be used or a new one created. This implementation is /// version non-specific and either the first existing instance of the application found or the latest installed version will be used. /// </summary> /// <param name="InstanceReuse">Specifies re-use or new instance.</param> protected void Initialise(InstanceReuse InstanceReuse) { this.InstanceReuse = InstanceReuse; // Either connect to an existing instance or create a new one switch (this.InstanceReuse) { case InstanceReuse.UseExistingInstance: // Use an existing instance UseExistingInstance(null, null); break; case InstanceReuse.CreateNewInstance: // Create a new instance CreateNewInstance(null, null); break; case InstanceReuse.CreateSingleInstance: // Close all other instances and create a new one CreateSingleInstance(null, null); break; } _isGUIVisible = true; }
/// <summary> /// Calls down to the base class to start PowerMILL based on the specified /// option. /// </summary> /// <param name="instanceReuse">Specifies how to start the application (e.g. use the running instance, create a new instance).</param> /// <param name="applicationMode">Represents the GUI option in PowerMill.</param> /// <remarks></remarks> public PMAutomation(InstanceReuse instanceReuse, Modes applicationMode = Modes.WithoutGui) { _applicationMode = applicationMode; Initialise(instanceReuse); // Ensure PowerMILL has started properly while (DoCommandEx("PRINT \"TEST\"").ToString() != "TEST") { System.Threading.Thread.Sleep(1000); DoCommand("ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT"); } // Dialogs are on by default _isGUIVisible = true; // Initialise the Macro substitution tokens collection _substitutionTokens = new PMSubstitutionTokensCollection(); IssueEchoOffCommands = false; }