Esempio n. 1
0
        public static void Main(string[] argv)
        {
            UtopiaClient utopiaClient = new UtopiaClient();

            while (!utopiaClient.isConnected())
            {
                try {
                    //utopiaClient.connect("localhost", Constants.DEFAULTPORT);
                    utopiaClient.autoconnect();
                }
                catch (System.Net.Sockets.SocketException ex) {
                    Console.WriteLine("Could not connect to server.  waiting");
                    System.Threading.Thread.Sleep(1000);
                }
            }

            //  initialize the time-lock
            utopiaClient.initClockAlign();

            // set the debug mode
            if (argv.Length > 0)
            {
                sendTestMessages(utopiaClient, 0);
            }
            else
            {
                utopiaClient.run();
            }
        }
Esempio n. 2
0
        private static void sendTestMessages(UtopiaClient utopiaClient, int offset)
        {
            //  write some test messages..
            int[] objIDs = new int[10];
            for (int i = 0; (i < objIDs.Length); i++)
            {
                objIDs[i] = i;
            }

            int[] objState = new int[objIDs.Length];
            //  send some test StimulusEvents
            for (int i = 0; (i < 5); i++)
            {
                for (int j = 0; (j < objState.Length); j++)
                {
                    objState[j] = (i + offset);
                }

                StimulusEvent e = new StimulusEvent(utopiaClient.getTimeStamp(), objIDs, objState);
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                try {
                    utopiaClient.sendMessage(e);
                }
                catch (IOException ex) {
                    Console.WriteLine(ex);
                }

                System.Threading.Thread.Sleep(1000);
            }

            {
                //  PREDICTEDTARGETPROB
                PredictedTargetProb e = new PredictedTargetProb(utopiaClient.getTimeStamp(), 1, ((float)(0.99)));
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }

            {
                //  PREDICTEDTARGETDIST
                PredictedTargetDist e = new PredictedTargetDist(utopiaClient.getTimeStamp(), new int[] { 1, 2, 3 }, new float[] { .1f, .2f, .3f });
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            {
                //  HEARTBEAT V.2.0
                Heartbeat e = new Heartbeat(utopiaClient.getTimeStamp(), "TestMessage");
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            // LOG
            {
                Log e = new Log(utopiaClient.getTimeStamp(), "ClientTest");
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            {
                //  MODECHANGE
                ModeChange e = new ModeChange(utopiaClient.getTimeStamp(), "ClientTest");
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            {
                //  RESET
                Reset e = new Reset(utopiaClient.getTimeStamp());
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            {
                //  NEWTARGET
                NewTarget e = new NewTarget(utopiaClient.getTimeStamp());
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
        }