Exemplo n.º 1
0
        TestPoint[] TestSetShip(int shipType, int orentation, int x, int y)
        {
            if (TestCanSetShip(x, y))
            {
                TestPoint[] testPoint = new TestPoint[shipType];
                switch (orentation)
                {
                case (int)Orentation.Vertical:
                    testPoint = TestSetShipDir(shipType, 1, 0, x, y);
                    if (testPoint == null)
                    {
                        testPoint = TestSetShipDir(shipType, -1, 0, x, y);
                    }
                    break;

                case (int)Orentation.Horizontal:
                    testPoint = TestSetShipDir(shipType, 0, 1, x, y);
                    if (testPoint == null)
                    {
                        testPoint = TestSetShipDir(shipType, 0, -1, x, y);
                    }
                    break;
                }
                return(testPoint);
            }
            return(null);
        }
Exemplo n.º 2
0
        private void dataGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            var dataList = this.dataGridView.DataSource as List <TestPoint>;

            //
            if (dataList == null)
            {
                return;
            }
            TestPoint.FindMaxErrorData(dataList);
            if (e.RowIndex < this.dataGridView.Rows.Count)
            {
                DataGridViewRow dgrSingle = this.dataGridView.Rows[e.RowIndex];
                try
                {
                    var testPoint = dataList[e.RowIndex];
                    if (testPoint.LineError > _upError || testPoint.LineError < -1 * _downError)
                    {
                        dgrSingle.DefaultCellStyle.ForeColor = Color.Red;
                    }

                    //如果误差最大的话,就标记为蓝色
                    //if (testPoint.IsMaxError == true)
                    //{
                    //    dgrSingle.DefaultCellStyle.ForeColor = Color.Blue;
                    //}
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
 private string ToJson(ParseSerializer ser, TestPoint target)
 {
     var sb = new StringBuilder();
     ser.Serialize(target, sb);
     sb = sb.Replace("\\u0027", "'");
     return sb.ToString();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Create struct for failed test
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="TestPlanId"></param>
        /// <param name="TestSuiteId"></param>
        /// <param name="TestCaseId"></param>
        /// <param name="TestRunId"></param>
        /// <returns></returns>
        static TestCaseResult FailedTest(string TeamProjectName, int TestPlanId, int TestSuiteId, string TestCaseId, int TestRunId)
        {
            TestPoint testPoint = TestManagementClient.GetPointsAsync(TeamProjectName, TestPlanId, TestSuiteId, testCaseId: TestCaseId).Result.FirstOrDefault();

            TestCaseResult testCaseResult = new TestCaseResult();

            testCaseResult.Outcome       = Enum.GetName(typeof(TestOutcome), TestOutcome.Failed);
            testCaseResult.TestPoint     = new Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference(testPoint.Id.ToString(), url: testPoint.Url);
            testCaseResult.CompletedDate = DateTime.Now;
            testCaseResult.ErrorMessage  = "Test Case " + TestCaseId + " failed";
            testCaseResult.State         = Enum.GetName(typeof(TestRunState), TestRunState.Completed);
            testCaseResult.StackTrace    = "Add StackTrace here";

            Dictionary <string, object> bugFields = new Dictionary <string, object>();

            bugFields.Add("Title", "Bug from console test - " + TestCaseId);

            //create new bug
            WorkItem bug = CreateWorkItem(TeamProjectName, "Bug", bugFields);

            var bugs = new List <Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference>();

            bugs.Add(new Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference(bug.Id.ToString(), url: bug.Url));

            testCaseResult.AssociatedBugs = bugs;

            return(testCaseResult);
        }
Exemplo n.º 5
0
 private void ExportData(List <TestPoint> list)
 {
     this.Invoke(new Action(() =>
     {
         //导出数据
         ExcelTool.TableToExcel(TestPoint.ConvertToDataTable(list), list, GetFileName(), GetBitmap());
     }));
 }
Exemplo n.º 6
0
        public int SetTestPointState(TestPoint testPoint, TestPointState state)
        {
            int retCode = CI2cControl.SendI2cCommand(testPoint.ToString() + "_" + state);

            CheckReturn(retCode);

            return(retCode);
        }
    static void Main(string[] args)
    {
        var list  = new TestPointLayer();
        var test1 = new TestPoint(list);
        var test2 = new TestPoint(list);

        Debug.WriteLine(list.Tests.Count);
        // 2
    }
Exemplo n.º 8
0
        /// <summary>
        /// 对采集的数据进行分析处理
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="number"></param>
        /// <param name="angleOne"></param>
        /// <param name="angleTwo"></param>
        /// <param name="offSetLine"></param>
        private void AnalyzeData(Chart chart, int number, decimal angleOne, decimal angleTwo, decimal offSetLine)
        {
            //读取到测试的结果
            var vList = GetTestDataList();
            var list  = TestPoint.GetTestPointList(vList, angleOne, 1 * angleTwo, offSetLine, _uMax, _uMin, _upError, _downError);

            this._dataSource = list;
            //查找误差最大的数据
            TestPoint.FindMaxErrorData(list);
        }
        public void Insert_EmptyList()
        {
            var points = new List <TestPoint>();

            var newPoint = new TestPoint(2, 1);

            points.Insert(newPoint);

            Assert.AreSame(newPoint, points[0]);
        }
Exemplo n.º 10
0
        Button MenuButton(TestPoint test)
        {
            var button = new Button {
                Text = test.ToString(), AutomationId = test.AutomationId
            };

            button.Clicked += (sender, args) => PushAsync(CreateTestPage(test));

            return(button);
        }
        TestOutcome HandleTestPoint(TestPoint point, Stream stream, ushort channel, List fields)
        {
            TestFunc func;

            if (this.testPoints.TryGetValue(point, out func))
            {
                return(func(stream, channel, fields));
            }

            return(TestOutcome.Continue);
        }
Exemplo n.º 12
0
        //public TestPointTreeModel(string name, string sn, Guid id)
        //    : base(name)
        //{
        //    TestPointId = id;
        //    IsExpanded = false;
        //    MSSN = new BindableValue<string>(sn);
        //    InitializeLocation();
        //}

        //public TestPointTreeModel(string name, string sn)
        //    : this(name, sn, Guid.NewGuid())
        //{

        //}

        public TestPointTreeModel(TestPoint tp)
            : base(tp.Name)
        {
            TestPoint  = tp;
            IsExpanded = false;
            MSSN       = new BindableValue <string>(TestPoint.MSSN);
            if (!string.IsNullOrEmpty(TestPoint.IP) && !string.IsNullOrEmpty(TestPoint.CardNum) && !string.IsNullOrEmpty(TestPoint.ChannelNum))
            {
                ChannelId = ChannelIdentity.Create(TestPoint.IP, TestPoint.CardNum, TestPoint.ChannelNum).Value;
            }
            InitializeLocation();
        }
        public void Insert_EndOfList()
        {
            var points = new List <TestPoint>
            {
                new TestPoint(1, 1),
            };

            var newPoint = new TestPoint(2, 1);

            points.Insert(newPoint);

            Assert.AreSame(newPoint, points[1]);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Create struct for passed test
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="TestPlanId"></param>
        /// <param name="StaticSuitePath"></param>
        /// <param name="TestCaseId"></param>
        /// <returns></returns>
        static TestCaseResult PassedTest(string TeamProjectName, int TestPlanId, string StaticSuitePath, int TestCaseId)
        {
            int       testSuiteId = GetSuiteId(TeamProjectName, TestPlanId, StaticSuitePath);
            TestPoint testPoint   = TestManagementClient.GetPointsAsync(TeamProjectName, TestPlanId, testSuiteId, testCaseId: TestCaseId.ToString()).Result.FirstOrDefault();

            TestCaseResult testCaseResult = new TestCaseResult();

            testCaseResult.Outcome       = Enum.GetName(typeof(TestOutcome), TestOutcome.Passed);
            testCaseResult.TestPoint     = new Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference(testPoint.Id.ToString(), url: testPoint.Url);
            testCaseResult.CompletedDate = DateTime.Now;
            testCaseResult.State         = Enum.GetName(typeof(TestRunState), TestRunState.Completed);

            return(testCaseResult);
        }
        public void Insert_IntoMiddle()
        {
            var points = new List <TestPoint>
            {
                new TestPoint(-1, -1),
                new TestPoint(-1, 1),
                new TestPoint(3, 3),
                new TestPoint(4, 1),
                new TestPoint(4, 3),
            };

            var newPoint = new TestPoint(2, 25);

            points.Insert(newPoint);

            Assert.AreSame(newPoint, points[2]);
        }
Exemplo n.º 16
0
        public void when_we_serialize_a_TestPoint()
        {
            const string runGuid = "1286fca346034ad9a49fb49b06f9999b";
            var now = new DateTime(2013, 12, 14, 10, 9,11, 456, DateTimeKind.Utc);
            var ser = ParseSerializer
                .Serializer()
                .AddSimpleType<TestPointProp>();
            var source = new TestPoint
                             {
                                 id = "1",
                                 index = 2,
                                 prop = new TestPointProp {Value = "3"},
                                 timestamp = now.ToUniversalTime(),
                                 parseDate = now.ToUniversalTime(),
                                 runId = runGuid,
                                location = new GeoPoint {Latitude = 45.50867M, Longitude = -73.553992M},
                                related = new Pointer {className = "Users", objectId = "deaIBwVQd5"}
                             };
            var json = ToJson(ser, source);
            Assert.AreEqual(
                "{\"runId\":\"1286fca346034ad9a49fb49b06f9999b\",\"id\":\"1\",\"prop\":\"3\",\"index\":2,\"timestamp\":\"2013-12-14T10:09:11.456Z\",\"location\":{\"__type\":\"GeoPoint\",\"latitude\":45.50867,\"longitude\":-73.553992},\"related\":{\"__type\":\"Pointer\",\"className\":\"Users\",\"objectId\":\"deaIBwVQd5\"},\"parseDate\":{\"__type\":\"Date\",\"iso\":\"2013-12-14T10:09:11.456Z\"},\"objectId\":null,\"createdAt\":\"0001-01-01T00:00:00.000Z\",\"updatedAt\":\"0001-01-01T00:00:00.000Z\"}",
                json);


            TestPoint target;
            using (var streamReader = new StringReader(json))
            {
                using (var jsonTextReader = new JsonTextReader(streamReader))
                {
                    target = ser.Deserialize<TestPoint>(jsonTextReader);
                    
                }
            }

            Assert.IsNotNull(target);
            Assert.AreEqual("1", target.id);
            Assert.AreEqual(2, target.index);
            Assert.AreEqual("3", target.prop.Value);
            Assert.AreEqual(now, target.timestamp);
            Assert.AreEqual(now, target.parseDate.Value);
            Assert.AreEqual(runGuid, target.runId);
            Assert.AreEqual("deaIBwVQd5", target.related.objectId);
            Assert.AreEqual(45.50867M, target.location.Latitude);
            Assert.AreEqual(-73.553992M, target.location.Longitude);
        }
Exemplo n.º 17
0
 public TestPoint[] TestSetShipDir(int shipType, int XD, int YD, int x, int y)
 {
     TestPoint[] testPoint = new TestPoint[shipType];
     for (int i = 0; i < shipType; i++)
     {
         if (TestCanSetShip(x, y))
         {
             testPoint[i].x = x;
             testPoint[i].y = y;
         }
         else
         {
             return(null);
         }
         x += XD;
         y += YD;
     }
     return(testPoint);
 }
Exemplo n.º 18
0
        public void VerifyInputTransparent(TestPoint test)
        {
            RunningApp.WaitForElement(q => q.Marked(test.AutomationId));
            RunningApp.Tap(test.AutomationId);

            // Determine the location of the button; we have to do this before adding the overlay because
            // otherwise the iOS UI tests won't be able to find it consistently
            var button = RunningApp.WaitForElement(DefaultButtonText);
            var coords = new Tuple <float, float>(button[0].Rect.CenterX, button[0].Rect.CenterY);

            // Add the overlay
            RunningApp.WaitForElement(AddOverlay);
            RunningApp.Tap(AddOverlay);

            // Now tap the screen at the Button's location
            // We can't do RunningApp.Tap(DefaultButtonText) because the UI tests on iOS can't see it
            RunningApp.TapCoordinates(coords.Item1, coords.Item2);

            // Check the results
            RunningApp.WaitForElement(test.ShouldBeTransparent ? Success : Running);
        }
Exemplo n.º 19
0
        private void 相对ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                //查询数据是否存在
                if (this._dataSource.Count == 0)
                {
                    MessageBox.Show("请获取采集数据,再进行操作");
                    return;
                }

                List <TestPoint> dataList = TestPoint.GetRelativePoints(_dataSource);
                //删除数据
                ClearDrawData();
                //加载数据
                RefreshVData(dataList);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 20
0
        private void BeginWork()
        {
            //首先对参数进行基本的校验
            if (!ValidateParameter())
            {
                return;
            }
            //对采集的数据进行分析处理
            AnalyzeData(this.myChart, int.Parse(tbNumber.Text), 0, this._allAngle, decimal.Parse(tbOffset.Text));

            this.Invoke(new Action(() =>
            {
                //获取functionid
                var functionId = AppSettingTool.GetFunctionId();
                if (0 == functionId)
                {
                    //加载线性曲线
                    //计算曲线误差
                    var newDataList = TestPoint.ComputeLineErrorValue(_dataSource, _uMax, _uMin);
                    //删除数据
                    ClearDrawData();
                    //加载数据
                    RefreshLineErrorData(newDataList);
                    //打印报表数据
                    ExportData(_dataSource);
                }
                if (1 == functionId)
                {
                    //加载电压曲线
                    ClearDrawData();
                    //刷新数据
                    RefreshVData(_dataSource);
                    //打印报表
                    ExportData(_dataSource);
                }
                MessageBox.Show("采集完成");
            }));
        }
Exemplo n.º 21
0
        public double GetTestPointVoltage(TestPoint testPoint)
        {
            double dVoltage = 0.0;
            int    count    = 0;
            int    status   = -1;

            status = SetTestPointState(testPoint, TestPointState.CLOSED);
            CheckReturn(status);

            while ((dVoltage < 2) && (count < TRY_READ_TIMES))
            {
                dVoltage += tcc.PwrSupply.ReadDVM1Voltage();
                Thread.Sleep(1000);
                count++;
            }

            dVoltage = dVoltage / count;

            status = SetTestPointState(testPoint, TestPointState.OPEN);
            CheckReturn(status);

            return(dVoltage);
        }
Exemplo n.º 22
0
        ContentPage CreateTestPage(TestPoint test)
        {
            Color  backgroundColor  = test.BackgroundColor ? _transparentColor : _nontransparentColor;
            double opacity          = test.Opacity ? _transparentOpacity : _nonTransparentOpacity;
            bool   inputTransparent = test.InputTransparent;

            var grid = new Grid
            {
                AutomationId      = "testgrid",
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill
            };

            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Star
            });

            var instructions = new Label
            {
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.Center,
                Text = $"Tap the 'Add Overlay' button, then tap the button labeled 'Button'."
                       + (test.ShouldBeTransparent
                                                   ? $" If the label below's text changes to {Success} the test has passed."
                                                   : " If the label below's text remains unchanged, the test has passed.")
            };

            grid.Children.Add(instructions);

            var results = new Label
            {
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.Center,
                Text = Running
            };

            grid.Children.Add(results);
            Grid.SetRow(results, 1);

            var button = new Button
            {
                Text = DefaultButtonText,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center
            };

            button.Clicked += (sender, args) =>
            {
                results.Text = test.ShouldBeTransparent ? Success : Failure;
            };

            var layout = new StackLayout
            {
                AutomationId      = Overlay,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                BackgroundColor   = backgroundColor,
                InputTransparent  = inputTransparent,
                Opacity           = opacity
            };

            // Bump up the elevation to cover FastRenderer buttons
            layout.On <Android>().SetElevation(10f);

            grid.Children.Add(button);
            Grid.SetRow(button, 3);

            var addOverlayButton = new Button()
            {
                Text = AddOverlay
            };

            addOverlayButton.Clicked += (sender, args) =>
            {
                grid.Children.Add(layout);
                Grid.SetRow(layout, 3);
            };

            grid.Children.Add(addOverlayButton);
            Grid.SetRow(addOverlayButton, 2);

            return(new ContentPage {
                Content = grid, Title = test.ToString()
            });
        }
Exemplo n.º 23
0
    TestPoint addStimuli()
    {
        FloatAngle newSti = new FloatAngle(0, 0);

        if (mode == TestMode.LaterGlaucoma)
        {
            float x = UnityEngine.Random.Range(-30.0f, 30.0f);
            float y = UnityEngine.Random.Range(-30.0f, 30.0f);

            if (x < 2f && x > 0f)
            {
                x += 2f;
            }
            if (y < 2f && y > 0f)
            {
                y += 2f;
            }
            if (x > -2f && x < 0f)
            {
                x -= 2f;
            }
            if (y > -2f && y < 0f)
            {
                y -= 2f;
            }
            newSti = new FloatAngle(x, y);
        }
        else if (mode == TestMode.EarlyGlaucoma)
        {
            float x = UnityEngine.Random.Range(-15.0f, 15.0f);
            float y = UnityEngine.Random.Range(-15.0f, 15.0f);
            if (x < 2f && x > 0f)
            {
                x += 2f;
            }
            if (y < 2f && y > 0f)
            {
                y += 2f;
            }
            if (x > -2f && x < 0f)
            {
                x -= 2f;
            }
            if (y > -2f && y < 0f)
            {
                y -= 2f;
            }
            if (x > 5f)
            {
                x += 5f;
            }
            if (y > 5f)
            {
                y += 5f;
            }
            if (x < -5f)
            {
                x -= 5f;
            }
            if (y < -5f)
            {
                y -= 5f;
            }
            newSti = new FloatAngle(x, y);
        }
        List <float> ints = new List <float>();

        ints.Add(startLightInt);
        TestPoint newPoint = new TestPoint(newSti.x, newSti.y, stimuliRadius, ints);

        return(newPoint);
    }
Exemplo n.º 24
0
        static int numTstPnt = 0;                     //for the crossing test

        public static int CrossingsTest(double PntX, double PntY)
        {
            if (TstPnt[0] == null)  // create if not created already
            {
                TstPnt[0] = new TestPoint();
                TstPnt[1] = new TestPoint();
                TstPnt[2] = new TestPoint();
                TstPnt[3] = new TestPoint();
            }
            int    j, yflag0, yflag1, inside_flag, xflag0;
            double ty, tx;// *vtx0, *vtx1 ;
            int    line_flag;
            short  index = 0;

            tx = PntX; //point[X] ;
            ty = PntY; //point[Y] ;
            TestPoint vtx0, vtx1;

            vtx0        = TstPnt[numTstPnt - 1];
            yflag0      = (vtx0.Y >= ty) ? 1 : 0;
            vtx1        = TstPnt[0];
            inside_flag = 0;
            line_flag   = 0;
            for (j = numTstPnt + 1; --j > 0;)
            {
                yflag1 = (vtx1.Y >= ty) ? 1 : 0;
                if (yflag0 != yflag1)
                {
                    xflag0 = (vtx0.X >= tx) ? 1 : 0;
                    if (xflag0 == ((vtx1.X >= tx) ? 1 : 0))
                    {
                        if (xflag0 != 0)
                        {
                            if (inside_flag == 1)
                            {
                                inside_flag = 0;
                            }
                            else
                            {
                                inside_flag = 1;
                            }
                            //inside_flag = !inside_flag;
                        }
                    }
                    else
                    {
                        if ((vtx1.X - (vtx1.Y - ty) *
                             (vtx0.X - vtx1.X) / (vtx0.Y - vtx1.Y)) >= tx)
                        {
                            //inside_flag = !inside_flag ;
                            if (inside_flag == 1)
                            {
                                inside_flag = 0;
                            }
                            else
                            {
                                inside_flag = 1;
                            }
                        }
                    }
                    if (line_flag != 0)
                    {
                        goto Exit;
                    }
                    line_flag = 1;
                }

                /* move to next pair of vertices, retaining info as possible */
                yflag0 = yflag1;
                vtx0   = vtx1;
                vtx1   = TstPnt[++index];
            }
            Exit :;
            return(inside_flag);
        }
Exemplo n.º 25
0
    //unsure
    //public int blindSpotErrorCheck = 0;
    //public int totalNumberOfBlindSpotPoints;


    // Use this for initialization
    void Start()
    {
        stimulus.enabled    = false;
        totalNumberOfPoints = 100;
        if (mode == TestMode.LaterGlaucoma)
        {
            startLightInt = 2.0f;
        }
        if (mode == TestMode.EarlyGlaucoma)
        {
            startLightInt = 1.0f;
        }
        stimuliRadius      = 1f;
        minIntensity       = 0.0f;   //defaulted to 0
        maxIntensity       = 8.0f;
        lightTimer         = -0.01f; // Initialize a wait
        minEnableDuration  = 0.8f;
        maxEnableDuration  = 1.2f;
        minDisableDuration = 3f;
        maxDisableDuration = 3f;
        counter            = 0;
        numDone            = 0;
        errorCounter       = 0;

        List <float> ints = new List <float>();

        ints.Add(startLightInt);

        //Add regular points
        for (int i = 0; i < totalNumberOfPoints / 5 - 1; i++)
        {
            testPoints.Add(addStimuli());
        }
        //Add blindspot points
        if (eye == TestingEye.LeftEye)
        {
            p1 = new TestPoint(-15, 0, stimuliRadius, ints);
        }
        if (eye == TestingEye.RightEye)
        {
            p1 = new TestPoint(15, 0, stimuliRadius, ints);
        }
        testPoints.Add(p1);


        for (int i = totalNumberOfPoints / 5; i < 2 * totalNumberOfPoints / 5 - 1; i++)
        {
            testPoints.Add(addStimuli());
        }
        if (eye == TestingEye.LeftEye)
        {
            p2 = new TestPoint(-14, -1, stimuliRadius, ints);
        }
        if (eye == TestingEye.RightEye)
        {
            p2 = new TestPoint(14, -1, stimuliRadius, ints);
        }
        testPoints.Add(p2);


        for (int i = 2 * totalNumberOfPoints / 5; i < 3 * totalNumberOfPoints / 5 - 1; i++)
        {
            testPoints.Add(addStimuli());
        }
        if (eye == TestingEye.LeftEye)
        {
            p3 = new TestPoint(-14, 1, stimuliRadius, ints);
        }
        if (eye == TestingEye.RightEye)
        {
            p3 = new TestPoint(14, 1, stimuliRadius, ints);
        }
        testPoints.Add(p3);


        for (int i = 3 * totalNumberOfPoints / 5; i < 4 * totalNumberOfPoints / 5 - 1; i++)
        {
            testPoints.Add(addStimuli());
        }
        if (eye == TestingEye.LeftEye)
        {
            p4 = new TestPoint(-16, 1, stimuliRadius, ints);
        }
        if (eye == TestingEye.RightEye)
        {
            p4 = new TestPoint(16, 1, stimuliRadius, ints);
        }
        testPoints.Add(p4);


        for (int i = 4 * totalNumberOfPoints / 5; i < totalNumberOfPoints - 1; i++)
        {
            testPoints.Add(addStimuli());
        }
        if (eye == TestingEye.LeftEye)
        {
            p5 = new TestPoint(-16, -1, stimuliRadius, ints);
        }
        if (eye == TestingEye.RightEye)
        {
            p5 = new TestPoint(16, -1, stimuliRadius, ints);
        }
        testPoints.Add(p5);
    }
Exemplo n.º 26
0
        public static bool IntersectPoly(Polygon poly, Point3d start, Point3d end, ref Point3d intersection)
        {
            //intersect a Polygon with a ray in world space
            bool   retval = false;
            double deltaX, deltaY, deltaZ, t, T, S;
            double A, B, C, D;//the Polygon plane
            double denom;

            if (TstPnt[0] == null)  // create if not created already
            {
                TstPnt[0] = new TestPoint();
                TstPnt[1] = new TestPoint();
                TstPnt[2] = new TestPoint();
                TstPnt[3] = new TestPoint();
            }

            A      = poly.plane.a;
            B      = poly.plane.b;
            C      = poly.plane.c;
            D      = poly.plane.d;
            deltaX = end.x - start.x;
            deltaY = end.y - start.y;
            deltaZ = end.z - start.z;

            denom = (A * deltaX + B * deltaY + C * deltaZ);

            if (denom == 0.0)//ray is parallel, no intersection
            {
                retval = false;
                return(retval);
            }
            T = (-1) / denom;
            S = (A * start.x + B * start.y + C * start.z);
            t = (S + D) * T;
            //at this point we have a possible intersection
            //project to a major world axis and test for containment in the poly
            intersection.x = (float)(start.x + (t * deltaX));
            intersection.y = (float)(start.y + (t * deltaY));
            intersection.z = (float)(start.z + (t * deltaZ));

            numTstPnt = poly.m_points.Length;
            // test the X/Y plane
            for (long counter = 0; counter < poly.m_points.Length; counter++)
            {
                TstPnt[counter].X = poly.m_points[counter].x;
                TstPnt[counter].Y = poly.m_points[counter].y;
            }
            if (CrossingsTest(intersection.x, intersection.y) == 1)
            {
                retval = true;
                return(retval);
            }
            // Test the X/Z plane
            for (long counter = 0; counter < poly.m_points.Length; counter++)
            {
                TstPnt[counter].X = poly.m_points[counter].x;
                TstPnt[counter].Y = poly.m_points[counter].z;
            }
            if (CrossingsTest(intersection.x, intersection.y) == 1)
            {
                retval = true;
            }
            return(retval);
        }
 public void RegisterTarget(TestPoint point, TestFunc func)
 {
     this.testPoints[point] = func;
 }
Exemplo n.º 28
0
 public void RegisterTarget(TestPoint point, TestFunc func)
 {
     this.testPoints[point] = func;
 }
Exemplo n.º 29
0
        TestOutcome HandleTestPoint(TestPoint point, Stream stream, ushort channel, List fields)
        {
            TestFunc func;
            if (this.testPoints.TryGetValue(point, out func))
            {
                return func(stream, channel, fields);
            }

            return TestOutcome.Continue;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Organises data into Lists.
        /// </summary>
        public void OrganiseData()
        {
            // MAP
            List <object> point = new List <object>();

            foreach (string line in mapData)
            {
                switch (line)
                {
                // Add point to map if end of data
                case "":
                    if (point.Count != 0)
                    {
                        Map.Add(point);
                        point = new List <object>();
                    }
                    break;

                default:
                    point.AddRange(AddPoint(line));
                    break;
                }
            }

            // Add final point
            if (!Map.Contains(point) && point.Count != 0)
            {
                Map.Add(point);
            }


            // TESTS AND SOLNS
            TestPoint tp = new TestPoint();

            tp.Data = new List <object>();
            int solnCount = 0;

            foreach (string line in testData)
            {
                if (line == "")
                {
                    if (tp.Data.Count != 0)
                    {
                        string[] bits = solnData[solnCount].Split(' ');
                        tp.ExpectedPoint     = Convert.ToInt32(bits[0]);
                        tp.ExpectedDirection = (bits.Length == 1) ? 0 : Convert.ToInt32(bits[1]);
                        solnCount++;
                        Tests.Add(tp);
                        tp      = new TestPoint();
                        tp.Data = new List <object>();
                    }
                }
                else
                {
                    tp.Data.AddRange(AddPoint(line));
                }
            }

            // Add final point
            if (!Tests.Contains(tp) && tp.Data.Count != 0)
            {
                if (solnCount != solnData.Count)
                {
                    string[] bits = solnData[solnCount].Split(' ');
                    tp.ExpectedPoint     = Convert.ToInt32(bits[0]);
                    tp.ExpectedDirection = (bits.Length == 1) ? 0 : Convert.ToInt32(bits[1]);
                    Tests.Add(tp);
                }
            }
        }
 public void SetTest(int ind, TestPoint rep)
 {
     Tests[ind] = rep;
 }
Exemplo n.º 32
0
 public void SetTest(int ind, TestPoint rep)
 {
     Tests[ind] = rep;
 }
Exemplo n.º 33
0
        /// <summary>
        /// 将excel中的数据导入到DataTable中
        /// </summary>
        /// <param name="sheetName">excel工作薄sheet的名称</param>
        /// <param name="isFirstRowColumn">第一行是否是DataTable的列名</param>
        /// <returns>返回的DataTable</returns>
        public static List <TestPoint> ExcelToDataList(string fileName, string sheetName, bool isFirstRowColumn)
        {
            ISheet           sheet    = null;
            int              startRow = 0;
            List <TestPoint> dataList = new List <TestPoint>();

            try
            {
                FileStream fs       = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                IWorkbook  workbook = null;
                if (fileName.IndexOf(".xlsx") > 0) // 2007版本
                {
                    workbook = new XSSFWorkbook(fs);
                }
                else if (fileName.IndexOf(".xls") > 0) // 2003版本
                {
                    workbook = new HSSFWorkbook(fs);
                }

                if (sheetName != null)
                {
                    sheet = workbook.GetSheet(sheetName);
                    if (sheet == null) //如果没有找到指定的sheetName对应的sheet,则尝试获取第一个sheet
                    {
                        sheet = workbook.GetSheetAt(0);
                    }
                }
                else
                {
                    sheet = workbook.GetSheetAt(0);
                }
                if (sheet != null)
                {
                    IRow firstRow  = sheet.GetRow(0);
                    int  cellCount = firstRow.LastCellNum; //一行最后一个cell的编号 即总的列数

                    if (isFirstRowColumn)
                    {
                        for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
                        {
                            ICell cell = firstRow.GetCell(i);
                            if (cell != null)
                            {
                                string cellValue = cell.StringCellValue;
                                if (cellValue != null)
                                {
                                    DataColumn column = new DataColumn(cellValue);
                                }
                            }
                        }
                        startRow = sheet.FirstRowNum + 1;
                    }
                    else
                    {
                        startRow = sheet.FirstRowNum;
                    }

                    //最后一列的标号
                    int rowCount = sheet.LastRowNum;
                    for (int i = startRow; i <= rowCount; ++i)
                    {
                        IRow row = sheet.GetRow(i);
                        if (row == null)
                        {
                            continue;              //没有数据的行默认是null       
                        }
                        var value1 = row.GetCell(0).ToString();
                        if (string.IsNullOrEmpty(value1))
                        {
                            continue;
                        }
                        TestPoint point = new TestPoint();
                        point.Angle     = decimal.Parse(value1);
                        point.ActualV   = decimal.Parse(row.GetCell(1).ToString());
                        point.IdealV    = decimal.Parse(row.GetCell(2).ToString());
                        point.UpperV    = decimal.Parse(row.GetCell(3).ToString());
                        point.DownV     = decimal.Parse(row.GetCell(4).ToString());
                        point.LineError = decimal.Parse(row.GetCell(5).ToString());
                        dataList.Add(point);
                    }
                }

                return(dataList);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
                return(null);
            }
        }
Exemplo n.º 34
0
 public static IndexWriter MockIndexWriter(Directory dir, IndexWriterConfig conf, TestPoint testPoint)
 {
     conf.SetInfoStream(new TestPointInfoStream(conf.InfoStream, testPoint));
     return(new IndexWriter(dir, conf));
 }
Exemplo n.º 35
0
 public TestPointInfoStream(InfoStream @delegate, TestPoint testPoint)
 {
     this.@delegate = @delegate ?? new NullInfoStream();
     this.TestPoint = testPoint;
 }
Exemplo n.º 36
0
        public static bool IntersectPoly(Polygon poly, Point3d start, Point3d end,ref  Point3d intersection)
        {
            //intersect a Polygon with a ray in world space
            bool retval = false;
            double deltaX, deltaY, deltaZ, t, T, S;
            double A, B, C, D;//the Polygon plane
            double denom;

            if (TstPnt[0] == null)  // create if not created already
            {
                TstPnt[0] = new TestPoint();
                TstPnt[1] = new TestPoint();
                TstPnt[2] = new TestPoint();
                TstPnt[3] = new TestPoint();
            }

            A = poly.plane.a;
            B = poly.plane.b;
            C = poly.plane.c;
            D = poly.plane.d;
            deltaX = end.x - start.x;
            deltaY = end.y - start.y;
            deltaZ = end.z - start.z;

            denom = (A * deltaX + B * deltaY + C * deltaZ);

            if (denom == 0.0)//ray is parallel, no intersection
            {
                retval = false;
                return retval;
            }
            T = (-1) / denom;
            S = (A * start.x + B * start.y + C * start.z);
            t = (S + D) * T;
            //at this point we have a possible intersection
            //project to a major world axis and test for containment in the poly
            intersection.x = (float)(start.x + (t * deltaX));
            intersection.y = (float)(start.y + (t * deltaY));
            intersection.z = (float)(start.z + (t * deltaZ));

            numTstPnt = poly.m_points.Length;
            // test the X/Y plane
            for (long counter = 0; counter < poly.m_points.Length; counter++)
            {
                TstPnt[counter].X = poly.m_points[counter].x;
                TstPnt[counter].Y = poly.m_points[counter].y;
            }
            if (CrossingsTest(intersection.x, intersection.y) == 1)
            {
                retval = true;
                return retval;
            }
            // Test the X/Z plane
            for (long counter = 0; counter < poly.m_points.Length; counter++)
            {
                TstPnt[counter].X = poly.m_points[counter].x;
                TstPnt[counter].Y = poly.m_points[counter].z;
            }
            if (CrossingsTest(intersection.x, intersection.y) == 1)
            {
                retval = true;
            }
            return retval;
        }
Exemplo n.º 37
0
        static TestPoint[] TstPnt = new TestPoint[4]; //for the crossing test

        #endregion Fields

        #region Methods

        public static int CrossingsTest(double PntX, double PntY)
        {
            if (TstPnt[0] == null)  // create if not created already
            {
                TstPnt[0] = new TestPoint();
                TstPnt[1] = new TestPoint();
                TstPnt[2] = new TestPoint();
                TstPnt[3] = new TestPoint();
            }
            int j, yflag0, yflag1, inside_flag, xflag0;
            double ty, tx;// *vtx0, *vtx1 ;
            int line_flag;
            short index = 0;
            tx = PntX;//point[X] ;
            ty = PntY;//point[Y] ;
            TestPoint vtx0, vtx1;
            vtx0 = TstPnt[numTstPnt - 1];
            yflag0 = (vtx0.Y >= ty) ? 1 : 0;
            vtx1 = TstPnt[0];
            inside_flag = 0;
            line_flag = 0;
            for (j = numTstPnt + 1; --j > 0; )
            {
                yflag1 = (vtx1.Y >= ty) ? 1 : 0;
                if (yflag0 != yflag1)
                {
                    xflag0 = (vtx0.X >= tx) ? 1 : 0;
                    if (xflag0 == ((vtx1.X >= tx) ? 1 : 0))
                    {
                        if (xflag0 != 0)
                        {
                            if (inside_flag == 1)
                            {
                                inside_flag = 0;
                            }
                            else
                            {
                                inside_flag = 1;
                            }
                            //inside_flag = !inside_flag;
                        }
                    }
                    else
                    {
                        if ((vtx1.X - (vtx1.Y - ty) *
                         (vtx0.X - vtx1.X) / (vtx0.Y - vtx1.Y)) >= tx)
                        {
                            //inside_flag = !inside_flag ;
                            if (inside_flag == 1)
                            {
                                inside_flag = 0;
                            }
                            else
                            {
                                inside_flag = 1;
                            }
                        }
                    }
                    if (line_flag != 0)
                        goto Exit;
                    line_flag = 1;
                }

                /* move to next pair of vertices, retaining info as possible */
                yflag0 = yflag1;
                vtx0 = vtx1;
                vtx1 = TstPnt[++index];
            }
            Exit: ;
            return (inside_flag);
        }
        /// <summary>
        /// Organises data into Lists.
        /// </summary>
        public void OrganiseData()
        {
            // MAP
            List<object> point = new List<object>();
            foreach (string line in mapData)
            {
                switch (line)
                {
                    // Add point to map if end of data
                    case "":
                        if (point.Count != 0)
                        {
                            Map.Add(point);
                            point = new List<object>();
                        }
                        break;
                    default:
                        point.AddRange(AddPoint(line));
                        break;
                }
            }

            // Add final point
            if (!Map.Contains(point) && point.Count != 0)
                Map.Add(point);

            // TESTS AND SOLNS
            TestPoint tp = new TestPoint();
            tp.Data = new List<object>();
            int solnCount = 0;
            foreach (string line in testData)
            {
                if (line == "")
                {
                    if (tp.Data.Count != 0)
                    {
                        string[] bits = solnData[solnCount].Split(' ');
                        tp.ExpectedPoint = Convert.ToInt32(bits[0]);
                        tp.ExpectedDirection = (bits.Length == 1) ? 0 : Convert.ToInt32(bits[1]);
                        solnCount++;
                        Tests.Add(tp);
                        tp = new TestPoint();
                        tp.Data = new List<object>();
                    }
                }
                else
                    tp.Data.AddRange(AddPoint(line));
            }

            // Add final point
            if (!Tests.Contains(tp) && tp.Data.Count != 0)
            {
                if (solnCount != solnData.Count)
                {
                    string[] bits = solnData[solnCount].Split(' ');
                    tp.ExpectedPoint = Convert.ToInt32(bits[0]);
                    tp.ExpectedDirection = (bits.Length == 1) ? 0 : Convert.ToInt32(bits[1]);
                    Tests.Add(tp);
                }
            }
        }