/// <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); }
/// <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; }
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 }
public string InstrumentInfo(InstrumentID instID) { // Only required for drivers shared between instruments (timebases) // A 'simple' should just return nothing return(String.Empty); }
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); }
/// <summary>Gets the instrument by ID.</summary> public InstrumentData GetItem(InstrumentID instrumentID) { InstrumentData result = this.FirstOrDefault(instrument => instrument.ID == instrumentID); return(result); }