Наследование: LCM.LCM.LCMEncodable
Пример #1
0
 public void MessageReceived(LCM.LCM lcm, string channel, LCMDataInputStream ins)
 {
     if (channel == "HALLWAY_TEMPERATURE")
     {
         try
         {
             temperature_t temp = new temperature_t(ins);
             Console.WriteLine("The temperature is: " + temp.deg_celsius);
         }
         catch (System.IO.IOException ex)
         {
             Console.Error.WriteLine("Error decoding temperature message: " + ex);
         }
     }
 }
Пример #2
0
        public static void Main(string[] args)
        {
            LCM.LCM myLCM = LCM.LCM.Singleton;

            while (true)
            {
                try
                {
                    temperature_t temp = new temperature_t();
                    temp.utime = DateTime.Now.Ticks / 10;
                    temp.deg_celsius = 25.0 + 5 * Math.Sin(DateTime.Now.Ticks / 10000000.0);

                    myLCM.Publish("HALLWAY_TEMPERATURE", temp);

                    System.Threading.Thread.Sleep(1000);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("Ex: " + ex);
                }
            }
        }