mirror of
https://github.com/weyne85/DCS-ExportScripts.git
synced 2025-10-29 16:58:18 +00:00
add new genericRadio config und function call
This commit is contained in:
parent
42b165c8b0
commit
51dc87a294
@ -848,7 +848,114 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
|
||||
|
||||
-- generic Radio display and frequency rotarys
|
||||
-------------------------------------------------
|
||||
ExportScript.genericRadio(nil, nil, ExportScript.Config.genericRadioHardwareID)
|
||||
-- genericRadioConf
|
||||
ExportScript.genericRadioConf = {}
|
||||
ExportScript.genericRadioConf['maxRadios'] = 3 -- numbers of aviables/supported radios
|
||||
ExportScript.genericRadioConf[1] = {} -- first radio
|
||||
ExportScript.genericRadioConf[1]['Name'] = "AN/ARC-164 UHF" -- name of radio
|
||||
ExportScript.genericRadioConf[1]['DeviceID'] = 54 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[1]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[1]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[1]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[1]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[1]['minFrequency'] = 220.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[1]['maxFrequency'] = 314.450 -- highest frequency
|
||||
ExportScript.genericRadioConf[1]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[1]['Power']['ButtonID'] = 3008 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Power']['ValueOn'] = 0.1 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[1]['Volume']['ButtonID'] = 3011 -- volume button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Preset'] = {} -- preset knob active
|
||||
ExportScript.genericRadioConf[1]['Preset']['ArgumentID'] = 161 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
ExportScript.genericRadioConf[1]['Preset']['List'] = {[0.0]="01",[0.05]="02",[0.10]="03",[0.15]="04",[0.20]="05",[0.25]="06",[0.30]="07",[0.35]="08",[0.40]="09",[0.45]="10",[0.50]="11",[0.55]="12",[0.60]="13",[0.65]="14",[0.70]="15",[0.75]="16",[0.80]="17",[0.85]="18",[0.90]="19",[0.95]="20",[1.00]="01"}
|
||||
ExportScript.genericRadioConf[1]['Preset']['Step'] = 0.05 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[1]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ArgumentID'] = 170 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ButtonID'] = 3010 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ValueOn'] = 0.0 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ValueOff'] = 1.0 -- squelch off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Load'] = {} -- load button preset
|
||||
ExportScript.genericRadioConf[1]['Load']['ButtonID'] = 3015 -- load button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['ManualPreset'] = {} -- switch manual or preset active
|
||||
ExportScript.genericRadioConf[1]['ManualPreset']['ArgumentID'] = 167 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['ManualPreset']['ButtonID'] = 3007 -- ManualPreset button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['ManualPreset']['ValueManual'] = 0.0-- ManualPreset Manual value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['ManualPreset']['ValuePreset'] = 0.1-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadioConf[2] = {} -- secound radio
|
||||
ExportScript.genericRadioConf[2]['Name'] = "AN/ARC-186(V) VHF FM" -- name of radio
|
||||
ExportScript.genericRadioConf[2]['DeviceID'] = 55 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[2]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[2]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[2]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[2]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[2]['minFrequency'] = 116.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[2]['maxFrequency'] = 151.975 -- highest frequency
|
||||
ExportScript.genericRadioConf[2]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[2]['Power']['ButtonID'] = 3003 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Power']['ValueOn'] = 0.1 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[2]['Volume']['ButtonID'] = 3005 -- volume button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Preset'] = {} -- preset knob active
|
||||
ExportScript.genericRadioConf[2]['Preset']['ArgumentID'] = 137 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
ExportScript.genericRadioConf[2]['Preset']['List'] = {[0.0]="01",[0.01]="02",[0.02]="03",[0.03]="04",[0.04]="05",[0.05]="06",[0.06]="07",[0.07]="08",[0.08]="09",[0.09]="10",[0.10]="11",[0.11]="12",[0.12]="13",[0.13]="14",[0.14]="15",[0.15]="16",[0.16]="17",[0.17]="18",[0.18]="19",[0.19]="20",[0.20]="01"}
|
||||
ExportScript.genericRadioConf[2]['Preset']['Step'] = 0.01 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[2]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ArgumentID'] = 134 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ButtonID'] = 3008 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ValueOn'] = 0.0 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ValueOff'] = 1.0 -- squelch off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Load'] = {} -- load button preset
|
||||
ExportScript.genericRadioConf[2]['Load']['ButtonID'] = 3006 -- load button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset'] = {} -- switch manual or preset active
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ArgumentID'] = 135 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ButtonID'] = 3004 -- ManualPreset button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ValueManual'] = 0.2-- ManualPreset Manual value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ValuePreset'] = 0.3-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadioConf[3] = {} -- secound radio
|
||||
ExportScript.genericRadioConf[3]['Name'] = "AN/ARC-186(V) VHF AM" -- name of radio
|
||||
ExportScript.genericRadioConf[3]['DeviceID'] = 56 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[3]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[3]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[3]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[3]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[3]['minFrequency'] = 30.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[3]['maxFrequency'] = 76.000 -- highest frequency
|
||||
ExportScript.genericRadioConf[3]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[3]['Power']['ButtonID'] = 3003 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Power']['ValueOn'] = 0.1 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[3]['Volume']['ButtonID'] = 3005 -- volume button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Preset'] = {} -- preset knob active
|
||||
ExportScript.genericRadioConf[3]['Preset']['ArgumentID'] = 151 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Preset']['ButtonID2'] = 3002 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
ExportScript.genericRadioConf[3]['Preset']['List'] = {[0.0]="01",[0.01]="02",[0.02]="03",[0.03]="04",[0.04]="05",[0.05]="06",[0.06]="07",[0.07]="08",[0.08]="09",[0.09]="10",[0.10]="11",[0.11]="12",[0.12]="13",[0.13]="14",[0.14]="15",[0.15]="16",[0.16]="17",[0.17]="18",[0.18]="19",[0.19]="20",[0.20]="01"}
|
||||
ExportScript.genericRadioConf[3]['Preset']['Step'] = 0.01 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[3]['Preset']['Step2'] = -0.01 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[3]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[3]['Squelch']['ArgumentID'] = 148 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Squelch']['ButtonID'] = 3008 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Squelch']['ValueOn'] = 0.0 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Squelch']['ValueOff'] = -1.0 -- squelch off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Load'] = {} -- load button preset
|
||||
ExportScript.genericRadioConf[3]['Load']['ButtonID'] = 3004 -- load button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['ManualPreset'] = {} -- switch manual or preset active
|
||||
ExportScript.genericRadioConf[3]['ManualPreset']['ArgumentID'] = 149 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['ManualPreset']['ButtonID'] = 3004 -- ManualPreset button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['ManualPreset']['ValueManual'] = 0.2-- ManualPreset Manual value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['ManualPreset']['ValuePreset'] = 0.3-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadio(nil, nil)
|
||||
|
||||
-- NOT FOR ARCAZE
|
||||
-------------------------------------------------
|
||||
@ -971,651 +1078,4 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
|
||||
|
||||
--getIndicatorData(3)
|
||||
|
||||
end
|
||||
|
||||
nextCDUIndicatorTime = 0
|
||||
function getIndicatorData(indicator_number)
|
||||
local pairData = ""
|
||||
local curTime = LoGetModelTime()
|
||||
if curTime >= nextCDUIndicatorTime then
|
||||
nextCDUIndicatorTime = curTime + .15
|
||||
local indicator = list_indication(indicator_number)
|
||||
if indicator ~= "" then
|
||||
for brace in indicator:gmatch("%b{}") do
|
||||
local lines = string.gsub(string.gsub(brace,"[{}]",""),"---+","")
|
||||
for data in lines:gmatch("[%w_]+\n[^\n]+") do
|
||||
pairData = pairData..string.gsub(data, "\n", "<==>")..'\n'
|
||||
end
|
||||
end
|
||||
--sendCduData(pairData, cduAppHost, cduAppPort)
|
||||
ExportScript.Tools.WriteToLog('indicator: '..ExportScript.Tools.dump(indicator))
|
||||
ExportScript.Tools.WriteToLog('pairData: '..ExportScript.Tools.dump(pairData))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------
|
||||
-- Custom functions --
|
||||
-----------------------------
|
||||
|
||||
function ExportScript.genericRadio(key, value, hardware)
|
||||
local lHardware = hardware or 1
|
||||
-- Werte werden per Encoder im Bereich von 0.0 bis 2.0 in 0.1 Schritten uebergeben
|
||||
-- im jeweiligen Abschnitt muessen die Eingangsdaten auf den Zulaessigen Bereich eingeschraengt werden
|
||||
local lRotaryFrequency_1, lRotaryFrequency_2, lVolume, lPreset, lLoad, lSquelch, lManualPreset, lPower, lDevice, lClickAction, lSetFrequency = nil
|
||||
local lMainPanelDevice = GetDevice(0)
|
||||
local lMaxRadios = 3
|
||||
|
||||
if ExportScript.AF.genericRadio == nil then
|
||||
ExportScript.AF.genericRadio = 0
|
||||
end
|
||||
if ExportScript.AF.genericRadioFrequency1 == nil then
|
||||
ExportScript.AF.genericRadioFrequency1 = 0.0
|
||||
end
|
||||
if ExportScript.AF.genericRadioFrequency2 == nil then
|
||||
ExportScript.AF.genericRadioFrequency2 = 0.0
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetChannel == nil then
|
||||
ExportScript.AF.genericRadioPresetChannel = 0.0
|
||||
end
|
||||
if ExportScript.AF.genericRadioPower == nil then
|
||||
ExportScript.AF.genericRadioPower = {}
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetManual == nil then
|
||||
ExportScript.AF.genericRadioPresetManual = {}
|
||||
end
|
||||
if ExportScript.AF.genericRadioSquelch == nil then
|
||||
ExportScript.AF.genericRadioSquelch = {}
|
||||
end
|
||||
|
||||
if key == "3001" then
|
||||
ExportScript.AF.genericRadio = tonumber(value)
|
||||
end
|
||||
if key == "3002" then
|
||||
lRotaryFrequency_1 = tonumber(value)
|
||||
end
|
||||
if key == "3003" then
|
||||
lRotaryFrequency_2 = tonumber(value)
|
||||
end
|
||||
if key == "3004" then
|
||||
lVolume = tonumber(value)
|
||||
end
|
||||
if key == "3005" then
|
||||
lPreset = tonumber(value)
|
||||
end
|
||||
if key == "3006" then
|
||||
lLoad = tonumber(value)
|
||||
end
|
||||
if key == "3007" then
|
||||
lSquelch = tonumber(value)
|
||||
end
|
||||
if key == "3008" then
|
||||
lManualPreset = tonumber(value)
|
||||
end
|
||||
if key == "3009" then
|
||||
lPower = tonumber(value)
|
||||
end
|
||||
|
||||
if ExportScript.AF.genericRadio > lMaxRadios then
|
||||
ExportScript.Tools.WriteToLog("Radio Nr. "..ExportScript.AF.genericRadio.." not defined.")
|
||||
return
|
||||
end
|
||||
|
||||
if ExportScript.AF.genericRadio == 1 then
|
||||
-- AN/ARC-164 UHF ###.###
|
||||
---------------------------------------------------
|
||||
local lDeviceID = 54
|
||||
local lUHF_RADIO = GetDevice(lDeviceID)
|
||||
|
||||
-- check status of the radio
|
||||
if ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == nil then
|
||||
if lUHF_RADIO:is_on() then
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
else
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0.0
|
||||
end
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(167), 1) == 0) and 0 or 1)
|
||||
end
|
||||
if ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(170), 1) == 0) and 1 or 0)
|
||||
end
|
||||
|
||||
if lUHF_RADIO:is_on() then
|
||||
local lPresetChannel = list_indication(10)
|
||||
lPresetChannel = lPresetChannel:gsub("-----------------------------------------", "")
|
||||
lPresetChannel = lPresetChannel:gsub("txtPresetChannel", "")
|
||||
lPresetChannel = lPresetChannel:gsub("%c", "")
|
||||
|
||||
local lUHF_RADIO_FREQUENCY = ExportScript.Tools.round(lUHF_RADIO:get_frequency()/1000000 , 3, "floor")
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3000", string.format("%s%.3f", lPresetChannel, lUHF_RADIO_FREQUENCY), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", string.format("%s", lPresetChannel), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", string.format("%.3f", lUHF_RADIO_FREQUENCY), lHardware)
|
||||
|
||||
if lRotaryFrequency_1 ~= nil and (lRotaryFrequency_1 >= 0.0 and lRotaryFrequency_1 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lUHF_RADIO_FREQUENCY, "%.") -- %. um den Punkt als Punkt zu suchen
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_1 < ExportScript.AF.genericRadioFrequency1 or lRotaryFrequency_1 == 0.0 or lRotaryFrequency_1 == 2.0 then
|
||||
lFrequency[1] = lFrequency[1] - 1
|
||||
if lFrequency[1] == 219 then
|
||||
lFrequency[1] = 314
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
else
|
||||
lFrequency[1] = lFrequency[1] + 1
|
||||
if lFrequency[1] == 315 then
|
||||
lFrequency[1] = 220
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("1. generic A-10C UHF Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lRotaryFrequency_2 ~= nil and (lRotaryFrequency_2 >= 0.0 and lRotaryFrequency_2 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lUHF_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_2 < ExportScript.AF.genericRadioFrequency2 or lRotaryFrequency_2 == 0.0 or lRotaryFrequency_2 == 2.0 then
|
||||
lFrequency[2] = lFrequency[2] - 25
|
||||
if lFrequency[2] == -25 then
|
||||
lFrequency[2] = 975
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
else
|
||||
lFrequency[2] = lFrequency[2] + 25
|
||||
if lFrequency[2] == 1000 then
|
||||
lFrequency[2] = 0
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("2. generic A-10C UHF Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
if lPreset ~= nil and (lPreset >= 0.0 and lPreset <= 1.9) then
|
||||
-- Preset 0.0 to 0.95 in 0.05 steps
|
||||
lPreset = lPreset / 2
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = lPreset}
|
||||
end
|
||||
|
||||
else
|
||||
ExportScript.Tools.SendDataDAC("3000", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", "-", lHardware)
|
||||
end
|
||||
|
||||
if lVolume ~= nil and (lVolume >= 0.0 and lVolume <= 2.0) then
|
||||
lVolume = lVolume / 2
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3011,
|
||||
Value = lVolume}
|
||||
end
|
||||
if lLoad ~= nil and (lLoad == 0.0 or lLoad <= 1.0) then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3015,
|
||||
Value = lLoad}
|
||||
end
|
||||
if lSquelch ~= nil and (lSquelch == 0.0 or lSquelch <= 1.0) then
|
||||
if lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Squelch off
|
||||
lSquelch = 1.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 0
|
||||
elseif lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Squelch on
|
||||
lSquelch = 0.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3010,
|
||||
Value = lSquelch}
|
||||
end
|
||||
if lManualPreset ~= nil and (lManualPreset == 0.0 or lManualPreset <= 1.0) then
|
||||
if lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Manual
|
||||
lManualPreset = 0.0
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 0
|
||||
elseif lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Preset
|
||||
lManualPreset = 0.1
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3007,
|
||||
Value = lManualPreset}
|
||||
end
|
||||
if lPower ~= nil and (lPower == 0.0 or lPower <= 1.0) then
|
||||
if lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lPower = 0.0
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0
|
||||
elseif lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 0 then
|
||||
--Power on
|
||||
lPower = 0.1
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3008,
|
||||
Value = lPower}
|
||||
end
|
||||
|
||||
elseif ExportScript.AF.genericRadio == 2 then
|
||||
-- AN/ARC-186(V) VHF AM ###.###
|
||||
---------------------------------------------------
|
||||
local lDeviceID = 55
|
||||
local lVHF_AM_RADIO = GetDevice(lDeviceID)
|
||||
|
||||
-- check status of the radio
|
||||
if ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == nil then
|
||||
if lVHF_AM_RADIO:is_on() then
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
else
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0.0
|
||||
end
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(135), 1) == 0.1) and 1 or 0)
|
||||
end
|
||||
if ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(134), 1) == 1.0) and 0 or 1)
|
||||
end
|
||||
|
||||
local lVHF_AM_RADIO_PRESET = {[0.0]="01",[0.01]="02",[0.02]="03",[0.03]="04",[0.04]="05",[0.05]="06",[0.06]="07",[0.07]="08",[0.08]="09",[0.09]="10",[0.10]="11",[0.11]="12",[0.12]="13",[0.13]="14",[0.14]="15",[0.15]="16",[0.16]="17",[0.17]="18",[0.18]="19",[0.19]="20",[0.20]="01"}
|
||||
local lVHF_AM_RADIO_FREQUENCY = ExportScript.Tools.round(lVHF_AM_RADIO:get_frequency()/1000000 , 3, "floor")
|
||||
|
||||
local lPresetChannel = ExportScript.Tools.round(lMainPanelDevice:get_argument_value(137), 2)
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3000", string.format("%s%.3f", lVHF_AM_RADIO_PRESET[lPresetChannel], lVHF_AM_RADIO_FREQUENCY), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", string.format("%s", lVHF_AM_RADIO_PRESET[lPresetChannel]), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", string.format("%.3f", lVHF_AM_RADIO_FREQUENCY), lHardware)
|
||||
|
||||
if lRotaryFrequency_1 ~= nil and (lRotaryFrequency_1 >= 0.0 and lRotaryFrequency_1 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lVHF_AM_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_1 < ExportScript.AF.genericRadioFrequency1 or lRotaryFrequency_1 == 0.0 or lRotaryFrequency_1 == 2.0 then
|
||||
lFrequency[1] = lFrequency[1] - 1
|
||||
if lFrequency[1] == 29 then
|
||||
lFrequency[1] = 159
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
else
|
||||
lFrequency[1] = lFrequency[1] + 1
|
||||
if lFrequency[1] == 160 then
|
||||
lFrequency[1] = 30
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("1. generic A-10C VHF AM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lRotaryFrequency_2 ~= nil and (lRotaryFrequency_2 >= 0.0 and lRotaryFrequency_2 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lVHF_AM_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_2 < ExportScript.AF.genericRadioFrequency2 or lRotaryFrequency_2 == 0.0 or lRotaryFrequency_2 == 2.0 then
|
||||
lFrequency[2] = lFrequency[2] - 25
|
||||
if lFrequency[2] == -25 then
|
||||
lFrequency[2] = 975
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
else
|
||||
lFrequency[2] = lFrequency[2] + 25
|
||||
if lFrequency[2] == 1000 then
|
||||
lFrequency[2] = 0
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("2. generic A-10C VHF AM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
if lVolume ~= nil and (lVolume >= 0.0 and lVolume <= 2.0) then
|
||||
lVolume = lVolume / 2
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3005,
|
||||
Value = lVolume}
|
||||
end
|
||||
if lPreset ~= nil and (lPreset >= 0.0 and lPreset <= 2.0) then
|
||||
-- Preset 0.0 to 0.20 in 0.01 steps
|
||||
if lPreset < ExportScript.AF.genericRadioPresetChannel or lPreset == 0.0 or lPreset == 2.0 then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = 0.01}
|
||||
ExportScript.AF.genericRadioPresetChannel = lPreset
|
||||
else
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3002,
|
||||
Value = -0.01}
|
||||
ExportScript.AF.genericRadioPresetChannel = lPreset
|
||||
end
|
||||
end
|
||||
if lLoad ~= nil and (lLoad == 0.0 or lLoad <= 1.0) then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3006,
|
||||
Value = lLoad}
|
||||
end
|
||||
if lSquelch ~= nil and (lSquelch == 0.0 or lSquelch <= 1.0) then
|
||||
if lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Squelch off
|
||||
lSquelch = -1.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 0
|
||||
elseif lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Squelch on
|
||||
lSquelch = 0.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3008,
|
||||
Value = lSquelch}
|
||||
end
|
||||
if lManualPreset ~= nil and (lManualPreset == 0.0 or lManualPreset <= 1.0) then
|
||||
if lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Manual on
|
||||
lManualPreset = 0.2
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 0
|
||||
elseif lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Preset on
|
||||
lManualPreset = 0.3
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3004,
|
||||
Value = lManualPreset}
|
||||
end
|
||||
if lPower ~= nil and (lPower == 0.0 or lPower <= 1.0) then
|
||||
if lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lPower = 0.0
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0
|
||||
elseif lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Power on
|
||||
lPower = 0.1
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3003,
|
||||
Value = lPower}
|
||||
end
|
||||
|
||||
elseif ExportScript.AF.genericRadio == 3 then
|
||||
-- AN/ARC-186(V) VHF FM ##.###
|
||||
-------------------------------------------------
|
||||
local lDeviceID = 56
|
||||
local lVHF_FM_RADIO = GetDevice(lDeviceID)
|
||||
|
||||
-- check status of the radio
|
||||
if ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == nil then
|
||||
if lVHF_FM_RADIO:is_on() then
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
else
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0.0
|
||||
end
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(149), 1) == 0.1) and 1 or 0)
|
||||
end
|
||||
if ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(148), 1) == 1.0) and 0 or 1)
|
||||
end
|
||||
|
||||
local lVHF_FM_RADIO_Frequency = ExportScript.Tools.round(lVHF_FM_RADIO:get_frequency()/1000000 , 3, "floor")
|
||||
if lVHF_FM_RADIO_Frequency > 99.999 then
|
||||
lVHF_FM_RADIO_Frequency = string.format("%.3f", lVHF_FM_RADIO_Frequency)
|
||||
else
|
||||
lVHF_FM_RADIO_Frequency = string.format("0%.3f", lVHF_FM_RADIO_Frequency)
|
||||
end
|
||||
-- Preset is buggy
|
||||
local lVHF_FM_RADIO_PRESET = {[0.0]="01",[0.01]="02",[0.02]="03",[0.03]="04",[0.04]="05",[0.05]="06",[0.06]="07",[0.07]="08",[0.08]="09",[0.09]="10",[0.10]="11",[0.11]="12",[0.12]="13",[0.13]="14",[0.14]="15",[0.15]="16",[0.16]="17",[0.17]="18",[0.18]="19",[0.19]="20",[0.20]="01"}
|
||||
|
||||
local lPresetChannel = ExportScript.Tools.round(lMainPanelDevice:get_argument_value(151), 2, "ceil")
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3000", string.format("%s%s", lVHF_FM_RADIO_PRESET[lPresetChannel], lVHF_FM_RADIO_Frequency), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", string.format("%s", lVHF_FM_RADIO_PRESET[lPresetChannel]), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", string.format("%s", lVHF_FM_RADIO_Frequency), lHardware)
|
||||
|
||||
if lRotaryFrequency_1 ~= nil and (lRotaryFrequency_1 >= 0.0 and lRotaryFrequency_1 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lVHF_FM_RADIO_Frequency, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_1 < ExportScript.AF.genericRadioFrequency1 or lRotaryFrequency_1 == 0.0 or lRotaryFrequency_1 == 2.0 then
|
||||
lFrequency[1] = lFrequency[1] - 1
|
||||
if lFrequency[1] == 29 then
|
||||
lFrequency[1] = 76
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
else
|
||||
lFrequency[1] = lFrequency[1] + 1
|
||||
if lFrequency[1] == 77 then
|
||||
lFrequency[1] = 30
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("1. generic A-10C VHF FM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lRotaryFrequency_2 ~= nil and (lRotaryFrequency_2 >= 0.0 and lRotaryFrequency_2 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lVHF_FM_RADIO_Frequency, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_2 < ExportScript.AF.genericRadioFrequency2 or lRotaryFrequency_2 == 0.0 or lRotaryFrequency_2 == 2.0 then
|
||||
lFrequency[2] = lFrequency[2] - 25
|
||||
if lFrequency[2] == -25 then
|
||||
lFrequency[2] = 975
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
else
|
||||
lFrequency[2] = lFrequency[2] + 25
|
||||
if lFrequency[2] == 1000 then
|
||||
lFrequency[2] = 0
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("2. generic A-10C VHF FM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
if lVolume ~= nil and (lVolume >= 0.0 and lVolume <= 2.0) then
|
||||
lVolume = lVolume / 2
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3005,
|
||||
Value = lVolume}
|
||||
end
|
||||
if lPreset ~= nil and (lPreset >= 0.0 and lPreset <= 2.0) then
|
||||
-- Preset 0.0 to 0.20 in 0.01 steps
|
||||
if lPreset < ExportScript.AF.genericRadioPresetChannel or lPreset == 0.0 or lPreset == 2.0 then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = 0.01}
|
||||
ExportScript.AF.genericRadioPresetChannel = lPreset
|
||||
else
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3002,
|
||||
Value = -0.01}
|
||||
ExportScript.AF.genericRadioPresetChannel = lPreset
|
||||
end
|
||||
end
|
||||
if lLoad ~= nil and (lLoad == 0.0 or lLoad <= 1.0) then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3006,
|
||||
Value = lLoad}
|
||||
end
|
||||
if lSquelch ~= nil and (lSquelch == 0.0 or lSquelch <= 1.0) then
|
||||
if lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Squelch off
|
||||
lSquelch = -1.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 0
|
||||
elseif lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Squelch on
|
||||
lSquelch = 0.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3008,
|
||||
Value = lSquelch}
|
||||
end
|
||||
if lManualPreset ~= nil and (lManualPreset == 0.0 or lManualPreset <= 1.0) then
|
||||
if lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Manual on
|
||||
lManualPreset = 0.2
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 0
|
||||
elseif lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Preset on
|
||||
lManualPreset = 0.3
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3004,
|
||||
Value = lManualPreset}
|
||||
end
|
||||
if lPower ~= nil and (lPower == 0.0 or lPower <= 1.0) then
|
||||
if lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lPower = 0.0
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0
|
||||
elseif lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Power on
|
||||
lPower = 0.1
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3003,
|
||||
Value = lPower}
|
||||
end
|
||||
|
||||
else
|
||||
ExportScript.Tools.SendDataDAC("3000", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3010", 0, lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3011", 0, lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3012", 0, lHardware)
|
||||
return
|
||||
end
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3010", ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio], lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3011", ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio], lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3012", ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio], lHardware)
|
||||
|
||||
if lClickAction ~= nil then
|
||||
lDevice = GetDevice(lClickAction.DeviceID)
|
||||
if type(lDevice) == "table" then
|
||||
--ExportScript.Tools.WriteToLog("GetDevice("..lClickAction.DeviceID.."):performClickableAction("..lClickAction.ButtonID..", "..lClickAction.Value..") ")
|
||||
lDevice:performClickableAction(lClickAction.ButtonID, lClickAction.Value)
|
||||
end
|
||||
elseif lSetFrequency ~= nil then
|
||||
lDevice = GetDevice(lSetFrequency.DeviceID)
|
||||
if type(lDevice) == "table" and lDevice:is_on() then
|
||||
--ExportScript.Tools.WriteToLog("GetDevice("..lSetFrequency.DeviceID.."):set_frequency("..lSetFrequency.Frequency..") ")
|
||||
lDevice:set_frequency(lSetFrequency.Frequency)
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("GetDevice("..lSetFrequency.DeviceID..") is no table or Radio is not on")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1027,7 +1027,81 @@ function ExportScript.ProcessDACConfigHighImportance(mainPanelDevice)
|
||||
|
||||
-- generic Radio display and frequency rotarys
|
||||
-------------------------------------------------
|
||||
ExportScript.genericRadio(nil, nil, ExportScript.Config.genericRadioHardwareID)
|
||||
-- genericRadioConf
|
||||
ExportScript.genericRadioConf = {}
|
||||
ExportScript.genericRadioConf['maxRadios'] = 2 -- numbers of aviables/supported radios
|
||||
ExportScript.genericRadioConf[1] = {} -- first radio
|
||||
ExportScript.genericRadioConf[1]['Name'] = "R_800 FM/AM" -- name of radio
|
||||
ExportScript.genericRadioConf[1]['DeviceID'] = 48 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[1]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[1]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[1]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[1]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[1]['minFrequency'] = 100.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[1]['maxFrequency'] = 399.975 -- highest frequency
|
||||
ExportScript.genericRadioConf[1]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[1]['Power']['ButtonID'] = 3011 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Power']['ValueOn'] = 1.0 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Volume'] = {} -- volume knob active
|
||||
-- ExportScript.genericRadioConf[1]['Volume']['ButtonID'] = 3011 -- volume button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset'] = {} -- preset knob active
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['ArgumentID'] = 161 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['List'] = {[0.0]="01",[0.05]="02",[0.10]="03",[0.15]="04",[0.20]="05",[0.25]="06",[0.30]="07",[0.35]="08",[0.40]="09",[0.45]="10",[0.50]="11",[0.55]="12",[0.60]="13",[0.65]="14",[0.70]="15",[0.75]="16",[0.80]="17",[0.85]="18",[0.90]="19",[0.95]="20",[1.00]="01"}
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['Step'] = 0.05 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[1]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ArgumentID'] = 170 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ButtonID'] = 3006 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ValueOn'] = 1.0 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ValueOff'] = 0.0 -- squelch off value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Load'] = {} -- load button preset
|
||||
-- ExportScript.genericRadioConf[1]['Load']['ButtonID'] = 3015 -- load button id from cklickable.lua
|
||||
-- ManualPreset is AM FM modus switch Manual=AM, Preset=FM
|
||||
ExportScript.genericRadioConf[1]['ManualPreset'] = {} -- switch manual or preset active
|
||||
ExportScript.genericRadioConf[1]['ManualPreset']['ArgumentID'] = 167 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['ManualPreset']['ButtonID'] = 3002 -- ManualPreset button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['ManualPreset']['ValueManual'] = 1.0-- ManualPreset Manual value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['ManualPreset']['ValuePreset'] = 0.0-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadioConf[2] = {} -- secound radio
|
||||
ExportScript.genericRadioConf[2]['Name'] = "R_828 VHF" -- name of radio
|
||||
ExportScript.genericRadioConf[2]['DeviceID'] = 49 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[2]['setFrequency'] = false -- change frequency active
|
||||
ExportScript.genericRadioConf[2]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[2]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
-- ExportScript.genericRadioConf[2]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
-- ExportScript.genericRadioConf[2]['minFrequency'] = 116.000 -- lowest frequency
|
||||
-- ExportScript.genericRadioConf[2]['maxFrequency'] = 151.975 -- highest frequency
|
||||
ExportScript.genericRadioConf[2]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[2]['Power']['ButtonID'] = 3003 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Power']['ValueOn'] = 0.1 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[2]['Volume']['ButtonID'] = 3002 -- volume button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Preset'] = {} -- preset knob active
|
||||
ExportScript.genericRadioConf[2]['Preset']['ArgumentID'] = 371 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
ExportScript.genericRadioConf[2]['Preset']['List'] = {[0.0]="1",[0.1]="2",[0.2]="3",[0.3]="4",[0.4]="5",[0.5]="6",[0.6]="7",[0.7]="8",[0.8]="9",[0.9]="10"}
|
||||
ExportScript.genericRadioConf[2]['Preset']['Step'] = 0.1 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[2]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ArgumentID'] = 134 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ButtonID'] = 3004 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ValueOn'] = 1.0 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ValueOff'] = 0.0 -- squelch off value from cklickable.lua
|
||||
-- Load Button is Autotune
|
||||
ExportScript.genericRadioConf[2]['Load'] = {} -- load button preset
|
||||
ExportScript.genericRadioConf[2]['Load']['ButtonID'] = 3003 -- load button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Load']['ArgumentID'] = 375 -- load argument id for autotune lamp on Ka-50
|
||||
-- ExportScript.genericRadioConf[2]['ManualPreset'] = {} -- switch manual or preset active
|
||||
-- ExportScript.genericRadioConf[2]['ManualPreset']['ArgumentID'] = 135 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[2]['ManualPreset']['ButtonID'] = 0 -- ManualPreset button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[2]['ManualPreset']['ValueManual'] = 0.0-- ManualPreset Manual value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[2]['ManualPreset']['ValuePreset'] = 0.0-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadio(nil, nil)
|
||||
|
||||
--[[
|
||||
-- ENGINE_INTERFACE
|
||||
@ -1165,466 +1239,4 @@ function ExportScript.ProcessDACConfigHighImportance(mainPanelDevice)
|
||||
ExportScript.Tools.WriteToLog(ltmp2..' (metatable): '..ExportScript.Tools.dump(getmetatable(ltmp1)))
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
-----------------------------
|
||||
-- Custom functions --
|
||||
-----------------------------
|
||||
|
||||
function ExportScript.genericRadio(key, value, hardware)
|
||||
local lHardware = hardware or 1
|
||||
-- Werte werden per Encoder im Bereich von 0.0 bis 2.0 in 0.1 Schritten uebergeben
|
||||
-- im jeweiligen Abschnitt muessen die Eingangsdaten auf den Zulaessigen Bereich eingeschraengt werden
|
||||
local lRotaryFrequency_1, lRotaryFrequency_2, lVolume, lPreset, lLoad, lSquelch, lManualPreset, lPower, lDevice, lClickAction, lSetFrequency = nil
|
||||
local lMainPanelDevice = GetDevice(0)
|
||||
local lMaxRadios = 2
|
||||
|
||||
if ExportScript.AF.genericRadio == nil then
|
||||
ExportScript.AF.genericRadio = 0
|
||||
end
|
||||
if ExportScript.AF.genericRadioFrequency1 == nil then
|
||||
ExportScript.AF.genericRadioFrequency1 = 0.0
|
||||
end
|
||||
if ExportScript.AF.genericRadioFrequency2 == nil then
|
||||
ExportScript.AF.genericRadioFrequency2 = 0.0
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetChannel == nil then
|
||||
ExportScript.AF.genericRadioPresetChannel = 0.0
|
||||
end
|
||||
if ExportScript.AF.genericRadioPower == nil then
|
||||
ExportScript.AF.genericRadioPower = {}
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetManual == nil then
|
||||
ExportScript.AF.genericRadioPresetManual = {}
|
||||
end
|
||||
if ExportScript.AF.genericRadioSquelch == nil then
|
||||
ExportScript.AF.genericRadioSquelch = {}
|
||||
end
|
||||
|
||||
if key == "3001" then
|
||||
ExportScript.AF.genericRadio = tonumber(value)
|
||||
end
|
||||
if key == "3002" then
|
||||
lRotaryFrequency_1 = tonumber(value)
|
||||
end
|
||||
if key == "3003" then
|
||||
lRotaryFrequency_2 = tonumber(value)
|
||||
end
|
||||
if key == "3004" then
|
||||
lVolume = tonumber(value)
|
||||
end
|
||||
if key == "3005" then
|
||||
lPreset = tonumber(value)
|
||||
end
|
||||
if key == "3006" then
|
||||
lLoad = tonumber(value)
|
||||
end
|
||||
if key == "3007" then
|
||||
lSquelch = tonumber(value)
|
||||
end
|
||||
if key == "3008" then
|
||||
lManualPreset = tonumber(value)
|
||||
end
|
||||
if key == "3009" then
|
||||
lPower = tonumber(value)
|
||||
end
|
||||
|
||||
if ExportScript.AF.genericRadio > lMaxRadios then
|
||||
ExportScript.Tools.WriteToLog("Radio Nr. "..ExportScript.AF.genericRadio.." not defined.")
|
||||
return
|
||||
end
|
||||
|
||||
if ExportScript.AF.genericRadio == 1 then
|
||||
-- R_800 FM/AM Radio###.###
|
||||
local lDeviceID = 48
|
||||
local lR_800 = GetDevice(lDeviceID)
|
||||
|
||||
-- check status of the radio
|
||||
if ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == nil then
|
||||
if lR_800:is_on() then
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
else
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0.0
|
||||
end
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(167), 1) == 0) and 1 or 0)
|
||||
end
|
||||
if ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(170), 1) == 0) and 1 or 0)
|
||||
end
|
||||
|
||||
local lR_800_FREQUENCY = ExportScript.Tools.round(lR_800:get_frequency()/1000000 , 3, "floor")
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3000", string.format("%.3f", lR_800_FREQUENCY), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", string.format("-"), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", string.format("%.3f", lR_800_FREQUENCY), lHardware)
|
||||
|
||||
if lRotaryFrequency_1 ~= nil and (lRotaryFrequency_1 >= 0.0 and lRotaryFrequency_1 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lR_800_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_1 < ExportScript.AF.genericRadioFrequency1 or lRotaryFrequency_1 == 0.0 or lRotaryFrequency_1 == 2.0 then
|
||||
lFrequency[1] = lFrequency[1] - 1
|
||||
if lFrequency[1] == 99 then
|
||||
lFrequency[1] = 399
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
else
|
||||
lFrequency[1] = lFrequency[1] + 1
|
||||
if lFrequency[1] == 400 then
|
||||
lFrequency[1] = 100
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("1. generic Ka-50 R_800 Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lRotaryFrequency_2 ~= nil and (lRotaryFrequency_2 >= 0.0 and lRotaryFrequency_2 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lR_800_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_2 < ExportScript.AF.genericRadioFrequency2 or lRotaryFrequency_2 == 0.0 or lRotaryFrequency_2 == 2.0 then
|
||||
lFrequency[2] = lFrequency[2] - 25
|
||||
if lFrequency[2] == -25 then
|
||||
lFrequency[2] = 975
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
else
|
||||
lFrequency[2] = lFrequency[2] + 25
|
||||
if lFrequency[2] == 1000 then
|
||||
lFrequency[2] = 0
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("2. generic Ka-50 R_800 Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
--[[
|
||||
if lVolume ~= nil and (lVolume >= 0.0 and lVolume <= 2.0) then
|
||||
lVolume = lVolume / 2
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3005,
|
||||
Value = lVolume}
|
||||
end
|
||||
if lPreset ~= nil and (lPreset >= 0.0 and lPreset <= 2.0) then
|
||||
-- Preset 0.0 to 0.20 in 0.01 steps
|
||||
if lPreset < ExportScript.AF.genericRadioPresetChannel or lPreset == 0.0 or lPreset == 2.0 then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = 0.01}
|
||||
ExportScript.AF.genericRadioPresetChannel = lPreset
|
||||
else
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3002,
|
||||
Value = -0.01}
|
||||
ExportScript.AF.genericRadioPresetChannel = lPreset
|
||||
end
|
||||
end
|
||||
if lLoad ~= nil and (lLoad == 0.0 or lLoad <= 1.0) then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3006,
|
||||
Value = lLoad}
|
||||
end
|
||||
]]
|
||||
if lSquelch ~= nil and (lSquelch == 0.0 or lSquelch <= 1.0) then
|
||||
if lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Squelch off
|
||||
lSquelch = 0.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 0
|
||||
elseif lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Squelch on
|
||||
lSquelch = 1.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3006,
|
||||
Value = lSquelch}
|
||||
end
|
||||
-- ManualPreset is AM FM modus switch
|
||||
if lManualPreset ~= nil and (lManualPreset == 0.0 or lManualPreset <= 1.0) then
|
||||
if lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 0.0 then
|
||||
-- AM
|
||||
lManualPreset = 1.0
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 1.0
|
||||
elseif lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- FM
|
||||
lManualPreset = 0.0
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 0.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3002,
|
||||
Value = lManualPreset}
|
||||
end
|
||||
if lPower ~= nil and (lPower == 0.0 or lPower <= 1.0) then
|
||||
if lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lPower = 0.0
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0
|
||||
elseif lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Power on
|
||||
lPower = 1.0
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3011,
|
||||
Value = lPower}
|
||||
end
|
||||
|
||||
elseif ExportScript.AF.genericRadio == 2 then
|
||||
-- R_828 VHF ###.###
|
||||
---------------------------------------------------
|
||||
local lDeviceID = 49
|
||||
local lR_828_RADIO = GetDevice(lDeviceID)
|
||||
|
||||
-- check status of the radio
|
||||
if ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == nil then
|
||||
if lR_828_RADIO:is_on() then
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
else
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0.0
|
||||
end
|
||||
end
|
||||
if ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(135), 1) == 0.1) and 1 or 0)
|
||||
end
|
||||
if ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == nil then
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(134), 1) == 1.0) and 0 or 1)
|
||||
end
|
||||
|
||||
local lR_828_RADIO_PRESET = {[0.0]="1",[0.1]="2",[0.2]="3",[0.3]="4",[0.4]="5",[0.5]="6",[0.6]="7",[0.7]="8",[0.8]="9",[0.9]="10"}
|
||||
local lR_828_RADIO_FREQUENCY = ExportScript.Tools.round(lR_828_RADIO:get_frequency()/1000000 , 3, "floor")
|
||||
|
||||
local lPresetChannel = ExportScript.Tools.round(lMainPanelDevice:get_argument_value(371), 1)
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3000", string.format("%s0%.3f", lR_828_RADIO_PRESET[lPresetChannel], lR_828_RADIO_FREQUENCY), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", string.format("%s0", lR_828_RADIO_PRESET[lPresetChannel]), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", string.format("%.3f", lR_828_RADIO_FREQUENCY), lHardware)
|
||||
|
||||
--[[
|
||||
if lRotaryFrequency_1 ~= nil and (lRotaryFrequency_1 >= 0.0 and lRotaryFrequency_1 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lR_828_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_1 < ExportScript.AF.genericRadioFrequency1 or lRotaryFrequency_1 == 0.0 or lRotaryFrequency_1 == 2.0 then
|
||||
lFrequency[1] = lFrequency[1] - 1
|
||||
if lFrequency[1] == 29 then
|
||||
lFrequency[1] = 159
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
else
|
||||
lFrequency[1] = lFrequency[1] + 1
|
||||
if lFrequency[1] == 160 then
|
||||
lFrequency[1] = 30
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency1 = lRotaryFrequency_1
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("1. generic Ka-50 VHF Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lRotaryFrequency_2 ~= nil and (lRotaryFrequency_2 >= 0.0 and lRotaryFrequency_2 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lR_828_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_2 < ExportScript.AF.genericRadioFrequency2 or lRotaryFrequency_2 == 0.0 or lRotaryFrequency_2 == 2.0 then
|
||||
lFrequency[2] = lFrequency[2] - 25
|
||||
if lFrequency[2] == -25 then
|
||||
lFrequency[2] = 975
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
else
|
||||
lFrequency[2] = lFrequency[2] + 25
|
||||
if lFrequency[2] == 1000 then
|
||||
lFrequency[2] = 0
|
||||
end
|
||||
ExportScript.AF.genericRadioFrequency2 = lRotaryFrequency_2
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("2. generic Ka-50 VHF Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
]]
|
||||
if lVolume ~= nil and (lVolume >= 0.0 and lVolume <= 2.0) then
|
||||
lVolume = lVolume / 2
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3002,
|
||||
Value = lVolume}
|
||||
end
|
||||
if lPreset ~= nil and (lPreset >= 0.0 and lPreset <= 2.0) then
|
||||
--[[
|
||||
-- Preset 0.0 to 0.9 in 0.1 steps
|
||||
lPreset = (lPreset / 2) - 0.1
|
||||
if lPreset < ExportScript.AF.genericRadioPresetChannel or lPreset == 0.0 or lPreset == 2.0 then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = 0.1}
|
||||
ExportScript.AF.genericRadioPresetChannel = lPreset
|
||||
else
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = -0.1}
|
||||
ExportScript.AF.genericRadioPresetChannel = lPreset
|
||||
end
|
||||
]]
|
||||
-- Preset 0.0 to 0.9 in 0.1 steps
|
||||
lPreset = lPreset / 2
|
||||
if lPreset == 1.0 then
|
||||
lPreset = 0.9
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = lPreset}
|
||||
end
|
||||
-- Load Button change the Frequence
|
||||
if lLoad ~= nil and (lLoad == 0.0 or lLoad <= 1.0) then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3003,
|
||||
Value = lLoad}
|
||||
end
|
||||
if lSquelch ~= nil and (lSquelch == 0.0 or lSquelch <= 1.0) then
|
||||
if lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Squelch off
|
||||
lSquelch = 0.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 0
|
||||
elseif lSquelch == 1.0 and ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Squelch on
|
||||
lSquelch = 1.0
|
||||
ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3004,
|
||||
Value = lSquelch}
|
||||
end
|
||||
--[[
|
||||
if lManualPreset ~= nil and (lManualPreset == 0.0 or lManualPreset <= 1.0) then
|
||||
if lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Manual on
|
||||
lManualPreset = 0.2
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 0
|
||||
elseif lManualPreset == 1.0 and ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Preset on
|
||||
lManualPreset = 0.3
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3003,
|
||||
Value = lManualPreset}
|
||||
end
|
||||
]]
|
||||
if lPower ~= nil and (lPower == 0.0 or lPower <= 1.0) then
|
||||
if lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lPower = 0.0
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 0
|
||||
elseif lPower == 1.0 and ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] == 0 then
|
||||
-- Power on
|
||||
lPower = 1.0
|
||||
ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3005,
|
||||
Value = lPower}
|
||||
end
|
||||
|
||||
--ExportScript.Tools.SendDataDAC("3011", lMainPanelDevice:get_argument_value(375), lHardware)
|
||||
ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio] = lMainPanelDevice:get_argument_value(375)
|
||||
|
||||
else
|
||||
ExportScript.Tools.SendDataDAC("3000", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3010", 0, lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3011", 0, lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3012", 0, lHardware)
|
||||
return
|
||||
end
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3010", ExportScript.AF.genericRadioPower[ExportScript.AF.genericRadio], lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3011", ExportScript.AF.genericRadioPresetManual[ExportScript.AF.genericRadio], lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3012", ExportScript.AF.genericRadioSquelch[ExportScript.AF.genericRadio], lHardware)
|
||||
|
||||
if lClickAction ~= nil then
|
||||
lDevice = GetDevice(lClickAction.DeviceID)
|
||||
if type(lDevice) == "table" then
|
||||
--ExportScript.Tools.WriteToLog("GetDevice("..lClickAction.DeviceID.."):performClickableAction("..lClickAction.ButtonID..", "..lClickAction.Value..") ")
|
||||
lDevice:performClickableAction(lClickAction.ButtonID, lClickAction.Value)
|
||||
end
|
||||
elseif lSetFrequency ~= nil then
|
||||
lDevice = GetDevice(lSetFrequency.DeviceID)
|
||||
if type(lDevice) == "table" and lDevice:is_on() then
|
||||
--ExportScript.Tools.WriteToLog("GetDevice("..lSetFrequency.DeviceID.."):set_frequency("..lSetFrequency.Frequency..") ")
|
||||
lDevice:set_frequency(lSetFrequency.Frequency)
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("GetDevice("..lSetFrequency.DeviceID..") is no table or Radio is not on")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1025,18 +1025,18 @@ function ExportScript.ProcessIkarusDCSConfigLowImportance(mainPanelDevice)
|
||||
ExportScript.Tools.WriteToLog('lAGB_3K_LEFT:get_sideslip '..ExportScript.Tools.dump(lAGB_3K_LEFT:get_sideslip()))
|
||||
ExportScript.Tools.WriteToLog('lAGB_3K_LEFT:get_bank '..ExportScript.Tools.dump(lAGB_3K_LEFT:get_bank()))
|
||||
ExportScript.Tools.WriteToLog('lAGB_3K_LEFT:get_pitch '..ExportScript.Tools.dump(lAGB_3K_LEFT:get_pitch()))
|
||||
|
||||
|
||||
-- AGB_3K_RIGHT
|
||||
local lAGB_3K_RIGHT = GetDevice(7)
|
||||
ExportScript.Tools.WriteToLog('lAGB_3K_RIGHT:get_sideslip '..ExportScript.Tools.dump(lAGB_3K_RIGHT:get_sideslip()))
|
||||
ExportScript.Tools.WriteToLog('lAGB_3K_RIGHT:get_bank '..ExportScript.Tools.dump(lAGB_3K_RIGHT:get_bank()))
|
||||
ExportScript.Tools.WriteToLog('lAGB_3K_RIGHT:get_pitch '..ExportScript.Tools.dump(lAGB_3K_RIGHT:get_pitch()))
|
||||
|
||||
|
||||
-- DISS_15
|
||||
local lDISS_15 = GetDevice(15)
|
||||
ExportScript.Tools.WriteToLog('lDISS_15:get_w_vector '..ExportScript.Tools.dump(lDISS_15:get_w_vector()))
|
||||
ExportScript.Tools.WriteToLog('lDISS_15:get_drift_angle '..ExportScript.Tools.dump(lDISS_15:get_drift_angle()))
|
||||
|
||||
|
||||
-- RADAR_ALTIMETER
|
||||
local lRADAR_ALTIMETER = GetDevice(18)
|
||||
ExportScript.Tools.WriteToLog('lRADAR_ALTIMETER:get_altitude '..ExportScript.Tools.dump(lRADAR_ALTIMETER:get_altitude()))
|
||||
@ -1047,12 +1047,12 @@ function ExportScript.ProcessIkarusDCSConfigLowImportance(mainPanelDevice)
|
||||
ExportScript.Tools.WriteToLog('lRADAR_ALTIMETER:get_mode '..ExportScript.Tools.dump(lRADAR_ALTIMETER:get_mode()))
|
||||
ExportScript.Tools.WriteToLog('lRADAR_ALTIMETER:get_aperture_size '..ExportScript.Tools.dump(lRADAR_ALTIMETER:get_aperture_size()))
|
||||
ExportScript.Tools.WriteToLog('lRADAR_ALTIMETER:get_needle_value '..ExportScript.Tools.dump(lRADAR_ALTIMETER:get_needle_value()))
|
||||
|
||||
|
||||
-- MISC_SYSTEMS_INTERFACE
|
||||
local lMISC_SYSTEMS_INTERFACE = GetDevice(20)
|
||||
ExportScript.Tools.WriteToLog('lMISC_SYSTEMS_INTERFACE:get_rotor_blades_pitch '..ExportScript.Tools.dump(lMISC_SYSTEMS_INTERFACE:get_rotor_blades_pitch()))
|
||||
ExportScript.Tools.WriteToLog('lMISC_SYSTEMS_INTERFACE:get_main_rotor_rpm '..ExportScript.Tools.dump(lMISC_SYSTEMS_INTERFACE:get_main_rotor_rpm()))
|
||||
|
||||
|
||||
-- SPU_7 (Intercom)
|
||||
local lSPU_7 = GetDevice(36)
|
||||
ExportScript.Tools.WriteToLog('lSPU_7:is_communicator_available '..ExportScript.Tools.dump(lSPU_7:is_communicator_available()))
|
||||
@ -1060,7 +1060,7 @@ function ExportScript.ProcessIkarusDCSConfigLowImportance(mainPanelDevice)
|
||||
ExportScript.Tools.WriteToLog('lSPU_7:get_signal_level '..ExportScript.Tools.dump(lSPU_7:get_signal_level()))
|
||||
--ExportScript.Tools.WriteToLog('lSPU_7:set_communicator '..ExportScript.Tools.dump(lSPU_7:set_communicator())) -- test parameters
|
||||
--ExportScript.Tools.WriteToLog('lSPU_7:set_voip_mode '..ExportScript.Tools.dump(lSPU_7:set_voip_mode())) -- test parameters
|
||||
|
||||
|
||||
-- JADRO_1A
|
||||
local lJADRO_1A = GetDevice(37)
|
||||
ExportScript.Tools.WriteToLog('lJADRO_1A:is_on '..ExportScript.Tools.dump(lJADRO_1A:is_on()))
|
||||
@ -1096,10 +1096,10 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
|
||||
ExportScript.Tools.SendDataDAC("2004", mainPanelDevice:get_argument_value(659)) -- GEAR_N_SAFE
|
||||
ExportScript.Tools.SendDataDAC("2005", mainPanelDevice:get_argument_value(660)) -- GEAR_L_SAFE
|
||||
ExportScript.Tools.SendDataDAC("2006", mainPanelDevice:get_argument_value(661)) -- GEAR_R_SAFE
|
||||
|
||||
|
||||
Device test, Device 2 to 32
|
||||
is value "userdata", is only DLL intern functions
|
||||
|
||||
|
||||
local ltmp1 = 0
|
||||
for ltmp2 = 1, 50, 1 do
|
||||
ltmp1 = GetDevice(ltmp2)
|
||||
@ -1116,24 +1116,24 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
|
||||
else
|
||||
ExportScript.Tools.SendDataDAC("2000", "-")
|
||||
end
|
||||
|
||||
|
||||
-- R_863 (center)
|
||||
local lR_863_c = GetDevice(38)
|
||||
ExportScript.Tools.SendDataDAC("2001", string.format("%7.3f", lR_863_c:get_frequency()/1000000))
|
||||
|
||||
|
||||
-- R_863 (left) Channel
|
||||
local lR_863_l = {[0.0]="1",[0.05]="2",[0.10]="3",[0.15]="4",[0.20]="5",[0.25]="6",[0.30]="7",[0.35]="8",[0.40]="9",[0.45]="10",[0.50]="11",[0.55]="12",[0.60]="13",[0.65]="14",[0.70]="15",[0.75]="16",[0.80]="17",[0.85]="18",[0.90]="19",[0.95]="20"}
|
||||
ExportScript.Tools.SendDataDAC("2002", lR_863_l[ExportScript.Tools.round(mainPanelDevice:get_argument_value(370), 2)])
|
||||
|
||||
|
||||
-- R_863 (left) Frequency
|
||||
-- is the same frequency as R_863 (center), but not the frequency from R_863 (left)
|
||||
local lR_863_F = GetDevice(38)
|
||||
ExportScript.Tools.SendDataDAC("2003", string.format("%7.3f", lR_863_F:get_frequency()/1000000))
|
||||
|
||||
|
||||
-- R_828 Channel
|
||||
local lR_828 = {[0.0]="1",[0.101]="2",[0.199]="3",[0.302]="4",[0.400]="5",[0.502]="6",[0.601]="7",[0.697]="8",[0.801]="9",[0.898]="10"}
|
||||
ExportScript.Tools.SendDataDAC("2004", lR_828[ExportScript.Tools.round(mainPanelDevice:get_argument_value(736), 3)])
|
||||
|
||||
|
||||
-- R_828 Frequency
|
||||
local lR_828_F = GetDevice(39)
|
||||
if lR_828_F:is_on() then
|
||||
@ -1141,16 +1141,132 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
|
||||
else
|
||||
ExportScript.Tools.SendDataDAC("2005", "-")
|
||||
end
|
||||
|
||||
|
||||
-- UV-26
|
||||
local lUV26 = list_indication(5)
|
||||
lUV26 = lUV26:gsub("-----------------------------------------", "")
|
||||
lUV26 = lUV26:gsub("txt_digits", "")
|
||||
lUV26 = lUV26:gsub("%c", "")
|
||||
|
||||
|
||||
ExportScript.Tools.SendDataDAC("2006", string.format("%s", lUV26))
|
||||
|
||||
|
||||
|
||||
-- generic Radio display and frequency rotarys
|
||||
-------------------------------------------------
|
||||
-- genericRadioConf
|
||||
ExportScript.genericRadioConf = {}
|
||||
ExportScript.genericRadioConf['maxRadios'] = 3 -- numbers of aviables/supported radios
|
||||
ExportScript.genericRadioConf[1] = {} -- first radio
|
||||
ExportScript.genericRadioConf[1]['Name'] = "R-863 VHF/UHF" -- name of radio
|
||||
ExportScript.genericRadioConf[1]['DeviceID'] = 38 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[1]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[1]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[1]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[1]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[1]['minFrequency'] = 100.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[1]['maxFrequency'] = 399.975 -- highest frequency
|
||||
ExportScript.genericRadioConf[1]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[1]['Power']['ButtonID'] = 3068 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Power']['ValueOn'] = 1.0 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Power']['ValueOff'] = -1.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[1]['Volume']['ButtonID'] = 3005 -- volume button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset'] = {} -- preset knob active
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['ArgumentID'] = 161 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['List'] = {[0.0]="01",[0.05]="02",[0.10]="03",[0.15]="04",[0.20]="05",[0.25]="06",[0.30]="07",[0.35]="08",[0.40]="09",[0.45]="10",[0.50]="11",[0.55]="12",[0.60]="13",[0.65]="14",[0.70]="15",[0.75]="16",[0.80]="17",[0.85]="18",[0.90]="19",[0.95]="20",[1.00]="01"}
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['Step'] = 0.05 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[1]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ArgumentID'] = 155 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ButtonID'] = 3004 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ValueOn'] = 1.0 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ValueOff'] = 0.0 -- squelch off value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Load'] = {} -- load button preset
|
||||
-- ExportScript.genericRadioConf[1]['Load']['ButtonID'] = 3015 -- load button id from cklickable.lua
|
||||
-- ManualPreset is AM FM modus switch Manual=AM, Preset=FM
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset'] = {} -- switch manual or preset active
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset']['ArgumentID'] = 369 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset']['ButtonID'] = 3001 -- ManualPreset button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset']['ValueManual'] = 0.0-- ManualPreset Manual value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset']['ValuePreset'] = 0.1-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadioConf[2] = {} -- secound radio
|
||||
ExportScript.genericRadioConf[2]['Name'] = "YaDRO-1A HF" -- name of radio
|
||||
ExportScript.genericRadioConf[2]['DeviceID'] = 37 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[2]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[2]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[2]['FrequencyFormat'] = "%7.4f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[2]['FrequencyStep'] = 1 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[2]['minFrequency'] = 2.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[2]['maxFrequency'] = 17.999 -- highest frequency
|
||||
ExportScript.genericRadioConf[2]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[2]['Power']['ButtonID'] = 3013 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Power']['ValueOn'] = 0.1 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[2]['Volume']['ButtonID'] = 3007 -- volume button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[2]['Preset'] = {} -- preset knob active
|
||||
-- ExportScript.genericRadioConf[2]['Preset']['ArgumentID'] = 137 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[2]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
-- ExportScript.genericRadioConf[2]['Preset']['List'] = {[0.0]="01",[0.01]="02",[0.02]="03",[0.03]="04",[0.04]="05",[0.05]="06",[0.06]="07",[0.07]="08",[0.08]="09",[0.09]="10",[0.10]="11",[0.11]="12",[0.12]="13",[0.13]="14",[0.14]="15",[0.15]="16",[0.16]="17",[0.17]="18",[0.18]="19",[0.19]="20",[0.20]="01"}
|
||||
-- ExportScript.genericRadioConf[2]['Preset']['Step'] = 0.01 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[2]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ArgumentID'] = 743 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ButtonID'] = 3008 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ValueOn'] = 0.7 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ValueOff'] = 0.0 -- squelch off value from cklickable.lua
|
||||
-- Load is autotune lamp on Mi-8
|
||||
ExportScript.genericRadioConf[2]['Load'] = {} -- load button preset
|
||||
ExportScript.genericRadioConf[2]['Load']['ButtonID'] = nil -- load button id from cklickable.lua, Load button deactiviert
|
||||
ExportScript.genericRadioConf[2]['Load']['ArgumentID'] = 849 -- load argument id for autotune lamp on Mi-8
|
||||
-- ManualPreset button change between SSB (Single SideBand) and AM, Manual=SSB, AM=Preset
|
||||
ExportScript.genericRadioConf[2]['ManualPreset'] = {} -- switch manual or preset active
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ArgumentID'] = 744 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ButtonID'] = 3001 -- ManualPreset button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ValueManual'] = 0.5-- ManualPreset Manual value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ValuePreset'] = 1.0-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadioConf[3] = {} -- secound radio
|
||||
ExportScript.genericRadioConf[3]['Name'] = " R-828 LVHF FM" -- name of radio
|
||||
ExportScript.genericRadioConf[3]['DeviceID'] = 39 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[3]['setFrequency'] = false -- change frequency active
|
||||
ExportScript.genericRadioConf[3]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[3]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[3]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[3]['minFrequency'] = 20.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[3]['maxFrequency'] = 59.975 -- highest frequency
|
||||
ExportScript.genericRadioConf[3]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[3]['Power']['ButtonID'] = 3005 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Power']['ValueOn'] = 1.0 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[3]['Volume']['ButtonID'] = 3002 -- volume button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Preset'] = {} -- preset knob active
|
||||
ExportScript.genericRadioConf[3]['Preset']['ArgumentID'] = 735 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['Preset']['ButtonID2'] = 3002 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
ExportScript.genericRadioConf[3]['Preset']['List'] = {[0.0]="1",[0.1]="2",[0.2]="3",[0.3]="4",[0.4]="5",[0.5]="6",[0.6]="7",[0.7]="8",[0.8]="9",[0.9]="10"}
|
||||
ExportScript.genericRadioConf[3]['Preset']['Step'] = 0.1 -- minimal step for preset change
|
||||
-- ExportScript.genericRadioConf[3]['Preset']['Step2'] = -0.1 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[3]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[3]['Squelch']['ArgumentID'] = 739 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Squelch']['ButtonID'] = 3004 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Squelch']['ValueOn'] = 0.0 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Squelch']['ValueOff'] = -1.0 -- squelch off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Load'] = {} -- load button preset
|
||||
ExportScript.genericRadioConf[3]['Load']['ButtonID'] = 3003 -- load button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Load']['ArgumentID'] = 740 -- load argument id for autotune lamp on Mi-8
|
||||
-- ManualPreset change betwen VOICE and HOMING Mode, Manual=Voice, Preset=Homing
|
||||
ExportScript.genericRadioConf[3]['ManualPreset'] = {} -- switch manual or preset active
|
||||
ExportScript.genericRadioConf[3]['ManualPreset']['ArgumentID'] = 757 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['ManualPreset']['ButtonID'] = 3006 -- ManualPreset button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['ManualPreset']['ValueManual'] = 1.0-- ManualPreset Manual value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['ManualPreset']['ValuePreset'] = 0.0-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadio(nil, nil)
|
||||
|
||||
--============================================================================================
|
||||
--[[
|
||||
ExportScript.Tools.WriteToLog('list_cockpit_params(): '..ExportScript.Tools.dump(list_cockpit_params()))
|
||||
@ -1163,10 +1279,3 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
-----------------------------
|
||||
-- Custom functions --
|
||||
-----------------------------
|
||||
|
||||
function ExportScript.genericRadio(key, value, hardware)
|
||||
end
|
||||
|
||||
@ -621,16 +621,122 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
|
||||
lAN_APN_209 = lAN_APN_209 .. lAN_APN_209_PRESET[ExportScript.Tools.round(mainPanelDevice:get_argument_value(471), 2)]
|
||||
ExportScript.Tools.SendDataDAC("2008", string.format("%s", lAN_APN_209))
|
||||
|
||||
--ExportScript.Tools.WriteToLog('VHF_ARC_134: '..string.format("%7.3f", lVHF_ARC_134:get_frequency()/1000000))
|
||||
--ExportScript.Tools.WriteToLog('VHF_ARC134_Freq1: '..mainPanelDevice:get_argument_value(1))
|
||||
--ExportScript.Tools.WriteToLog('VHF_ARC134_Freq2: '..mainPanelDevice:get_argument_value(2))
|
||||
--ExportScript.Tools.WriteToLog('VHF_ARC134_Freq3: '..mainPanelDevice:get_argument_value(3))
|
||||
--ExportScript.Tools.WriteToLog('VHF_ARC134_Freq4: '..mainPanelDevice:get_argument_value(4))
|
||||
|
||||
-- generic Radio display and frequency rotarys
|
||||
-------------------------------------------------
|
||||
ExportScript.genericRadio(nil, nil, ExportScript.Config.genericRadioHardwareID)
|
||||
-- genericRadioConf
|
||||
ExportScript.genericRadioConf = {}
|
||||
ExportScript.genericRadioConf['maxRadios'] = 3 -- numbers of aviables/supported radios
|
||||
ExportScript.genericRadioConf[1] = {} -- first radio
|
||||
ExportScript.genericRadioConf[1]['Name'] = "AN/ARC-131 VHF FM" -- name of radio
|
||||
ExportScript.genericRadioConf[1]['DeviceID'] = 23 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[1]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[1]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[1]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[1]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[1]['minFrequency'] = 100.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[1]['maxFrequency'] = 399.975 -- highest frequency
|
||||
ExportScript.genericRadioConf[1]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[1]['Power']['ButtonID'] = 3008 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Power']['ValueOn'] = 0.1 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[1]['Volume']['ButtonID'] = 3006 -- volume button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset'] = {} -- preset knob active
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['ArgumentID'] = 161 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['List'] = {[0.0]="01",[0.05]="02",[0.10]="03",[0.15]="04",[0.20]="05",[0.25]="06",[0.30]="07",[0.35]="08",[0.40]="09",[0.45]="10",[0.50]="11",[0.55]="12",[0.60]="13",[0.65]="14",[0.70]="15",[0.75]="16",[0.80]="17",[0.85]="18",[0.90]="19",[0.95]="20",[1.00]="01"}
|
||||
-- ExportScript.genericRadioConf[1]['Preset']['Step'] = 0.05 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[1]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ArgumentID'] = 36 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ButtonID'] = 3005 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ValueOn'] = 0.1 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[1]['Squelch']['ValueOff'] = 0.0 -- squelch off value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['Load'] = {} -- load button preset
|
||||
-- ExportScript.genericRadioConf[1]['Load']['ButtonID'] = 3015 -- load button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset'] = {} -- switch manual or preset active
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset']['ArgumentID'] = 167 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset']['ButtonID'] = 3007 -- ManualPreset button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset']['ValueManual'] = 0.0-- ManualPreset Manual value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[1]['ManualPreset']['ValuePreset'] = 0.1-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadioConf[2] = {} -- secound radio
|
||||
ExportScript.genericRadioConf[2]['Name'] = "AN/ARC-51BX UHF AM" -- name of radio
|
||||
ExportScript.genericRadioConf[2]['DeviceID'] = 22 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[2]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[2]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[2]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[2]['FrequencyStep'] = 50 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[2]['minFrequency'] = 225.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[2]['maxFrequency'] = 399.950 -- highest frequency
|
||||
ExportScript.genericRadioConf[2]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[2]['Power']['ButtonID'] = 3006 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Power']['ValueOn'] = 0.1 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Power']['ValueOff'] = 0.0 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[2]['Volume']['ButtonID'] = 3008 -- volume button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Preset'] = {} -- preset knob active
|
||||
ExportScript.genericRadioConf[2]['Preset']['ArgumentID'] = 16 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
ExportScript.genericRadioConf[2]['Preset']['List'] = {[0.0]="01",[0.05]="02",[0.10]="03",[0.15]="04",[0.20]="05",[0.25]="06",[0.30]="07",[0.35]="08",[0.40]="09",[0.45]="10",[0.50]="11",[0.55]="12",[0.60]="13",[0.65]="14",[0.70]="15",[0.75]="16",[0.80]="17",[0.85]="18",[0.90]="19",[0.95]="20"}
|
||||
ExportScript.genericRadioConf[2]['Preset']['Step'] = 0.05 -- minimal step for preset change
|
||||
ExportScript.genericRadioConf[2]['Squelch'] = {} -- squelch switch active
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ArgumentID'] = 134 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ButtonID'] = 3007 -- squelch button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ValueOn'] = 1.0 -- squelch on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Squelch']['ValueOff'] = 0.0 -- squelch off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['Load'] = {} -- load button preset
|
||||
ExportScript.genericRadioConf[2]['Load']['ButtonID'] = 3006 -- load button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset'] = {} -- switch manual or preset active
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ArgumentID'] = 135 -- ManualPreset argument id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ButtonID'] = 3005 -- ManualPreset button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ValueManual'] = 0.1-- ManualPreset Manual value from cklickable.lua
|
||||
ExportScript.genericRadioConf[2]['ManualPreset']['ValuePreset'] = 0.0-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.genericRadioConf[3] = {} -- secound radio
|
||||
ExportScript.genericRadioConf[3]['Name'] = "AN/ARC-134 VHF AM" -- name of radio
|
||||
ExportScript.genericRadioConf[3]['DeviceID'] = 20 -- DeviceID for GetDevice from device.lua
|
||||
ExportScript.genericRadioConf[3]['setFrequency'] = true -- change frequency active
|
||||
ExportScript.genericRadioConf[3]['FrequencyMultiplicator'] = 1000000 -- Multiplicator from Hz to MHz
|
||||
ExportScript.genericRadioConf[3]['FrequencyFormat'] = "%7.3f" -- frequency view format LUA style
|
||||
ExportScript.genericRadioConf[3]['FrequencyStep'] = 25 -- minimal step for frequency change
|
||||
ExportScript.genericRadioConf[3]['minFrequency'] = 100.000 -- lowest frequency
|
||||
ExportScript.genericRadioConf[3]['maxFrequency'] = 399.975 -- highest frequency
|
||||
ExportScript.genericRadioConf[3]['Power'] = {} -- power button active
|
||||
ExportScript.genericRadioConf[3]['Power']['ButtonID'] = 3001 -- power button id from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Power']['ValueOn'] = 1.0 -- power on value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Power']['ValueOff'] = 0.85 -- power off value from cklickable.lua
|
||||
ExportScript.genericRadioConf[3]['Volume'] = {} -- volume knob active
|
||||
ExportScript.genericRadioConf[3]['Volume']['ButtonID'] = 3003 -- volume button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['Preset'] = {} -- preset knob active
|
||||
-- ExportScript.genericRadioConf[3]['Preset']['ArgumentID'] = 151 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['Preset']['ButtonID'] = 3001 -- preset button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['Preset']['ButtonID2'] = 3002 -- preset button id from cklickable.lua
|
||||
-- Preset based on switchlogic on clickabledata.lua
|
||||
-- ExportScript.genericRadioConf[3]['Preset']['List'] = {[0.0]="01",[0.01]="02",[0.02]="03",[0.03]="04",[0.04]="05",[0.05]="06",[0.06]="07",[0.07]="08",[0.08]="09",[0.09]="10",[0.10]="11",[0.11]="12",[0.12]="13",[0.13]="14",[0.14]="15",[0.15]="16",[0.16]="17",[0.17]="18",[0.18]="19",[0.19]="20",[0.20]="01"}
|
||||
-- ExportScript.genericRadioConf[3]['Preset']['Step'] = 0.01 -- minimal step for preset change
|
||||
-- ExportScript.genericRadioConf[3]['Preset']['Step2'] = -0.01 -- minimal step for preset change
|
||||
-- ExportScript.genericRadioConf[3]['Squelch'] = {} -- squelch switch active
|
||||
-- ExportScript.genericRadioConf[3]['Squelch']['ArgumentID'] = 148 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['Squelch']['ButtonID'] = 3008 -- squelch button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['Squelch']['ValueOn'] = 0.0 -- squelch on value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['Squelch']['ValueOff'] = -1.0 -- squelch off value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['Load'] = {} -- load button preset
|
||||
-- ExportScript.genericRadioConf[3]['Load']['ButtonID'] = 3004 -- load button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['ManualPreset'] = {} -- switch manual or preset active
|
||||
-- ExportScript.genericRadioConf[3]['ManualPreset']['ArgumentID'] = 149 -- ManualPreset argument id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['ManualPreset']['ButtonID'] = 3004 -- ManualPreset button id from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['ManualPreset']['ValueManual'] = 0.2-- ManualPreset Manual value from cklickable.lua
|
||||
-- ExportScript.genericRadioConf[3]['ManualPreset']['ValuePreset'] = 0.3-- ManualPreset Preset value from cklickable.lua
|
||||
|
||||
ExportScript.Tools.WriteToLog('VHF_ARC_134: '..string.format("%7.3f", lVHF_ARC_134:get_frequency()/1000000))
|
||||
ExportScript.Tools.WriteToLog('VHF_ARC134_Freq1: '..mainPanelDevice:get_argument_value(1))
|
||||
ExportScript.Tools.WriteToLog('VHF_ARC134_Freq2: '..mainPanelDevice:get_argument_value(2))
|
||||
ExportScript.Tools.WriteToLog('VHF_ARC134_Freq3: '..mainPanelDevice:get_argument_value(3))
|
||||
ExportScript.Tools.WriteToLog('VHF_ARC134_Freq4: '..mainPanelDevice:get_argument_value(4))
|
||||
ExportScript.genericRadio(nil, nil)
|
||||
|
||||
--[[
|
||||
-- ENGINE_INTERFACE
|
||||
@ -716,621 +822,4 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
|
||||
--ExportScript.Tools.WriteToLog(ltmp2..' (metatable): '..ExportScript.Tools.dump(getmetatable(ltmp1)))
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
-----------------------------
|
||||
-- Custom functions --
|
||||
-----------------------------
|
||||
|
||||
function ExportScript.genericRadio(key, value, hardware)
|
||||
local lHardware = hardware or 1
|
||||
-- Werte werden per Encoder im Bereich von 0.0 bis 2.0 in 0.1 Schritten uebergeben
|
||||
-- im jeweiligen Abschnitt muessen die Eingangsdaten auf den Zulaessigen Bereich eingeschraengt werden
|
||||
local lRotaryFrequency_1, lRotaryFrequency_2, lVolume, lPreset, lLoad, lSquelch, lManualPreset, lPower, lDevice, lClickAction, lSetFrequency = nil
|
||||
local lMainPanelDevice = GetDevice(0)
|
||||
local lMaxRadios = 3
|
||||
|
||||
if gES_genericRadio == nil then
|
||||
gES_genericRadio = 0
|
||||
end
|
||||
if gES_genericRadioFrequency1 == nil then
|
||||
gES_genericRadioFrequency1 = 0.0
|
||||
end
|
||||
if gES_genericRadioFrequency2 == nil then
|
||||
gES_genericRadioFrequency2 = 0.0
|
||||
end
|
||||
if gES_genericRadioPresetChannel == nil then
|
||||
gES_genericRadioPresetChannel = 0.0
|
||||
end
|
||||
if gES_genericRadioPower == nil then
|
||||
gES_genericRadioPower = {}
|
||||
end
|
||||
if gES_genericRadioPresetManual == nil then
|
||||
gES_genericRadioPresetManual = {}
|
||||
end
|
||||
if gES_genericRadioSquelch == nil then
|
||||
gES_genericRadioSquelch = {}
|
||||
end
|
||||
|
||||
if key == "3001" then
|
||||
gES_genericRadio = tonumber(value)
|
||||
end
|
||||
if key == "3002" then
|
||||
lRotaryFrequency_1 = tonumber(value)
|
||||
end
|
||||
if key == "3003" then
|
||||
lRotaryFrequency_2 = tonumber(value)
|
||||
end
|
||||
if key == "3004" then
|
||||
lVolume = tonumber(value)
|
||||
end
|
||||
if key == "3005" then
|
||||
lPreset = tonumber(value)
|
||||
end
|
||||
if key == "3006" then
|
||||
lLoad = tonumber(value)
|
||||
end
|
||||
if key == "3007" then
|
||||
lSquelch = tonumber(value)
|
||||
end
|
||||
if key == "3008" then
|
||||
lManualPreset = tonumber(value)
|
||||
end
|
||||
if key == "3009" then
|
||||
lPower = tonumber(value)
|
||||
end
|
||||
|
||||
if gES_genericRadio > lMaxRadios then
|
||||
ExportScript.Tools.WriteToLog("Radio Nr. "..gES_genericRadio.." not defined.")
|
||||
return
|
||||
end
|
||||
|
||||
if gES_genericRadio == 1 then
|
||||
-- AN/ARC-131 VHF FM Radio
|
||||
local lDeviceID = 23
|
||||
local lVHF_FM_RADIO = GetDevice(lDeviceID)
|
||||
|
||||
-- check status of the radio
|
||||
if gES_genericRadioPower[gES_genericRadio] == nil then
|
||||
if lVHF_FM_RADIO:is_on() then
|
||||
gES_genericRadioPower[gES_genericRadio] = 1.0
|
||||
else
|
||||
gES_genericRadioPower[gES_genericRadio] = 0.0
|
||||
end
|
||||
end
|
||||
if gES_genericRadioPresetManual[gES_genericRadio] == nil then
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = 0 -- no preset channels
|
||||
end
|
||||
if gES_genericRadioSquelch[gES_genericRadio] == nil then
|
||||
gES_genericRadioSquelch[gES_genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(36), 1) == 0.1) and 0 or 1)
|
||||
end
|
||||
|
||||
local lVHF_FM_RADIO_FREQUENCY = ExportScript.Tools.round(lVHF_FM_RADIO:get_frequency()/1000000 , 3, "floor")
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3000", string.format("%.3f", lVHF_FM_RADIO_FREQUENCY), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", string.format("-"), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", string.format("%.3f", lVHF_FM_RADIO_FREQUENCY), lHardware)
|
||||
|
||||
if lRotaryFrequency_1 ~= nil and (lRotaryFrequency_1 >= 0.0 and lRotaryFrequency_1 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lVHF_FM_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_1 < gES_genericRadioFrequency1 or lRotaryFrequency_1 == 0.0 or lRotaryFrequency_1 == 2.0 then
|
||||
lFrequency[1] = lFrequency[1] - 1
|
||||
if lFrequency[1] == 99 then
|
||||
lFrequency[1] = 399
|
||||
end
|
||||
gES_genericRadioFrequency1 = lRotaryFrequency_1
|
||||
else
|
||||
lFrequency[1] = lFrequency[1] + 1
|
||||
if lFrequency[1] == 400 then
|
||||
lFrequency[1] = 100
|
||||
end
|
||||
gES_genericRadioFrequency1 = lRotaryFrequency_1
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("1. genericUH-1H AN/ARC-131 VHF FM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lRotaryFrequency_2 ~= nil and (lRotaryFrequency_2 >= 0.0 and lRotaryFrequency_2 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lVHF_FM_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_2 < gES_genericRadioFrequency2 or lRotaryFrequency_2 == 0.0 or lRotaryFrequency_2 == 2.0 then
|
||||
lFrequency[2] = lFrequency[2] - 25
|
||||
if lFrequency[2] == -25 then
|
||||
lFrequency[2] = 975
|
||||
end
|
||||
gES_genericRadioFrequency2 = lRotaryFrequency_2
|
||||
else
|
||||
lFrequency[2] = lFrequency[2] + 25
|
||||
if lFrequency[2] == 1000 then
|
||||
lFrequency[2] = 0
|
||||
end
|
||||
gES_genericRadioFrequency2 = lRotaryFrequency_2
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("2. generic UH-1H AN/ARC-131 VHF FM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lVolume ~= nil and (lVolume >= 0.0 and lVolume <= 2.0) then
|
||||
lVolume = lVolume / 2
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3006,
|
||||
Value = lVolume}
|
||||
end
|
||||
--[[
|
||||
if lPreset ~= nil and (lPreset >= 0.0 and lPreset <= 2.0) then
|
||||
-- Preset 0.0 to 0.20 in 0.01 steps
|
||||
if lPreset < gES_genericRadioPresetChannel or lPreset == 0.0 or lPreset == 2.0 then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = 0.01}
|
||||
gES_genericRadioPresetChannel = lPreset
|
||||
else
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3002,
|
||||
Value = -0.01}
|
||||
gES_genericRadioPresetChannel = lPreset
|
||||
end
|
||||
end
|
||||
if lLoad ~= nil and (lLoad == 0.0 or lLoad <= 1.0) then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3006,
|
||||
Value = lLoad}
|
||||
end
|
||||
if lManualPreset ~= nil and (lManualPreset == 0.0 or lManualPreset <= 1.0) then
|
||||
if lManualPreset == 1.0 and gES_genericRadioPresetManual[gES_genericRadio] == 1.0 then
|
||||
-- Manual on
|
||||
lManualPreset = 0.1
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = 0
|
||||
elseif lManualPreset == 1.0 and gES_genericRadioPresetManual[gES_genericRadio] == 0 then
|
||||
-- Preset on
|
||||
lManualPreset = 0.0
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3005,
|
||||
Value = lManualPreset}
|
||||
end
|
||||
]]
|
||||
if lSquelch ~= nil and (lSquelch == 0.0 or lSquelch <= 1.0) then
|
||||
if lSquelch == 1.0 and gES_genericRadioSquelch[gES_genericRadio] == 1.0 then
|
||||
-- Squelch off
|
||||
lSquelch = 0.0
|
||||
gES_genericRadioSquelch[gES_genericRadio] = 0
|
||||
elseif lSquelch == 1.0 and gES_genericRadioSquelch[gES_genericRadio] == 0 then
|
||||
-- Squelch on
|
||||
lSquelch = 0.1
|
||||
gES_genericRadioSquelch[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3005,
|
||||
Value = lSquelch}
|
||||
end
|
||||
if lPower ~= nil and (lPower == 0.0 or lPower <= 1.0) then
|
||||
if lPower == 1.0 and gES_genericRadioPower[gES_genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lPower = 0.0
|
||||
gES_genericRadioPower[gES_genericRadio] = 0
|
||||
elseif lPower == 1.0 and gES_genericRadioPower[gES_genericRadio] == 0 then
|
||||
-- Power on
|
||||
lPower = 0.1
|
||||
gES_genericRadioPower[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3007,
|
||||
Value = lPower}
|
||||
end
|
||||
|
||||
elseif gES_genericRadio == 2 then
|
||||
-- AN/ARC-51BX UHF AM Radio
|
||||
local lDeviceID = 22
|
||||
local lUHF_AM_RADIO = GetDevice(lDeviceID)
|
||||
|
||||
-- check status of the radio
|
||||
if gES_genericRadioPower[gES_genericRadio] == nil then
|
||||
if lUHF_AM_RADIO:is_on() then
|
||||
gES_genericRadioPower[gES_genericRadio] = 1.0
|
||||
else
|
||||
gES_genericRadioPower[gES_genericRadio] = 0.0
|
||||
end
|
||||
end
|
||||
if gES_genericRadioPresetManual[gES_genericRadio] == nil then
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = ((ExportScript.Tools.round(lMainPanelDevice:get_argument_value(15), 1) == 0.1) and 0 or 1)
|
||||
end
|
||||
if gES_genericRadioSquelch[gES_genericRadio] == nil then
|
||||
gES_genericRadioSquelch[gES_genericRadio] = ExportScript.Tools.round(lMainPanelDevice:get_argument_value(22), 1)
|
||||
end
|
||||
|
||||
local lPresetChannel = ExportScript.Tools.round(lMainPanelDevice:get_argument_value(16), 2)
|
||||
|
||||
local lUHF_AM_RADIO_PRESET = {[0.0]="01",[0.05]="02",[0.10]="03",[0.15]="04",[0.20]="05",[0.25]="06",[0.30]="07",[0.35]="08",[0.40]="09",[0.45]="10",[0.50]="11",[0.55]="12",[0.60]="13",[0.65]="14",[0.70]="15",[0.75]="16",[0.80]="17",[0.85]="18",[0.90]="19",[0.95]="20"}
|
||||
local lUHF_AM_RADIO_FREQUENCY = ExportScript.Tools.round(lUHF_AM_RADIO:get_frequency()/1000000 , 3, "floor")
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3000", string.format("%s%.3f", lUHF_AM_RADIO_PRESET[lPresetChannel], lUHF_AM_RADIO_FREQUENCY), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", string.format("%s", lUHF_AM_RADIO_PRESET[lPresetChannel]), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", string.format("%.3f", lUHF_AM_RADIO_FREQUENCY), lHardware)
|
||||
|
||||
if lRotaryFrequency_1 ~= nil and (lRotaryFrequency_1 >= 0.0 and lRotaryFrequency_1 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lUHF_AM_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 50)
|
||||
lFrequency[2] = ltmp * 50
|
||||
end
|
||||
if lRotaryFrequency_1 < gES_genericRadioFrequency1 or lRotaryFrequency_1 == 0.0 or lRotaryFrequency_1 == 2.0 then
|
||||
lFrequency[1] = lFrequency[1] - 1
|
||||
if lFrequency[1] == 224 then
|
||||
lFrequency[1] = 399
|
||||
end
|
||||
gES_genericRadioFrequency1 = lRotaryFrequency_1
|
||||
else
|
||||
lFrequency[1] = lFrequency[1] + 1
|
||||
if lFrequency[1] == 400 then
|
||||
lFrequency[1] = 225
|
||||
end
|
||||
gES_genericRadioFrequency1 = lRotaryFrequency_1
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("1. generic UH-1H AN/ARC-51BX UHF AM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lRotaryFrequency_2 ~= nil and (lRotaryFrequency_2 >= 0.0 and lRotaryFrequency_2 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lUHF_AM_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 50)
|
||||
lFrequency[2] = ltmp * 50
|
||||
end
|
||||
if lRotaryFrequency_2 < gES_genericRadioFrequency2 or lRotaryFrequency_2 == 0.0 or lRotaryFrequency_2 == 2.0 then
|
||||
lFrequency[2] = lFrequency[2] - 50
|
||||
if lFrequency[2] == -50 then
|
||||
lFrequency[2] = 950
|
||||
end
|
||||
gES_genericRadioFrequency2 = lRotaryFrequency_2
|
||||
else
|
||||
lFrequency[2] = lFrequency[2] + 50
|
||||
if lFrequency[2] == 1000 then
|
||||
lFrequency[2] = 0
|
||||
end
|
||||
gES_genericRadioFrequency2 = lRotaryFrequency_2
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("2. generic UH-1H AN/ARC-51BX UHF AM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
if lVolume ~= nil and (lVolume >= 0.0 and lVolume <= 2.0) then
|
||||
lVolume = lVolume / 2
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3008,
|
||||
Value = lVolume}
|
||||
end
|
||||
if lPreset ~= nil and (lPreset >= 0.0 and lPreset <= 2.0) then
|
||||
-- Preset 0.0 to 0.95 in 0.05 steps
|
||||
if lPreset < gES_genericRadioPresetChannel or lPreset == 0.0 or lPreset == 2.0 then
|
||||
lPresetChannel = lPresetChannel + 0.05
|
||||
gES_genericRadioPresetChannel = lPreset
|
||||
if lPresetChannel == 1.00 then
|
||||
lPresetChannel = 0.0
|
||||
end
|
||||
else
|
||||
lPresetChannel = lPresetChannel - 0.05
|
||||
gES_genericRadioPresetChannel = lPreset
|
||||
if lPresetChannel == -0.05 then
|
||||
lPresetChannel = 0.95
|
||||
end
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = lPresetChannel}
|
||||
end
|
||||
if lSquelch ~= nil and (lSquelch == 0.0 or lSquelch <= 1.0) then
|
||||
if lSquelch == 1.0 and gES_genericRadioSquelch[gES_genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lSquelch = 0.0
|
||||
gES_genericRadioSquelch[gES_genericRadio] = 0
|
||||
elseif lSquelch == 1.0 and gES_genericRadioSquelch[gES_genericRadio] == 0 then
|
||||
-- Power on
|
||||
lSquelch = 1.0
|
||||
gES_genericRadioSquelch[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3007,
|
||||
Value = lSquelch}
|
||||
end
|
||||
if lManualPreset ~= nil and (lManualPreset == 0.0 or lManualPreset <= 1.0) then
|
||||
if lManualPreset == 1.0 and gES_genericRadioPresetManual[gES_genericRadio] == 1.0 then
|
||||
-- Manual on
|
||||
lManualPreset = 0.1
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = 0
|
||||
elseif lManualPreset == 1.0 and gES_genericRadioPresetManual[gES_genericRadio] == 0 then
|
||||
-- Preset on
|
||||
lManualPreset = 0.0
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3005,
|
||||
Value = lManualPreset}
|
||||
end
|
||||
if lPower ~= nil and (lPower == 0.0 or lPower <= 1.0) then
|
||||
if lPower == 1.0 and gES_genericRadioPower[gES_genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lPower = 0.0
|
||||
gES_genericRadioPower[gES_genericRadio] = 0
|
||||
elseif lPower == 1.0 and gES_genericRadioPower[gES_genericRadio] == 0 then
|
||||
-- Power on
|
||||
lPower = 0.1
|
||||
gES_genericRadioPower[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3006,
|
||||
Value = lPower}
|
||||
end
|
||||
|
||||
elseif gES_genericRadio == 3 then
|
||||
-- AN/ARC-134 VHF AM Radio
|
||||
local lDeviceID = 20
|
||||
local lVHF_AM_RADIO = GetDevice(lDeviceID)
|
||||
|
||||
-- check status of the radio
|
||||
if gES_genericRadioPower[gES_genericRadio] == nil then
|
||||
if lVHF_AM_RADIO:is_on() then
|
||||
gES_genericRadioPower[gES_genericRadio] = 1.0
|
||||
else
|
||||
gES_genericRadioPower[gES_genericRadio] = 0.85
|
||||
end
|
||||
end
|
||||
if gES_genericRadioPresetManual[gES_genericRadio] == nil then
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = 0.0 -- no preset channels
|
||||
end
|
||||
if gES_genericRadioSquelch[gES_genericRadio] == nil then
|
||||
gES_genericRadioSquelch[gES_genericRadio] = 0.0 -- no Squelch
|
||||
end
|
||||
|
||||
local lVHF_AM_RADIO_FREQUENCY = ExportScript.Tools.round(lVHF_AM_RADIO:get_frequency()/1000000 , 3, "floor")
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3000", string.format("%.3f", lVHF_AM_RADIO_FREQUENCY), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", string.format("-"), lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", string.format("%.3f", lVHF_AM_RADIO_FREQUENCY), lHardware)
|
||||
|
||||
if lRotaryFrequency_1 ~= nil and (lRotaryFrequency_1 >= 0.0 and lRotaryFrequency_1 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lVHF_AM_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_1 < gES_genericRadioFrequency1 or lRotaryFrequency_1 == 0.0 or lRotaryFrequency_1 == 2.0 then
|
||||
lFrequency[1] = lFrequency[1] - 1
|
||||
if lFrequency[1] == 99 then
|
||||
lFrequency[1] = 399
|
||||
end
|
||||
gES_genericRadioFrequency1 = lRotaryFrequency_1
|
||||
else
|
||||
lFrequency[1] = lFrequency[1] + 1
|
||||
if lFrequency[1] == 400 then
|
||||
lFrequency[1] = 100
|
||||
end
|
||||
gES_genericRadioFrequency1 = lRotaryFrequency_1
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("1. genericUH-1H AN/ARC-134 VHF AM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lRotaryFrequency_2 ~= nil and (lRotaryFrequency_2 >= 0.0 and lRotaryFrequency_2 <= 2.0) then
|
||||
|
||||
local lFrequency = ExportScript.Tools.StrSplit(lVHF_AM_RADIO_FREQUENCY, "%.")
|
||||
|
||||
if type(lFrequency) == "table" and lFrequency[1] ~= nil then
|
||||
lFrequency[1] = tonumber(lFrequency[1])
|
||||
if lFrequency[2] == nil then
|
||||
lFrequency[2] = 0
|
||||
else
|
||||
lFrequency[2] = tonumber(lFrequency[2])
|
||||
local ltmp = string.format("%.0f", lFrequency[2] / 25)
|
||||
lFrequency[2] = ltmp * 25
|
||||
end
|
||||
if lRotaryFrequency_2 < gES_genericRadioFrequency2 or lRotaryFrequency_2 == 0.0 or lRotaryFrequency_2 == 2.0 then
|
||||
lFrequency[2] = lFrequency[2] - 25
|
||||
if lFrequency[2] == -25 then
|
||||
lFrequency[2] = 975
|
||||
end
|
||||
gES_genericRadioFrequency2 = lRotaryFrequency_2
|
||||
else
|
||||
lFrequency[2] = lFrequency[2] + 25
|
||||
if lFrequency[2] == 1000 then
|
||||
lFrequency[2] = 0
|
||||
end
|
||||
gES_genericRadioFrequency2 = lRotaryFrequency_2
|
||||
end
|
||||
|
||||
lFrequency[2] = string.format("%.3f", lFrequency[2] / 1000)
|
||||
local ltempFrequency = string.format("%.3f", lFrequency[1] + lFrequency[2])
|
||||
ltempFrequency = tonumber(ltempFrequency)
|
||||
lSetFrequency = {DeviceID = lDeviceID,
|
||||
Frequency = ltempFrequency * 1000000}
|
||||
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("2. generic UH-1H AN/ARC-134 VHF AM Radio, don't split frequency: "..lFrequency)
|
||||
end
|
||||
end
|
||||
|
||||
if lVolume ~= nil and (lVolume >= 0.0 and lVolume <= 2.0) then
|
||||
lVolume = lVolume / 3
|
||||
if lVolume > 0.65 then
|
||||
lVolume = 0.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3003,
|
||||
Value = lVolume}
|
||||
end
|
||||
--[[
|
||||
if lPreset ~= nil and (lPreset >= 0.0 and lPreset <= 2.0) then
|
||||
-- Preset 0.0 to 0.20 in 0.01 steps
|
||||
if lPreset < gES_genericRadioPresetChannel or lPreset == 0.0 or lPreset == 2.0 then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = 0.01}
|
||||
gES_genericRadioPresetChannel = lPreset
|
||||
else
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3002,
|
||||
Value = -0.01}
|
||||
gES_genericRadioPresetChannel = lPreset
|
||||
end
|
||||
end
|
||||
if lLoad ~= nil and (lLoad == 0.0 or lLoad <= 1.0) then
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3006,
|
||||
Value = lLoad}
|
||||
end
|
||||
if lSquelch ~= nil and (lSquelch == 0.0 or lSquelch <= 1.0) then
|
||||
if lSquelch == 1.0 and gES_genericRadioSquelch[gES_genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lSquelch = 0.0
|
||||
gES_genericRadioSquelch[gES_genericRadio] = 0
|
||||
elseif lSquelch == 1.0 and gES_genericRadioSquelch[gES_genericRadio] == 0 then
|
||||
-- Power on
|
||||
lSquelch = 1.0
|
||||
gES_genericRadioSquelch[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3007,
|
||||
Value = lSquelch}
|
||||
end
|
||||
if lManualPreset ~= nil and (lManualPreset == 0.0 or lManualPreset <= 1.0) then
|
||||
if lManualPreset == 1.0 and gES_genericRadioPresetManual[gES_genericRadio] == 1.0 then
|
||||
-- Manual on
|
||||
lManualPreset = 0.1
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = 0
|
||||
elseif lManualPreset == 1.0 and gES_genericRadioPresetManual[gES_genericRadio] == 0 then
|
||||
-- Preset on
|
||||
lManualPreset = 0.0
|
||||
gES_genericRadioPresetManual[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3005,
|
||||
Value = lManualPreset}
|
||||
end
|
||||
]]
|
||||
if lPower ~= nil and (lPower == 0.0 or lPower <= 1.0) then
|
||||
if lPower == 1.0 and gES_genericRadioPower[gES_genericRadio] == 1.0 then
|
||||
-- Power off
|
||||
lPower = 0.85
|
||||
gES_genericRadioPower[gES_genericRadio] = 0
|
||||
elseif lPower == 1.0 and gES_genericRadioPower[gES_genericRadio] == 0 then
|
||||
-- Power on
|
||||
lPower = 1.0
|
||||
gES_genericRadioPower[gES_genericRadio] = 1.0
|
||||
end
|
||||
lClickAction = {DeviceID = lDeviceID,
|
||||
ButtonID = 3001,
|
||||
Value = lPower}
|
||||
end
|
||||
|
||||
else
|
||||
ExportScript.Tools.SendDataDAC("3000", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3001", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3002", "-", lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3010", 0, lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3011", 0, lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3012", 0, lHardware)
|
||||
return
|
||||
end
|
||||
|
||||
ExportScript.Tools.SendDataDAC("3010", gES_genericRadioPower[gES_genericRadio], lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3011", gES_genericRadioPresetManual[gES_genericRadio], lHardware)
|
||||
ExportScript.Tools.SendDataDAC("3012", gES_genericRadioSquelch[gES_genericRadio], lHardware)
|
||||
|
||||
if lClickAction ~= nil then
|
||||
lDevice = GetDevice(lClickAction.DeviceID)
|
||||
if type(lDevice) == "table" then
|
||||
--ExportScript.Tools.WriteToLog("GetDevice("..lClickAction.DeviceID.."):performClickableAction("..lClickAction.ButtonID..", "..lClickAction.Value..") ")
|
||||
lDevice:performClickableAction(lClickAction.ButtonID, lClickAction.Value)
|
||||
end
|
||||
elseif lSetFrequency ~= nil then
|
||||
lDevice = GetDevice(lSetFrequency.DeviceID)
|
||||
if type(lDevice) == "table" and lDevice:is_on() then
|
||||
--ExportScript.Tools.WriteToLog("GetDevice("..lSetFrequency.DeviceID.."):set_frequency("..lSetFrequency.Frequency..") ")
|
||||
lDevice:set_frequency(lSetFrequency.Frequency)
|
||||
else
|
||||
ExportScript.Tools.WriteToLog("GetDevice("..lSetFrequency.DeviceID..") is no table or Radio is not on")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user