Exemplo 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);
        }
Exemplo n.º 2
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 device that illustrates the usage of IDevice.DelayTermination.");

            m_DelayTerminationProperty =
                m_MyCmDevice.CreateBooleanProperty("DelayTermination", "Enable/Disable termination delay.", "Off", "On");

            m_DelayTerminationProperty.OnSetProperty += new SetPropertyEventHandler(m_DelayTerminationProperty_OnSetProperty);

            ITypeInt tTimeout = cmDDK.CreateInt(0, 30);

            tTimeout.Unit = "s";
            m_TerminationTimeoutProperty =
                m_MyCmDevice.CreateProperty("TerminationTimeout", "The timeout for the delayed termination.", tTimeout);

            m_TerminationTimeoutProperty.OnSetProperty += new SetPropertyEventHandler(m_TerminationTimeoutProperty_OnSetProperty);

            m_TerminateInTimeProperty =
                m_MyCmDevice.CreateBooleanProperty("TerminateInTime", "Enable/Disable proper termination.", "Off", "On");
            m_TerminateInTimeProperty.OnSetProperty += new SetPropertyEventHandler(m_TerminateInTimeProperty_OnSetProperty);

            m_MyCmDevice.OnTransferPreflightToRun += new PreflightEventHandler(m_MyCmDevice_OnTransferPreflightToRun);

            m_MyCmDevice.OnBroadcast += new BroadcastEventHandler(m_MyCmDevice_OnBroadcast);

            m_ProgramTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_ProgramTimer_Elapsed);

            return(m_MyCmDevice);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public Device(IDDK cmDDK)
        {
            m_DDK    = cmDDK;
            m_Device = m_DDK.CreateDevice("MyDevice", "Device that dumps all events to the audit trail");

            IIntProperty simpleProperty = m_Device.CreateBooleanProperty("SimpleProperty", "help text", "False", "True");

            simpleProperty.OnPreflightSetProperty += new SetPropertyEventHandler(simpleProperty_OnPreflightSetProperty);
            simpleProperty.OnSetProperty          += new SetPropertyEventHandler(simpleProperty_OnSetProperty);

            m_Device.OnBroadcast += new BroadcastEventHandler(m_Device_OnBroadcast);
            // will be called 100 times a second ... m_Device.OnLatch += new RuntimeEventHandler(m_Device_OnLatch);
            // will be called 100 times a second ... m_Device.OnSync += new RuntimeEventHandler(m_Device_OnSync);

            m_Device.OnPreflightBegin     += new PreflightEventHandler(m_Device_OnPreflightBegin);
            m_Device.OnPreflightBroadcast += new BroadcastEventHandler(m_Device_OnPreflightBroadcast);
            m_Device.OnPreflightLatch     += new PreflightEventHandler(m_Device_OnPreflightLatch);
            m_Device.OnPreflightSync      += new PreflightEventHandler(m_Device_OnPreflightSync);
            m_Device.OnPreflightEnd       += new PreflightEventHandler(m_Device_OnPreflightEnd);

            m_Device.OnTransferPreflightToRun += new PreflightEventHandler(m_Device_OnTransferPreflightToRun);

            m_Device.OnBatchPreflightBegin             += new BatchPreflightEventHandler(m_Device_OnBatchPreflightBegin);
            m_Device.OnBatchPreflightSample            += new SamplePreflightEventHandler(m_Device_OnBatchPreflightSample);
            m_Device.OnBatchPreflightStandAloneProgram += new BatchEntryPreflightEventHandler(m_Device_OnBatchPreflightStandAloneProgram);
            m_Device.OnBatchPreflightEmergencyProgram  += new BatchEntryPreflightEventHandler(m_Device_OnBatchPreflightEmergencyProgram);
            m_Device.OnBatchPreflightEnd += new BatchPreflightEventHandler(m_Device_OnBatchPreflightEnd);

            m_Device.OnSequenceStart  += new SequencePreflightEventHandler(m_Device_OnSequenceStart);
            m_Device.OnSequenceEnd    += new SequencePreflightEventHandler(m_Device_OnSequenceEnd);
            m_Device.OnSequenceChange += new SequenceChangeEventHandler(m_Device_OnSequenceChange);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
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");
        }
Exemplo n.º 8
0
        /// We will create our properties in here.
        internal IDevice Create(IDDK cmDDK, string name)
        {
            m_MyCmDevice = cmDDK.CreateDevice(name, "Relay");

            ITypeInt tState = cmDDK.CreateInt(0, 1);

            m_PropState = m_MyCmDevice.CreateProperty("State",
                                                      "Indicates or sets the relay's state.",
                                                      tState);
            m_PropState.OnSetProperty += new SetPropertyEventHandler(OnSetState);

            return(m_MyCmDevice);
        }
Exemplo n.º 9
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);
        }
        /// <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);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Create the 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 a device using an embedded binary data block (blob).");

            // Let the DDK create a data block id.
            // This id will be associated with the driver id and the symbol name of your driver instance.
            m_BlobDataID = m_MyCmDevice.CreateBlobId("MyBlobDataType");

            // Attach to TransferPreflightToRun and OnPreflightEnd in order to report the content of the blob to the audit trail.
            m_MyCmDevice.OnTransferPreflightToRun += OnTransferPfToRun;
            m_MyCmDevice.OnPreflightEnd           += OnPreflightEnd;

            m_MyCmDevice.StoreAdditionalInformation("AdditionalInformation1");
            cmDDK.AuditMessage(AuditLevel.Normal, m_MyCmDevice.GetAdditionalInformation());

            m_MyCmDevice.CustomData = "Some custom data, here, a string, but could be any object";

            return(m_MyCmDevice);
        }
Exemplo n.º 12
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);
        }
Exemplo 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="driver">The driver instance</param>
        /// <param name="name">The name for our device</param>
        /// <returns>our IDevice object</returns>
        internal IDevice OnCreate(ChannelTestDriver driver, IDDK cmDDK, string name)
        {
            m_Driver = driver;

            // Create our Dionex.Chromeleon.Symbols.IDevice
            m_MyCmDevice = cmDDK.CreateDevice(name, "This is the master device of the ChannelTest driver.");
            m_MyCmDevice.ImmediateNotReady = true;
            // NOTE:
            //      Setting 'ImmediateNotReady' to true on the main device toggles the 'Ready' property for 5s(default) to false when entering TransferPreflightToRun, unless one updates the ready property explicitly.
            //      Therefore it's also necessary to create a standard property 'Ready' which can be toggled and which can be added to instrument methods in a Wait statement.
            // More background:
            //      In common LC/GC environments an injector is used in the instrument configuration and it's Inject command in the method would cause a natural delay.
            //       In our example driver we have no delay like this and can run into a kind of data exchange delay issue.
            //      Setting the parameter FixedRate in a method updates also the channel parameters TimeStepFactorProperty and TimeStepDevisorProperty.
            //      If setting the parameter FixedRate is immediately followed by an AcqOn command, the 'Real Time Kernel' might not be updated via interprocess communication soon enough and
            //      calculates the number of expected datapoints with old settings of TimeStepFactorProperty and TimeStepDevisorProperty. This might stop the data acquisition by 'OnDataFinished' when faulty 'enough' data points have been dumped.
            //      To avoid this in this example, following to steps in combination are necessary:
            //          1) introducing a standard property 'Ready' which can be checked in the instrument method.
            //          2) Set ChannelTest.ImmediateNotReady to true
            //          3) Adding a Wait ChannelTest.Ready in the method before AcqOn.
            //      This provides enough time when setting FixedRate in our example to update the 'Real Time Kernel's TimeStepFactorProperty and TimeStepDevisorProperty.

            // Create a command for the hardware error simulation.
            m_HardwareErrorCommand =
                m_MyCmDevice.CreateCommand("HardwareError", "This command simulates a hardware error.");

            m_HardwareErrorCommand.OnCommand += new CommandEventHandler(m_HardwareErrorCommand_OnCommand);

            //Create ready property
            ITypeInt tReady = cmDDK.CreateInt(0, 1);

            //Add named values
            tReady.AddNamedValue("NotReady", 0);
            tReady.AddNamedValue("Ready", 1);
            ReadyProperty = m_MyCmDevice.CreateStandardProperty(StandardPropertyID.Ready, tReady);
            ReadyProperty.Update(1);

            return(m_MyCmDevice);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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);
        }
Exemplo 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 our Dionex.Chromeleon.Symbols.IDevice
            m_MyCmDevice = cmDDK.CreateDevice(name, "This is download device.");

            // Create two event properties. These properties may be switched several times during
            // an instrument method. Before the run is started all timed events must be collected into
            // a download method.
            m_EventAProperty =
                m_MyCmDevice.CreateBooleanProperty("EventA", "An event property.", "Off", "On");

            // We need to set Writeable to allow CM to change the value. If we had a handler
            // for the property, this would happen automatically.
            m_EventAProperty.Writeable = true;

            m_EventBProperty =
                m_MyCmDevice.CreateBooleanProperty("EventB", "An event property.", "Off", "On");
            m_EventBProperty.Writeable = true;

            // The complete method will be sent to the hardware in one go in the OnTransferPfToRun handler.
            m_MyCmDevice.OnTransferPreflightToRun += new PreflightEventHandler(OnTransferPfToRun);

            return(m_MyCmDevice);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
        public Device(IDriverEx driver, IDDK ddk, string deviceType, string id, string name, IDevice owner = null, IDevice device = null)
        {
            if (driver == null)
            {
                throw new ArgumentNullException("driver");
            }
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (string.IsNullOrEmpty(deviceType))
            {
                throw new ArgumentNullException("deviceType");
            }
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }
            if (id.Length != id.Trim().Length)
            {
                throw new ArgumentException("id \"" + id + "\" is invalid - it starts or ends with a space");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (name.Length != name.Trim().Length)
            {
                throw new ArgumentException("name \"" + name + "\" is invalid - it starts or ends with a space");
            }

            m_Driver = driver;
            m_DDK    = ddk;
            m_Id     = id;
            m_Name   = name;
            Log.TaskBegin(Id, "Name = \"" + Name + "\"");
            try
            {
                m_IsSimulated = m_Driver.IsSimulated;

                m_Device = device;
                if (m_Device == null)
                {
                    m_Device = m_DDK.CreateDevice(Name, "Help text for device " + Id + " with name \"" + Name + "\"");
                }

                if (owner != null)
                {
                    m_Device.SetOwner(owner);
                }

                m_Properties = new DeviceProperties(m_DDK, m_Device, Id, deviceType, Name);

                m_Properties.Description.OnPreflightSetProperty += OnPropertyDescriptionSetPreflight;
                m_Properties.Description.OnSetProperty          += OnPropertyDescriptionSet;

                // The Debug.Assert problem fixed in VS 2017, but the debugger must be already attached - else nothing happens
                Debug.Assert(!string.IsNullOrEmpty(Name));

                bool debuggerBreak = false;
                if (debuggerBreak)
                {
                    DebuggerBreak("Test debugger break");
                }

                bool breakIfDebuggerIsAttached = false;
                if (breakIfDebuggerIsAttached)
                {
                    DebuggerBreakIfIsAttached("Test debugger break is it's attached");
                }

                Log.TaskEnd(Id);
            }
            catch (Exception ex)
            {
                Log.TaskEnd(Id, ex);
                throw;
            }
        }
Exemplo n.º 20
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);
        }