/// <summary> /// Create our Dionex.Chromeleon.Symbols.IDevice and our Properties and Commands /// </summary> /// <param name="cmDDK">The DDK instance</param> /// <param name="name">The name for our device</param> /// <returns>our IDevice object</returns> internal IDevice Create(IDDK cmDDK, string name) { m_MyCmDDK = cmDDK; // Create our Dionex.Chromeleon.Symbols.IDevice m_MyCmDevice = cmDDK.CreateDevice(name, "Autosampler device."); ITypeDouble tVolume = cmDDK.CreateDouble(0.1, 10.0, 1); tVolume.Unit = "µL"; ITypeInt tPosition = cmDDK.CreateInt(1, 10); for (int i = 1; i <= 10; i++) { tPosition.AddNamedValue("RA" + i.ToString(), i); } tPosition.NamedValuesOnly = false; m_InjectHandler = m_MyCmDevice.CreateInjectHandler(tVolume, tPosition); m_InjectHandler.PositionProperty.OnSetProperty += new SetPropertyEventHandler(OnSetPosition); m_InjectHandler.VolumeProperty.OnSetProperty += new SetPropertyEventHandler(OnSetVolume); m_InjectHandler.InjectCommand.OnCommand += new CommandEventHandler(OnInject); ICommand simulateVialNotFoundCommand = m_MyCmDevice.CreateCommand("SimulateVialNotFound", "Simulate a vial not found error"); simulateVialNotFoundCommand.OnCommand += new CommandEventHandler(simulateVialNotFoundCommand_OnCommand); ICommand modifyPositionTypeCommand = m_MyCmDevice.CreateCommand("ModifyPositionType", "Changes the data type of the Position property and the Inject.Position parameter"); modifyPositionTypeCommand.OnCommand += new CommandEventHandler(modifyPositionTypeCommand_OnCommand); ICommand modifyVolumeTypeCommand = m_MyCmDevice.CreateCommand("ModifyVolumeType", "Changes the data type of the Volume property and the Inject.Volume parameter"); modifyVolumeTypeCommand.OnCommand += new CommandEventHandler(modifyVolumeTypeCommand_OnCommand); ITypeString tTrayDescription = cmDDK.CreateString(500); // ensure length is sufficient, but don't be too generous m_TrayDesciptionProperty = m_MyCmDevice.CreateStandardProperty(StandardPropertyID.TrayDescription, tTrayDescription); m_TrayDesciptionProperty.AuditLevel = AuditLevel.Service; m_TrayDesciptionProperty.Update(GenerateTrayDescription()); // In this example driver, simulating the injection process // is handled by a timer started by the Inject command. // When the timer has elapsed the inject response is generated. m_InjectionTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_InjectionTimer_Elapsed); m_InjectionTimer.AutoReset = false; return(m_MyCmDevice); }
/// <summary> /// Create our Dionex.Chromeleon.Symbols.IDevice and our Properties and Commands /// </summary> /// <param name="cmDDK">The DDK instance</param> /// <param name="name">The name for our device</param> /// <returns>our IDevice object</returns> internal IDevice Create(IDDK cmDDK, string name) { // Create our Dionex.Chromeleon.Symbols.IDevice m_MyCmDevice = cmDDK.CreateDevice(name, "PreparingSampler device."); ITypeDouble tVolume = cmDDK.CreateDouble(0.1, 10.0, 1); ITypeInt tPosition = cmDDK.CreateInt(1, 10); for (int i = 1; i < 10; i++) { tPosition.AddNamedValue("RA" + i.ToString(), i); } m_InjectHandler = m_MyCmDevice.CreateInjectHandler(tVolume, tPosition); m_InjectHandler.PositionProperty.OnSetProperty += new SetPropertyEventHandler(OnSetPosition); m_InjectHandler.VolumeProperty.OnSetProperty += new SetPropertyEventHandler(OnSetVolume); m_InjectHandler.InjectCommand.OnCommand += new CommandEventHandler(OnInject); m_PrepareNextSampleCommand = m_MyCmDevice.CreateCommand("PrepareNextSample", "Start sample preparation for the next injection."); m_PrepareNextSampleCommand.OnCommand += new CommandEventHandler(m_PrepareNextSampleCommand_OnCommand); // Note that before the batch preflight starts all contained methods are preflighted. m_MyCmDevice.OnPreflightBegin += new PreflightEventHandler(m_MyCmDevice_OnPreflightBegin); m_MyCmDevice.OnPreflightEnd += new PreflightEventHandler(m_MyCmDevice_OnPreflightEnd); m_MyCmDevice.OnTransferPreflightToRun += new PreflightEventHandler(m_MyCmDevice_OnTransferPreflightToRun); // The following events can be used to investigate injection properties and stand-alone methods // during batch preflight m_MyCmDevice.OnBatchPreflightBegin += new BatchPreflightEventHandler(m_MyCmDevice_OnBatchPreflightBegin); m_MyCmDevice.OnBatchPreflightSample += new SamplePreflightEventHandler(m_MyCmDevice_OnBatchPreflightSample); m_MyCmDevice.OnBatchPreflightStandAloneProgram += new BatchEntryPreflightEventHandler(m_MyCmDevice_OnBatchPreflightStandAloneProgram); m_MyCmDevice.OnBatchPreflightEmergencyProgram += new BatchEntryPreflightEventHandler(m_MyCmDevice_OnBatchPreflightEmergencyProgram); m_MyCmDevice.OnBatchPreflightEnd += new BatchPreflightEventHandler(m_MyCmDevice_OnBatchPreflightEnd); m_MyCmDevice.OnSequenceStart += new SequencePreflightEventHandler(m_MyCmDevice_OnSequenceStart); m_MyCmDevice.OnSequenceEnd += new SequencePreflightEventHandler(m_MyCmDevice_OnSequenceEnd); m_MyCmDevice.OnSequenceChange += new SequenceChangeEventHandler(m_MyCmDevice_OnSequenceChange); return(m_MyCmDevice); }
internal void Create(IDDK cmDDK, string deviceName) { m_DDK = cmDDK; m_Device = m_DDK.CreateDevice(deviceName, "Sampler device"); IStringProperty typeProperty = m_Device.CreateProperty("DeviceType", "The DeviceType property tells us which component we are talking to.", m_DDK.CreateString(20)); typeProperty.Update("Sampler"); ITypeDouble tVolume = m_DDK.CreateDouble(0.1, 10.0, 1); ITypeInt tPosition = m_DDK.CreateInt(1, 10); m_InjectHandler = m_Device.CreateInjectHandler(tVolume, tPosition); m_InjectHandler.PositionProperty.OnSetProperty += new SetPropertyEventHandler(OnSetPosition); m_InjectHandler.VolumeProperty.OnSetProperty += new SetPropertyEventHandler(OnSetVolume); m_InjectHandler.InjectCommand.OnCommand += new CommandEventHandler(OnInject); //Create ready property ITypeInt tReady = m_DDK.CreateInt(0, 1); //Add named values tReady.AddNamedValue("NotReady", 0); tReady.AddNamedValue("Ready", 1); m_ReadyProperty = m_Device.CreateStandardProperty(StandardPropertyID.Ready, tReady); m_ReadyProperty.Update(1); m_Device.OnBroadcast += new BroadcastEventHandler(OnBroadcast); }
public AutoSampler(IDriverEx driver, IDDK ddk, Config.AutoSampler config, string id) : base(driver, ddk, typeof(AutoSampler).Name, id, config.Name) { Log.TaskBegin(Id); try { m_Properties = new AutoSamplerProperties(m_DDK, m_Device); ITypeDouble volumeType = m_DDK.CreateDouble(0.1, 30, 3); volumeType.Unit = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_MicroLiter); // µl int positionMax = m_RackInfos.Sum(item => item.TubeColumnsCount * item.TubeRowsCount); ITypeInt positionType = m_DDK.CreateInt(1, positionMax); positionType.NamedValuesOnly = false; int position = positionType.Minimum.GetValueOrDefault() - 1; foreach (RackInfo rack in m_RackInfos) { int tubeNumber = rack.TubeFirstNumber - 1; for (int row = 1; row <= rack.TubeRowsCount; row++) { for (int col = 1; col <= rack.TubeColumnsCount; col++) { position++; tubeNumber++; string positionName = rack.TubePositionNamePrefix + tubeNumber.ToString(); positionType.AddNamedValue(positionName, tubeNumber); } } } m_InjectHandler = m_Device.CreateInjectHandler(volumeType, positionType); m_RackDesciptionProperty = m_Device.CreateStandardProperty(StandardPropertyID.TrayDescription, m_DDK.CreateString(1000)); m_RackDesciptionProperty.AuditLevel = AuditLevel.Service; string rackDescription = GetRackDescription(); if (m_RackDesciptionProperty.DataType.Length < rackDescription.Length) { throw new InvalidOperationException("m_RackDesciptionProperty length " + m_RackDesciptionProperty.DataType.Length + " is less than the needed " + rackDescription.Length.ToString()); } m_RackDesciptionProperty.Update(rackDescription); m_Position = -1; m_VolumeUnitName = m_InjectHandler.VolumeProperty.DataType.Unit; // µl m_VolumeUnit = UnitConversionEx.PhysUnitFindName(m_VolumeUnitName); m_InjectHandler.PositionProperty.OnSetProperty += OnPropertyPositionSet; m_InjectHandler.VolumeProperty.OnSetProperty += OnPropertyVolumeSet; m_InjectHandler.InjectCommand.OnCommand += OnCommandInjectHandlerInject; m_Device.OnBatchPreflightBegin += OnDeviceBatchPreflightBegin; m_Device.OnPreflightEnd += OnDevicePreflightEnd; m_Device.OnTransferPreflightToRun += OnDeviceTransferPreflightToRun; m_Device.OnSequenceStart += OnDeviceSequenceStart; m_Device.OnSequenceChange += OnDeviceSequenceChange; m_Device.OnSequenceEnd += OnDeviceSequenceEnd; m_Device.OnBroadcast += OnDeviceBroadcast; m_Driver.OnConnected += OnDriverConnected; m_Driver.OnDisconnected += OnDriverDisconnected; Log.TaskEnd(Id); } catch (Exception ex) { Log.TaskEnd(Id, ex); throw; } }