protected virtual void OnFeedbackReceived(SoundstructureCommandType commandType, string commandModifier, double value) { switch (commandType) { case SoundstructureCommandType.MUTE: _mute = Convert.ToBoolean(value); _muteValueInit = true; OnMuteChange(Muted); break; case SoundstructureCommandType.FADER: switch (commandModifier) { case "min": FaderMin = value; break; case "max": FaderMax = value; break; default: _fader = value; _faderValueInit = true; break; } OnLevelChange(this, Level); break; } }
protected virtual void OnFeedbackReceived(SoundstructureCommandType commandType, string commandModifier, double value) { switch (commandType) { case SoundstructureCommandType.MUTE: _mute = Convert.ToBoolean(value); muteValueInit = true; OnMuteChange(); break; case SoundstructureCommandType.FADER: if (commandModifier == "min") { FaderMin = value; } else if (commandModifier == "max") { FaderMax = value; } else { _Fader = value; faderValueInit = true; } OnFaderChange(); break; } }
void OnValueChange(string name, SoundstructureCommandType commandType, string commandModifier, double value) { ISoundstructureItem item = GetItemForName(name); if (ValueChange != null && item != null) { ValueChange(item, new SoundstructureValueChangeEventArgs(commandType, commandModifier, value)); } }
public bool Set(ISoundstructureItem channel, SoundstructureCommandType type) { string str = string.Format("set {0} \"{1}\"", type.ToString().ToLower(), channel.Name); if (this.Connected) { this.Send(str); return(true); } return(false); }
public bool Set(ISoundstructureItem channel, SoundstructureCommandType type, string value) { var str = string.Format("set {0} \"{1}\" \"{2}\"", type.ToString().ToLower(), channel.Name, value); if (!Connected) { return(false); } Send(str); return(true); }
protected override void OnFeedbackReceived(SoundstructureCommandType commandType, string commandModifier, double value) { switch (commandType) { case SoundstructureCommandType.PHONE_CONNECT: _offHook = Convert.ToBoolean(value); #if DEBUG CrestronConsole.PrintLine("{0} OffHook = {1}", Name, OffHook); #endif break; } base.OnFeedbackReceived(commandType, commandModifier, value); }
public void Get(ISoundstructureItem channel, SoundstructureCommandType type) { string str = string.Format("get {0} \"{1}\"", type.ToString().ToLower(), channel.Name); this.Send(str); if (type == SoundstructureCommandType.FADER) { str = string.Format("get fader min \"{0}\"", channel.Name); this.Send(str); str = string.Format("get fader max \"{0}\"", channel.Name); this.Send(str); } }
protected override void OnFeedbackReceived(SoundstructureCommandType commandType, string commandModifier, double value) { if (commandType == SoundstructureCommandType.PHONE_RING) { #if DEBUG CrestronConsole.PrintLine("{0}.OnFeedbackReceived {1} {2}", GetType().Name, commandType, value); #endif IsRinging = Convert.ToBoolean(value); if (IsRingingChange != null) { IsRingingChange(this); } } base.OnFeedbackReceived(commandType, commandModifier, value); }
protected override void OnFeedbackReceived(SoundstructureCommandType commandType, string commandModifier, double value) { switch (commandType) { case SoundstructureCommandType.PHONE_CONNECT: _OffHook = Convert.ToBoolean(value); if (OffHookChange != null) { OffHookChange(this, _OffHook); } #if DEBUG CrestronConsole.PrintLine("{0} OffHook = {1}", this.Name, OffHook); #endif break; } this.Initialised = true; base.OnFeedbackReceived(commandType, commandModifier, value); }
public SoundstructureValueChangeEventArgs(SoundstructureCommandType commandType, string commmandModifier, double value) { this.CommandType = commandType; this.CommandModifier = commmandModifier; this.Value = value; }
public SoundstructureValueChangeEventArgs(SoundstructureCommandType commandType, double value) { this.CommandType = commandType; this.Value = value; }
public void OnReceive(string receivedString) { #if DEBUG CrestronConsole.PrintLine("Soundstructure Rx: {0}", receivedString); #endif if (!this.DeviceCommunicating) { this.DeviceCommunicating = true; this.FusionUpdate(); if (this.DeviceCommunicatingChanged != null) { this.DeviceCommunicatingChanged(this, true); } } if (receivedString.Contains(' ')) { List <string> elements = SoundstructureSocket.ElementsFromString(receivedString); switch (elements[0]) { case "error": { ErrorLog.Error("Soundtructure received Error: {0}", elements[1]); } break; case "ran": if (PresetRan != null) { PresetRan(this, elements[1]); } break; case "vcitem": // this should be a response from the vclist command which sends back all virtual channels defined try { List <uint> values = new List <uint>(); for (int element = 4; element < elements.Count(); element++) { values.Add(Convert.ToUInt32(elements[element])); } SoundstructurePhysicalChannelType type = (SoundstructurePhysicalChannelType)Enum.Parse(typeof(SoundstructurePhysicalChannelType), elements[3], true); if (type == SoundstructurePhysicalChannelType.VOIP_OUT) { listedItems.Add(new VoipOutChannel(this, elements[1], values.ToArray())); } else if (type == SoundstructurePhysicalChannelType.VOIP_IN) { listedItems.Add(new VoipInChannel(this, elements[1], values.ToArray())); } else if (type == SoundstructurePhysicalChannelType.PSTN_OUT) { listedItems.Add(new AnalogPhoneOutChannel(this, elements[1], values.ToArray())); } else if (type == SoundstructurePhysicalChannelType.PSTN_IN) { listedItems.Add(new AnalogPhoneInChannel(this, elements[1], values.ToArray())); } else { listedItems.Add(new VirtualChannel(this, elements[1], (SoundstructureVirtualChannelType)Enum.Parse(typeof(SoundstructureVirtualChannelType), elements[2], true), type, values.ToArray())); } } catch (Exception e) { ErrorLog.Error("Error parsing Soundstructure vcitem: {0}", e.Message); } break; case "vcgitem": { List <ISoundstructureItem> channels = new List <ISoundstructureItem>(); if (elements.Count() > 2) { for (int e = 2; e < elements.Count(); e++) { if (this.VirtualChannels.Contains(elements[e])) { channels.Add(this.VirtualChannels[elements[e]]); } } VirtualChannelGroup group = new VirtualChannelGroup(this, elements[1], channels); listedItems.Add(group); } else { ErrorLog.Warn("Ignoring Soundstructure group item {0} as it has no members", elements[1]); } } break; case "vcrename": { List <ISoundstructureItem> channels = new List <ISoundstructureItem>(); foreach (VirtualChannel channel in this.VirtualChannels) { if (channel.Name == elements[1]) { VirtualChannel newChannel = new VirtualChannel(this, elements[2], channel.VirtualChannelType, channel.PhysicalChannelType, channel.PhysicalChannelIndex.ToArray()); channels.Add(newChannel); } else { channels.Add(channel); } } this.VirtualChannels = new SoundstructureItemCollection(channels); } break; case "vcgrename": { List <ISoundstructureItem> groups = new List <ISoundstructureItem>(); foreach (VirtualChannelGroup group in this.VirtualChannelGroups) { if (group.Name == elements[1]) { List <ISoundstructureItem> channels = new List <ISoundstructureItem>(); foreach (VirtualChannel channel in group) { channels.Add(channel); } VirtualChannelGroup newGroup = new VirtualChannelGroup(this, elements[2], channels); groups.Add(newGroup); } else { groups.Add(group); } } this.VirtualChannelGroups = new SoundstructureItemCollection(groups); } break; case "val": // this should be a value response from a set or get { try { if (elements[1] == "eth_settings" && elements[2] == "1") { this.LanAdapter = new SoundstructureEthernetSettings(elements[3]); break; } bool commandOK = false; SoundstructureCommandType commandType = SoundstructureCommandType.FADER; try { commandType = (SoundstructureCommandType)Enum.Parse(typeof(SoundstructureCommandType), elements[1], true); commandOK = true; } catch { if (elements[1].StartsWith("voip_") && this.VirtualChannels.Contains(elements[2])) { VirtualChannel channel = this.VirtualChannels[elements[2]] as VirtualChannel; if (channel.IsVoip && VoipInfoReceived != null) { string info = receivedString.Substring(receivedString.IndexOf(channel.Name) + channel.Name.Length + 2, receivedString.Length - receivedString.IndexOf(channel.Name) - channel.Name.Length - 2); VoipInfoReceived(channel, new SoundstructureVoipInfoReceivedEventArgs(elements[1], info)); } } } if (commandOK) { switch (commandType) { case SoundstructureCommandType.MATRIX_MUTE: #if DEBUG CrestronConsole.PrintLine("Matrix Mute Input: \x22{0}\x22 Output: \x22{1}\x22 Value: {2}", elements[2], elements[3], elements[4]); #endif break; case SoundstructureCommandType.FADER: if (elements[2] == "min" || elements[2] == "max") { OnValueChange(elements[3], commandType, elements[2], Convert.ToDouble(elements[4])); } else { OnValueChange(elements[2], commandType, Convert.ToDouble(elements[3])); } break; case SoundstructureCommandType.PHONE_DIAL: // Cannot parse reply for string values and we don't currently need to track this. break; default: if (elements.Count > 3) { OnValueChange(elements[2], commandType, Convert.ToDouble(elements[3])); } break; } if (!Initialized && CheckAllItemsHaveInitialised()) { Initialized = true; ErrorLog.Notice("Soundstructure Initialised"); CrestronConsole.PrintLine("Soundstructure Initialised!"); if (HasInitialised != null) { HasInitialised(this); } } } } catch (Exception e) { ErrorLog.Error("Soundstructure Rx: {0}, Error: {1}", receivedString, e.Message); } } break; default: break; } } else { if (receivedString == "vclist") { this.VirtualChannels = new SoundstructureItemCollection(listedItems); listedItems.Clear(); Socket.Send("vcglist"); } else if (receivedString == "vcglist") { this.VirtualChannelGroups = new SoundstructureItemCollection(listedItems); listedItems.Clear(); foreach (ISoundstructureItem item in VirtualChannelGroups) { item.Init(); } foreach (ISoundstructureItem item in VirtualChannels) { if (!ChannelIsGrouped(item)) { item.Init(); } } } } }
public bool Set(ISoundstructureItem rowChannel, ISoundstructureItem colChannel, SoundstructureCommandType type, bool value) { string str = string.Format("set {0} \"{1}\" \"{2}\" {3}", type.ToString().ToLower(), rowChannel.Name, colChannel.Name, value ? 1 : 0); if (this.Connected) { this.Send(str); return(true); } return(false); }