Last active
October 17, 2024 03:35
-
-
Save jh4xsy/83246acdc852f348a2459da07178e10c to your computer and use it in GitHub Desktop.
HamLogのADIFをeQSL用に加工するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
# | |
# Turbo HAMLOG/WinのADIF出力をeQSLにアップロードする前に | |
# FT8のQSOをカットして, | |
# 衛星通信用にタグを追加するスクリプト | |
# 2024/10/17 JH4XSY/1 Iwamoto | |
# | |
f1 = open("LogList.adi", "r") | |
f2 = open("LogList-new.adi", "w") | |
qth = "JH4XSY/1 JCC#1321 GL:PM95vu" | |
# | |
def set_SAT_MODE(line) | |
case line | |
when /\<BAND:2\>2m\<BAND_RX:2\>2m/ | |
mode = "VV" | |
when /\<BAND:4\>70cm\<BAND_RX:4\>70cm/ | |
mode = "UU" | |
when /\<BAND:4\>70cm\<BAND_RX:2\>2m/ | |
mode = "B" | |
when /\<BAND:2\>2m\<BAND_RX:4\>70cm/ | |
mode = "J" | |
else | |
printf("Wrong SAT_QSO data: %s", line) | |
exit | |
end | |
return mode | |
end | |
# | |
def format_l1(line) | |
raw1 = line.split(/[\<|\>]/) | |
# remove FREQ | |
freq = sprintf("\<%s\>%s", raw1[7], raw1[8]) | |
line.gsub(freq, "") | |
# remove BAND | |
band = sprintf("\<%s\>%s", raw1[11], raw1[12]) | |
line.gsub(band, "") | |
# remove FREQ_RX | |
freq_rx = sprintf("\<%s\>%s", raw1[9], raw1[10]) | |
line.gsub(freq_rx, "") | |
# remove BAND_RX | |
band_rx = sprintf("\<%s\>%s", raw1[13], raw1[14]) | |
line.gsub(band_rx, "") | |
return line | |
end | |
# | |
def get_SAT_NAME(line) | |
raw3 = line.split(" ") | |
sname = raw3[1] | |
# eQSL hack | |
case sname | |
when "HO-113" | |
sname = "CAS-9" | |
when "FO-118" | |
sname = "CAS-5A" | |
when "MO-122" | |
sname = "MESAT-1" | |
end | |
return sname | |
end | |
# SAT QSOはRemarks2に%VIA ISS%などと記入する前提 | |
def get_REM2(line) | |
line.chop! | |
raw3 = line.split(/[\<|\>]/) | |
rem2 = raw3[2] | |
return rem2 | |
end | |
# | |
def get_FREQ(line) | |
raw1 = line.split(/[\<|\>]/) | |
up = raw1[8] | |
down = raw1[10] | |
return up, down | |
end | |
# ---8<--- | |
# Header | |
l1 = f1.gets | |
l2 = f1.gets | |
l3 = f1.gets | |
f2.puts(l1) | |
f2.puts(l2) | |
f2.puts(l3) | |
# QSO data | |
while l1 = f1.gets | |
l2 = f1.gets | |
l3 = f1.gets | |
if l1.include?("FT8") | |
# SKIP FT8 QSO | |
else | |
# write l1 | |
if l2.include?("SAT") | |
# SAT QSO hack | |
mode = set_SAT_MODE(l1) | |
formatted_l1 = format_l1(l1) | |
f2.puts(formatted_l1) | |
else | |
# Noraml QSO | |
f2.puts(l1) | |
end | |
# write l2 | |
f2.puts(l2) | |
# write l3 | |
if l2.include?("SAT") | |
# SAT QSO hack | |
sname = get_SAT_NAME(l3) | |
rem2 = get_REM2(l3) | |
up, down = get_FREQ(l1) | |
qslmsg = sprintf("%s %s %sMHz/%sMHz", qth, rem2, up, down) | |
f2.printf("\<SAT_NAME:%d\>%s\<SAT_MODE:%d\>%s\<QSLMSG:%d\>%s\r\n", sname.size, sname, mode.size, mode, qslmsg.size, qslmsg) | |
# write l4 | |
l4 = f1.gets | |
f2.printf("\<COMMENT:%d\>%s\<EOR\>\r\n",qslmsg.size, qslmsg) | |
else | |
# Normal QSO | |
f2.printf("<QSLMSG:%d\>%s<COMMENT:%d\>%s", qth.size, qth, qth.size, qth) | |
f2.puts(l3) | |
end | |
end | |
end | |
# | |
f1.close | |
f2.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment