1
0
Fork 0

HF radios interfaced

This commit is contained in:
legoboyvdlp R 2020-04-21 15:54:55 +01:00
parent 333d8ec00a
commit 1782383168
5 changed files with 154 additions and 61 deletions

View file

@ -961,7 +961,10 @@
</apu>
<comm>
<hf>
<tone1000hz type="bool">0</tone1000hz>
<reception-1 type="bool">1</reception-1>
<reception-2 type="bool">1</reception-2>
<tone1000hz-1 type="bool">0</tone1000hz-1>
<tone1000hz-2 type="bool">0</tone1000hz-2>
</hf>
</comm>
<electrical n="0">
@ -1541,7 +1544,11 @@
<command>nasal</command>
<script>
space(1, modifiers.getValue());
systems.HFS[0].pttToggle();
if (getprop("systems/audio/acp[0]/call_chan") == "hf1") {
systems.HFS[0].pttToggle();
} elsif (getprop("systems/audio/acp[0]/call_chan") == "hf2") {
systems.HFS[1].pttToggle();
}
</script>
</binding>
<mod-up>
@ -1553,7 +1560,11 @@
<command>nasal</command>
<script>
space(0, modifiers.getValue());
systems.HFS[0].pttToggle();
if (getprop("systems/audio/acp[0]/call_chan") == "hf1") {
systems.HFS[0].pttToggle();
} elsif (getprop("systems/audio/acp[0]/call_chan") == "hf2") {
systems.HFS[1].pttToggle();
}
</script>
</binding>
</mod-up>

View file

@ -484,8 +484,8 @@
<command>property-adjust</command>
<property>systems/radio/rmp[0]/hf1-standby</property>
<step>1</step>
<min>200</min>
<max>1800</max>
<min>2000</min>
<max>29999</max>
<wrap>true</wrap>
</binding>
@ -509,8 +509,8 @@
<command>property-adjust</command>
<property>systems/radio/rmp[0]/hf2-standby</property>
<step>1</step>
<min>200</min>
<max>1800</max>
<min>2000</min>
<max>29999</max>
<wrap>true</wrap>
</binding>
@ -750,8 +750,8 @@
<command>property-adjust</command>
<property>systems/radio/rmp[0]/hf1-standby</property>
<step>-1</step>
<min>200</min>
<max>1800</max>
<min>2000</min>
<max>29999</max>
<wrap>true</wrap>
</binding>
@ -775,8 +775,8 @@
<command>property-adjust</command>
<property>systems/radio/rmp[0]/hf2-standby</property>
<step>-1</step>
<min>200</min>
<max>1800</max>
<min>2000</min>
<max>29999</max>
<wrap>true</wrap>
</binding>
@ -894,8 +894,8 @@
<command>property-adjust</command>
<property>systems/radio/rmp[0]/hf1-standby</property>
<step>100</step>
<min>200</min>
<max>1800</max>
<min>2000</min>
<max>29999</max>
<wrap>true</wrap>
<mask>integer</mask>
</binding>
@ -920,8 +920,8 @@
<command>property-adjust</command>
<property>systems/radio/rmp[0]/hf2-standby</property>
<step>100</step>
<min>200</min>
<max>1800</max>
<min>2000</min>
<max>29999</max>
<wrap>true</wrap>
<mask>integer</mask>
</binding>
@ -1036,8 +1036,8 @@
<command>property-adjust</command>
<property>systems/radio/rmp[0]/hf1-standby</property>
<step>-100</step>
<min>200</min>
<max>1800</max>
<min>2000</min>
<max>29999</max>
<wrap>true</wrap>
<mask>integer</mask>
</binding>
@ -1062,8 +1062,8 @@
<command>property-adjust</command>
<property>systems/radio/rmp[0]/hf2-standby</property>
<step>-100</step>
<min>200</min>
<max>1800</max>
<min>2000</min>
<max>29999</max>
<wrap>true</wrap>
<mask>integer</mask>
</binding>

View file

@ -5,6 +5,22 @@
# Copyright (c) merspieler #
############################
var genFourRand = func() {
var sequence = int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10);
while (sequence < 2000 or sequence > 10000) {
sequence = int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10);
}
return sequence;
}
var genFiveRand = func() {
var sequence = int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10);
while (sequence < 10000 or sequence > 29999) {
sequence = int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10);
}
return sequence;
}
# GLOBAL TODO add stuff for HF1, HF2, VOR, LS and ADF
var chan_rmp1_v = "vhr1";
@ -15,29 +31,37 @@ var act_vhf1 = props.globals.getNode("instrumentation/comm[0]/frequencies/select
var act_vhf2 = props.globals.getNode("instrumentation/comm[1]/frequencies/selected-mhz");
var act_vhf3 = props.globals.getNode("instrumentation/comm[2]/frequencies/selected-mhz");
if (rand() > 0.5) {
var hf1 = genFourRand();
var hf2 = genFiveRand();
} else {
var hf1 = genFiveRand();
var hf2 = genFourRand();
}
var act_display_rmp1 = props.globals.initNode("/controls/radio/rmp[0]/active-display", "118.700", "STRING");
var stby_display_rmp1 = props.globals.initNode("/controls/radio/rmp[0]/standby-display", "121.400", "STRING");
var stby_rmp1_vhf1 = props.globals.initNode("/systems/radio/rmp[0]/vhf1-standby", 121.4, "DOUBLE");
var stby_rmp1_vhf2 = props.globals.initNode("/systems/radio/rmp[0]/vhf2-standby", 122.6, "DOUBLE");
var stby_rmp1_vhf3 = props.globals.initNode("/systems/radio/rmp[0]/vhf3-standby", 123.2, "DOUBLE");
var stby_rmp1_hf1 = props.globals.initNode("/systems/radio/rmp[0]/hf1-standby", 12501, "DOUBLE");
var stby_rmp1_hf2 = props.globals.initNode("/systems/radio/rmp[0]/hf2-standby", 2809, "DOUBLE");
var stby_rmp1_hf1 = props.globals.initNode("/systems/radio/rmp[0]/hf1-standby", hf1, "DOUBLE");
var stby_rmp1_hf2 = props.globals.initNode("/systems/radio/rmp[0]/hf2-standby", hf2, "DOUBLE");
var act_display_rmp2 = props.globals.initNode("/controls/radio/rmp[1]/active-display", "119.400", "STRING");
var stby_display_rmp2 = props.globals.initNode("/controls/radio/rmp[1]/standby-display", "122.600", "STRING");
var stby_rmp2_vhf1 = props.globals.initNode("/systems/radio/rmp[1]/vhf1-standby", 121.4, "DOUBLE");
var stby_rmp2_vhf2 = props.globals.initNode("/systems/radio/rmp[1]/vhf2-standby", 122.6, "DOUBLE");
var stby_rmp2_vhf3 = props.globals.initNode("/systems/radio/rmp[1]/vhf3-standby", 123.2, "DOUBLE");
var stby_rmp2_hf1 = props.globals.initNode("/systems/radio/rmp[1]/hf1-standby", 22801, "DOUBLE");
var stby_rmp2_hf2 = props.globals.initNode("/systems/radio/rmp[1]/hf2-standby", 6079, "DOUBLE");
var stby_rmp2_hf1 = props.globals.initNode("/systems/radio/rmp[1]/hf1-standby", hf1, "DOUBLE");
var stby_rmp2_hf2 = props.globals.initNode("/systems/radio/rmp[1]/hf2-standby", hf2, "DOUBLE");
var act_display_rmp3 = props.globals.initNode("/controls/radio/rmp[2]/active-display", "data", "STRING");
var stby_display_rmp3 = props.globals.initNode("/controls/radio/rmp[2]/standby-display", "123.200", "STRING");
var stby_rmp3_vhf1 = props.globals.initNode("/systems/radio/rmp[2]/vhf1-standby", 121.4, "DOUBLE");
var stby_rmp3_vhf2 = props.globals.initNode("/systems/radio/rmp[2]/vhf2-standby", 122.6, "DOUBLE");
var stby_rmp3_vhf3 = props.globals.initNode("/systems/radio/rmp[2]/vhf3-standby", 123.2, "DOUBLE");
var stby_rmp3_hf1 = props.globals.initNode("/systems/radio/rmp[2]/hf1-standby", 8650, "DOUBLE");
var stby_rmp3_hf2 = props.globals.initNode("/systems/radio/rmp[2]/hf2-standby", 18506, "DOUBLE");
var stby_rmp3_hf1 = props.globals.initNode("/systems/radio/rmp[2]/hf1-standby", hf1, "DOUBLE");
var stby_rmp3_hf2 = props.globals.initNode("/systems/radio/rmp[2]/hf2-standby", hf2, "DOUBLE");
var chan_rmp1 = props.globals.initNode("/systems/radio/rmp[0]/sel_chan", "vhf1", "STRING");
var chan_rmp2 = props.globals.initNode("/systems/radio/rmp[1]/sel_chan", "vhf2", "STRING");

View file

@ -3,21 +3,20 @@
# Copyright (c) 2020 Josh Davidson (Octal450)
var toneControl = props.globals.getNode("/systems/comm/hf/tone1000hz");
var reception = props.globals.getNode("/systems/comm/hf/reception");
var _toneTime = nil;
var highFrequencyRadio = {
selectedChannelKhz: int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10),
transmit: 0,
tuned: 0,
overrideDataLink: 0,
datalinkConnected: 0,
_transmitTime: nil,
new: func(powerNode, num) {
var a = { parents:[highFrequencyRadio] };
a.powerNode = powerNode;
a.selectedChannelKhz = int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10) ~ int(rand() * 10);
a.num = num;
a.receptionProp = props.globals.getNode("/systems/comm/hf/reception-" ~ (num + 1));
a.toneControl = props.globals.getNode("/systems/comm/hf/tone1000hz-" ~ (num + 1));
a._toneTime = nil;
a._transmitTime = nil;
a.transmit = 0;
a.tuned = 0;
return a;
},
selectChannel: func(selectedKhz) {
@ -35,15 +34,20 @@ var highFrequencyRadio = {
if (me.transmit) {
me.transmit = 0;
reception.setValue(1);
me.receptionProp.setValue(1);
} else {
me.transmit = 1;
reception.setValue(0);
me.receptionProp.setValue(0);
}
if (me.transmit) {
_transmitTime = pts.Sim.Time.elapsedSec.getValue();
transmitTimer.start();
me._transmitTime = pts.Sim.Time.elapsedSec.getValue();
if (me.num == 0) {
transmitTimer1.start();
} else {
transmitTimer2.start();
}
if (me.selectedChannelKhz < 2800 or me.selectedChannelKhz > 23999) {
me.generate1000Hz();
return;
@ -53,28 +57,37 @@ var highFrequencyRadio = {
me.tuned = 1;
}
} else {
transmitTimer.stop();
ecam.transmitFlag = 0;
if (_toneTime == nil) {
toneControl.setValue(0);
if (me.num == 0) {
transmitTimer1.stop();
} else {
transmitTimer2.stop();
}
_transmitTime = nil;
ecam.transmitFlag = 0;
if (me._toneTime == nil) {
me.toneControl.setValue(0);
}
me._transmitTime = nil;
}
},
monitorPTT: func() {
if (me.transmit) {
if (pts.Sim.Time.elapsedSec.getValue() > _transmitTime + 60) {
if (pts.Sim.Time.elapsedSec.getValue() > me._transmitTime + 60) {
ecam.transmitFlag = 1;
}
}
},
generate1000Hz: func(timeSec = 0) {
if (timeSec == 0) {
toneControl.setValue(1);
me.toneControl.setValue(1);
} else {
toneControl.setValue(1);
_toneTime = pts.Sim.Time.elapsedSec.getValue() + timeSec;
toneTimer.start();
me.toneControl.setValue(1);
me._toneTime = pts.Sim.Time.elapsedSec.getValue() + timeSec;
if (me.num == 0) {
toneTimer1.start();
} else {
toneTimer2.start();
}
}
},
datalink: func() {
@ -94,14 +107,25 @@ var highFrequencyRadio = {
var HFS = [highFrequencyRadio.new(systems.ELEC.Bus.acEssShed, 0), highFrequencyRadio.new(systems.ELEC.Bus.ac2, 1)];
var toneTimer = maketimer(1, func() {
if (pts.Sim.Time.elapsedSec.getValue() > _toneTime) {
toneControl.setValue(0);
_toneTime = nil;
toneTimer.stop();
var toneTimer1 = maketimer(1, func() {
if (pts.Sim.Time.elapsedSec.getValue() > HFS[0]._toneTime) {
HFS[0].toneControl.setValue(0);
HFS[0]._toneTime = nil;
toneTimer1.stop();
}
});
var transmitTimer = maketimer(1, func() {
var toneTimer2 = maketimer(1, func() {
if (pts.Sim.Time.elapsedSec.getValue() > HFS[1]._toneTime) {
HFS[1].toneControl.setValue(0);
HFS[1]._toneTime = nil;
toneTimer1.stop();
}
});
var transmitTimer1 = maketimer(1, func() {
HFS[0].monitorPTT();
});
var transmitTimer2 = maketimer(1, func() {
HFS[1].monitorPTT();
});

View file

@ -1477,13 +1477,29 @@
<condition>
<and>
<property>/sim/current-view/internal</property>
<equals>
<property>/systems/comm/hf/tone1000hz</property>
<value>1</value>
</equals>
<property>/systems/comm/hf/tone1000hz-1</property>
<property>/controls/audio/acp[0]/hf1-recive</property>
</and>
</condition>
<volume>
<property>controls/audio/acp[0]/hf1-volume</property>
<factor>0.4</factor>
</volume>
</hftone>
<hftone>
<name>HF PTT tone 2</name>
<mode>looped</mode>
<path>Aircraft/A320-family/Sounds/Cockpit/1000hz.wav</path>
<condition>
<and>
<property>/sim/current-view/internal</property>
<property>/systems/comm/hf/tone1000hz-2</property>
<property>/controls/audio/acp[0]/hf2-recive</property>
</and>
</condition>
<volume>
<property>controls/audio/acp[0]/hf2-volume</property>
<factor>0.4</factor>
</volume>
</hftone>
@ -1495,13 +1511,31 @@
<condition>
<and>
<property>/sim/current-view/internal</property>
<equals>
<property>/systems/comm/hf/reception</property>
<value>1</value>
</equals>
<property>/systems/comm/hf/reception-1</property>
<property>/controls/audio/acp[0]/hf1-recive</property>
<not><property>/systems/comm/hf/tone1000hz-1</property></not>
</and>
</condition>
<volume>
<property>controls/audio/acp[0]/hf1-volume</property>
<factor>0.4</factor>
</volume>
</hfstatic>
<hfstatic>
<name>HF static 2</name>
<mode>looped</mode>
<path>Aircraft/A320-family/Sounds/Cockpit/hf-radio-static.wav</path>
<condition>
<and>
<property>/sim/current-view/internal</property>
<property>/systems/comm/hf/reception-2</property>
<property>/controls/audio/acp[0]/hf2-recive</property>
<not><property>/systems/comm/hf/tone1000hz-2</property></not>
</and>
</condition>
<volume>
<property>controls/audio/acp[0]/hf2-volume</property>
<factor>0.4</factor>
</volume>
</hfstatic>