public static void LinkToApi(this PepperDash.Essentials.Core.DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey) { int inputNumber = 0; IntFeedback inputNumberFeedback; List <string> inputKeys = new List <string>(); DisplayControllerJoinMap joinMap = new DisplayControllerJoinMap(); var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) { joinMap = JsonConvert.DeserializeObject <DisplayControllerJoinMap>(joinMapSerialized); } joinMap.OffsetJoinNumbers(joinStart); Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); trilist.StringInput[joinMap.Name].StringValue = displayDevice.Name; var commMonitor = displayDevice as ICommunicationMonitor; if (commMonitor != null) { commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); } inputNumberFeedback = new IntFeedback(() => { return(inputNumber); }); // Two way feedbacks var twoWayDisplay = displayDevice as PepperDash.Essentials.Core.TwoWayDisplayBase; if (twoWayDisplay != null) { trilist.SetBool(joinMap.IsTwoWayDisplay, true); twoWayDisplay.CurrentInputFeedback.OutputChange += new EventHandler <FeedbackEventArgs>(CurrentInputFeedback_OutputChange); inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]); } // Power Off trilist.SetSigTrueAction(joinMap.PowerOff, () => { inputNumber = 102; inputNumberFeedback.FireUpdate(); displayDevice.PowerOff(); }); displayDevice.PowerIsOnFeedback.OutputChange += new EventHandler <FeedbackEventArgs>((o, a) => { if (!a.BoolValue) { inputNumber = 102; inputNumberFeedback.FireUpdate(); } else { inputNumber = 0; inputNumberFeedback.FireUpdate(); } }); displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]); // PowerOn trilist.SetSigTrueAction(joinMap.PowerOn, () => { inputNumber = 0; inputNumberFeedback.FireUpdate(); displayDevice.PowerOn(); }); displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); int count = 1; foreach (var input in displayDevice.InputPorts) { inputKeys.Add(input.Key.ToString()); var tempKey = inputKeys.ElementAt(count - 1); trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => { displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector); }); Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[tempKey].Key.ToString()); trilist.StringInput[(ushort)(joinMap.InputNamesOffset + count)].StringValue = input.Key.ToString(); count++; } Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); trilist.SetUShortSigAction(joinMap.InputSelect, (a) => { if (a == 0) { displayDevice.PowerOff(); inputNumber = 0; } else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber) { displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector); inputNumber = a; } else if (a == 102) { displayDevice.PowerToggle(); } if (twoWayDisplay != null) { inputNumberFeedback.FireUpdate(); } }); var volumeDisplay = displayDevice as IBasicVolumeControls; if (volumeDisplay != null) { trilist.SetBoolSigAction(joinMap.VolumeUp, (b) => volumeDisplay.VolumeUp(b)); trilist.SetBoolSigAction(joinMap.VolumeDown, (b) => volumeDisplay.VolumeDown(b)); trilist.SetSigTrueAction(joinMap.VolumeMute, () => volumeDisplay.MuteToggle()); var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; if (volumeDisplayWithFeedback != null) { trilist.SetUShortSigAction(joinMap.VolumeLevel, new Action <ushort>((u) => volumeDisplayWithFeedback.SetVolume(u))); volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel]); volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]); } } }
void IBridgeAdvanced.LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { var joinMap = new TesiraDialerJoinMapAdvancedStandalone(joinStart); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) { joinMap = JsonConvert.DeserializeObject <TesiraDialerJoinMapAdvancedStandalone>(joinMapSerialized); } if (bridge != null) { bridge.AddJoinMap(Key, joinMap); } Debug.Console(2, "Adding Dialer {0}", Key); for (var i = 0; i < joinMap.KeyPadNumeric.JoinSpan; i++) { trilist.SetSigTrueAction((joinMap.KeyPadNumeric.JoinNumber + (uint)i), () => SendKeypad(eKeypadKeys.Num0)); } trilist.SetSigTrueAction((joinMap.KeyPadStar.JoinNumber), () => SendKeypad(eKeypadKeys.Star)); trilist.SetSigTrueAction((joinMap.KeyPadPound.JoinNumber), () => SendKeypad(eKeypadKeys.Pound)); trilist.SetSigTrueAction((joinMap.KeyPadClear.JoinNumber), () => SendKeypad(eKeypadKeys.Clear)); trilist.SetSigTrueAction((joinMap.KeyPadBackspace.JoinNumber), () => SendKeypad(eKeypadKeys.Backspace)); trilist.SetSigTrueAction(joinMap.KeyPadDial.JoinNumber, Dial); trilist.SetSigTrueAction(joinMap.DoNotDisturbToggle.JoinNumber, DoNotDisturbToggle); trilist.SetSigTrueAction(joinMap.DoNotDisturbOn.JoinNumber, DoNotDisturbOn); trilist.SetSigTrueAction(joinMap.DoNotDisturbOff.JoinNumber, DoNotDisturbOff); trilist.SetSigTrueAction(joinMap.AutoAnswerToggle.JoinNumber, AutoAnswerToggle); trilist.SetSigTrueAction(joinMap.AutoAnswerOn.JoinNumber, AutoAnswerOn); trilist.SetSigTrueAction(joinMap.AutoAnswerOff.JoinNumber, AutoAnswerOff); trilist.SetSigTrueAction(joinMap.Answer.JoinNumber, Answer); trilist.SetSigTrueAction(joinMap.EndCall.JoinNumber, EndAllCalls); trilist.SetSigTrueAction(joinMap.OnHook.JoinNumber, OnHook); trilist.SetSigTrueAction(joinMap.OffHook.JoinNumber, OffHook); trilist.SetStringSigAction(joinMap.DialString.JoinNumber, SetDialString); DisplayNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.DisplayNumber.JoinNumber]); NameFeedback.LinkInputSig(trilist.StringInput[joinMap.Label.JoinNumber]); DoNotDisturbFeedback.LinkInputSig(trilist.BooleanInput[joinMap.DoNotDisturbToggle.JoinNumber]); DoNotDisturbFeedback.LinkInputSig(trilist.BooleanInput[joinMap.DoNotDisturbOn.JoinNumber]); DoNotDisturbFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.DoNotDisturbOff.JoinNumber]); OffHookFeedback.LinkInputSig(trilist.BooleanInput[joinMap.KeyPadDial.JoinNumber]); OffHookFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OffHook.JoinNumber]); OffHookFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.OnHook.JoinNumber]); IncomingCallFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IncomingCall.JoinNumber]); AutoAnswerFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoAnswerToggle.JoinNumber]); AutoAnswerFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoAnswerOn.JoinNumber]); AutoAnswerFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.AutoAnswerOff.JoinNumber]); DialStringFeedback.LinkInputSig(trilist.StringInput[joinMap.DialString.JoinNumber]); CallerIdNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.CallerIdNumberFb.JoinNumber]); CallerIdNameFeedback.LinkInputSig(trilist.StringInput[joinMap.CallerIdNameFb.JoinNumber]); LastDialedFeedback.LinkInputSig(trilist.StringInput[joinMap.LastNumberDialerFb.JoinNumber]); CallStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.CallState.JoinNumber]); trilist.OnlineStatusChange += (d, args) => { if (!args.DeviceOnLine) { return; } foreach (var feedback in Feedbacks) { feedback.FireUpdate(); } }; }
/// <summary> /// Calls the extension method to bridge the device to an EiscApi class (SIMPL Bridge) /// </summary> /// <param name="trilist"></param> /// <param name="joinStart"></param> /// <param name="joinMapKey"></param> public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { DisplayControllerJoinMap joinMap = new DisplayControllerJoinMap(joinStart, typeof(DisplayControllerJoinMap)); var JoinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(JoinMapSerialized)) { joinMap = JsonConvert.DeserializeObject <DisplayControllerJoinMap>(JoinMapSerialized); } if (bridge != null) { bridge.AddJoinMap(Key, joinMap); } Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(0, "Linking to Display: {0}", Name); trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; var commMonitor = this as ICommunicationMonitor; if (commMonitor != null) { commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); } InputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); // Two way feedbacks var twoWayDisplay = this as PepperDash.Essentials.Core.TwoWayDisplayBase; if (twoWayDisplay != null) { trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true); twoWayDisplay.CurrentInputFeedback.OutputChange += new EventHandler <FeedbackEventArgs>(CurrentInputFeedback_OutputChange); } // Power Off trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => { PowerOff(); }); PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); // PowerOn trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => { PowerOn(); }); PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); int count = 1; var displayBase = this as PepperDash.Essentials.Core.DisplayBase; foreach (var input in InputPorts) { //displayDevice.InputKeys.Add(input.Key.ToString()); //var tempKey = InputKeys.ElementAt(count - 1); trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + count), () => { ExecuteSwitch(InputPorts[input.Key.ToString()].Selector); }); Debug.Console(2, this, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset.JoinNumber + count, InputPorts[input.Key.ToString()].Key.ToString()); trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + count)].StringValue = input.Key.ToString(); count++; } Debug.Console(2, this, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => { if (a == 0) { PowerOff(); } else if (a > 0 && a < InputPorts.Count) { ExecuteSwitch(InputPorts.ElementAt(a - 1).Selector); } else if (a == 102) { PowerToggle(); } Debug.Console(2, this, "InputChange {0}", a); }); var volumeDisplay = this as IBasicVolumeControls; if (volumeDisplay != null) { trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, (b) => volumeDisplay.VolumeUp(b)); trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, (b) => volumeDisplay.VolumeDown(b)); trilist.SetSigTrueAction(joinMap.VolumeMute.JoinNumber, () => volumeDisplay.MuteToggle()); var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; if (volumeDisplayWithFeedback != null) { volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]); volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]); } } }