Example #1
0
            /// <summary>Returns the value before the script assignment</summary>
            public Nullable <double> GetPreconditionValue(IDoubleProperty property)
            {
                IPropertyValue       propertyValue       = GetPreconditionPropertyValue(property);
                IDoublePropertyValue doublePropertyValue = propertyValue as IDoublePropertyValue;
                Nullable <double>    result = doublePropertyValue.Value;

                return(result);
            }
Example #2
0
            private Nullable <double> GetScriptOrPreconditionValue(IDoubleProperty property, bool ifNotFoundReturnPreconditionValue)
            {
                Nullable <double> result        = null;
                IPropertyValue    propertyValue = GetPropertyValue(property);

                if (propertyValue == null)
                {
                    if (ifNotFoundReturnPreconditionValue)
                    {
                        result = GetPreconditionValue(property);
                    }
                    return(result);
                }
                IDoublePropertyValue doublePropertyValue = propertyValue as IDoublePropertyValue;

                result = doublePropertyValue.Value;
                return(result);
            }
Example #3
0
        private void OnDevicePreflightEnd(PreflightEventArgs args)
        {
            Log.WriteLine(Id, "ProgramTime.Minutes = " + args.RunContext.ProgramTime.Minutes.ToString());

            // Check everything
            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;
            }
        }
Example #4
0
        private void OnTransferPreflightToRun(PreflightEventArgs args)
        {
            // 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)
            {
                IRampStep rampStep = step as IRampStep;

                if (rampStep != null)
                {
                    RetentionTime        duration   = rampStep.Duration;
                    IDoublePropertyValue startValue = rampStep.StartValue as IDoublePropertyValue;
                    IDoublePropertyValue endValue   = rampStep.EndValue as IDoublePropertyValue;

                    sb.Append("Retention ");
                    sb.Append(step.Retention.Minutes.ToString("F3"));
                    sb.Append(": ");
                    sb.Append(startValue.Property.Owner.Name);
                    sb.Append(".");
                    sb.Append(startValue.Property.Name);
                    sb.Append("=");
                    sb.Append(startValue.Value.Value.ToString("F3"));
                    sb.Append(", ");
                    sb.Append(endValue.Property.Owner.Name);
                    sb.Append(".");
                    sb.Append(endValue.Property.Name);
                    sb.Append("=");
                    sb.Append(endValue.Value.Value.ToString("F3"));
                    sb.Append(", Duration=");
                    sb.Append(duration.Minutes.ToString("F3"));
                    sb.Append("\n");
                }
            }

            m_Device.AuditMessage(AuditLevel.Message, sb.ToString());
        }
Example #5
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);
            }
        }