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;
        }
示例#2
0
        public static ITypeDouble CreatePercentType(IDDK ddk, double min, double max, int digits)
        {
            ITypeDouble result = ddk.CreateDouble(min, max, digits);

            result.Unit = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_Percent);
            return(result);
        }
示例#3
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);
        }
示例#4
0
        public static ITypeDouble CreateDoubleType(IDDK ddk,
                                                   Nullable <UnitConversion.PhysUnitEnum> unit = null,
                                                   double minValue = double.MinValue, double maxValue = double.MaxValue, int precision = 3)
        {
            ITypeDouble result = ddk.CreateDouble(minValue, maxValue, precision);

            if (unit != null)
            {
                result.Unit = UnitConversionEx.PhysUnitName(unit.GetValueOrDefault());
            }
            return(result);
        }
示例#5
0
        //private Driver m_Driver;
        //private IConfigSendReceive m_SendReceive;
        //private IInstrumentInfo m_InstrumentInfo;
        #endregion

        #region Constructor
        public MainForm()
        {
#if DEBUG
            //Debugger.Launch();
#endif
            InitializeComponent();

            gbDemo.Text       = string.Empty;
            txtDemo_Name.Text = string.Empty;
            txtDemo_FirmwareUsbAddress.Text = string.Empty;
            lblFirmwareVersion.Text         = string.Empty;
            lblSerialNo.Text = string.Empty;

            chkDemo_IsSimulated.CheckedChanged += OnDemo_IsSimulated_CheckedChanged;

            txtDemo_Name.Validating     += OnDemo_Name_Validating;
            txtHeater_Name.Validating   += OnHeater_Name_Validating;
            txtDetector_Name.Validating += OnDetector_Name_Validating;

            HelpButtonClicked += OnMainFormHelp;

            btnOK.Click += OnBtnOK;

            // Conversion example
            const double valuePsi        = 100;
            double       valueMegaPascal = UnitConversionEx.PhysUnitConvert(UnitConversion.PhysUnitEnum.PhysUnit_Psi, UnitConversion.PhysUnitEnum.PhysUnit_MegaPascal, valuePsi); // 0.68947569999999991
            double       valueBar        = UnitConversionEx.PhysUnitConvert(UnitConversion.PhysUnitEnum.PhysUnit_Psi, UnitConversion.PhysUnitEnum.PhysUnit_Bar, valuePsi);        // 6.8947569999999994

            // Not localized
            string unitPsi        = UnitConversionEx.PhysUnitLatin(UnitConversion.PhysUnitEnum.PhysUnit_Psi);         // psi
            string unitMegaPascal = UnitConversionEx.PhysUnitLatin(UnitConversion.PhysUnitEnum.PhysUnit_MegaPascal);  // MPa
            string unitBar        = UnitConversionEx.PhysUnitLatin(UnitConversion.PhysUnitEnum.PhysUnit_Bar);         // bar

            // Localized
            string unitPsiLocalized        = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_Psi);
            string unitMegaPascalLocalized = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_MegaPascal);
            string unitBarLocalized        = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_Bar);

            string text = valuePsi.ToString() + " " + unitPsi + " " + unitPsiLocalized + " = " +
                          valueMegaPascal.ToString() + " " + unitMegaPascal + " " + unitMegaPascalLocalized + " = " +
                          valueBar.ToString() + " " + unitBar + " " + unitBarLocalized;
            Trace.WriteLine(text);
        }
示例#6
0
        private static IDevice CreateChannel(IDDK ddk, string name, UnitConversion.PhysUnitEnum unit)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (unit == UnitConversion.PhysUnitEnum.PhysUnit_Unknown)
            {
                throw new ArgumentException("The unit mus be specified");
            }

            ITypeInt typeSignal = ddk.CreateInt(0, 1000);

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

            return(result);
        }
示例#7
0
        private static IDevice CreateChannel(IDDK ddk, string name, double min, double max, int digits, UnitConversion.PhysUnitEnum unit)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (unit == UnitConversion.PhysUnitEnum.PhysUnit_Unknown)
            {
                throw new ArgumentException("The unit mus be specified");
            }

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

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

            return(result);
        }
示例#8
0
        public AutoSampler(IDriverEx driver, IDDK ddk, Config.AutoSampler config, string id)
            : base(driver, ddk, typeof(AutoSampler).Name, id, config.Name)
        {
            Log.TaskBegin(Id);
            try
            {
                m_Properties = new AutoSamplerProperties(m_DDK, m_Device);

                ITypeDouble volumeType = m_DDK.CreateDouble(0.1, 30, 3);
                volumeType.Unit = UnitConversionEx.PhysUnitName(UnitConversion.PhysUnitEnum.PhysUnit_MicroLiter); // µl

                int      positionMax  = m_RackInfos.Sum(item => item.TubeColumnsCount * item.TubeRowsCount);
                ITypeInt positionType = m_DDK.CreateInt(1, positionMax);
                positionType.NamedValuesOnly = false;
                int position = positionType.Minimum.GetValueOrDefault() - 1;
                foreach (RackInfo rack in m_RackInfos)
                {
                    int tubeNumber = rack.TubeFirstNumber - 1;

                    for (int row = 1; row <= rack.TubeRowsCount; row++)
                    {
                        for (int col = 1; col <= rack.TubeColumnsCount; col++)
                        {
                            position++;
                            tubeNumber++;
                            string positionName = rack.TubePositionNamePrefix + tubeNumber.ToString();
                            positionType.AddNamedValue(positionName, tubeNumber);
                        }
                    }
                }

                m_InjectHandler = m_Device.CreateInjectHandler(volumeType, positionType);

                m_RackDesciptionProperty            = m_Device.CreateStandardProperty(StandardPropertyID.TrayDescription, m_DDK.CreateString(1000));
                m_RackDesciptionProperty.AuditLevel = AuditLevel.Service;
                string rackDescription = GetRackDescription();
                if (m_RackDesciptionProperty.DataType.Length < rackDescription.Length)
                {
                    throw new InvalidOperationException("m_RackDesciptionProperty length " + m_RackDesciptionProperty.DataType.Length + " is less than the needed " + rackDescription.Length.ToString());
                }
                m_RackDesciptionProperty.Update(rackDescription);

                m_Position       = -1;
                m_VolumeUnitName = m_InjectHandler.VolumeProperty.DataType.Unit;  // µl
                m_VolumeUnit     = UnitConversionEx.PhysUnitFindName(m_VolumeUnitName);

                m_InjectHandler.PositionProperty.OnSetProperty += OnPropertyPositionSet;
                m_InjectHandler.VolumeProperty.OnSetProperty   += OnPropertyVolumeSet;

                m_InjectHandler.InjectCommand.OnCommand += OnCommandInjectHandlerInject;

                m_Device.OnBatchPreflightBegin += OnDeviceBatchPreflightBegin;

                m_Device.OnPreflightEnd += OnDevicePreflightEnd;

                m_Device.OnTransferPreflightToRun += OnDeviceTransferPreflightToRun;

                m_Device.OnSequenceStart  += OnDeviceSequenceStart;
                m_Device.OnSequenceChange += OnDeviceSequenceChange;
                m_Device.OnSequenceEnd    += OnDeviceSequenceEnd;

                m_Device.OnBroadcast += OnDeviceBroadcast;

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

                Log.TaskEnd(Id);
            }
            catch (Exception ex)
            {
                Log.TaskEnd(Id, ex);
                throw;
            }
        }
示例#9
0
        public HeaterProperties(IDDK ddk, Config.Heater config, IDevice device)
        {
            if (ddk == null)
            {
                throw new ArgumentNullException("ddk");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }

            Ready = Property.CreateReady(ddk, device);

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

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

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

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

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

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

            temperatureType.Unit = temperatureUnit;

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

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

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

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

            // Set the default read and write properties for the structure
            m_Temperature.DefaultGetProperty = TemperatureValue;
            m_Temperature.DefaultSetProperty = TemperatureNominal;
        }
示例#10
0
        public Pump(IDriverEx driver, IDDK ddk, Config.Pump config, string id)
            : base(driver, ddk, typeof(Pump).Name, id, config.Name)
        {
            Log.TaskBegin(Id);
            try
            {
                m_Properties = new PumpProperties(m_DDK, m_Device);

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

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

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

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

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

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

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

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

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

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

                m_Device.OnTransferPreflightToRun += OnDeviceTransferPreflightToRun;

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

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

                m_Device.OnBroadcast += OnDeviceBroadcast;

                Log.TaskEnd(Id);
            }
            catch (Exception ex)
            {
                Log.TaskEnd(Id, ex);
                throw;
            }
        }