Aded puck detection using Esera

This commit is contained in:
gac-S_Changer
2018-01-09 10:52:06 +01:00
parent ff1bfbe15c
commit c4ce826ae8
4 changed files with 91 additions and 76 deletions

108
pom.xml
View File

@@ -1,55 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.psi</groupId>
<artifactId>MXSC</artifactId>
<version>1.5.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pshell</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>releases</id>
<name>releases</name>
<url>https://artifacts.psi.ch/artifactory/releases</url>
</repository>
<repository>
<id>libs-releases</id>
<name>libs-releases</name>
<url>https://artifacts.psi.ch/artifactory/libs-releases-local</url>
</repository>
<repository>
<id>libs-snapshots</id>
<name>libs-snapshots</name>
<url>https://artifacts.psi.ch/artifactory/libs-snapshots-local</url>
</repository>
</repositories>
<name>MXSC</name>
<build>
<!-- To remove the version numnber from jar
<finalName>${project.name}</finalName>
-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>../../pshell/home/plugins</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.psi</groupId>
<artifactId>MXSC</artifactId>
<version>1.8.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pshell</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>releases</id>
<name>releases</name>
<url>https://artifacts.psi.ch/artifactory/releases</url>
</repository>
<repository>
<id>libs-releases</id>
<name>libs-releases</name>
<url>https://artifacts.psi.ch/artifactory/libs-releases-local</url>
</repository>
<repository>
<id>libs-snapshots</id>
<name>libs-snapshots</name>
<url>https://artifacts.psi.ch/artifactory/libs-snapshots-local</url>
</repository>
</repositories>
<name>MXSC</name>
<build>
<!-- To remove the version numnber from jar
<finalName>${project.name}</finalName>
-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>../pshell/home/plugins</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -18,7 +18,15 @@ public class MainPanel extends Panel {
BasePlate basePlate;
/** Creates new form Panel */
static MainPanel instance;
static String PUCK_DETECTION_DEVICE = "onewire";
enum PuckSensorAccess{
RaspberryPi,
Esera;
}
final PuckSensorAccess puckSensorAccess = PuckSensorAccess.RaspberryPi;
static String PUCK_ESERA_DEVICE = "onewire";
public static final int NUMBER_OF_PUCKS = 30;
@@ -71,27 +79,29 @@ public class MainPanel extends Panel {
addDevice(basePlate);
clearPuckStates();
getContext().getDevicePool().addListener(new DevicePoolListener() {
@Override
public void onDeviceAdded(GenericDevice dev) {
if (dev.getName().equals(PUCK_DETECTION_DEVICE)){
detection = new EseraDetection((Device) dev);
if (puckSensorAccess == PuckSensorAccess.Esera){
getContext().getDevicePool().addListener(new DevicePoolListener() {
@Override
public void onDeviceAdded(GenericDevice dev) {
if (dev.getName().equals(PUCK_ESERA_DEVICE)){
detection = new EseraDetection((Device) dev);
}
}
}
@Override
public void onDeviceRemoved(GenericDevice dev) {
if (dev.getName().equals(PUCK_DETECTION_DEVICE)){
detection.close();
detection = null;
@Override
public void onDeviceRemoved(GenericDevice dev) {
if (dev.getName().equals(PUCK_ESERA_DEVICE)){
detection.close();
detection = null;
}
}
});
if (detection != null){
detection.close();
detection = null;
}
if ((Device) getDevice(PUCK_ESERA_DEVICE) != null){
detection = new EseraDetection((Device) getDevice(PUCK_ESERA_DEVICE));
}
});
if (detection != null){
detection.close();
detection = null;
}
if ((Device) getDevice(PUCK_DETECTION_DEVICE) != null){
detection = new EseraDetection((Device) getDevice(PUCK_DETECTION_DEVICE));
}
}

View File

@@ -211,10 +211,16 @@ public class Puck extends DeviceBase {
}
Font getLabelFont() {
if (plotRect != null){
return new Font("Times New Roman", Font.BOLD, 18);
}
return new Font("Times New Roman", Font.BOLD, 12);
}
Font getIdFont() {
if (plotRect != null){
return new Font("Times New Roman", Font.PLAIN, 12);
}
return new Font("Times New Roman", Font.PLAIN, 9);
}

View File

@@ -57,7 +57,6 @@ public class PuckDetection extends DeviceBase{
watchDog.start();
}
void subscriberTask(){
try{
setState(State.Ready);
@@ -68,9 +67,9 @@ public class PuckDetection extends DeviceBase{
try{
while (!Thread.currentThread().isInterrupted()) {
String type = subscriber.recvStr();
System.out.println(type);
//System.out.println(type);
String contents = subscriber.recvStr();
System.out.println(contents);
//System.out.println(contents);
processMessage(contents);
if (MainPanel.getInstance()!=null){
MainPanel.getInstance().repaint();