예제 #1
0
 public void Stop()
 {
     if (MemoryCache.Default.Contains(ServiceCacheName))
     {
         RadioRelayService service = (RadioRelayService)MemoryCache.Default.Get(ServiceCacheName);
         service.Stop();
         MemoryCache.Default.Remove(ServiceCacheName);
     }
 }
예제 #2
0
 public int BatteryLevel([FromBody] DroneBattery battery)
 {
     if (MemoryCache.Default.Contains(ServiceCacheName))
     {
         RadioRelayService service = (RadioRelayService)MemoryCache.Default.Get(ServiceCacheName);
         return(service.GetBatteryLevel(battery));
     }
     else
     {
         return(0);
     }
 }
예제 #3
0
 public bool IsRunning()
 {
     if (MemoryCache.Default.Contains(ServiceCacheName))
     {
         // Make this more robust to send a message to the Teensy to ask if it's running.
         RadioRelayService service = (RadioRelayService)MemoryCache.Default.Get(ServiceCacheName);
         return(service.IsRelayConnected());
     }
     else
     {
         return(false);
     }
 }
예제 #4
0
 public void Start(int comId)
 {
     if (!MemoryCache.Default.Contains(ServiceCacheName))
     {
         try
         {
             RadioRelayService service = new RadioRelayService(comId);
             service.Start();
             MemoryCache.Default.Add(ServiceCacheName, service, DateTime.Now.AddYears(1));
         }
         catch { }
     }
 }