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; }
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 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; }
/// 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); }