protected override void ReceivedNotification(TesiraAttributeCode attributeCode, JToken data) { switch (attributeCode) { case TesiraAttributeCode.Levels: { var values = data["value"] as JArray; uint channel = 0; foreach (var value in values) { channel++; Channels[channel].UpdateValue(TesiraAttributeCode.Level, value); } } break; case TesiraAttributeCode.Mutes: { var values = data["value"] as JArray; uint channel = 0; foreach (var value in values) { channel++; Channels[channel].UpdateValue(TesiraAttributeCode.Mute, value); } } break; } }
protected override void ReceivedNotification(TesiraAttributeCode attributeCode, JToken data) { if (attributeCode == TesiraAttributeCode.SourceSelection) { _sourceSelection = data["value"].Value <uint>(); } }
private void SendSubscribe(string publishToken, TesiraAttributeCode attributeCode) { var message = Tesira.FormatBaseMessage(InstanceTag, TesiraCommand.Subscribe, attributeCode) + " \"" + publishToken + "\" " + 200; Device.Send(message); }
public void Send(string instanceTag, TesiraCommand command, TesiraAttributeCode attributeCode, uint[] indexes) { var message = FormatBaseMessage(instanceTag, command, attributeCode); message = indexes.Aggregate(message, (current, index) => current + " " + index); _client.Send(message); }
protected override void UpdateAttribute(TesiraAttributeCode code, JToken data) { switch (code) { case TesiraAttributeCode.Ganged: Ganged = data["value"].Value <bool>(); break; } }
protected void Subscribe(TesiraAttributeCode attributeCode) { var token = InstanceTag + "_" + attributeCode.ToCommandString(); Subscriptions[token] = attributeCode; if (!Device.DeviceCommunicating) { return; } SendSubscribe(token, attributeCode); }
internal override void UpdateValue(TesiraAttributeCode attributeCode, JToken value) { switch (attributeCode) { case TesiraAttributeCode.Gain: var gain = value.ToObject<double>(); #if DEBUG Debug.WriteSuccess(Name + " new level value = " + _level.ToString("F1")); #endif if (Math.Abs(_level - gain) >= 0.1) { _level = gain; LevelString = _level.ToString("F1") + " dB"; OnLevelChange(this, Level); } break; case TesiraAttributeCode.Level: var level = value.ToObject<double>(); #if DEBUG Debug.WriteSuccess(Name + " new level value = " + _level.ToString("F1")); #endif if (Math.Abs(_level - level) >= 0.1) { _level = level; LevelString = _level.ToString("F1") + " dB"; OnLevelChange(this, Level); } break; case TesiraAttributeCode.Mute: var mute = value.ToObject<bool>(); #if DEBUG Debug.WriteSuccess(Name + " " + (mute ? "Muted" : "Unmuted")); #endif if (mute != _mute) { _mute = mute; OnMuteChange(_mute); } break; } }
protected override void ReceivedNotification(TesiraAttributeCode attributeCode, JToken data) { switch (attributeCode) { case TesiraAttributeCode.CallState: { var callStates = data["value"]["callState"].ToObject <List <CallState> >(); foreach (var line in _channels) { var statesForLine = callStates.Where(c => c.LineId == (line.Key - 1)); line.Value.UpdateCallStates(statesForLine); } } break; case TesiraAttributeCode.DisplayNameLabel: { } break; } }
public void Send(string instanceTag, TesiraCommand command, TesiraAttributeCode attributeCode) { _client.Send(FormatBaseMessage(instanceTag, command, attributeCode)); }
internal static string FormatBaseMessage(string instanceTag, TesiraCommand command, TesiraAttributeCode attributeCode) { return(string.Format("{0} {1} {2}", instanceTag, command.ToString().ToLower(), attributeCode.ToCommandString())); }
internal override void UpdateValue(TesiraAttributeCode attributeCode, JToken value) { }
protected override void ReceivedNotification(TesiraAttributeCode attributeCode, JToken data) { }
protected abstract void UpdateAttribute(TesiraAttributeCode code, JToken data);
internal abstract void UpdateValue(TesiraAttributeCode attributeCode, JToken value);
protected abstract void ReceivedNotification(TesiraAttributeCode attributeCode, JToken data);
public static string ToCommandString(this TesiraAttributeCode attribute) { var str = attribute.ToString(); return(str.Substring(0, 1).ToLower() + str.Substring(1, str.Length - 1)); }
protected override void UpdateAttribute(TesiraAttributeCode code, JToken data) { }