This commit is contained in:
rdkartono
2025-05-20 10:32:55 +07:00
24 changed files with 60 additions and 82 deletions

View File

@@ -226,10 +226,10 @@ public class SomeCodes {
for(int i=0; i<path.length; i++){
try{
result[i] = Files.deleteIfExists(Path.of(path[i]));
if (result[i]) System.out.println("Delete: "+path[i]);
if (result[i]) Logger.info("Delete: "+path[i]);
} catch (Exception e){
result[i] = false;
System.out.println("Error deleting file: "+path[i]+", Msg : "+e.getMessage());
Logger.error("Error deleting file: "+path[i]+", Msg : "+e.getMessage());
}
}
return Arrays.stream(result).allMatch(x->x);
@@ -243,10 +243,10 @@ public class SomeCodes {
for(int i=0; i<path.length; i++){
try{
result[i] = Files.deleteIfExists(path[i]);
if (result[i]) System.out.println("Delete: "+path[i]);
if (result[i]) Logger.info("Delete: "+path[i]);
} catch (Exception e){
result[i] = false;
System.out.println("Error deleting file: "+path[i]+", Msg : "+e.getMessage());
Logger.error("Error deleting file: "+path[i]+", Msg : "+e.getMessage());
}
}
return Arrays.stream(result).allMatch(x->x);

View File

@@ -21,7 +21,6 @@ public class PhotoCleaner {
public PhotoCleaner(int days){
this.days = days;
this.started = new boolean[]{false};
System.out.println("PhotoCleaner created, days: "+days);
}
/**
@@ -31,7 +30,6 @@ public class PhotoCleaner {
public void Start(){
Thread thread = new Thread(() -> {
started[0] = true;
System.out.println("PhotoCleaner started");
while (started[0]) {
try {
System.out.println("Rechecking Database for older photos...");
@@ -42,7 +40,6 @@ public class PhotoCleaner {
Thread sqldelete = new Thread(()->{
Sqlite sql = new Sqlite();
PhotoReviewClass[] prcs = sql.GetAll();
System.out.println("Database contains "+prcs.length+" PhotoReviewClass");
for (PhotoReviewClass prc : prcs) {
if (!started[0]) break;
if (prc != null && prc.getDateTime() != null) {
@@ -55,7 +52,7 @@ public class PhotoCleaner {
SomeCodes.Delete(prc.compressedcrop());
SomeCodes.Delete(prc.thumbnails());
sql.Delete(prc);
System.out.println("Deleted PhotoReviewClass: " + prc.getDateTime() + " " + prc.getPrefix());
Logger.info("Deleted PhotoReviewClass: " + prc.getDateTime() + " " + prc.getPrefix());
}
}
}
@@ -103,10 +100,8 @@ public class PhotoCleaner {
this.now = LocalDateTime.now();
}
public void run(){
System.out.println("DiskDeleter started, path: "+path);
Path[] ppp = SomeCodes.GetFilesInDirectory(path);
if (ppp != null){
System.out.println("DiskDeleter found "+ppp.length+" files in path: "+path);
for(Path p : ppp){
if (!started[0]) break;
LocalDateTime ldt = SomeCodes.GetCreationTime(p);

View File

@@ -94,14 +94,11 @@ public class ErhaAPI {
return gson.fromJson(body, BarcodeResullt.class);
} else {
Logger.error("Validate_Barcode failed, status code : " , response.statusCode());
System.out.println("Validate Barcode status code : " + response.statusCode());
}
} catch (IOException e) {
System.out.println("Validate_Barcode IO Exception, Msg : " + e.getMessage());
Logger.error("Validate_Barcode IO Exception, Msg : " , e.getMessage());
} catch (InterruptedException e) {
System.out.println("Validate_Barcode Interrupted Exception, Msg : " + e.getMessage());
Logger.error("Validate_Barcode Interrupted Exception, Msg : " , e.getMessage());
}
@@ -173,13 +170,11 @@ public class ErhaAPI {
return gson.fromJson(response.body(), UploadResult.class);
} else {
System.out.println("Upload_File status code : " + response.statusCode());
Logger.error("Upload_File file ",filename," failed, status code : " , response.statusCode());
}
} catch (Exception e){
System.out.println("Upload_File Exception, Msg : " + e.getMessage());
Logger.error("Upload_File file ",filename," failed, Exception, Msg : " , e.getMessage());
}
}

View File

@@ -76,7 +76,6 @@ public class SecureDongle {
if (result== LibSecureDongle.ERR_SUCCESS){
HardwareID = lp1[0];
//System.out.println("SecureDongle found with HardwareID="+HardwareID);
return true;
} else {
if (event!=null) event.onDongleError("Find", result);
@@ -135,10 +134,9 @@ public class SecureDongle {
System.arraycopy(data, 0, buffer, 0, length);
short result = SD.SecureDongle(LibSecureDongle.SD_WRITE, handle, lp1, lp2, p1, p2, p3, p4, buffer);
if (result== LibSecureDongle.ERR_SUCCESS){
//System.out.println("SecureDongle HardwareID="+HardwareID+" write success ");
return true;
} else if (event!=null) event.onDongleError("Write", result);
} //else System.out.println("SecureDongle not opened");
}
return false;
}
@@ -160,12 +158,11 @@ public class SecureDongle {
p2[0] = Length;
short result = SD.SecureDongle(LibSecureDongle.SD_READ, handle, lp1, lp2, p1, p2, p3, p4, buffer);
if (result== LibSecureDongle.ERR_SUCCESS){
//System.out.println("SecureDongle HardwareID="+HardwareID+" read success ");
byte[] data = new byte[Length];
System.arraycopy(buffer, 0, data, 0, Length);
return data;
} else if (event!=null) event.onDongleError("Read", result);
} //else System.out.println("SecureDongle not opened");
}
return new byte[0];
}
@@ -181,14 +178,13 @@ public class SecureDongle {
handle[0] = Handle;
short result = SD.SecureDongle(LibSecureDongle.SD_RANDOM, handle, lp1, lp2, p1, p2, p3, p4, buffer);
if (result== LibSecureDongle.ERR_SUCCESS){
//System.out.println("SecureDongle HardwareID="+HardwareID+" generate random success ");
random[0] = p1[0];
random[1] = p2[0];
random[2] = p3[0];
random[3] = p4[0];
return random;
} else if (event!=null) event.onDongleError("GenerateRandomNumber", result);
} //else System.out.println("SecureDongle not opened");
}
return random;
}
@@ -205,11 +201,10 @@ public class SecureDongle {
lp1[0] = UserID;
short result = SD.SecureDongle(LibSecureDongle.SD_WRITE_USERID, handle, lp1, lp2, p1, p2, p3, p4, buffer);
if (result== LibSecureDongle.ERR_SUCCESS){
//System.out.println("SecureDongle HardwareID="+HardwareID+" set UserID success ");
this.UserID = UserID;
return true;
} else if (event!=null) event.onDongleError("WriteUserID", result);
} //else System.out.println("SecureDongle not opened");
}
return false;
}
@@ -224,10 +219,9 @@ public class SecureDongle {
short result = SD.SecureDongle(LibSecureDongle.SD_READ_USERID, handle, lp1, lp2, p1, p2, p3, p4, buffer);
if (result== LibSecureDongle.ERR_SUCCESS){
this.UserID = lp1[0];
//System.out.println("SecureDongle HardwareID="+HardwareID+" read UserID success, value = "+UserID);
return UserID;
} else if (event!=null) event.onDongleError("ReadUserID", result);
} //else System.out.println("SecureDongle not opened");
}
return 0;
}

View File

@@ -19,6 +19,8 @@ import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.*;
import javafx.util.Duration;
import org.tinylog.Logger;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@@ -341,12 +343,11 @@ public class AutoCloseAlert {
if (ValidFile(filename)){
try{
Image mm = new Image(Paths.get(filename).toUri().toString());
System.out.println("Load image from "+filename);
return mm;
} catch (Exception e){
System.out.println("Error loading image: " + filename+", Message: "+e.getMessage());
Logger.error("Error loading image: " + filename+", Message: "+e.getMessage());
}
} else System.out.println("LoadImage: Invalid file: "+filename);
} else Logger.error("LoadImage: Invalid file: " + filename);
return null;
}

View File

@@ -919,7 +919,6 @@ public class Cameradetail {
if (theface.getFace()!=null){
LiveMatROI = new Rect(theface.getFace().x(), theface.getFace().y(), theface.getFace().width(), theface.getFace().height());
//System.out.println("Frontal Face Detected from camera "+cameratitle+" "+RectToString(LiveMatROI));
}
if (theface.getEyesCount()>=2){
@@ -930,7 +929,6 @@ public class Cameradetail {
if (event!=null) event.onEyeDetector(true);
LabelVisible(eye_indicator,true);
//System.out.println("Valid Eye Detected from camera "+cameratitle);
// Valid eye condition
if (eye_state.get()!=1){
@@ -939,7 +937,6 @@ public class Cameradetail {
System.out.println("First Eye Detected from camera "+cameratitle.getText());
eye_state.set(1);
} else {
//System.out.println("Transition from close to open eyes");
eye_state.set(1);
blink_counter.incrementAndGet();
@@ -975,7 +972,6 @@ public class Cameradetail {
if (eye_state.get()!=0){
//System.out.println("Transition from open to close eyes");
eye_state.set(0);
}

View File

@@ -4,7 +4,6 @@ import BASS.AudioPlayer;
import BASS.PlaybackStatus;
import Camera.*;
import Config.CameraConfigEnum;
import Config.SomeCodes;
import Database.PhotoReviewClass;
import Database.Sqlite;
import ErhaAPI.ErhaAPI;
@@ -13,6 +12,8 @@ import ErhaAPI.PhotoResult;
import ErhaAPI.PatientRecord;
import ErhaAPI.UploadResult;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.concurrent.Task;
@@ -30,6 +31,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javafx.scene.control.Alert.AlertType;
import javafx.util.Duration;
import org.bytedeco.javacv.OpenCVFrameGrabber;
import org.bytedeco.javacv.VideoInputFrameGrabber;
import org.bytedeco.opencv.opencv_core.Rect;
@@ -73,7 +75,7 @@ public class CaptureView {
private String audio_posisikan_muka = "posisikan_wajah.wav";
private String audio_scan_barcode = "scan_barcode.wav";
private String audio_pengambilan_gagal = "pengambilan_gagal.wav";
private String audio_pengambilan_berhasil = "pengambilan_berhasil.wav";
private String audio_pengambilan_berhasil = "pengambilan_berhasil_tunggu_lobby.wav";
private String audio_upload_gagal = "upload_gagal.wav";
private String audio_countdown = "countdown321.wav";
private String audio_camera_shutter = "camera-shutter-click-01.wav";
@@ -206,12 +208,10 @@ public class CaptureView {
}
} else {
System.out.println("Prefix invalid, not taking photo");
isTakingPhoto.set(false);
//AutoCloseAlert.show("QR Code Not Available", "", "Please scan QR before continue", 5, s -> AutoCloseAlert.show("Scan Barcode", "Silahkan Scan Barcode Anda", "Arahkan kertas barcode ke kamera", 0, null));
if (!Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
if (AutoCloseAlert.banner_01!=null){
System.out.println("Showing banner 01 because prefix invalid");
AutoCloseAlert.showbanner(AutoCloseAlert.banner_01,0,null);
}
}
@@ -225,7 +225,6 @@ public class CaptureView {
}
}
} else {
System.out.println("Photo Directory invalid, not taking photo");
isTakingPhoto.set(false);
AutoCloseAlert.show("Invalid Photo Directory","Photo Directory not set", "Please set photo directory at Setting", 5, s -> AutoCloseAlert.show("Setting", "Setting", "Please set photo directory", 0, null));
}
@@ -307,8 +306,6 @@ public class CaptureView {
String timestamp = SomeCodes.GetDateTimeString();
System.out.println("Creating timestamp: "+timestamp);
// check for blurred image
double score1=-1, score2=-1, score3=-1, score4=-1, score5=-1;
@@ -530,7 +527,6 @@ public class CaptureView {
public void onPlaybackFinished(String filename) {
AutoCloseAlert.showpictures(prc.compressed(),3, (s)->{
if (AutoCloseAlert.banner_02!=null) {
System.out.println("Showing banner 02 after photo taken");
AutoCloseAlert.showbanner(AutoCloseAlert.banner_02, 0, null);
UploadFiles(prc, prefix);
@@ -573,7 +569,7 @@ public class CaptureView {
int totalfiles = files.length;
int counter = 0;
for (String ff : files) {
UploadResult ur = erhaAPI.Upload_File(prefix, ff,true);
UploadResult ur = erhaAPI.Upload_File(prefix, ff,false);
if (ur != null) {
if (ur.message.startsWith("Record has been created")) {
counter++;
@@ -591,19 +587,12 @@ public class CaptureView {
uploadtask.messageProperty().addListener((obs, oldval, newval)-> {
System.out.println("UploadTask message: "+newval);
Logger.info(newval);
});
uploadtask.messageProperty().addListener((obs, oldval, newval)-> Logger.info(newval));
uploadtask.setOnSucceeded(e-> {
System.out.println("UploadTask succeeded");
clear();
});
uploadtask.setOnSucceeded(e-> clear());
uploadtask.setOnFailed(e-> {
System.out.println("UploadTask failed");
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_upload_gagal)){
audioPlayer.StopCurrentPlayback();
@@ -637,15 +626,12 @@ public class CaptureView {
//tambahan 19/03/2025
barcodeData.textProperty().addListener((observable, oldValue, newValue) -> {
System.out.println("barcodeData changed from ["+oldValue+"] to ["+newValue+"]");
if (ValidBarCode(newValue)){
if (Objects.equals(AutoCloseAlert.banner_01, AutoCloseAlert.shownBanner)){
System.out.println("Close banner 01");
AutoCloseAlert.close();
}
} else {
if (AutoCloseAlert.banner_01!=null){
System.out.println("Show banner 01");
AutoCloseAlert.showbanner(AutoCloseAlert.banner_01,0, null);
}
}
@@ -680,7 +666,6 @@ public class CaptureView {
Platform.runLater(()->{
if (!Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
if (AutoCloseAlert.banner_01!=null){
System.out.println("Showing banner 01 for first time");
AutoCloseAlert.showbanner(AutoCloseAlert.banner_01,0,null);
}
}
@@ -886,6 +871,9 @@ public class CaptureView {
boolean use_qr_detector = true;
LiveCamEvent lce = new LiveCamEvent() {
Timeline audioTimeline;
@Override
public void onDetectedQRCode(String barCode) {
barCode = RemoveSpaces(barCode);
@@ -894,10 +882,39 @@ public class CaptureView {
if (!barCode.equals(prefix)){
final String finalbarCode = barCode;
TextAreaSetText(barcodeData, finalbarCode);
// revisi 19/05/2025
if (runningTask!=null) runningTask.cancel(false);
runningTask = timeoutExecutor.schedule(()->{
// timeout
clear();
}, timeout, TimeUnit.SECONDS);
// Revisi 19/05/2025
// pakai Timeline untuk pengulangan PlayFile audio_posisikan_muka dengan interval 5 detik
// diulang 3x
// terakhir, PlayFile audio_hubungi_staf_kami
audioTimeline = new Timeline();
int file_duration = 7; // audio_posisikan_muka durasi 7 detik
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(0), k1 ->{
}));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(5+file_duration), k2 ->{
}));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(10+file_duration), k3 ->{
}));
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(15+file_duration), k4 ->{
}));
Task<PatientRecord> checkpatientID = new Task<>() {
@Override
protected PatientRecord call() throws Exception {
BarcodeResullt br = erhaAPI.Validate_Barcode(finalbarCode,true);
BarcodeResullt br = erhaAPI.Validate_Barcode(finalbarCode,false);
if (br!=null){
if (br.message.startsWith("Records found")){
if (br.data!=null && br.data.length>0){
@@ -936,12 +953,8 @@ public class CaptureView {
TextAreaSetText(medicalRecordID,""+medrecid);
TextAreaSetText(PatientName, pr.name);
if (audioTimeline!=null) audioTimeline.play();
runningTask = timeoutExecutor.schedule(()->{
// timeout
System.out.println("runningTask timeout after "+timeout+" seconds");
clear();
}, timeout, TimeUnit.SECONDS);
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_posisikan_muka)) {
@@ -992,7 +1005,6 @@ public class CaptureView {
Task<?> failed = (Task<?>) event.getSource();
Throwable t = failed.getException();
final String message = t.getMessage();
System.out.println("checkpatientID.setOnFailed message : "+message);
AutoCloseAlert.show("Data Tidak Ditemukan", "Pastikan data barcode anda benar", message , 5, s -> clear());
@@ -1019,6 +1031,8 @@ 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 (audioPlayer!=null && audioPlayer.isInited()){
@@ -1092,7 +1106,6 @@ public class CaptureView {
@Override
public void onDoubleBlink(int counter) {
System.out.println("Double Blink detected at camera "+title+" delay= "+counter);
if (audioPlayer!=null && audioPlayer.isPlaying()) return; // let audio finish playback
if (isTakingPhoto.get()) return; // other camera is taking picture
// revisi 08/04/2025
@@ -1145,7 +1158,6 @@ public class CaptureView {
cam.getChildren().add(child);
cam.widthProperty().addListener(observable ->{
//System.out.println("Width property, cam "+camid+" width="+cam.getWidth()+" height="+cam.getHeight());
if (cam.getWidth()!=0) {
if (cam.getHeight()!=0){
AnchorPane.setTopAnchor(child, 0.0);
@@ -1156,7 +1168,6 @@ public class CaptureView {
}
});
cam.heightProperty().addListener(observable -> {
//System.out.println("Height property, cam "+camid+" width="+cam.getWidth()+" height="+cam.getHeight());
if (cam.getWidth()!=0) {
if (cam.getHeight()!=0){
AnchorPane.setTopAnchor(child, 0.0);

View File

@@ -97,7 +97,6 @@ public class Detectors {
for(Rect eye : eyes.get()){
if (SomeCodes.IsInsideRect(eye, face)) {
dr.AddEye(eye);
System.out.println("face width : " + face.width() + " eye width : " + eye.width());
}
}
}
@@ -145,7 +144,6 @@ public class Detectors {
//Logger.info("FaceMinSize created with value : " + FaceminSize.width());
}
System.out.println("Face Min Size : " + FaceminSize.width());
}
public static void setFaceMaxSize(int value){
@@ -159,7 +157,6 @@ public class Detectors {
//Logger.info("FaceMaxSize created with value : " + FacemaxSize.width());
}
System.out.println("Face Max Size : " + FacemaxSize.width());
}

View File

@@ -31,8 +31,8 @@ public class MainApplication extends Application {
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());
//thread.interrupt();
//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 13052025-001");
stage.setTitle("MultiCam Capture App for ERHA 19052025-001");
stage.setScene(scene);
stage.setResizable(true);
stage.setMaximized(true);

View File

@@ -45,17 +45,8 @@ public class PhotoRow {
imgview.setStyle(borderstyle);
imgview.setOnMouseClicked(e->{
if (e.getClickCount()>=2){
//System.out.println("Photo path: "+photopath);
File ff = new File(photopath);
// System.out.println("Config exists : "+(config!=null));
// System.out.println("Photo directory: "+config.getPhotoDirectory());
// System.out.println("Full quality directory: "+config.getFullQualityDirectory());
// System.out.println("Full Quality Crop directory: "+config.getFullQualityCropDirectory());
// System.out.println("Reduced quality directory: "+config.getCompressedDirectory());
// System.out.println("Reduced quality crop directory: "+config.getCompressedCropDirectory());
//String hires = Path.of(config.getPhotoDirectory(), ff.getName()).toString();
String hires = Path.of(config.getFullQualityDirectory(), ff.getName()).toString();
//System.out.println("Hires: "+hires);
File hiresfile = new File(hires);
if (hiresfile.isFile()){
System.out.println("Opening file: "+hires);

View File

@@ -144,13 +144,11 @@ public class SettingView {
}
MirrorCamera.selectedProperty().addListener(((observable, oldValue, newValue) -> {
System.out.println("Mirror option changed to : "+newValue);
config.setMirrorCamera(newValue);
config.Save();
}));
FlipCamera.selectedProperty().addListener((observable, oldValue, newValue) -> {
System.out.println("Flip option changed to : "+newValue);
config.setFlipCamera(newValue);
config.Save();
});