public Demo(IDriverEx driver, IDDK ddk, Config.Demo config, string id, InstrumentDataList instrumentDataList, string driverFolder) : base(driver, ddk, config, typeof(Demo).Name, id) { Log.TaskBegin(Id); try { if (string.IsNullOrEmpty(driverFolder)) { throw new ArgumentNullException("driverFolder"); } if (instrumentDataList == null) { throw new ArgumentNullException("instrumentDataList"); } m_Properties = new DemoProperties(driver, m_DDK, config, m_Device); //------------------------------------------------------------------------------------------------------------------- if (m_DDK.InstrumentMap == null) { throw new InvalidOperationException("DDK.InstrumentMap is Null"); } long instrumentsMap = m_DDK.InstrumentMap.Value; if (instrumentsMap == (long)InstrumentID.None) { throw new InvalidOperationException("DDK.InstrumentMap = " + instrumentsMap.ToString() + " must be != " + ((long)InstrumentID.None).ToString()); } string instrumentsMapBinary = InstrumentData.GetBitMapBinary(instrumentsMap); string instrumentsNames = instrumentDataList.GetNames(); bool logInFile = LogInFile; string fileNamePrefix = instrumentDataList[0].Name; Log.Init(Id, logInFile, fileNamePrefix); // Logging in a file starts here, if logInFile is True const string indent = "\t"; string text = Environment.NewLine + Environment.NewLine + indent + "Driver Folder \"" + driverFolder + "\"" + Environment.NewLine + indent + "Name \"" + Name + "\", IsSimulated = " + IsSimulated.ToString() + Environment.NewLine + indent + "USB Address \"" + UsbAddress + "\"" + Environment.NewLine + indent + "DDK.InstrumentMap = " + instrumentsMap.ToString() + " = " + instrumentsMapBinary + " = " + instrumentsNames + Environment.NewLine; Log.WriteLine(Id, text); //------------------------------------------------------------------------------------------------------------------- m_Properties.LogInFile.OnSetProperty += OnPropertyLogInFileSet; //------------------------------------------------------------------------------------------------------------------- CommandTestInit(); CommandStartStopInit(); Log.TaskEnd(Id); } catch (Exception ex) { Log.TaskEnd(Id, ex); throw; } }
void IDriver.Init(IDDK ddk) { m_DDK = ddk; string driverFolder = AppDomain.CurrentDomain.BaseDirectory; Log.TaskBegin(Id, "Driver Folder \"" + driverFolder + "\""); try { #region Instrument Data List long instrumentsMap = ddk.InstrumentMap.Value; if (instrumentsMap == (long)InstrumentID.None) { throw new InvalidOperationException("DDK.InstrumentMap = " + instrumentsMap.ToString() + " must be != " + ((long)InstrumentID.None).ToString()); } string instrumentsMapBinary = InstrumentData.GetBitMapBinary(instrumentsMap); Log.WriteLine(Id, "DDK.InstrumentMap = " + instrumentsMap.ToString() + " = " + instrumentsMapBinary); InstrumentDataList instrumentDataList = new InstrumentDataList(); instrumentDataList.Init(ddk, instrumentsMap); if (instrumentDataList.Count < 1) { throw new InvalidOperationException("Failed to get the instruments from the DDK.InstrumentMap = " + instrumentsMap.ToString() + " = " + instrumentsMapBinary); } #endregion m_Demo = new Demo((IDriverEx)this, ddk, m_Config.Demo, Config.Driver.DeviceId.Demo, instrumentDataList, driverFolder); AddDevice(m_Demo); //m_Heater = new Heater((IDriverEx)this, ddk, m_Config.Heater, Config.Driver.DeviceId.Heater); //AddDevice(m_Heater); //m_Pump = new Pump((IDriverEx)this, ddk, m_Config.Pump, Config.Driver.DeviceId.Pump); //AddDevice(m_Pump); //m_AutoSampler = new AutoSampler((IDriverEx)this, ddk, m_Config.AutoSampler, Config.Driver.DeviceId.AutoSampler); //AddDevice(m_AutoSampler); //m_Detector = new Detector((IDriverEx)this, ddk, m_Config.Detector, Config.Driver.DeviceId.Detector); //AddDevice(m_Detector); Log.TaskEnd(Id); } catch (Exception ex) { Log.TaskEnd(Id, ex); throw; } }