/// <summary> /// Create an instance of a QsysCore /// </summary> /// <param name="deviceAddresses">The hostnames or ip addresses of the core(s)</param> /// <param name="port">Override the default TCP port of 1710</param> /// <param name="name"></param> public QsysCore(IList <string> deviceAddresses, string name, int port) { _name = name; try { _socket = new QsysSocket(deviceAddresses, port, name); _socket.StatusChanged += (client, status) => { _initialized = status != SocketStatus.SOCKET_STATUS_CONNECTED; DeviceCommunicating = status == SocketStatus.SOCKET_STATUS_CONNECTED; }; _socket.RequestReceived += SocketOnRequestReceived; _socket.ResponseReceived += SocketOnResponseReceived; CloudLog.Debug("{0} instance created with address(es) \"{1}\" port {2}", GetType().Name, String.Join(",", deviceAddresses.ToArray()), port); CrestronConsole.AddNewConsoleCommand(parameters => DefaultChangeGroup.Invalidate(), "QSysUpdateAll", "Invalidate the default change group in the core", ConsoleAccessLevelEnum.AccessOperator); } catch (Exception e) { CloudLog.Error("Error in {0}.ctor(), {1}", GetType().Name, e.Message); } }
private object InitalizeProcess() { CloudLog.Debug("{0} Initializing has started...", GetType().Name); var sw = new Stopwatch(); sw.Start(); if (!string.IsNullOrEmpty(_username)) { var logonResponse = Request("Logon", new { User = _username, Password = _password }); Debug.WriteSuccess(GetType().Name + " Login Response", logonResponse); } if (_components.Count == 0) { CloudLog.Debug("{0} has no component details... requesting...", GetType().Name); var response = Request("Component.GetComponents", null); CloudLog.Debug("QsysCore has received list of user defined components, count = {0}", response.Result.Children().Count()); foreach (var component in response.Result.Children()) { CloudLog.Debug("QsysCore has compononent \"{0}\"", component["Name"].Value <string>()); } foreach (var component in response.Result.Children() .Where(c => _userDefinedComponentNames.Contains(c["Name"].Value <string>()))) { var name = component["Name"].Value <string>(); if (_components.ContainsKey(name)) { continue; } switch (component["Type"].Value <string>()) { case "audio_file_player": _components[name] = new AudioFilePlayer(this, component); break; case "mixer": _components[name] = new Mixer(this, component); break; case "system_mute": case "gain": _components[name] = new Gain(this, component); break; case "scriptable_controls": _components[name] = new ScriptableControls(this, component); break; case "snapshot_controller": _components[name] = new SnapshotController(this, component); break; case "softphone": _components[name] = new SoftPhone(this, component); break; case "pots_control_status_core": _components[name] = new PotsPhone(this, component); break; case "signal_presence": _components[name] = new SignalPresence(this, component); break; case "sine": _components[name] = new Sine(this, component); break; case "router_with_output": _components[name] = new RouterWithOutput(this, component); break; case "io_status": _components[name] = new IoStatus(this, component); break; default: _components[name] = new GenericComponent(this, component); break; } } } else { CloudLog.Debug("{0} has component details... updating...", GetType().Name); foreach (var component in this) { component.UpdateAsync(); } } _initialized = true; sw.Stop(); CloudLog.Debug("{0} has initialized, process time = {1}", GetType().Name, sw.Elapsed); OnHasIntitialized(this); DefaultChangeGroup.PollAuto(1.0); return(null); }