void m_Device_OnPreflightEnd(PreflightEventArgs args)
        {
            String message = String.Format("Device.OnPreflightEnd({0}) called", args.RunContext);

            m_Device.AuditMessage(AuditLevel.Warning, message);

            IProgramSteps steps = args.RunContext.ProgramSteps;

            message = String.Format("ProgramSteps count: {0}", steps.Count);
            m_Device.AuditMessage(AuditLevel.Warning, message);
            foreach (IProgramStep step in steps)
            {
                IPropertyAssignmentStep paStep = step as IPropertyAssignmentStep;
                if (paStep != null)
                {
                    message = String.Format("Assignment at time {0} for property {1}", paStep.Retention.Minutes, paStep.Property.Name);
                }
                ILatchStep lStep = step as ILatchStep;
                if (lStep != null)
                {
                    message = String.Format("Latch at time {0}", lStep.Retention);
                }
                ISyncStep sStep = step as ISyncStep;
                if (sStep != null)
                {
                    message = String.Format("Sync at time {0}", sStep.Retention);
                }
                IRampStep rStep = step as IRampStep;
                if (rStep != null)
                {
                    message = String.Format("Ramp at time {0}", rStep.Retention);
                }
                m_Device.AuditMessage(AuditLevel.Warning, message);
            }
        }
            private IPropertyValue GetPropertyValue(IProperty property)
            {
                IPropertyValue result = null;

                foreach (IProgramStep step in m_runContext.ProgramSteps)
                {
                    IPropertyAssignmentStep assignmentStep = step as IPropertyAssignmentStep;
                    if (assignmentStep != null && assignmentStep.Property == property)
                    {
                        result = assignmentStep.Value;
                    }
                }
                return(result);
            }
        /// <summary>
        /// OnTransferPfToRun is called when the previously preflighted instrument method is actually started.
        /// </summary>
        /// <param name="args">The PreflightEventArgs contain the IRunContext with the ProgramSteps.</param>
        private void OnTransferPfToRun(PreflightEventArgs args)
        {
            m_MyCmDevice.AuditMessage(AuditLevel.Message, "OnTransferPreflightToRun handler OnTransferPfToRun, please wait...");

            // We use the IProgramStep interface to walk the list of events in the instrument method.
            // In a real driver we would need to build some kind of time table and send it to the hardware.
            // In this example we create a list instead and write it to the audit trail.
            // Note that the property is not updated, as this would be done asynchronously during the run.

            StringBuilder sb = new StringBuilder("Table of timed events:\n");

            foreach (IProgramStep step in args.RunContext.ProgramSteps)
            {
                IPropertyAssignmentStep propertyAssignment = step as IPropertyAssignmentStep;

                if (propertyAssignment != null)
                {
                    if (propertyAssignment.Value.Property == m_EventAProperty ||
                        propertyAssignment.Value.Property == m_EventBProperty)
                    {
                        IIntPropertyValue value = propertyAssignment.Value as IIntPropertyValue;

                        sb.Append("Retention ");
                        sb.Append(step.Retention.Minutes.ToString("F3"));
                        sb.Append(": ");
                        sb.Append(propertyAssignment.Value.Property.Name);
                        sb.Append("=");
                        sb.Append(value.Value.ToString());
                        sb.Append("\n");
                    }
                }
            }

            m_MyCmDevice.AuditMessage(AuditLevel.Message, sb.ToString());

            m_MyCmDevice.AuditMessage(AuditLevel.Message, "OnTransferPreflightToRun handler OnTransferPfToRun has finished.");
        }
Exemple #4
0
        private void OnDeviceTransferPreflightToRun(PreflightEventArgs args)
        {
            Log.WriteLine(Id, "ProgramTime.Minutes = " + args.RunContext.ProgramTime.Minutes.ToString());

            m_IsRamped = false;

            // Iterate  through each IProgramStep from the instrument method
            bool isIsocratic = false;

            foreach (IProgramStep step in args.RunContext.ProgramSteps)
            {
                IPropertyAssignmentStep propertyAssignmentStep = step as IPropertyAssignmentStep;
                if (propertyAssignmentStep == null)
                {
                    continue;
                }

                if (propertyAssignmentStep.Property == m_FlowHandler.FlowNominalProperty)
                {
                    isIsocratic   = true;
                    FlowRequested = (propertyAssignmentStep.Value as IDoublePropertyValue).Value.GetValueOrDefault();
                }
                else if (propertyAssignmentStep.Property == m_FlowHandler.ComponentProperties[1])
                {
                    isIsocratic      = true;
                    m_EluentPercentB = (propertyAssignmentStep.Value as IDoublePropertyValue).Value.GetValueOrDefault();
                }
                else if (propertyAssignmentStep.Property == m_FlowHandler.ComponentProperties[2])
                {
                    isIsocratic      = true;
                    m_EluentPercentC = (propertyAssignmentStep.Value as IDoublePropertyValue).Value.GetValueOrDefault();
                }
                else if (propertyAssignmentStep.Property == m_FlowHandler.ComponentProperties[3])
                {
                    isIsocratic      = true;
                    m_EluentPercentD = (propertyAssignmentStep.Value as IDoublePropertyValue).Value.GetValueOrDefault();
                }
            }

            if (isIsocratic)
            {
                Log.WriteLine(Id, "Isocratic - FlowRequested = " + FlowRequested.ToString());
                UpdateEluents();
                FlowNominal = FlowRequested;
                if (IsSimulated)
                {
                    Flow = FlowRequested;
                }
                return;
            }

            // In a real driver we would need to build some kind of time table and send it to the hardware.
            // In this example we create a list instead and write it to the audit trail.
            // Note that the property is not updated, as this would be done asynchronously during the run.
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Table of timed events:");
            foreach (IProgramStep step in args.RunContext.ProgramSteps)
            {
                IRampStep rampStep = step as IRampStep;
                if (rampStep == null)
                {
                    continue;
                }

                m_IsRamped = true;
                RetentionTime        duration   = rampStep.Duration;
                IDoublePropertyValue startValue = rampStep.StartValue as IDoublePropertyValue;
                IDoublePropertyValue endValue   = rampStep.EndValue as IDoublePropertyValue;

                const string sprt = "\t";
                sb.Append("Retention " + step.Retention.Minutes.ToString("F3") + sprt);
                sb.Append(startValue.Property.Owner.Name + "." + startValue.Property.Name + " = " + startValue.Value.Value.ToString("F3") + ", ");
                sb.Append(endValue.Property.Owner.Name + "." + endValue.Property.Name + " = " + endValue.Value.Value.ToString("F3") + ", ");
                sb.AppendLine("Duration = " + duration.Minutes.ToString("F3"));
            }

            if (m_IsRamped)
            {
                string text = "Table of timed events:" + Environment.NewLine + sb.ToString();
                Log.WriteLine(Id, "Gradient - " + text);

                // SendTimeTableCommand
                if (args.RunContext.IsManual)
                {
                    // SendStartCommand();
                }
            }
            else
            {
                string text = "Table of timed events: None";
                Log.WriteLine(Id, "Gradient - " + text);
            }
        }