Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        /// Create our Dionex.Chromeleon.Symbols.IDevice and our Properties and Commands
        internal IDevice Create(IDDK cmDDK, string name)
        {
            // Create our Dionex.Chromeleon.Symbols.IDevice
            m_MyCmDevice = cmDDK.CreateDevice(name, "This is a preflight test device.");

            // create the standard Property containing our model number
            m_ModelNoProperty =
                m_MyCmDevice.CreateStandardProperty(StandardPropertyID.ModelNo, cmDDK.CreateString(20));

            m_someProperty = m_MyCmDevice.CreateBooleanProperty("Test", "Use this property to watch all preflight events.", "Off", "On");
            m_someProperty.OnPreflightSetProperty += new SetPropertyEventHandler(OnPfTest);
            m_someProperty.OnSetProperty          += new SetPropertyEventHandler(OnTest);

            m_MyCmDevice.OnPreflightBegin += new PreflightEventHandler(OnPfBegin);
            m_MyCmDevice.OnPreflightEnd   += new PreflightEventHandler(OnPfEnd);

            m_MyCmDevice.OnPreflightLatch += new PreflightEventHandler(OnPfLatch);
            m_MyCmDevice.OnPreflightSync  += new PreflightEventHandler(OnPfSync);

            m_MyCmDevice.OnPreflightBroadcast += new BroadcastEventHandler(OnPfBroadcast);

            m_MyCmDevice.OnTransferPreflightToRun += new PreflightEventHandler(OnTransferPfToRun);

            ICommand command =
                m_MyCmDevice.CreateCommand("DoAbort", "This command sends an abort error.");

            command.OnCommand += new CommandEventHandler(OnDoAbort);

            command =
                m_MyCmDevice.CreateCommand("DoError", "This command sends an error.");
            command.OnCommand += new CommandEventHandler(OnDoError);

            return(m_MyCmDevice);
        }
Ejemplo n.º 3
0
 public static IStringProperty CreateString(IDDK ddk, IStruct structure, string name, string helpText = null, int valueMaxLength = 300)
 {
     if (valueMaxLength <= 0)
     {
         throw new ArgumentOutOfRangeException("Parameter valueMaxLength must be > 0");
     }
     return(structure.CreateProperty(name, helpText, ddk.CreateString(valueMaxLength)));
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        internal void Create(IDDK cmDDK, string deviceName)
        {
            m_DDK    = cmDDK;
            m_Device = m_DDK.CreateDevice(deviceName, "LCSystem device. This is our master device.");

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

            typeProperty.Update("LCSystem");
        }
Ejemplo n.º 7
0
        /// Create our Dionex.Chromeleon.Symbols.IDevice and our Property
        internal IDevice Create(IDDK cmDDK, string name)
        {
            // Create our Dionex.Chromeleon.Symbols.IDevice
            m_MyCmDevice = cmDDK.CreateDevice(name, "SendReceive DDK Example.");

            // Create the standard Property containing our model number
            // There are standard properties with a special meaning for CM and a simplified
            // syntax. For details, see the documentation.
            m_ModelNoProperty =
                m_MyCmDevice.CreateStandardProperty(StandardPropertyID.ModelNo, cmDDK.CreateString(20));

            return(m_MyCmDevice);
        }
Ejemplo n.º 8
0
        public DemoProperties(IDriverEx driver, IDDK ddk, Config.Demo config, IDevice device)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }

            LogInFile            = Property.CreateBool(ddk, device, "LogInFile");
            LogInFile.Writeable  = true;
            LogInFile.AuditLevel = AuditLevel.Service;
            LogInFile.Update(Property.GetBoolNumber(true));  // Can be configurable = config.LogInFile

            m_IsSimulated = Property.CreateBool(ddk, device, "IsSimulated");
            m_IsSimulated.Update(Property.GetBoolNumber(driver.IsSimulated));
            if (driver.IsSimulated != config.IsSimulated)
            {
                Device.DebuggerBreak();
            }

            FirmwareUsbAddress = Property.CreateString(ddk, device, "FirmwareUsbAddress");
            FirmwareUsbAddress.Update(driver.FirmwareUsbAddress);

            FirmwareVersion = Property.CreateString(ddk, device, "FirmwareVersion");
            FirmwareVersion.Update(driver.FirmwareVersion);

            SerialNo = device.CreateStandardProperty(StandardPropertyID.SerialNo, ddk.CreateString(100));
            SerialNo.Update(driver.SerialNo);

            TaskName              = Property.CreateString(ddk, device, "TaskName", driver.TaskName);
            TaskNamePrevious      = Property.CreateString(ddk, device, "TaskNamePrevious", driver.TaskNamePrevious);
            TaskPreviousErrorText = Property.CreateString(ddk, device, "TaskPreviousErrorText", driver.TaskPreviousErrorText);

            CommunicationState = Property.CreateEnum(ddk, device, "CommunicationState", driver.CommunicationState, null);
            BehaviorStatePrev  = Property.CreateEnum(ddk, device, "BehaviorStatePrev", driver.BehaviorStatePrev);
            BehaviorState      = Property.CreateEnum(ddk, device, "BehaviorState", driver.BehaviorState);

            ProcessStep = Property.CreateInt(ddk, device, "ProcessStep");
            ProcessStep.Update(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)
        {
            // Load the help text from the resource
            string deviceHelpText =
                Properties.Resources.LocalizedDevice_HelpText;

            // Create our Dionex.Chromeleon.Symbols.IDevice
            m_MyCmDevice = cmDDK.CreateDevice(name, deviceHelpText);

            // Load the help text from the resource
            string statusPropertyText =
                Properties.Resources.StatusProperty_HelpText;

            // create a test Property containing a string
            m_statusProperty =
                m_MyCmDevice.CreateProperty("Status", statusPropertyText, cmDDK.CreateString(20));
            m_statusProperty.Update("Disconnected.");

            return(m_MyCmDevice);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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, "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);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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);
        }
        public DeviceProperties(IDDK ddk, IDevice device, string deviceId, string deviceType, string deviceName)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }
            if (string.IsNullOrEmpty(deviceType))
            {
                throw new ArgumentNullException("deviceType");
            }
            if (string.IsNullOrEmpty(deviceName))
            {
                throw new ArgumentNullException("deviceName");
            }
            if (deviceName.Length != deviceName.Trim().Length)
            {
                throw new ArgumentException("Device Name is invalid - it starts or ends with space");
            }

            // ModelNo is used to identify the device in the instrument method editor plug-in
            Debug.Assert(StandardPropertyID.ModelNo.ToString() == Property.ConstantName.ModelNo);
            IStringProperty stringProperty = device.CreateStandardProperty(StandardPropertyID.ModelNo, ddk.CreateString(100));

            stringProperty.Update(deviceType);

            stringProperty = Property.CreateString(ddk, device, Property.ConstantName.InternalName);
            stringProperty.Update(deviceId);
            stringProperty.AuditLevel = AuditLevel.Expert;

            stringProperty = Property.CreateString(ddk, device, Property.ConstantName.DeviceType);
            stringProperty.Update(deviceType);

            stringProperty = Property.CreateString(ddk, device, "DeviceName");
            stringProperty.Update(deviceName);

            Description = Property.CreateString(ddk, device, "DeviceDescription");
            Description.Update("Description for " + deviceId);
            // Description.Writeable = true; - not needed, because of m_Properties.DeviceDesription.OnSetProperty += OnPropertyDeviceDesriptionSet;

            Language = Property.CreateString(ddk, device, "DeviceLanguage");
            Language.Update("Language for " + deviceId);
        }
Ejemplo n.º 15
0
 public static ITypeString CreateTypeString(IDDK ddk)
 {
     return(ddk.CreateString(300));
 }
Ejemplo n.º 16
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);
        }