示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InstrumentManager_InstrumentChanged(object sender, EventArgs e)
        {
            if (!IsHandleCreated || IsDisposed)
            {
                return;
            }

            List <InstrumentBase> insts = new List <InstrumentBase>();

            foreach (var inst in InstrumentManager.GetAllInstruments())
            {
                foreach (var i in instruments)
                {
                    if (i.DeviceID == inst.DeviceID && i.UnitNumber == inst.UnitNumber)
                    {
                        insts.Add(inst);
                    }
                }
            }

            instruments = insts;
            if (insts.Count == 0)
            {
                Close();
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService = null;

            if (provider != null)
            {
                editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            }

            if (editorService == null)
            {
                return(value);
            }

            bool          singleSel = true;
            TMS5220Timbre tim       = context.Instance as TMS5220Timbre;

            TMS5220Timbre[] tims = value as TMS5220Timbre[];
            if (tims != null)
            {
                tim       = tims[0];
                singleSel = false;
            }

            TMS5220 inst = null;

            try
            {
                //InstrumentManager.ExclusiveLockObject.EnterReadLock();

                inst = InstrumentManager.FindParentInstrument(InstrumentType.TMS5220, tim) as TMS5220;
            }
            finally
            {
                //InstrumentManager.ExclusiveLockObject.ExitReadLock();
            }

            using (FormLpcEditor frm = new FormLpcEditor(inst, tim, singleSel))
            {
                frm.Tag = context;

                frm.LpcData       = (byte[])value;
                frm.ValueChanged += Frm_ValueChangedByte;

                DialogResult dr = frm.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    value = frm.LpcData;
                }
                else if (value != null)
                {
                    value = ((byte[])value).Clone();
                }
                else
                {
                    value = new byte[] { };
                }
            }
            return(value);
        }
示例#3
0
 internal AccountResetService(Account account, InstrumentManager instrumentManager)
 {
     _account            = account;
     _instrumentManager  = instrumentManager;
     _systemResetter     = new SystemResetter(account, instrumentManager);
     _instrumentResetter = new InstrumentResetter(account, instrumentManager);
 }
        private void _client_BatchContractDetailsEnd(object sender, ContractDetailsEndEventArgs e)
        {
            if (_tmpContractDetails.Count == 1)
            {
                var        im         = new InstrumentManager();
                Instrument instrument = ContractToInstrument(_tmpContractDetails[0]);

                if (instrument != null && TryAddInstrument(im, instrument))
                {
                    //successfully added the symbol
                    _symbolsAdded.Add(instrument.Symbol);
                }
            }

            _tmpContractDetails.Clear();

            if (_queuedSymbols.Count == 0)
            {
                //in this case, we have completed all the requests
                BatchRequestJobCompleted();
            }
            else
            {
                //we're not done, send the next request
                SendNextRequestInBatch();
            }
        }
 internal InstrumentResetter(Account account, InstrumentManager instrumentManager)
 {
     _account           = account;
     _instrumentManager = instrumentManager;
     _instrumentDayClosePriceFactory = new InstrumentDayClosePriceFactory(account);
     _instalmentResetter             = new Lazy <InstalmentResetter>(() => new InstalmentResetter(_instrumentManager, _account));
 }
示例#6
0
        public virtual void Initialize()
        {
            PreValidate();

            InstrumentManager.InstrumentKeys = InstrumentKeys;
            InstrumentManager.Initialize();

            PortfolioManager.Initialize();

            Strategy.Context = this;
            Strategy.Initialize();

            EventSources = EventSources.Union(new[] { TradingEngine }).ToArray();
            foreach (var eventSource in EventSources)
            {
                eventSource.InstrumentKeys = InstrumentKeys;
                eventSource.FromTime       = FromTime;
                eventSource.ToTime         = ToTime;
                eventSource.Initialize();
                eventSource.NewEvent += (sender, e) => Strategy.EventEngine.SendEvent(e.Event);
            }
            TradingEngine.Initialize();

            PostValidate();
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static EnvironmentSettings SaveEnvironmentSettings()
        {
            var es = new EnvironmentSettings();

            try
            {
                InstrumentManager.InstExclusiveLockObject.EnterReadLock();

                InstrumentManager.SaveSettings(es);
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(Exception))
                {
                    throw;
                }
                else if (ex.GetType() == typeof(SystemException))
                {
                    throw;
                }

                MessageBox.Show(ex.ToString());
            }
            finally
            {
                InstrumentManager.InstExclusiveLockObject.ExitReadLock();
            }
            return(es);
        }
示例#8
0
        /// <summary>
        /// 获取主力合约
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="tradingDay"></param>
        /// <returns></returns>
        public static List <Instrument> GetMainFutures(this InstrumentManager manager, DateTime?tradingDay = null)
        {
            var framework = manager.GetFramework();

            if (!tradingDay.HasValue)
            {
                tradingDay = TradingCalendar.Instance.GetPrevTradingDay(DateTime.Today);
            }
            return(GetInstrumentList(framework, InstrumentType.Future, tradingDay, true));
        }
示例#9
0
        /// <summary>
        /// 获取上市合约
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="tradingDay"></param>
        /// <returns></returns>
        public static List <Instrument> GetLiveFutures(this InstrumentManager manager, DateTime?tradingDay = null)
        {
            var framework = manager.GetFramework();

            if (!tradingDay.HasValue)
            {
                tradingDay = DateTime.Today;
            }
            return(GetInstrumentList(framework, InstrumentType.Future, tradingDay));
        }
示例#10
0
    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("singletone error!");
            Destroy(gameObject);
            return;
        }

        instance = this;
    }
示例#11
0
        public override void Run()
        {
            Instrument spreadInsturment = InstrumentManager.Get("NGF 01-15 vs NGG 02-15");

            // Add spread instrument if needed.
            if (spreadInsturment == null)
            {
                spreadInsturment = new Instrument(InstrumentType.Synthetic, "NGF 01-15 vs NGG 02-15");

                InstrumentManager.Add(spreadInsturment);
            }


            spreadInsturment.Legs.Clear();


            // Add legs for spread instrument if needed.
            if (spreadInsturment.Legs.Count == 0)
            {
                spreadInsturment.Legs.Add(new Leg(InstrumentManager.Get("NGF17after"), 1));
                spreadInsturment.Legs.Add(new Leg(InstrumentManager.Get("NGG17after"), 1));
            }


            // Main strategy.
            strategy = new Strategy(framework, "SpreadTrading");

            // Create BuySide strategy and add trading instrument.
            MyStrategy buySide = new MyStrategy(framework, "BuySide");

            buySide.Instruments.Add(spreadInsturment);

            // Create SellSide strategy.
            SpreadSellSide sellSide = new SpreadSellSide(framework, "SellSide");

            sellSide.Global[SpreadSellSide.barSizeCode] = barSize;

            // Set SellSide as data and execution provider for BuySide strategy.
            buySide.DataProvider      = sellSide;
            buySide.ExecutionProvider = sellSide;

            // Add strategies to main.
            strategy.AddStrategy(buySide);
            strategy.AddStrategy(sellSide);

            // Set DataSimulator's dates.
            DataSimulator.DateTime1 = new DateTime(2014, 11, 23);            // 1 day before real start
            DataSimulator.DateTime2 = new DateTime(2014, 11, 29);            // 1 day after real end

            BarFactory.Clear();

            // Run.
            StartStrategy();
        }
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
     }
 }
示例#13
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         DontDestroyOnLoad(this.gameObject);
         instance = this;
     }
 }
示例#14
0
        public override void Run()
        {
            Instrument spreadInsturment = InstrumentManager.Get("AAPL vs MSFT");

            // Add spread instrument if needed.
            if (spreadInsturment == null)
            {
                spreadInsturment = new Instrument(InstrumentType.Stock, "AAPL vs MSFT");

                InstrumentManager.Add(spreadInsturment);
            }

            spreadInsturment.Legs.Clear();

            // Add legs for spread instrument if needed.
            if (spreadInsturment.Legs.Count == 0)
            {
                spreadInsturment.Legs.Add(new Leg(InstrumentManager.Get("AAPL"), 1));
                spreadInsturment.Legs.Add(new Leg(InstrumentManager.Get("MSFT"), -12));
            }

            // Main strategy.
            strategy = new Strategy(framework, "SpreadTrading");

            // Create BuySide strategy and add trading instrument.
            MyStrategy buySide = new MyStrategy(framework, "BuySide");

            buySide.Instruments.Add(spreadInsturment);

            // Create SellSide strategy.
            SpreadSellSide sellSide = new SpreadSellSide(framework, "SellSide");

            sellSide.Global[SpreadSellSide.barSizeCode] = barSize;

            // Set SellSide as data and execution provider for BuySide strategy.
            buySide.DataProvider      = sellSide;
            buySide.ExecutionProvider = sellSide;

            // Add strategies to main.
            strategy.AddStrategy(buySide);
            strategy.AddStrategy(sellSide);

            // Set DataSimulator's dates.
            DataSimulator.DateTime1 = new DateTime(2013, 01, 01);
            DataSimulator.DateTime2 = new DateTime(2013, 12, 31);

            // Add 1 minute bars (60 seconds) for spread instrument.
            BarFactory.Add(spreadInsturment, BarType.Time, barSize);

            // Run.
            StartStrategy();
        }
示例#15
0
        /// <summary>
        /// 更新期货上市合约
        /// </summary>
        /// <param name="manager"></param>
        public static void UpdateLiveFutures(this InstrumentManager manager, DateTime?tradingDay = null)
        {
            var framework = manager.GetFramework();
            var list      = GetLiveFutures(manager, tradingDay);

            foreach (var item in list)
            {
                if (!framework.InstrumentManager.Contains(item.Symbol))
                {
                    framework.InstrumentManager.Add(item);
                }
            }
        }
示例#16
0
        static public Instrument[] UserInputInstruments(InstrumentManager im)
        {
            List <Instrument> rtn = new List <Instrument>();

            string[] symbols = Interaction.InputBox("輸入商品代號", "", "BTC-PERPETUAL,ETH-PERPETUAL,BTC-25SEP20-8000-C,BTC-25SEP20-8000-P").Split(',');//

            foreach (string s in symbols)
            {
                rtn.Add(CreateInstrument(s, im));
            }

            return(rtn.ToArray());
        }
示例#17
0
        public AccountRisk(Account account, IDBRow dr, InstrumentManager manager)
            : base(account)
        {
            _account            = account;
            _instrumentManager  = manager;
            _riskDataCalculator = new RiskDataCalculator(account, manager);
            ConstructParams constructParams = new AccountRisk.ConstructParams();

            constructParams.AlertLevel         = (AlertLevel)dr["AlertLevel"];
            constructParams.AlertTime          = null;
            constructParams.AlertLevelAfterCut = constructParams.AlertLevel;
            this.Parse(constructParams);
        }
示例#18
0
        /// <summary>
        /// </summary>
        /// <param name="account"></param>
        public AccountRisk(Account account, InstrumentManager manager)
            : base(account)
        {
            _account            = account;
            _instrumentManager  = manager;
            _riskDataCalculator = new RiskDataCalculator(account, manager);
            ConstructParams constructParams = new ConstructParams();

            constructParams.AlertLevel         = iExchange.Common.AlertLevel.Normal;
            constructParams.AlertLevelAfterCut = constructParams.AlertLevel;
            constructParams.AlertTime          = null;
            this.Parse(constructParams);
        }
示例#19
0
        public void RefreshCollections()
        {
            Tags.Clear();
            Instruments.Clear();

            using (var context = new MyDBContext())
            {
                Tags.AddRange(context.Tags.ToList());

                var im = new InstrumentManager();
                Instruments.AddRange(im.FindInstruments(context));
            }
        }
示例#20
0
        public void RefreshCollections()
        {
            Tags.Clear();
            Instruments.Clear();

            using (var context = new MyDBContext())
            {
                Tags.AddRange(context.Tags.ToList());

                var im = new InstrumentManager();
                Instruments.AddRange(im.FindInstruments(context));
            }
        }
示例#21
0
        private void _onRtnDepthMarketData(object sender, ref DepthMarketDataNClass marketData)
        {
            Instrument inst = InstrumentManager.GetInstrument(marketData.InstrumentID);

            if (inst == null)
            {
                return;
            }
            //计算量的差值
            double vol    = 0;
            double difVol = 0;

            if (volumeMap.TryGetValue(marketData.InstrumentID, out vol))
            {
                if (marketData.Volume < vol)
                {
                    return;
                }
                difVol = marketData.Volume - vol;
                vol    = marketData.Volume;
            }
            else
            {
                volumeMap.Add(marketData.InstrumentID, marketData.Volume);
                return;
            }
            //
            Tick tick = new Tick(inst
                                 , marketData.LastPrice
                                 , marketData.Bids.Length > 0 ? marketData.Bids[0].Price : 0
                                 , marketData.Bids.Length > 0 ? marketData.Bids[0].Size : 0
                                 , marketData.Asks.Length > 0 ? marketData.Asks[0].Price : 0
                                 , marketData.Asks.Length > 0 ? marketData.Asks[0].Size : 0
                                 , difVol
                                 , marketData.OpenInterest
                                 , new DateTime(
                                     marketData.ActionDay / 10000
                                     , marketData.ActionDay / 100 % 100
                                     , marketData.ActionDay % 100
                                     , marketData.UpdateTime / 10000
                                     , marketData.UpdateTime / 100 % 100
                                     , marketData.UpdateTime % 100
                                     , marketData.UpdateMillisec)
                                 , marketData.UpperLimitPrice
                                 , marketData.LowerLimitPrice);

            //
            mOnTick?.Invoke(tick);
        }
示例#22
0
        static public Instrument CreateInstrument(string symbol, InstrumentManager im)
        {
            Instrument instru;

            instru = new Instrument(InstrumentType.Stock, symbol);

            if (!im.Contains(symbol))
            {
                im.Add(instru, false);
            }

            instru = im.Instruments[symbol];

            return(instru);
        }
        /// <summary>
        /// 获取指定的合约列表,如果合约不存在就从数据中心下载。
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="symbols"></param>
        public static List <Instrument> GetInstruments(this InstrumentManager manager, params string[] symbols)
        {
            var framework = manager.GetFramework();
            var result    = new List <Instrument>();
            var missing   = new HashSet <string>();

            foreach (var item in symbols)
            {
                if (Find(result, item) != null)
                {
                    continue;
                }
                var inst = manager.Get(item);
                if (inst != null)
                {
                    result.Add(inst);
                }
                else
                {
                    if (!missing.Contains(item))
                    {
                        missing.Add(item);
                    }
                }
            }

            if (missing.Count > 0)
            {
                var list = GetInstrumentList(framework);
                foreach (var item in missing)
                {
                    var inst = Find(list, item);
                    if (inst != null)
                    {
                        manager.Add(inst);
                        result.Add(inst);
                    }
                }
            }

            return(result);

            Instrument Find(List <Instrument> instruments, string symbol)
            {
                return(instruments.SingleOrDefault(n =>
                                                   n.Symbol == symbol || n.GetSymbol(QuantBoxConst.PIdHisData) == symbol));
            }
        }
示例#24
0
        /// <summary>
        /// 更新期货期权上市合约
        /// </summary>
        /// <param name="manager"></param>
        public static void UpdateLiveFutureOptions(this InstrumentManager manager, bool includeEtf = false, DateTime?tradingDay = null)
        {
            var framework = manager.GetFramework();
            var list      = GetLiveFutureOptions(manager, tradingDay);

            foreach (var item in list)
            {
                if (!includeEtf && Regex.IsMatch(item.Symbol, @"^\d+$"))
                {
                    continue;
                }
                if (!framework.InstrumentManager.Contains(item.Symbol))
                {
                    framework.InstrumentManager.Add(item);
                }
            }
        }
示例#25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InstrumentManager_InstrumentChanged(object sender, EventArgs e)
        {
            if (!IsHandleCreated || IsDisposed)
            {
                return;
            }

            foreach (var inst in InstrumentManager.GetAllInstruments())
            {
                if (Instrument.DeviceID == inst.DeviceID && Instrument.UnitNumber == inst.UnitNumber)
                {
                    return;
                }
            }
            DialogResult = DialogResult.Cancel;
            Close();
        }
示例#26
0
        private void _onRtnTrade(object sender, ref TradeField field)
        {
            Instrument inst = InstrumentManager.GetInstrument(field.InstrumentID);

            if (inst == null)
            {
                return;
            }
            //
            BrokerTrade trade = new BrokerTrade(inst
                                                , ConvertUtil.ConvertExchange(field.ExchangeID)
                                                , ConvertUtil.ConvertDirectionType(field.Side)
                                                , (long)field.Qty
                                                , field.Price
                                                , ConvertUtil.ConvertOpenCloseType(field.OpenClose)
                                                , DateTime.Now);

            mOnTrade?.Invoke(trade);
        }
示例#27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <param name="inst"></param>
        /// <param name="target"></param>
        public static void DrawOsc(PaintEventArgs e, InstrumentBase inst, Control target, Color color)
        {
            int[][] data = InstrumentManager.GetLastOutputBuffer(inst);

            e.Graphics.Clear(target.BackColor);

            int w = target.ClientSize.Width;
            int h = target.ClientSize.Height;

            if (data != null)
            {
                using (Pen p = new Pen(color))
                {
                    int max = h * 4;
                    for (int ch = 0; ch < 2; ch++)
                    {
                        if (data[ch] != null)
                        {
                            for (int i = 0; i < data[ch].Length; i++)
                            {
                                int dt = data[ch][i];
                                max = Math.Max(Math.Abs(dt), max);
                            }
                        }
                    }
                    max += max / 10;

                    if (data[0] != null)
                    {
                        drawCore(e, p, data[0], w / 2 - 1, h / 2, 0, max);
                    }
                    if (data[1] != null)
                    {
                        drawCore(e, p, data[1], w / 2 - 1, h / 2, w / 2 + 1, max);
                    }
                }
            }
            using (Pen p = new Pen(color))
            {
                //e.Graphics.DrawLine(p, w / 2 - 1, 0, w / 2 - 1, h);
                e.Graphics.DrawLine(p, w / 2, 0, w / 2, h);
            }
        }
示例#28
0
        private void _OnRspQryInvestorPosition(object sender, ref PositionField field, int size1, bool bIsLast)
        {
            Instrument inst = InstrumentManager.GetInstrument(field.InstrumentID);

            if (inst == null)
            {
                return;
            }
            //
            BrokerPosition brokerPos = new BrokerPosition(inst
                                                          , ConvertUtil.ConvertExchange(field.ExchangeID)
                                                          , field.Side == PositionSide.Long ? DirectionType.Buy : DirectionType.Sell
                                                          , (long)field.Position
                                                          , (long)field.TodayPosition
                                                          , (long)field.HistoryPosition
                                                          , (long)field.HistoryFrozen
                                                          , (long)field.TodayBSPosition
                                                          , (long)field.TodayBSFrozen);

            mOnBroderPosition?.Invoke(brokerPos);
        }
示例#29
0
        private bool TryAddInstrument(InstrumentManager instrumentSource, Instrument newInstrument, bool showDialogs = true)
        {
            try
            {
                if (instrumentSource.AddInstrument(newInstrument) != null)
                {
                    AddedInstruments.Add(newInstrument);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                if (showDialogs)
                {
                    _dialogService.ShowMessageAsync(this, "Error", ex.Message);
                }

                Application.Current.Dispatcher.Invoke(() => _logger.Log(NLog.LogLevel.Warn, ex, "Error adding instrument"));
            }
            return(false);
        }
示例#30
0
        unsafe public static void LoadData(byte *data, int length)
        {
            try
            {
                string text = StringCompressionUtility.Decompress(Encoding.Unicode.GetString(data, length));
                InstrumentManager.ClearAllInstruments();
                var settings = JsonConvert.DeserializeObject <EnvironmentSettings>(text, Program.JsonAutoSettings);
                InstrumentManager.RestoreSettings(settings);
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(Exception))
                {
                    throw;
                }
                else if (ex.GetType() == typeof(SystemException))
                {
                    throw;
                }

                MessageBox.Show(ex.ToString());
            }
        }
示例#31
0
        private void ExecuteAddSelectedInstruments(IList selectedInstruments)
        {
            if (selectedInstruments == null)
            {
                throw new ArgumentNullException("selectedInstruments");
            }
            if (selectedInstruments.Count == 0)
            {
                return;
            }

            int count            = 0;
            var instrumentSource = new InstrumentManager();

            foreach (Instrument newInstrument in selectedInstruments)
            {
                if (TryAddInstrument(instrumentSource, newInstrument))
                {
                    count++;
                }
            }

            Status = string.Format("{0}/{1} instruments added.", count, selectedInstruments.Count);
        }
示例#32
0
        private bool TryAddInstrument(InstrumentManager instrumentSource, Instrument newInstrument, bool showDialogs = true)
        {
            try
            {
                if (instrumentSource.AddInstrument(newInstrument) != null)
                {
                    AddedInstruments.Add(newInstrument);
                    return true;
                }
            }
            catch (Exception ex)
            {
                if (showDialogs)
                {
                    _dialogService.ShowMessageAsync(this, "Error", ex.Message);
                }

                Application.Current.Dispatcher.Invoke(() => _logger.Log(NLog.LogLevel.Warn, ex, "Error adding instrument"));
            }
            return false;
        }
示例#33
0
        void ClarityEngine_OnGenericError(InstrumentManager Source, Exception thrown)
        {
            if (this.InvokeRequired)
            {
                IME myDel = ClarityEngine_OnGenericError;
                this.Invoke(myDel, new object[] { Source, thrown });
            }
            else
            {
                btnExecuteProtocols.Enabled = true;
                btnCancelProtocolExecution.Enabled = false;
                ShowError("Unspecified Error", thrown);
                UpdateForm();

                string ErrorMessage = thrown.Message;
                AddErrorLogText(ErrorMessage);
            }
        }
示例#34
0
        void ClarityEngine_OnProtocolExecutionUpdates(InstrumentManager Source, EventArgs e)
        {
            if (this.InvokeRequired)
            {

                IM myDel=ClarityEngine_OnProtocolExecutionUpdates;
                this.Invoke(myDel,new object[] {Source,e});
            }
            else
            {
                lock (Source.LoadedProtocols)
                {
                    try
                    {
                        UpdateForm();
                        try
                        {
                            string toUse = Source.LoadedProtocols.CurrentProtocolInUse.Instructions[Source.LoadedProtocols.CurrentProtocolInUse.NextItemToRun - 1].ToString();
                            StatusLabel.Text = "Performing operation: " +toUse;
                        }
                        catch { }
                    }
                    catch { }
                }
            }
        }
示例#35
0
文件: Twister.cs 项目: RobAmos/osla
 void PM_onProtocolPause(InstrumentManager source, TimeSpan TS)
 {
     if (TS.TotalMinutes >= pMinutesRequiredForVerticalMotorShutdown)
     {
         DisableVerticalMotor();
     }
 }
示例#36
0
        void ClarityEngine_OnErrorDuringProtocolExecution(InstrumentManager Source, Exception thrown)
        {
            if (this.InvokeRequired)
            {
                IME myDel= ClarityEngine_OnErrorDuringProtocolExecution;
                this.Invoke(myDel, new object[] { Source, thrown});
            }
            else
            {
                StatusLabel.Text = "Procedure ended with errors";
                UpdateInstrumentStatus();

                btnRetryLastInstruction.Enabled = true;
                pnlFailure.Visible = true;
                lblFailure.Text = "The Last Instruction Failed To Run, Please recover the machines and retry or delete the protocol, Do not reattempt a macro instruction";
                if (Source.GetLastFailedInstruction() != null)
                {
                    lblFailureInstructionName.Text = "Would you like to reattempt: " + Source.GetLastFailedInstruction().ToString();
                }
                else
                {
                    btnRetryLastInstruction.Enabled = false;
                    AddErrorLogText("\nWeird command failure, the last instruction is not available");

                }
                btnExecuteProtocols.Enabled = true;
                btnCancelProtocolExecution.Enabled = false;
                TimeToGo.Stop();
                TimeToGo.Text = "Error";
                if (thrown is ProtcolExcecutionError)
                {
                    this.AddErrorLogText(((ProtcolExcecutionError)thrown).MakeErrorReport());
                }

                ShowError("Failed To Run Protocol", thrown);
            }
        }
示例#37
0
        private void _client_BatchContractDetailsEnd(object sender, ContractDetailsEndEventArgs e)
        {
            if (_tmpContractDetails.Count == 1)
            {
                var im = new InstrumentManager();
                Instrument instrument = ContractToInstrument(_tmpContractDetails[0]);

                if (instrument != null && TryAddInstrument(im, instrument))
                {
                    //successfully added the symbol
                    _symbolsAdded.Add(instrument.Symbol);
                }
            }

            _tmpContractDetails.Clear();

            if (_queuedSymbols.Count == 0)
            {
                //in this case, we have completed all the requests
                BatchRequestJobCompleted();
            }
            else
            {
                //we're not done, send the next request
                SendNextRequestInBatch();
            }
        }
示例#38
0
        private void ExecuteAddSelectedInstruments(IList selectedInstruments)
        {
            if (selectedInstruments == null) throw new ArgumentNullException("selectedInstruments");
            if (selectedInstruments.Count == 0) return;

            int count = 0;
            var instrumentSource = new InstrumentManager();

            foreach (Instrument newInstrument in selectedInstruments)
            {
                if (TryAddInstrument(instrumentSource, newInstrument))
                {
                    count++;
                }
            }

            Status = string.Format("{0}/{1} instruments added.", count, selectedInstruments.Count);
        }
示例#39
0
        void ClarityEngine_OnProtocolPaused(InstrumentManager Source, TimeSpan TS)
        {
            if (this.InvokeRequired)
            {
                IMT myDel = ClarityEngine_OnProtocolPaused;
                this.Invoke(myDel, new object[] { Source, TS });
            }
            else
            {

                StatusLabel.Text = "Waiting Until It Is Time To Run The Next Protocol Instruction";
                TimeToGo.Start((int)TS.TotalMilliseconds);
                UpdateForm();
            }
        }
示例#40
0
 void ClarityEngine_OnProtocolStarted(InstrumentManager Source, EventArgs e)
 {
     if (this.InvokeRequired)
     {
         IM myDel = ClarityEngine_OnProtocolStarted;
         this.Invoke(myDel, new object[] { Source, e });
     }
     else
     {
         pnlFailure.Visible = false;
         btnExecuteProtocols.Enabled = false;
         btnCancelProtocolExecution.Enabled = true;
         btnRetryLastInstruction.Enabled = false;
         //probably should try some checks here
         TimeToGo.Stop();
         TimeToGo.Text = "Protocol Running";
     }
 }
示例#41
0
文件: Protocol.cs 项目: RobAmos/osla
 public ProtocolManager(InstrumentManager manager)
 {
     this.manager = manager;
     Protocols = new List<Protocol>();
 }
示例#42
0
 void ClarityEngine_OnProtocolSuccessfullyCancelled(InstrumentManager Source, EventArgs e)
 {
     if (this.InvokeRequired)
     {
         IM myDel = ClarityEngine_OnProtocolSuccessfullyCancelled;
         this.Invoke(myDel, new object[] { Source, e });
     }
     else
     {
         btnCancelProtocolExecution.Enabled = false;
         btnExecuteProtocols.Enabled = true;
         StatusLabel.Text = "Cancelled Protocol";
         UpdateForm();
     }
 }
示例#43
0
文件: Protocol.cs 项目: RobAmos/osla
 public void FirePauseEvent(InstrumentManager source, TimeSpan curDelay)
 {
     if (onProtocolPause != null)
     {
         onProtocolPause(source,curDelay);
     }
 }
示例#44
0
 void ClarityEngine_OnAllProtocolsEnded(InstrumentManager Source, EventArgs e)
 {
     if (this.InvokeRequired)
     {
         IM myDel = ClarityEngine_OnAllProtocolsEnded;
         this.Invoke(myDel, new object[] { Source, e });
     }
     else
     {
         StatusLabel.Text = "Finished Running Protocols";
         UpdateForm();
     }
 }