public MeasurementToolInstance(MeasurementToolDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.ReferencePoint1 == null)
            {
                throw new ArgumentException(Name + " doesn't have ReferencePoint1 defined.");
            }
            mReferencePoint1 = testExecution.ReferencePointRegistry.GetObject(theDefinition.ReferencePoint1.Name);

            if (theDefinition.ReferencePoint2 == null)
            {
                throw new ArgumentException(Name + " doesn't have ReferencePoint2 defined.");
            }
            mReferencePoint2 = testExecution.ReferencePointRegistry.GetObject(theDefinition.ReferencePoint2.Name);

            if (theDefinition.PixelsPerUnit == null)
            {
                throw new ArgumentException(Name + " doesn't have PixelsPerUnit defined.");
            }
            mPixelsPerUnit = testExecution.DataValueRegistry.GetObject(theDefinition.PixelsPerUnit.Name);

            if (theDefinition.Ensure1Before2 != null)
            {
                mEnsure1Before2 = testExecution.DataValueRegistry.GetObject(theDefinition.Ensure1Before2.Name);
            }

            mDistance = new GeneratedValueInstance(theDefinition.Distance, testExecution);
            if (theDefinition.Distance_pixels != null)
            {
                mDistance_pixels = new GeneratedValueInstance(theDefinition.Distance_pixels, testExecution);
            }
        }
示例#2
0
        public ImageCropInstance(ImageCropDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.LeftEdge == null)
            {
                throw new ArgumentException(theDefinition.Name + " doesn't have a value assigned to LeftEdge");
            }
            mLeftEdge = testExecution.DataValueRegistry.GetObject(theDefinition.LeftEdge.Name);

            if (theDefinition.Width == null)
            {
                throw new ArgumentException(theDefinition.Name + " doesn't have a value assigned to Width");
            }
            mWidth = testExecution.DataValueRegistry.GetObject(theDefinition.Width.Name);

            if (theDefinition.TopEdge == null)
            {
                throw new ArgumentException(theDefinition.Name + " doesn't have a value assigned to TopEdge");
            }
            mTopEdge = testExecution.DataValueRegistry.GetObject(theDefinition.TopEdge.Name);

            if (theDefinition.Height == null)
            {
                throw new ArgumentException(theDefinition.Name + " doesn't have a value assigned to Height");
            }
            mHeight = testExecution.DataValueRegistry.GetObject(theDefinition.Height.Name);

            if (theDefinition.SourceImage == null)
            {
                throw new ArgumentException(theDefinition.Name + " doesn't have a value assigned to SourceImage");
            }
            mSourceImage = testExecution.ImageRegistry.GetObject(theDefinition.SourceImage.Name);

            mCroppedImage = new GeneratedImageInstance(theDefinition.ResultantImage, testExecution);
        }
示例#3
0
 public ImageTestInstance(ImageTestDefinition theDefinition, TestExecution testExecution)
     : base(theDefinition, testExecution)
 {
     //
     // TODO: Add constructor logic here
     //
 }
        public FindBrightestSpotInstance(FindBrightestSpotDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.SourceImage == null)
            {
                throw new ArgumentException(Name + " doesn't have SourceImage defined.");
            }
            mSourceImage = testExecution.ImageRegistry.GetObject(theDefinition.SourceImage.Name);

            if (theDefinition.ROI == null)
            {
                throw new ArgumentException(Name + " doesn't have ROI defined.");
            }
            mROI = testExecution.ROIRegistry.GetObject(theDefinition.ROI.Name);

            if (theDefinition.BrightnessThreshold == null)
            {
                throw new ArgumentException(Name + " doesn't have BrightnessThreshold defined.");
            }
            mBrightnessThreshold = testExecution.DataValueRegistry.GetObject(theDefinition.BrightnessThreshold.Name);

            mBrightSpot_X = new GeneratedValueInstance(theDefinition.BrightSpot_X, testExecution);
            mBrightSpot_Y = new GeneratedValueInstance(theDefinition.BrightSpot_Y, testExecution);

            mAutoSave = theDefinition.AutoSave;
        }
示例#5
0
 public void CloseFileFromWriting(TestExecution testExecution)
 {
     // WARNING: testExecution may be null
     if (writer != null)
     {
         try
         {
             writer.Close();
         }
         catch (Exception e)
         {
             string msg = "Unable to close data log file " + mFile + ".  Error='" + e.Message + "'";
             if (testExecution != null)
             {
                 testExecution.LogErrorWithTimeFromTrigger(msg);
             }
             TestSequence().LogError(msg);
             return;
         }
         try
         {
             writer.Dispose(); // can this throw exceptions?  if so, it isn't fatal to the test execution, so we catch it here
         }
         catch (Exception e)
         {
             string msg = "Unable to dispose data log file " + mFile + ".  Error='" + e.Message + "'";
             if (testExecution != null)
             {
                 testExecution.LogErrorWithTimeFromTrigger(msg);
             }
             TestSequence().LogError(msg);
         }
         writer = null;
     }
 }
示例#6
0
        public CircleDecorationInstance(CircleDecorationDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.CenterX() == null)
            {
                throw new ArgumentException("CircleDecoration " + Name + " doesn't have anything assigned to CenterX");
            }
            mCenterX = testExecution.DataValueRegistry.GetObject(theDefinition.CenterX().Name);

            if (theDefinition.CenterY() == null)
            {
                throw new ArgumentException("CircleDecoration " + Name + " doesn't have anything assigned to CenterY");
            }
            mCenterY = testExecution.DataValueRegistry.GetObject(theDefinition.CenterY().Name);

            if (theDefinition.Radius() == null)
            {
                throw new ArgumentException("CircleDecoration " + Name + " doesn't have anything assigned to Radius");
            }
            mRadius = testExecution.DataValueRegistry.GetObject(theDefinition.Radius().Name);

            mColor = theDefinition.Color;

            testExecution.CircleDecorationRegistry.RegisterObject(this);
        }
示例#7
0
        public ColorMatchCountInstance(ColorMatchCountDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.SourceImage == null)
            {
                throw new ArgumentException(Name + " doesn't have SourceImage defined.");
            }
            mSourceImage = testExecution.ImageRegistry.GetObject(theDefinition.SourceImage.Name);

            if (theDefinition.ColorMatchDefinition == null)
            {
                throw new ArgumentException(Name + " doesn't have ColorMatchDefinition defined.");
            }
            mColorMatcher = testExecution.GetColorMatcher(theDefinition.ColorMatchDefinition.Name);

            if (theDefinition.ROI == null)
            {
                throw new ArgumentException(Name + " doesn't have ROI defined.");
            }
            mROI = testExecution.ROIRegistry.GetObject(theDefinition.ROI.Name);

            mResult = new GeneratedValueInstance(theDefinition.Result, testExecution);

            mCreateMarkedImage = theDefinition.CreateMarkedImage;
            mMarkColor         = theDefinition.MarkColor;
            if (theDefinition.ImageToMark != null)
            {
                mImageToMark = testExecution.ImageRegistry.GetObject(theDefinition.ImageToMark.Name);
            }
        }
示例#8
0
 public override void CreateInstance(TestExecution theExecution)
 {
     if (mCommonValueDefinition.ReadStyle == CommonValueDefinition.DataReadStyle.AtTrigger)
     {
         new AtTriggerValueGetterToolInstance(this, theExecution);
     }
 }
示例#9
0
        public CommonValueInstance(CommonValueDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.GlobalValue == null)
            {
                throw new ArgumentException(Name + " doesn't have GlobalValue defined.");
            }

            switch (theDefinition.ReadStyle)
            {
            case CommonValueDefinition.DataReadStyle.AtTrigger:
                if (theDefinition.mHelperTool == null)
                {
                    throw new ArgumentException("askjdkljsdhf");
                }
                theDefinition.mHelperTool.CurrentInstance.ValueGetter = new AtTriggerValueGetter(theDefinition.GlobalValue);
                mValueGetter = theDefinition.mHelperTool.CurrentInstance.ValueGetter;
                break;

            case CommonValueDefinition.DataReadStyle.Live:
                mValueGetter = new LiveValueGetter(theDefinition.GlobalValue);
                break;

            default:
                throw new ArgumentException("CommonValue '" + Name + "' has an unsupported ReadStyle. ReadStyle=" + theDefinition.ReadStyle);
                break;
            }
        }
示例#10
0
 public PointDecorationInstance(PointDecorationDefinition theDefinition, TestExecution testExecution)
     : base(theDefinition, testExecution)
 {
     mX     = testExecution.DataValueRegistry.GetObject(theDefinition.GetX().Name);
     mY     = testExecution.DataValueRegistry.GetObject(theDefinition.GetY().Name);
     mColor = theDefinition.Color();
 }
示例#11
0
        public LineDecorationInstance(LineDecorationDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            mColor = theDefinition.Color;

            testExecution.LineDecorationRegistry.RegisterObject(this);
            testExecution.ReferencePointRegistry.RegisterObject(this);
        }
示例#12
0
 public OrColorMatchInstance(OrColorMatchDefinition theDefinition, TestExecution testExecution)
     : base(theDefinition, testExecution)
 {
     foreach (ColorMatchDefinition def in theDefinition.SubMatchers)
     {
         mReferencedColorMatchers.Add(testExecution.GetColorMatcher(def.Name));
     }
 }
示例#13
0
 void mParentForm_TestSelectionChange(TestExecution testExecution)
 {
     if (propertyGrid.SelectedObject == null)
     {
         return;
     }
     ((FavoriteValues)propertyGrid.SelectedObject).UpdateTestExecution(testExecution);
     RefreshValues(); //needed?
 }
示例#14
0
 public WriteValueToTNDInstance(WriteValueToTNDDefinition theDefinition, TestExecution testExecution)
     : base(theDefinition, testExecution)
 {
     if (theDefinition.ValueToWrite == null)
     {
         throw new ArgumentException("'" + theDefinition.Name + "' doesn't have a value assigned to ValueToWrite");
     }
     mValueToWrite = TestExecution().DataValueRegistry.GetObject(theDefinition.ValueToWrite.Name);
 }
示例#15
0
 public void CleanupActiveTestExecution()
 {
     mTestExecutionTimeoutTimer.Enabled = false;
     if (mActiveExecution != null)
     {
         mActiveExecution.PerformPostExecutionCleanup();
         mActiveExecution = null;
     }
 }
 public CalculationToolInstance(CalculationToolDefinition theDefinition, TestExecution testExecution)
     : base(theDefinition, testExecution)
 {
     if (theDefinition.RootOperation == null)
     {
         throw new ArgumentException(theDefinition.Name + " does not seem to have a calculation defined.");
     }
     mRootOperation  = testExecution.GetMathOperation(theDefinition.RootOperation.Name);
     mCalculationDef = theDefinition.Calculation;
 }
示例#17
0
        public ToolInstance(ToolDefinition theDefinition, TestExecution theExecution)
            : base(theDefinition, theExecution)
        {
            if (theDefinition.Prerequisite != null)
            {
                mPrerequisite = theExecution.DataValueRegistry.GetObject(theDefinition.Prerequisite.Name);
            }

            theExecution.RegisterWorker(this);
        }
示例#18
0
 public ReadValueFromTNDInstance(ReadValueFromTNDDefinition theDefinition, TestExecution testExecution)
     : base(theDefinition, testExecution)
 {
     mDataValueInstance = new GeneratedValueInstance(theDefinition.DataValue, testExecution);
     if (mDataValueInstance.Type == DataType.NotDefined)
     {
         // we shouldn't get here since this should be trapped in the GeneratedValueInstance ctor
         throw new ArgumentException("Data Type for '" + mDataValueInstance.Name + "' is not defined. Can't copy value from TND.");
     }
 }
示例#19
0
        public AddNumbersInstance(AddNumbersDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            //
            // TODO: Add constructor logic here
            //

            mValue1 = testExecution.DataValueRegistry.GetObject(theDefinition.Value1.Name);
            mValue2 = testExecution.DataValueRegistry.GetObject(theDefinition.Value2.Name);
            mResult = new GeneratedValueInstance(theDefinition.Result, testExecution);
        }
示例#20
0
        public CopyValueInstance(CopyValueDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.SourceValue == null)
            {
                throw new ArgumentException(Name + " doesn't have SourceValue defined.");
            }
            mSourceValue = testExecution.DataValueRegistry.GetObject(theDefinition.SourceValue.Name);

            mDestinationValue = new GeneratedValueInstance(theDefinition.DestinationValue, testExecution);
        }
示例#21
0
        public FindTransitionInstance(FindTransitionDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.SourceImage == null)
            {
                throw new ArgumentException(Name + " doesn't have SourceImage defined.");
            }
            mSourceImage = testExecution.ImageRegistry.GetObject(theDefinition.SourceImage.Name);

            if (theDefinition.SearchArea == null)
            {
                throw new ArgumentException(Name + " doesn't have SearchArea defined.");
            }
            ROIInstance theROI = testExecution.ROIRegistry.GetObject(theDefinition.SearchArea.Name);

            if (!(theROI is IRectangleROIInstance))
            {
                throw new ArgumentException(Name + " requires a rectangle ROI for its SearchArea. " + theROI.Name + " isn't a rectangle.");
            }
            mSearchArea = (IRectangleROIInstance)theROI;

            if (theDefinition.SearchDirection == Direction.NotDefined)
            {
                throw new ArgumentException(Name + " doesn't have SearchDirection defined.");
            }
            mSearchDirection = theDefinition.SearchDirection;

            //if (theDefinition.TransitionDetectionMode == FindTransitionDefinition.TransitionDetectionModes.NotDefined) throw new ArgumentException(Name + " doesn't have TransitionDetectionMode defined.");
            //mTransitionDetectionMode = theDefinition.TransitionDetectionMode;

            mTransitionTypeSelectionFilter = theDefinition.TransitionTypeSelectionFilter;

            if (theDefinition.TransitionThreshold_Min == null)
            {
                throw new ArgumentException(Name + " doesn't have SurfaceNoiseThreshold_Min defined.");
            }
            mSurfaceNoiseThreshold_Min = testExecution.DataValueRegistry.GetObject(theDefinition.TransitionThreshold_Min.Name);

            //if (theDefinition.SurfaceNoiseThreshold_PercentOfSharpestTransition == null) throw new ArgumentException(Name + " doesn't have SurfaceNoiseThreshold_PercentOfSharpestTransition defined.");
            //mSurfaceNoiseThreshold_PercentOfSharpestTransition = testExecution.DataValueRegistry.GetObject(theDefinition.SurfaceNoiseThreshold_PercentOfSharpestTransition.Name);

            mTransitionMarker = new ValueBasedLineDecorationInstance(theDefinition.TransitionMarker, testExecution);

            mTransitionLocation = new GeneratedValueInstance(theDefinition.TransitionLocation, testExecution);

            if (theDefinition.TransitionScore != null)
            {
                mTransitionScore = new GeneratedValueInstance(theDefinition.TransitionScore, testExecution);
            }

            mAutoSave      = theDefinition.AutoSave;
            mVerboseOutput = theDefinition.VerboseOutput;
        }
        public FindColorOnLineInstance(FindColorOnLineDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.ColorMatchDefinition == null)
            {
                throw new ArgumentException(Name + " doesn't have ColorMatchDefinition defined.");
            }
            mColorMatcher = testExecution.GetColorMatcher(theDefinition.ColorMatchDefinition.Name);

            if (theDefinition.SourceImage == null)
            {
                throw new ArgumentException(Name + " doesn't have SourceImage defined.");
            }
            mSourceImage = testExecution.ImageRegistry.GetObject(theDefinition.SourceImage.Name);

            if (theDefinition.StartX == null)
            {
                throw new ArgumentException(Name + " doesn't have StartX defined.");
            }
            mStartX = testExecution.DataValueRegistry.GetObject(theDefinition.StartX.Name);

            if (theDefinition.StartY == null)
            {
                throw new ArgumentException(Name + " doesn't have StartY defined.");
            }
            mStartY = testExecution.DataValueRegistry.GetObject(theDefinition.StartY.Name);

            if (theDefinition.SlopeRise == null)
            {
                throw new ArgumentException(Name + " doesn't have SlopeRise defined.");
            }
            mSlopeRise = testExecution.DataValueRegistry.GetObject(theDefinition.SlopeRise.Name);

            if (theDefinition.SlopeRun == null)
            {
                throw new ArgumentException(Name + " doesn't have SlopeRun defined.");
            }
            mSlopeRun = testExecution.DataValueRegistry.GetObject(theDefinition.SlopeRun.Name);

            if (theDefinition.RequiredConsecutivePixels == null)
            {
                throw new ArgumentException(Name + " doesn't have RequiredConsecutivePixels defined.");
            }
            mRequiredConsecutivePixels = testExecution.DataValueRegistry.GetObject(theDefinition.RequiredConsecutivePixels.Name);

            mResultX = new GeneratedValueInstance(theDefinition.ResultX, testExecution);
            mResultY = new GeneratedValueInstance(theDefinition.ResultY, testExecution);

            mSearchEndX = new GeneratedValueInstance(theDefinition.SearchEndX, testExecution);
            mSearchEndY = new GeneratedValueInstance(theDefinition.SearchEndY, testExecution);

            mSearchPath = new ObjectBasedLineDecorationInstance(theDefinition.SearchPath, testExecution);
        }
        public ImageDuplicatorInstance(ImageDuplicatorDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.SourceImage == null)
            {
                throw new ArgumentException("'" + theDefinition.Name + "' doesn't have a value assigned to SourceImage");
            }
            mSourceImage = testExecution.ImageRegistry.GetObject(theDefinition.SourceImage.Name);

            mEnabled = theDefinition.Enabled;

            mDuplicateImage = new GeneratedImageInstance(theDefinition.ResultantImage, testExecution);
        }
 public ButtonTriggerInstance(ButtonTriggerDefinition theDefinition, TestExecution testExecution) : base(theDefinition, testExecution)
 {
     mButtonTriggerDef = theDefinition;
     // iterate through test collections, get button, register as listener
     foreach (TestExecutionCollection collection in theDefinition.TestSequence().mTestCollections)
     {
         OperationForm opForm = collection.OperationForm;
         if (opForm != null)
         {
             RegisterAsListenerOnControl(opForm);
         }
     }
 }
示例#25
0
        public FindEdgeOriginalInstance(FindEdgeOriginalDefinition theDefinition, TestExecution testExecution)
            : base(theDefinition, testExecution)
        {
            if (theDefinition.SourceImage == null)
            {
                throw new ArgumentException(Name + " doesn't have SourceImage defined.");
            }
            mSourceImage = testExecution.ImageRegistry.GetObject(theDefinition.SourceImage.Name);

            if (theDefinition.SearchArea == null)
            {
                throw new ArgumentException(Name + " doesn't have SearchArea defined.");
            }
            ROIInstance theROI = testExecution.ROIRegistry.GetObject(theDefinition.SearchArea.Name);

            if (!(theROI is IRectangleROIInstance))
            {
                throw new ArgumentException(Name + " requires a rectangle ROI for its SearchArea. " + theROI.Name + " isn't a rectangle.");
            }
            mSearchArea = (IRectangleROIInstance)theROI;

            if (theDefinition.SearchDirection == Direction.NotDefined)
            {
                throw new ArgumentException(Name + " doesn't have SearchDirection defined.");
            }
            mSearchDirection = theDefinition.SearchDirection;

            if (theDefinition.EdgeDetectionMode == FindEdgeOriginalDefinition.EdgeDetectionModes.NotDefined)
            {
                throw new ArgumentException(Name + " doesn't have EdgeDetectionMode defined.");
            }
            mEdgeDetectionMode = theDefinition.EdgeDetectionMode;

            if (theDefinition.SurfaceNoiseThreshold == null)
            {
                throw new ArgumentException(Name + " doesn't have SurfaceNoiseThreshold defined.");
            }
            mSurfaceNoiseThreshold = testExecution.DataValueRegistry.GetObject(theDefinition.SurfaceNoiseThreshold.Name);

            if (theDefinition.MinSurfaceSize == null)
            {
                throw new ArgumentException(Name + " doesn't have MinSurfaceSize defined.");
            }
            mMinSurfaceSize = testExecution.DataValueRegistry.GetObject(theDefinition.MinSurfaceSize.Name);

            mEdgeMarker = new ValueBasedLineDecorationInstance(theDefinition.EdgeMarker, testExecution);

            mEdgeLocation = new GeneratedValueInstance(theDefinition.EdgeLocation, testExecution);

            mAutoSave = theDefinition.AutoSave;
        }
示例#26
0
 public ROIWithHoleInstance(ROIWithHoleDefinition theDefinition, TestExecution theExecution)
     : base(theDefinition, theExecution)
 {
     if (theDefinition.MainROI == null)
     {
         throw new ArgumentException("ROI '" + theDefinition.Name + "' doesn't have a value assigned to MainROI");
     }
     if (theDefinition.HoleROI == null)
     {
         throw new ArgumentException("ROI '" + theDefinition.Name + "' doesn't have a value assigned to HoleROI");
     }
     mMainROI = theExecution.ROIRegistry.GetObject(theDefinition.MainROI.Name);
     mHoleROI = theExecution.ROIRegistry.GetObject(theDefinition.HoleROI.Name);
 }
示例#27
0
        public ROIInstance(ROIDefinition theDefinition, TestExecution theExecution)
            : base(theDefinition, theExecution)
        {
            if (theDefinition.ReferencePoint_X != null)
            {
                mReferencePoint_X = theExecution.ReferencePointRegistry.GetObject(theDefinition.ReferencePoint_X.Name);
            }
            if (theDefinition.ReferencePoint_Y != null)
            {
                mReferencePoint_Y = theExecution.ReferencePointRegistry.GetObject(theDefinition.ReferencePoint_Y.Name);
            }

            theExecution.ROIRegistry.RegisterObject(this);
        }
示例#28
0
 public JoinedROIInstance(JoinedROIDefinition theDefinition, TestExecution theExecution)
     : base(theDefinition, theExecution)
 {
     if (theDefinition.FirstROI == null)
     {
         throw new ArgumentException("ROI '" + theDefinition.Name + "' doesn't have a value assigned to FirstROI");
     }
     if (theDefinition.SecondROI == null)
     {
         throw new ArgumentException("ROI '" + theDefinition.Name + "' doesn't have a value assigned to SecondROI");
     }
     mFirstROI  = theExecution.ROIRegistry.GetObject(theDefinition.FirstROI.Name);
     mSecondROI = theExecution.ROIRegistry.GetObject(theDefinition.SecondROI.Name);
 }
示例#29
0
        public void OpenFileForWriting(TestExecution testExecution)
        {
            // WARNING: testExecution may be null
            try
            {
                if (writer != null)
                {
                    CloseFileFromWriting(testExecution);
                }
            }
            catch (Exception e)
            {
                string msg = "Unable to successfully close the data log file before re-opening.  Error='" + e.Message + "'";
                if (testExecution != null)
                {
                    testExecution.LogErrorWithTimeFromTrigger(msg);
                }
                TestSequence().LogError(msg);
            }

            string filePath = FileHelper.ExpandPath(this, mFile);
            string fileName = Path.GetFileName(filePath);

            filePath = Path.GetDirectoryName(filePath);
            if (!Directory.Exists(filePath))
            {
                try
                {
                    Directory.CreateDirectory(filePath);
                }
                catch (Exception e)
                {
                    throw new ArgumentException("Unable to open data log file '" + filePath + "'. Reason=Unable to create path.  Low-level message=" + e.Message);
                }
            }
            try
            {
                writer = new StreamWriter(filePath + "\\" + fileName, true); // true=append
            }
            catch (Exception e)
            {
                string msg = "Unable to open the data log file " + mFile + ".  Error='" + e.Message + "'";
                if (testExecution != null)
                {
                    testExecution.LogErrorWithTimeFromTrigger(msg);
                }
                TestSequence().LogError(msg);
            }
        }
示例#30
0
        public void AddLine(TestExecution testExecution)
        {
            DateTime now       = DateTime.Now;
            String   seperator = ", ";
            String   theEntry  = now.ToShortDateString() + seperator + now.ToLongTimeString();

            try
            {
                foreach (DataValueDefinition value in mValuesToLog)
                {
                    theEntry += seperator + testExecution.DataValueRegistry.GetObject(value.Name).Value;
                }
            }
            catch (Exception e)
            {
                string msg = "Unable to build data log entry for " + mFile + ".  Error='" + e.Message + "'";
                testExecution.LogErrorWithTimeFromTrigger(msg);
                TestSequence().LogError(msg);
            }

            testExecution.LogMessageWithTimeFromTrigger(Name + " is logging '" + theEntry + "'");

            if (writer == null)
            {
                OpenFileForWriting(testExecution);
            }

            if (writer != null)
            {
                try
                {
                    writer.WriteLine(theEntry);
                }
                catch (Exception e)
                {
                    string msg = "Unable to write entry to data log file " + mFile + ".  Error='" + e.Message + "'";
                    testExecution.LogErrorWithTimeFromTrigger(msg);
                    TestSequence().LogError(msg);
                }
                if (mFlushAfterEachLine)
                {
                    writer.Flush();
                }
                if (mCloseAfterEachLine)
                {
                    CloseFileFromWriting(testExecution);
                }
            }
        }