private T GetParValueOrDefault <T, parT>(string funName, string parName, BNT boolNumText)
        {
            parT par = GetUniquePar <parT>(parName);

            if (par == null)
            {
                return(DefinitionAdmin.GetParDefault <T>(funName, parName));
            }
            switch (boolNumText)
            {
            case BNT.BOOL: return((T)((par as ParBool).GetBoolValue() as object));

            case BNT.NUM: return((T)((par as ParNumber).GetValue() as object));

            case BNT.TEXT: return((T)((par as ParBase).xmlValue as object));
            }
            throw new Exception("GetParValueOrDefault failed");
        }
예제 #2
0
        private void bntBtn_Click(object sender, EventArgs e)
        {
            ///   robot.ReadLaserValues();
//               robot.Rotate(90);
//            return;
            //Console.WriteLine("Robot: {0} {1}", robot.Center.x, robot.Center.y);
            //Console.WriteLine("Robot: {0} {1} {2} {3}", robot.LL, robot.LF, robot.RF, robot.RR);

            CreatePathForm createPathForm = new CreatePathForm();

            createPathForm.FormClosing += (o, form) =>
            {
                var src = new Point(Int32.Parse(createPathForm.srcXTextBox.Text), Int32.Parse(createPathForm.srcYTextBox.Text));
                // LocationApproximator locationApproximator = new LocationApproximator();
                //   locationApproximator.SetUp(map);
                //    Point loc = locationApproximator.GetLocation((int)(src.x - R / 2), (int)(src.y - R / 2), R, R, 2, robot.LL, robot.LF, robot.RR, robot.RF);
                //      robot.Center = loc;
                Console.WriteLine("Robot: {0} {1}", robot.Center.x, robot.Center.y);
                Console.WriteLine("Robot: {0} {1} {2} {3}", robot.LL, robot.LF, robot.RF, robot.RR);
                bnt = new BNT(map, robot);


                List <String> names = new List <string>(createPathForm.dstXtextBox.Text.Split(' '));
                List <String> oo    = new List <string>(createPathForm.dstYTextBox.Text.Split(' '));

                List <Orientation> orientations = oo.ConvertAll(input =>
                {
                    Orientation orientation;
                    Enum.TryParse <Orientation>(input, out orientation);
                    return(orientation);
                });
//                bnt.TEST(src, names, orientations);
                bnt.Start(src, names, orientations);

                Timer1.Enabled = true;
                Render();
            };
            createPathForm.Show();
            Render();
        }