Example #1
0
 protected BarFactoryItem(Instrument instrument, BarType barType, long barSize, BarInput barInput, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : this(instrument, barType, barSize, barInput, providerId)
 {
     this.sessionEnabled = true;
     this.session1 = session1;
     this.session2 = session2;
 }
Example #2
0
 public TestItemOnAV(Instrument.SwitchSetting ss,
     string channelID)
     : base(ss)
 {
     this.ChannelID = channelID;
     this.Values = new List<string>();
 }
Example #3
0
 internal void Init(Framework framework)
 {
     this.framework = framework;
     this.instrument = framework.InstrumentManager.GetById(InstrumentId);
     if (this.instrument == null)
         Console.WriteLine($"{nameof(Leg)}::{nameof(Init)} Can not find leg instrument in the framework instrument manager. Id = {InstrumentId}");
 }
Example #4
0
        public Member(StreamReader sr)
        {
            firstName = sr.ReadLine();
            lastName = sr.ReadLine();
            type = (MemberType)Convert.ToInt32(sr.ReadLine());
            uiStudentNumber = Convert.ToUInt32(sr.ReadLine());
            memberFaculty = (Faculty)Convert.ToInt32(sr.ReadLine());

            otherInstrument = sr.ReadLine();
            curInstrument = (Instrument)Convert.ToInt32(sr.ReadLine());

            this.bMultipleInstruments = Convert.ToBoolean(sr.ReadLine());

            // write if the member plays multiple instruments
            // write any other instruments that the member plays (or does not play)
            int numberOfInstruments = Enum.GetValues(typeof(Member.Instrument)).Length;
            if (this.bMultipleInstruments)
            {
                playsInstrument = new bool[Enum.GetValues(typeof(Member.Instrument)).Length];
                for (int j = 0; j < numberOfInstruments; j++)
                    playsInstrument[j] = Convert.ToBoolean(sr.ReadLine());
            }

            email = sr.ReadLine();
            comments = ClsStorage.ReverseCleanNewLine(sr.ReadLine());
            sID = Convert.ToInt16(sr.ReadLine());
            signupTime = new DateTime(Convert.ToInt64(sr.ReadLine()));
            size = (ShirtSize)Convert.ToInt32(sr.ReadLine());
        }
Example #5
0
        public Loader()
        {
            _cache_mark = "";

            _slices_cache = new Hashtable();

            XmlDocument doc = new XmlDocument();

            try {
                doc.Load("config.xml");

                XmlNodeList instruments = doc.DocumentElement.ChildNodes;

                _instruments = new Queue();

                foreach (XmlNode i in instruments) {
                    Instrument instrument = new Instrument();

                    instrument.class_id = i.Attributes["class_id"].Value;
                    instrument.id = i.Attributes["id"].Value;
                    instrument.name = i.Attributes["name"].Value;

                    _instruments.Enqueue(instrument);
                }

            }
            catch (Exception ex) {
                // MessageBox.Show("Ошибка: " + ex.Message);
            }
        }
Example #6
0
        protected override void OnBarOpen(Instrument instrument, Bar bar)
        {
            double orderQty = Qty;

            // Set order qty if position already exist.
            if (HasPosition(Instrument))
                orderQty = Math.Abs(Position.Amount) + Qty;

            // Send trading orders if needed.
            if (positionInBlock == 0)
            {
                if (buyOnNewBlock)
                {
                    Order order = BuyOrder(Instrument, orderQty, "Reverse to Long");
                    Send(order);

                    buyOnNewBlock = false;
                }

                if (sellOnNewBlock)
                {
                    Order order = SellOrder(Instrument, orderQty, "Reverse to Short");
                    Send(order);

                    sellOnNewBlock = false;
                }
            }
        }
 public PriceDataService(Instrument instrument, TimeFrame timeframe, DateTime startDate, DateTime endDate)
 {
     _instrument = instrument;
     _timeframe = timeframe;
     _startDate = startDate;
     _endDate = endDate;
 }
Example #8
0
 public InstrumentNode(Instrument instrument)
 {
   eX4XcIhHpDXt70u2x3N.k8isAcYzkUOGF();
   // ISSUE: explicit constructor call
   base.\u002Ector(instrument.Symbol, 1, 1);
   this.ijdxXmDIwH = instrument;
 }
Example #9
0
        protected override void OnBar(Instrument instrument, Bar bar)
        {
            // Add bar to bar series.
            Bars.Add(bar);

            Log(bar, barsGroup);

            if (fastSMA.Count > 0)
                Log(fastSMA.Last, fastSmaGroup);

            if (slowSMA.Count > 0)
                Log(slowSMA.Last, slowSmaGroup);

            // Calculate performance.
            Portfolio.Performance.Update();

            Log(Portfolio.Value, equityGroup);

            // Check strategy logic.
            if (fastSMA.Count > 0 && slowSMA.Count > 0)
            {
                Cross cross = fastSMA.Crosses(slowSMA, bar.DateTime);

                if (cross == Cross.Above)
                    buyOnNewBlock = true;

                if (cross == Cross.Below)
                    sellOnNewBlock = true;
            }

            positionInBlock = (positionInBlock++) % BarBlockSize;
        }
Example #10
0
 public Leg(Instrument instrument, double weight = 1.0)
 {
     this.instrument = instrument;
     Weight = weight;
     InstrumentId = instrument.Id;
     this.framework = instrument.Framework;
 }
Example #11
0
        public YPitchBendCube(Point3D center, double radius, 
                Pitch pitch, Instrument instrument, OutputDevice device, Channel channel)
            : base(center, radius, new InstrumentNoteAction(device, channel, pitch)) {

                outputDevice = device;
                this.channel = channel;
        }
Example #12
0
 public Position getPosition(Instrument instrument, Side orderMode)
 {
     IntPtr cPtr = ContextModulePINVOKE.NetPositions_getPosition(swigCPtr, Instrument.getCPtr(instrument), (int)orderMode);
     Position ret = (cPtr == IntPtr.Zero) ? null : new Position(cPtr, false);
     if (ContextModulePINVOKE.SWIGPendingException.Pending) throw ContextModulePINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #13
0
 public HistoricalDataRequest(Instrument instrument, DateTime dateTime1, DateTime dateTime2, byte dataType)
 {
     Instrument = instrument;
     DateTime1 = dateTime1;
     DateTime2 = dateTime2;
     DataType = dataType;
 }
        public NewCompositionPanelViewModel()
        {
            EditorState.IsNewCompositionPanel = true;

            //we are reusing vectors and such, but the newcompositionpanel, needs different vector widths for some vectors, so....
            //these values are set back normal in the start and cancel button handlers below.
            Preferences.MeasureWidth = Preferences.NewComppositionPanelMeasureWidth;
            Preferences.StaffDimensionAreaWidth = Preferences.NewComppositionPanelStaffDimensionAreaWidth;
            //

            #region Set DropDowns to Default Values
            Infrastructure.Dimensions.Keys.InitializeKeys();
            Keys = (from a in Infrastructure.Dimensions.Keys.KeyList where a.Listable select a).ToList();
            SelectedKey = (from a in Infrastructure.Dimensions.Keys.KeyList where a.Name == Preferences.DefaultKey select a).Single();
            _selectedInstrument = (from a in Infrastructure.Dimensions.Instruments.InstrumentList where a.Name == Preferences.DefaultInstrument select a).Single();
            SelectedSimpleStaffConfigurationClef = (from a in Infrastructure.Dimensions.Clefs.ClefList where a.Id == Preferences.DefaultClefId select a).Single();
            SelectedGrandStaffConfigurationClef = (from a in Infrastructure.Dimensions.Clefs.ClefList where a.Id == Preferences.DefaultGrandStaffClefId select a).Single();
            SelectedTimeSignature = (from a in Infrastructure.Dimensions.TimeSignatures.TimeSignatureList where a.Id == Preferences.DefaultTimeSignatureId select a).Single();

            #endregion Set DropDowns to Default Values

            CreateNewCompositionForPanel();

            DefineCommands();
            SubscribeEvents();
            EA.GetEvent<SetProvenancePanel>().Publish(string.Empty);
            Scale = 1;
            Update();
            EA.GetEvent<SetNewCompositionTitleForeground>().Publish("#CCCCCC");
            SetMargins();
            GrandStaffConfigurationClefComboBoxVisibility = (_staffConfiguration == _Enum.StaffConfiguration.Grand) ? Visibility.Visible : Visibility.Collapsed;
            EditorState.StaffConfiguration = _staffConfiguration;
            CompositionPanelVisibility = Visibility.Visible;
        }
Example #15
0
 public Position(Portfolio portfolio, Instrument instrument)
 {
     Portfolio = portfolio;
     Instrument = instrument;
     PortfolioId = portfolio.Id;
     InstrumentId = instrument.Id;
 }
Example #16
0
    void CreateInstruments()
    {
        Instrument guitar = new Instrument("rhythmGuitar", gameObject.GetComponent<AudioSource>());

        Chord[] C_Chords = new Chord[6];
        C_Chords[0] = LoadChord("C");
        C_Chords[1] = LoadChord("Dm");
        C_Chords[2] = LoadChord("Em");
        C_Chords[3] = LoadChord("F");
        C_Chords[4] = LoadChord("G");
        C_Chords[5] = LoadChord("Am");

        guitar.AddKey("C", C_Chords);

        Chord[] Am_Chords = new Chord[6];
        Am_Chords[0] = LoadChord("Am");
        Am_Chords[1] = LoadChord("C");
        Am_Chords[2] = LoadChord("Dm");
        Am_Chords[3] = LoadChord("Em");
        Am_Chords[4] = LoadChord("F");
        Am_Chords[5] = LoadChord("G");

        guitar.AddKey("Am", Am_Chords);

        m_Instruments.Add(guitar);
    }
Example #17
0
        public void Add(Instrument instrument, bool save = true)
        {
            if (Contains(instrument.Symbol))
                throw new ArgumentException($"Instrument with the same symbol is already present in the framework : {instrument.Symbol}");

            var i = this.deletedInstruments.Get(instrument.Symbol);
            if (i != null)
            {
                Console.WriteLine($"InstrumentManager::Add Using deleted instrument id = {i.Id} for symbol {instrument.Symbol}");
                instrument.Id = i.Id;
                this.deletedInstruments.Remove(i);
            }
            else
            {
                instrument.Id = this.counter++;
            }
            Instruments.Add(instrument);
            if (instrument.Framework == null)
                instrument.Init(this.framework);

            if (save)
            {
                instrument.Loaded = true;
                Save(instrument);
            }
            this.framework.EventServer.OnInstrumentAdded(instrument);
        }
Example #18
0
 public Member(
     string firstName,
     string lastName,
     MemberType type,
     uint uiStudentNumber,
     int iFaculty,
     string instrument,
     string otherInstrument,
     string email,
     string comments,
     int iShirt)
 {
     // declare basic information about user
     this.firstName = firstName;
     this.lastName = lastName;
     this.type = type;
     this.uiStudentNumber = uiStudentNumber;
     this.memberFaculty = (Faculty)iFaculty;
     this.curInstrument = ParseInstrument(instrument);
     if (this.curInstrument == Instrument.Other && String.IsNullOrEmpty(otherInstrument))
         this.otherInstrument = instrument;
     else
         this.otherInstrument = otherInstrument;
     this.email = email;
     this.comments = comments;
     this.sID = ClsStorage.currentClub.iMember;
     this.signupTime = DateTime.Now;
     this.size = (ShirtSize)iShirt;
     this.bMultipleInstruments = false;
 }
Example #19
0
 public void Delete(Instrument instrument)
 {
     Instruments.Remove(instrument);
     instrument.DeleteCached = true;
     this.deletedInstruments.Add(instrument);
     Save(instrument);
     this.framework.EventServer.OnInstrumentDeleted(instrument);
 }
Example #20
0
 protected BarFactoryItem(Instrument instrument, BarType barType, long barSize, BarInput barInput = BarInput.Trade, int providerId = -1)
 {
     this.instrument = instrument;
     this.barType = barType;
     this.barSize = barSize;
     this.barInput = barInput;
     this.providerId = providerId;
 }
		public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
		{
			if (context != null && context.Instance is Instrument)
			{
				this.instrument = (Instrument)context.Instance;
			}
			return base.EditValue(context, provider, value);
		}
 // Use this for initialization
 void Start()
 {
     controlScheme = ControlManager.Instance.ControlSchemes[0];
     InstrumentInHand = ((GameObject)GameObject.Instantiate(InstrumentsInCollection.First().gameObject)).GetComponent<Instrument>();
     InstrumentInHand.gameObject.SetActive(true);
     InstrumentInHand.transform.position = transform.position;
     InstrumentInHand.transform.parent = transform;
     player = transform.parent.Find("PlayerCharacter");
 }
 public VmInstrument(Instrument instrument)
     : base(instrument)
 {
     this._Instrument = instrument;
     if (!instrument.IsDerivative)
     {
         this.SourceRelations = new ObservableCollection<VmInstrumentSourceRelation>();
         this.SourceRelations.CollectionChanged += SourceRelations_CollectionChanged;
     }
 }
 public static void AddNew(Song currentSong)
 {
     Instrument nuevo = new Instrument();
     nuevo.SetVolumeLength(5);
     nuevo.Name = WYZTracker.Core.Properties.Resources.New;
     nuevo.Looped = false;
     nuevo.Volumes = new byte[] { 8, 8, 8, 8, 8 };
     nuevo.ID = currentSong.Instruments.GetSafeId().ToString();
     currentSong.Instruments.Add(nuevo);
 }
Example #25
0
 /// <param name='note'>
 /// 0 - 24
 /// </param>
 public static BlockAction NoteBlock(CoordInt pos, Instrument ins, byte note)
 {
     BlockAction ba = new BlockAction();
     ba.Position = pos;
     ba.TypeState = (byte)ins;
     if (note < 0 || note > 24)
         ba.PitchDirection = 0;
     else
         ba.PitchDirection = (byte)note;
     return ba;
 }
Example #26
0
		private double GetAmount(Instrument instrument, double amount)
		{
			if (instrument.Quote.DateTime != DateTime.MinValue)
				return (instrument.Quote.Ask + instrument.Quote.Bid) / 2.0;
			if (instrument.Trade.DateTime != DateTime.MinValue && instrument.Trade.DateTime >= instrument.Bar.DateTime)
				return instrument.Trade.Price;
			if (instrument.Bar.DateTime != DateTime.MinValue)
				return instrument.Bar.Close;
			else
				return 1.0;
		}
 public void switchInstrument(Instrument inst)
 {
     print("Instrument " + inst.type.ToString() + " selected");
     current_inst = inst;
     current_sound = inst.sound;
     setPitchRelatedVars();
     sliderback.color = inst.col;
     secret_2nd_audio.GetComponent<SecondAudio> ().SetBrackets (current_inst.minPitch,
                                                                current_inst.maxPitch,
                                                                current_inst.sound);
 }
Example #28
0
		public Channel GetWorkingChannel(Instrument instrument, bool single = false)
		{
			Channel c = _generatorFramework.GetWorkingChannel(this, instrument, single);

			if (_channel == (Midi.Channel) 100)
			{
				_channel = c;
			}

			return c;
		}
Example #29
0
 public Fill(DateTime dateTime, Order order, Instrument instrument, byte currencyId, OrderSide side, double qty, double price, string text = "")
 {
     DateTime = dateTime;
     Order = order;
     Instrument = instrument;
     OrderId = order.Id;
     InstrumentId = instrument.Id;
     CurrencyId = currencyId;
     Side = side;
     Qty = qty;
     Price = price;
     Text = text;
 }
Example #30
0
 public void SetInstrument(Instrument instrument)
 {
   this.Text = string.Format(RNaihRhYEl0wUmAftnB.aYu7exFQKN(14904), (object) instrument.Symbol);
   int num = 2;
   try
   {
     num = int.Parse(instrument.PriceDisplay[1].ToString());
   }
   catch
   {
   }
   this.fdXV7Teq0Z.DecimalPlaces = num;
 }
Example #31
0
 public Task <MarketBook?> GetTicker(Instrument instr)
 {
     throw new NotImplementedException();
 }
Example #32
0
 protected virtual void OnTriggerEnter(Collider other)
 {
     if (mState == State.held)
     {
         if (other.transform.gameObject.layer == LayerMask.NameToLayer("Wall"))
         {
             isInWall = other.transform;
         }
         else
         {
             //Debug.Log("碰撞到的物体" + other.gameObject.name);
             Instrument adsorbInstrument = other.gameObject.GetComponentInParent <Instrument>();
             //Debug.Log(adsorbInstrument);
             //碰到的对象不是仪器,变红
             if (adsorbInstrument == null)
             {
                 if (other.gameObject.layer == LayerMask.NameToLayer("Player"))
                 {
                     if (other.GetComponentInParent <Valve.VR.InteractionSystem.HandCollider>())
                     {
                         if (other.GetComponentInParent <Valve.VR.InteractionSystem.HandCollider>().transform.name == "HandColliderLeft(Clone)")
                         {
                             ScaleHand = LeftHand.Instance.GetComponent <HandBase>();
                             ScaleHand.ScaleInstrument = this;
                         }
                         //else if (other.GetComponentInParent<Valve.VR.InteractionSystem.HandCollider>().transform.name == "HandColliderRight(Clone)")
                         //{
                         //    ScaleHand = RightHand.Instance.GetComponent<HandBase>();
                         //    ScaleHand.ScaleInstrument = this;
                         //}
                     }
                     return;
                 }
                 SetRenderer(HeldState.red);
                 isHeldCollision = true;
             }
             else
             {//碰到的对象是仪器
                 if (groupInstrumentList != null && groupInstrumentList.Contains(adsorbInstrument))
                 {
                     //是自己的内部仪器,什么都不做
                 }
                 else
                 {
                     isHeldCollision = true;
                     //不是自己的内部仪器
                     //判断是否可以吸附
                     if (adsorbTypeList != null && adsorbInstrument.adsorbCollider == other && adsorbTypeList.Contains(adsorbInstrument.type))
                     {
                         //可以吸附
                         curAdsorbInstrument = adsorbInstrument;
                         SetRenderer(HeldState.green);
                     }
                     else
                     {
                         //不可以吸附
                         SetRenderer(HeldState.red);
                     }
                 }
             }
         }
     }
 }
Example #33
0
 public virtual Task <ExecutionReport> GetOrder(string id, Instrument instrument, TimeSpan timeout)
 {
     throw new NotSupportedException($"{Name} does not support receiving order information by {nameof(id)} and {nameof(instrument)}");
 }
Example #34
0
        public int GetMarketTime(Instrument inst)
        {
            DateTime time = inst.CurrentTime;

            return(ConvertMarketTime(time));
        }
Example #35
0
 public void SetInstrument(Instrument instrument)
 {
     RollOver(false);
     this.instrument = instrument;
     GetComponent <Collider> ().enabled = false;
 }
Example #36
0
 private void setMarketVolatility(Instrument inst, int tf, double value)
 {
     currentVolatility[inst.ToString() + tf.ToString()] = value;
 }
Example #37
0
 public int GetMarketVolatility(Instrument inst, int tf)
 {
     return((int)currentVolatility[inst.ToString() + tf.ToString()]);
 }
 public static double GetPreOpenInterest(this Instrument inst)
 {
     return(GetMarketData(inst)?.PreOpenInterest ?? double.NaN);
 }
 public static TradingTimeRange GetTimeRange(this Instrument inst)
 {
     return((TradingTimeRange)inst.Fields[QuantBoxConst.InstrumentTimeManagerOffset]);
 }
 private static DepthMarketDataField GetMarketData(this Instrument inst)
 {
     return((DepthMarketDataField)inst.Fields[QuantBoxConst.InstrumentMarketDataOffset]);
 }
Example #41
0
 public bool Contains(Instrument instrument)
 {
     return(this.t3XyVaLbw1.Contains((object)instrument));
 }
Example #42
0
 public InstrumentViewModel(Instrument instrument)
 {
     _instrument = instrument;
     _instrument.PriceUpdated += PriceUpdated;
 }
Example #43
0
 static void PrintInstrumentInfo(Instrument inst)
 {
     Console.WriteLine(string.Format(" ExchangeID={0}, ProductID={1}, ID={2}, Name={3}",
                                     inst.ExchangeID, inst.ProductID,
                                     inst.InstrumentID, inst.InstrumentName));
 }
Example #44
0
        private static void HandleStartEnsemble(GameSession session, PacketReader packet)
        {
            long instrumentItemUid = packet.ReadLong();
            long scoreItemUid      = packet.ReadLong();

            Party party = GameServer.PartyManager.GetPartyById(session.Player.PartyId);

            if (party == null)
            {
                return;
            }

            if (!session.Player.Inventory.Items.ContainsKey(scoreItemUid) || !session.Player.Inventory.Items.ContainsKey(instrumentItemUid))
            {
                return;
            }


            Item score = session.Player.Inventory.Items[scoreItemUid];

            if (score.PlayCount <= 0)
            {
                return;
            }

            Item instrumentItem = session.Player.Inventory.Items[instrumentItemUid];
            InsturmentInfoMetadata         instrumentInfo     = InstrumentInfoMetadataStorage.GetMetadata(instrumentItem.Function.Id);
            InstrumentCategoryInfoMetadata instrumentCategory = InstrumentCategoryInfoMetadataStorage.GetMetadata(instrumentInfo.Category);
            Instrument instrument = new Instrument(instrumentCategory.GMId, instrumentCategory.PercussionId, score.IsCustomScore, session.FieldPlayer.ObjectId)
            {
                Score     = score,
                Ensemble  = true,
                Improvise = false
            };

            session.Player.Instrument       = session.FieldManager.RequestFieldObject(instrument);
            session.Player.Instrument.Coord = session.FieldPlayer.Coord;

            if (session.Player != party.Leader)
            {
                return;
            }

            int instrumentTick = session.ServerTick;

            foreach (Player member in party.Members)
            {
                if (member.Instrument == null)
                {
                    continue;
                }

                if (!member.Instrument.Value.Ensemble)
                {
                    continue;
                }

                member.Instrument.Value.InstrumentTick = instrumentTick; // set the tick to be all the same
                member.Session.FieldManager.AddInstrument(member.Session.Player.Instrument);
                session.FieldManager.BroadcastPacket(InstrumentPacket.PlayScore(session.Player.Instrument));
                member.Instrument.Value.Score.PlayCount -= 1;
                member.Session.Send(InstrumentPacket.UpdateScoreUses(member.Instrument.Value.Score.Uid, member.Instrument.Value.Score.PlayCount));
                member.Instrument.Value.Ensemble = false;
            }
        }
Example #45
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="instrument">The instrument whose audio has been captured.</param>
 /// <param name="audio">The audio data. This should not be mutated after construction.</param>
 public InstrumentAudio(Instrument instrument, byte[] audio) =>
 (Instrument, Audio) = (instrument, audio);
 public static DateTime GetTradingDay(this Instrument inst)
 {
     return(GetMarketData(inst)?.TradingDay() ?? DateTime.Today);
 }
Example #47
0
 private void setMarketTrend(Instrument inst, int tf, double value)
 {
     currentTrend[inst.ToString() + tf.ToString()] = value;
 }
 public static double GetPreClosePrice(this Instrument inst)
 {
     return(GetMarketData(inst)?.PreClosePrice ?? double.NaN);
 }
Example #49
0
 public int GetMarketTrend(Instrument inst, int tf)
 {
     return((int)currentTrend[inst.ToString() + tf.ToString()]);
 }
 public static double GetOpenPrice(this Instrument inst)
 {
     return(GetMarketData(inst)?.OpenPrice ?? double.NaN);
 }
Example #51
0
 public void SetEmpty()
 {
     instrument = null;
     GetComponent <Collider> ().enabled = true;
 }
 public InstrumentStats(Instrument instrument)
 {
     symbol = instrument.Symbol;
 }
 public static double GetLowerLimitPrice(this Instrument inst)
 {
     return(GetMarketData(inst)?.LowerLimitPrice ?? double.NaN);
 }
Example #54
0
 /// <summary>
 ///设置仪器状态
 /// </summary>
 /// <param name="state">状态</param>
 /// <param name="hand">设置握持手</param>
 public void SetState(State state, GameObject hand = null)
 {
     HeldingHand = hand;
     if (rig == null)
     {
         rig = gameObject.AddComponent <Rigidbody>();
     }
     if (mState != state)
     {
         mLastState = mState;
         mState     = state;
     }
     if (adsorbCollider)
     {
         adsorbCollider.enabled = false;
     }
     Messenger.Broadcast <Instrument>(GlobalEvent.Instrument_State_Change, this);
     if (mState == State.normal)
     {
         rig.isKinematic = true;
         for (int i = 0; i < colliders.Count; i++)
         {
             colliders[i].isTrigger = false;
         }
         SetRenderer(HeldState.normal);
     }
     if (mState == State.held)
     {
         if (curAdsorbInstrument)
         {
             curAdsorbInstrument.adsorbCollider.enabled = true;
             curAdsorbInstrument.subInstrument          = null;
             curAdsorbInstrument = null;
         }
         rig.isKinematic = true;
         isHeldCollision = false;
         for (int i = 0; i < colliders.Count; i++)
         {
             colliders[i].isTrigger = true;
         }
         SetRenderer(HeldState.green);
         HeldCallBack(hand);
     }
     if (mState == State.drop)
     {
         if (curAdsorbInstrument)
         {
             //吸附模式
             SetState(State.life);
             AdsorbCallBack();
             curAdsorbInstrument.adsorbCollider.enabled = false;
             curAdsorbInstrument.subInstrument          = this;
         }
         else
         {
             //放下模式
             rig.isKinematic = false;
             for (int i = 0; i < colliders.Count; i++)
             {
                 colliders[i].isTrigger = false;
             }
             SetRenderer(HeldState.normal);
             FallCourse();
         }
     }
     if (mState == State.life)
     {
         if (adsorbCollider && subInstrument == null)
         {
             adsorbCollider.enabled = true;
         }
         rig.isKinematic = true;
         for (int i = 0; i < colliders.Count; i++)
         {
             colliders[i].isTrigger = false;
         }
         SetRenderer(HeldState.normal);
         LifeCallBack();
     }
     if (mState == State.free)
     {
         //放下模式
         rig.isKinematic = false;
         for (int i = 0; i < colliders.Count; i++)
         {
             colliders[i].isTrigger = false;
         }
         SetRenderer(HeldState.normal);
         FreeCallBack();
     }
 }
Example #55
0
        internal static Mock <ControllerWrapper> GetControllerMock(DockingStation dockingStation, Instrument instrument)
        {
            Mock <ControllerWrapper> controllerWrapper = new Mock <ControllerWrapper>();

            controllerWrapper.Setup(x => x.GetDockingStation()).Returns(dockingStation);
            controllerWrapper.Setup(x => x.IsDocked()).Returns(instrument != null);
            controllerWrapper.Setup(x => x.IsUsbDriveAttached(It.IsAny <string>())).Returns(true);
            controllerWrapper.Setup(x => x.Round(It.IsAny <double>(), It.IsAny <int>())).Returns <double, int>((value, resolution) => Math.Round(value, resolution));
            controllerWrapper.Setup(x => x.GetKeyPress()).Returns(new KeyPress(Key.Left, new TimeSpan(0, 0, 5)));

            return(controllerWrapper);
        }
 public static void SetMarketData(this Instrument inst, DepthMarketDataField field)
 {
     inst.Fields[QuantBoxConst.InstrumentMarketDataOffset] = field;
 }
Example #57
0
        internal static Mock <InstrumentController> GetInstrumentControllerMockForCal(Instrument instrument = null)
        {
            Mock <InstrumentController> instrumentController = new Mock <InstrumentController>();

            SensorPosition[] sensorPositions = null;

            if (instrument != null)
            {
                sensorPositions = instrument.InstalledComponents
                                  .Where(installedComponent => installedComponent.Component is Sensor)
                                  .Select(sensor => new SensorPosition(sensor.Position, SensorMode.Installed, false))
                                  .ToArray();

                instrumentController.Setup(x => x.AccessoryPump).Returns(instrument.AccessoryPump);
            }

            instrumentController.Setup(x => x.Initialize(It.IsAny <InstrumentController.Mode>()));
            instrumentController.Setup(x => x.TestForInstrumentReset(It.IsAny <SensorGasResponse>(), It.IsAny <string>())).Returns(false);
            instrumentController.Setup(x => x.GetSensorBiasStatus()).Returns(true);
            instrumentController.Setup(x => x.EnablePump(It.IsAny <bool>()));
            instrumentController.Setup(x => x.GetSensorPositions()).Returns(sensorPositions);
            instrumentController.Setup(x => x.OpenGasEndPoint(It.IsAny <GasEndPoint>(), It.IsAny <int>()));
            instrumentController.Setup(x => x.CloseGasEndPoint(It.IsAny <GasEndPoint>()));
            instrumentController.Setup(x => x.GetSensorReading(It.IsAny <int>(), It.IsAny <double>())).Returns(0);
            instrumentController.Setup(x => x.GetSensorBumpStatus(It.IsAny <int>())).Returns(true);
            instrumentController.Setup(x => x.PauseGasFlow(It.IsAny <GasEndPoint>(), It.IsAny <long>()));
            instrumentController.Setup(x => x.GetSensorMaximumReading(It.IsAny <int>(), It.IsAny <double>())).Returns(30);

            instrumentController.Setup(x => x.IsSensorEnabled(It.IsAny <int>())).Returns <int>(pos =>
            {
                InstalledComponent installedComponent = instrument.InstalledComponents.Find(component => component.Position == pos);
                if (installedComponent != null)
                {
                    return(installedComponent.Component.Enabled);
                }
                return(false);
            });
            instrumentController.Setup(x => x.GetSensorLowAlarm(It.IsAny <int>(), It.IsAny <double>())).Returns <int, double>((pos, resolution) =>
            {
                InstalledComponent installedComponent = instrument.InstalledComponents.Find(component => component.Position == pos);
                if (installedComponent != null)
                {
                    Sensor sensor = (Sensor)installedComponent.Component;
                    return(sensor.Alarm.Low);
                }
                return(0);
            });

            #region [ Calibration Methods ]

            instrumentController.Setup(x => x.PreconditionSensor(It.IsAny <InstalledComponent>(), It.IsAny <GasEndPoint>(), It.IsAny <SensorGasResponse>())).Returns(new TimeSpan(0));
            instrumentController.Setup(x => x.GetSensorZeroingStatus(It.IsAny <int>())).Returns(true);
            instrumentController.Setup(x => x.IsSensorCalibrationEnabled(It.IsAny <InstalledComponent>())).Returns(true);
            instrumentController.Setup(x => x.GetSensorLastCalibrationTime(It.IsAny <int>())).Returns(DateTime.Now);
            instrumentController.Setup(x => x.ZeroSensors(It.IsAny <GasEndPoint>())).Returns(true);
            instrumentController.Setup(x => x.SetSensorCalGasConcentration(It.IsAny <int>(), It.IsAny <double>(), It.IsAny <double>()));
            instrumentController.Setup(x => x.SetCalibrationGasConcentration(It.IsAny <InstalledComponent>(), It.IsAny <double>(), It.IsAny <bool>()));
            instrumentController.Setup(x => x.GetSensorCalibrationTimeout(It.IsAny <int>())).Returns(new TimeSpan(0, 0, 10));
            instrumentController.Setup(x => x.GetSensorBaseline(It.IsAny <int>())).Returns(0);
            instrumentController.Setup(x => x.GetSensorZeroOffset(It.IsAny <int>(), It.IsAny <double>())).Returns(0);
            instrumentController.Setup(x => x.GetSensorSpanCoeff(It.IsAny <int>())).Returns(49485);
            instrumentController.Setup(x => x.BeginSensorCalibration(It.IsAny <IEnumerable <int> >()));
            instrumentController.Setup(x => x.GetSensorCalibrationFlowRate(It.IsAny <InstalledComponent>())).Returns(500);
            instrumentController.Setup(x => x.GetSensorPreconditionFlowRate(It.IsAny <InstalledComponent>())).Returns(500);
            instrumentController.Setup(x => x.GetSensorPreconditionTimeout(It.IsAny <InstalledComponent>())).Returns(new TimeSpan(0, 0, 10));

            instrumentController.Setup(x => x.SetCalibrationGasConcentration(It.IsAny <InstalledComponent>(), It.IsAny <GasEndPoint>())).Returns <InstalledComponent, GasEndPoint>((installedComponent, gasEndPoint) =>
            {
                Sensor sensor = (Sensor)installedComponent.Component;
                GasConcentration gasConcentration = null;

                gasConcentration = gasEndPoint.Cylinder.GasConcentrations.Find(gas => gas.Type.Code == sensor.CalibrationGas.Code);
                if (gasConcentration != null)
                {
                    sensor.CalibrationGasConcentration = gasConcentration.Concentration;
                    return(gasConcentration.Concentration);
                }

                gasConcentration = gasEndPoint.Cylinder.GasConcentrations.Find(gas => gas.Type.Code == GasCode.FreshAir && sensor.CalibrationGas.Code == GasCode.O2);
                if (gasConcentration != null)
                {
                    sensor.CalibrationGasConcentration = 209000;
                    return(209000);
                }

                return(0);
            });
            if (instrument != null && instrument.InstalledComponents.Where(installedComponent => installedComponent.Component is Sensor).Count() > 0)
            {
                int noOfReadingsNeeded = 3;
                Func <string, int, string>  sensorID = (sn, position) => string.Join("_", sn, position);
                Func <Sensor, double>       sensorCalibrationGasConcentration = s => ((SensorType)s.Type).MeasurementType != MeasurementType.VOL ? s.CalibrationGasConcentration : s.CalibrationGasConcentration * 10000;
                Dictionary <string, double> sensorReadings      = createSensorReadingDictionary(instrument.InstalledComponents.Where(installedComponent => installedComponent.Component is Sensor));
                Dictionary <int, double>    sensorReadingCounts = createSensorReadingCount(instrument.InstalledComponents.Where(installedComponent => installedComponent.Component is Sensor));
                Func <int, double>          sensorSpanReserve   = position =>
                {
                    double             spanReserve        = 0;
                    InstalledComponent installedComponent = instrument.InstalledComponents.Find(installComp => installComp.Position == position);
                    if (installedComponent != null)
                    {
                        Sensor sensor        = (Sensor)installedComponent.Component;
                        double calGasConc    = sensorCalibrationGasConcentration(sensor);
                        double sensorReading = sensorReadings[sensorID(sensor.SerialNumber, position)];
                        spanReserve = (sensorReading / calGasConc) * 100;
                    }
                    return(spanReserve);
                };

                instrumentController.Setup(x => x.GetSensorCalibrationReading(It.IsAny <int>(), It.IsAny <double>()))
                .Returns <int, double>((position, resolution) =>
                {
                    double reading = 0;
                    InstalledComponent installedComponent = instrument.InstalledComponents.Find(installComp => installComp.Position == position);
                    if (installedComponent != null)
                    {
                        reading = sensorReadings[sensorID(installedComponent.Component.SerialNumber, position)];
                    }
                    return(reading);
                })
                .Callback <int, double>((position, resolution) =>
                {
                    InstalledComponent installedComponent = instrument.InstalledComponents.Find(installComp => installComp.Position == position);
                    if (installedComponent != null)
                    {
                        Sensor sensor        = (Sensor)installedComponent.Component;
                        double calGasConc    = sensorCalibrationGasConcentration(sensor);
                        double increment     = calGasConc / noOfReadingsNeeded;
                        double sensorReading = sensorReadings[sensorID(sensor.SerialNumber, position)];
                        if (sensorReading < (calGasConc + increment))
                        {
                            sensorReadings[sensorID(sensor.SerialNumber, position)] += increment;
                        }
                    }
                });

                instrumentController.Setup(x => x.GetSensorCalibrationStatus(It.IsAny <int>()))
                .Returns <int>(position => sensorSpanReserve(position) > 80);

                instrumentController.Setup(x => x.IsSensorCalibrating(It.IsAny <int>()))
                .Returns <int>(position => sensorReadingCounts[position] <= noOfReadingsNeeded)
                .Callback <int>(position => sensorReadingCounts[position] += 1);

                instrumentController.Setup(x => x.GetSensorSpanReserve(It.IsAny <int>())).Returns <int>(pos => sensorSpanReserve(pos));
                instrumentController.Setup(x => x.GetSensorSpanCoeff(It.IsAny <int>())).Returns(1);

                instrumentController.Setup(x => x.GetSensorLastCalibrationTime(It.IsAny <int>()))
                .Returns <int>(position => sensorReadingCounts[position] > 0 ? DateTime.Now : DateTime.Now.AddMinutes(-5))
                .Callback <int>(position =>
                {
                    if (sensorReadingCounts[position] > 1)
                    {
                        sensorReadingCounts[position] = 0;
                    }
                });
            }

            #endregion

            return(instrumentController);
        }
 public static void SetTimeRange(this Instrument inst, TradingTimeRange manager)
 {
     inst.Fields[QuantBoxConst.InstrumentTimeManagerOffset] = manager;
 }
Example #59
0
        private List <GMSDK.Tick> gskTicksCache = new List <GMSDK.Tick>();//trade和quote都由GMSDK.tick产生,为了历史数据提供者在导入trade和quote时不用读取两遍的tick,故而用此变量缓存tick
        public void SendHistoricalDataRequest(HistoricalDataRequest request)
        {
            if (!this.IsConnected)
            {
                this.EmitError(1, "The current historical data provider not connected.");
                return;
            }
            Instrument instrument = (Instrument)request.Instrument;

            this.historicalDataIds.Add(request.RequestId, request);
            string beginTime          = request.BeginDate.ToString("yyyy-MM-dd HH:mm:ss");
            string endTime            = request.EndDate.ToString("yyyy-MM-dd HH:mm:ss");
            List <ISeriesObject> list = this.GetHistoricalData(instrument, request.DataType, (int)request.BarSize, beginTime, endTime);
            bool flag = false;

            if ((list.Count < 1) || (flag = this.historicalPendingCancels.ContainsKey(request.RequestId)))
            {
                if (flag)
                {
                    this.historicalPendingCancels.Remove(request.RequestId);
                    this.EmitHistoricalDataRequestCancelled(request.RequestId, request.Instrument);
                }
                else
                {
                    this.historicalDataIds.Remove(request.RequestId);
                    this.EmitHistoricalDataRequestCompleted(request.RequestId, request.Instrument);
                }
            }
            else
            {
                if (request.DataType == HistoricalDataType.Trade)
                {
                    foreach (ISeriesObject obj1 in list)
                    {
                        this.EmitHistoricalTrade(request.RequestId, request.Instrument, obj1 as Trade);
                        if (this.historicalPendingCancels.ContainsKey(request.RequestId))
                        {
                            this.historicalPendingCancels.Remove(request.RequestId);
                            this.EmitHistoricalDataRequestCancelled(request.RequestId, request.Instrument);
                        }
                    }
                    if (this.tradeAndQuote)//Quote与Trade一起导入
                    {
                        List <ISeriesObject> listOther = GSKToGM.ConvertQuotes(this.gskTicksCache);
                        foreach (ISeriesObject obj2 in listOther)
                        {
                            this.EmitHistoricalQuote(request.RequestId, request.Instrument, obj2 as Quote);
                            if (this.historicalPendingCancels.ContainsKey(request.RequestId))
                            {
                                this.historicalPendingCancels.Remove(request.RequestId);
                                this.EmitHistoricalDataRequestCancelled(request.RequestId, request.Instrument);
                            }
                        }
                    }
                }
                else if (request.DataType == HistoricalDataType.Quote)
                {
                    foreach (ISeriesObject obj2 in list)
                    {
                        this.EmitHistoricalQuote(request.RequestId, request.Instrument, obj2 as Quote);
                        if (this.historicalPendingCancels.ContainsKey(request.RequestId))
                        {
                            this.historicalPendingCancels.Remove(request.RequestId);
                            this.EmitHistoricalDataRequestCancelled(request.RequestId, request.Instrument);
                        }
                    }

                    if (this.tradeAndQuote)//Trade与Quote一起导入
                    {
                        List <ISeriesObject> listOther = GSKToGM.ConvertTrades(this.gskTicksCache);
                        foreach (ISeriesObject obj1 in listOther)
                        {
                            this.EmitHistoricalTrade(request.RequestId, request.Instrument, obj1 as Trade);
                            if (this.historicalPendingCancels.ContainsKey(request.RequestId))
                            {
                                this.historicalPendingCancels.Remove(request.RequestId);
                                this.EmitHistoricalDataRequestCancelled(request.RequestId, request.Instrument);
                            }
                        }
                    }
                }
                else
                {
                    foreach (ISeriesObject obj3 in list)
                    {
                        this.EmitHistoricalBar(request.RequestId, request.Instrument, obj3 as Bar);
                        if (this.historicalPendingCancels.ContainsKey(request.RequestId))
                        {
                            this.historicalPendingCancels.Remove(request.RequestId);
                            this.EmitHistoricalDataRequestCancelled(request.RequestId, request.Instrument);
                        }
                    }
                }
                this.EmitHistoricalDataRequestCompleted(request.RequestId, request.Instrument);
            }
        }
 public MusicPlayer(MusicSheet musicSheet, Instrument instrument, IPlayAlgorithm algorithm)
 {
     Algorithm = algorithm;
     Worker    = new Thread(() => algorithm.Play(instrument, musicSheet.MetronomeMark, musicSheet.Melody.ToArray()));
 }