public ChannelProperties(IDDK ddk, IChannel channel) { if (ddk == null) { throw new ArgumentNullException("ddk"); } if (channel == null) { throw new ArgumentNullException("channel"); } ITypeDouble typeDouble = Property.CreateDoubleType(ddk, UnitConversion.PhysUnitEnum.PhysUnit_Hertz, 0.1, 1000, 1); Rate = channel.CreateProperty("Rate", "The data collection rate in " + typeDouble.Unit, typeDouble); Rate.Update(100); typeDouble = Property.CreateDoubleType(ddk, UnitConversion.PhysUnitEnum.PhysUnit_NanoMeter, 200, 400, 1); Wavelength = channel.CreateStandardProperty(StandardPropertyID.Wavelength, typeDouble); AcquisitionTimeOn = Property.CreateString(ddk, channel, "AcquisitionTime_1_On"); AcquisitionTimeOff = Property.CreateString(ddk, channel, "AcquisitionTime_2_Off"); AcquisitionTimeDiff = Property.CreateString(ddk, channel, "AcquisitionTime_3_Diff"); // Make the property available as a report variable. This is stored with the signal as meta data. channel.AddPropertyToChannelInfo(Rate); channel.AddPropertyToChannelInfo(Wavelength); }
/// Create our Chromeleon symbols internal IChannel Create(IDDK cmDDK, string name) { // Create a data type for our signal ITypeInt tSignal = cmDDK.CreateInt(-100, 100); tSignal.Unit = "mV"; // Create the channel symbol m_MyCmDevice = cmDDK.CreateChannel(name, "This is a channel that can generate a sinus curve.", tSignal); // Attach our handlers to the AcquisitionOffCommand and AcquisitionOnCommand of the channel m_MyCmDevice.AcquisitionOffCommand.OnCommand += new CommandEventHandler(OnAcqOff); m_MyCmDevice.AcquisitionOnCommand.OnCommand += new CommandEventHandler(OnAcqOn); m_MyCmDevice.TimeStepFactorProperty.DataType.Minimum = 100; m_MyCmDevice.TimeStepFactorProperty.DataType.Maximum = 100; m_MyCmDevice.TimeStepFactorProperty.Writeable = false; m_MyCmDevice.TimeStepDivisorProperty.DataType.Minimum = 1; m_MyCmDevice.TimeStepDivisorProperty.DataType.Maximum = 100; m_MyCmDevice.TimeStepDivisorProperty.OnSetProperty += new SetPropertyEventHandler(OnTimeStepDivisor); ITypeDouble tWavelength = cmDDK.CreateDouble(200, 400, 1); tWavelength.Unit = "nm"; m_WavelengthProperty = m_MyCmDevice.CreateStandardProperty(StandardPropertyID.Wavelength, tWavelength); // We want to have the wavelength available as a report variable and therefore add it to the channel info. m_MyCmDevice.AddPropertyToChannelInfo(m_WavelengthProperty); // What do we actually measure? m_MyCmDevice.PhysicalQuantity = "MotorCurrent"; // This channel doesn't have peaks, we don't want to have it integrated. m_MyCmDevice.NeedsIntegration = false; // Create a command for writing a spectrum ICommand writeSpectrumCommand = m_MyCmDevice.CreateCommand("WriteSpectrum", "Write a spectrum"); writeSpectrumCommand.OnCommand += new CommandEventHandler(OnWriteSpectrum); // Create an interface for spectrum writing m_SpectrumWriter = m_MyCmDevice.CreateSpectrumWriter(); return(m_MyCmDevice); }
internal void Create(IDDK cmDDK, string deviceName) { m_DDK = cmDDK; ITypeInt tSignal = m_DDK.CreateInt(0, 1000); tSignal.Unit = "mAU"; m_Channel = m_DDK.CreateChannel(deviceName, "Detector device", tSignal); IStringProperty typeProperty = m_Channel.CreateProperty("DeviceType", "The DeviceType property tells us which component we are talking to.", m_DDK.CreateString(20)); typeProperty.Update("Detector"); m_Channel.AcquisitionOffCommand.OnCommand += new CommandEventHandler(OnAcqOff); m_Channel.AcquisitionOnCommand.OnCommand += new CommandEventHandler(OnAcqOn); ITypeDouble tWavelength = m_DDK.CreateDouble(200, 400, 1); tWavelength.Unit = "nm"; m_WavelengthProperty = m_Channel.CreateStandardProperty(StandardPropertyID.Wavelength, tWavelength); m_WavelengthProperty.OnSetProperty += new SetPropertyEventHandler(OnSetWaveLength); // We want to have the wavelength available as a report variable and therefore add it to the channel info. m_Channel.AddPropertyToChannelInfo(m_WavelengthProperty); m_WavelengthProperty.Update(m_WaveLength); // What do we actually measure? m_Channel.PhysicalQuantity = "Absorbance"; m_Timer.Elapsed += new ElapsedEventHandler(OnTimedEvent); }
/// Create our Chromeleon symbols internal IChannel OnCreate(IDDK cmDDK, IDevice master, string name) { // Create a data type for our signal ITypeDouble tSignal = cmDDK.CreateDouble(-100.0, 100.0, 1); tSignal.Unit = "mV"; // Create the channel symbol m_MyCmDevice = cmDDK.CreateChannel(name, "This is a channel that can generate a sinus curve.", tSignal); // We will be a subdevice of the master device m_MyCmDevice.SetOwner(master); // Attach our handlers to the AcquisitionOffCommand and AcquisitionOnCommand of the channel m_MyCmDevice.AcquisitionOffCommand.OnCommand += new CommandEventHandler(OnAcqOff); m_MyCmDevice.AcquisitionOnCommand.OnCommand += new CommandEventHandler(OnAcqOn); m_MyCmDevice.OnDataFinished += new DataFinishedEventHandler(m_MyCmDevice_OnDataFinished); // Usually, TimeStepFactor and TimeStepFactor are read-only properties and the driver updates them. // In this driver we allow to change these values manually for illustration purposes. m_MyCmDevice.TimeStepFactorProperty.DataType.Minimum = 1; m_MyCmDevice.TimeStepFactorProperty.DataType.Maximum = 10000; m_MyCmDevice.TimeStepFactorProperty.OnSetProperty += new SetPropertyEventHandler(TimeStepFactorProperty_OnSetProperty); m_MyCmDevice.TimeStepDivisorProperty.DataType.Minimum = 1; m_MyCmDevice.TimeStepDivisorProperty.DataType.Maximum = 10000; m_MyCmDevice.TimeStepDivisorProperty.OnSetProperty += new SetPropertyEventHandler(TimeStepDivisorProperty_OnSetProperty); ITypeDouble tRateType = cmDDK.CreateDouble(0.1, 1000.0, 1); tRateType.Unit = "Hz"; m_RateProperty = m_MyCmDevice.CreateProperty("FixedRate", "The data collection rate in Hz.", tRateType); m_RateProperty.OnSetProperty += new SetPropertyEventHandler(m_RateProperty_OnSetProperty); // We want to have the FixedRate available as a report variable and therefore add it to the channel info. m_MyCmDevice.AddPropertyToChannelInfo(m_RateProperty); ITypeInt tDataIndexType = cmDDK.CreateInt(0, int.MaxValue); m_DataIndexProperty = m_MyCmDevice.CreateProperty("TotalDataPoints", "Total number of data points.", tDataIndexType); ICommand noMoreDataCommand = m_MyCmDevice.CreateCommand("NoMoreData", "Send IChannel.NoMoreData to stop data acquisition immediately."); noMoreDataCommand.OnCommand += new CommandEventHandler(noMoreDataCommand_OnCommand); ITypeDouble tChannelTimeType = cmDDK.CreateDouble(0, 1000, 3); tChannelTimeType.Unit = "min"; m_ChannelTimeProperty = m_MyCmDevice.CreateProperty("ChannelTime", "Internal time of the channel.", tChannelTimeType); // What do we actually measure? m_MyCmDevice.PhysicalQuantity = "MotorCurrent"; // This channel doesn't have peaks, we don't want to have it integrated. m_MyCmDevice.NeedsIntegration = false; // Create a command for writing a spectrum ICommand writeSpectrumCommand = m_MyCmDevice.CreateCommand("WriteSpectrum", "Write a spectrum"); writeSpectrumCommand.OnCommand += new CommandEventHandler(OnWriteSpectrum); // Create an interface for spectrum writing m_SpectrumWriter = m_MyCmDevice.CreateSpectrumWriter(); return(m_MyCmDevice); }