コード例 #1
0
        static void Main(string[] args)
        {
            //Rewrite();


            string[] switches = GetSwitches(args);
            if (switches == null)
            {
                WriteInstructions();
                Console.ReadKey();
                return;
            }

            if (switches[0] != null)
            {
                comPort = switches[0];
                runId   = switches[1];
            }
            else
            {
                runId = switches[1];
            }



            Task task = null;

            if (comPort == null)
            {
                //use a Web socket to send
                string           host        = "ws://broker.pegasusmission.io/api/connect";
                string           subprotocol = "coap.v1";
                string           token       = GetSecurityToken();
                TelemetryManager wsTelemetry = new TelemetryManager(host, subprotocol, token);
                Console.WriteLine("Starting telemetry");
                task = wsTelemetry.RunAsync(runId);
                Task.WhenAll(task);
            }
            else
            {
                //use the serial connection to send (test Field Gateway)
                SerialConnection connection = new SerialConnection(comPort, 38400, 8, System.IO.Ports.StopBits.One, System.IO.Ports.Parity.None);
                connection.Open();

                TelemetryManager tm = new TelemetryManager(connection);
                Console.WriteLine("Starting telemetry");
                task = tm.RunAsync(runId);
                Task.WhenAll(task);
            }

            Console.WriteLine("press any key to stop...");
            Console.ReadKey();


            //using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(Properties.Resources.RT_Telemetry_Test)))
            //{

            //    using (StreamReader reader = new StreamReader(stream))
            //    {
            //        while (!reader.EndOfStream)
            //        {
            //            string line = reader.ReadLine();
            //            Thread.Sleep(500);
            //        }

            //        reader.Close();
            //    }
            //    stream.Close();
            //}
        }
コード例 #2
0
 public TelemetryManager(SerialConnection conn)
 {
     this.serial = conn;
 }