public void BypassDevice(int deviceId, int projectId, bool bypass) { var device = dispatcher.Dispatch(DeviceActions.GetDevice(deviceId)); Guard.This(device).AgainstDefaultValue(string.Format("Cannot find device with device id '{0}'", deviceId)); var projectDevice = dispatcher.Dispatch(ProjectDeviceActions.GetProjectDevice(deviceId, projectId)); Guard.This(projectDevice).AgainstDefaultValue(string.Format("Cannot find project device with device id '{0}' and project id '{1}'", deviceId, projectId)); dispatcher.Dispatch(ProjectDeviceActions.BypassDevice(projectDevice.Id, bypass)); }
public ProjectDevicePlaybackStatus GetProjectDevicePlaybackStatus(int deviceId, int projectId) { var device = dispatcher.Dispatch(DeviceActions.GetDevice(deviceId)); Guard.This(device).AgainstDefaultValue(string.Format("Cannot find device with device id '{0}'", deviceId)); var projectDevice = dispatcher.Dispatch(ProjectDeviceActions.GetProjectDevice(deviceId, projectId)); Guard.This(projectDevice).AgainstDefaultValue(string.Format("Cannot find project device with device id '{0}' and project id '{1}'", deviceId, projectId)); if (projectDevice.IsBypassed) { return(ProjectDevicePlaybackStatus.Bypassed); } var deviceClient = clientFactory.ForDevice(device); try { deviceClient.LoadVideo(projectDevice.Id); if (!devicePlaybacks.Any(dp => dp.Client.BaseAddress == deviceClient.BaseAddress)) { devicePlaybacks.Add(new DevicePlayback(projectDevice.Id, deviceClient)); } return(ProjectDevicePlaybackStatus.Ready); } catch (PiApiClientCommunicationException) { return(ProjectDevicePlaybackStatus.NotOnline); } catch (PiApiClientRequestException) { return(ProjectDevicePlaybackStatus.NotReady); } }