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;
        }
        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);
        }
        void genericHandler(SetPropertyEventArgs args)
        {
            SetDoublePropertyEventArgs doubleArgs = args as SetDoublePropertyEventArgs;
            Double?         newValue       = doubleArgs.NewValue;
            IDoubleProperty doubleProperty = args.Property as IDoubleProperty;

            doubleProperty.Update(doubleArgs.NewValue);
        }
示例#4
0
            /// <summary>Returns the value before the script assignment</summary>
            public Nullable <double> GetPreconditionValue(IDoubleProperty property)
            {
                IPropertyValue       propertyValue       = GetPreconditionPropertyValue(property);
                IDoublePropertyValue doublePropertyValue = propertyValue as IDoublePropertyValue;
                Nullable <double>    result = doublePropertyValue.Value;

                return(result);
            }
示例#5
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);
        }
示例#6
0
        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);
        }
示例#7
0
        public static void PropertyChanged(string callerId, string unitName, IDoubleProperty property, string callerMethodName = null)
        {
            if (callerMethodName == null)
            {
                callerMethodName = CallerMethodName;
            }
            Nullable <double> value = property.Value;

            WriteLinePropertyChanged(callerId, property.Name, (value == null ? "Null" : value.GetValueOrDefault().ToString(CultureInfo.InvariantCulture)) + " " + unitName, callerMethodName);
        }
        /// 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);
        }
        private void stapleConfig(String stapleComponentName)
        {
            StapleSection parameterStaple = ConfigReader.readStapleConfig();

            ISimComponent stapleComponent = app.Value.World.FindComponent(stapleComponentName);

            if (stapleComponentName != "" && stapleComponent == null)
            {
                ms.AppendMessage("Failed to find staple component with name\"" + stapleComponentName + "\"! Planning of motion aborted...", MessageLevel.Warning);
                return;
            }

            String stapleFileFolder = parameterStaple.staplePath.Path;

            if (stapleComponent.GetProperty("stlID") == null)
            {
                ms.AppendMessage("Component with name \"" + stapleComponentName + "\" has no property \"stlID\"! Planning of motion aborted...", MessageLevel.Warning);
                return;
            }
            String stlID            = (String)stapleComponent.GetProperty("stlID").Value;
            String obstacleFilePath = stapleFileFolder + stlID + ".stl";

            if (!File.Exists(obstacleFilePath))
            {
                ms.AppendMessage("A path planning request requested stlID with \"" + stlID + "\" failed, because file \"" + obstacleFilePath + "\" does not exist...", MessageLevel.Warning);
                return;
            }
            ;
            if (stapleComponent.GetProperty("StackHeight") == null)
            {
                ms.AppendMessage("Failed to find StackHeight property in component with name \"" + stapleComponentName + "\"! Planning of motion aborted!", MessageLevel.Warning);
                return;
            }

            Vector3         staplePosition = stapleComponent.TransformationInWorld.GetP();
            IDoubleProperty stackwidth     = (IDoubleProperty)stapleComponent.GetProperty("StackWidth");
            IDoubleProperty stacklength    = (IDoubleProperty)stapleComponent.GetProperty("StackLength");

            float translate_x = (float)staplePosition.X - (float)(stacklength.Value / 2.0);
            float translate_y = (float)staplePosition.Y - (float)(stackwidth.Value / 2.0);

            IDoubleProperty stackheight = (IDoubleProperty)stapleComponent.GetProperty("StackHeight");
            float           translate_z = (float)stackheight.Value;

            // setup staple obstacle
            int obstacleId = motionPlan.addObstacle(obstacleFilePath, translate_x / 1000.0f, translate_y / 1000.0f, translate_z / 1000.0f, 0.0f, 0.0f, 0.0f);
        }
示例#10
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);
        }
示例#11
0
            private Nullable <double> GetScriptOrPreconditionValue(IDoubleProperty property, bool ifNotFoundReturnPreconditionValue)
            {
                Nullable <double> result        = null;
                IPropertyValue    propertyValue = GetPropertyValue(property);

                if (propertyValue == null)
                {
                    if (ifNotFoundReturnPreconditionValue)
                    {
                        result = GetPreconditionValue(property);
                    }
                    return(result);
                }
                IDoublePropertyValue doublePropertyValue = propertyValue as IDoublePropertyValue;

                result = doublePropertyValue.Value;
                return(result);
            }
示例#12
0
        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);
        }
示例#13
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);
        }
        /// <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);
        }
示例#15
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);
        }
        /// <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);
        }
示例#17
0
            /// <summary>Returns the value in the script assignment if found, else the precondition value</summary>
            public Nullable <double> GetCurrentValue(IDoubleProperty property)
            {
                Nullable <double> result = GetScriptOrPreconditionValue(property, true);

                return(result);
            }
        /// <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);
        }
示例#19
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;
        }
示例#20
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);
        }
        /// 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);
        }