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; } }
public DemoProperties(IDriverEx driver, IDDK ddk, Config.Demo config, IDevice device) { if (ddk == null) { throw new ArgumentNullException("ddk"); } if (config == null) { throw new ArgumentNullException("config"); } if (device == null) { throw new ArgumentNullException("device"); } LogInFile = Property.CreateBool(ddk, device, "LogInFile"); LogInFile.Writeable = true; LogInFile.AuditLevel = AuditLevel.Service; LogInFile.Update(Property.GetBoolNumber(true)); // Can be configurable = config.LogInFile m_IsSimulated = Property.CreateBool(ddk, device, "IsSimulated"); m_IsSimulated.Update(Property.GetBoolNumber(driver.IsSimulated)); if (driver.IsSimulated != config.IsSimulated) { Device.DebuggerBreak(); } FirmwareUsbAddress = Property.CreateString(ddk, device, "FirmwareUsbAddress"); FirmwareUsbAddress.Update(driver.FirmwareUsbAddress); FirmwareVersion = Property.CreateString(ddk, device, "FirmwareVersion"); FirmwareVersion.Update(driver.FirmwareVersion); SerialNo = device.CreateStandardProperty(StandardPropertyID.SerialNo, ddk.CreateString(100)); SerialNo.Update(driver.SerialNo); TaskName = Property.CreateString(ddk, device, "TaskName", driver.TaskName); TaskNamePrevious = Property.CreateString(ddk, device, "TaskNamePrevious", driver.TaskNamePrevious); TaskPreviousErrorText = Property.CreateString(ddk, device, "TaskPreviousErrorText", driver.TaskPreviousErrorText); CommunicationState = Property.CreateEnum(ddk, device, "CommunicationState", driver.CommunicationState, null); BehaviorStatePrev = Property.CreateEnum(ddk, device, "BehaviorStatePrev", driver.BehaviorStatePrev); BehaviorState = Property.CreateEnum(ddk, device, "BehaviorState", driver.BehaviorState); ProcessStep = Property.CreateInt(ddk, device, "ProcessStep"); ProcessStep.Update(0); }