Ejemplo n.º 1
0
        /// <summary>
        /// Helper function to get the MethodXMLContext
        /// </summary>
        /// <param name="model">The instrument model</param>
        /// <param name="version">The instrument version</param>
        /// <returns></returns>
        public static IMethodXMLContext CreateContext(string model = "", string version = "")
        {
            if (string.IsNullOrEmpty(model))
            {
                model = MethodXMLFactory.GetInstalledServerModel();
            }

            if (string.IsNullOrEmpty(version))
            {
                version = MethodXMLFactory.GetLatestInstalledVersion(model);
            }

            if (!MethodXMLFactory.GetInstalledInstrumentModels().Contains(model))
            {
                throw new ArgumentException("Cannot create method context for non-installed instrument model: " + model);
            }

            return(MethodXMLFactory.CreateContext(model, version));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Prints information about the executing computer's TNG status
        /// </summary>
        public static IEnumerable <string> PrintInformation()
        {
            // Get all installed instruments for executing computer
            // Searches the registry for installed TNG instruments.
            // HKEY_LOCAL_MACHINE\SOFTWARE\Thermo Instruments\TNG
            // or
            // HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Thermo Instruments\TNG
            var instruments = MethodXMLFactory.GetInstalledInstrumentModels();

            yield return("== Configured Instruments ==");

            int i = 1;

            foreach (string instrument in instruments)
            {
                Console.WriteLine("{0,2}: {1}", i++, instrument);
                // Get all installed instrument versions for this particular instrument (i.e., Fusion 1.1, 1.2, etc...)
                var versions = MethodXMLFactory.GetInstalledVersions(instrument);

                // TNG can be installed as Full (connected to instrument) or Workstation (just MethodEditor) mode.
                var fullInstalledVersions = new HashSet <string>(MethodXMLFactory.GetFullInstalledVersions(instrument));

                // The most recently installed version for this instrument model
                var lastInstalledVersion = MethodXMLFactory.GetLatestInstalledVersion(instrument);

                foreach (string version in versions)
                {
                    yield return(string.Format("{0,8} ({1}){2}",
                                               version,
                                               fullInstalledVersions.Contains(version) ? "Full" : "WorkStation",
                                               version == lastInstalledVersion ? " Latest Installed" : ""));
                }
            }
            yield return("============================");

            yield return(string.Format("Installed Server Model:   {0}", MethodXMLFactory.GetInstalledServerModel()));

            yield return(string.Format("Installed Server Version: {0}", MethodXMLFactory.GetInstalledServerVersion()));
        }
Ejemplo n.º 3
0
        public void ParseCommandArgs(string[] args)
        {
            string outputMethod = null;
            bool   readStdin    = false;
            bool   multiFile    = false;

            int i = 0;

            while (i < args.Length && args[i][0] == '-')
            {
                string arg = args[i++];
                switch (arg[1])
                {
                case 'f':
                    InstrumentType = InstrumentFusion;
                    break;

                case 'e':
                    InstrumentType = InstrumentEndura;
                    break;

                case 'q':
                    InstrumentType = InstrumentQuantiva;
                    break;

                case 'a':
                    InstrumentType = InstrumentAltis;
                    break;

                case 'o':
                    if (i >= args.Length)
                    {
                        throw new UsageException();
                    }
                    outputMethod = Path.GetFullPath(args[i++]);
                    break;

                case 'x':
                    ExportXml = true;
                    break;

                case 's':
                    readStdin = true;
                    break;

                case 'm':
                    multiFile = true;
                    break;

                default:
                    throw new UsageException(string.Format("Unknown argument {0}", arg));
                }
            }

            InstrumentVersion = MethodXMLFactory.GetLatestInstalledVersion(InstrumentType);

            if (multiFile && !string.IsNullOrEmpty(outputMethod))
            {
                Usage("Multi-file and specific output are not compatibile.");
            }

            int argcLeft = args.Length - i;

            if (argcLeft < 1 || (!readStdin && argcLeft < 2))
            {
                Usage();
            }

            TemplateMethod = Path.GetFullPath(args[i++]);

            // Read input into a list of lists of fields
            if (readStdin)
            {
                if (!multiFile && string.IsNullOrEmpty(outputMethod))
                {
                    Usage("Reading from standard in without multi-file format must specify an output file.");
                }

                ReadTransitions(Console.In, outputMethod);
            }
            else
            {
                for (; i < args.Length; i++)
                {
                    string inputFile = Path.GetFullPath(args[i]);
                    string filter    = null;
                    if (inputFile.Contains('*'))
                    {
                        filter = Path.GetFileName(inputFile);
                    }
                    else if (Directory.Exists(inputFile))
                    {
                        filter = "*.csv";
                    }

                    if (string.IsNullOrEmpty(filter))
                    {
                        ReadFile(inputFile, outputMethod, multiFile);
                    }
                    else
                    {
                        string dirName = Path.GetDirectoryName(filter) ?? ".";
                        foreach (var fileName in Directory.GetFiles(dirName, filter))
                        {
                            ReadFile(Path.Combine(dirName, fileName), null, multiFile);
                        }
                    }
                }
            }
        }