commit 03/09/2025
This commit is contained in:
73
src/Main.kt
73
src/Main.kt
@@ -1,6 +1,9 @@
|
||||
import audio.AudioPlayer
|
||||
import codes.Somecodes.Companion.dateformat1
|
||||
import codes.Somecodes.Companion.timeformat2
|
||||
import com.sun.jna.Platform
|
||||
import content.ContentCache
|
||||
import content.ScheduleDay
|
||||
import database.MariaDB
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -10,6 +13,9 @@ import kotlinx.coroutines.launch
|
||||
import org.tinylog.Logger
|
||||
import oshi.util.GlobalConfig
|
||||
import web.WebApp
|
||||
import java.time.DayOfWeek
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
|
||||
|
||||
fun main() {
|
||||
@@ -22,6 +28,7 @@ fun main() {
|
||||
audioPlayer.InitAudio(1)
|
||||
val content = ContentCache()
|
||||
val db = MariaDB()
|
||||
// Coroutine untuk cek Paging Queue dan AAS Queue setiap detik
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
while (isActive) {
|
||||
delay(1000)
|
||||
@@ -38,16 +45,12 @@ fun main() {
|
||||
} else {
|
||||
// ada broadcast zone yang tidak valid, delete from queue paging
|
||||
db.Delete_Queue_Paging_by_index(it.index)
|
||||
//TODO check log message yang benar
|
||||
db.Add_Log(
|
||||
"AAS",
|
||||
"Cancelled paging message with index ${it.index} due to invalid broadcast zone"
|
||||
db.Add_Log("AAS", "Cancelled paging message with index ${it.index} due to invalid broadcast zone"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// invalid broadcast zone, delete from queue paging
|
||||
db.Delete_Queue_Paging_by_index(it.index)
|
||||
// TODO check log message yang benar
|
||||
db.Add_Log("AAS", "Cancelled paging message with index ${it.index} due to empty broadcast zone")
|
||||
}
|
||||
}
|
||||
@@ -62,22 +65,72 @@ fun main() {
|
||||
} else {
|
||||
// ada broadcast zone yang tidak valid, delete from queue table
|
||||
db.Delete_Queue_Table_by_index(it.index)
|
||||
//TODO check log message yang benar
|
||||
db.Add_Log(
|
||||
"AAS",
|
||||
"Cancelled table message with index ${it.index} due to invalid broadcast zone"
|
||||
db.Add_Log("AAS", "Cancelled table message with index ${it.index} due to invalid broadcast zone"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// invalid broadcast zone, delete from queue table
|
||||
db.Delete_Queue_Table_by_index(it.index)
|
||||
// TODO check log message yang benar
|
||||
db.Add_Log("AAS", "Cancelled table message with index ${it.index} due to empty broadcast zone")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Coroutine untuk cek Schedulebank tiap menit saat detik 00
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
while (isActive) {
|
||||
delay(1000)
|
||||
val localtime = LocalTime.now()
|
||||
// detik harus 00
|
||||
if (localtime.second!=0) continue
|
||||
val timestring = timeformat2.format(localtime)
|
||||
val sch = db.SchedulebankList.filter{
|
||||
it.Time==timestring && it.Enable
|
||||
}
|
||||
// tidak ada schedule dengan time sekarang dan enable=true
|
||||
if (sch.isEmpty()) continue
|
||||
|
||||
val localdate = LocalDate.now()
|
||||
val ddmmyyyy = dateformat1.format(localdate)
|
||||
// check special date dulu
|
||||
val specialdate = sch.find {
|
||||
it.Day==ddmmyyyy
|
||||
}
|
||||
if (specialdate!=null) {
|
||||
// TODO Masukin ke queue table sebagai schedule special date
|
||||
|
||||
}
|
||||
// cek weekly schedule
|
||||
val weekly = sch.find {
|
||||
it.Day == when(localdate.dayOfWeek){
|
||||
DayOfWeek.MONDAY -> ScheduleDay.Monday.name
|
||||
DayOfWeek.TUESDAY -> ScheduleDay.Tuesday.name
|
||||
DayOfWeek.WEDNESDAY -> ScheduleDay.Wednesday.name
|
||||
DayOfWeek.THURSDAY -> ScheduleDay.Thursday.name
|
||||
DayOfWeek.FRIDAY -> ScheduleDay.Friday.name
|
||||
DayOfWeek.SATURDAY -> ScheduleDay.Saturday.name
|
||||
DayOfWeek.SUNDAY -> ScheduleDay.Sunday.name
|
||||
}
|
||||
}
|
||||
if (weekly!=null) {
|
||||
// TODO Masukin ke queue table sebagai schedule weekly
|
||||
|
||||
}
|
||||
// check daily schedule
|
||||
val daily = sch.find {
|
||||
it.Day == ScheduleDay.Everyday.name
|
||||
}
|
||||
if (daily!=null) {
|
||||
// TODO Masukin ke queue table sebagai schedule daily
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val web = WebApp(
|
||||
3030,
|
||||
listOf(
|
||||
|
||||
Reference in New Issue
Block a user