Beispiel #1
0
        /// <summary>
        /// IDriver implementation: Init
        /// </summary>
        /// <param name="cmDDK">The DDK instance</param>
        public void Init(IDDK cmDDK)
        {
            m_CmDDK = cmDDK;

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(m_Configuration);

            // create the master device
            m_MasterDevice = new ChannelTestDevice();
            IDevice master = m_MasterDevice.OnCreate(this, cmDDK, DeviceName(doc, "ChannelTest"));

            // create the fixed rate channel
            m_FixedRateChannel = new FixedRateChannel();
            m_FixedRateChannel.OnCreate(cmDDK, master, DeviceName(doc, "FixedRateChannel"));

            // create the timestamped channel (double, double)
            m_TimestampedChannelDouble = new TimestampedChannelDouble();
            m_TimestampedChannelDouble.OnCreate(cmDDK, master, DeviceName(doc, "TimestampedChannel"));

            // create the timestamped channel (Int64, Int64)
            m_TimestampedChannelInt64 = new TimestampedChannelInt64();
            m_TimestampedChannelInt64.OnCreate(cmDDK, master, DeviceName(doc, "Int64Channel"));

            // create the spectral channel
            m_PDAChannel = new PDAChannel();
            m_PDAChannel.OnCreate(cmDDK, master, DeviceName(doc, "PDAChannel"));
        }
        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);
        }
Beispiel #3
0
        public void OnGenericXmlRequest(IDDK cmDDK, string inputString, out string outputString)
        {
            XmlDocument xmlDocIn = new XmlDocument();

            xmlDocIn.LoadXml(inputString);
            XmlNode customXmlNode = xmlDocIn.SelectSingleNode("//CustomXML");

            if (customXmlNode == null)
            {
                outputString = "<Reply><Error>Unknown custom XML</Error></Reply>";
                return;
            }

            if (customXmlNode.InnerText == "...") // for round trip testing
            {
                outputString = "<Reply><Success>" + inputString + "</Success></Reply>";
            }
            else
            {
                String response = m_Device.DoSomething(customXmlNode.InnerText);

                XmlDocument xmlDocOut = new XmlDocument();
                xmlDocOut.PreserveWhitespace = true;
                XmlNode replyNode = xmlDocOut.CreateNode(XmlNodeType.Element, "Reply", "");
                xmlDocOut.AppendChild(replyNode);
                XmlNode successNode = xmlDocOut.CreateNode(XmlNodeType.Element, "Success", "");
                successNode.InnerText = response;
                replyNode.AppendChild(successNode);
                outputString = xmlDocOut.OuterXml;
            }
        }
        void IDriverSendReceive.OnSendReceive(IDDK ddk, string xmlTextRequest, out string xmlTextResponse)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }

            xmlTextResponse = string.Empty;
            xmlTextResponse = string.Empty;
            try
            {
            }
            catch (Exception ex)
            {
                //Log.TaskEnd(Id, ex);
                //CommandResponse commandResponse = new CommandResponse(commandId, ex);
                //xmlTextResponse = commandResponse.XmlText;
                //// In general ddk.AuditMessage is not need here. Let the UI display the error from the xmlTextResponse.
                //bool showErrorAsAuditTrail = false;
                //if (showErrorAsAuditTrail)
                //{
                //    ddk.AuditMessage(AuditLevel.Error, ex.Message);
                //}
            }
        }
Beispiel #5
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);
        }
        public static ITypeDouble CreatePercentType(IDDK ddk, double min, double max, int digits)
        {
            ITypeDouble result = ddk.CreateDouble(min, max, digits);

            result.Unit = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_Percent);
            return(result);
        }
        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 static IIntProperty CreateInt(IDDK ddk, IStruct structure, string name, string helpText = null)
        {
            ITypeInt     typeInt = CreateIntType(ddk);
            IIntProperty result  = structure.CreateProperty(name, helpText, typeInt);

            return(result);
        }
Beispiel #9
0
        public Heater(IDriverEx driver, IDDK ddk, Config.Heater config, string id)
            : base(driver, ddk, config, typeof(Heater).Name, id)
        {
            Log.TaskBegin(Id);
            try
            {
                m_Properties = new HeaterProperties(m_DDK, config, m_Device);

                // Enable the scenario below:
                // Heater.TemperatureNominal N
                // Wait                      Heater.Ready
                m_Properties.TemperatureNominal.ImmediateNotReady = true;

                m_Properties.TemperatureControl.OnSetProperty += OnPropertyTemperatureControlSet;

                m_Properties.TemperatureNominal.OnPreflightSetProperty += OnPropertyTemperatureNominalSetPreflight;
                m_Properties.TemperatureNominal.OnSetProperty          += OnPropertyTemperatureNominalSet;

                m_Device.OnPreflightSync += OnDevicePreflightSync;

                Log.TaskEnd(Id);
            }
            catch (Exception ex)
            {
                Log.TaskEnd(Id, ex);
                throw;
            }
        }
        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);
        }
Beispiel #11
0
        public DetectorChannelProperties(IDDK ddk, IDevice device, int deviceNumber, IChannel channel)
            : base(ddk, channel)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }
            if (deviceNumber <= 0)
            {
                throw new ArgumentException("Parameter deviceNumber = " + deviceNumber.ToString() + " must be > 0");
            }

            DetectorChannel.Location location = (DetectorChannel.Location)deviceNumber;
#if DEBUG
            string locationName = Enum.GetName(typeof(DetectorChannel.Location), deviceNumber);
            if (string.IsNullOrEmpty(locationName))
            {
                Device.DebuggerBreak();
            }
#endif
            Location = Property.CreateEnum(ddk, device, Property.ConstantName.Location, location);

            // Location can also be just a number
            //Location = Property.CreateInt(ddk, device, Property.ConstantName.Location";
            //Location.Update(deviceNumber);
        }
Beispiel #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)
        {
            // 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);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
        }
Beispiel #15
0
        public Demo(IDriverEx driver, IDDK ddk, Config.Demo config, string id, InstrumentDataList instrumentDataList, string driverFolder)
            : base(driver, ddk, config, typeof(Demo).Name, id)
        {
            Log.TaskBegin(Id);
            try
            {
                if (string.IsNullOrEmpty(driverFolder))
                {
                    throw new ArgumentNullException("driverFolder");
                }
                if (instrumentDataList == null)
                {
                    throw new ArgumentNullException("instrumentDataList");
                }

                m_Properties = new DemoProperties(driver, m_DDK, config, m_Device);

                //-------------------------------------------------------------------------------------------------------------------
                if (m_DDK.InstrumentMap == null)
                {
                    throw new InvalidOperationException("DDK.InstrumentMap is Null");
                }
                long instrumentsMap = m_DDK.InstrumentMap.Value;
                if (instrumentsMap == (long)InstrumentID.None)
                {
                    throw new InvalidOperationException("DDK.InstrumentMap = " + instrumentsMap.ToString() + " must be != " + ((long)InstrumentID.None).ToString());
                }
                string instrumentsMapBinary = InstrumentData.GetBitMapBinary(instrumentsMap);
                string instrumentsNames     = instrumentDataList.GetNames();

                bool   logInFile      = LogInFile;
                string fileNamePrefix = instrumentDataList[0].Name;
                Log.Init(Id, logInFile, fileNamePrefix);

                // Logging in a file starts here, if logInFile is True
                const string indent = "\t";
                string       text   = Environment.NewLine + Environment.NewLine +
                                      indent + "Driver Folder \"" + driverFolder + "\"" + Environment.NewLine +
                                      indent + "Name        \"" + Name + "\", IsSimulated = " + IsSimulated.ToString() + Environment.NewLine +
                                      indent + "USB Address \"" + UsbAddress + "\"" + Environment.NewLine +
                                      indent + "DDK.InstrumentMap = " + instrumentsMap.ToString() + " = " + instrumentsMapBinary + " = " + instrumentsNames +
                                      Environment.NewLine;
                Log.WriteLine(Id, text);

                //-------------------------------------------------------------------------------------------------------------------
                m_Properties.LogInFile.OnSetProperty += OnPropertyLogInFileSet;

                //-------------------------------------------------------------------------------------------------------------------
                CommandTestInit();
                CommandStartStopInit();

                Log.TaskEnd(Id);
            }
            catch (Exception ex)
            {
                Log.TaskEnd(Id, ex);
                throw;
            }
        }
Beispiel #16
0
        public DetectorChannel(IDriverEx driver, IDDK ddk, IDevice owner, string id, string channelName, int channelNumber, UnitConversion.PhysUnitEnum unit, bool channelNeedsIntegration, string channelPhysicalQuantity)
            : base(driver, ddk, typeof(DetectorChannel).Name, id, channelName, owner, CreateChannel(ddk, channelName, unit))
        {
            m_Number = channelNumber;
            Log.TaskBegin(Id);
            try
            {
                if (owner == null)
                {
                    throw new ArgumentNullException("owner");
                }

                m_Channel = m_Device as IChannel;
                if (m_Channel == null)
                {
                    if (m_Device == null)
                    {
                        throw new InvalidOperationException("The device is not created");
                    }
                    if (m_Channel == null)
                    {
                        throw new InvalidOperationException("The device is type " + m_Device.GetType().FullName + " is not " + typeof(IChannel).FullName);
                    }
                }

                m_Properties = new DetectorChannelProperties(m_DDK, m_Device, channelNumber, m_Channel);

                m_Channel.PhysicalQuantity = channelPhysicalQuantity;  // What do we actually measure
                m_Channel.NeedsIntegration = channelNeedsIntegration;  // If False then this channel doesn't have peaks and, we don't want to have it integrated

                Rate = 100;

                // Signal scaling
                m_Channel.SignalFactorProperty.Update(1);

                m_Properties.Wavelength.OnSetProperty += OnPropertyWaveLengthSet;

                m_Channel.AcquisitionOnCommand.OnPreflightCommand += OnCommandAcquisitionOnPreflight;
                m_Channel.AcquisitionOnCommand.OnCommand          += OnCommandAcquisitionOn;

                m_Channel.AcquisitionOffCommand.OnPreflightCommand += OnCommandAcquisitionOffPreflight;
                m_Channel.AcquisitionOffCommand.OnCommand          += OnCommandAcquisitionOff;

                m_Channel.OnDataFinished += OnChannelDataFinished;

                m_Driver.OnConnected    += OnDriverConnected;
                m_Driver.OnDisconnected += OnDriverDisconnected;

                m_Timer          = new System.Timers.Timer(1000);
                m_Timer.Elapsed += OnTimerElapsed;

                Log.TaskEnd(Id);
            }
            catch (Exception ex)
            {
                Log.TaskEnd(Id, ex);
                throw;
            }
        }
        public static IIntProperty CreateReady(IDDK ddk, IDevice device)
        {
            ITypeInt     type   = CreateBoolType(ddk);
            IIntProperty result = device.CreateStandardProperty(StandardPropertyID.Ready, type);

            result.Update(GetBoolNumber(true));
            return(result);
        }
        public static IIntProperty CreateEnum <T>(IDDK ddk, IStruct structure, string name, T value, string helpText = null)
        {
            ITypeInt     typeInt = CreateEnumType <T>(ddk);
            IIntProperty result  = structure.CreateProperty(name, string.Empty, typeInt);

            UpdateEnumProperty(result, value, helpText);
            return(result);
        }
        public static IIntProperty CreateEnum <T>(IDDK ddk, IDevice device, string name, string helpText = null)
        {
            ITypeInt     typeInt = CreateEnumType <T>(ddk);
            IIntProperty result  = device.CreateProperty(name, string.Empty, typeInt);

            result.HelpText = helpText;
            return(result);
        }
Beispiel #20
0
        /// <summary>
        /// IDriver implementation: Init
        /// </summary>
        /// <param name="cmDDK">The DDK instance</param>
        public void Init(IDDK cmDDK)
        {
            ConfigurationParser configurationParser =
                new ConfigurationParser(m_Configuration);

            m_Device = new BlobDataDevice();
            m_Device.Create(cmDDK, configurationParser.GetDeviceName("Blob data device"));
        }
 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)));
 }
Beispiel #22
0
 /// <summary>Initializes the data with the specified instruments in the instrumentsMap parameter.</summary>
 public void Init(IDDK ddk, long instrumentsMap)
 {
     if (ddk == null)
     {
         throw new ArgumentNullException("ddk");
     }
     Init(ddk.GetInstrumentName, instrumentsMap);
 }
Beispiel #23
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);
        }
Beispiel #24
0
        /// <summary>
        /// IDriver implementation: Init
        /// IDriver.Init is called after successful configuration of the driver.
        /// During IDriver.Init a driver must create its devices, properties, etc.
        /// </summary>
        /// <param name="cmDDK">The DDK instance that hosts the driver.</param>
        public void Init(IDDK cmDDK)
        {
            ConfigurationParser configurationParser =
                new ConfigurationParser(m_Configuration);

            // Create our device.
            m_AutoSamplerDevice = new AutoSamplerDevice();
            m_AutoSamplerDevice.Create(cmDDK, configurationParser.GetDeviceName("Sampler"));
        }
Beispiel #25
0
        private static IDevice CreateChannel(IDDK ddk, string name, UnitConversion.PhysUnitEnum unit)
        {
            ITypeInt typeSignal = ddk.CreateInt(0, 1000);

            typeSignal.Unit = UnitConversionEx.PhysUnitName(unit);
            IChannel result = ddk.CreateChannel(name, "Detector channel", typeSignal);

            return(result);
        }
        /// <summary>
        /// This method is called to exchange data (string) with the driver. The main purpose
        /// is to communicate with the driver configuration module.
        /// </summary>
        /// <remarks>
        /// Note that OnSendReceive can be called BEFORE Init, therefore we receive the calling
        /// IDDK instance as a parameter. When a driver is initially added to the instrument,
        /// it is loaded but it will not be initialized until the user has confirmed the
        /// configuration.
        /// </remarks>
        /// <param name="cmDDK">The DDK instance</param>
        /// <param name="inputString">The string which is sent to the driver</param>
        /// <param name="outputString">The answer string from the driver</param>
        public void OnSendReceive(IDDK cmDDK, string inputString, out string outputString)
        {
            // Write the input to the audit trail.
            cmDDK.AuditMessage(AuditLevel.Message, "OnSendReceive: inputString = " + inputString);

            // Fill in some response.
            outputString = DateTime.Now.ToString() + " - " + inputString;
            cmDDK.AuditMessage(AuditLevel.Message, "OnSendReceive: outputString = " + outputString);
        }
        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);
        }
        /// <summary>
        /// IDriver implementation: Init
        /// </summary>
        /// <param name="cmDDK">The DDK instance</param>
        public void Init(IDDK cmDDK)
        {
            m_MyDevice = new LocalizedDevice();

            ConfigurationParser configurationParser =
                new ConfigurationParser(m_Configuration);

            m_MyDevice.Create(cmDDK, configurationParser.GetDeviceName("Localized Device"));
        }
Beispiel #29
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);
        }
        public static ITypeInt CreateBoolType(IDDK ddk)
        {
            int      numberFalse = GetBoolNumber(false);
            int      numberTrue  = GetBoolNumber(true);
            ITypeInt result      = CreateIntType(ddk, numberFalse, numberTrue);

            result.AddNamedValue(false.ToString(), numberFalse);
            result.AddNamedValue(true.ToString(), numberTrue);
            return(result);
        }