private void SourceButtonsOnButtonEvent(IButton button, ButtonEventArgs args) { if (args.EventType != ButtonEventType.Released) { return; } try { if (args.CollectionKey == 3 && Room.OtherRooms.Count > 0 && Room.OtherRooms.First().Source != null) { Room.Source = Room.OtherRooms.First().Source; return; } Room.Source = Room.Sources.ElementAt((int)args.CollectionKey - 1); } catch (ArgumentOutOfRangeException) { } catch (Exception e) { CloudLog.Exception(e); } }
private void CountStep(object userSpecific) { _secondsCount++; if (_timeOutTime == 0) { return; } if (_secondsCount < _timeOutTime) { return; } _view.Hide(); if (_callback == null) { return; } try { _callback(UIActionSheetResponseType.TimedOut, new UIActionSheetResponseArgs()); } catch (Exception e) { CloudLog.Exception(e); } }
public void RegisterParameter(string paramName) { if (_parameterInfo.ContainsKey(paramName)) { try { var xTotal = int.Parse(_parameterInfo[paramName][0]); var yTotal = int.Parse(_parameterInfo[paramName][1]); for (int x = 0; x < xTotal; x++) { for (int y = 0; y < yTotal; y++) { Send("get {0} {1} {2}", paramName, x, y); } } } catch (Exception e) { CloudLog.Exception(e); } } else { throw new Exception(string.Format("Unknown parameter \"{0}\"", paramName)); } }
protected override void WillShow() { base.WillShow(); _inputListButtons.ButtonEvent += InputListButtonsOnButtonEvent; _outputListButtons.ButtonEvent += OutputListButtonsOnButtonEvent; _takeButton.ButtonEvent += TakeButtonOnButtonEvent; _cancelButton.ButtonEvent += CancelButtonOnButtonEvent; _switcher.Chassis.DMInputChange += ChassisOnDmInputChange; try { //UpdateSyncStatusFeedback(); } catch (Exception e) { CloudLog.Exception(e); } UpdateLists(ConfigManager.Config.SwitcherConfig); if (_updateFeedbackThread != null && _updateFeedbackThread.ThreadState == Thread.eThreadStates.ThreadRunning) { return; } _updateFeedbackThread = new Thread(UpdateFeedbackProcess, null) { Priority = Thread.eThreadPriority.LowestPriority, Name = "Routing UI Feedback Process" }; }
protected virtual void OnDeviceCommunicatingChange(IDevice device, bool communicating) { var handler = DeviceCommunicatingChange; if (handler == null) { return; } try { if (communicating) { CloudLog.Notice("{0}.DeviceCommunicating = {1}", GetType().Name, true); } else { CloudLog.Warn("{0}.DeviceCommunicating = {1}", GetType().Name, false); } handler(device, communicating); } catch (Exception e) { CloudLog.Exception(e); } }
/// <summary> /// Creates a base class for subpage reference list items /// </summary> /// <param name="list">The subpage list</param> /// <param name="index">The index of the item</param> internal UIDynamicButtonListItem(UIDynamicButtonList list, uint index) : base(list.SmartObject) { try { _list = list; _index = index; VisibleJoin = list.SmartObject.BooleanInput[string.Format("Item {0} Visible", index)]; EnableJoin = list.SmartObject.BooleanInput[string.Format("Item {0} Enabled", index)]; var boolInputSig = list.SmartObject.BooleanInput[string.Format("Item {0} Selected", index)]; var boolOutputSig = list.SmartObject.BooleanOutput[string.Format("Item {0} Pressed", index)]; _iconAnalogSig = list.SmartObject.UShortInput[string.Format("Set Item {0} Icon Analog", index)]; _iconSerialSig = list.SmartObject.StringInput[string.Format("Set Item {0} Icon Serial", index)]; var nameStringSig = list.SmartObject.StringInput[string.Format("Set Item {0} Text", index)]; _button = new UIButton(list.SmartObject, boolOutputSig.Name, boolInputSig.Name, nameStringSig.Name); } catch (Exception e) { CloudLog.Exception(e); } }
protected virtual void OnStatusChanged(CodecApiElement element, string[] propertyNamesWhichUpdated) { #if DEBUG foreach (var name in propertyNamesWhichUpdated) { try { var f = GetFieldWithAttributeName(name); if (f != null) { Debug.WriteInfo(_apiNameSpace, "{0} = {1}", name, f.GetValue(this).ToString()); } } catch (Exception e) { Debug.WriteWarn(_apiNameSpace, "Could not get value for debug on property: {0}, {1}", name, e.Message); } } #endif if (StatusChange == null) { return; } try { StatusChange(this, propertyNamesWhichUpdated); } catch (Exception e) { CloudLog.Exception(e); } }
public FireAlarmMonitorSystem(CrestronControlSystem controlSystem) : base(controlSystem) { try { if (controlSystem.NumberOfVersiPorts > 0) { controlSystem.VersiPorts[1].Register(); _fireAlarmMonitor = new FireAlarmMonitor(9002, 20, controlSystem.VersiPorts[1]); return; } if (controlSystem.NumberOfDigitalInputPorts > 0) { controlSystem.DigitalInputPorts[1].Register(); _fireAlarmMonitor = new FireAlarmMonitor(9002, 20, controlSystem.DigitalInputPorts[1]); return; } CloudLog.Error("Could not setup fire alarm interface! No io ports available"); } catch (Exception e) { CloudLog.Exception(e); } }
internal void HandleError(OnHttpRequestArgs args, int code, string title, string message) { //#if DEBUG CloudLog.Warn("Webserver Error {0}, {1}, Path: {2}\r\n{3}", code, title, args.Request.Path, message); //#endif try { var errorTemplate = new TemplateEngine(Assembly.GetExecutingAssembly(), "WebApp.Templates.error.html", "Error" + code, false); errorTemplate.Context.Add("error_code", code.ToString()); errorTemplate.Context.Add("error_title", title); errorTemplate.Context.Add("error_message", message); errorTemplate.Context["page_style_link"] = @"<link href=""/static/lib2/css/error.css"" rel=""stylesheet"">"; args.Response.Code = code; args.Response.ResponseText = title; args.Response.Header.ContentType = "text/html"; args.Response.ContentSource = ContentSource.ContentString; args.Response.ContentString = errorTemplate.Render(); } catch (Exception e) { CloudLog.Exception(e); } try { //args.Response.FinalizeHeader(); } catch (Exception e) { CloudLog.Exception(e); } }
internal CodecResponse(CodecRequest request, HttpsClientResponse response) { _request = request; _response = response; if (_response.ContentLength == 0) { return; } try { #if DEBUG Debug.WriteNormal(Debug.AnsiBlue + _xml + Debug.AnsiReset); #endif if (response.Code == 200) { var reader = new XmlReader(response.ContentString); _xml = XDocument.Load(reader); } } catch (Exception e) { CloudLog.Exception(e, "Error parsing xml document from codec"); } }
public void TryParseMacAddressFromConfigString(SourceConfig config) { if (string.IsNullOrEmpty(config.DeviceAddressString)) { return; } if (config.DeviceAddressString.Length != 6) { return; } try { _usbExtenderMacAddress = new byte[3]; for (int i = 0; i < 6; i = i + 2) { var byteString = config.DeviceAddressString.Substring(i, 2); var b = Byte.Parse(byteString, NumberStyles.HexNumber); _usbExtenderMacAddress[i / 2] = b; } } catch (Exception e) { CloudLog.Exception(e); } }
private static void GetChannelsCallback(int requestId, HttpClientResponse response) { if (ChannelResponseCallbacks.ContainsKey(requestId)) { var callback = ChannelResponseCallbacks[requestId]; ChannelResponseLock.Enter(); ChannelResponseCallbacks.Remove(requestId); ChannelResponseLock.Leave(); if (response.Code != 200) { callback(false, null); return; } try { var json = JToken.Parse(response.ContentString); var channels = json["result"].Select(item => new Channel(item)); callback(true, channels); } catch (Exception e) { CloudLog.Exception(e); callback(false, null); } } }
private object UpdateFeedback(OneBeyond selectedProcessor) { if (selectedProcessor == null) { return(null); } try { selectedProcessor.GetRoomConfigs(); selectedProcessor.GetCurrentRoomConfig(); selectedProcessor.GetAutoSwitchStatus(); selectedProcessor.GetLayouts(); selectedProcessor.GetCurrentLayout(); selectedProcessor.GetAutoSwitchStatus(); selectedProcessor.GetCameraStatus(); selectedProcessor.GetRecordStatus(); selectedProcessor.GetRecordingSpace(); selectedProcessor.GetStreamStatus(); selectedProcessor.GetIsoRecordStatus(); } catch (Exception e) { CloudLog.Exception(e); } return(null); }
public void Connect() { if (_client != null && _client.IsConnected) { CloudLog.Warn("{0} already connected", GetType().Name); return; } _reconnect = true; var info = new KeyboardInteractiveConnectionInfo(_address, _port, _username); info.AuthenticationPrompt += OnPasswordPrompt; _client = new SshClient(info); _client.ErrorOccurred += (sender, args) => CloudLog.Exception(args.Exception, "SshClient.ErrorOccurred Event"); _client.HostKeyReceived += (sender, args) => CloudLog.Notice("{0} HostKeyReceived: {1}, can trust = {2}", GetType().Name, args.HostKeyName, args.CanTrust); _sshProcess = new Thread(SshCommsProcess, null, Thread.eThreadStartOptions.CreateSuspended) { Name = "CodecSshClient Comms Handler", Priority = Thread.eThreadPriority.MediumPriority }; _sshProcess.Start(); }
private object SendBufferProcess(object o) { while (true) { try { var bytes = _txQueue.Dequeue(); if (bytes == null) { CloudLog.Notice("Exiting {0}", Thread.CurrentThread.Name); return(null); } #if DEBUG Debug.WriteInfo("Samsung Tx", Debug.AnsiPurple + Tools.GetBytesAsReadableString(bytes, 0, bytes.Length, false) + Debug.AnsiReset); #endif _comPort.Send(bytes, bytes.Length); CrestronEnvironment.AllowOtherAppsToRun(); Thread.Sleep(10); } catch (Exception e) { if (e.Message != "ThreadAbortException") { CloudLog.Exception(string.Format("{0} - Exception in tx buffer thread", GetType().Name), e); } } } }
protected virtual void OnRoomSourceChange(RoomBase room, RoomSourceChangeEventArgs args) { if (room != Room || !System.Booted) { return; } try { if (SourceChange != null) { SourceChange(room, args); } } catch (Exception e) { CloudLog.Exception(e); } if (args.NewSource != null) { UIShouldShowSource(args.NewSource); } else { UIShouldShowHomePage(ShowHomePageEventType.OnClearingSource); } }
protected virtual void OnSourceChange(SourceBase source) { CloudLog.Debug("{0} set to Source: {1}", this, source != null ? source.ToString() : "None"); if (source == null || _displayDevice == null) { return; } if (!_displayDevice.Power) { CloudLog.Debug("{0} Power set to On!", this); _displayDevice.Power = true; } try { if (Room != null && Room.GetDisplayInputOverrideForSource(this, source) != DisplayDeviceInput.Unknown) { RouteSourceDisplayDeviceInput(Room.GetDisplayInputOverrideForSource(this, source)); } else if (source.DisplayDeviceInput != DisplayDeviceInput.Unknown) { RouteSourceDisplayDeviceInput(source.DisplayDeviceInput); } } catch (Exception e) { CloudLog.Exception(e, "Error setting input for display"); } }
public UITabBar(UIControllerWithSmartObjects uiController, SmartObject smartObject) { _uiController = uiController; _smartObject = smartObject; CloudLog.Debug("{0}.ctor for SmartObject ID: {1}", GetType(), smartObject.ID); try { var count = 1U; while (true) { var name = string.Format("Tab Button {0} Press", count); if (_smartObject.BooleanOutput.Contains(name)) { Buttons[count] = new UIButton(_smartObject, name, string.Format("Tab Button {0} Select", count)); count++; } else { break; } } CloudLog.Debug("{0} for SmartObject ID: {1} contains {2} items", GetType(), smartObject.ID, Buttons.Count); } catch (Exception e) { CloudLog.Exception(e, "Error in {0}.ctor, {1}", GetType().Name, e.Message); } }
protected virtual void OnStatusChanged(TCPClient mytcpclient, SocketStatus clientsocketstatus) { var handler = StatusChanged; if (handler != null) { try { #if DEBUG if (clientsocketstatus == SocketStatus.SOCKET_STATUS_CONNECTED) { Debug.WriteSuccess(GetType().Name + " Connected", "IP: " + mytcpclient.AddressClientConnectedTo); } else { Debug.WriteWarn(GetType().Name, "Socket status = " + clientsocketstatus); } #endif handler(mytcpclient, clientsocketstatus); } catch (Exception e) { CloudLog.Exception(e); } } }
private void SocketOnResponseReceived(QsysSocket socket, QsysResponse response) { #if DEBUG //CloudLog.Debug("{0}.SocketOnResponseReceived(), ID = {1}{2}", GetType().Name, response.Id, // response.IsError ? string.Format(", Error: {0}", response.ErrorMessage) : " OK"); #endif if (_awaitingEvents.ContainsKey(response.Id)) { #if DEBUG //CrestronConsole.PrintLine("Found awaiting CEvent for response ID {0}", response.Id); #endif _awaitingResponsesLocked.Enter(); _awaitingResponses[response.Id] = response; _awaitingResponsesLocked.Leave(); _awaitingEvents[response.Id].Set(); return; } if (!_awaitingAsyncRequests.ContainsKey(response.Id)) { return; } try { _awaitingAsyncRequests[response.Id](response); } catch (Exception e) { CloudLog.Exception(e); } _awaitingAsyncRequestsLocked.Enter(); _awaitingAsyncRequests.Remove(response.Id); _awaitingAsyncRequestsLocked.Leave(); }
object ReceiveBufferProcess(object obj) { var bytes = new Byte[1000]; var byteIndex = 0; while (true) { try { var b = _rxQueue.Dequeue(); if (_programStopping) { return(null); } if (b == 'x') { var copiedBytes = new byte[byteIndex]; Array.Copy(bytes, copiedBytes, byteIndex); #if DEBUG //CrestronConsole.Print("LG Rx: "); //Tools.PrintBytes(copiedBytes, 0, copiedBytes.Length, true); #endif if (ReceivedData != null) { try { ReceivedData(copiedBytes); } catch (Exception e) { CloudLog.Exception(e); } } byteIndex = 0; } else { bytes[byteIndex] = b; byteIndex++; } } catch (Exception e) { if (e.Message != "ThreadAbortException") { #if DEBUG //CrestronConsole.Print("Error in Lg Rx Handler: "); //Tools.PrintBytes(bytes, 0, byteIndex); #endif CloudLog.Exception(string.Format("{0} - Exception in rx thread", GetType().Name), e); } } CrestronEnvironment.AllowOtherAppsToRun(); Thread.Sleep(0); } }
void OnReceive(string receivedString) { var match = Regex.Match(receivedString, @"^mute near (off|on)"); if (!match.Success) { return; } var muted = match.Groups[1].Value == "on"; if (_muted == muted) { return; } _muted = muted; if (MuteChange == null) { return; } try { MuteChange(_muted); } catch (Exception e) { CloudLog.Exception(e); } }
private void AmOnOnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) { if (!args.DeviceOnLine) { CloudLog.Warn("{0} is offline!", currentDevice.ToString()); } if (args.DeviceOnLine && currentDevice is AmX00) { try { ((AmX00)currentDevice).DisplayControl.DisableAutomaticRouting(); } catch (Exception e) { CloudLog.Exception(e); } } try { if (DeviceCommunicatingChange != null) { DeviceCommunicatingChange(this, args.DeviceOnLine); } } catch (Exception e) { CloudLog.Exception(e); } }
internal QsysRequest(JToken data) { try { if (data["method"] != null) { Method = data["method"].Value <string>(); if (data["id"] != null) { Id = data["id"].Value <int>(); } if (data["params"] != null) { Args = data["params"]; } return; } CloudLog.Error("Error processing {0} from data string", GetType().Name); } catch (Exception e) { CloudLog.Exception(e); } }
internal void QueueRequest(ServerRequest request) { RequestQueue.Enqueue(request); if (_dispatchThread != null && _dispatchThread.ThreadState == Thread.eThreadStates.ThreadRunning) { return; } _dispatchThread = new Thread(specific => { #if true Debug.WriteSuccess("AvediaServer", "Launching {0}.DispacthThread, Request Count = {1}", GetType().Name, RequestQueue.Count); Debug.WriteInfo("AvediaServer", "HttpClient Timeout = {0}, TimeoutEnabled = {1}", HttpClient.Timeout, HttpClient.TimeoutEnabled); #endif while (true) { var r = RequestQueue.Dequeue(); if (request == null) { CloudLog.Info("Exiting {0}", Thread.CurrentThread.Name); return(null); } #if true CrestronConsole.PrintLine("{0} {1}", r.RequestType.ToString(), r.Url); if (r.RequestType == RequestType.Post) { CrestronConsole.PrintLine(r.ContentString); } #endif try { var response = HttpClient.Dispatch(r); try { r.Callback(response, HTTP_CALLBACK_ERROR.COMPLETED); } catch (Exception e) { CloudLog.Exception(e); } } catch { r.Callback(null, HTTP_CALLBACK_ERROR.UNKNOWN_ERROR); } CrestronEnvironment.AllowOtherAppsToRun(); } }, null) { Name = "Avedia HTTP dispatch process" }; }
internal void FusionRegisterInternal() { var ipId = FusionShouldRegister(); try { if (ipId > 0) { IpIdFactory.Block(ipId, IpIdFactory.DeviceType.Fusion); Fusion = new FusionRoom(ipId, System.ControlSystem, Name, Guid.NewGuid().ToString()); Fusion.Description = "Fusion for " + Name; Fusion.FusionStateChange += OnFusionStateChange; Fusion.OnlineStatusChange += OnFusionOnlineStatusChange; Fusion.FusionAssetStateChange += FusionOnFusionAssetStateChange; } else { return; } } catch (Exception e) { CloudLog.Exception(e); } try { FusionShouldRegisterUserSigs(); } catch (Exception e) { CloudLog.Exception(e); } try { FusionShouldRegisterAssets(); } catch (Exception e) { CloudLog.Exception(e); } try { var regResult = Fusion.Register(); if (regResult != eDeviceRegistrationUnRegistrationResponse.Success) { CloudLog.Error("Error registering fusion in room {0} with IpId 0x{1:X2}, result = {2}", Id, ipId, regResult); } } catch (Exception e) { CloudLog.Exception(e); } }
private object SourceLoadProcess(object userSpecific) { var sources = userSpecific as SourceBase[]; if (sources == null) { CloudLog.Error("Error in SourceLoadProcess(object userSpecific)"); return(null); } _sourceChangeBusy = true; try { SourceLoadStarted(sources[1]); } catch (Exception e) { CloudLog.Exception(e); } try { SourceLoadProcess(sources[0], sources[1]); } catch (Exception e) { CloudLog.Exception(e, "Error loading source \"{0}\"", sources[1] != null ? sources[1].Name : "None"); } try { if (Fusion != null) { FusionShouldUpdateCoreParameters(); } } catch (Exception e) { CloudLog.Exception(e); } _sourceChangeBusy = false; try { SourceLoadEnded(); } catch (Exception e) { CloudLog.Exception(e); } return(null); }
private void Callback(HttpClientResponse response, HTTP_CALLBACK_ERROR error) { try { if (error != HTTP_CALLBACK_ERROR.COMPLETED) { CloudLog.Warn("Cannot communicate with AvediaServer to discover receivers"); return; } if (response.Code != 200) { CloudLog.Error("{0} HttpResponse = {1}", GetType().Name, response.Code); return; } var data = JArray.Parse(response.ContentString); #if true Debug.WriteInfo(Debug.AnsiPurple + data.ToString(Formatting.Indented) + Debug.AnsiReset); #endif foreach ( var device in data.Where( d => d["type"].Value <string>() == "Media Player" || d["type"].Value <string>() == "Receiver") ) { if (this.Any(d => d.Id == device["id"].Value <string>())) { this[device["id"].Value <string>()].UpdateInfo(device); } else { Receiver receiver = null; try { receiver = new Receiver(_server, device); } catch (Exception e) { CloudLog.Exception(e, "Error loading receiver object from data"); } if (receiver == null) { continue; } _receivers.Add(receiver); OnReceiverDiscovered(receiver, receiver.Id, receiver.Name); } } } catch (Exception e) { CloudLog.Exception(e); } }
internal void InternalRoomPowerOff(PowerOfFEventType eventType) { try { RoomDidPowerOff(eventType); } catch (Exception e) { CloudLog.Exception(e); } }
protected virtual void RouteSourceDisplayDeviceInput(DisplayDeviceInput input) { try { _displayDevice.SetInput(input); } catch (Exception e) { CloudLog.Exception(e, "Error setting display device input"); } }