Beispiel #1
0
        public static void PlaceFullScan(IScans m_scans, Parameters parameters)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }
            ICustomScan scan = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.FullScanSetting.MzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.FullScanSetting.MzRangeHighBound.ToString();
            scan.Values["IsolationRangeLow"]  = parameters.FullScanSetting.MzRangeLowBound.ToString();
            scan.Values["IsolationRangeHigh"] = parameters.FullScanSetting.MzRangeHighBound.ToString();
            scan.Values["MaxIT"]             = parameters.FullScanSetting.MaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.FullScanSetting.Resolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = "0.0";
            scan.Values["NCE_NormCharge"]    = parameters.MS1IonSelecting.NormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            scan.Values["NCE_Factors"]       = "[]";
            scan.Values["SourceCID"]         = parameters.GeneralSetting.SourceCID.ToString();
            scan.Values["Microscans"]        = parameters.FullScanSetting.Microscans.ToString();
            scan.Values["AGC_Target"]        = parameters.FullScanSetting.AgcTarget.ToString();
            scan.Values["AGC_Mode"]          = parameters.GeneralSetting.AGC_Mode.ToString();

            scan.Values["MsxInjectRanges"]    = "[]";
            scan.Values["MsxInjectTargets"]   = "[]";
            scan.Values["MsxInjectMaxITs"]    = "[]";
            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";

            Console.WriteLine("{0:HH:mm:ss,fff} placing Full MS1 scan", DateTime.Now);
            m_scans.SetCustomScan(scan);
        }
Beispiel #2
0
 /// <summary>
 /// Dump the list of possible commands.
 /// </summary>
 /// <param name="scans">where to take possible parameters from</param>
 /// <param name="verbose">shall each parameter be dumped?</param>
 static private bool DumpPossibleParameters(IScans scans, bool verbose)
 {
     IParameterDescription[] parameters = scans.PossibleParameters;
     if (parameters.Length == 0)
     {
         Console.WriteLine("No possible IScans parameters known.");
         return(false);
     }
     if (verbose)
     {
         Console.WriteLine("IScans parameters:");
         foreach (IParameterDescription parameter in parameters)
         {
             StringBuilder sb = new StringBuilder();
             sb.AppendFormat("   '{0}' ", parameter.Name);
             if (parameter.Selection == "")
             {
                 sb.AppendFormat("doesn't accept an argument, help: {0}", parameter.Help);
             }
             else
             {
                 sb.AppendFormat("accepts '{0}', default='{1}', help: {2}", parameter.Selection, parameter.DefaultValue, parameter.Help);
             }
             Console.WriteLine(sb.ToString());
         }
     }
     else
     {
         Console.WriteLine("IScans parameters: {0}", string.Join(", ", parameters.Select(n => n.Name).ToArray()));
     }
     return(true);
 }
Beispiel #3
0
        /// <summary>
        /// Create a new <see cref="ScansTest"/> and start the performance test immediately.
        /// </summary>
        /// <param name="instrument">the instrument instance</param>
        /// <param name="arguments">program arguments</param>
        internal ScansTest(IExactiveInstrumentAccess instrument, Arguments arguments)
        {
            Arguments = arguments;

            m_scans = instrument.Control.GetScans(false);
            m_scans.CanAcceptNextCustomScan   += new EventHandler(Scans_CanAcceptNextCustomScan);
            m_scans.PossibleParametersChanged += new EventHandler(Scans_PossibleParametersChanged);

            DumpPossibleParameters();
            bool startNewScan = false;

            lock (m_lock)
            {
                if (m_scans.PossibleParameters.Length > 0)
                {
                    startNewScan      = m_startCustomScan;
                    m_startCustomScan = false;
                }
            }

            if (startNewScan)
            {
                StartNewScan();
            }
        }
 /// <summary>
 /// Gets a scan information
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='scanName'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Scan> GetAsync(this IScans operations, string dataSourceName, string scanName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetWithHttpMessagesAsync(dataSourceName, scanName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// List scans in data source
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='skipToken'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ScanList> ListByDataSourceAsync(this IScans operations, string dataSourceName, string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListByDataSourceWithHttpMessagesAsync(dataSourceName, skipToken, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Runs the scan
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='scanName'>
 /// </param>
 /// <param name='body'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <OperationResponse> RunAsync(this IScans operations, string dataSourceName, string scanName, ScanRunProperties body = default(ScanRunProperties), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.RunWithHttpMessagesAsync(dataSourceName, scanName, body, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #7
0
 public static void PlaceDynamicBoxCarScan_BU(IScans m_scans, Parameters parameters, List <List <Tuple <double, double, double> > > dynamicBoxs)
 {
     foreach (var dynamicBox in dynamicBoxs)
     {
         if (dynamicBox.Count > 0)
         {
             PlaceDynamicBoxCarScan(m_scans, parameters, dynamicBox.ToArray());
         }
     }
 }
        public override void Initialize(IScans machine_scan_manager)
        {
            ScanManager = machine_scan_manager;
            scan_queue  = new ConcurrentQueue <ICustomScan>();

            MS1_outstanding = false;

            RunTimer = new Stopwatch();
            RunTimer.Start();
            //exclusion_time_interval = TimeSpan.FromSeconds(10);

            MS1_tardiness       = new Stopwatch();
            MS1_expiration_span = TimeSpan.FromSeconds(10);
        }
        public override void Initialize(IScans machine_scan_manager)
        {
            ScanManager = machine_scan_manager;


            scan_queue = new ConcurrentQueue <ICustomScan>();

            RunTimer = new Stopwatch();
            RunTimer.Start();

            mz_exclusion_intervals = new Dictionary <double, TimeSpan>();

            MS1_tardiness       = new Stopwatch();
            MS1_expiration_span = TimeSpan.FromSeconds(3);
        }
        internal void DoJob()
        {
            using (IExactiveInstrumentAccess instrument = Connection.GetFirstInstrument())
            {
                using (m_scans = instrument.Control.GetScans(false))
                {
                    IMsScanContainer orbitrap = instrument.GetMsScanContainer(0);
                    Console.WriteLine("Waiting 60 seconds for scans on detector " + orbitrap.DetectorClass + "...");

                    orbitrap.MsScanArrived += Orbitrap_MsScanArrived;
                    Thread.CurrentThread.Join(60000);
                    orbitrap.MsScanArrived -= Orbitrap_MsScanArrived;
                }
            }
        }
Beispiel #11
0
 /// <summary>
 /// Cancel an outstanding repetition scan.
 /// </summary>
 /// <param name="access">used to get access to the needed IScans interface.</param>
 static internal void CancelRepeatingScan(IExactiveInstrumentAccess access)
 {
     try
     {
         using (IScans scans = access.Control.GetScans(false))
         {
             if (!scans.CancelRepetition())
             {
                 Console.WriteLine("CANCELLATION OF THE REPETITION SCAN HAS NOT BEEN PERFORMED, CONNECTION TO SERVICE BROKEN.");
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("CANCELING A REPETITION SCAN: " + e.Message);
     }
 }
Beispiel #12
0
        public static void PlaceMS2Scan(IScans m_scans, Parameters parameters, List <double> dynamicBox)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }

            double      Range = parameters.MS1IonSelecting.IsolationWindow;
            ICustomScan scan  = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.MS2ScanSetting.MS2MzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.MS2ScanSetting.MS2MzRangeHighBound.ToString(); //TO THINK: Dynamic range as MqLive?
            scan.Values["IsolationRangeLow"]  = parameters.MS2ScanSetting.MS2MzRangeLowBound.ToString();
            scan.Values["IsolationRangeHigh"] = parameters.MS2ScanSetting.MS2MzRangeLowBound.ToString();
            scan.Values["Resolution"]         = parameters.MS2ScanSetting.MS2Resolution.ToString();

            scan.Values["MaxIT"]             = parameters.MS2ScanSetting.MS2MaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.MS2ScanSetting.MS2Resolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = parameters.MS2ScanSetting.NCE.ToString();
            scan.Values["NCE_NormCharge"]    = parameters.MS1IonSelecting.NormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            if (parameters.MS2ScanSetting.NCE_factors != "null")
            {
                scan.Values["NCE_Factors"] = parameters.MS2ScanSetting.NCE_factors;
            }
            scan.Values["SourceCID"]  = parameters.GeneralSetting.SourceCID.ToString("0.00");
            scan.Values["Microscans"] = parameters.MS2ScanSetting.MS2MicroScans.ToString();
            scan.Values["AGC_Target"] = parameters.MS2ScanSetting.MS2AgcTarget.ToString();
            scan.Values["AGC_Mode"]   = parameters.GeneralSetting.AGC_Mode.ToString();


            string dynamicTargets;
            string dynamicMaxIts;
            var    dynamicBoxString = BuildDynamicBoxInclusionString(parameters, dynamicBox, out dynamicTargets, out dynamicMaxIts);

            scan.Values["MsxInjectRanges"]  = dynamicBoxString;
            scan.Values["MsxInjectTargets"] = dynamicTargets;
            scan.Values["MsxInjectMaxITs"]  = dynamicMaxIts;

            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";

            Console.WriteLine("{0:HH:mm:ss,fff} placing data dependent ms2 scan {1}", DateTime.Now, dynamicBoxString);
            m_scans.SetCustomScan(scan);
        }
Beispiel #13
0
        internal void DoJob(int time)
        {
            using (IExactiveInstrumentAccess instrument = Connection.GetFirstInstrument())
            {
                using (m_scans = instrument.Control.GetScans(false))
                {
                    m_scans.CanAcceptNextCustomScan += Scans_CanAcceptNextCustomScan;
                    IMsScanContainer orbitrap = instrument.GetMsScanContainer(0);
                    Console.WriteLine("Waiting for scans on detector " + orbitrap.DetectorClass + "...");

                    orbitrap.MsScanArrived += Orbitrap_MsScanArrived;
                    Thread.CurrentThread.Join(time);
                    orbitrap.MsScanArrived          -= Orbitrap_MsScanArrived;
                    m_scans.CanAcceptNextCustomScan -= Scans_CanAcceptNextCustomScan;
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Set a default repeating scan with a FirstMass of 400.
        /// </summary>
        /// <param name="access">used to get access to the needed IScans interface.</param>
        /// <param name="verbose">shall the output be verbose?</param>
        static internal bool SetRepeatingScan(IExactiveInstrumentAccess access, bool verbose)
        {
            try
            {
                using (IScans scans = access.Control.GetScans(false))
                {
                    bool parametersArrived = (scans.PossibleParameters.Length != 0);
                    // Test if we have to wait for arrival of possible parameters:
                    if (!parametersArrived)
                    {
                        EventHandler handler = (sender, args) => { parametersArrived = true; };
                        scans.PossibleParametersChanged += handler;
                        DateTime end = DateTime.Now.AddSeconds(3);
                        // Not elegant, but it works
                        while (!parametersArrived && (DateTime.Now < end))
                        {
                            // Sleep but perform COM communication in background.
                            Thread.CurrentThread.Join(10);
                        }
                        scans.PossibleParametersChanged -= handler;
                        // Fall into an error below if we didn't receive parameter descriptions.
                    }

                    DumpPossibleParameters(scans, verbose);

                    IRepeatingScan scan = scans.CreateRepeatingScan();
                    scan.RunningNumber       = 9999;
                    scan.Values["FirstMass"] = "400";

                    if (scans.SetRepetitionScan(scan))
                    {
                        return(true);
                    }

                    Console.WriteLine("SETTING A REPETITION SCAN HAS NOT BEEN DONE, CONNECTION TO SERVICE BROKEN.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("SETTING A REPETITION SCAN: " + e.Message);
            }

            return(false);
        }
Beispiel #15
0
        //parameter Tuple<double, double, double> for each box start m/z, end m/z, m/z length
        public static void PlaceDynamicBoxCarScan(IScans m_scans, Parameters parameters, Tuple <double, double, double>[] dynamicBox)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }

            ICustomScan scan = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.BoxCarScanSetting.BoxCarMzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.BoxCarScanSetting.BoxCarMzRangeHighBound.ToString();
            scan.Values["IsolationRangeLow"]  = (parameters.BoxCarScanSetting.BoxCarMzRangeLowBound - 200).ToString();
            scan.Values["IsolationRangeHigh"] = (parameters.BoxCarScanSetting.BoxCarMzRangeHighBound + 200).ToString();

            scan.Values["MaxIT"]             = parameters.BoxCarScanSetting.BoxCarMaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.BoxCarScanSetting.BoxCarResolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = "0.0";
            scan.Values["NCE_NormCharge"]    = parameters.BoxCarScanSetting.BoxCarNormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            scan.Values["NCE_Factors"]       = "[]";

            scan.Values["SourceCID"]  = parameters.GeneralSetting.SourceCID.ToString("0.00");
            scan.Values["Microscans"] = parameters.BoxCarScanSetting.BoxCarMicroScans.ToString();
            scan.Values["AGC_Target"] = parameters.BoxCarScanSetting.BoxCarAgcTarget.ToString();
            scan.Values["AGC_Mode"]   = parameters.GeneralSetting.AGC_Mode.ToString();



            string dynamicTargets;
            string dynamicMaxIts;
            var    dynamicBoxString = BuildDynamicBoxString(parameters, dynamicBox, out dynamicTargets, out dynamicMaxIts);

            scan.Values["MsxInjectRanges"]  = dynamicBoxString;
            scan.Values["MsxInjectTargets"] = dynamicTargets;
            scan.Values["MsxInjectMaxITs"]  = dynamicMaxIts;

            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";

            Console.WriteLine("{0:HH:mm:ss,fff} placing Dynamic BoxCar MS1 scan {1}", DateTime.Now, dynamicBoxString);
            m_scans.SetCustomScan(scan);
        }
Beispiel #16
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposeEvenManagedStuff">true to dispose managed and unmanaged resources; false to dispose unmanaged resources</param>
        protected void Dispose(bool disposeEvenManagedStuff)
        {
            // prevent double disposing
            if (Interlocked.Exchange(ref m_disposed, 1) != 0)
            {
                return;
            }

            if (disposeEvenManagedStuff)
            {
                if (m_scans != null)
                {
                    m_scans.CanAcceptNextCustomScan   -= new EventHandler(Scans_CanAcceptNextCustomScan);
                    m_scans.PossibleParametersChanged -= new EventHandler(Scans_PossibleParametersChanged);
                    m_scans.Dispose();
                    m_scans = null;
                }
            }
        }
Beispiel #17
0
        internal void DoJob()
        {
            Thread childThreadCheckTime = new Thread(CheckTime);

            childThreadCheckTime.IsBackground = true;
            childThreadCheckTime.Start();
            Console.WriteLine("Start Thread for checking time!");

            if (Parameters.GeneralSetting.MethodType == MethodTypes.DynamicBoxCar_TD)
            {
                Thread childThreadDBCExclusionList = new Thread(DynamicDBCExclusionListDeque);
                childThreadDBCExclusionList.IsBackground = true;
                childThreadDBCExclusionList.Start();
                Console.WriteLine("Start Thread for DynamicBoxCar (DBC) exclusion list!");
            }

            Thread childThreadExclusionList = new Thread(DynamicExclusionListDeqeue);

            childThreadExclusionList.IsBackground = true;
            childThreadExclusionList.Start();
            Console.WriteLine("Start Thread for exclusion list!");

            using (IExactiveInstrumentAccess instrument = Connection.GetFirstInstrument())
            {
                using (m_scans = instrument.Control.GetScans(false))
                {
                    IMsScanContainer orbitrap = instrument.GetMsScanContainer(0);
                    Console.WriteLine("Waiting for scans on detector " + orbitrap.DetectorClass + "...");

                    orbitrap.AcquisitionStreamOpening += Orbitrap_AcquisitionStreamOpening;
                    orbitrap.AcquisitionStreamClosing += Orbitrap_AcquisitionStreamClosing;
                    orbitrap.MsScanArrived            += Orbitrap_MsScanArrived;

                    Thread.CurrentThread.Join(Parameters.GeneralSetting.TotalTimeInMinute * 60000);

                    orbitrap.MsScanArrived            -= Orbitrap_MsScanArrived;
                    orbitrap.AcquisitionStreamClosing -= Orbitrap_AcquisitionStreamClosing;
                    orbitrap.AcquisitionStreamOpening -= Orbitrap_AcquisitionStreamOpening;
                }
            }
        }
Beispiel #18
0
        /// <summary>
        /// Wait up to 10 seconds to see the list of parameters for scans. Before that we cannot place scans.
        /// </summary>
        /// <param name="scans">interface to use</param>
        private void WaitFor(IScans scans)
        {
            Console.WriteLine("{0:HH:mm:ss,fff} waiting for IScans interface to become ready", DateTime.Now);
            ManualResetEvent wait = new ManualResetEvent(false);

            EventHandler handler = (sender, e) => { wait.Set(); };

            scans.PossibleParametersChanged += handler;
            if ((scans.PossibleParameters != null) && (scans.PossibleParameters.Length > 0))
            {
                wait.Set();
            }
            wait.WaitOne(10000);
            scans.PossibleParametersChanged -= handler;

            if ((scans.PossibleParameters == null) || (scans.PossibleParameters.Length == 0))
            {
                throw new TimeoutException("Not connected to the instrument or something else happened.");
            }
            Console.WriteLine("{0:HH:mm:ss,fff} end of wait", DateTime.Now);
        }
Beispiel #19
0
        public static void PlaceStaticBoxCarScan(IScans m_scans, Parameters parameters)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }

            ICustomScan scan = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.BoxCarScanSetting.BoxCarMzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.BoxCarScanSetting.BoxCarMzRangeHighBound.ToString();
            scan.Values["IsolationRangeLow"]  = (parameters.BoxCarScanSetting.BoxCarMzRangeLowBound).ToString();
            scan.Values["IsolationRangeHigh"] = (parameters.BoxCarScanSetting.BoxCarMzRangeHighBound).ToString();

            scan.Values["MaxIT"]             = parameters.BoxCarScanSetting.BoxCarMaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.BoxCarScanSetting.BoxCarResolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = "0.0";
            scan.Values["NCE_NormCharge"]    = parameters.BoxCarScanSetting.BoxCarNormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            scan.Values["NCE_Factors"]       = "[]";

            scan.Values["SourceCID"]  = parameters.GeneralSetting.SourceCID.ToString("0.00");
            scan.Values["Microscans"] = parameters.BoxCarScanSetting.BoxCarMicroScans.ToString();
            scan.Values["AGC_Target"] = parameters.BoxCarScanSetting.BoxCarAgcTarget.ToString();
            scan.Values["AGC_Mode"]   = parameters.GeneralSetting.AGC_Mode.ToString();

            scan.Values["MsxInjectTargets"]   = StaticBoxCarScanTargets;
            scan.Values["MsxInjectMaxITs"]    = StaticBoxCarScanMaxIts;
            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";
            for (int i = 0; i < parameters.BoxCarScanSetting.NumberOfBoxCarScans; i++)
            {
                scan.Values["MsxInjectRanges"] = StaticBoxCarScanRanges[i];

                Console.WriteLine("{0:HH:mm:ss,fff} placing BoxCar MS1 scan", DateTime.Now);
                m_scans.SetCustomScan(scan);
            }
        }
 /// <summary>
 /// Runs the scan
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='scanName'>
 /// </param>
 /// <param name='body'>
 /// </param>
 public static OperationResponse Run(this IScans operations, string dataSourceName, string scanName, ScanRunProperties body = default(ScanRunProperties))
 {
     return(operations.RunAsync(dataSourceName, scanName, body).GetAwaiter().GetResult());
 }
Beispiel #21
0
        public static void PlaceMS2Scan(IScans m_scans, Parameters parameters, double mz)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }

            double Range = parameters.MS1IonSelecting.IsolationWindow;
            string xl    = (mz - Range).ToString("0.000");
            string xh    = (mz + Range).ToString("0.000");

            if (mz - Range < 50.0)
            {
                Console.WriteLine("placing data dependent ms2 scan wrong, the Ms2MzRangeLowBound should larger than 50!!!");

                return;
            }
            ICustomScan scan = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.MS2ScanSetting.MS2MzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.MS2ScanSetting.MS2MzRangeHighBound.ToString(); //TO THINK: Dynamic range as MqLive?
            scan.Values["IsolationRangeLow"]  = xl;
            scan.Values["IsolationRangeHigh"] = xh;
            scan.Values["Resolution"]         = parameters.MS2ScanSetting.MS2Resolution.ToString();

            scan.Values["MaxIT"]             = parameters.MS2ScanSetting.MS2MaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.MS2ScanSetting.MS2Resolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = parameters.MS2ScanSetting.NCE.ToString();
            scan.Values["NCE_NormCharge"]    = parameters.MS1IonSelecting.NormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            if (parameters.MS2ScanSetting.NCE_factors != "null")
            {
                scan.Values["NCE_Factors"] = parameters.MS2ScanSetting.NCE_factors;
            }
            scan.Values["SourceCID"]  = parameters.GeneralSetting.SourceCID.ToString("0.00");
            scan.Values["Microscans"] = parameters.MS2ScanSetting.MS2MicroScans.ToString();
            scan.Values["AGC_Target"] = parameters.MS2ScanSetting.MS2AgcTarget.ToString();
            scan.Values["AGC_Mode"]   = parameters.GeneralSetting.AGC_Mode.ToString();


            scan.Values["MsxInjectRanges"]    = "[]";
            scan.Values["MsxInjectTargets"]   = "[]";
            scan.Values["MsxInjectMaxITs"]    = "[]";
            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";

            //Console.WriteLine("++++++++++++++++++");
            //Console.WriteLine("Target Isolation Mass: {0}, {1}", xl, xh);
            //foreach (var v in scan.Values)
            //{
            //    Console.WriteLine(v);
            //}

            ////This is the code where we find all the scan settings.
            ////foreach (var item in m_scans.PossibleParameters)
            ////{
            ////    Console.WriteLine(item.Name + "----" + item.DefaultValue + "----" + item.Help + "----" + item.Selection);
            ////}

            Console.WriteLine("{0:HH:mm:ss,fff} placing data dependent ms2 scan {1}", DateTime.Now, mz);
            m_scans.SetCustomScan(scan);
        }
 /// <summary>
 /// List scans in data source
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='skipToken'>
 /// </param>
 public static ScanList ListByDataSource(this IScans operations, string dataSourceName, string skipToken = default(string))
 {
     return(operations.ListByDataSourceAsync(dataSourceName, skipToken).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Deletes the scan associated with the data source
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='scanName'>
 /// </param>
 public static void Delete(this IScans operations, string dataSourceName, string scanName)
 {
     operations.DeleteAsync(dataSourceName, scanName).GetAwaiter().GetResult();
 }
Beispiel #24
0
        public void RunMachine(Planner runManager, string filename, bool auto)
        {
            runProgram = runManager;

            // Instrument access setup stuff.
            if (!auto)
            {
                Console.WriteLine("Ready. (Press any key.)");
                Console.ReadKey();
            }


            string device_registration = ((IntPtr.Size > 4) ? @"SOFTWARE\Wow6432Node\Finnigan\Xcalibur\Devices\" : @"SOFTWARE\Finnigan\Xcalibur\Devices\") + "Thermo Exactive";
            string asmName             = "None";
            string typeName            = "None";

            RegistryKey key = Registry.LocalMachine.OpenSubKey(device_registration);

            Debug.Assert(key != null);
            asmName  = (string)key.GetValue("ApiFileName_Clr2_32_V1", null);
            typeName = (string)key.GetValue("ApiClassName_Clr2_32_V1", null);

            Console.WriteLine("ASM: " + asmName + "\nType: " + typeName);

            Directory.SetCurrentDirectory(Path.GetDirectoryName(asmName));
            Assembly asm     = Assembly.LoadFrom(asmName);
            object   api_obj = asm.CreateInstance(typeName);

            container = api_obj as IInstrumentAccessContainer;
            Debug.Assert(container != null);

            instrument = container.Get(1);
            Debug.Assert(instrument != null);

            iexactive = instrument as IExactiveInstrumentAccess;
            Debug.Assert(iexactive != null);

            control     = iexactive.Control;
            acquisition = control.Acquisition as IExactiveAcquisition;
            scanner     = control.GetScans(false);

            runProgram.Initialize(scanner);

            // Attaching a simple function to on-new-scan event; equivalent of wx.Bind.
            IMsScanContainer scancontainer = iexactive.GetMsScanContainer(0);

            scancontainer.AcquisitionStreamOpening += new EventHandler <MsAcquisitionOpeningEventArgs>(goahead_Response);
            scancontainer.AcquisitionStreamClosing += new EventHandler(stop_Response);
            scancontainer.MsScanArrived            += new EventHandler <MsScanEventArgs>(scanArrived_Response);
            scanner.CanAcceptNextCustomScan        += new EventHandler(readyForScan_Response);

            acquisition.StateChanged += new EventHandler <StateChangedEventArgs>(note_state_change);

            machine_voltage = control.InstrumentValues.Get("SourceSprayVoltage");
            machine_voltage.ContentChanged += new EventHandler <Thermo.Interfaces.InstrumentAccess_V1.Control.ContentChangedEventArgs>(voltageChangeResponse);
            Thread.Sleep(100); // Gives machine_voltage a chance to get its act together.
            current_voltage = Double.Parse(machine_voltage.Content.Content);
            change_voltage(0);

            // Submitting method and running.
            Console.WriteLine("Starting State=" + acquisition.State.SystemState);
            // Attempts to control machine state; should be "On" after this code block.
            ChangeResult set_to_standby_result = acquisition.SetMode(acquisition.CreateForcedStandbyMode());

            acquisition.WaitFor(TimeSpan.FromSeconds(3), SystemMode.Standby);
            ChangeResult set_to_on_result = acquisition.SetMode(acquisition.CreateOnMode());

            acquisition.WaitFor(TimeSpan.FromSeconds(3), SystemMode.On);

            authorized_for_run = false;
            accepting_scans    = false;

            IAcquisitionWorkflow methodWorkflow = null;

            methodWorkflow             = acquisition.CreatePermanentAcquisition();
            methodWorkflow.RawFileName = filename; // Numbers are appended to file name on overwrite.
            if (USE_CONTACT_CLOSURE)
            {
                ITrigger ccTrigger = acquisition.CreateTrigger("WaitForContactClosure");
                methodWorkflow.Trigger = ccTrigger;
            }
            else
            {
                authorized_for_run = true;
                Console.WriteLine("NON-CONTACT CLOSURE START.");
            }


            ChangeResult start_acq_result = acquisition.StartAcquisition(methodWorkflow);

            //methodWorkflow.SingleProcessingDelay = 600.0D; // Doesn't work!
            run_is_active = true;

            intendedRunTime = TimeSpan.FromSeconds(intended_run_seconds);
            runTimeKeeper   = new Stopwatch();


            Console.WriteLine("Waiting for goahead...");
            while (!authorized_for_run)
            {
                Thread.Sleep(100);
            }
            Console.WriteLine("Got goahead.");
            Thread.Sleep(column_wait_time_seconds * 1000);
            Console.WriteLine("Column wait over, setting charge up.");
            change_voltage(working_voltage);

            bool got_to_workable_state = acquisition.WaitFor(TimeSpan.FromSeconds(5), SystemMode.On, SystemMode.DirectControl);

            if (!got_to_workable_state)
            {
                Console.WriteLine("Invalid state " + acquisition.State.SystemMode + " before scan submission.  Done.");
                if (!auto)
                {
                    Console.ReadKey();
                }
                Environment.Exit(0);
            }

            Console.WriteLine("Starting.");

            runTimeKeeper.Start(); // This had been before contact closure confirmation!

            accepting_scans = true;
            Thread scan_handler = new Thread(scan_assignment_handler);

            scan_handler.Start();


            //Debug.Assert(!acquisition.WaitFor(intendedRunTime, SystemMode.Standby)); // Wait while things run; state shouldn't change.
            // COULD PROBABLY do something with AcquisitionStreamClosing instead.
            Console.WriteLine("In run loop.");
            while (runTimeKeeper.Elapsed < intendedRunTime)
            {
                Thread.Sleep(100);
            }
            Console.WriteLine("Closing up.");
            authorized_for_run = false;
            accepting_scans    = false;



            //run_is_active = false;
            //scan_handler.Abort();
            scan_handler.Join();
            Console.WriteLine("Joined.");

            change_voltage(0);

            ChangeResult cancel_result = acquisition.CancelAcquisition();

            Console.WriteLine("Cancellation result: " + cancel_result.ToString());

            Console.WriteLine("Setting mode to standby.");
            ChangeResult setmode2_result = acquisition.SetMode(acquisition.CreateForcedStandbyMode());

            Console.WriteLine("Set mode result: " + setmode2_result.ToString());

            //if (run_is_active)
            //{
            //    Console.WriteLine("Acquisition closed immediately/already.");
            //} else
            //{
            //    Console.WriteLine("Waiting for acquisition close event.");
            //    Stopwatch CloseTimer = new Stopwatch();
            //    CloseTimer.Start();
            //    while (run_is_active)
            //    {
            //        Thread.Sleep(100);
            //    }
            //    Console.WriteLine("Close event received after " + CloseTimer.Elapsed.ToString() + " seconds.");

            //}
            runManager.Cleanup();

            Console.WriteLine("Safety wait.");
            Thread.Sleep(15 * 1000); // Should match SingleProcessingDelay used by Planner.

            Console.WriteLine("Done.");
            if (!auto)
            {
                Console.ReadKey();
            }

            Environment.Exit(0);
        }
 /// <summary>
 /// Creates an instance of a scan
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='scanName'>
 /// </param>
 /// <param name='body'>
 /// </param>
 public static Scan CreateOrUpdate(this IScans operations, string dataSourceName, string scanName, Scan body)
 {
     return(operations.CreateOrUpdateAsync(dataSourceName, scanName, body).GetAwaiter().GetResult());
 }
Beispiel #26
0
 public abstract void Initialize(IScans machine_scan_manager);
Beispiel #27
0
        private void button3_Click(object sender, EventArgs e)
        {
            _instAccess = _instAccessContainer.Get(1);

            instrumentIdTB.Text        = _instAccess.InstrumentId.ToString();
            instrumentNameTB.Text      = _instAccess.InstrumentName;
            instrumentConnectedTB.Text = _instAccess.Connected.ToString();

            _instControl = _instAccess.Control;
            _instAccess.ConnectionChanged     += _instAccess_ConnectionChanged;
            _instAccess.ContactClosureChanged += _instAccess_ContactClosureChanged;


            _instAcq = _instControl.Acquisition;
            _instAcq.StateChanged             += Acquisition_StateChanged;
            _instAcq.AcquisitionStreamClosing += _instAcq_AcquisitionStreamClosing;
            _instAcq.AcquisitionStreamOpening += _instAcq_AcquisitionStreamOpening;

            UpdateState(_instAcq.State);

            _instValues = _instControl.InstrumentValues;
            _scans      = _instControl.GetScans(false);
            _scans.CanAcceptNextCustomScan   += _scans_CanAcceptNextCustomScan;
            _scans.PossibleParametersChanged += _scans_PossibleParametersChanged;

            scanProperties = new DataTable();
            var propColumn = scanProperties.Columns.Add("Property", typeof(string));

            propColumn.ReadOnly = true;
            scanProperties.Columns.Add("Value", typeof(string));
            scanProperties.Columns.Add("Selection", typeof(string)).ReadOnly = true;
            scanProperties.Columns.Add("Help", typeof(string)).ReadOnly      = true;

            BindingSource source = new BindingSource();

            source.DataSource = scanProperties;

            dataGridView1.DataSource = source;

            UpdateScanProperties();

            _syringe = _instControl.SyringePumpControl;
            _syringe.ParameterValueChanged += _syringe_ParameterValueChanged;
            _syringe.StatusChanged         += _syringe_StatusChanged;
            updateSyringeReadbacks(true);

            _instMSScanContainer = _instAccess.GetMsScanContainer(0);


            // Analog Values
            int numOfAnalogs = _instAccess.CountAnalogChannels;

            _analogTrace = new IAnalogTraceContainer[numOfAnalogs];
            for (int i = 0; i < numOfAnalogs; i++)
            {
                var trace = _analogTrace[i] = _instAccess.GetAnalogTraceContainer(i);
                if (trace != null)
                {
                    analogGroupBoxes[i].Text = trace.DetectorClass;
                }
            }
        }
 /// <summary>
 /// Cancels a scan
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='scanName'>
 /// </param>
 /// <param name='body'>
 /// </param>
 public static void Cancel(this IScans operations, string dataSourceName, string scanName, CancelScanRequest body)
 {
     operations.CancelAsync(dataSourceName, scanName, body).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Cancels a scan
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='scanName'>
 /// </param>
 /// <param name='body'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task CancelAsync(this IScans operations, string dataSourceName, string scanName, CancelScanRequest body, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.CancelWithHttpMessagesAsync(dataSourceName, scanName, body, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <summary>
 /// Gets a scan information
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dataSourceName'>
 /// </param>
 /// <param name='scanName'>
 /// </param>
 public static Scan Get(this IScans operations, string dataSourceName, string scanName)
 {
     return(operations.GetAsync(dataSourceName, scanName).GetAwaiter().GetResult());
 }