Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit 3c03e7f

Browse files
author
Ciaran Fisher
committed
Added Radio Transmit Status
Fixed Bug with VHF on C101 Added status indicator to show which radio you're receiving on - White text for frequency shows you're receiving on that radio Added transparent window slider and made window Chromeless
1 parent ddaf96b commit 3c03e7f

File tree

6 files changed

+53
-32
lines changed

6 files changed

+53
-32
lines changed

Plugin/Plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static SimpleRadio::Plugin plugin;
3636
namespace SimpleRadio
3737
{
3838
const char* Plugin::NAME = "DCS-SimpleRadio";
39-
const char* Plugin::VERSION = "1.1.5";
39+
const char* Plugin::VERSION = "1.1.6";
4040
const char* Plugin::AUTHOR = "Ciribob - GitHub.com/ciribob";
4141
const char* Plugin::DESCRIPTION = "DCS-SimpleRadio ";
4242
const char* Plugin::COMMAND_KEYWORD = "sr";

Plugin/Plugin.rc

0 Bytes
Binary file not shown.

RadioGui/MainWindow.xaml.cs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public partial class MainWindow : Window
3636

3737
private DateTime lastUpdateTime = new DateTime(0L);
3838

39-
private RadioTransmit lastRadioTransmit;
40-
private DateTime lastRadioTransmitTime = new DateTime(0L);
39+
4140

4241
const double MHZ = 1000000;
4342

@@ -184,10 +183,21 @@ private void setupActiveRadio()
184183
activeRadioUdpClient.Client.ReceiveTimeout = 10000;
185184
var receivedResults = activeRadioUdpClient.Receive(ref remoteEndPoint);
186185

187-
lastRadioTransmit = JsonConvert.DeserializeObject<RadioTransmit>(Encoding.UTF8.GetString(receivedResults));
188-
189-
lastRadioTransmitTime = DateTime.Now;
190-
186+
RadioTransmit lastRadioTransmit = JsonConvert.DeserializeObject<RadioTransmit>(Encoding.UTF8.GetString(receivedResults));
187+
switch (lastRadioTransmit.radio)
188+
{
189+
case 0:
190+
radio1.setLastRadioTransmit(lastRadioTransmit);
191+
break;
192+
case 1:
193+
radio2.setLastRadioTransmit(lastRadioTransmit);
194+
break;
195+
case 2:
196+
radio3.setLastRadioTransmit(lastRadioTransmit);
197+
break;
198+
default:
199+
break;
200+
}
191201
}
192202
catch (Exception e)
193203
{
@@ -209,24 +219,15 @@ private void setupActiveRadio()
209219
{
210220
Thread.Sleep(100);
211221

212-
//check
213-
if (lastRadioTransmit != null )
222+
Application.Current.Dispatcher.Invoke(new Action(() =>
214223
{
215-
Application.Current.Dispatcher.Invoke(new Action(() =>
216-
{
224+
radio1.repaintRadioTransmit();
225+
radio2.repaintRadioTransmit();
226+
radio3.repaintRadioTransmit();
217227

218-
//check if current
219-
long elapsedTicks = DateTime.Now.Ticks - lastRadioTransmitTime.Ticks;
220-
TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);
221-
222-
223-
radio1.updateRadioTransmit(lastRadioTransmit, elapsedSpan);
224-
radio2.updateRadioTransmit(lastRadioTransmit, elapsedSpan);
225-
radio3.updateRadioTransmit(lastRadioTransmit, elapsedSpan);
226-
227-
}));
228-
}
228+
}));
229229
}
230+
230231
});
231232

232233
}

RadioGui/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.1.5.0")]
55-
[assembly: AssemblyFileVersion("1.1.5.0")]
54+
[assembly: AssemblyVersion("1.1.6.0")]
55+
[assembly: AssemblyFileVersion("1.1.6.0")]

RadioGui/RadioControlGroup.xaml.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public partial class RadioControlGroup : UserControl
2828
private bool dragging;
2929
private RadioUpdate lastUpdate = null;
3030

31+
private RadioTransmit lastActive = null;
32+
33+
private DateTime lastActiveTime = new DateTime(0L);
34+
3135
public RadioControlGroup()
3236
{
3337
InitializeComponent();
@@ -213,23 +217,39 @@ internal void update(RadioUpdate lastUpdate, TimeSpan elapsedSpan)
213217

214218
}
215219
}
220+
221+
public void setLastRadioTransmit(RadioTransmit radio)
222+
{
223+
this.lastActive = radio;
224+
lastActiveTime = DateTime.Now;
225+
}
216226

217-
internal void updateRadioTransmit(RadioTransmit lastRadioTransmit, TimeSpan elapsedSpan)
227+
internal void repaintRadioTransmit()
218228
{
219-
220-
if (elapsedSpan.TotalSeconds > 0.5)
229+
if (this.lastActive == null)
221230
{
222231
radioFrequency.Foreground = new SolidColorBrush(Colors.Orange);
223232
}
224233
else
225234
{
226-
if(lastRadioTransmit.radio == this.radioId)
235+
//check if current
236+
long elapsedTicks = DateTime.Now.Ticks - lastActiveTime.Ticks;
237+
TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);
238+
239+
if (elapsedSpan.TotalSeconds > 0.5)
227240
{
228-
radioFrequency.Foreground = new SolidColorBrush(Colors.White);
241+
radioFrequency.Foreground = new SolidColorBrush(Colors.Orange);
229242
}
230243
else
231244
{
232-
radioFrequency.Foreground = new SolidColorBrush(Colors.Orange);
245+
if (this.lastActive.radio == this.radioId)
246+
{
247+
radioFrequency.Foreground = new SolidColorBrush(Colors.White);
248+
}
249+
else
250+
{
251+
radioFrequency.Foreground = new SolidColorBrush(Colors.Orange);
252+
}
233253
}
234254
}
235255
}

Scripts/DCS-SimpleRadio/SimpleRadioInit.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Version 1.1.5
1+
-- Version 1.1.6
22
SR = {}
33

44
SR.unicast = false -- if you've setup DCS Correctly and the plugin isn't talking to DCS,
@@ -533,7 +533,7 @@ function SR.exportRadioC101(_data)
533533

534534
if _vhfPower == 1 then
535535

536-
local _tens = SR.round(SR.getKnobPosition(0, 415,{0.1,0.3},{1,3}),0.1)*10*1000000
536+
local _tens = (SR.round(SR.getKnobPosition(0, 415,{0.1,0.4},{1,4}),0.1)/2.5) *10*1000000
537537
local _ones = SR.round(SR.getKnobPosition(0, 416,{0.0,0.9},{0,9}),0.1)*1000000
538538
local _tenth = SR.round(SR.getKnobPosition(0, 417,{0.0,0.9},{0,9}),0.1)*100000
539539
local _hundreth = SR.round(SR.getKnobPosition(0, 418,{0.0,0.3},{0,3}),0.1)*10000

0 commit comments

Comments
 (0)