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); }
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 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); }
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); }
/// <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); }
public static async Task <IEntityValue> CreateUIPropertyValueValueAsync(IEntityRuntimeModel runtimeModel, EntityIdentity id, ProjectConfiguration configuration, ProjectSystem.Properties.IProperty property, IUIPropertyValuePropertiesAvailableStatus requestedProperties) { Requires.NotNull(property, nameof(property)); var newUIPropertyValue = new UIPropertyValueValue(runtimeModel, id, new UIPropertyValuePropertiesAvailableStatus()); if (requestedProperties.UnevaluatedValue) { if (property is IEvaluatedProperty evaluatedProperty) { newUIPropertyValue.UnevaluatedValue = await evaluatedProperty.GetUnevaluatedValueAsync(); } else { newUIPropertyValue.UnevaluatedValue = await property.GetValueAsync() as string; } } if (requestedProperties.EvaluatedValue) { newUIPropertyValue.EvaluatedValue = property switch { IBoolProperty boolProperty => await boolProperty.GetValueAsBoolAsync(), IStringProperty stringProperty => await stringProperty.GetValueAsStringAsync(), IIntProperty intProperty => await intProperty.GetValueAsIntAsync(), IEnumProperty enumProperty => (await enumProperty.GetValueAsIEnumValueAsync())?.Name, IStringListProperty stringListProperty => await stringListProperty.GetValueAsStringCollectionAsync(), _ => await property.GetValueAsync() }; } ((IEntityValueFromProvider)newUIPropertyValue).ProviderState = new PropertyValueProviderState(configuration, property); return(newUIPropertyValue); }
/// 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); }
private static void UpdateEnumProperty <T>(IIntProperty property, T value, string helpText) { property.HelpText = helpText; int valueNumber = Convert.ToInt32(value); property.Update(valueNumber); }
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); }
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); }
/// <summary>Returns the value before the script assignment</summary> public Nullable <int> GetPreconditionValue(IIntProperty property) { IPropertyValue propertyValue = GetPreconditionPropertyValue(property); IIntPropertyValue intPropertyValue = propertyValue as IIntPropertyValue; Nullable <int> result = intPropertyValue.Value; return(result); }
private void OnTest(SetPropertyEventArgs args) { SetIntPropertyEventArgs iProp = args as SetIntPropertyEventArgs; m_MyCmDevice.AuditMessage(AuditLevel.Message, args.RunContext.ProgramTime.Minutes.ToString() + " min: OnSetProperty OnTest"); IIntProperty intProperty = iProp.Property as IIntProperty; intProperty.Update(iProp.NewValue); }
public static void PropertyChanged(string callerId, string unitName, IIntProperty property, string callerMethodName = null) { if (callerMethodName == null) { callerMethodName = CallerMethodName; } Nullable <int> value = property.Value; WriteLinePropertyChanged(callerId, property.Name, (value == null ? "Null" : value.GetValueOrDefault().ToString(CultureInfo.InvariantCulture)) + " " + unitName, callerMethodName); }
public static void PropertyChangedBinary(string callerId, IIntProperty property, int numberOfBits = 0, string callerMethodName = null) { if (callerMethodName == null) { callerMethodName = CallerMethodName; } uint value = (uint)property.Value.GetValueOrDefault(); PropertyChangedBinary(callerId, property.Name, value, numberOfBits, callerMethodName); }
/// 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); }
public AutoSamplerProperties(IDDK ddk, IDevice device) { if (ddk == null) { throw new ArgumentNullException("ddk"); } if (device == null) { throw new ArgumentNullException("device"); } Ready = Property.CreateReady(ddk, device); }
/// Create our Chromeleon symbols internal IChannel OnCreate(IDDK cmDDK, IDevice master, string name) { // Create a data type for our signal ITypeDouble tSignal = cmDDK.CreateDouble(-100.0, 100.0, 1); tSignal.Unit = "mV"; // Create the channel symbol m_MyCmDevice = cmDDK.CreateChannel(name, "Channel that can generate both sinus curve and sawtooth signal as Int64 data points.", tSignal); // We will be a subdevice of the master device m_MyCmDevice.SetOwner(master); // Attach our handlers to the AcquisitionOffCommand and AcquisitionOnCommand of the channel m_MyCmDevice.AcquisitionOffCommand.OnCommand += new CommandEventHandler(OnAcqOff); m_MyCmDevice.AcquisitionOnCommand.OnCommand += new CommandEventHandler(OnAcqOn); m_MyCmDevice.OnDataFinished += new DataFinishedEventHandler(m_MyCmDevice_OnDataFinished); // These two parameters are not longer relevant when using the new UpdateDataEx function // in contradiction to the old UpdateData interface. So leave these parameters unchanged; // the DDK will initialize them appropriately. m_MyCmDevice.TimeStepFactorProperty.Writeable = false; m_MyCmDevice.TimeStepDivisorProperty.Writeable = false; ITypeDouble tRateType = cmDDK.CreateDouble(0.1, 1000.0, 1); tRateType.Unit = "Hz"; m_RateProperty = m_MyCmDevice.CreateProperty("FixedRate", "The data collection rate in Hz.", tRateType); m_RateProperty.OnSetProperty += new SetPropertyEventHandler(m_RateProperty_OnSetProperty); ITypeInt tDataIndexType = cmDDK.CreateInt(0, int.MaxValue); m_DataIndexProperty = m_MyCmDevice.CreateProperty("TotalDataPoints", "Total number of data points.", tDataIndexType); ICommand noMoreDataCommand = m_MyCmDevice.CreateCommand("NoMoreData", "Send IChannel.NoMoreData to stop data acquisition immediately."); noMoreDataCommand.OnCommand += new CommandEventHandler(noMoreDataCommand_OnCommand); ITypeDouble tChannelTimeType = cmDDK.CreateDouble(0, 1000, 3); tChannelTimeType.Unit = "min"; m_ChannelTimeProperty = m_MyCmDevice.CreateProperty("ChannelTime", "Internal time of the channel.", tChannelTimeType); // This channel doesn't have peaks, we don't want to have it integrated. m_MyCmDevice.NeedsIntegration = false; return(m_MyCmDevice); }
public static void PropertyChangedBool(string callerId, IIntProperty property, Nullable <bool> value, string callerMethodName = null) { if (callerMethodName == null) { callerMethodName = CallerMethodName; } if (value == null) { WriteLinePropertyChanged(callerId, property.Name, "Null", callerMethodName); } else { WriteLinePropertyChanged(callerId, property.Name, value.GetValueOrDefault().ToString(CultureInfo.InvariantCulture), callerMethodName); } }
public DemoProperties(IDriverEx driver, IDDK ddk, Config.Demo config, IDevice device) { if (ddk == null) { throw new ArgumentNullException("ddk"); } if (config == null) { throw new ArgumentNullException("config"); } if (device == null) { throw new ArgumentNullException("device"); } LogInFile = Property.CreateBool(ddk, device, "LogInFile"); LogInFile.Writeable = true; LogInFile.AuditLevel = AuditLevel.Service; LogInFile.Update(Property.GetBoolNumber(true)); // Can be configurable = config.LogInFile m_IsSimulated = Property.CreateBool(ddk, device, "IsSimulated"); m_IsSimulated.Update(Property.GetBoolNumber(driver.IsSimulated)); if (driver.IsSimulated != config.IsSimulated) { Device.DebuggerBreak(); } FirmwareUsbAddress = Property.CreateString(ddk, device, "FirmwareUsbAddress"); FirmwareUsbAddress.Update(driver.FirmwareUsbAddress); FirmwareVersion = Property.CreateString(ddk, device, "FirmwareVersion"); FirmwareVersion.Update(driver.FirmwareVersion); SerialNo = device.CreateStandardProperty(StandardPropertyID.SerialNo, ddk.CreateString(100)); SerialNo.Update(driver.SerialNo); TaskName = Property.CreateString(ddk, device, "TaskName", driver.TaskName); TaskNamePrevious = Property.CreateString(ddk, device, "TaskNamePrevious", driver.TaskNamePrevious); TaskPreviousErrorText = Property.CreateString(ddk, device, "TaskPreviousErrorText", driver.TaskPreviousErrorText); CommunicationState = Property.CreateEnum(ddk, device, "CommunicationState", driver.CommunicationState, null); BehaviorStatePrev = Property.CreateEnum(ddk, device, "BehaviorStatePrev", driver.BehaviorStatePrev); BehaviorState = Property.CreateEnum(ddk, device, "BehaviorState", driver.BehaviorState); ProcessStep = Property.CreateInt(ddk, device, "ProcessStep"); ProcessStep.Update(0); }
private Nullable <int> GetScriptOrPreconditionValue(IIntProperty property, bool ifNotFoundReturnPreconditionValue) { Nullable <int> result = null; IPropertyValue propertyValue = GetPropertyValue(property); if (propertyValue == null) { if (ifNotFoundReturnPreconditionValue) { result = GetPreconditionValue(property); } return(result); } IIntPropertyValue intPropertyValue = propertyValue as IIntPropertyValue; result = intPropertyValue.Value; return(result); }
public static string GetValueName(IIntProperty property) { INamedIntList namedValues = property == null || property.DataType == null ? null : property.DataType.NamedValues; if (namedValues == null || property.Value == null) { return(null); } string result = null; int value = property.Value.GetValueOrDefault(); INamedInt namedValue = namedValues.Find(value); if (namedValue != null) { result = namedValue.Name; } return(result); }
internal IChannel Create(IDDK cmDDK, string name) { // Create a data type for our signal ITypeInt tSignal = cmDDK.CreateInt(-100, 100); // Create the channel symbol m_MyCmDevice = cmDDK.CreateChannel(name, "This is a channel that can generate a sinus curve.", tSignal); // Attach our handlers to the AcquisitionOffCommand and AcquisitionOnCommand of the channel m_MyCmDevice.AcquisitionOffCommand.OnCommand += new CommandEventHandler(OnAcqOff); m_MyCmDevice.AcquisitionOnCommand.OnCommand += new CommandEventHandler(OnAcqOn); m_MyCmDevice.TimeStepFactorProperty.DataType.Minimum = 1; m_MyCmDevice.TimeStepFactorProperty.DataType.Maximum = 1; m_MyCmDevice.TimeStepFactorProperty.Writeable = false; m_MyCmDevice.TimeStepDivisorProperty.DataType.Minimum = 1; m_MyCmDevice.TimeStepDivisorProperty.DataType.Maximum = 1; m_MyCmDevice.TimeStepDivisorProperty.Writeable = false; m_dcr = m_MyCmDevice.CreateProperty("Data_Collection_Rate", "This is the data collection rate of the device", cmDDK.CreateDouble(0.1, 300.0, 1)); m_dcr.OnPreflightSetProperty += new SetPropertyEventHandler(m_dcr_OnPreflightSetProperty); m_dcr.OnSetProperty += new SetPropertyEventHandler(m_dcr_OnSetProperty); ITypeInt dcrModeType = cmDDK.CreateInt(0, 1); dcrModeType.AddNamedValue("Regular", 0); dcrModeType.AddNamedValue("Random", 1); m_dcrmode = m_MyCmDevice.CreateProperty("DCRMode", "Mode in which the data points are sent - regular interval or arbitrary", dcrModeType); m_dcrmode.OnSetProperty += new SetPropertyEventHandler(m_dcrmode_OnSetProperty); m_dcrmode.OnPreflightSetProperty += new SetPropertyEventHandler(m_dcrmode_OnPreflightSetProperty); ITypeInt signalTypeType = cmDDK.CreateInt(0, 1); signalTypeType.AddNamedValue("SawTooth", 0); signalTypeType.AddNamedValue("Sinus", 1); m_signalType = m_MyCmDevice.CreateProperty("SignalType", "The signal type of the simulation mode data - SawTooth or Sinus (frequency 0.1Hz)", signalTypeType); m_signalType.OnSetProperty += new SetPropertyEventHandler(m_signalType_OnSetProperty); 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="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); }
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); }
/// <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); }
public DetectorProperties(IDDK ddk, IDevice device, Config.Detector config) { if (ddk == null) { throw new ArgumentNullException("ddk"); } if (device == null) { throw new ArgumentNullException("device"); } if (config == null) { throw new ArgumentNullException("config"); } Ready = Property.CreateReady(ddk, device); IsAutoZeroRunning = Property.CreateBool(ddk, device, "IsAutoZeroRunning"); IsAutoZeroRunning.Update(Property.GetBoolNumber(false)); IIntProperty channelsNumber = Property.CreateInt(ddk, device, "ChannelsNumber"); channelsNumber.Update(config.ChannelsNumber); }
/// <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); }
/// Create our Chromeleon symbols internal IPDAChannel OnCreate(IDDK cmDDK, IDevice master, string name) { // Create a data type for the wavelength range ITypeDouble tWavelength = cmDDK.CreateDouble(200.0, 600.0, 1); tWavelength.Unit = "nm"; // Create a data type for the reference wavelength range ITypeDouble tRefWavelength = cmDDK.CreateDouble(200.0, 600.0, 1); tRefWavelength.Unit = "nm"; tRefWavelength.AddNamedValue("Off", 0.0); // Create a data type for the reference bandwidth ITypeDouble tReferenceBandwidth = cmDDK.CreateDouble(0.0, 20.0, 1); tReferenceBandwidth.Unit = "nm"; // Create a data type for the bunch width ITypeDouble tBunchWidth = cmDDK.CreateDouble(0.0, 10.0, 1); tBunchWidth.Unit = "nm"; // Create the channel symbol m_MyCmDevice = cmDDK.CreatePDAChannel(name, "This is a channel that can generate a spectrum.", tWavelength, tRefWavelength, tReferenceBandwidth, tBunchWidth, 400, PDAWriteMode.AbsorbanceDirect); // We will be a subdevice of the master device m_MyCmDevice.SetOwner(master); // Attach our handlers to the AcquisitionOffCommand and AcquisitionOnCommand of the channel m_MyCmDevice.AcquisitionOffCommand.OnCommand += new CommandEventHandler(OnAcqOff); m_MyCmDevice.AcquisitionOnCommand.OnCommand += new CommandEventHandler(OnAcqOn); m_MyCmDevice.OnDataFinished += new DataFinishedEventHandler(m_MyCmDevice_OnDataFinished); // Usually, TimeStepFactor and TimeStepFactor are read-only properties and the driver updates them. // In this driver we allow to change these values manually for illustration purposes. m_MyCmDevice.TimeStepFactorProperty.DataType.Minimum = 1; m_MyCmDevice.TimeStepFactorProperty.DataType.Maximum = 10000; m_MyCmDevice.TimeStepFactorProperty.OnSetProperty += new SetPropertyEventHandler(TimeStepFactorProperty_OnSetProperty); m_MyCmDevice.TimeStepDivisorProperty.DataType.Minimum = 1; m_MyCmDevice.TimeStepDivisorProperty.DataType.Maximum = 10000; m_MyCmDevice.TimeStepDivisorProperty.OnSetProperty += new SetPropertyEventHandler(TimeStepDivisorProperty_OnSetProperty); ITypeDouble tRateType = cmDDK.CreateDouble(0.1, 1000.0, 1); tRateType.Unit = "Hz"; m_RateProperty = m_MyCmDevice.CreateProperty("FixedRate", "The data collection rate in Hz.", tRateType); m_RateProperty.OnSetProperty += new SetPropertyEventHandler(m_RateProperty_OnSetProperty); ITypeInt tDataIndexType = cmDDK.CreateInt(0, int.MaxValue); m_SpectraIndexProperty = m_MyCmDevice.CreateProperty("TotalSpectra", "Total number of spectra.", tDataIndexType); ICommand noMoreDataCommand = m_MyCmDevice.CreateCommand("NoMoreData", "Send IChannel.NoMoreData to stop data acquisition immediately."); noMoreDataCommand.OnCommand += new CommandEventHandler(noMoreDataCommand_OnCommand); ITypeDouble tChannelTimeType = cmDDK.CreateDouble(0, 1000, 3); tChannelTimeType.Unit = "min"; m_ChannelTimeProperty = m_MyCmDevice.CreateProperty("ChannelTime", "Internal time of the channel.", tChannelTimeType); 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) { 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); }