/// <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, "This is device that illustrates the usage of IDevice.DelayTermination."); m_DelayTerminationProperty = m_MyCmDevice.CreateBooleanProperty("DelayTermination", "Enable/Disable termination delay.", "Off", "On"); m_DelayTerminationProperty.OnSetProperty += new SetPropertyEventHandler(m_DelayTerminationProperty_OnSetProperty); ITypeInt tTimeout = cmDDK.CreateInt(0, 30); tTimeout.Unit = "s"; m_TerminationTimeoutProperty = m_MyCmDevice.CreateProperty("TerminationTimeout", "The timeout for the delayed termination.", tTimeout); m_TerminationTimeoutProperty.OnSetProperty += new SetPropertyEventHandler(m_TerminationTimeoutProperty_OnSetProperty); m_TerminateInTimeProperty = m_MyCmDevice.CreateBooleanProperty("TerminateInTime", "Enable/Disable proper termination.", "Off", "On"); m_TerminateInTimeProperty.OnSetProperty += new SetPropertyEventHandler(m_TerminateInTimeProperty_OnSetProperty); m_MyCmDevice.OnTransferPreflightToRun += new PreflightEventHandler(m_MyCmDevice_OnTransferPreflightToRun); m_MyCmDevice.OnBroadcast += new BroadcastEventHandler(m_MyCmDevice_OnBroadcast); m_ProgramTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_ProgramTimer_Elapsed); 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) { 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); }
private static IDevice CreateChannel(IDDK ddk, string name, UnitConversion.PhysUnitEnum unit) { ITypeInt typeSignal = ddk.CreateInt(0, 1000); typeSignal.Unit = UnitConversionEx.PhysUnitName(unit); IChannel result = ddk.CreateChannel(name, "Detector channel", typeSignal); return(result); }
internal IChannel Create(IDDK cmDDK, string name) { // Create a data type for our signal ITypeInt tSignal = cmDDK.CreateInt(-100, 100); // 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 = 1; m_MyCmDevice.TimeStepFactorProperty.DataType.Maximum = 1; m_MyCmDevice.TimeStepFactorProperty.Writeable = false; m_MyCmDevice.TimeStepDivisorProperty.DataType.Minimum = 1; m_MyCmDevice.TimeStepDivisorProperty.DataType.Maximum = 1; m_MyCmDevice.TimeStepDivisorProperty.Writeable = false; m_dcr = m_MyCmDevice.CreateProperty("Data_Collection_Rate", "This is the data collection rate of the device", cmDDK.CreateDouble(0.1, 300.0, 1)); m_dcr.OnPreflightSetProperty += new SetPropertyEventHandler(m_dcr_OnPreflightSetProperty); m_dcr.OnSetProperty += new SetPropertyEventHandler(m_dcr_OnSetProperty); ITypeInt dcrModeType = cmDDK.CreateInt(0, 1); dcrModeType.AddNamedValue("Regular", 0); dcrModeType.AddNamedValue("Random", 1); m_dcrmode = m_MyCmDevice.CreateProperty("DCRMode", "Mode in which the data points are sent - regular interval or arbitrary", dcrModeType); m_dcrmode.OnSetProperty += new SetPropertyEventHandler(m_dcrmode_OnSetProperty); m_dcrmode.OnPreflightSetProperty += new SetPropertyEventHandler(m_dcrmode_OnPreflightSetProperty); ITypeInt signalTypeType = cmDDK.CreateInt(0, 1); signalTypeType.AddNamedValue("SawTooth", 0); signalTypeType.AddNamedValue("Sinus", 1); m_signalType = m_MyCmDevice.CreateProperty("SignalType", "The signal type of the simulation mode data - SawTooth or Sinus (frequency 0.1Hz)", signalTypeType); m_signalType.OnSetProperty += new SetPropertyEventHandler(m_signalType_OnSetProperty); return(m_MyCmDevice); }
/// We will create our properties in here. internal IDevice Create(IDDK cmDDK, string name) { m_MyCmDevice = cmDDK.CreateDevice(name, "Relay"); ITypeInt tState = cmDDK.CreateInt(0, 1); m_PropState = m_MyCmDevice.CreateProperty("State", "Indicates or sets the relay's state.", tState); m_PropState.OnSetProperty += new SetPropertyEventHandler(OnSetState); return(m_MyCmDevice); }
private static ITypeInt CreateIntType(IDDK ddk, int minValue = int.MinValue + 1, int maxValue = int.MaxValue) { // The Real Time Kernel has one special value for a property that is used for an undefined / empty value. // In case of an integer property this is int.MinValue = -2147483648 = (-2147483647 - 1) == INVALID_INT == INVALID_LONG == INT_MIN == LONG_MIN. // This value should not be used as the minimum for the property. if (minValue == int.MinValue) { throw new ArgumentOutOfRangeException("Cannot create an integer type with minimum value minValue = int.MinValue = " + int.MinValue.ToString() + ". " + // -2147483648 "The minimum value cannot be smaller than int.MinValue + 1 = " + (int.MinValue + 1).ToString()); // -2147483647 } ITypeInt result = ddk.CreateInt(minValue, maxValue); return(result); }
/// 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, "Channel that can generate both sinus curve and sawtooth signal as Int64 data points.", 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); // These two parameters are not longer relevant when using the new UpdateDataEx function // in contradiction to the old UpdateData interface. So leave these parameters unchanged; // the DDK will initialize them appropriately. m_MyCmDevice.TimeStepFactorProperty.Writeable = false; m_MyCmDevice.TimeStepDivisorProperty.Writeable = false; 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); 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); // This channel doesn't have peaks, we don't want to have it integrated. m_MyCmDevice.NeedsIntegration = false; return(m_MyCmDevice); }
void modifyPositionTypeCommand_OnCommand(CommandEventArgs args) { ITypeInt tNewPositionType = m_MyCmDDK.CreateInt(0, 20); for (int i = 0; i <= 20; i++) { tNewPositionType.AddNamedValue("X" + i.ToString(), i); } tNewPositionType.NamedValuesOnly = true; ITypeDouble tOldVolumeType = m_InjectHandler.VolumeProperty.DataType; // remains unchanged m_InjectHandler.UpdateDataTypes(tOldVolumeType, tNewPositionType); }
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); }
/// <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); }
/// 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); }
/// <summary> /// Create our Dionex.Chromeleon.Symbols.IChannel 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 IChannel Create(IDDK cmDDK, string name) { ITypeInt tSignal = cmDDK.CreateInt(-1000, 1000); m_MyCmDevice = cmDDK.CreateChannel(name, "Nelson NCI 900 Channel", tSignal); 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); return(m_MyCmDevice); }
private static IDevice CreateChannel(IDDK ddk, string name, UnitConversion.PhysUnitEnum unit) { if (ddk == null) { throw new ArgumentNullException("ddk"); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (unit == UnitConversion.PhysUnitEnum.PhysUnit_Unknown) { throw new ArgumentException("The unit mus be specified"); } ITypeInt typeSignal = ddk.CreateInt(0, 1000); typeSignal.Unit = UnitConversionEx.PhysUnitName(unit); IChannel result = ddk.CreateChannel(name, "Detector channel", typeSignal); return(result); }
/// <summary> /// Create our Dionex.Chromeleon.Symbols.IDevice and our Properties and Commands /// </summary> /// <param name="cmDDK">The DDK instance</param> /// <param name="driver">The driver instance</param> /// <param name="name">The name for our device</param> /// <returns>our IDevice object</returns> internal IDevice OnCreate(ChannelTestDriver driver, IDDK cmDDK, string name) { m_Driver = driver; // Create our Dionex.Chromeleon.Symbols.IDevice m_MyCmDevice = cmDDK.CreateDevice(name, "This is the master device of the ChannelTest driver."); m_MyCmDevice.ImmediateNotReady = true; // NOTE: // Setting 'ImmediateNotReady' to true on the main device toggles the 'Ready' property for 5s(default) to false when entering TransferPreflightToRun, unless one updates the ready property explicitly. // Therefore it's also necessary to create a standard property 'Ready' which can be toggled and which can be added to instrument methods in a Wait statement. // More background: // In common LC/GC environments an injector is used in the instrument configuration and it's Inject command in the method would cause a natural delay. // In our example driver we have no delay like this and can run into a kind of data exchange delay issue. // Setting the parameter FixedRate in a method updates also the channel parameters TimeStepFactorProperty and TimeStepDevisorProperty. // If setting the parameter FixedRate is immediately followed by an AcqOn command, the 'Real Time Kernel' might not be updated via interprocess communication soon enough and // calculates the number of expected datapoints with old settings of TimeStepFactorProperty and TimeStepDevisorProperty. This might stop the data acquisition by 'OnDataFinished' when faulty 'enough' data points have been dumped. // To avoid this in this example, following to steps in combination are necessary: // 1) introducing a standard property 'Ready' which can be checked in the instrument method. // 2) Set ChannelTest.ImmediateNotReady to true // 3) Adding a Wait ChannelTest.Ready in the method before AcqOn. // This provides enough time when setting FixedRate in our example to update the 'Real Time Kernel's TimeStepFactorProperty and TimeStepDevisorProperty. // Create a command for the hardware error simulation. m_HardwareErrorCommand = m_MyCmDevice.CreateCommand("HardwareError", "This command simulates a hardware error."); m_HardwareErrorCommand.OnCommand += new CommandEventHandler(m_HardwareErrorCommand_OnCommand); //Create ready property ITypeInt tReady = cmDDK.CreateInt(0, 1); //Add named values tReady.AddNamedValue("NotReady", 0); tReady.AddNamedValue("Ready", 1); ReadyProperty = m_MyCmDevice.CreateStandardProperty(StandardPropertyID.Ready, tReady); ReadyProperty.Update(1); 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); }
/// <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 the Dionex.Chromeleon.Symbols.IDevice m_MyCmDevice = cmDDK.CreateDevice(name, "This is an example device."); // create a few example properties // A Data type for seconds ranging from 0 - 59 ITypeInt tSeconds = cmDDK.CreateInt(0, 59); tSeconds.Unit = "s"; // Create the "Clock" property m_ClockProperty = m_MyCmDevice.CreateProperty("Clock", "This is a second counter", tSeconds); // Attach the OnSetClockProperty handler to the "Clock" property m_ClockProperty.OnSetProperty += new SetPropertyEventHandler(OnSetClockProperty); // we will use a timer to update the clock property each second // Attach the OnTimedEvent handler to the timer. m_clockTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); // A Data type with two values 0 and 1 ITypeInt tEnable = cmDDK.CreateInt(0, 1); tEnable.AddNamedValue("false", 0); tEnable.AddNamedValue("true", 1); // Create the "EnableClock" property m_EnableClockProperty = m_MyCmDevice.CreateProperty("EnableClock", "Enable / disable the clock", tEnable); // Attach the OnEnableClock handler to the "EnableClock" property m_EnableClockProperty.OnSetProperty += new SetPropertyEventHandler(OnEnableClock); // A Data type for a percentage ranging from 0.0 - 100.0 ITypeDouble tPercent = cmDDK.CreateDouble(0, 100, 2); tPercent.Unit = "%"; // Create the "Percentage" property m_PercentageProperty = m_MyCmDevice.CreateProperty("Percentage", "This is a percentage property", tPercent); // Attach the OnSetProperty handler to the "Percentage" property m_PercentageProperty.OnSetProperty += new SetPropertyEventHandler(OnSetProperty); // A Data type for a time constant ranging from 1.0 - 10.0 ITypeDouble tTimeConstant = cmDDK.CreateDouble(1.0, 10.0, 1); tTimeConstant.AddNamedValue("Off", 0.0); tTimeConstant.Unit = "s"; // Create the "Percentage" property m_FilterTimeConstantProperty = m_MyCmDevice.CreateProperty("FilterTimeConstant", "This is a numeric property with one special named value.", tTimeConstant); // Attach the OnSetProperty handler to the "FilterTimeConstant" property m_FilterTimeConstantProperty.OnSetProperty += new SetPropertyEventHandler(OnSetProperty); // A Data type for the measurement range property ITypeDouble tMeasurementRange = cmDDK.CreateDouble(0.01, 100.0, 2); tMeasurementRange.LegalValues = new double[] { 0.01, 0.1, 1.0, 10.0, 100.0 }; tMeasurementRange.EnforceLegalValues = true; tMeasurementRange.Unit = "V"; // Create the "Percentage" property m_MeasurementRangeProperty = m_MyCmDevice.CreateProperty("MeasurementRange", "This is a numeric property with 5 legal (valid) values.", tMeasurementRange); // Attach the OnSetProperty handler to the "FilterTimeConstant" property m_MeasurementRangeProperty.OnSetProperty += new SetPropertyEventHandler(OnSetProperty); // A Data type for a string with 20 characters at most ITypeString tString = cmDDK.CreateString(20); // Create the "AnyText" property m_AnyTextProperty = m_MyCmDevice.CreateProperty("AnyText", "This is a string property", tString); // Attach the OnSetProperty handler to the "AnyText" property m_AnyTextProperty.OnSetProperty += new SetPropertyEventHandler(OnSetProperty); // Create the "ToggleEnableClock" example command m_Command = m_MyCmDevice.CreateCommand("ToggleEnableClock", "This is a simple command that toggles the EnableClock property."); // Attach the OnToggleEnableClock handler to the "ToggleEnableClock" command m_Command.OnCommand += new CommandEventHandler(OnToggleEnableClock); // Create the "SetEnableClock" command which uses a parameter. m_SetEnableClockCommand = m_MyCmDevice.CreateCommand("SetEnableClock", "This is a command with one required parameter. Set true or false to enable/disable the clock."); // Add the "Enable" parameter to the "SetEnableClock" command IParameter parameter = m_SetEnableClockCommand.AddParameter("Enable", "Set true or false to enable/disable the clock", tEnable); // This is a required parameter. parameter.Required = true; // Attach the OnSetEnableClock handler to the "SetEnableClock" command m_SetEnableClockCommand.OnCommand += new CommandEventHandler(OnSetEnableClock); // Create the "SetPercentage" command which uses a parameter. m_SetPercentageCommand = m_MyCmDevice.CreateCommand("SetPercentage", "This is a command with one required parameter to set the \"Percentage\" property."); // Add the "Value" parameter to the "SetPercentage" command parameter = m_SetPercentageCommand.AddParameter("Value", "Set to 0.00 - 100.00", tPercent); // This is a required parameter. parameter.Required = true; // Attach the OnSetPercentage handler to the "SetPercentage" command m_SetPercentageCommand.OnCommand += new CommandEventHandler(OnSetPercentage); // Create the "CommandWith4Parameters" command which uses 4 optional parameters. m_CommandWith4Parameters = m_MyCmDevice.CreateCommand("CommandWith4Parameters", "This is a command with four optional parameters."); // Add the parameters to the "CommandWith4Parameters" command m_CommandWith4Parameters.AddParameter("Param1", "Set true or false", tEnable); m_CommandWith4Parameters.AddParameter("Param2", "Set to 0.00 - 100.00", tPercent); m_CommandWith4Parameters.AddParameter("Param3", "Set true or false", tEnable); m_CommandWith4Parameters.AddParameter("Param4", "A string with 20 characters", tString); // Attach the OnCommandWith4Parameters handler to the "CommandWith4Parameters" command m_CommandWith4Parameters.OnCommand += new CommandEventHandler(OnCommandWith4Parameters); 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, "This is my first DDK device."); m_MyStringProperty = m_MyCmDevice.CreateProperty("MyStringProperty", "A string property", cmDDK.CreateString(5)); m_MyStringProperty.OnSetProperty += new SetPropertyEventHandler(m_MyStringProperty_OnSetProperty); m_MyStringProperty.OnPreflightSetProperty += m_MyStringProperty_OnPreflightSetProperty; // Create a Property of type double. m_MyDoubleProperty = m_MyCmDevice.CreateProperty("MyDoubleProperty", "This is my first property", cmDDK.CreateDouble(0, 20, 2)); // Set the property to writable. m_MyDoubleProperty.Writeable = true; // And provide a handler that gets called when the property is assigned. m_MyDoubleProperty.OnSetProperty += new SetPropertyEventHandler(m_MyDoubleProperty_OnSetProperty); // Update all properties that have to be readable before the device is connected. m_MyDoubleProperty.Update(20.0); // Create a Property of type int. m_MyIntProperty = m_MyCmDevice.CreateProperty("MyIntProperty", "This is my second property", cmDDK.CreateInt(-1, 2)); // Set the property to read-only. m_MyIntProperty.Writeable = false; // No value known until the device is connected. m_MyIntProperty.Update(null); CreateMoreProperties(cmDDK); return(m_MyCmDevice); }
/// <summary> /// This illustrates variations on the ITypeDouble that can be used for creating properties /// </summary> internal void CreateMoreProperties(IDDK cmDDK) { ITypeDouble type1 = cmDDK.CreateDouble(-1, 1, 0); // Range: [-1...1] // - any number -1 <= x <= 1 can be assigned, will be rounded to 0 decimals // - user input is allowed with 0 decimals only (-1|0|1) // - numbers outside this range (-1|0|1) cause validation errors in panel edit controls or during Instrument Method syntax checking // - panel edit control's spin box will spin -1,0,1 // - F8 box's/Instrument Method Editor's drop list will contain -1,0,1 IDoubleProperty type1Property = m_MyCmDevice.CreateProperty("Type1Property", "", type1); type1Property.Update(-1); //set default value type1Property.OnSetProperty += new SetPropertyEventHandler(type1Property_OnSetProperty); ITypeDouble type2 = cmDDK.CreateDouble(-1, 1, 2); type2.Unit = "bar"; // Range: [-1.00..1.00 bar] // - any number -1 <= x <= 1 can be assigned, will be rounded to 2 decimals // - user input is allowed with up to 2 decimals // - numbers outside this range cause validation errors in panel edit controls or during Instrument Method syntax checking // - unit "bar" is shown in Commands overview (F8), // and can be appended to text shown in panel edit controls and panel string displays // - unit [bar] can be added to assignments in Instrument Method scripts, // system can also convert from other units if it makes sense, // e.g. Type2Property = 1 [psi] is equal to Type2Property = 0.0689475729 [bar] // - panel edit control's spin box will spin in 0.01 incrementals // - F8 box's/Instrument Method Editor's drop list will be empty as it would be too long (a maximum of 12 items can be shown) IDoubleProperty type2Property = m_MyCmDevice.CreateProperty("Type2Property", "", type2); type2Property.Update(0.0); //set default value type2Property.OnSetProperty += new SetPropertyEventHandler(type2Property_OnSetProperty); ITypeDouble type3 = cmDDK.CreateDouble(0, 20, 1); type3.AddNamedValue("Null", 0); type3.AddNamedValue("OnePointFive", 1.5); type3.AddNamedValue("Ten", 10); type3.AddNamedValue("Thirty", 30); // Range: [Null..20.0] - when a property is displayed or logged, a named value is used instead of a pure number if a named value is available. // - any number 0 <= x <= 20 can be assigned, will be rounded to 1 decimal // - 30 can also be assigned, even if it is outside the min/max range, because it has been added as named value // - user input is allowed with up to 1 decimal // - instead of Type3Property = 0, one can write Type3Property = Null // - instead of Type3Property = 1.5, one can write Type3Property = OnePointFive // - instead of Type3Property = 10, one can write Type3Property = Ten // - instead of Type3Property = 30, one can write Type3Property = Thirty // - panel edit control's spin box will spin in 0.1 incrementals: Null, 0.1, 0.2, ..., 1.4, OnePointFive, 1.6, .... 20.0, Thirty // - F8 box's/Instrument Method Editor's drop list contains the four named values IDoubleProperty type3Property = m_MyCmDevice.CreateProperty("Type3Property", "", type3); type3Property.Update(4);//set default value type3Property.OnSetProperty += new SetPropertyEventHandler(type3Property_OnSetProperty); ITypeDouble type4 = cmDDK.CreateDouble(0, 20, 1); type4.AddNamedValue("Null", 0); type4.AddNamedValue("Ten", 10); type4.AddNamedValue("Twenty", 20); type4.NamedValuesOnly = true; // Range: [Null..Twenty] - when a property is displayed or logged, a named value is used instead of a pure number if a named value is available. // - numbers 0.0, 10.0 and 20.0 can be assigned only, because of the 'NamedValuesOnly' flag. // - instead of Type3Property = 0, one can write Type3Property = Null // - instead of Type3Property = 10, one can write Type3Property = Ten // - instead of Type3Property = 20, one can write Type3Property = Twenty // - panel edit control's spin box will spin Null, Ten, Twenty only. Other values will cause validation errors // - F8 box's/Instrument Method Editor's drop list contains the three named values, other values will cause validation errors IDoubleProperty type4Property = m_MyCmDevice.CreateProperty("Type4Property", "", type4); type4Property.Update(0);//set default value type4Property.OnSetProperty += new SetPropertyEventHandler(type4Property_OnSetProperty); ITypeDouble type5 = cmDDK.CreateDouble(0, 20, 1); Double[] legalValues = { 1.1, 2.2, 3.3 }; type5.LegalValues = legalValues; // Range: [0.0..20.0] // - any (!) number 0 <= x <= 20 can be assigned, will be rounded to 1 decimal // - user input is allowed with up to 1 decimal // - panel edit control's spin box will spin to 1.1, 2.2 and 3.3 (due to LegalValues) // - F8 box's/Instrument Method Editor's drop list contains the three legal values IDoubleProperty type5Property = m_MyCmDevice.CreateProperty("Type5Property", "", type5); type5Property.Update(2.2);//set default value type5Property.OnSetProperty += new SetPropertyEventHandler(type5Property_OnSetProperty); ITypeDouble type6 = cmDDK.CreateDouble(0, 20, 1); type6.LegalValues = legalValues; type6.AddNamedValue("Null", 0); type6.AddNamedValue("OnePointFive", 1.5); type6.AddNamedValue("Ten", 10); type6.AddNamedValue("Twenty", 20); // Range: [Null..20.0] // - any (!) number 0 <= x <= 20 can be assigned, will be rounded to 1 decimal // - user input is allowed with up to 1 decimal // - panel edit control's spin box will spin to all legal and named values // - F8 box's/Instrument Method Editor's drop list contains the seven legal and named values IDoubleProperty type6Property = m_MyCmDevice.CreateProperty("Type6Property", "", type6); type6Property.Update(10);//set default value type6Property.OnSetProperty += new SetPropertyEventHandler(type6Property_OnSetProperty); ITypeInt badBooleanType = cmDDK.CreateInt(0, 1); IIntProperty badBoolean1 = m_MyCmDevice.CreateProperty("BadBoolean", "This is a Boolean type without enumerations. Please define appropriate enumerations in the driver!", badBooleanType); badBoolean1.OnSetProperty += new SetPropertyEventHandler(badBoolean_OnSetProperty); m_MyProperBoolean = m_MyCmDevice.CreateBooleanProperty("ProperBoolean", "This is how to do it", "False_No_Zero_NotReady", "True_Yes_One_Ready"); m_MyProperBoolean.OnSetProperty += new SetPropertyEventHandler(properBoolean_OnSetProperty); ITypeInt explicitBooleanType = cmDDK.CreateInt(0, 1); explicitBooleanType.AddNamedValue("False_No_Zero_NotReady", 0); explicitBooleanType.AddNamedValue("True_Yes_One_Ready", 1); explicitBooleanType.NamedValuesOnly = true; IIntProperty explicitBoolean = m_MyCmDevice.CreateProperty("ExplicitBoolean", "Also ok, but way more explicit code", explicitBooleanType); explicitBoolean.OnSetProperty += new SetPropertyEventHandler(explicitBoolean_OnSetProperty); }
/// <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 the Dionex.Chromeleon.Symbols.IDevice m_MyCmDevice = cmDDK.CreateDevice(name, "This is an example device."); // create a few example properties // A Data type for a flow ranging from 0.000 - 10.000 ITypeDouble tFlow = cmDDK.CreateDouble(0, 10, 3); tFlow.Unit = "ml/min"; // Create our flow handler. The flow handler creates a Flow.Nominal, // a Flow.Value and 2 eluent component properties for us. m_FlowHandler = m_MyCmDevice.CreateFlowHandler(tFlow, 2, 2); // initialize the flow m_FlowHandler.FlowNominalProperty.Update(0); // initialize the components m_FlowHandler.ComponentProperties[0].Update(100.0); m_FlowHandler.ComponentProperties[1].Update(0); // All properties support ramps m_FlowHandler.FlowNominalProperty.RampSyntax = true; m_FlowHandler.ComponentProperties[0].RampSyntax = true; m_FlowHandler.ComponentProperties[1].RampSyntax = true; // Attach various handlers m_FlowHandler.FlowNominalProperty.OnSetProperty += new SetPropertyEventHandler(m_RampedFlowProperty_OnSetProperty); m_FlowHandler.ComponentProperties[1].OnSetProperty += new SetPropertyEventHandler(m_RampedPercentageProperty_OnSetProperty); m_FlowHandler.FlowNominalProperty.OnSetRamp += new SetRampEventHandler(m_RampedFlowProperty_OnSetRamp); m_FlowHandler.ComponentProperties[1].OnSetRamp += new SetRampEventHandler(m_RampedPercentageProperty_OnSetRamp); m_FlowHandler.FlowNominalProperty.OnPreflightSetProperty += new SetPropertyEventHandler(m_RampedFlowProperty_OnPreflightSetProperty); m_FlowHandler.ComponentProperties[1].OnPreflightSetProperty += new SetPropertyEventHandler(m_RampedPercentageProperty_OnPreflightSetProperty); m_FlowHandler.FlowNominalProperty.OnPreflightSetRamp += new SetRampEventHandler(m_RampedFlowProperty_OnPreflightSetRamp); m_FlowHandler.ComponentProperties[1].OnPreflightSetRamp += new SetRampEventHandler(m_RampedPercentageProperty_OnPreflightSetRamp); m_MyCmDevice.OnSetTimeTable += new SetTimeTableEventHandler(m_MyCmDevice_OnSetTimeTable); m_MyCmDevice.OnPreflightSetTimeTable += new SetTimeTableEventHandler(m_MyCmDevice_OnPreflightSetTimeTable); // now create the properties and command for valve simulation ITypeInt valvePropType = cmDDK.CreateInt(1, 2); valvePropType.LegalValues = new[] { 1, 2 }; m_ValveState = m_MyCmDevice.CreateProperty("ValveState", "The state of the simulated valve, can be '1' or '2'.", valvePropType); m_ValveState.OnSetProperty += new SetPropertyEventHandler(m_ValveState_OnSetProperty); m_ValveState.OnPreflightSetProperty += new SetPropertyEventHandler(m_ValveState_OnPreflightSetProperty); m_ValveCommandTo1 = m_MyCmDevice.CreateCommand("SwitchValveTo1", "Switch the simulated valve to '1' state."); m_ValveCommandTo1.OnCommand += new CommandEventHandler(m_ValveCommandTo1_OnCommand); m_ValveCommandTo1.OnPreflightCommand += new CommandEventHandler(m_ValveCommandTo1_OnPreflightCommand); m_ValveCommandTo2 = m_MyCmDevice.CreateCommand("SwitchValveTo2", "Switch the simulated valve to '2' state."); m_ValveCommandTo2.OnCommand += new CommandEventHandler(m_ValveCommandTo2_OnCommand); m_ValveCommandTo2.OnPreflightCommand += new CommandEventHandler(m_ValveCommandTo2_OnPreflightCommand); m_ValveCommandWithPar = m_MyCmDevice.CreateCommand("SwitchValve", "Switch the simulated valve according to parameters."); m_ValveStateParameter = m_ValveCommandWithPar.AddParameter("NewState", "The new state of the simulated valve, can be '1' or '2'.", valvePropType); m_ValveStateParameter.Required = true; m_ValveLogParameter = m_ValveCommandWithPar.AddParameter("Message", "A message to be written when executing the command.", m_MyCmDDK.CreateString(64)); m_ValveLogParameter.Required = false; m_ValveCommandWithPar.OnCommand += new CommandEventHandler(m_ValveCommandWithPar_OnCommand); m_ValveCommandWithPar.OnPreflightCommand += new CommandEventHandler(m_ValveCommandWithPar_OnPreflightCommand); return(m_MyCmDevice); }
/// Create our Chromeleon symbols internal IPDAChannel OnCreate(IDDK cmDDK, IDevice master, string name) { // Create a data type for the wavelength range ITypeDouble tWavelength = cmDDK.CreateDouble(200.0, 600.0, 1); tWavelength.Unit = "nm"; // Create a data type for the reference wavelength range ITypeDouble tRefWavelength = cmDDK.CreateDouble(200.0, 600.0, 1); tRefWavelength.Unit = "nm"; tRefWavelength.AddNamedValue("Off", 0.0); // Create a data type for the reference bandwidth ITypeDouble tReferenceBandwidth = cmDDK.CreateDouble(0.0, 20.0, 1); tReferenceBandwidth.Unit = "nm"; // Create a data type for the bunch width ITypeDouble tBunchWidth = cmDDK.CreateDouble(0.0, 10.0, 1); tBunchWidth.Unit = "nm"; // Create the channel symbol m_MyCmDevice = cmDDK.CreatePDAChannel(name, "This is a channel that can generate a spectrum.", tWavelength, tRefWavelength, tReferenceBandwidth, tBunchWidth, 400, PDAWriteMode.AbsorbanceDirect); // 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); ITypeInt tDataIndexType = cmDDK.CreateInt(0, int.MaxValue); m_SpectraIndexProperty = m_MyCmDevice.CreateProperty("TotalSpectra", "Total number of spectra.", 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); return(m_MyCmDevice); }
/// Create our Dionex.Chromeleon.Symbols.IDevice and our Properties internal IDevice Create(IDDK cmDDK, string name) { // Create a device for temperature control m_Device = cmDDK.CreateDevice(name, "Example for a temperature control device"); // Create a type for a temperature logging command ITypeInt tyTempLogParam = cmDDK.CreateInt(0, 2); tyTempLogParam.AddNamedValue("Start", 0); tyTempLogParam.AddNamedValue("Stop", 1); tyTempLogParam.AddNamedValue("Pause", 2); // Create a temperature logging command ICommand logTemperature = m_Device.CreateCommand("LogTemperature", "Switches temperature logging on / off"); // Add a parameter for the tewmperature logging command logTemperature.AddParameter("LogParameter", "Starts, stops or pauses temperature logging", tyTempLogParam); // Create a boolean property to signal if the device is ready for an inject operation. ITypeInt tyReady = cmDDK.CreateInt(0, 1); tyReady.AddNamedValue("False", 0); tyReady.AddNamedValue("True", 1); IProperty readyProp = m_Device.CreateStandardProperty(StandardPropertyID.Ready, tyReady); // Create a data type that represent the activation state of the temperature control. ITypeInt tOnOff = cmDDK.CreateInt((int)TempCtrlState.Off, (int)TempCtrlState.On); tOnOff.AddNamedValue("Off", (int)TempCtrlState.Off); tOnOff.AddNamedValue("On", (int)TempCtrlState.On); // Create a property to activate / deactivate temperature control // This property must be writable m_TempCtrlProperty = m_Device.CreateProperty("TemperatureControl", "Activates /deactivates temperature control", tOnOff); m_TempCtrlProperty.Writeable = true; // Create a struct that holds standard properties for temperature and temperature limits m_TempCtrlStruct = m_Device.CreateStruct("Temperature", "Temperature of Column Oven."); // Create a data type that applies to all temperature properties ITypeDouble tTemperature = cmDDK.CreateDouble(0, 100, 1); tTemperature.Unit = "°C"; // Create a property that holds the current temperature // This property is read-only m_CurrentTempProperty = m_TempCtrlStruct.CreateStandardProperty(StandardPropertyID.Value, tTemperature); // Create a property that holds the nominal temperature // This property must be writeable m_NominalTempProperty = m_TempCtrlStruct.CreateStandardProperty(StandardPropertyID.Nominal, tTemperature); m_NominalTempProperty.Update(30.0); //set default value m_NominalTempProperty.OnSetProperty += new SetPropertyEventHandler(OnSetTemperature); // Create a property that holds the minimal temperature // This property must be writeable m_MinTempProperty = m_TempCtrlStruct.CreateStandardProperty(StandardPropertyID.LowerLimit, tTemperature); m_MinTempProperty.Update(15.0); //set default value m_MinTempProperty.Writeable = true; // Create a property that holds the maximal temperature // This property must be writeable m_MaxTempProperty = m_TempCtrlStruct.CreateStandardProperty(StandardPropertyID.UpperLimit, tTemperature); m_MaxTempProperty.Update(110.0);//set default value m_MaxTempProperty.Writeable = true; // Set the default read and write properties for the struct m_TempCtrlStruct.DefaultSetProperty = m_NominalTempProperty; m_TempCtrlStruct.DefaultGetProperty = m_CurrentTempProperty; // Update property values. They must be readable before the device has been connected. // The device may not be connected when UI-Modules read the default values. m_TempCtrlProperty.Update((int)m_TempCtrl); m_NominalTempProperty.Update(m_NominalTemp); m_MinTempProperty.Update(m_MinTemp); m_MaxTempProperty.Update(m_MaxTemp); m_CurrentTempProperty.Update(m_CurrentTemp); return(m_Device); }