Exemplo n.º 1
0
        public Interface()
        {
            InitializeComponent();

            //Populate message type combobox
            var msgTypeDataSource = new List<comboboxItem>();

            msgTypeDataSource.Add(new comboboxItem() { Name = "Intention", Value = "Intention" });
            msgTypeDataSource.Add(new comboboxItem() { Name = "TaskGoal", Value = "TaskGoal" });
            msgTypeDataSource.Add(new comboboxItem() { Name = "SocialGoal", Value = "SocialGoal" });
            msgTypeDataSource.Add(new comboboxItem() { Name = "Spoke", Value = "Spoke" });

            //Setup data binding
            msgTypeComboBox.DataSource = msgTypeDataSource;
            msgTypeComboBox.DisplayMember = "Name";
            msgTypeComboBox.ValueMember = "Value";

            _intention = _socialGoal = _taskGoal = "NONE";

            _vhmsgClient = new VHMsg.Client();
            _vhmsgClient.OpenConnection();

            Console.WriteLine("GLOBAL DATA MODULE");
            Console.WriteLine("VHMSG_SERVER: {0}", _vhmsgClient.Server);
            Console.WriteLine("VHMSG_SCOPE: {0}", _vhmsgClient.Scope);

            //Announce availability
            _vhmsgClient.SendMessage("vrComponent GlobalData all");

            num_sent_msgs = 0;
        }
Exemplo n.º 2
0
        private void MessageAction(object sender, VHMsg.Message args)
        {
            //Console.WriteLine( "Received Message '" + args.s + "'" );

            string[] splitargs = args.s.Split(" ".ToCharArray());

            if (splitargs.Length > 0)
            {
                if (splitargs[0] == "adc")
                {
                    if (!m_form.checkBox2.Checked)
                    {
                        AddLineDelay(m_form.richTextBox1, args.s);
                    }
                }
                else if (splitargs[0] == "wsp")
                {
                    if (!m_form.checkBox3.Checked)
                    {
                        AddLineDelay(m_form.richTextBox1, args.s);
                    }
                }
                else if (splitargs[0] == "sbmdebugger")
                {
                    if (!m_form.checkBox5.Checked)
                    {
                        AddLineDelay(m_form.richTextBox1, args.s);
                    }
                }
                else
                {
                    if (splitargs[0] == "vrAllCall")
                    {
                        m_vhmsg.SendMessage("vrComponent elsender all");
                    }
                    else if (splitargs[0] == "vrKillComponent")
                    {
                        if (splitargs.Length > 1)
                        {
                            if (splitargs[1] == "elsender" || splitargs[1] == "all")
                            {
                                Application.Exit();
                            }
                        }
                    }

                    AddLineDelay(m_form.richTextBox1, args.s);
                }
            }
        }
Exemplo n.º 3
0
        public WozInterface()
        {
            InitializeComponent();

            _rapportState = 3;  //Range: [0, 7]

            //Initialize selections to NONE, to avoid sending empty messages
            rapportStrategyListBox.SelectedItem = rapportStrategyListBox.Items[rapportStrategyListBox.Items.Count-1];
            taskGoalListBox.SelectedItem = taskGoalListBox.Items[taskGoalListBox.Items.Count - 1];
            socialGoalListBox.SelectedItem = socialGoalListBox.Items[socialGoalListBox.Items.Count - 1];
            speechActListBox.SelectedItem = speechActListBox.Items[speechActListBox.Items.Count - 1];

            _vhmsgClient = new VHMsg.Client();
            _vhmsgClient.OpenConnection();

            Console.WriteLine("GLOBAL DATA MODULE");
            Console.WriteLine("VHMSG_SERVER: {0}", _vhmsgClient.Server);
            Console.WriteLine("VHMSG_SCOPE: {0}", _vhmsgClient.Scope);

            //Announce availability
            _vhmsgClient.SendMessage("vrComponent GlobalData all");
        }
        public void sendMsg()
        {
            Random rand = new Random();

            using (_vhmsgClient = new VHMsg.Client())
            {
                _vhmsgClient.OpenConnection();

                Thread.Sleep(rand.Next(3000));

                //Sends a single message
                _vhmsgClient.SendMessage("vrGlobalData update " + _count++);

                Console.WriteLine("Sent: vrGlobalData update " + (_count - 1));

                _vhmsgClient.CloseConnection();
            }
        }
        public void run()
        {
            using (_vhmsgClient = new VHMsg.Client())
            {
                _vhmsgClient.OpenConnection();

                _vhmsgClient.MessageEvent += new VHMsg.Client.MessageEventHandler(MessageAction);

                for (int i = 0; i < _subscribedMessages.Length; i++ ) {
                    _vhmsgClient.SubscribeMessage(_subscribedMessages[i]);
                }

                //Announce availability
                _vhmsgClient.SendMessage("vrComponent ConversationManager all");

                //Suspend self, message-halding thread will take over
                print("Listening for incoming messages...");

                //Activate the Dialogue Manager
                _dialogueMgr = new DialogueManager(this);
                Thread DMThread = new Thread(new ThreadStart(_dialogueMgr.run));
                _activeThreads.Add(DMThread);
                DMThread.Start();

                //Activate the Interaction Manager
                _rapportMgr = new RapportManager(this);
                Thread IMThread = new Thread(new ThreadStart(_rapportMgr.run));
                _activeThreads.Add(IMThread);
                IMThread.Start();

                //FOR DEMO ONLY
                _dialogueState.OtherAgentID = _agentID == 0 ? 1 : 0;

                //Notify Dialoge State Updated for initializations at the dialogue managers
                OnDSUpdated(EventArgs.Empty);

                while (Win32Interop._kbhit() == 0) { }
            }
        }
Exemplo n.º 6
0
        private void Connect()
        {
            // Connect to remote galaxy device.
            try
            {
                // Establish the remote endpoint for the socket.
                IPEndPoint remoteEP = new IPEndPoint(_ipAddr, _port);

                // Create a TCP/IP socket.
                _client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                // Connect to the remote endpoint.
                _client.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), _client);
                connectDone.WaitOne();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            // Connect to vh network
            _vhmsgClient = new VHMsg.Client();

            _vhmsgClient.OpenConnection();

            for (int i = 0; i < _subscribedMessages.Length; i++)
            {
                _vhmsgClient.SubscribeMessage(_subscribedMessages[i]);
            }

            _vhmsgClient.MessageEvent += new VHMsg.Client.MessageEventHandler(MessageAction);

            //Announce availability
            _vhmsgClient.SendMessage("vrComponent vh2galaxy all");
        }
Exemplo n.º 7
0
        public void run()
        {
            //Connect to the server
            _tcpClient = new AsynchronousClient(this, _serverIP, _serverPort);

            _tcpClient.StartClient();

            using (_vhmsgClient = new VHMsg.Client())
            {
                _vhmsgClient.OpenConnection();

                _vhmsgClient.MessageEvent += new VHMsg.Client.MessageEventHandler(MessageAction);

                for (int i = 0; i < _subscribedMessages.Length; i++)
                {
                    _vhmsgClient.SubscribeMessage(_subscribedMessages[i]);
                }

                //Announce availability
                _vhmsgClient.SendMessage("vrComponent DialogueManager all");

                while (Win32Interop._kbhit() == 0) { }
            }
        }
Exemplo n.º 8
0
        private static void Main(string[] args)
        {
            // Subscribing
            shouldListen = false;
            hr = new HandlerRoutine(ConsoleCtrlCheck);
            SetConsoleCtrlHandler(hr, true);

            using (vhmsg = new VHMsg.Client())
            {
                gazeTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
                string configFile = "config.ini";
                if (args.Length > 0)
                {
                    configFile = args[0];
                    Console.WriteLine("Reading config file - " + configFile);
                }

                ReadConfigFile(configFile);

                vhmsg.OpenConnection();

                Console.WriteLine("VHMSG_SERVER: {0}", vhmsg.Server);
                Console.WriteLine("VHMSG_SCOPE: {0}", vhmsg.Scope);

                Console.WriteLine("Press q to quit");
                Console.WriteLine("Listening to vrPerception Messages");

                vhmsg.MessageEvent += new VHMsg.Client.MessageEventHandler(MessageAction);
                vhmsg.SubscribeMessage("vrPerception");
                vhmsg.SubscribeMessage("vrAllCall");
                vhmsg.SubscribeMessage("vrKillComponent");
                vhmsg.SubscribeMessage("vrPerceptionApplication");

                vhmsg.SendMessage("vrComponent perception-test-application");

                while (isRunning)
                {
                    Thread.Sleep(100);

                    if (_kbhit() != 0)
                    {
                        char c = Console.ReadKey(true).KeyChar;
                        if (c == 'q')
                        {
                            isRunning = false;
                        }
                    }
                }
                CleanupBeforeExiting();
            }
        }
        public void run()
        {
            using (_vhmsgClient = new VHMsg.Client())
            {
                _vhmsgClient.OpenConnection();

                switch (_type)
                {
                    case DM_TYPE.RULE_BASED:
                        {
                            _vhmsgClient.MessageEvent += new VHMsg.Client.MessageEventHandler(MessageActionRuleBased);
                            break;
                        }
                    case DM_TYPE.REINFORCEMENT_LEARNING:
                        {
                            runRL();
                            break;
                        }
                    default:
                        {
                            Console.WriteLine("Error! Unknown Rapport Manager Type: " + _type);
                            break;
                        }
                }

                for (int i = 0; i < _subscribedMessages.Length; i++)
                {
                    _vhmsgClient.SubscribeMessage(_subscribedMessages[i]);
                }

                //Announce availability
                _vhmsgClient.SendMessage("vrComponent RapportManager all");

                //Log user in
                _vhmsgClient.SendMessage("vrGlobalData " + _agentID + " login " + _userName);

                //Suspend self, message-halding thread will take over
                print(_type.ToString() + " listening for incoming messages...");

                while (Win32Interop._kbhit() == 0) { }
            }
        }
Exemplo n.º 10
0
        public void Run()
        {
            bool   runSingleMessage = false;
            string singleMessage    = "";

            string[] args = Environment.GetCommandLineArgs();

            for (int i = 1; i < args.Length; i++)
            {
                if (args[i] == "-m" || args[i] == "-M" ||
                    args[i] == "/m" || args[i] == "/M")
                {
                    if (i + 1 < args.Length)
                    {
                        runSingleMessage = true;
                        singleMessage    = args[i + 1];
                    }
                }
            }

            if (runSingleMessage)
            {
                using (m_vhmsg = new VHMsg.Client())
                {
                    m_vhmsg.OpenConnection();

                    m_vhmsg.SendMessage(singleMessage);
                }

                return;
            }



            m_addTextLineDelegate   = new AddTextLineDelegate(AddLineInvoke);
            m_addLineTimer          = new Timer();
            m_addLineTimer.Tick    += new EventHandler(AddLineTimerEvent);
            m_addLineTimer.Interval = 1000;
            m_addLineTimer.Start();

            m_form = new Form1(this);


            if (File.Exists("history.txt"))
            {
                StreamReader historyReader = new StreamReader("history.txt");

                string input;
                while ((input = historyReader.ReadLine()) != null)
                {
                    m_form.comboBox1.Items.Add(input);
                }

                historyReader.Close();
                historyReader = null;
            }


            if (m_form.comboBox1.Items.Count > 0)
            {
                m_form.comboBox1.Text = (string)m_form.comboBox1.Items[0];
            }
            else
            {
                m_form.comboBox1.Text = "";
            }


            using (m_vhmsg = new VHMsg.Client())
            {
                m_vhmsg.OpenConnection();

                Console.WriteLine("VHMSG_SERVER: {0}", m_vhmsg.Server);
                Console.WriteLine("VHMSG_SCOPE: {0}", m_vhmsg.Scope);

                m_form.label8.Text = string.Format("VHMSG_SERVER: {0}", m_vhmsg.Server);
                m_form.label9.Text = string.Format("VHMSG_SCOPE: {0}", m_vhmsg.Scope);

                m_vhmsg.MessageEvent += new VHMsg.Client.MessageEventHandler(MessageAction);
                m_vhmsg.SubscribeMessage("*");

                m_vhmsg.SendMessage("vrComponent elsender all");


                Application.Run(m_form);


                m_vhmsg.SendMessage("vrProcEnd elsender");

                try
                {
                    using (StreamWriter history = new StreamWriter("history.txt"))
                    {
                        for (int i = 0; i < m_form.comboBox1.Items.Count; i++)
                        {
                            history.WriteLine((string)m_form.comboBox1.Items[i]);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error writing to history file.  " + e);
                }
            }
        }