Esempio n. 1
1
 public void Start(string[] args)
 {
     registry = new Registry();
     if (!registry.Register(this))
     {
         Console.WriteLine("Error registering service.");
         return;
     }
     Console.WriteLine("Registered service.");
     try
     {
         TcpClient tcpclient = new TcpClient();
         if (args.Count() != 2)
             throw new Exception("Argument must contain a publishing ip and port. call with: 127.0.0.1 12345");
         tcpclient.Connect(args[0], Int32.Parse(args[1]));
         StreamReader sr = new StreamReader(tcpclient.GetStream());
         string data;
         while ((data = sr.ReadLine()) != null)
         {
             Console.WriteLine("Raw data: " + data);
             if (RawAisData != null)
                 RawAisData(data);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message + e.StackTrace);
         Console.WriteLine("Press enter");
         Console.ReadLine();
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Registry registry = new Registry("tcp://*****:*****@"..\..\data.txt");
                    foreach (var data in dummydata)
                    {
                        Console.Clear();
                        AisData? ais = AisToolset.DecodeAis(data);
                        if (ais != null)
                        {
                            AisToolset.DumpAis((AisData)ais);
                            Console.WriteLine(KMLDumperInstance.Call<String>("AddOrUpdateAisTransponder", (AisData)ais));
                        }
                        Thread.Sleep(1000);
                    }
                }
                else
                {
                    TcpClient tcpclient = new TcpClient();
                    tcpclient.Connect("82.210.120.176", 2000);
                    StreamReader sr = new StreamReader(tcpclient.GetStream());
                    string data;
                    while ((data = sr.ReadLine()) != null)
                    {
                        AisData? ais = AisToolset.DecodeAis(data);
                        Console.Clear();
                        if (ais != null)
                        {
                            AisToolset.DumpAis((AisData)ais);
                            Console.WriteLine(KMLDumperInstance.Call<String>("AddOrUpdateAisTransponder", (AisData)ais));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + e.StackTrace);
                Console.WriteLine("Press enter");
                Console.ReadLine();
            }
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            try {
                // Get console quit key press events.
                Console.CancelKeyPress += CancelKeyPressHandler;

                // Sleep so registry and server can start up first.
                Thread.Sleep(1000);

                // Create registry client for registry at address tcp://localhost:5555.
                using(Registry registry = new Registry())
                {
                    // Get HelloWorldResponder service, loop until it exists.
                    Service helloWorld1 = null;
                    while(helloWorld1 == null) helloWorld1 = registry.GetServiceByUID("HelloWorldResponder1");
                    Console.WriteLine("Found HelloWorldResponder1: " + helloWorld1);

                    // Get HelloWorldResponder services, loop until it exists.
                    Service helloWorldAll = null;
                    while(helloWorldAll == null) helloWorldAll = registry.GetServiceByType("HelloWorldResponder");
                    Console.WriteLine("Found HelloWorldResponders: " + helloWorldAll);

                    // Subscribe for published event.
                    helloWorld1.Published += (object obj) => Console.WriteLine("HelloWorldResponder1 published: " + obj);
                    helloWorldAll.Published += (object obj) => Console.WriteLine("HelloWorldResponders published: " + obj);

                    // Program loop
                    while(!_quit) {
                        // Call receive on the objects to receive published messages.
                        // TODO: Optionally let the library take care of this.
                        //helloWorld1.Receive();
                        //helloWorldAll.Receive();
                        registry.Update();
                        //Console.WriteLine(ApplicationInstance.Guid);

                        // RPC HelloWorld function with no parameters and print the result.
                        //Console.WriteLine("RPC call HelloWorld on HelloWorldResponder1: " + helloWorld1.Call<String>("HelloWorld"));
                        //Console.WriteLine("RPC call HelloWorld on HelloWorldResponders: " + helloWorldAll.Call<String>("HelloWorld"));
                        // RPC ReturnParam function with 3 params and print the result.
                        //Console.WriteLine("RPC call ReturnParam on HelloWorldResponder1: " + helloWorld1.Call<String>("ReturnParam", 1, 1.0f, "one"));
                        //Console.WriteLine("RPC call ReturnParam on HelloWorldResponders: " + helloWorldAll.Call<String>("ReturnParam", 1, 1.0f, "one"));

                        Thread.Sleep(100);
                    }

                    // Dispose of service objects to free sockets.
                    helloWorld1.Dispose();
                    helloWorldAll.Dispose();
                }
            } catch(Exception e) {
                Console.WriteLine(e.Message + "\n" + e.StackTrace);
                Thread.Sleep(10000);
            }
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            // Get console quit key press events.
            Console.CancelKeyPress += CancelKeyPressHandler;

            // Create registry client for registry at address tcp://localhost:5555.
            using(Registry registry = new Registry("tcp://localhost:5555")) {
                // Register our hello world responder objects with the registry.
                HelloWorldResponder responder1 = new HelloWorldResponder(1);
                HelloWorldResponder responder2 = new HelloWorldResponder(2);
                HelloWorldResponder responder3 = new HelloWorldResponder(3);

                if(registry.Register("HelloWorldResponder1", responder1))
                    Console.WriteLine("Registered HelloWorldResponder1");
                else {
                    Console.WriteLine("Failed to register HelloWorldResponder 1");
                    return;
                }
                if(registry.Register("HelloWorldResponder2", responder2))
                    Console.WriteLine("Registered HelloWorldResponder2");
                else {
                    Console.WriteLine("Failed to register HelloWorldResponder2");
                    return;
                }
                if(registry.Register("HelloWorldResponder3", responder3))
                    Console.WriteLine("Registered HelloWorldResponder3");
                else {
                    Console.WriteLine("Failed to register HelloWorldResponder3");
                    return;
                }

                // Program loop
                while(!_quit) {
                    // Emit an event in the service.
                    responder1.SomethingHappened();
                    responder3.SomethingHappened();

                    // Receive RPC calls
                    // TODO: Optionally let the library take care of this.
                    registry.Update();

                    Thread.Sleep(100);
                }
            }
        }
Esempio n. 5
0
 public void Start()
 {
     registry = new Registry();
     if (!registry.Register(this))
     {
         Console.WriteLine("Error registering service.");
         return;
     }
     Console.WriteLine("Registered service.");
     Service rawDataPublisher = null;
     while (rawDataPublisher == null && !quit)
         rawDataPublisher = registry.GetServiceByType("RawAisDataPublisher");
     if (!quit)
         rawDataPublisher.Published += RAWAisDataRecieved;
     while (!quit)
         registry.Update();
     registry.Unregister(this);
 }
Esempio n. 6
0
 static void Main(string[] args)
 {
     registry = new Registry();
     Service rawDataPublisher = null;
     while (rawDataPublisher == null && !quit)
         rawDataPublisher = registry.GetServiceByType("RawAisDataPublisher");
     rawDataPublisher.Published += publishedEvent;
     while (!quit)
     {
         Console.Clear();
         Console.WriteLine("Total messages: " + TotalCount);
         Console.WriteLine("Total messages OK: " + OKCount);
         Console.WriteLine("Total messages Multipart: " + MultiPartCount);
         Console.WriteLine("Total messages Failed: " + FailCount);
         Console.WriteLine("");
         Console.WriteLine("Pecentage OK: " + (((double)OKCount / (double)TotalCount))*100);
         Thread.Sleep(100);
         registry.Update();
     }
 }
Esempio n. 7
0
 static void Main(string[] args)
 {
     testKML = new GoogleEarthKMLDumper();
     Console.CancelKeyPress += CancelKeyPressHandler;
     Registry registry = new Registry();
     Service aisDataPublisher = null;
     while (aisDataPublisher == null && !quit)
         aisDataPublisher = registry.GetServiceByType("AisDataPublisher");
     aisDataPublisher.Published += publishedEvent;
     int count = 0;
     while (!quit)
     {
         count++;
         if (count > 10)
         {
             count = 0;
             testKML.DumpKMLFile();
         }
         registry.Update();
         Thread.Sleep(100);
     }
 }