commit 22/05/2025

This commit is contained in:
rdkartono
2025-05-22 11:25:54 +07:00
parent ee0a82aa32
commit 1fcd905b07
5 changed files with 129 additions and 67 deletions

View File

@@ -1,4 +1,4 @@
#Tue May 13 14:43:52 WIB 2025
#Thu May 22 11:19:22 WIB 2025
AudioPhase1=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase1.mp3
AudioPhase2=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase2.mp3
AudioPhase3=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase3.mp3
@@ -21,7 +21,7 @@ FTPPort=21
FTPUser=user
FlipCamera=true
MirrorCamera=true
PhotoDirectory=C\:\\Users\\rdkar\\OneDrive\\Desktop\\Erha Capture
PhotoDirectory=C\:\\Users\\Erha\\Desktop\\ErhaCapture
SharpnessThreshold=1000.0
cascadeMaxSize=500
cascadeMinNeighbors=3

Binary file not shown.

View File

@@ -42,6 +42,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import static org.bytedeco.opencv.global.opencv_core.CV_64F;
@@ -147,6 +148,19 @@ public class SomeCodes {
}
}
public static void WaitAsync(long millis, String threadname, Consumer<Void> success){
Thread thread = new Thread(()->{
try {
Thread.sleep(millis);
} catch (Exception ignored){ }
if (success != null) success.accept(null);
});
thread.setName(threadname);
thread.setDaemon(true);
thread.start();
}
/**
* Make thumbfile from source jpg file
* @param sourcejpg source jpg file

View File

@@ -318,6 +318,7 @@ public class CaptureView {
PlayFileWithoutEvent(audio_pengambilan_gagal);
} else {
PlayFileWithoutEvent(audio_hubungi_staf_kami);
clear();
}
return;
@@ -839,6 +840,7 @@ public class CaptureView {
runningTask = timeoutExecutor.schedule(()->{
// timeout
clear();
System.out.println("180 seconds timeout");
}, timeout, TimeUnit.SECONDS);
// Revisi 19/05/2025
@@ -847,12 +849,90 @@ public class CaptureView {
// terakhir, PlayFile audio_hubungi_staf_kami
audioTimeline = new Timeline();
int file_duration = 8; // audio_posisikan_muka durasi 7 detik
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(0), k1 -> PlayFileWithoutEvent(audio_posisikan_muka)));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(5+file_duration), k2 -> PlayFileWithoutEvent(audio_posisikan_muka)));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(10+file_duration), k3 -> PlayFileWithoutEvent(audio_posisikan_muka)));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(15+file_duration), k4 ->{
PlayFileWithoutEvent(audio_hubungi_staf_kami);
final int file_duration = 8; // audio_posisikan_muka durasi 7 detik
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(0), k1 ->{
PlayFileWithEvent(audio_posisikan_muka, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
anti_bawel.set(true);
System.out.println("Peringatan pertama audio_posisikan_muka");
}
@Override
public void onPlaybackFinished(String filename) {
anti_bawel.set(false);
}
@Override
public void onPlaybackFailure(String filename) {
anti_bawel.set(false);
}
});
}));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(file_duration+5), k2 -> {
PlayFileWithEvent(audio_posisikan_muka, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
anti_bawel.set(true);
System.out.println("Peringatan kedua audio_posisikan_muka");
}
@Override
public void onPlaybackFinished(String filename) {
anti_bawel.set(false);
}
@Override
public void onPlaybackFailure(String filename) {
anti_bawel.set(false);
}
});
}));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(3*file_duration+5), k3 -> {
PlayFileWithEvent(audio_posisikan_muka, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
anti_bawel.set(true);
System.out.println("Peringatan ketiga audio_posisikan_muka");
}
@Override
public void onPlaybackFinished(String filename) {
anti_bawel.set(false);
}
@Override
public void onPlaybackFailure(String filename) {
anti_bawel.set(false);
}
});
}));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(5*file_duration+5), k4 ->{
PlayFileWithEvent(audio_hubungi_staf_kami, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
anti_bawel.set(true);
System.out.println("Peringatan keempat audio_hubungi_staf_kami");
}
@Override
public void onPlaybackFinished(String filename) {
anti_bawel.set(false);
}
@Override
public void onPlaybackFailure(String filename) {
anti_bawel.set(false);
}
});
clear();
}));
@@ -899,35 +979,9 @@ public class CaptureView {
TextAreaSetText(medicalRecordID,""+medrecid);
TextAreaSetText(PatientName, pr.name);
// harusnya ganti ke Timeline, tapi belum tested
//if (audioTimeline!=null) audioTimeline.play();
if (anti_bawel.get()) return; // sudah ada LiveCamEvent lain yang bunyiin, jadi tidak usah bunyiin lagi
if (audioTimeline!=null) audioTimeline.play();
if (anti_bawel.get()) return;
PlayFileWithEvent(audio_posisikan_muka, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
anti_bawel.set(true);
}
@Override
public void onPlaybackFinished(String filename) {
Thread antibawel = new Thread(()->{
try {
Thread.sleep(15*1000);
} catch (InterruptedException ignored) {
}
anti_bawel.set(false);
});
antibawel.setName("anti bawel");
antibawel.setDaemon(true);
antibawel.start();
}
@Override
public void onPlaybackFailure(String filename) {
anti_bawel.set(false);
}
});
}
});
@@ -963,11 +1017,11 @@ public class CaptureView {
}
//update_status(image);
if (hasface && audioTimeline!=null) audioTimeline.stop();
// instruksi scan barcode ketika welcomeUI masih muncul dan ada muka terdeteksi
if (hasface && Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
if (anti_bawel.get()) return;
if (hasface){
// ada face terdeteksi
if (Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
// WelcomeUI masih muncul
if (anti_bawel.get()) return; // sudah ada LiveCamEvent lain yang bunyiin, jadi tidak usah bunyiin lagi
PlayFileWithEvent(audio_scan_barcode, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
@@ -976,16 +1030,7 @@ public class CaptureView {
@Override
public void onPlaybackFinished(String filename) {
Thread antibawel = new Thread(()->{
try {
Thread.sleep(15*1000);
} catch (InterruptedException ignored) {
}
anti_bawel.set(false);
});
antibawel.setName("anti bawel");
antibawel.setDaemon(true);
antibawel.start();
WaitAsync(15*1000, "anti bawel", x-> anti_bawel.set(false));
}
@Override
@@ -993,11 +1038,14 @@ public class CaptureView {
}
});
} else if (audioTimeline!=null){
// WelcomeUI sudah tidak muncul, tapi audioTimeLine masih ada
audioTimeline.stop();
}
}
}
}

View File

@@ -28,13 +28,13 @@ public class MainApplication extends Application {
public void start(Stage stage) throws IOException {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (photoCleaner!=null) photoCleaner.Stop();
System.out.println("ShutdownHook Checking running threads...");
Map<Thread, StackTraceElement[]> allThreads = Thread.getAllStackTraces();
for(Thread thread : allThreads.keySet()){
//System.out.println("Thread: " + thread.getName()+", State: " + thread.getState()+", Daemon: " + thread.isDaemon());
System.out.println("Thread: " + thread.getName()+", State: " + thread.getState()+", Daemon: " + thread.isDaemon());
thread.interrupt();
}
if (photoCleaner!=null) photoCleaner.Stop();
}));
@@ -50,7 +50,7 @@ public class MainApplication extends Application {
Screen screen = Screen.getPrimary();
Rectangle2D screenbound = screen.getBounds();
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
stage.setTitle("MultiCam Capture App for ERHA 20052025-001");
stage.setTitle("MultiCam Capture App for ERHA 22052025-004");
stage.setScene(scene);
stage.setResizable(true);
stage.setMaximized(true);