GPIO control.

Bug fix.
This commit is contained in:
2024-11-14 10:23:50 +07:00
parent 10fad0e192
commit 0942c9936c
12 changed files with 340 additions and 104 deletions

View File

@@ -1,6 +1,7 @@
package Camera;
import com.fazecast.jSerialComm.SerialPort;
import id.co.gtc.Main;
import org.tinylog.Logger;
@@ -40,9 +41,6 @@ public class PanTiltController {
} else Logger.info("Serial Port {} not found", portname);
} else Logger.info("No Serial Port found");
}
/**
@@ -53,6 +51,14 @@ public class PanTiltController {
Logger.info("Serial Port closed");
}
/**
* Check if Serial Port is open
* @return true if open, false otherwise
*/
public boolean isOpen(){
return serialPort != null && serialPort.isOpen();
}
/**
* Stop Pan Tilt Movement
*/
@@ -60,7 +66,12 @@ public class PanTiltController {
byte[] command = new byte[]{0, cameraid, 0, 0, 0, 0, 0};
command[6] = Checksum(command); // add checksum
command[0] = (byte) 0xFF; // add synchronization byte
if (serialPort!=null && serialPort.isOpen()) serialPort.writeBytes(command, command.length);
if (isOpen()) {
Main.Max485Direction(true);
serialPort.writeBytes(command, command.length);
Main.Max485Direction(false);
Main.Blink_LedPanTilt();
}
}
/**
@@ -74,7 +85,12 @@ public class PanTiltController {
byte[] command = new byte[]{0, cameraid, 0, 4, speed, 0, 0};
command[6] = Checksum(command); // add checksum
command[0] = (byte) 0xFF; // add synchronization byte
if (serialPort!=null && serialPort.isOpen()) serialPort.writeBytes(command, command.length);
if (isOpen()) {
Main.Max485Direction(true);
serialPort.writeBytes(command, command.length);
Main.Max485Direction(false);
Main.Blink_LedPanTilt();
}
}
/**
@@ -88,7 +104,12 @@ public class PanTiltController {
byte[] command = new byte[]{0, cameraid, 0, 2, speed, 0, 0};
command[6] = Checksum(command); // add checksum
command[0] = (byte) 0xFF; // add synchronization byte
if (serialPort!=null && serialPort.isOpen()) serialPort.writeBytes(command, command.length);
if (isOpen()) {
Main.Max485Direction(true);
serialPort.writeBytes(command, command.length);
Main.Max485Direction(false);
Main.Blink_LedPanTilt();
}
}
/**
@@ -102,7 +123,12 @@ public class PanTiltController {
byte[] command = new byte[]{0, cameraid, 0, 8, speed, 0, 0};
command[6] = Checksum(command); // add checksum
command[0] = (byte) 0xFF; // add synchronization byte
if (serialPort!=null && serialPort.isOpen()) serialPort.writeBytes(command, command.length);
if (isOpen()) {
Main.Max485Direction(true);
serialPort.writeBytes(command, command.length);
Main.Max485Direction(false);
Main.Blink_LedPanTilt();
}
}
/**
@@ -116,7 +142,12 @@ public class PanTiltController {
byte[] command = new byte[]{0, cameraid, 0, 16, speed, 0, 0};
command[6] = Checksum(command); // add checksum
command[0] = (byte) 0xFF; // add synchronization byte
if (serialPort!=null && serialPort.isOpen()) serialPort.writeBytes(command, command.length);
if (isOpen()) {
Main.Max485Direction(true);
serialPort.writeBytes(command, command.length);
Main.Max485Direction(false);
Main.Blink_LedPanTilt();
}
}
/**

View File

@@ -111,11 +111,11 @@ public class RtspGrabber {
}
public String LQStreamingStatus(){
return gson.toJson(new String[]{String.valueOf(LQWidth), String.valueOf(LQHeight) , String.valueOf(grabbingTask.getCaptureFPS())});
return gson.toJson(new String[]{String.valueOf(LQWidth), String.valueOf(LQHeight) , String.valueOf(grabbingTask!=null ? grabbingTask.getCaptureFPS():"0")});
}
public String HQStreamingStatus(){
return gson.toJson(new String[]{String.valueOf(HQWidth), String.valueOf(HQHeight) , String.valueOf(grabbingTask.getCaptureFPS())});
return gson.toJson(new String[]{String.valueOf(HQWidth), String.valueOf(HQHeight) , String.valueOf(grabbingTask!=null ? grabbingTask.getCaptureFPS(): "0")});
}
@NotNull

View File

@@ -1,5 +1,6 @@
package Camera;
import lombok.Getter;
import org.tinylog.Logger;
import java.net.http.HttpClient;
@@ -27,7 +28,7 @@ public class VapixProtocol {
private String[] ImageResolutions = new String[0];
private String[] ImageFormats = new String[0];
private int CurrentZoomValue = 0;
@Getter private boolean successQuery = false;
/**
* Create a new VapixProtocol object
* @param ip The IP address of the camera
@@ -83,6 +84,7 @@ public class VapixProtocol {
if (ValidString(value)) ImageFormats = value.split(",");
//Logger.info("Format: "+value);
}
successQuery = true;
}
}