mirror of
https://github.com/s-d-a/DCS-ExportScripts.git
synced 2025-10-29 16:59:03 +00:00
add new genericRadio config und function call
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user