commit 06/10/2025

This commit is contained in:
2025-10-06 16:00:43 +07:00
parent 611745439f
commit a8e5b027ef
2 changed files with 61 additions and 38 deletions

View File

@@ -83,9 +83,9 @@ class MainExtension01 {
}
if (idlebz.size == bz.size) {
return true
} else Logger.warn { "Some requested Streamer Outputs are not idle" }
} else Logger.error { "Streamer Outputs empty, Idle Broadcast Zones not available" }
} else Logger.error { "No Broadcast Zones checked for idle" }
}
}
}
return false
}
@@ -135,20 +135,20 @@ class MainExtension01 {
val result = mutableListOf<String>()
if (ValidString(value)) {
if (sb.isNotEmpty()) {
val regex = Regex("([A-Z])?(\\d+)([A-Z])?")
val match = regex.find(value)
match?.groupValues?.forEach {
if (IsNumber(it)) {
val num =
sb.firstOrNull { s1 -> s1.Category == Category.AlphabetNumeric.name && s1.TAG == "N$it" }
if (num != null) {
if (ValidFile(num.Path)) {
val regex = Regex("[A-Z0-9]")
val match = regex.findAll(value)
match.forEach {
mm ->
if (IsNumber(mm.value)) {
val num =sb.firstOrNull { s1 -> s1.Category == Category.AlphabetNumeric.name && s1.TAG == "N${mm.value}" }
if (num!=null){
if (ValidFile(num.Path)){
result.add(num.Path)
}
}
} else if (IsAlphabethic(it)) {
} else if (IsAlphabethic(mm.value)) {
val alp =
sb.firstOrNull { s1 -> s1.Category == Category.AlphabetNumeric.name && s1.TAG == it }
sb.firstOrNull { s1 -> s1.Category == Category.AlphabetNumeric.name && s1.TAG == mm.value }
if (alp != null) {
if (ValidFile(alp.Path)) {
result.add(alp.Path)
@@ -156,14 +156,24 @@ class MainExtension01 {
}
}
}
if (result.isNotEmpty()) {
return result
}
return result
}
}
return null
}
fun Get_Soundbank_Hour_Minute(sb: List<Soundbank>, value: Int) : String {
if (value in 0..59){
val tag = if (value<10) "N0${value}" else "N${value}"
val hm = sb.firstOrNull { it.Category == Category.AlphabetNumeric.name && it.TAG == tag }
if (hm!=null){
if (ValidFile(hm.Path)) return hm.Path
}
}
return ""
}
val SoundbankKeywords = listOf("ANN_ID","AL","FLNUM","A_D","I_D","ORIGIN","CITY","SHALAT","PLACES","DESTINATION","ETAD","STANDCODE","GATECODE","REMARK","BCB","PLATNOMOR","REASON","PROCEDURE")
/**
@@ -177,14 +187,16 @@ class MainExtension01 {
if (values.isNotEmpty()){
val result = mutableMapOf<String, String>()
values.forEach {
val kv = it.split(":")
if (kv.size==2){
val key = kv[0].trim().uppercase()
val val1 = kv[1].trim().uppercase()
if (ValidString(key) && ValidString(val1)){
if (SoundbankKeywords.contains(key)) result[key] = val1
val separatorindex = it.indexOf(":")
if (separatorindex!=-1){
// ada separator
val key = it.substring(0, separatorindex).trim().uppercase()
val value = it.substring(separatorindex+1).trim().uppercase()
if (ValidString(key) && ValidString(value)){
if (SoundbankKeywords.contains(key)) result[key] = value
}
}
}
if (result.isNotEmpty()) return result
}
@@ -224,7 +236,7 @@ class MainExtension01 {
tags.forEach { tag ->
when (val _tag = tag.trim()) {
"[AIRPLANE_NAME]" -> {
val value = variables["AIRPLANE_NAME"].orEmpty()
val value = variables["AL"].orEmpty()
if (ValidString(value)) {
val airplane =
sb.firstOrNull { it.Category == Category.Airplane_Name.name && it.TAG == value }
@@ -247,8 +259,8 @@ class MainExtension01 {
}
"[FLIGHT_NUMBER]" -> {
val alcode = variables["AIRPLANE_NAME"].orEmpty()
val fncode = variables["FLIGHT_NUMBER"].orEmpty()
val alcode = variables["AL"].orEmpty()
val fncode = variables["FLNUM"].orEmpty()
if (ValidString(alcode) && ValidString(fncode)) {
val val1 = sb.firstOrNull { it.Category == Category.Airline_Code.name && it.TAG == alcode }
val val2 = Get_Soundbank_AlpabethNumeric(sb, fncode)
@@ -365,21 +377,29 @@ class MainExtension01 {
"[ETAD]" -> {
val values = variables["ETAD"].orEmpty().split(":").map { it.trim() }.filter { IsNumber(it) }
println("ETAD values: $values")
if (values.size == 2) {
val hh = Get_Soundbank_AlpabethNumeric(sb, values[0])
val mm = Get_Soundbank_AlpabethNumeric(sb, values[1])
if (hh != null && mm != null && hh.isNotEmpty() && mm.isNotEmpty()) {
if (ValidFile(hh[0]) && ValidFile(mm[0])) {
files.add(hh[0])
files.add(mm[0])
if (IsNumber(values[0]) && IsNumber(values[1])) {
val _h = values[0].toInt()
val _m = values[1].toInt()
if (_h in 0..23 && _m in 0..59) {
// valid
val hh = Get_Soundbank_Hour_Minute(sb, _h)
val mm = Get_Soundbank_Hour_Minute(sb, _m)
if (hh.isNotEmpty() && mm.isNotEmpty()){
files.add(hh)
files.add(mm)
} else {
cbFail.accept("ETAD variable has invalid soundbank for hour or minute for tag $_tag in messagebank id ${mb.ANN_ID}")
return
}
} else {
cbFail.accept("ETAD variable has invalid soundbank files for tag $_tag in messagebank id ${mb.ANN_ID}, unable to find valid soundbank files for HH='${values[0]}' or MM='${values[1]}'")
cbFail.accept("ETAD variable has invalid hour or minute for tag $_tag in messagebank id ${mb.ANN_ID}, hour must be 0-23 and minute must be 0-59")
return
}
} else {
cbFail.accept("ETAD variable has invalid soundbank for tag $_tag in messagebank id ${mb.ANN_ID}, unable to find soundbank for HH='${values[0]}' or MM='${values[1]}'")
return
}
} else {
cbFail.accept("ETAD variable has invalid format for tag $_tag in messagebank id ${mb.ANN_ID}, expected format HH:MM")
return
@@ -425,7 +445,7 @@ class MainExtension01 {
"[GATENUMBER]" -> {
// gate number bisa angka saja, misalnya 1,2,3
// atau huruf dan angka, misalnya A1, B2, C3, 1A, 2B, 3C
val value = variables["GATENUMBER"].orEmpty()
val value = variables["GATECODE"].orEmpty()
if (ValidString(value)) {
val values = value.split(",").map { it.trim() }.filter { ValidString(it) }
if (values.isNotEmpty()) {

View File

@@ -20,7 +20,7 @@ class BarixConnection(val index: UInt, var channel: String, val ipaddress: Strin
private var _onlinecounter = 0
private val udp = DatagramSocket(0)
private val inet = InetSocketAddress(ipaddress, port)
private val maxUDPsize = 1000
/**
@@ -97,8 +97,11 @@ class BarixConnection(val index: UInt, var channel: String, val ipaddress: Strin
val bb = ByteBuffer.wrap(data)
while(bb.hasRemaining()){
try {
val chunk = ByteArray(if (bb.remaining() > 1400) 1400 else bb.remaining())
val chunk = ByteArray(if (bb.remaining() > maxUDPsize) maxUDPsize else bb.remaining())
bb.get(chunk)
while(bufferRemain<chunk.size){
delay(100)
}
udp.send(DatagramPacket(chunk, chunk.size, inet))
delay(5)
} catch (e: Exception) {