commit 08/10/2025
BarixConnection Activate Deactivate Relays
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import audio.AudioFileInfo
|
||||
import barix.BarixConnection
|
||||
import codes.Result_GetSoundbankFiles
|
||||
import codes.Somecodes.Companion.Get_ANN_ID
|
||||
import codes.Somecodes.Companion.IsAlphabethic
|
||||
@@ -89,6 +90,25 @@ class MainExtension01 {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Find BarixConnection by BroadcastZones description
|
||||
* @param zonename BroadcastZones description
|
||||
* @return BarixConnection if found, null if not found or invalid
|
||||
*/
|
||||
fun Get_Barix_Connection_by_ZoneName(zonename: String) : BarixConnection? {
|
||||
if (ValidString(zonename)){
|
||||
val bz = db.broadcastDB.List.find{ it.description == zonename }
|
||||
val sc = if (bz!=null) db.soundchannelDB.List.find { it.channel == bz.SoundChannel } else null
|
||||
val ip = sc?.ip ?: ""
|
||||
if (ValidIPV4(ip)){
|
||||
// ketemu ip-nya
|
||||
return StreamerOutputs[ip]
|
||||
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* find SoundChannel IP from BroadcastZones description
|
||||
* @param bz List of BroadcastZones description
|
||||
@@ -550,8 +570,18 @@ class MainExtension01 {
|
||||
if (AllStreamerOutputIdle(ips)){
|
||||
val afi = audioPlayer.LoadAudioFile(qp.Message)
|
||||
if (afi.isValid()){
|
||||
// file bisa di load, kirim ke masing masing Streamer Output by IP address
|
||||
ips.forEach { ip -> StreamerOutputs[ip]?.SendData(afi.bytes, { db.Add_Log("AAS", it) }, { db.Add_Log("AAS", it) }) }
|
||||
// file bisa di load, kirim ke masing-masing Streamer Output by IP address
|
||||
Activate_Relays(zz)
|
||||
ips.forEach { ip ->
|
||||
// send byte array to streamer output
|
||||
StreamerOutputs[ip]?.SendData(afi.bytes,
|
||||
{
|
||||
Deactivate_Relays(zz)
|
||||
db.Add_Log("AAS", it) },
|
||||
{
|
||||
Deactivate_Relays(zz)
|
||||
db.Add_Log("AAS", it) })
|
||||
}
|
||||
|
||||
val logmessage =
|
||||
"Broadcast started PAGING with Filename '${qp.Message}' to zones: ${qp.BroadcastZones}"
|
||||
@@ -640,7 +670,18 @@ class MainExtension01 {
|
||||
// file siap broadcast
|
||||
val targetafi = audioPlayer.LoadAudioFile(targetfile)
|
||||
if (targetafi.isValid()) {
|
||||
ips.forEach { ip -> StreamerOutputs[ip]?.SendData(targetafi.bytes, { db.Add_Log("AAS", it) }, {db.Add_Log("AAS", it) }) }
|
||||
// activate relays from broadcast zone
|
||||
Activate_Relays(zz)
|
||||
ips.forEach { ip ->
|
||||
// send byte array to streamer output
|
||||
StreamerOutputs[ip]?.SendData(targetafi.bytes,
|
||||
{
|
||||
Deactivate_Relays(zz)
|
||||
db.Add_Log("AAS", it) },
|
||||
{
|
||||
Deactivate_Relays(zz)
|
||||
db.Add_Log("AAS", it) })
|
||||
}
|
||||
|
||||
val logmsg =
|
||||
"Broadcast started SHALAT message with generated file '$targetfile' to zones: ${qp.BroadcastZones}"
|
||||
@@ -730,7 +771,18 @@ class MainExtension01 {
|
||||
// file siap broadcast
|
||||
val targetafi = audioPlayer.LoadAudioFile(targetfile)
|
||||
if (targetafi.isValid()) {
|
||||
ips.forEach { ip -> StreamerOutputs[ip]?.SendData(targetafi.bytes, { db.Add_Log("AAS", it) }, { db.Add_Log("AAS", it) }) }
|
||||
// activate relays from broadcast zone
|
||||
Activate_Relays(zz)
|
||||
ips.forEach { ip ->
|
||||
// send byte array to streamer output
|
||||
StreamerOutputs[ip]?.SendData(targetafi.bytes,
|
||||
{
|
||||
Deactivate_Relays(zz)
|
||||
db.Add_Log("AAS", it) },
|
||||
{
|
||||
Deactivate_Relays(zz)
|
||||
db.Add_Log("AAS", it) })
|
||||
}
|
||||
|
||||
val logmsg =
|
||||
"Broadcast started TIMER message with generated file '$targetfile' to zones: ${qa.BroadcastZones}"
|
||||
@@ -779,6 +831,37 @@ class MainExtension01 {
|
||||
return false
|
||||
}
|
||||
|
||||
fun Activate_Relays(zz: List<String>){
|
||||
zz.forEach { zonename ->
|
||||
val bz = db.broadcastDB.List.find { it.description == zonename }
|
||||
if (bz!=null){
|
||||
val bc = Get_Barix_Connection_by_ZoneName(zonename)
|
||||
if (bc!=null){
|
||||
// ada barix connection
|
||||
val relays = bz.bp.split(",")
|
||||
.map { it.trim()}
|
||||
.filter { it.isNotBlank() }
|
||||
.filter { IsNumber(it) && it.toInt() in 1..8 }
|
||||
.map{ it.toInt() }
|
||||
if (relays.isNotEmpty()) bc.ActivateRelay(relays)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun Deactivate_Relays(zz: List<String>){
|
||||
zz.forEach { zonename ->
|
||||
val bz = db.broadcastDB.List.find { it.description == zonename }
|
||||
if (bz!=null){
|
||||
val bc = Get_Barix_Connection_by_ZoneName(zonename)
|
||||
bc?.DeactivateRelay()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun Read_Queue_Soundbank() : Boolean{
|
||||
db.queuetableDB.Get()
|
||||
val list = db.queuetableDB.List.filter { it.Type=="SOUNDBANK" }
|
||||
@@ -864,7 +947,20 @@ class MainExtension01 {
|
||||
//println("Successfully wrote WAV file: $targetfile")
|
||||
val targetafi = audioPlayer.LoadAudioFile(targetfile)
|
||||
if (targetafi.isValid()) {
|
||||
ips.forEach { ip -> StreamerOutputs[ip]?.SendData(targetafi.bytes, { db.Add_Log("AAS", it) }, { db.Add_Log("AAS", it) }) }
|
||||
// activate relays from broadcast zone
|
||||
Activate_Relays(zz)
|
||||
ips.forEach { ip ->
|
||||
// send byte array to streamer output
|
||||
StreamerOutputs[ip]?.SendData(targetafi.bytes,
|
||||
{
|
||||
Deactivate_Relays(zz)
|
||||
db.Add_Log("AAS", it)
|
||||
|
||||
}, {
|
||||
Deactivate_Relays(zz)
|
||||
db.Add_Log("AAS", it)
|
||||
})
|
||||
}
|
||||
|
||||
val logmsg =
|
||||
"Broadcast started SOUNDBANK message with generated file '$targetfile' to zones: ${qa.BroadcastZones}"
|
||||
|
||||
Reference in New Issue
Block a user