/// <summary> /// 解析移动服务配置相关信息 /// </summary> /// <param name="xdocument"></param> static void GetMobileHelpers(System.Xml.Linq.XDocument xdocument) { //解析普通配置项 xml: Mobile var element = xdocument.Element("items"); if (null == element) { return; } var items = element.Elements("item"); mRadioHelpers = new Dictionary <int[], RadioHelper>(); foreach (var item in items) { var helperItem = new RadioHelper(); Async(item, helperItem); var pattern = item.Element("pattern"); if (pattern != null) { helperItem.Childrens = new List <RadioHelper>(); var patternChildrens = pattern.Elements("item"); foreach (var cd in patternChildrens) { var cdItem = new RadioHelper(); Async(cd, cdItem); helperItem.Childrens.Add(cdItem); } } mRadioHelpers.Add(helperItem.Key, helperItem); } }
private void EncryptionKeySpinner_OnValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (EncryptionKeySpinner?.Value != null) { RadioHelper.SetEncryptionKey(RadioId, (byte)EncryptionKeySpinner.Value); } }
public async Task <ActionResult <IEnumerable <Radio> > > GetRadios() { var helper = new RadioHelper(_context); await helper.GetLocations(); return(await _context.Radios.ToListAsync()); }
private void DropDownClosed(object args) { if (SelectedPresetChannel != null && SelectedPresetChannel.Value is Double && (Double)SelectedPresetChannel.Value > 0 && RadioId > 0) { RadioHelper.SelectRadioChannel(SelectedPresetChannel, RadioId); } }
private void RadioFrequencyOnLostFocus(object sender, RoutedEventArgs routedEventArgs) { double freq = 0; if (double.TryParse(RadioFrequency.Text.Trim(), out freq)) { RadioHelper.UpdateRadioFrequency(freq, RadioId, false); } else { RadioFrequency.Text = ""; } }
private void ToggleSimultaneousTransmissionButton_Click(object sender, RoutedEventArgs e) { if (_clientStateSingleton.DcsPlayerRadioInfo != null && _clientStateSingleton.DcsPlayerRadioInfo.simultaneousTransmission) { var currentRadio = RadioHelper.GetRadio(RadioId); if (currentRadio != null) { currentRadio.simul = !currentRadio.simul; ToggleSimultaneousTransmissionButton.Content = currentRadio.simul ? "Sim. ON" : "Sim. OFF"; } } }
private void RadioFrequencyOnLostFocus(object sender, RoutedEventArgs routedEventArgs) { double freq = 0; // Some locales/cultures (e.g. German) do not parse "." as decimal points since they use decimal commas ("123,45"), leading to "123.45" being parsed as "12345" and frequencies being set too high // Using an invariant culture makes sure the decimal point is parsed properly for all locales - replacing any commas makes sure people entering numbers in a weird format still get correct results if (double.TryParse(RadioFrequency.Text.Replace(',', '.').Trim(), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out freq)) { RadioHelper.UpdateRadioFrequency(freq, RadioId, false); } else { RadioFrequency.Text = ""; } }
public async Task <IActionResult> PutRadio(int id, Radio radio) { var helper = new RadioHelper(_context); var isLocationAllowed = helper.IsLocationAllowed(radio.location); if (id != radio.id) { return(BadRequest()); } if (await isLocationAllowed) { _context.Entry(radio).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); } return(Forbid()); }
private void ToggleSimultaneousTransmissionButton_Click(object sender, RoutedEventArgs e) { if (_clientStateSingleton.DcsPlayerRadioInfo != null && _clientStateSingleton.DcsPlayerRadioInfo.simultaneousTransmission) { var currentRadio = RadioHelper.GetRadio(RadioId); if (currentRadio != null) { currentRadio.simul = !currentRadio.simul; if (currentRadio.simul) { ToggleSimultaneousTransmissionButton.Foreground = new SolidColorBrush(Colors.Orange); } else { ToggleSimultaneousTransmissionButton.Foreground = new SolidColorBrush(Colors.White); } } } }
private void Encryption_ButtonClick(object sender, RoutedEventArgs e) { var currentRadio = RadioHelper.GetRadio(RadioId); if (currentRadio != null && currentRadio.modulation != RadioInformation.Modulation.DISABLED) // disabled { //update stuff if (currentRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_JUST_OVERLAY) { RadioHelper.ToggleEncryption(RadioId); if (currentRadio.enc) { EncryptionButton.Content = "Enable"; } else { EncryptionButton.Content = "Disable"; } } } }
public void StartDetectPtt(DetectPttCallback callback) { _detectPtt = true; //detect the state of all current buttons var pttInputThread = new Thread(() => { while (_detectPtt) { var bindStates = GenerateBindStateList(); for (var i = 0; i < bindStates.Count; i++) { //contains main binding and optional modifier binding + states of each var bindState = bindStates[i]; bindState.MainDeviceState = GetButtonState(bindState.MainDevice); if (bindState.ModifierDevice != null) { bindState.ModifierState = GetButtonState(bindState.ModifierDevice); bindState.IsActive = bindState.MainDeviceState && bindState.ModifierState; } else { bindState.IsActive = bindState.MainDeviceState; } //now check this is the best binding and no previous ones are better //Means you can have better binds like PTT = Space and Radio 1 is Space +1 - holding space +1 will actually trigger radio 1 not PTT if (bindState.IsActive) { for (int j = 0; j < i; j++) { //check previous bindings var previousBind = bindStates[j]; if (previousBind.IsActive) { if (previousBind.ModifierDevice == null && bindState.ModifierDevice != null) { //set previous bind to off if previous bind Main == main or modifier of bindstate if (previousBind.MainDevice.IsSameBind(bindState.MainDevice)) { previousBind.IsActive = false; break; } if (previousBind.MainDevice.IsSameBind(bindState.ModifierDevice)) { previousBind.IsActive = false; break; } } else if (previousBind.ModifierDevice != null && bindState.ModifierDevice == null) { if (previousBind.MainDevice.IsSameBind(bindState.MainDevice)) { bindState.IsActive = false; break; } if (previousBind.ModifierDevice.IsSameBind(bindState.MainDevice)) { bindState.IsActive = false; break; } } } } } } callback(bindStates); //handle overlay foreach (var bindState in bindStates) { if (bindState.IsActive && bindState.MainDevice.InputBind == InputBinding.OverlayToggle) { //run on main Application.Current.Dispatcher.Invoke( () => { _toggleOverlayCallback(false); }); break; } else if ((int)bindState.MainDevice.InputBind >= (int)InputBinding.Up100 && (int)bindState.MainDevice.InputBind <= (int)InputBinding.RadioChannelDown) { if (bindState.MainDevice.InputBind == _lastActiveBinding && !bindState.IsActive) { //Assign to a totally different binding to mark as unassign _lastActiveBinding = InputBinding.ModifierIntercom; } //key repeat if (bindState.IsActive && (bindState.MainDevice.InputBind != _lastActiveBinding)) { _lastActiveBinding = bindState.MainDevice.InputBind; var dcsPlayerRadioInfo = ClientStateSingleton.Instance.DcsPlayerRadioInfo; if (dcsPlayerRadioInfo != null && dcsPlayerRadioInfo.IsCurrent()) { switch (bindState.MainDevice.InputBind) { case InputBinding.Up100: RadioHelper.UpdateRadioFrequency(100, dcsPlayerRadioInfo.selected); break; case InputBinding.Up10: RadioHelper.UpdateRadioFrequency(10, dcsPlayerRadioInfo.selected); break; case InputBinding.Up1: RadioHelper.UpdateRadioFrequency(1, dcsPlayerRadioInfo.selected); break; case InputBinding.Up01: RadioHelper.UpdateRadioFrequency(0.1, dcsPlayerRadioInfo.selected); break; case InputBinding.Up001: RadioHelper.UpdateRadioFrequency(0.01, dcsPlayerRadioInfo.selected); break; case InputBinding.Up0001: RadioHelper.UpdateRadioFrequency(0.001, dcsPlayerRadioInfo.selected); break; case InputBinding.Down100: RadioHelper.UpdateRadioFrequency(-100, dcsPlayerRadioInfo.selected); break; case InputBinding.Down10: RadioHelper.UpdateRadioFrequency(-10, dcsPlayerRadioInfo.selected); break; case InputBinding.Down1: RadioHelper.UpdateRadioFrequency(-1, dcsPlayerRadioInfo.selected); break; case InputBinding.Down01: RadioHelper.UpdateRadioFrequency(-0.1, dcsPlayerRadioInfo.selected); break; case InputBinding.Down001: RadioHelper.UpdateRadioFrequency(-0.01, dcsPlayerRadioInfo.selected); break; case InputBinding.Down0001: RadioHelper.UpdateRadioFrequency(-0.001, dcsPlayerRadioInfo.selected); break; case InputBinding.ToggleGuard: RadioHelper.ToggleGuard(dcsPlayerRadioInfo.selected); break; case InputBinding.ToggleEncryption: RadioHelper.ToggleEncryption(dcsPlayerRadioInfo.selected); break; case InputBinding.NextRadio: RadioHelper.SelectNextRadio(); break; case InputBinding.PreviousRadio: RadioHelper.SelectPreviousRadio(); break; case InputBinding.EncryptionKeyIncrease: RadioHelper.IncreaseEncryptionKey(dcsPlayerRadioInfo.selected); break; case InputBinding.EncryptionKeyDecrease: RadioHelper.DecreaseEncryptionKey(dcsPlayerRadioInfo.selected); break; case InputBinding.RadioChannelUp: RadioHelper.RadioChannelUp(dcsPlayerRadioInfo.selected); break; case InputBinding.RadioChannelDown: RadioHelper.RadioChannelDown(dcsPlayerRadioInfo.selected); break; default: break; } } break; } } } Thread.Sleep(40); } }); pttInputThread.Start(); }
private static void DefaultMeth(double userBackNum, int playType, StringBuilder builder, StringBuilder lotteryBuilder, PlayTypeRadio radio, RadioHelper helper, bool isk3 = false) { builder.Append("{"); int noBigIndex = 5; int maxcodecount = 0; builder.Append("methoddesc: '" + helper.methoddesc + "',"); builder.Append("methodhelp: '" + helper.methodhelp + "',"); builder.Append("methodexample: '" + helper.methodexample + "',"); builder.Append("selectarea: {type: '" + helper.type + "',layout: [" + string.Join(",", helper.Layouts) + "],noBigIndex:" + noBigIndex + ",isButton: " + helper.isButton); if (!string.IsNullOrEmpty(helper.selPosition)) { builder.Append(",'selPosition' : '" + helper.selPosition + "'"); } builder.Append("},"); builder.Append("show_str: '" + helper.show_str + "',code_sp: '" + helper.code_sp + "',methodid: " + (isk3?helper.Key[0]:radio.RadioCode) + ",name: '" + radio.PlayTypeRadioName + "',");//如果为k3的话,直接使用code if (!string.IsNullOrEmpty(helper.defaultposition)) { builder.Append("'defaultposition' : '" + helper.defaultposition + "',"); } builder.Append("prize: { 1: '" + Utils.DecimalConvert(playType == 0 ? radio.BonusBasic : radio.BonusBasic17) + "' },"); if (!radio.IsFixed && !isk3)//非块3 { builder.Append("nfdprize:" + GetRebateInfo(playType, userBackNum, radio) + ","); } else { builder.Append("nfdprize:{},"); } builder.Append("modes: [{ modeid: 1, name: '元', rate: 1 }, { modeid: 2, name: '角', rate: 0.1 }, { modeid: 3, name: '分', rate: 0.01 },{ modeid: 4, name: '厘', rate: 0.001 }],"); string desc = string.IsNullOrEmpty(helper.Desc) ? radio.PlayTypeRadioName : helper.Desc; builder.Append("desc: '" + desc + "', maxcodecount:" + maxcodecount + ""); builder.Append("}"); }
private void RadioFrequencyText_Click(object sender, MouseButtonEventArgs e) { RadioHelper.SelectRadio(RadioId); }
private void RadioFrequencyText_RightClick(object sender, MouseButtonEventArgs e) { RadioHelper.ToggleGuard(RadioId); }
private void Down0001_Click(object sender, RoutedEventArgs e) { RadioHelper.UpdateRadioFrequency(-0.001, RadioId); }
private void RadioSelectSwitch(object sender, RoutedEventArgs e) { RadioHelper.SelectRadio(RadioId); }
private void StartUDPCommandListener() { _udpCommandListener = new UdpClient(); _udpCommandListener.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _udpCommandListener.ExclusiveAddressUse = false; // only if you want to send/receive on same machine. var localEp = new IPEndPoint(IPAddress.Any, _settings.GetNetworkSetting(SettingsKeys.CommandListenerUDP)); _udpCommandListener.Client.Bind(localEp); Task.Factory.StartNew(() => { using (_udpCommandListener) { while (!_stop) { try { var groupEp = new IPEndPoint(IPAddress.Any, _settings.GetNetworkSetting(SettingsKeys.CommandListenerUDP)); var bytes = _udpCommandListener.Receive(ref groupEp); //Logger.Info("Recevied Message from UDP COMMAND INTERFACE: "+ Encoding.UTF8.GetString( // bytes, 0, bytes.Length)); var message = JsonConvert.DeserializeObject <UDPInterfaceCommand>(Encoding.UTF8.GetString( bytes, 0, bytes.Length)); if (message?.Command == UDPInterfaceCommand.UDPCommandType.FREQUENCY) { RadioHelper.UpdateRadioFrequency(message.Frequency, message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.ACTIVE_RADIO) { RadioHelper.SelectRadio(message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.TOGGLE_GUARD) { RadioHelper.ToggleGuard(message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.CHANNEL_UP) { RadioHelper.RadioChannelUp(message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.CHANNEL_DOWN) { RadioHelper.RadioChannelDown(message.RadioId); } else { Logger.Error("Unknown UDP Command!"); } } catch (SocketException e) { // SocketException is raised when closing app/disconnecting, ignore so we don't log "irrelevant" exceptions if (!_stop) { Logger.Error(e, "SocketException Handling DCS Message"); } } catch (Exception e) { Logger.Error(e, "Exception Handling DCS Message"); } } try { _udpCommandListener.Close(); } catch (Exception e) { Logger.Error(e, "Exception stoping DCS listener "); } } }); }
private void Up10_Click(object sender, RoutedEventArgs e) { RadioHelper.UpdateRadioFrequency(10, RadioId); }
private void StartUDPCommandListener() { Task.Factory.StartNew(() => { while (!_stop) { var localEp = new IPEndPoint(IPAddress.Any, _globalSettings.GetNetworkSetting(GlobalSettingsKeys.CommandListenerUDP)); try { _udpCommandListener = new UdpClient(localEp); break; } catch (Exception ex) { Logger.Warn(ex, $"Unable to bind to the UDP Command Listener Socket Port: {localEp.Port}"); Thread.Sleep(500); } } while (!_stop) { try { var groupEp = new IPEndPoint(IPAddress.Any, 0); var bytes = _udpCommandListener.Receive(ref groupEp); //Logger.Info("Recevied Message from UDP COMMAND INTERFACE: "+ Encoding.UTF8.GetString( // bytes, 0, bytes.Length)); var message = JsonConvert.DeserializeObject <UDPInterfaceCommand>(Encoding.UTF8.GetString( bytes, 0, bytes.Length)); if (message?.Command == UDPInterfaceCommand.UDPCommandType.FREQUENCY_DELTA) { RadioHelper.UpdateRadioFrequency(message.Frequency, message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.FREQUENCY_SET) { RadioHelper.UpdateRadioFrequency(message.Frequency, message.RadioId, false, true); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.ACTIVE_RADIO) { RadioHelper.SelectRadio(message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.TOGGLE_GUARD) { RadioHelper.ToggleGuard(message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.GUARD) { RadioHelper.SetGuard(message.RadioId, message.Enabled); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.CHANNEL_UP) { RadioHelper.RadioChannelUp(message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.CHANNEL_DOWN) { RadioHelper.RadioChannelDown(message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.SET_VOLUME) { RadioHelper.SetRadioVolume(message.Volume, message.RadioId); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.TRANSPONDER_POWER) { TransponderHelper.SetPower(message.Enabled); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.TRANSPONDER_M1_CODE) { TransponderHelper.SetMode1(message.Code); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.TRANSPONDER_M3_CODE) { TransponderHelper.SetMode3(message.Code); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.TRANSPONDER_M4) { TransponderHelper.SetMode4(message.Enabled); } else if (message?.Command == UDPInterfaceCommand.UDPCommandType.TRANSPONDER_IDENT) { TransponderHelper.SetIdent(message.Enabled); } else { Logger.Error("Unknown UDP Command!"); } } catch (SocketException e) { // SocketException is raised when closing app/disconnecting, ignore so we don't log "irrelevant" exceptions if (!_stop) { Logger.Error(e, "SocketException Handling DCS Message"); } } catch (Exception e) { Logger.Error(e, "Exception Handling DCS Message"); } } try { _udpCommandListener.Close(); } catch (Exception e) { Logger.Error(e, "Exception stoping DCS listener "); } }); }
private bool UpdateRadio(DCSPlayerRadioInfo message) { var changed = false; var expansion = ClientSync.ServerSettings[(int)ServerSettingType.RADIO_EXPANSION]; var playerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; //update common parts playerRadioInfo.name = message.name; if (_settings.GetClientSetting(SettingsKeys.AlwaysAllowHotasControls).BoolValue) { playerRadioInfo.control = DCSPlayerRadioInfo.RadioSwitchControls.HOTAS; } else { playerRadioInfo.control = message.control; } playerRadioInfo.unit = message.unit; playerRadioInfo.pos = message.pos; var overrideFreqAndVol = false; var newAircraft = playerRadioInfo.unitId != message.unitId || !playerRadioInfo.IsCurrent(); if (message.unitId >= DCSPlayerRadioInfo.UnitIdOffset && playerRadioInfo.unitId >= DCSPlayerRadioInfo.UnitIdOffset) { //overriden so leave as is } else { overrideFreqAndVol = playerRadioInfo.unitId != message.unitId; playerRadioInfo.unitId = message.unitId; } if (overrideFreqAndVol) { playerRadioInfo.selected = message.selected; changed = true; } if (message.control == DCSPlayerRadioInfo.RadioSwitchControls.IN_COCKPIT) { playerRadioInfo.selected = message.selected; } //copy over radio names, min + max for (var i = 0; i < playerRadioInfo.radios.Length; i++) { var clientRadio = playerRadioInfo.radios[i]; //if awacs NOT open - disable radios over 3 if (i >= message.radios.Length || (RadioOverlayWindow.AwacsActive == false && (i > 3 || i == 0) // disable intercom and all radios over 3 if awacs panel isnt open and we're a spectator given by the UnitId && playerRadioInfo.unitId >= DCSPlayerRadioInfo.UnitIdOffset)) { clientRadio.freq = 1; clientRadio.freqMin = 1; clientRadio.freqMax = 1; clientRadio.secFreq = 0; clientRadio.modulation = RadioInformation.Modulation.DISABLED; clientRadio.name = "No Radio"; clientRadio.freqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.encMode = RadioInformation.EncryptionMode.NO_ENCRYPTION; clientRadio.volMode = RadioInformation.VolumeMode.COCKPIT; continue; } var updateRadio = message.radios[i]; if ((updateRadio.expansion && !expansion) || (updateRadio.modulation == RadioInformation.Modulation.DISABLED)) { //expansion radio, not allowed clientRadio.freq = 1; clientRadio.freqMin = 1; clientRadio.freqMax = 1; clientRadio.secFreq = 0; clientRadio.modulation = RadioInformation.Modulation.DISABLED; clientRadio.name = "No Radio"; clientRadio.freqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.encMode = RadioInformation.EncryptionMode.NO_ENCRYPTION; clientRadio.volMode = RadioInformation.VolumeMode.COCKPIT; } else { //update common parts clientRadio.freqMin = updateRadio.freqMin; clientRadio.freqMax = updateRadio.freqMax; clientRadio.name = updateRadio.name; clientRadio.modulation = updateRadio.modulation; //update modes clientRadio.freqMode = updateRadio.freqMode; clientRadio.encMode = updateRadio.encMode; clientRadio.volMode = updateRadio.volMode; if ((updateRadio.freqMode == RadioInformation.FreqMode.COCKPIT) || overrideFreqAndVol) { if (clientRadio.freq != updateRadio.freq) { changed = true; } if (clientRadio.secFreq != updateRadio.secFreq) { changed = true; } clientRadio.freq = updateRadio.freq; //default overlay to off if (updateRadio.freqMode == RadioInformation.FreqMode.OVERLAY) { clientRadio.secFreq = 0; } else { clientRadio.secFreq = updateRadio.secFreq; } clientRadio.channel = updateRadio.channel; } else { if (clientRadio.secFreq != 0) { //put back clientRadio.secFreq = updateRadio.secFreq; } //check we're not over a limit if (clientRadio.freq > clientRadio.freqMax) { clientRadio.freq = clientRadio.freqMax; } else if (clientRadio.freq < clientRadio.freqMin) { clientRadio.freq = clientRadio.freqMin; } } //reset encryption if (overrideFreqAndVol) { clientRadio.enc = false; clientRadio.encKey = 0; } //Handle Encryption if (updateRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_JUST_OVERLAY) { if (clientRadio.encKey == 0) { clientRadio.encKey = 1; } } else if (clientRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_COCKPIT_TOGGLE_OVERLAY_CODE) { clientRadio.enc = updateRadio.enc; if (clientRadio.encKey == 0) { clientRadio.encKey = 1; } } else if (clientRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_FULL) { clientRadio.enc = updateRadio.enc; clientRadio.encKey = updateRadio.encKey; } else { clientRadio.enc = false; clientRadio.encKey = 0; } //handle volume if ((updateRadio.volMode == RadioInformation.VolumeMode.COCKPIT) || overrideFreqAndVol) { clientRadio.volume = updateRadio.volume; } //handle Channels load for radios if (newAircraft && i > 0) { if (clientRadio.freqMode == RadioInformation.FreqMode.OVERLAY) { var channelModel = _clientStateSingleton.FixedChannels[i - 1]; channelModel.Max = clientRadio.freqMax; channelModel.Min = clientRadio.freqMin; channelModel.Reload(); clientRadio.channel = -1; //reset channel if (_settings.GetClientSetting(SettingsKeys.AutoSelectPresetChannel).BoolValue) { RadioHelper.RadioChannelUp(i); } } else { _clientStateSingleton.FixedChannels[i - 1].Clear(); //clear } } } } //change PTT last if (!_settings.GetClientSetting(SettingsKeys.AllowDCSPTT).BoolValue) { playerRadioInfo.ptt = false; } else { playerRadioInfo.ptt = message.ptt; } // } // } //update playerRadioInfo.LastUpdate = DateTime.Now.Ticks; return(changed); }
private static void Async(System.Xml.Linq.XElement item, RadioHelper helperItem) { string key = item.Attribute("Code").Value; helperItem.Key = key.Split(',').Select(c => Convert.ToInt32(c.ToString())).ToArray(); string defType = "digital"; string defshow_str = "X,X,X,X,X"; string defcode_sp = ""; var type = item.Attribute("type"); var show_str = item.Attribute("show_str"); var code_sp = item.Attribute("code_sp"); var methoddesc = item.Attribute("methoddesc"); var methodhelp = item.Attribute("methodhelp"); var methodexample = item.Attribute("methodexample"); var methodid = item.Attribute("methodid"); var isButton = item.Attribute("isButton"); var selPosition = item.Attribute("selPosition"); var defaultposition = item.Attribute("defaultposition"); var name = item.Attribute("name"); var desc = item.Attribute("desc"); if (type != null) { defType = type.Value; } if (show_str != null) { defshow_str = show_str.Value; } if (code_sp != null) { defcode_sp = code_sp.Value; } helperItem.type = defType; helperItem.show_str = defshow_str; helperItem.code_sp = defcode_sp; helperItem.isButton = "true"; if (isButton != null) { helperItem.isButton = isButton.Value; } helperItem.methodid = "0"; if (methodid != null) { helperItem.methodid = methodid.Value; } if (methoddesc != null) { helperItem.methoddesc = methoddesc.Value; } if (methodhelp != null) { helperItem.methodhelp = methodhelp.Value; } if (methodexample != null) { helperItem.methodexample = methodexample.Value; } if (selPosition != null) { helperItem.selPosition = selPosition.Value; } if (defaultposition != null) { helperItem.defaultposition = defaultposition.Value; } if (name != null) { helperItem.Name = name.Value; } if (desc != null) { helperItem.Desc = desc.Value; } helperItem.Layouts = new List <string>(); var layouts = item.Elements("Layout"); foreach (var layout in layouts) { var pageAttribute = layout.Value; if (!string.IsNullOrEmpty(pageAttribute)) { helperItem.Layouts.Add(pageAttribute); } } }
private void RetransmitClick(object sender, RoutedEventArgs e) { RadioHelper.ToggleRetransmit(RadioId); }
private bool UpdateRadio(DCSPlayerRadioInfo message) { var expansion = _serverSettings.GetSettingAsBool(ServerSettingsKeys.RADIO_EXPANSION); var playerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; //copy and compare to look for changes var beforeUpdate = playerRadioInfo.DeepClone(); //update common parts playerRadioInfo.name = message.name; playerRadioInfo.inAircraft = message.inAircraft; playerRadioInfo.intercomHotMic = message.intercomHotMic; playerRadioInfo.capabilities = message.capabilities; if (_globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.AlwaysAllowHotasControls)) { message.control = DCSPlayerRadioInfo.RadioSwitchControls.HOTAS; playerRadioInfo.control = DCSPlayerRadioInfo.RadioSwitchControls.HOTAS; } else { playerRadioInfo.control = message.control; } playerRadioInfo.simultaneousTransmissionControl = message.simultaneousTransmissionControl; playerRadioInfo.unit = message.unit; if (!_clientStateSingleton.ShouldUseLotATCPosition()) { _clientStateSingleton.UpdatePlayerPosition(message.latLng); } var overrideFreqAndVol = false; var newAircraft = playerRadioInfo.unitId != message.unitId || !playerRadioInfo.IsCurrent(); overrideFreqAndVol = playerRadioInfo.unitId != message.unitId; //save unit id playerRadioInfo.unitId = message.unitId; if (newAircraft) { if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.AutoSelectSettingsProfile)) { _newAircraftCallback(message.unit); } playerRadioInfo.iff = message.iff; } if (overrideFreqAndVol) { playerRadioInfo.selected = message.selected; } if (playerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.IN_COCKPIT) { playerRadioInfo.selected = message.selected; } bool simul = false; //copy over radio names, min + max for (var i = 0; i < playerRadioInfo.radios.Length; i++) { var clientRadio = playerRadioInfo.radios[i]; //if we have more radios than the message has if (i >= message.radios.Length) { clientRadio.freq = 1; clientRadio.freqMin = 1; clientRadio.freqMax = 1; clientRadio.secFreq = 0; clientRadio.retransmit = false; clientRadio.modulation = RadioInformation.Modulation.DISABLED; clientRadio.name = "No Radio"; clientRadio.rtMode = RadioInformation.RetransmitMode.DISABLED; clientRadio.retransmit = false; clientRadio.freqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.guardFreqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.encMode = RadioInformation.EncryptionMode.NO_ENCRYPTION; clientRadio.volMode = RadioInformation.VolumeMode.COCKPIT; continue; } var updateRadio = message.radios[i]; if ((updateRadio.expansion && !expansion) || (updateRadio.modulation == RadioInformation.Modulation.DISABLED)) { //expansion radio, not allowed clientRadio.freq = 1; clientRadio.freqMin = 1; clientRadio.freqMax = 1; clientRadio.secFreq = 0; clientRadio.retransmit = false; clientRadio.modulation = RadioInformation.Modulation.DISABLED; clientRadio.name = "No Radio"; clientRadio.rtMode = RadioInformation.RetransmitMode.DISABLED; clientRadio.retransmit = false; clientRadio.freqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.guardFreqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.encMode = RadioInformation.EncryptionMode.NO_ENCRYPTION; clientRadio.volMode = RadioInformation.VolumeMode.COCKPIT; } else { //update common parts clientRadio.freqMin = updateRadio.freqMin; clientRadio.freqMax = updateRadio.freqMax; if (playerRadioInfo.simultaneousTransmissionControl == DCSPlayerRadioInfo.SimultaneousTransmissionControl.EXTERNAL_DCS_CONTROL) { clientRadio.simul = updateRadio.simul; } if (updateRadio.simul) { simul = true; } clientRadio.name = updateRadio.name; clientRadio.modulation = updateRadio.modulation; //update modes clientRadio.freqMode = updateRadio.freqMode; clientRadio.guardFreqMode = updateRadio.guardFreqMode; clientRadio.rtMode = updateRadio.rtMode; if (_serverSettings.GetSettingAsBool(ServerSettingsKeys.ALLOW_RADIO_ENCRYPTION)) { clientRadio.encMode = updateRadio.encMode; } else { clientRadio.encMode = RadioInformation.EncryptionMode.NO_ENCRYPTION; } clientRadio.volMode = updateRadio.volMode; if ((updateRadio.freqMode == RadioInformation.FreqMode.COCKPIT) || overrideFreqAndVol) { clientRadio.freq = updateRadio.freq; if (newAircraft && updateRadio.guardFreqMode == RadioInformation.FreqMode.OVERLAY) { //default guard to off clientRadio.secFreq = 0; } else { if (clientRadio.secFreq != 0 && updateRadio.guardFreqMode == RadioInformation.FreqMode.OVERLAY) { //put back clientRadio.secFreq = updateRadio.secFreq; } else if (clientRadio.secFreq == 0 && updateRadio.guardFreqMode == RadioInformation.FreqMode.OVERLAY) { clientRadio.secFreq = 0; } else { clientRadio.secFreq = updateRadio.secFreq; } } clientRadio.channel = updateRadio.channel; } else { if (clientRadio.secFreq != 0) { //put back clientRadio.secFreq = updateRadio.secFreq; } //check we're not over a limit if (clientRadio.freq > clientRadio.freqMax) { clientRadio.freq = clientRadio.freqMax; } else if (clientRadio.freq < clientRadio.freqMin) { clientRadio.freq = clientRadio.freqMin; } } //reset encryption if (overrideFreqAndVol) { clientRadio.enc = false; clientRadio.encKey = 0; } //Handle Encryption if (updateRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_JUST_OVERLAY) { if (clientRadio.encKey == 0) { clientRadio.encKey = 1; } } else if (clientRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_COCKPIT_TOGGLE_OVERLAY_CODE) { clientRadio.enc = updateRadio.enc; if (clientRadio.encKey == 0) { clientRadio.encKey = 1; } } else if (clientRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_FULL) { clientRadio.enc = updateRadio.enc; clientRadio.encKey = updateRadio.encKey; } else { clientRadio.enc = false; clientRadio.encKey = 0; } //handle volume if ((updateRadio.volMode == RadioInformation.VolumeMode.COCKPIT) || overrideFreqAndVol) { clientRadio.volume = updateRadio.volume; } //handle Retransmit mode if ((updateRadio.rtMode == RadioInformation.RetransmitMode.COCKPIT)) { clientRadio.rtMode = updateRadio.rtMode; clientRadio.retransmit = updateRadio.retransmit; } else if (updateRadio.rtMode == RadioInformation.RetransmitMode.DISABLED) { clientRadio.rtMode = updateRadio.rtMode; clientRadio.retransmit = false; } //handle Channels load for radios if (newAircraft && i > 0) { if (clientRadio.freqMode == RadioInformation.FreqMode.OVERLAY) { var channelModel = _clientStateSingleton.FixedChannels[i - 1]; channelModel.Max = clientRadio.freqMax; channelModel.Min = clientRadio.freqMin; channelModel.Reload(); clientRadio.channel = -1; //reset channel if (_globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.AutoSelectPresetChannel)) { RadioHelper.RadioChannelUp(i); } } else { _clientStateSingleton.FixedChannels[i - 1].Clear(); //clear } } } } if (playerRadioInfo.simultaneousTransmissionControl == DCSPlayerRadioInfo.SimultaneousTransmissionControl.EXTERNAL_DCS_CONTROL) { playerRadioInfo.simultaneousTransmission = simul; } //change PTT last if (!_globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.AllowDCSPTT)) { playerRadioInfo.ptt = false; } else { playerRadioInfo.ptt = message.ptt; } //HANDLE IFF/TRANSPONDER UPDATE //TODO tidy up the IFF/Transponder handling and this giant function in general as its silly big :( if (_globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys .AlwaysAllowTransponderOverlay)) { if (message.iff.control != Transponder.IFFControlMode.DISABLED) { playerRadioInfo.iff.control = Transponder.IFFControlMode.OVERLAY; message.iff.control = Transponder.IFFControlMode.OVERLAY; } } if (message.iff.control == Transponder.IFFControlMode.COCKPIT) { playerRadioInfo.iff = message.iff; } //HANDLE MIC IDENT if (!playerRadioInfo.ptt && playerRadioInfo.iff.mic > 0 && _clientStateSingleton.RadioSendingState.IsSending) { if (_clientStateSingleton.RadioSendingState.SendingOn == playerRadioInfo.iff.mic) { playerRadioInfo.iff.status = Transponder.IFFStatus.IDENT; } } //Handle IDENT only lasting for 40 seconds at most - need to toggle it if (playerRadioInfo.iff.status == Transponder.IFFStatus.IDENT) { if (_identStart == 0) { _identStart = DateTime.Now.Ticks; } if (TimeSpan.FromTicks(DateTime.Now.Ticks - _identStart).TotalSeconds > 40) { playerRadioInfo.iff.status = Transponder.IFFStatus.NORMAL; } } else { _identStart = 0; } // } // } //update playerRadioInfo.LastUpdate = DateTime.Now.Ticks; return(!beforeUpdate.Equals(playerRadioInfo)); }
private void ChannelFive_Click(object sender, RoutedEventArgs e) { RadioHelper.SelectRadioChannel(5, RadioId); }
public void StartDetectPtt(DetectPttCallback callback) { _detectPtt = true; //detect the state of all current buttons var pttInputThread = new Thread(() => { while (_detectPtt) { var bindStates = GenerateBindStateList(); for (var i = 0; i < bindStates.Count; i++) { //contains main binding and optional modifier binding + states of each var bindState = bindStates[i]; bindState.MainDeviceState = GetButtonState(bindState.MainDevice); if (bindState.ModifierDevice != null) { bindState.ModifierState = GetButtonState(bindState.ModifierDevice); bindState.IsActive = bindState.MainDeviceState && bindState.ModifierState; } else { bindState.IsActive = bindState.MainDeviceState; } //now check this is the best binding and no previous ones are better //Means you can have better binds like PTT = Space and Radio 1 is Space +1 - holding space +1 will actually trigger radio 1 not PTT if (bindState.IsActive) { for (int j = 0; j < i; j++) { //check previous bindings var previousBind = bindStates[j]; if (!previousBind.IsActive) { continue; } if (previousBind.ModifierDevice == null && bindState.ModifierDevice != null) { //set previous bind to off if previous bind Main == main or modifier of bindstate if (previousBind.MainDevice.IsSameBind(bindState.MainDevice)) { previousBind.IsActive = false; break; } if (previousBind.MainDevice.IsSameBind(bindState.ModifierDevice)) { previousBind.IsActive = false; break; } } else if (previousBind.ModifierDevice != null && bindState.ModifierDevice == null) { if (previousBind.MainDevice.IsSameBind(bindState.MainDevice)) { bindState.IsActive = false; break; } if (previousBind.ModifierDevice.IsSameBind(bindState.MainDevice)) { bindState.IsActive = false; break; } } } } } callback(bindStates); //handle overlay foreach (var bindState in bindStates) { if (bindState.IsActive && bindState.MainDevice.InputBind == InputBinding.OverlayToggle) { //run on main Application.Current.Dispatcher.Invoke( () => { _toggleOverlayCallback(false); }); break; } else if ((int)bindState.MainDevice.InputBind >= (int)InputBinding.RadioChannel1 && (int)bindState.MainDevice.InputBind <= (int)InputBinding.RadioChannelDown) { if (bindState.MainDevice.InputBind == _lastActiveBinding && !bindState.IsActive) { //Assign to a totally different binding to mark as unassign _lastActiveBinding = InputBinding.ModifierIntercom; } //key repeat if (bindState.IsActive && (bindState.MainDevice.InputBind != _lastActiveBinding)) { _lastActiveBinding = bindState.MainDevice.InputBind; var IL2PlayerRadioInfo = ClientStateSingleton.Instance.PlayerGameState; if (IL2PlayerRadioInfo != null) { switch (bindState.MainDevice.InputBind) { case InputBinding.RadioChannelUp: if (!RadioHelper.IsSecondRadioAvailable()) { RadioHelper.RadioChannelUp(1); } else { RadioHelper.RadioChannelUp(ClientStateSingleton.Instance.PlayerGameState.selected); } break; case InputBinding.RadioChannelDown: if (!RadioHelper.IsSecondRadioAvailable()) { RadioHelper.RadioChannelDown(1); } else { RadioHelper.RadioChannelDown(ClientStateSingleton.Instance.PlayerGameState.selected); } break; case InputBinding.RadioChannel1: if (!RadioHelper.IsSecondRadioAvailable()) { RadioHelper.SelectRadioChannel(1, 1); } else { RadioHelper.SelectRadioChannel(1, ClientStateSingleton.Instance.PlayerGameState.selected); } break; case InputBinding.RadioChannel2: if (!RadioHelper.IsSecondRadioAvailable()) { RadioHelper.SelectRadioChannel(2, 1); } else { RadioHelper.SelectRadioChannel(2, ClientStateSingleton.Instance.PlayerGameState.selected); } break; case InputBinding.RadioChannel3: if (!RadioHelper.IsSecondRadioAvailable()) { RadioHelper.SelectRadioChannel(3, 1); } else { RadioHelper.SelectRadioChannel(3, ClientStateSingleton.Instance.PlayerGameState.selected); } break; case InputBinding.RadioChannel4: if (!RadioHelper.IsSecondRadioAvailable()) { RadioHelper.SelectRadioChannel(4, 1); } else { RadioHelper.SelectRadioChannel(4, ClientStateSingleton.Instance.PlayerGameState.selected); } break; case InputBinding.RadioChannel5: if (!RadioHelper.IsSecondRadioAvailable()) { RadioHelper.SelectRadioChannel(5, 1); } else { RadioHelper.SelectRadioChannel(5, ClientStateSingleton.Instance.PlayerGameState.selected); } break; case InputBinding.PreviousRadio: RadioHelper.PreviousRadio(); break; case InputBinding.NextRadio: RadioHelper.NextRadio(); break; case InputBinding.ReadStatus: RadioHelper.ReadStatus(); break; default: break; } } break; } } } Thread.Sleep(40); } }); pttInputThread.Start(); }
public void Listen() { _udpLastReceived = 0; _ready = false; _listener = new UdpClient(); try { _listener.AllowNatTraversal(true); } catch { } // _listener.Connect(_serverEndpoint); //start 2 audio processing threads var decoderThread = new Thread(UdpAudioDecode); decoderThread.Start(); var settings = GlobalSettingsStore.Instance; _inputManager.StartDetectPtt(pressed => { var radios = _clientStateSingleton.PlayerGameState; var radioSwitchPtt = _globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.RadioSwitchIsPTT); var radioSwitchPttWhenValid = _globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.RadioSwitchIsPTTOnlyWhenValid); //store the current PTT state and radios var currentRadioId = radios.selected; var currentPtt = _ptt; var ptt = false; foreach (var inputBindState in pressed) { if (inputBindState.IsActive) { //radio switch? if ((int)inputBindState.MainDevice.InputBind >= (int)InputBinding.Intercom && (int)inputBindState.MainDevice.InputBind <= (int)InputBinding.Switch10) { //gives you radio id if you minus 100 var radioId = (int)inputBindState.MainDevice.InputBind - 100; if (radioId < _clientStateSingleton.PlayerGameState.radios.Length) { var clientRadio = _clientStateSingleton.PlayerGameState.radios[radioId]; if (RadioHelper.SelectRadio(radioId, !(radioSwitchPttWhenValid || radioSwitchPtt))) { //turn on PTT if (radioSwitchPttWhenValid || radioSwitchPtt) { _lastPTTPress = DateTime.Now.Ticks; ptt = true; //Store last release time } } else { //turn on PTT even if not valid radio switch if (radioSwitchPtt) { _lastPTTPress = DateTime.Now.Ticks; ptt = true; } } } } else if (inputBindState.MainDevice.InputBind == InputBinding.Ptt) { _lastPTTPress = DateTime.Now.Ticks; ptt = true; } } } //if length is zero - no keybinds or no PTT pressed set to false var diff = new TimeSpan(DateTime.Now.Ticks - _lastPTTPress); //Release the PTT ONLY if X ms have passed and we didnt switch radios to handle //shitty buttons var releaseTime = _globalSettings.ProfileSettingsStore .GetClientSetting(ProfileSettingsKeys.PTTReleaseDelay).IntValue; if (!ptt && releaseTime > 0 && diff.TotalMilliseconds <= releaseTime && currentRadioId == radios.selected) { ptt = true; } _ptt = ptt; }); StartTimer(); StartPing(); _packetNumber = 1; //reset packet number while (!_stop) { if (_ready) { try { var groupEp = new IPEndPoint(IPAddress.Any, _port); // listener.Client.ReceiveTimeout = 3000; var bytes = _listener.Receive(ref groupEp); if (bytes?.Length == 22) { _udpLastReceived = DateTime.Now.Ticks; Logger.Info("Received Ping Back from Server"); } else if (bytes?.Length > 22) { _udpLastReceived = DateTime.Now.Ticks; _encodedAudio.Add(bytes); } } catch (Exception e) { // logger.Error(e, "error listening for UDP Voip"); } } } _ready = false; //stop UI Refreshing _updateTimer.Stop(); _clientStateSingleton.IsVoipConnected = false; }
private bool UpdateRadio(DCSPlayerRadioInfo message) { var changed = false; var expansion = _serverSettings.GetSettingAsBool(ServerSettingsKeys.RADIO_EXPANSION); var playerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; //update common parts playerRadioInfo.name = message.name; playerRadioInfo.inAircraft = message.inAircraft; playerRadioInfo.intercomHotMic = message.intercomHotMic; if (_globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.AlwaysAllowHotasControls)) { message.control = DCSPlayerRadioInfo.RadioSwitchControls.HOTAS; playerRadioInfo.control = DCSPlayerRadioInfo.RadioSwitchControls.HOTAS; } else { playerRadioInfo.control = message.control; } playerRadioInfo.simultaneousTransmissionControl = message.simultaneousTransmissionControl; playerRadioInfo.unit = message.unit; if (!_clientStateSingleton.ShouldUseLotATCPosition()) { _clientStateSingleton.UpdatePlayerPosition(message.pos, message.latLng); } var overrideFreqAndVol = false; var newAircraft = playerRadioInfo.unitId != message.unitId || !playerRadioInfo.IsCurrent(); if (message.unitId >= DCSPlayerRadioInfo.UnitIdOffset && playerRadioInfo.unitId >= DCSPlayerRadioInfo.UnitIdOffset) { //overriden so leave as is } else { overrideFreqAndVol = playerRadioInfo.unitId != message.unitId; playerRadioInfo.unitId = message.unitId; } if (newAircraft) { if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.AutoSelectSettingsProfile)) { _newAircraftCallback(message.unit); } playerRadioInfo.iff = message.iff; } if (overrideFreqAndVol) { playerRadioInfo.selected = message.selected; changed = true; } if (playerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.IN_COCKPIT) { playerRadioInfo.selected = message.selected; } bool simul = false; //copy over radio names, min + max for (var i = 0; i < playerRadioInfo.radios.Length; i++) { var clientRadio = playerRadioInfo.radios[i]; //if awacs NOT open - disable radios over 3 if (i >= message.radios.Length || (RadioOverlayWindow.AwacsActive == false && (i > 3 || i == 0) // disable intercom and all radios over 3 if awacs panel isnt open and we're a spectator given by the UnitId && playerRadioInfo.unitId >= DCSPlayerRadioInfo.UnitIdOffset)) { clientRadio.freq = 1; clientRadio.freqMin = 1; clientRadio.freqMax = 1; clientRadio.secFreq = 0; clientRadio.modulation = RadioInformation.Modulation.DISABLED; clientRadio.name = "No Radio"; clientRadio.freqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.guardFreqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.encMode = RadioInformation.EncryptionMode.NO_ENCRYPTION; clientRadio.volMode = RadioInformation.VolumeMode.COCKPIT; continue; } var updateRadio = message.radios[i]; if ((updateRadio.expansion && !expansion) || (updateRadio.modulation == RadioInformation.Modulation.DISABLED)) { //expansion radio, not allowed clientRadio.freq = 1; clientRadio.freqMin = 1; clientRadio.freqMax = 1; clientRadio.secFreq = 0; clientRadio.modulation = RadioInformation.Modulation.DISABLED; clientRadio.name = "No Radio"; clientRadio.freqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.guardFreqMode = RadioInformation.FreqMode.COCKPIT; clientRadio.encMode = RadioInformation.EncryptionMode.NO_ENCRYPTION; clientRadio.volMode = RadioInformation.VolumeMode.COCKPIT; } else { //update common parts clientRadio.freqMin = updateRadio.freqMin; clientRadio.freqMax = updateRadio.freqMax; if (playerRadioInfo.simultaneousTransmissionControl == DCSPlayerRadioInfo.SimultaneousTransmissionControl.EXTERNAL_DCS_CONTROL) { clientRadio.simul = updateRadio.simul; } if (updateRadio.simul) { simul = true; } clientRadio.name = updateRadio.name; clientRadio.modulation = updateRadio.modulation; //update modes clientRadio.freqMode = updateRadio.freqMode; clientRadio.guardFreqMode = updateRadio.guardFreqMode; if (_serverSettings.GetSettingAsBool(ServerSettingsKeys.ALLOW_RADIO_ENCRYPTION)) { clientRadio.encMode = updateRadio.encMode; } else { clientRadio.encMode = RadioInformation.EncryptionMode.NO_ENCRYPTION; } clientRadio.volMode = updateRadio.volMode; if ((updateRadio.freqMode == RadioInformation.FreqMode.COCKPIT) || overrideFreqAndVol) { if (clientRadio.freq != updateRadio.freq) { changed = true; } if (clientRadio.secFreq != updateRadio.secFreq) { changed = true; } clientRadio.freq = updateRadio.freq; if (newAircraft && updateRadio.guardFreqMode == RadioInformation.FreqMode.OVERLAY) { //default guard to off clientRadio.secFreq = 0; } else { if (clientRadio.secFreq != 0 && updateRadio.guardFreqMode == RadioInformation.FreqMode.OVERLAY) { //put back clientRadio.secFreq = updateRadio.secFreq; } else if (clientRadio.secFreq == 0 && updateRadio.guardFreqMode == RadioInformation.FreqMode.OVERLAY) { clientRadio.secFreq = 0; } else { clientRadio.secFreq = updateRadio.secFreq; } } clientRadio.channel = updateRadio.channel; } else { if (clientRadio.secFreq != 0) { //put back clientRadio.secFreq = updateRadio.secFreq; } //check we're not over a limit if (clientRadio.freq > clientRadio.freqMax) { clientRadio.freq = clientRadio.freqMax; } else if (clientRadio.freq < clientRadio.freqMin) { clientRadio.freq = clientRadio.freqMin; } } //reset encryption if (overrideFreqAndVol) { clientRadio.enc = false; clientRadio.encKey = 0; } //Handle Encryption if (updateRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_JUST_OVERLAY) { if (clientRadio.encKey == 0) { clientRadio.encKey = 1; } } else if (clientRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_COCKPIT_TOGGLE_OVERLAY_CODE) { clientRadio.enc = updateRadio.enc; if (clientRadio.encKey == 0) { clientRadio.encKey = 1; } } else if (clientRadio.encMode == RadioInformation.EncryptionMode.ENCRYPTION_FULL) { clientRadio.enc = updateRadio.enc; clientRadio.encKey = updateRadio.encKey; } else { clientRadio.enc = false; clientRadio.encKey = 0; } //handle volume if ((updateRadio.volMode == RadioInformation.VolumeMode.COCKPIT) || overrideFreqAndVol) { clientRadio.volume = updateRadio.volume; } //handle Channels load for radios if (newAircraft && i > 0) { if (clientRadio.freqMode == RadioInformation.FreqMode.OVERLAY) { var channelModel = _clientStateSingleton.FixedChannels[i - 1]; channelModel.Max = clientRadio.freqMax; channelModel.Min = clientRadio.freqMin; channelModel.Reload(); clientRadio.channel = -1; //reset channel if (_globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.AutoSelectPresetChannel)) { RadioHelper.RadioChannelUp(i); } } else { _clientStateSingleton.FixedChannels[i - 1].Clear(); //clear } } } } if (playerRadioInfo.simultaneousTransmissionControl == DCSPlayerRadioInfo.SimultaneousTransmissionControl.EXTERNAL_DCS_CONTROL) { playerRadioInfo.simultaneousTransmission = simul; } //change PTT last if (!_globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.AllowDCSPTT)) { playerRadioInfo.ptt = false; } else { playerRadioInfo.ptt = message.ptt; } //HANDLE IFF/TRANSPONDER UPDATE //TODO tidy up the IFF/Transponder handling and this giant function in general as its silly big :( if (message.iff.control == Transponder.IFFControlMode.COCKPIT) { playerRadioInfo.iff = message.iff; } //HANDLE MIC IDENT if (!playerRadioInfo.ptt && playerRadioInfo.iff.mic > 0 && UdpVoiceHandler.RadioSendingState.IsSending) { if (UdpVoiceHandler.RadioSendingState.SendingOn == playerRadioInfo.iff.mic) { playerRadioInfo.iff.status = Transponder.IFFStatus.IDENT; } } // } // } //update playerRadioInfo.LastUpdate = DateTime.Now.Ticks; return(changed); }