void m_dcrmode_OnSetProperty(SetPropertyEventArgs args) { SetIntPropertyEventArgs intArgs = args as SetIntPropertyEventArgs; if (intArgs != null) { m_dcrmode.Update(intArgs.NewValue); } }
/// <summary> /// We use the OnDataFinished event to stop data acquisition. /// When CM sends this event enough data has already been sent and we can stop immediately. /// </summary> /// <param name="args"></param> void m_MyCmDevice_OnDataFinished(DataFinishedEventArgs args) { if (m_Timer != null) { m_GotDataFinished = true; m_SpectraIndexProperty.Update(null); m_ChannelTimeProperty.Update(null); } }
void m_TerminationTimeoutProperty_OnSetProperty(SetPropertyEventArgs args) { SetIntPropertyEventArgs setIntArgs = args as SetIntPropertyEventArgs; if (setIntArgs.NewValue.HasValue) { m_TerminationTimeoutProperty.Update(setIntArgs.NewValue.Value); m_MyCmDevice.TerminationTimeout = setIntArgs.NewValue.Value; } }
void OnBroadcast(BroadcastEventArgs args) { if (args != null) { switch (args.Broadcast) { case Broadcast.Sampleend: m_ReadyProperty.Update(1); //signal sampler ready break; } } }
/// <summary> /// Called by the clock timer /// </summary> /// <param name="source"></param> /// <param name="args"></param> private void OnTimedEvent(object source, ElapsedEventArgs args) { m_ClockTime++; Trace.WriteLine("OnTimedEvent: " + m_ClockTime); if (m_ClockTime == 60) { m_ClockTime = 0; } // Send the updated clock to Chromeleon. m_ClockProperty.Update(m_ClockTime); }
/// <summary> /// Called when the ValveState property is set by Chromeleon. /// </summary> /// <param name="args">The SetPropertyEventArgs contain both a reference to /// the property being set and the new value.</param> private void m_ValveState_OnSetProperty(SetPropertyEventArgs args) { SetIntPropertyEventArgs intArgs = args as SetIntPropertyEventArgs; Debug.Assert((intArgs != null) && (intArgs.NewValue.HasValue)); // Write a message to the audit trail String message = String.Format(CultureInfo.InvariantCulture, "m_ValveState_OnSetProperty(time: {1} newValue: {0})", intArgs.NewValue, RetentionToString(args.RetentionTime)); m_MyCmDevice.AuditMessage(AuditLevel.Message, message); // As we simulate the valve only, we update the property direcly. m_ValveState.Update(intArgs.NewValue.Value); }
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 CreateReady(IDDK ddk, IDevice device) { ITypeInt type = CreateBoolType(ddk); IIntProperty result = device.CreateStandardProperty(StandardPropertyID.Ready, type); result.Update(GetBoolNumber(true)); 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); }
/// <summary> /// We use a timer to determine if the runtime is already finished. /// If TerminateInTime = On we will allow the instrument method to terminate /// properly by setting IDevice.DelayTermination=false half the /// interval given by IDevice.TerminationTimeout later. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void m_ProgramTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (m_TerminateInTimeProperty.Value.HasValue && m_TerminateInTimeProperty.Value.Value == 1) { TimeSpan runTime = DateTime.Now - m_StartTime; TimeSpan expectedRunTime = new TimeSpan(0, 0, m_EndTime.HundredthSeconds / 100) + new TimeSpan(0, 0, m_TerminationTimeoutProperty.Value.Value / 2); if (runTime >= expectedRunTime) { m_MyCmDevice.DelayTermination = false; m_DelayTerminationProperty.Update(m_MyCmDevice.DelayTermination ? 1 : 0); } } }
void m_TerminateInTimeProperty_OnSetProperty(SetPropertyEventArgs args) { SetIntPropertyEventArgs setIntArgs = args as SetIntPropertyEventArgs; if (setIntArgs.NewValue.HasValue) { m_TerminateInTimeProperty.Update(setIntArgs.NewValue.Value); } }
/// <summary> /// OnConnect we set up some initial values. /// In a real driver, OnConnect would establish the hardware connection first and /// retrieve the actual hardware status from the hardware. /// </summary> internal void OnConnect() { // Write a message to the audit trail m_MyCmDevice.AuditMessage(AuditLevel.Message, "ExampleDevice.OnConnect()"); // set up the initial values m_EnableClockProperty.Update(0); m_MyString = "Initial value"; // Send the updated string to Chromeleon. m_AnyTextProperty.Update(m_MyString); m_Percentage = 11.11; // Send the updated percentage to Chromeleon. m_PercentageProperty.Update(m_Percentage); // Update the other properties m_FilterTimeConstantProperty.Update(0.0); m_MeasurementRangeProperty.Update(10.0); }
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); }
/// OnSetState will be called when the State property is set by CM. private void OnSetState(SetPropertyEventArgs args) { if (args.Property == m_PropState) { SetIntPropertyEventArgs intPropertyArgs = args as SetIntPropertyEventArgs; Debug.Assert(intPropertyArgs.NewValue.HasValue); m_State = intPropertyArgs.NewValue.Value; if (m_State == 1) { Driver.Comm.SetRelayState(m_Index, true); } else { Driver.Comm.SetRelayState(m_Index, false); } m_PropState.Update(m_State); } }
/// <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); }
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); }
/// <summary> /// IDriver implementation: Connect /// When we are connected, we initialize our properties. /// </summary> internal void OnConnect() { m_EventAProperty.Update(0); m_EventBProperty.Update(0); }
/// Create our Dionex.Chromeleon.Symbols.IDevice and our Properties internal IDevice Create(IDDK cmDDK, string name) { // Create a device for temperature control m_Device = cmDDK.CreateDevice(name, "Example for a temperature control device"); // Create a type for a temperature logging command ITypeInt tyTempLogParam = cmDDK.CreateInt(0, 2); tyTempLogParam.AddNamedValue("Start", 0); tyTempLogParam.AddNamedValue("Stop", 1); tyTempLogParam.AddNamedValue("Pause", 2); // Create a temperature logging command ICommand logTemperature = m_Device.CreateCommand("LogTemperature", "Switches temperature logging on / off"); // Add a parameter for the tewmperature logging command logTemperature.AddParameter("LogParameter", "Starts, stops or pauses temperature logging", tyTempLogParam); // Create a boolean property to signal if the device is ready for an inject operation. ITypeInt tyReady = cmDDK.CreateInt(0, 1); tyReady.AddNamedValue("False", 0); tyReady.AddNamedValue("True", 1); IProperty readyProp = m_Device.CreateStandardProperty(StandardPropertyID.Ready, tyReady); // Create a data type that represent the activation state of the temperature control. ITypeInt tOnOff = cmDDK.CreateInt((int)TempCtrlState.Off, (int)TempCtrlState.On); tOnOff.AddNamedValue("Off", (int)TempCtrlState.Off); tOnOff.AddNamedValue("On", (int)TempCtrlState.On); // Create a property to activate / deactivate temperature control // This property must be writable m_TempCtrlProperty = m_Device.CreateProperty("TemperatureControl", "Activates /deactivates temperature control", tOnOff); m_TempCtrlProperty.Writeable = true; // Create a struct that holds standard properties for temperature and temperature limits m_TempCtrlStruct = m_Device.CreateStruct("Temperature", "Temperature of Column Oven."); // Create a data type that applies to all temperature properties ITypeDouble tTemperature = cmDDK.CreateDouble(0, 100, 1); tTemperature.Unit = "°C"; // Create a property that holds the current temperature // This property is read-only m_CurrentTempProperty = m_TempCtrlStruct.CreateStandardProperty(StandardPropertyID.Value, tTemperature); // Create a property that holds the nominal temperature // This property must be writeable m_NominalTempProperty = m_TempCtrlStruct.CreateStandardProperty(StandardPropertyID.Nominal, tTemperature); m_NominalTempProperty.Update(30.0); //set default value m_NominalTempProperty.OnSetProperty += new SetPropertyEventHandler(OnSetTemperature); // Create a property that holds the minimal temperature // This property must be writeable m_MinTempProperty = m_TempCtrlStruct.CreateStandardProperty(StandardPropertyID.LowerLimit, tTemperature); m_MinTempProperty.Update(15.0); //set default value m_MinTempProperty.Writeable = true; // Create a property that holds the maximal temperature // This property must be writeable m_MaxTempProperty = m_TempCtrlStruct.CreateStandardProperty(StandardPropertyID.UpperLimit, tTemperature); m_MaxTempProperty.Update(110.0);//set default value m_MaxTempProperty.Writeable = true; // Set the default read and write properties for the struct m_TempCtrlStruct.DefaultSetProperty = m_NominalTempProperty; m_TempCtrlStruct.DefaultGetProperty = m_CurrentTempProperty; // Update property values. They must be readable before the device has been connected. // The device may not be connected when UI-Modules read the default values. m_TempCtrlProperty.Update((int)m_TempCtrl); m_NominalTempProperty.Update(m_NominalTemp); m_MinTempProperty.Update(m_MinTemp); m_MaxTempProperty.Update(m_MaxTemp); m_CurrentTempProperty.Update(m_CurrentTemp); return(m_Device); }
/// <summary> /// IDriver implementation: Connect /// When we are connected, we initialize properties that are visible in the connected state only. /// </summary> internal void OnConnect() { m_MyIntProperty.Update(1); }
void properBoolean_OnSetProperty(SetPropertyEventArgs args) { SetIntPropertyEventArgs intArgs = args as SetIntPropertyEventArgs; m_MyProperBoolean.Update(intArgs.NewValue); }
/// When we are connected, we initialize our properties. internal void OnConnect() { m_ModelNoProperty.Update("Preflight Model"); m_someProperty.Update(0); }