Exemple #1
0
        public void Test_CommandLineParameter()
        {
            var rdk = new RoboDK
            {
                ApplicationDir        = "C:\\zBuilds\\Bystronic\\repository\\ByRobotManager-2\\ByRobotManager\\bin\\Debug\\RoboDK\\RoboDK.exe",
                RoboDKServerStartPort = 56252,

                //CustomCommandLineArgumentString = "-NOSPLASH -NOSHOW -HIDDEN -PORT=56252  -NOSTDOUT -SKIPINIRECENT -SKIPINI -SKIPCOM -EXIT_LAST_COM -NOUI",
                CustomCommandLineArgumentString = "-PORT=56252  -NOSTDOUT -SKIPINIRECENT -SKIPINI -SKIPCOM -EXIT_LAST_COM -NOUI -TREE_STATE=-1",

                //CustomCommandLineArgumentString = "/NOSPLASH /NOSHOW /HIDDEN /PORT=56252  /NOSTDOUT /SKIPINIRECENT /SKIPINI /SKIPCOM /EXIT_LAST_COM /NOUI /TREE_STATE=-1",
                //CustomCommandLineArgumentString = "/NOSPLASH /NOSHOW /HIDDEN /NOSTDOUT /SKIPINIRECENT /SKIPINI /SKIPCOM /EXIT_LAST_COM /NOUI /TREE_STATE=-1"
                //CustomCommandLineArgumentString = "/NOSTDOUT /SKIPINIRECENT /SKIPINI /SKIPCOM /EXIT_LAST_COM /NOUI"
            };

            rdk.Connect();

//            Thread.Sleep(5000);
            var mainWindow = rdk.Command("MainWindow_ID");

            var item = rdk.AddFile(@"C:\Users\mth\AppData\Local\Temp\ByRobotManager_Geometries\Regrip lower arm NS2+NS3_collision.sld");

            item.SetParam("FilterMesh", "0,0.0001,0.005");

            var mainWindowId = int.Parse(mainWindow);


            rdk.CloseRoboDK();
        }
Exemple #2
0
        public void Test_ParallelRoboDKConnections()
        {
            var stopAsyncTask = false;
            var rdk           = new RoboDK
            {
                RoboDKServerStartPort = 10000,
                Logfile = Path.Combine(Directory.GetCurrentDirectory(), "RoboDk.log"),
                DefaultSocketTimeoutMilliseconds = 20 * 1000
            };

            rdk.Connect();
            rdk.Render(false);
            rdk.Command("AutoRenderDelay", 50);
            rdk.Command("AutoRenderDelayMax", 300);
            rdk.DefaultSocketTimeoutMilliseconds = 10 * 1000;

            List <IItem> AddStaticParts()
            {
                var parts = new List <IItem>();
                var cwd   = Directory.GetCurrentDirectory();

                parts.Add(rdk.AddFile(Path.Combine(cwd, "TableOut.sld")));
                parts.Add(rdk.AddFile(Path.Combine(cwd, "robot.robot")));
                return(parts);
            }

            List <IItem> AddDynamicParts()
            {
                var parts = new List <IItem>();
                var cwd   = Directory.GetCurrentDirectory();

                for (var n = 0; n < 10; n++)
                {
                    parts.Add(rdk.AddFile(Path.Combine(cwd, "Phone Case Box.sld")));
                    parts.Add(rdk.AddFile(Path.Combine(cwd, "Box.sld")));
                    parts.Add(rdk.AddFile(Path.Combine(cwd, "Phone Case Done.sld")));
                }

                return(parts);
            }

            // Task which opens a temporary new connection
            void DoTemporaryConnectionCalls(IReadOnlyCollection <IItem> staticParts)
            {
                // ReSharper disable once AccessToModifiedClosure
                while (!stopAsyncTask)
                {
                    foreach (var staticPart in staticParts)
                    {
                        Thread.Sleep(1);
                        using (var roboDkLink = new RoboDK.RoboDKLink(staticPart.RDK()))
                        {
                            var clonedItem = staticPart.Clone(roboDkLink.RoboDK);
                            clonedItem.Pose();
                        }
                    }
                }
            }

            var p    = AddStaticParts();
            var task = new Task(() => DoTemporaryConnectionCalls(p));

            task.Start();

            try
            {
                for (var i = 0; i < 20; i++)
                {
                    var dynamicParts = AddDynamicParts();
                    rdk.Command("CollisionMap", "Off");
                    rdk.SetCollisionActive(CollisionCheckOptions.CollisionCheckOff);
                    rdk.Delete(dynamicParts);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                stopAsyncTask = true;
            }

            try
            {
                task.Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                rdk.CloseRoboDK();
            }
        }