Exemplo n.º 1
0
        /// <summary>Adds a new data if the list does not contain the id</summary>
        private void Add(InstrumentID id, Func <InstrumentID, string> getInstrumentName)
        {
            InstrumentData item = this.FirstOrDefault(instrument => instrument.ID == id);

            if (item != null)
            {
                return;
            }
            item = new InstrumentData(id, getInstrumentName);
            m_Instruments.Add(item);
        }
Exemplo n.º 2
0
        /// <summary>Initializes a new instance of the <see cref="InstrumentData"/> class.</summary>
        public InstrumentData(InstrumentID id, Func <InstrumentID, string> getInstrumentName)
        {
            if (id == InstrumentID.None)
            {
                throw new ArgumentException("Parameter instrument id cannot be " + id.ToString());
            }
            if (getInstrumentName == null)
            {
                throw new ArgumentNullException("getInstrumentName");
            }

            ID = id;
            m_GetInstrumentName = getInstrumentName;
        }
Exemplo n.º 3
0
        private void Init(Func <InstrumentID, string> getInstrumentName, long instrumentsMap)
        {
            if (getInstrumentName == null)
            {
                throw new ArgumentNullException("getInstrumentName");
            }

            InstrumentsMap = instrumentsMap;
            m_Instruments.Clear();

            if (instrumentsMap == (long)InstrumentID.None)
            {
                return;
            }

            for (int i = 0; i < InstrumentData.MaxInstrumentCount; i++)
            {
                long instrumentIdNumber = 1 << i;  // Bit Map
                //Trace.WriteLine(instrumentIdNumber.ToString("N0").PadLeft(6) + " = " + Convert.ToString(instrumentIdNumber, 2).PadLeft(InstrumentData.MaxInstrumentCount, '0'));

                if ((instrumentsMap & instrumentIdNumber) == instrumentIdNumber)
                {
                    InstrumentID instrumentId   = (InstrumentID)instrumentIdNumber;
                    string       instrumentName = getInstrumentName(instrumentId);
                    if (string.IsNullOrEmpty(instrumentName))
                    {
                        continue;
                    }
                    Add(instrumentId, getInstrumentName);
                }
            }
#if DEBUG
            if (Count < 1)
            {
                throw new InvalidDataException("Failed to detect the instruments from the instrumentsMap = " + instrumentsMap.ToString() + " " +
                                               "InstrumentDataList Count = " + Count.ToString() + " must be >= 1");
            }
#endif
        }
Exemplo n.º 4
0
 public string InstrumentInfo(InstrumentID instID)
 {
     // Only required for drivers shared between instruments (timebases)
     // A 'simple' should just return nothing
     return(String.Empty);
 }
Exemplo n.º 5
0
 string IConfigurationDescriptors.InstrumentInfo(InstrumentID instrumentId)  // Required for drivers that are shared among a few instruments
 {
     // This is added to text where the instrument name is displayed
     return(string.Empty);
 }
Exemplo n.º 6
0
        /// <summary>Gets the instrument by ID.</summary>
        public InstrumentData GetItem(InstrumentID instrumentID)
        {
            InstrumentData result = this.FirstOrDefault(instrument => instrument.ID == instrumentID);

            return(result);
        }