public void Control(string changerKey, string command) { try { _ = discChangerService.Changer(changerKey).Control(command); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Exception from control " + changerKey + '/' + command + ": " + e); } }
public async Task <IActionResult> OnGetDiscsToScanAsync(string changerKey) { try { var t = await discChangerService.Changer(changerKey).GetDiscsToScan(); return(new JsonResult(new { discsToScan = t.Item1, emptySlots = t.Item2 })); } catch (Exception e) { return(StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status500InternalServerError, e.Message)); } }
private void updateModel(string Key) { DiscChanger.Models.DiscChanger discChanger = null; if (Key != null) { discChanger = discChangerService.Changer(Key); Name ??= discChanger.Name; Type ??= discChanger.Type; Connection ??= discChanger.Connection; CommandMode ??= discChanger.CommandMode; PortName ??= discChanger.PortName; NetworkHost ??= discChanger.NetworkHost; NetworkPort ??= discChanger.NetworkPort; HardwareFlowControl ??= discChanger.HardwareFlowControl?.ToString(); } switch (Type) { case DiscChangerSonyDVD.DVP_CX777ES: CommandMode = null; Connection = DiscChanger.Models.DiscChanger.CONNECTION_SERIAL_PORT; ConnectionTypes = new string[] { DiscChanger.Models.DiscChanger.CONNECTION_SERIAL_PORT }; break; case DiscChangerSonyBD.BDP_CX7000ES: CommandMode ??= DiscChangerSonyBD.CommandModes[0]; Connection ??= DiscChanger.Models.DiscChanger.CONNECTION_SERIAL_PORT; ConnectionTypes = new string[] { DiscChanger.Models.DiscChanger.CONNECTION_SERIAL_PORT, DiscChanger.Models.DiscChanger.CONNECTION_NETWORK }; break; } SerialPortNames = null; if (Connection == DiscChanger.Models.DiscChanger.CONNECTION_SERIAL_PORT) { HardwareFlowControl ??= "true"; SerialPortNames = Array.FindAll(SerialPort.GetPortNames(), p => discChangerService.DiscChangers.All(dc => dc == discChanger || dc.PortName != p)); } else if (Connection == DiscChanger.Models.DiscChanger.CONNECTION_NETWORK) { NetworkPort ??= 6001; SerialPortNames = null; } }