private async void TryConnectToController()
    {
        if (controllerClient != null)
        {
            textToaster.Toast("A controller is already connected.");
            return;
        }

        if (!ConnectWindowVisibility)
        {
            textToaster.Toast("Cannot try connecting to more than one remote machine.");
            return;
        }

        ConnectWindowVisibility = false;

        var random = new System.Random();
        int userId = random.Next();

        var tcpSocket = new TcpSocket(new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp));

        if (await tcpSocket.ConnectAsync(IPAddress.Loopback, ControllerMessages.PORT))
        {
            textToaster.Toast("connected");
            controllerClient = new ControllerClient(userId, tcpSocket);
        }
        else
        {
            textToaster.Toast("not connected");
        }


        ConnectWindowVisibility = true;
    }
        // Create ControllerClient instance and try login - Invalid password
        private static void CTUA00300()
        {
            string xmlFilepath = "C:\\connection2.xml";

            XmlDocument  document = new XmlDocument();
            StreamReader reader   = new StreamReader(xmlFilepath, Encoding.UTF8);

            document.Load(reader);

            string mujinIpAddress  = document.GetElementsByTagName("ipaddress")[0].InnerText;
            string scenePrimaryKey = document.GetElementsByTagName("scenepk")[0].InnerText;
            string username        = document.GetElementsByTagName("password")[0].InnerText;
            string password        = "******";
            string taskName        = document.GetElementsByTagName("taskname")[0].InnerText;
            string taskType        = document.GetElementsByTagName("tasktype")[0].InnerText;
            string controllerip    = document.GetElementsByTagName("controllerip")[0].InnerText;
            int    controllerport  = int.Parse(document.GetElementsByTagName("controllerport")[0].InnerText);

            try
            {
                ControllerClient controllerClient = new ControllerClient(username, password, mujinIpAddress);
            }
            catch (ClientException ex)
            {
                if (!ex.ToString().Contains("Confirm username and password"))
                {
                    throw new Exception("Test case CTUA00300 failed");
                }
            }
        }
Exemple #3
0
        public ConfigurationTabVM(ControllerClient controllerClient, UnhandledExceptionPresenter unhandledExceptionPresenter)
        {
            if (controllerClient == null)
            {
                throw new ArgumentNullException(nameof(controllerClient));
            }
            if (unhandledExceptionPresenter == null)
            {
                throw new ArgumentNullException(nameof(unhandledExceptionPresenter));
            }

            _controllerClient            = controllerClient;
            _unhandledExceptionPresenter = unhandledExceptionPresenter;

            Areas = new SelectableObservableCollection <AreaItemVM>();

            RefreshCommand = new AsyncDelegateCommand(RefreshAsync);
            SaveCommand    = new AsyncDelegateCommand(SaveAsync);

            MoveAreaUpCommand   = new DelegateCommand(MoveAreaUp);
            MoveAreaDownCommand = new DelegateCommand(MoveAreaDown);

            MoveActuatorUpCommand   = new DelegateCommand(MoveActuatorUp);
            MoveActuatorDownCommand = new DelegateCommand(MoveActuatorDown);
        }
Exemple #4
0
 public FormListClients(ControllerClient service, ControllerSelection serviceR, ControllerService serviceS, ControllerValidation serviceV)
 {
     InitializeComponent();
     this.service  = service;
     this.serviceR = serviceR;
     this.serviceS = serviceS;
     this.serviceV = serviceV;
 }
 public FormFillingContracts(ControllerDirection serviceD, ControllerClient serviceC, ControllerContractClient serviceCC,
                             ContractAgent serviceCA, ControllerService serviceS, ControllerPrinting serviceP, ControllerValidation validation)
 {
     InitializeComponent();
     this.serviceD   = serviceD;
     this.serviceCC  = serviceCC;
     this.serviceC   = serviceC;
     this.serviceS   = serviceS;
     this.serviceCA  = serviceCA;
     this.validation = validation;
     this.serviceP   = serviceP;
 }
Exemple #6
0
        static void Main(string[] args)
        {
            string hostname = "controller65";
            string username = "******";
            string password = "******";
            string scenepk  = "knowledgepicking1.mujin.dae";

            ControllerClient controllerClient = new ControllerClient(username, password, "http://" + hostname);

            SceneResource  scene = controllerClient.GetScene(scenepk);
            BinPickingTask task  = (BinPickingTask)scene.GetOrCreateTaskFromName("test_task_1", "binpicking");

            // slave request id for the target slave, usually hostname + "_slave0"
            task.SlaveRequestID = hostname + "_slave0";

            // remove objects in the scene whose names have this prefix, optional
            string prefix = "detected_sourcecontainer_";

            // list of objects and their poses to be updated in the scene
            List <Dictionary <string, object> > envstate = new List <Dictionary <string, object> >()
            {
                new Dictionary <string, object>()
                {
                    { "name", prefix + "1" },
                    { "quat_", new List <double>()
                      {
                          1, 0, 0, 0
                      } },
                    { "translation_", new List <double>()
                      {
                          0, 0, 300
                      } },
                    { "object_uri", "mujin:/work1.mujin.dae" },
                },
                new Dictionary <string, object>()
                {
                    { "name", prefix + "2" },
                    { "quat_", new List <double>()
                      {
                          1, 0, 0, 0
                      } },
                    { "translation_", new List <double>()
                      {
                          0, 100, 400
                      } },
                    { "object_uri", "mujin:/work2_b.mujin.dae" },
                }
            };

            task.UpdateObjects(envstate, prefix);
        }
        public void ChangeItemTests_null()        //Вещь изменяется несуществующим игроком
        {
            ModelClient      model     = new ModelClient();
            ControllerClient controler = new ControllerClient(model);

            model.threadStart = true;
            Thread threadClient = new Thread(new ThreadStart(serverStart));

            threadClient.Start();
            bool expected = false;

            bool actual = controler.ChangeItem(1);

            Assert.AreEqual(expected, actual);
        }
        public void TestConnect_null()        //Подключение к нулевому адресу
        {
            //arrange
            ModelClient      model     = new ModelClient();
            ControllerClient controler = new ControllerClient(model);
            bool             expected  = false;

            Thread threadClient = new Thread(new ThreadStart(serverStart));

            threadClient.Start();

            //act

            //assert
            Assert.ThrowsException <NullReferenceException>(() => controler.Connect(null));
        }
        public void TestConnect_192168125()        //Подключение к несуществующему адресу
        {
            //arrange
            ModelClient      model     = new ModelClient();
            ControllerClient controler = new ControllerClient(model);
            bool             expected  = false;

            Thread threadClient = new Thread(new ThreadStart(serverStart));

            threadClient.Start();

            //act

            //assert
            Assert.ThrowsException <NullReferenceException>(() => controler.Connect("192.168.1.25"));
        }
Exemple #10
0
        public WeatherStationTabVM(ControllerClient controllerClient)
        {
            if (controllerClient == null)
            {
                throw new ArgumentNullException(nameof(controllerClient));
            }

            _controllerClient = controllerClient;

            ApiKey    = new PropertyVM <string>(string.Empty);
            Latitude  = new PropertyVM <string>(string.Empty);
            Longitude = new PropertyVM <string>(string.Empty);

            RefreshCommand = new AsyncDelegateCommand(Refresh);
            SaveCommand    = new AsyncDelegateCommand(Save);
        }
        // Get scene resource- Invalid primary key
        public static void CTUB00200()
        {
            ControllerClient controllerClient = CTUA00100();

            try
            {
                controllerClient.GetScene("irex2013.mujin.hogehoge.dae");
            }
            catch (ClientException ex)
            {
                if (!ex.ToString().Contains("invalid scene primary key"))
                {
                    throw new Exception("Test case CTUB00200 failed");
                }
            }
        }
        public void TestConnect_127001()        //Подключение к существующему серверу
        {
            //arrange
            ModelClient      model     = new ModelClient();
            ControllerClient controler = new ControllerClient(model);
            bool             expected  = true;

            Thread threadClient = new Thread(new ThreadStart(serverStart));

            threadClient.Start();

            //act
            bool actual = controler.Connect("127.0.0.1");

            //assert
            Assert.AreEqual(expected, actual);
        }
        public HomeTabVM(ControllerClient controllerClient)
        {
            if (controllerClient == null)
            {
                throw new ArgumentNullException(nameof(controllerClient));
            }

            _controllerClient = controllerClient;

            OpenHomepageCommand      = new OpenLinkCommand("http://www.HA4IoT.de");
            OpenTwitterCommand       = new OpenLinkCommand("https://twitter.com/chkratky");
            OpenRepositoryCommand    = new OpenLinkCommand("https://github.com/chkr1011/CK.HomeAutomation");
            OpenDocumentationCommand = new OpenLinkCommand(
                "https://www.hackster.io/cyborg-titanium-14/home-automation-with-raspberry-pi-2-and-windows-10-iot-784235");

            OpenAppCommand = new DelegateCommand(OpenApp);
        }
Exemple #14
0
        public Form1()
        {
            InitializeComponent();
            emergencyTicks    = 0;
            emergencyPlane    = null;
            this.flightstatus = new string[3];
            for (int i = 0; i < flightstatus.Length; i++)
            {
                flightstatus[i] = "";
            }
            this.context         = new InstanceContext(this);
            this.proxy           = new ControllerClient(context);
            Switch               = false;
            this.timer1.Interval = 2000;
            this.timer2.Interval = 1000;
            this.proxy.SubscribeEvent();
            this.lbAirportName.Text = proxy.GetAirportName();


            CancelTokenSource = new CancellationTokenSource();
            Token             = CancelTokenSource.Token;

            listOfPlanes = this.proxy.GetAirplaneList().ToList();


            timer1.Start();
            timer2.Start();
            //set starting points of planes for animation
            startR1 = new Point(50, 50);
            startR2 = new Point(50, 100);
            startR3 = new Point(50, 190);
            startR4 = new Point(50, 315);
            // hide all planes and labels
            hidePlanes();
            lblR1.Hide(); lblR2.Hide(); lblR3.Hide(); lblR4.Hide();
            //only one item can be selected from the listView (for command pusposes), it returns an array of selected items so the one we look for is on index 0
            listView_flight.MultiSelect = false;
            //all runways are free
            prepareRunway("R1");
            prepareRunway("R2");
            prepareRunway("R3");

            statusDict  = proxy.GetStatusDictionaryController();
            commandDict = proxy.GetCommandDictionary();
        }
        // Create ControllerClient instance and try login
        private static ControllerClient CTUA00100()
        {
            string xmlFilepath = "C:\\connection2.xml";

            XmlDocument  document = new XmlDocument();
            StreamReader reader   = new StreamReader(xmlFilepath, Encoding.UTF8);

            document.Load(reader);

            string mujinIpAddress  = document.GetElementsByTagName("ipaddress")[0].InnerText;
            string scenePrimaryKey = document.GetElementsByTagName("scenepk")[0].InnerText;
            string username        = document.GetElementsByTagName("username")[0].InnerText;
            string password        = document.GetElementsByTagName("password")[0].InnerText;
            string taskName        = document.GetElementsByTagName("taskname")[0].InnerText;
            string taskType        = document.GetElementsByTagName("tasktype")[0].InnerText;
            string controllerip    = document.GetElementsByTagName("controllerip")[0].InnerText;
            int    controllerport  = int.Parse(document.GetElementsByTagName("controllerport")[0].InnerText);

            ControllerClient controllerClient = new ControllerClient(username, password, mujinIpAddress);

            return(controllerClient);
        }
        public HealthTabVM(ControllerClient controllerClient)
        {
            if (controllerClient == null)
            {
                throw new ArgumentNullException(nameof(controllerClient));
            }

            TraceItems = new SelectableObservableCollection <TraceItem>();

            _controllerClient = controllerClient;

            _traceItemReceiverClient = new TraceItemReceiverClient();
            _traceItemReceiverClient.TraceItemReceived += EnlistTraceItem;
            _traceItemReceiverClient.Start();

            ClearCommand = new DelegateCommand(Clear);

            AutoScroll          = new PropertyVM <bool>(true);
            ShowVerboseMessages = new PropertyVM <bool>(true);
            ShowInformations    = new PropertyVM <bool>(true);
            ShowWarnings        = new PropertyVM <bool>(true);
            ShowErrors          = new PropertyVM <bool>(true);
        }
    // Start is called before the first frame update
    async void Start()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        var options = new ControllerClientOptions
        {
            BrokerAddress        = ip,
            BrokerPort           = port,
            EnableConsoleLogging = true,
            Identifier           = "gruppo-4",
            ReconnectDelay       = TimeSpan.FromSeconds(5),
            QualityOfService     = MqttQualityOfServiceLevel.AtLeastOnce,
            LastWillTopic        = $"{teamId}/features/lifecycle/simulator/ondisconnect"
        };

        Client = new ControllerClient(options);
        Debug.Log("Connecting to broker");
        await Client.StartAsync();

        var publishOnConnectTask   = Client.PublishAsync($"{teamId}/features/lifecycle/simulator/onconnect", string.Empty);
        var subscribeOnConnectTask = Client.SubscribeAsync(
            $"{teamId}/features/lifecycle/controller/onconnect",
            message => Debug.Log("Received on connect from controller")
            );
        var subscribeOnDisconnectTask = Client.SubscribeAsync(
            $"{teamId}/features/lifecycle/controller/ondisconnect",
            message => Debug.Log("Received on disconnect from controller")
            );

        await Task.WhenAll(publishOnConnectTask, subscribeOnConnectTask, subscribeOnDisconnectTask);

        Debug.Log("Connected");
    }
Exemple #18
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     try
     {
         TcpClient tcp = new TcpClient(proxy.Endpoint.Address.Uri.Host, Convert.ToInt32(proxy.Endpoint.Address.Uri.OriginalString.TrimStart('h', 't', 't', 'p', '/', '/', 'l', 'o', 'c', 'a', 'l', 'h', 'o', 's', 't', ':').Split('/')[0]));
         lbl_serverStatus.Text      = " I ";
         lbl_serverStatus.BackColor = Color.Green;
         if (Switch == true)
         {
             this.context = new InstanceContext(this);
             this.proxy   = new ControllerClient(context);
             proxy.SubscribeEvent();
             CancelTokenSource = new CancellationTokenSource();
             Token             = CancelTokenSource.Token;
             timer1.Start();
             Switch = false;
         }
     }
     catch (Exception)
     {
         CancelTokenSource.Cancel();
         lbl_serverStatus.Text      = "O";
         lbl_serverStatus.BackColor = Color.Red;
         if (Switch == false)
         {
             timer1.Stop();
             Switch = true;
         }
     }
     // timer1.Stop();
     // IPAddress ip =  Dns.GetHostAddresses(proxy.Endpoint.Address.Uri.Host)[0];
     //PingReply reply = ping.Send(ip);
     // pining = reply.Status == IPStatus.Success;
     // MessageBox.Show(pining.ToString());
     // timer1.Start();
 }
 public FormClient()
 {
     InitializeComponent();
     controller = new ControllerClient(dgv, bn);
     controller.FillColumns();
 }
Exemple #20
0
 private void Awake()
 {
     Application.runInBackground = true;
     renderServer = RendererServer.Instance;
     ctrlClient   = ControllerClient.Instance;
 }
        // Get scene resource
        public static SceneResource CTUB00100()
        {
            ControllerClient controllerClient = CTUA00100();

            return(controllerClient.GetScene("irex2013.mujin.dae"));
        }
 public ParserSystem(string UrlController, string WebServerUrl)
 {
     this.ControllerClient = new ControllerClient(UrlController);
     this.WebServerClient  = new WebServerClient(WebServerUrl);
 }
 public PublishCommand(ControllerClient client)
 {
     _client = client;
 }
    void Update()
    {
        // Sends virtual keyboards strokes to the TextMeshes for the IP address and the port.
        AbsorbInput();

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (connectionWindow.ConnectionTarget == ConnectionTarget.Controller)
            {
                connectionWindow.ConnectionTarget = ConnectionTarget.Kinect;
            }
            else
            {
                connectionWindow.ConnectionTarget = ConnectionTarget.Controller;
            }
        }

        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            if (connectionWindow.ConnectionTarget == ConnectionTarget.Controller)
            {
                TryConnectToController();
            }
            else
            {
                StartCoroutine(TryConnectToKinect());
            }
        }

        // Gives the information of the camera position and floor level.
        if (Input.GetKeyDown(KeyCode.Space))
        {
            sharedSpaceAnchor.UpdateTransform(cameraTransform.position, cameraTransform.rotation);
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            sharedSpaceAnchor.DebugVisibility = !sharedSpaceAnchor.DebugVisibility;
        }

        if (controllerClient != null)
        {
            var receiverStates = new List <ReceiverState>();
            if (kinectReceiver != null)
            {
                var receiverState = new ReceiverState(kinectReceiver.SenderEndPoint.Address.ToString(),
                                                      kinectReceiver.SenderEndPoint.Port,
                                                      kinectReceiver.ReceiverSessionId);
                receiverStates.Add(receiverState);
            }
            try
            {
                controllerClient.SendViewerState(receiverStates);
            }
            catch (TcpSocketException e)
            {
                print($"TcpSocketException while connecting: {e}");
                controllerClient = null;
            }
        }

        if (kinectReceiver != null)
        {
            var senderPacketSet = SenderPacketReceiver.Receive(udpSocket);
            if (!kinectReceiver.UpdateFrame(udpSocket, senderPacketSet))
            {
                kinectReceiver          = null;
                ConnectWindowVisibility = true;
            }
        }
    }
Exemple #25
0
        static void Main(string[] args)
        {
            if (true)
            {
                ControllerClient controllerClient2 = new ControllerClient("testuser", "mytestpass", "http://controller13");

                //controllerClient.Initialize("mujin:/irex2013/irex2013.WPJ", "mujincollada", "wincaps", "mujin:/irex2013.mujin.dae");

                //SceneResource scene2 = controllerClient2.GetScene("test.mujin.dae");

                // JSON creation
                //Dictionary<string, object> jsonMessage = controllerClient2.GetJsonMessage(HttpMethod.POST, "scene/?format=json", "{\"name\":\"newname\", \"reference_uri\":\"mujin:/plasticnut-center.mujin.dae\"}");

                // XML creation
                Dictionary <string, object> xmlMessage = controllerClient2.GetXMLMessage(HttpMethod.POST, "scene/?format=xml", "<request><name>newname3</name><reference_uri>mujin:/plasticnut-center.mujin.dae</reference_uri></request>");
            }

            // Default XML path:
            // string xmlFilepath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "..\\..\\samples\\getsceneinfo\\config\\connection.xml";

            // Custom XML path;
            string xmlFilepath = "C:\\connection2.xml";

            XmlDocument  document = new XmlDocument();
            StreamReader reader   = new StreamReader(xmlFilepath, Encoding.UTF8);

            document.Load(reader);

            string mujinIpAddress  = document.GetElementsByTagName("ipaddress")[0].InnerText;
            string scenePrimaryKey = document.GetElementsByTagName("scenepk")[0].InnerText;
            string username        = document.GetElementsByTagName("username")[0].InnerText;
            string password        = document.GetElementsByTagName("password")[0].InnerText;
            string taskName        = document.GetElementsByTagName("taskname")[0].InnerText;
            string taskType        = document.GetElementsByTagName("tasktype")[0].InnerText;
            string controllerip    = document.GetElementsByTagName("controllerip")[0].InnerText;
            int    controllerport  = int.Parse(document.GetElementsByTagName("controllerport")[0].InnerText);

            ControllerClient controllerClient = new ControllerClient(username, password, mujinIpAddress);

            //controllerClient.Initialize("mujin:/irex2013/irex2013.WPJ", "mujincollada", "wincaps", "mujin:/irex2013.mujin.dae");

            SceneResource  scene = controllerClient.GetScene(scenePrimaryKey);
            BinPickingTask task  = (BinPickingTask)scene.GetOrCreateTaskFromName(taskName, taskType, controllerip, controllerport);

            // Test1: GetJointValues
            RobotState robotState = task.GetJointValues();

            /*
             * // Test2: MoveJoints
             * robotState.jointValues[1] += 30;
             * robotState.jointValues[3] -= 30;
             * List<double> jointValues = new List<double>() { robotState.jointValues[1], robotState.jointValues[3] };
             * List<int> jointIndices = new List<int>(){1, 3};
             * task.MoveJoints(jointValues, jointIndices, 30, 0.2, "");
             */

            List <double> jointValues = new List <double>()
            {
                45
            };
            List <int> jointIndices = new List <int>()
            {
                6
            };

            task.MoveJoints(jointValues, jointIndices, 30, 0.2, "");

            jointValues = new List <double>()
            {
                0, 0, 0, 0, 0, 0, 0
            };
            jointIndices = new List <int>()
            {
                0, 1, 2, 3, 4, 5, 6
            };
            task.MoveJoints(jointValues, jointIndices, 30, 0.2, "");

            /*
             * // Test3: MoveToHandPosition
             * double[] basepos = robotState.tools["1Base"];
             * basepos[1] += 50;
             * basepos[3] -= 50;
             * task.MoveToHandPosition(new List<double>(basepos), GoalType.transform6d, "1Base", 0.2);
             */

            // Test4: PickAndMove
            //task.PickAndMove("container3", "camera3", "1Base", GoalType.translationdirection5d, new List<double>() { 1900, 240, 700, 0, 0, 1 }, 0.2);
        }
 public SubscribeCommand(ControllerClient client)
 {
     _client = client;
 }