コード例 #1
0
        private void CheckTemperature(double value)
        {
            ITypeDouble type = m_Properties.TemperatureValue.ValueType as ITypeDouble;

            Debug.Assert(type != null);
            string units = type != null ? " " + type.Unit : string.Empty;

            double valueMin = TemperatureMin;
            double valueMax = TemperatureMax;

            if (value < valueMin || value > valueMax)
            {
                throw new InvalidOperationException("Cannot set TemperatureValue = " + value.ToString() + units + ". Must be in [" + valueMin + ", " + valueMax.ToString() + "]");
            }

            if (type != null)
            {
                valueMin = type.Minimum.GetValueOrDefault();
                valueMax = type.Maximum.GetValueOrDefault();
                if (value < valueMin || value > valueMax)
                {
                    throw new InvalidOperationException("Cannot set TemperatureValue = " + value.ToString() + units + ". Must be in [" + valueMin + ", " + valueMax.ToString() + "]");
                }
            }
        }
コード例 #2
0
        internal IDevice Create(IDDK cmDDK, string name)
        {
            // Create our IDevice object
            m_MyCmDevice = cmDDK.CreateDevice(name, "Nelson NCI 900 Master Device");

            // Create our properties

            // ModelNo
            m_ModelNoProperty =
                m_MyCmDevice.CreateStandardProperty(StandardPropertyID.ModelNo, cmDDK.CreateString(20));

            // DebugCommand
            ITypeString tString = cmDDK.CreateString(255);

            m_DebugCommand = m_MyCmDevice.CreateProperty("DebugCommand",
                                                         "For internal use only.", tString);
            m_DebugCommand.AuditLevel     = AuditLevel.Message;
            m_DebugCommand.OnSetProperty += new SetPropertyEventHandler(OnDebugCommand);

            ITypeDouble tDouble = cmDDK.CreateDouble(0, 100, 1);

            tDouble.Unit = "%";

            IProperty dblProp =
                m_MyCmDevice.CreateProperty("DoubleProp", "DoubleHelp", tDouble);

            return(m_MyCmDevice);
        }
コード例 #3
0
        public static ITypeDouble CreatePercentType(IDDK ddk, double min, double max, int digits)
        {
            ITypeDouble result = ddk.CreateDouble(min, max, digits);

            result.Unit = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_Percent);
            return(result);
        }
コード例 #4
0
        private void CheckTemperature(SetPropertyEventArgs args, double value)
        {
            if (args.RunContext.IsManual)              // If this is requested manually by the user
            {
                if (!args.RunContext.IsSemanticCheck)  // This is not just a check - the command will be executed after the preflight is successful
                {
                    m_Driver.CheckIsCommunicating();
                    CheckIsTemperatureControlOn();
                }
            }

            ITypeDouble type = m_Properties.TemperatureNominal.DataType;

            if (args.RunContext.IsManual)
            {
                // This check can be made only in manual mode, because the script can have steps that modify
                // TemperatureMin and/or TemperatureMax and therefor the current Min/Max values are not the ones the script sets
                if (value < TemperatureMin || value > TemperatureMax)
                {
                    throw new InvalidOperationException("Cannot set TemperatureValue = " + value.ToString() + " " + type.Unit + ". Must be in [" + TemperatureMin + ", " + TemperatureMax.ToString() + "]");
                }
            }

            double valueMin = type.Minimum.GetValueOrDefault();
            double valueMax = type.Maximum.GetValueOrDefault();

            if (value < valueMin || value > valueMax)
            {
                throw new InvalidOperationException("Cannot set TemperatureValue = " + value.ToString() + " " + type.Unit + ". Must be in [" + valueMin + ", " + valueMax.ToString() + "]");
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public PumpProperties(IDDK ddk, IDevice device)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }

            Ready = Property.CreateReady(ddk, device);

            // Pressure.LowerLimit
            // Pressure.UpperLimit
            // Pressure.Value
            m_Pressure = device.CreateStruct("Pressure", "The pump pressure.");

            ITypeDouble pressureType = ddk.CreateDouble(0, 400, 3);

            pressureType.Unit = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_Bar);

            PressureValue = m_Pressure.CreateStandardProperty(StandardPropertyID.Value, pressureType);
            PressureValue.Update(0);

            PressureLowerLimit = m_Pressure.CreateStandardProperty(StandardPropertyID.LowerLimit, pressureType);
            PressureLowerLimit.Update(pressureType.Minimum);

            PressureUpperLimit = m_Pressure.CreateStandardProperty(StandardPropertyID.UpperLimit, pressureType);
            PressureUpperLimit.Update(pressureType.Maximum);

            m_Pressure.DefaultGetProperty = PressureValue;
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
        public static IDoubleProperty CreateDouble(IDDK ddk, IStruct structure, string name,
                                                   Nullable <UnitConversion.PhysUnitEnum> unit = null, string helpText = null,
                                                   double minValue = double.MinValue, double maxValue = double.MaxValue, int precision = 3)
        {
            ITypeDouble     typeDouble = CreateDoubleType(ddk, unit, minValue, maxValue, precision);
            IDoubleProperty result     = structure.CreateProperty(name, helpText, typeDouble);

            return(result);
        }
コード例 #9
0
ファイル: Pump.cs プロジェクト: IhorRudych/Chromelion-Driver
        internal void Create(IDDK cmDDK, string deviceName)
        {
            m_DDK    = cmDDK;
            m_Device = m_DDK.CreateDevice(deviceName, "Pump device");

            IStringProperty typeProperty =
                m_Device.CreateProperty("DeviceType",
                                        "The DeviceType property tells us which component we are talking to.",
                                        m_DDK.CreateString(20));

            typeProperty.Update("Pump");


            // A data type for our pump flow
            ITypeDouble tFlow = m_DDK.CreateDouble(0, 10, 1);

            tFlow.Unit = "ml/min";

            // Create our flow handler. The flow handler creates a Flow.Nominal,
            // a Flow.Value and 4 eluent component properties for us.
            m_FlowHandler = m_Device.CreateFlowHandler(tFlow, 4, 2);

            m_FlowHandler.FlowNominalProperty.OnSetProperty += OnSetFlow;

            // initialize the flow
            m_FlowHandler.FlowNominalProperty.Update(0);

            // initialize the components
            m_FlowHandler.ComponentProperties[0].Update(100.0);
            m_FlowHandler.ComponentProperties[1].Update(0);
            m_FlowHandler.ComponentProperties[2].Update(0);
            m_FlowHandler.ComponentProperties[3].Update(0);


            // A type for our pump pressure
            ITypeDouble tPressure = m_DDK.CreateDouble(0, 400, 1);

            tPressure.Unit = "bar";

            // We create a struct for the pressure with Value, LowerLimit and UpperLimit
            m_PressureStruct = m_Device.CreateStruct("Pressure", "The pump pressure.");

            m_PressureValue = m_PressureStruct.CreateStandardProperty(StandardPropertyID.Value, tPressure);

            m_PressureLowerLimit = m_PressureStruct.CreateStandardProperty(StandardPropertyID.LowerLimit, tPressure);
            m_PressureLowerLimit.OnSetProperty += new SetPropertyEventHandler(OnSetPressureLowerLimit);
            m_PressureLowerLimit.Update(0.0);

            m_PressureUpperLimit = m_PressureStruct.CreateStandardProperty(StandardPropertyID.UpperLimit, tPressure);
            m_PressureUpperLimit.OnSetProperty += new SetPropertyEventHandler(OnSetPressureUpperLimit);
            m_PressureUpperLimit.Update(400.0);

            m_PressureStruct.DefaultGetProperty = m_PressureValue;

            m_Device.OnTransferPreflightToRun += new PreflightEventHandler(OnTransferPreflightToRun);
        }
コード例 #10
0
        public static ITypeDouble CreateDoubleType(IDDK ddk,
                                                   Nullable <UnitConversion.PhysUnitEnum> unit = null,
                                                   double minValue = double.MinValue, double maxValue = double.MaxValue, int precision = 3)
        {
            ITypeDouble result = ddk.CreateDouble(minValue, maxValue, precision);

            if (unit != null)
            {
                result.Unit = UnitConversionEx.PhysUnitName(unit.GetValueOrDefault());
            }
            return(result);
        }
コード例 #11
0
        /// 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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        void modifyVolumeTypeCommand_OnCommand(CommandEventArgs args)
        {
            ITypeDouble tNewVolumeType = m_MyCmDDK.CreateDouble(0.00, 20.00, 2);

            tNewVolumeType.Unit = "mL";
            double[] legalValues = new double[3];
            legalValues[0]             = 0.00;
            legalValues[1]             = 10.00;
            legalValues[2]             = 20.00;
            tNewVolumeType.LegalValues = legalValues;

            ITypeInt tOldPositionType = m_InjectHandler.PositionProperty.DataType; // remains unchanged

            m_InjectHandler.UpdateDataTypes(tNewVolumeType, tOldPositionType);
        }
コード例 #14
0
        /// <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);
        }
コード例 #15
0
        /// 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);
        }
コード例 #16
0
        private static IDevice CreateChannel(IDDK ddk, string name, double min, double max, int digits, 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");
            }

            ITypeDouble typeSignal = ddk.CreateDouble(min, max, digits);

            typeSignal.Unit = UnitConversionEx.PhysUnitName(unit);
            IChannel result = ddk.CreateChannel(name, "Pump Pressure Channel", typeSignal);

            return(result);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        /// <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);
        }
コード例 #20
0
        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;
            }
        }
コード例 #21
0
        public HeaterProperties(IDDK ddk, Config.Heater config, IDevice device)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }

            Ready = Property.CreateReady(ddk, device);

            m_Product               = device.CreateStruct("Product", "Product Help Text");
            m_ProductName           = Property.CreateString(ddk, m_Product, "Name");
            m_ProductName.Writeable = true;
            m_ProductName.Update("Product Name");
            m_ProductDescription = Property.CreateString(ddk, m_Product, "Description");
            m_ProductDescription.Update(config.ProductDescription);
            // Set the default read and write properties for the structure - optional
            m_Product.DefaultGetProperty = m_ProductName;
            m_Product.DefaultSetProperty = m_ProductName;

            Power = Property.CreateDouble(ddk, device, "Power", UnitConversion.PhysUnitEnum.PhysUnit_Watt, null, 0);  // the unit W is localized

            // Temperature.Control - On/Off
            // Temperature.LowerLimit
            // Temperature.UpperLimit
            // Temperature.Nominal
            // Temperature.Value
            m_Temperature = device.CreateStruct("Temperature", "Heater Temperature");

            TemperatureControl           = Property.CreateEnum(ddk, m_Temperature, "Control", Heater.TemperatureControl.Off);
            TemperatureControl.Writeable = true;

            string    temperatureUnit      = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_Celsius); // °C - localized
            const int temperaturePrecision = 1;

            ITypeDouble temperatureType = ddk.CreateDouble(0, 100, temperaturePrecision);

            temperatureType.Unit = temperatureUnit;

            TemperatureMin           = m_Temperature.CreateStandardProperty(StandardPropertyID.LowerLimit, temperatureType);
            TemperatureMin.Writeable = true;
            TemperatureMin.Update(20);

            TemperatureMax           = m_Temperature.CreateStandardProperty(StandardPropertyID.UpperLimit, temperatureType);
            TemperatureMax.Writeable = true;
            TemperatureMax.Update(80);

            TemperatureNominal           = m_Temperature.CreateStandardProperty(StandardPropertyID.Nominal, temperatureType); // Desired (requested) temperature
            TemperatureNominal.Writeable = true;
            TemperatureNominal.Update(50);

            temperatureType      = ddk.CreateDouble(double.MinValue, double.MaxValue, temperaturePrecision);
            temperatureType.Unit = temperatureUnit;
            TemperatureValue     = m_Temperature.CreateStandardProperty(StandardPropertyID.Value, temperatureType);
            TemperatureValue.Update(40);

            // Set the default read and write properties for the structure
            m_Temperature.DefaultGetProperty = TemperatureValue;
            m_Temperature.DefaultSetProperty = TemperatureNominal;
        }
コード例 #22
0
        /// 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);
        }
コード例 #23
0
ファイル: Pump.cs プロジェクト: IhorRudych/Chromelion-Driver
        public Pump(IDriverEx driver, IDDK ddk, Config.Pump config, string id)
            : base(driver, ddk, typeof(Pump).Name, id, config.Name)
        {
            Log.TaskBegin(Id);
            try
            {
                m_Properties = new PumpProperties(m_DDK, m_Device);

                m_Properties.PressureLowerLimit.OnSetProperty += OnPropertyPressureLowerLimitSet;
                m_Properties.PressureUpperLimit.OnSetProperty += OnPropertyPressureUpperLimitSet;

                // Properties of the flow handler:
                //     m_FlowHandler.FlowNominalProperty                         - Flow.Nominal
                //     m_FlowHandler.FlowValueProperty                           - Flow.Value
                //     m_FlowHandler.ComponentProperties[i] (4 eluent component) - %A.Equate, %B.Equate, %C.Equate, %D.Equate
                //                                                                 %A.Valuue, %B.Valuue; %C.Valuue; %D.Valuue
                ITypeDouble flowType = m_DDK.CreateDouble(0, 10, 3);
                flowType.Unit = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_MilliLiterPerMin); // ml/min
                m_FlowHandler = m_Device.CreateFlowHandler(flowType, 4, 2);

                m_FlowHandler.FlowNominalProperty.OnPreflightSetProperty += OnPropertyFlowNominalSetPreflight;
                m_FlowHandler.FlowNominalProperty.OnSetProperty          += OnPropertyFlowNominalSet;
                m_FlowHandler.FlowNominalProperty.OnSetRamp += OnPropertyFlowNominalSetRamp;
                //m_FlowHandler.FlowNominalProperty.RampSyntax = true; // m_FlowHandler.FlowNominalProperty.IsRampSyntax is already True
                m_FlowHandler.FlowNominalProperty.Update(0);

                //m_FlowHandler.FlowValueProperty.RampSyntax = true; // m_FlowHandler.FlowValueProperty.IsRampSyntax is already True
                m_FlowHandler.FlowValueProperty.Update(0);

                m_EluentPercentA = 100;
                m_FlowHandler.ComponentProperties[0].Update(m_EluentPercentA);  // Partial flow of this component, expressed in percent of the total flow. m_FlowHandler.EquateProperties[i].HelpText = "User-selectable designation of this solvent component."
                m_FlowHandler.ComponentProperties[1].Update(m_EluentPercentB);
                m_FlowHandler.ComponentProperties[2].Update(m_EluentPercentC);
                m_FlowHandler.ComponentProperties[3].Update(m_EluentPercentD);

                m_FlowHandler.EquateProperties[0].Update("Water");

                m_FlowHandler.ComponentProperties[1].OnSetProperty += OnPropertyFlowHandler_ComponentProperty_2_Set;
                m_FlowHandler.ComponentProperties[2].OnSetProperty += OnPropertyFlowHandler_ComponentProperty_3_Set;
                m_FlowHandler.ComponentProperties[3].OnSetProperty += OnPropertyFlowHandler_ComponentProperty_4_Set;

                double pressureSignalMin    = m_Properties.PressureLowerLimit.Value.GetValueOrDefault();
                double pressureSignalMax    = m_Properties.PressureUpperLimit.Value.GetValueOrDefault();
                int    pressureSignalDigits = 3;
                string pressureUnitName     = m_Properties.PressureValue.DataType.Unit;
                UnitConversion.PhysUnitEnum pressureUnit = UnitConversionEx.PhysUnitFindName(pressureUnitName);
                m_ChannelPressure = new PumpChannelPressure(driver, ddk, m_Device, "Channel_Pressure_Id", "Channel_Pressure_Name", pressureSignalMin, pressureSignalMax, pressureSignalDigits, pressureUnit);

                m_Device.OnBatchPreflightBegin  += OnDeviceBatchPreflightBegin;
                m_Device.OnBatchPreflightSample += OnDeviceBatchPreflightSample;
                m_Device.OnBatchPreflightEnd    += OnDeviceBatchPreflightEnd;

                m_Device.OnPreflightBegin     += OnDevicePreflightBegin;
                m_Device.OnPreflightLatch     += OnDevicePreflightLatch;
                m_Device.OnPreflightSync      += OnDevicePreflightSync;
                m_Device.OnPreflightBroadcast += OnDevicePreflightBroadcast;
                m_Device.OnPreflightEnd       += OnDevicePreflightEnd;

                m_Device.OnTransferPreflightToRun += OnDeviceTransferPreflightToRun;

                m_Device.OnLatch += OnDeviceLatch;
                m_Device.OnSync  += OnDeviceSync;

                // See these in the AutoSampler
                m_Device.OnSequenceStart  += OnDeviceSequenceStart;
                m_Device.OnSequenceChange += OnDeviceSequenceChange;
                m_Device.OnSequenceEnd    += OnDeviceSequenceEnd;

                m_Device.OnBroadcast += OnDeviceBroadcast;

                Log.TaskEnd(Id);
            }
            catch (Exception ex)
            {
                Log.TaskEnd(Id, ex);
                throw;
            }
        }
コード例 #24
0
        /// <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);
        }
コード例 #25
0
        /// <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);
        }
コード例 #26
0
        /// 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);
        }
コード例 #27
0
        /// 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);
        }