public void Stop() { if (MemoryCache.Default.Contains(ServiceCacheName)) { RadioRelayService service = (RadioRelayService)MemoryCache.Default.Get(ServiceCacheName); service.Stop(); MemoryCache.Default.Remove(ServiceCacheName); } }
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); } }
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); } }
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 { } } }